summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/alias.test129
-rw-r--r--mysql-test/t/alter_table.test102
-rw-r--r--mysql-test/t/archive.test69
-rw-r--r--mysql-test/t/archive_debug.test13
-rw-r--r--mysql-test/t/archive_plugin-master.opt1
-rw-r--r--mysql-test/t/archive_plugin.test35
-rw-r--r--mysql-test/t/auto_increment.test2
-rwxr-xr-xmysql-test/t/backup-master.sh5
-rw-r--r--mysql-test/t/backup.test104
-rw-r--r--mysql-test/t/blackhole_plugin-master.opt1
-rw-r--r--mysql-test/t/blackhole_plugin.test34
-rw-r--r--mysql-test/t/bootstrap-master.opt1
-rw-r--r--mysql-test/t/bootstrap.test16
-rw-r--r--mysql-test/t/bug46080-master.opt2
-rw-r--r--mysql-test/t/bug46080.test2
-rw-r--r--mysql-test/t/bug46261.test2
-rw-r--r--mysql-test/t/bug46760.test2
-rw-r--r--mysql-test/t/bug47671-master.opt2
-rw-r--r--mysql-test/t/bug58669-master.opt1
-rw-r--r--mysql-test/t/bug58669.test22
-rw-r--r--mysql-test/t/cache_innodb-master.opt2
-rw-r--r--mysql-test/t/cache_innodb.test15
-rw-r--r--mysql-test/t/case.test3
-rw-r--r--mysql-test/t/cast.test16
-rw-r--r--mysql-test/t/change_user.test50
-rw-r--r--mysql-test/t/check.test24
-rw-r--r--mysql-test/t/comment_column.test130
-rw-r--r--mysql-test/t/comment_column2.test172
-rw-r--r--mysql-test/t/comment_index.test100
-rw-r--r--mysql-test/t/comment_table.test55
-rw-r--r--mysql-test/t/commit.test350
-rw-r--r--mysql-test/t/commit_1innodb.test2
-rw-r--r--mysql-test/t/connect.test28
-rw-r--r--mysql-test/t/constraints.test44
-rw-r--r--mysql-test/t/count_distinct.test11
-rw-r--r--mysql-test/t/count_distinct2-master.opt2
-rw-r--r--mysql-test/t/crash_commit_before-master.opt3
-rw-r--r--mysql-test/t/crash_commit_before.test2
-rw-r--r--mysql-test/t/create.test484
-rw-r--r--mysql-test/t/create_select_tmp.test4
-rw-r--r--mysql-test/t/csv.test80
-rw-r--r--mysql-test/t/ctype_big5.test61
-rw-r--r--mysql-test/t/ctype_binary.test12
-rw-r--r--mysql-test/t/ctype_collate.test12
-rw-r--r--mysql-test/t/ctype_cp1250_ch.test10
-rw-r--r--mysql-test/t/ctype_cp1251.test40
-rw-r--r--mysql-test/t/ctype_cp932_binlog_stm.test105
-rw-r--r--mysql-test/t/ctype_errors.test47
-rw-r--r--mysql-test/t/ctype_eucjpms.test113
-rw-r--r--mysql-test/t/ctype_euckr.test65
-rw-r--r--mysql-test/t/ctype_gb2312.test91
-rw-r--r--mysql-test/t/ctype_gbk.test91
-rw-r--r--mysql-test/t/ctype_latin1.test29
-rw-r--r--mysql-test/t/ctype_latin1_de-master.opt2
-rw-r--r--mysql-test/t/ctype_ldml.test74
-rw-r--r--mysql-test/t/ctype_like_range.test87
-rw-r--r--mysql-test/t/ctype_many.test92
-rw-r--r--mysql-test/t/ctype_sjis.test97
-rw-r--r--mysql-test/t/ctype_uca.test16
-rw-r--r--mysql-test/t/ctype_ucs.test20
-rw-r--r--mysql-test/t/ctype_ucs2_def-master.opt2
-rw-r--r--mysql-test/t/ctype_ujis.test102
-rw-r--r--mysql-test/t/ctype_utf16.test764
-rw-r--r--mysql-test/t/ctype_utf16_def-master.opt1
-rw-r--r--mysql-test/t/ctype_utf16_def.test8
-rw-r--r--mysql-test/t/ctype_utf16_uca.test297
-rw-r--r--mysql-test/t/ctype_utf32.test845
-rw-r--r--mysql-test/t/ctype_utf32_uca.test299
-rw-r--r--mysql-test/t/ctype_utf8-master.opt1
-rw-r--r--mysql-test/t/ctype_utf8.test142
-rw-r--r--mysql-test/t/ctype_utf8mb4-master.opt1
-rw-r--r--mysql-test/t/ctype_utf8mb4.test1820
-rw-r--r--mysql-test/t/ctype_utf8mb4_heap.test6
-rw-r--r--mysql-test/t/ctype_utf8mb4_innodb-master.opt1
-rw-r--r--mysql-test/t/ctype_utf8mb4_innodb.test6
-rw-r--r--mysql-test/t/ctype_utf8mb4_myisam.test5
-rw-r--r--mysql-test/t/date_formats.test139
-rw-r--r--mysql-test/t/ddl_i18n_koi8r.test26
-rw-r--r--mysql-test/t/ddl_i18n_utf8.test26
-rw-r--r--mysql-test/t/debug_sync.test2
-rw-r--r--mysql-test/t/delayed.test267
-rw-r--r--mysql-test/t/delete.test181
-rw-r--r--mysql-test/t/deprecated_features.test27
-rw-r--r--mysql-test/t/derived.test24
-rw-r--r--mysql-test/t/dirty_close.test33
-rw-r--r--mysql-test/t/disabled.def11
-rw-r--r--mysql-test/t/distinct.test13
-rw-r--r--mysql-test/t/drop-no_root.test85
-rw-r--r--mysql-test/t/drop.test73
-rw-r--r--mysql-test/t/drop_debug.test38
-rw-r--r--mysql-test/t/endspace.test6
-rw-r--r--mysql-test/t/errors.test104
-rw-r--r--mysql-test/t/events_1.test109
-rw-r--r--mysql-test/t/events_2.test55
-rw-r--r--mysql-test/t/events_bugs.test90
-rw-r--r--mysql-test/t/events_restart.test2
-rw-r--r--mysql-test/t/events_trans.test25
-rw-r--r--mysql-test/t/exampledb.test22
-rw-r--r--mysql-test/t/execution_constants.test2
-rw-r--r--mysql-test/t/explain.test35
-rw-r--r--mysql-test/t/file_contents.test68
-rw-r--r--mysql-test/t/filesort_debug.test59
-rw-r--r--mysql-test/t/fix_priv_tables.test2
-rw-r--r--mysql-test/t/flush.test479
-rw-r--r--mysql-test/t/flush_block_commit.test33
-rw-r--r--mysql-test/t/flush_block_commit_notembedded.test27
-rw-r--r--mysql-test/t/flush_read_lock.test2192
-rw-r--r--mysql-test/t/flush_read_lock_kill-master.opt1
-rw-r--r--mysql-test/t/flush_read_lock_kill.test68
-rw-r--r--mysql-test/t/flush_table.test25
-rw-r--r--mysql-test/t/foreign_key.test72
-rw-r--r--mysql-test/t/fulltext.test12
-rw-r--r--mysql-test/t/fulltext_plugin.test3
-rw-r--r--mysql-test/t/func_analyse.test (renamed from mysql-test/t/analyse.test)24
-rw-r--r--mysql-test/t/func_des_encrypt.test2
-rw-r--r--mysql-test/t/func_digest.test496
-rw-r--r--mysql-test/t/func_encrypt.test2
-rw-r--r--mysql-test/t/func_encrypt_ucs2.test12
-rw-r--r--mysql-test/t/func_gconcat.test37
-rw-r--r--mysql-test/t/func_group.test63
-rw-r--r--mysql-test/t/func_group_innodb.test50
-rw-r--r--mysql-test/t/func_if.test12
-rw-r--r--mysql-test/t/func_in.test6
-rw-r--r--mysql-test/t/func_isnull.test12
-rw-r--r--mysql-test/t/func_math.test211
-rw-r--r--mysql-test/t/func_misc.test60
-rw-r--r--mysql-test/t/func_sapdb.test22
-rw-r--r--mysql-test/t/func_set.test22
-rw-r--r--mysql-test/t/func_str.test60
-rw-r--r--mysql-test/t/func_test.test2
-rw-r--r--mysql-test/t/func_time.test122
-rw-r--r--mysql-test/t/gis-rtree.test28
-rw-r--r--mysql-test/t/gis.test67
-rw-r--r--mysql-test/t/grant.test640
-rw-r--r--mysql-test/t/grant2.test4
-rw-r--r--mysql-test/t/grant4.test146
-rw-r--r--mysql-test/t/group_by.test63
-rw-r--r--mysql-test/t/group_min_max.test144
-rw-r--r--mysql-test/t/handler_read_last.test40
-rw-r--r--mysql-test/t/having.test26
-rw-r--r--mysql-test/t/heap_hash.test17
-rw-r--r--mysql-test/t/implicit_char_to_num_conversion.test174
-rw-r--r--mysql-test/t/implicit_commit-master.opt1
-rw-r--r--mysql-test/t/implicit_commit.test1166
-rw-r--r--mysql-test/t/index_merge_innodb.test14
-rw-r--r--mysql-test/t/index_merge_myisam.test1
-rw-r--r--mysql-test/t/information_schema-big.test48
-rw-r--r--mysql-test/t/information_schema.test215
-rw-r--r--mysql-test/t/information_schema_db.test15
-rw-r--r--mysql-test/t/information_schema_inno.test20
-rw-r--r--mysql-test/t/information_schema_parameters.test251
-rw-r--r--mysql-test/t/information_schema_routines.test247
-rw-r--r--mysql-test/t/init_connect-master.opt2
-rw-r--r--mysql-test/t/innodb_mysql_lock-master.opt1
-rw-r--r--mysql-test/t/innodb_mysql_lock.test320
-rw-r--r--mysql-test/t/innodb_mysql_lock2.test218
-rw-r--r--mysql-test/t/innodb_mysql_sync.test309
-rw-r--r--mysql-test/t/insert.test38
-rw-r--r--mysql-test/t/insert_notembedded.test3
-rw-r--r--mysql-test/t/insert_select.test2
-rw-r--r--mysql-test/t/ipv4_as_ipv6-master.opt1
-rw-r--r--mysql-test/t/ipv4_as_ipv6.test64
-rw-r--r--mysql-test/t/ipv6-master.opt1
-rw-r--r--mysql-test/t/ipv6.test36
-rw-r--r--mysql-test/t/join_optimizer.test45
-rw-r--r--mysql-test/t/join_outer.test206
-rw-r--r--mysql-test/t/join_outer_innodb.test37
-rw-r--r--mysql-test/t/key_cache.test9
-rw-r--r--mysql-test/t/keywords.test100
-rw-r--r--mysql-test/t/kill.test681
-rw-r--r--mysql-test/t/loaddata.test38
-rw-r--r--mysql-test/t/loadxml.test118
-rw-r--r--mysql-test/t/locale.test38
-rw-r--r--mysql-test/t/lock.test341
-rw-r--r--mysql-test/t/lock_multi.test612
-rw-r--r--mysql-test/t/lock_sync-master.opt1
-rw-r--r--mysql-test/t/lock_sync.test443
-rw-r--r--mysql-test/t/log_state.test97
-rw-r--r--mysql-test/t/log_state_bug33693-master.opt1
-rw-r--r--mysql-test/t/log_state_bug33693.test18
-rw-r--r--mysql-test/t/log_tables.test21
-rw-r--r--mysql-test/t/log_tables_debug.test1
-rw-r--r--mysql-test/t/lowercase_fs_off.test11
-rw-r--r--mysql-test/t/lowercase_table2.test109
-rwxr-xr-xmysql-test/t/lowercase_table4.test52
-rw-r--r--mysql-test/t/mdl_sync-master.opt1
-rw-r--r--mysql-test/t/mdl_sync.test4609
-rw-r--r--mysql-test/t/merge-big.test4
-rw-r--r--mysql-test/t/merge.test1097
-rw-r--r--mysql-test/t/merge_mmap-master.opt1
-rw-r--r--mysql-test/t/merge_mmap.test151
-rw-r--r--mysql-test/t/merge_recover-master.opt1
-rw-r--r--mysql-test/t/merge_recover.test113
-rw-r--r--mysql-test/t/metadata.test57
-rw-r--r--mysql-test/t/multi_update-master.opt2
-rw-r--r--mysql-test/t/multi_update.test37
-rw-r--r--mysql-test/t/multi_update2-master.opt2
-rw-r--r--mysql-test/t/multi_update_innodb.test33
-rw-r--r--mysql-test/t/multi_update_tiny_hash-master.opt2
-rw-r--r--mysql-test/t/myisam.test34
-rw-r--r--mysql-test/t/myisam_crash_before_flush_keys.test5
-rw-r--r--mysql-test/t/myisampack.test114
-rw-r--r--mysql-test/t/mysql.test19
-rw-r--r--mysql-test/t/mysql_client_test-master.opt5
-rw-r--r--mysql-test/t/mysql_client_test.test11
-rw-r--r--[-rwxr-xr-x]mysql-test/t/mysql_delimiter_19799.sql0
-rw-r--r--mysql-test/t/mysql_locale_posix.test205
-rw-r--r--mysql-test/t/mysql_not_windows.test15
-rw-r--r--mysql-test/t/mysql_upgrade.test38
-rw-r--r--mysql-test/t/mysql_upgrade_ssl.test10
-rw-r--r--mysql-test/t/mysqladmin.test20
-rw-r--r--mysql-test/t/mysqlbinlog.test78
-rw-r--r--mysql-test/t/mysqlbinlog2.test24
-rw-r--r--mysql-test/t/mysqlbinlog_base64.test29
-rw-r--r--mysql-test/t/mysqlcheck.test139
-rw-r--r--mysql-test/t/mysqld--defaults-file.test47
-rw-r--r--mysql-test/t/mysqld--help-notwin.test24
-rw-r--r--mysql-test/t/mysqld--help-win.test24
-rw-r--r--mysql-test/t/mysqldump-max-master.opt1
-rw-r--r--mysql-test/t/mysqldump.test74
-rw-r--r--mysql-test/t/mysqlshow.test4
-rw-r--r--mysql-test/t/mysqlslap.test15
-rw-r--r--mysql-test/t/mysqltest.test252
-rw-r--r--mysql-test/t/named_pipe.test5
-rw-r--r--mysql-test/t/no-threads.test1
-rw-r--r--mysql-test/t/not_embedded_server.test111
-rw-r--r--mysql-test/t/not_partition.test1
-rw-r--r--mysql-test/t/odbc.test4
-rw-r--r--mysql-test/t/openssl_1.test2
-rw-r--r--mysql-test/t/optimizer_switch_eng_cond_pushdown1-master.opt1
-rw-r--r--mysql-test/t/optimizer_switch_eng_cond_pushdown1.test5
-rw-r--r--mysql-test/t/optimizer_switch_eng_cond_pushdown2-master.opt1
-rw-r--r--mysql-test/t/optimizer_switch_eng_cond_pushdown2.test5
-rw-r--r--mysql-test/t/order_by.test47
-rw-r--r--mysql-test/t/order_fill_sortbuf-master.opt2
-rw-r--r--mysql-test/t/outfile.test2
-rw-r--r--mysql-test/t/parser.test5
-rw-r--r--mysql-test/t/parser_not_embedded.test75
-rw-r--r--mysql-test/t/parser_stack.test8
-rw-r--r--mysql-test/t/partition.test274
-rw-r--r--mysql-test/t/partition_archive.test21
-rw-r--r--mysql-test/t/partition_binlog.test42
-rw-r--r--mysql-test/t/partition_column.test510
-rw-r--r--mysql-test/t/partition_column_prune.test71
-rw-r--r--mysql-test/t/partition_datatype.test9
-rw-r--r--mysql-test/t/partition_debug_sync.test18
-rw-r--r--mysql-test/t/partition_error.test241
-rw-r--r--mysql-test/t/partition_innodb-master.opt1
-rw-r--r--mysql-test/t/partition_innodb.test203
-rw-r--r--mysql-test/t/partition_innodb_builtin.test67
-rw-r--r--mysql-test/t/partition_innodb_plugin.test8
-rw-r--r--mysql-test/t/partition_innodb_semi_consistent-master.opt2
-rw-r--r--mysql-test/t/partition_innodb_semi_consistent.test5
-rw-r--r--mysql-test/t/partition_innodb_stmt.test2
-rw-r--r--mysql-test/t/partition_key_cache.test251
-rw-r--r--mysql-test/t/partition_list.test2
-rw-r--r--mysql-test/t/partition_mgm_err.test2
-rw-r--r--mysql-test/t/partition_myisam.test182
-rw-r--r--mysql-test/t/partition_not_embedded.test53
-rw-r--r--mysql-test/t/partition_pruning.test39
-rw-r--r--mysql-test/t/partition_range.test85
-rw-r--r--mysql-test/t/partition_symlink.test11
-rw-r--r--mysql-test/t/partition_sync.test93
-rw-r--r--mysql-test/t/partition_truncate.test33
-rw-r--r--mysql-test/t/partition_utf8.test42
-rw-r--r--mysql-test/t/perror.test15
-rw-r--r--mysql-test/t/plugin.test16
-rw-r--r--mysql-test/t/plugin_auth-master.opt2
-rw-r--r--mysql-test/t/plugin_auth.test515
-rw-r--r--mysql-test/t/plugin_auth_qa-master.opt2
-rw-r--r--mysql-test/t/plugin_auth_qa.test338
-rw-r--r--mysql-test/t/plugin_auth_qa_1-master.opt2
-rw-r--r--mysql-test/t/plugin_auth_qa_1.test340
-rw-r--r--mysql-test/t/plugin_auth_qa_2-master.opt2
-rw-r--r--mysql-test/t/plugin_auth_qa_2.test153
-rw-r--r--mysql-test/t/plugin_auth_qa_3-master.opt2
-rw-r--r--mysql-test/t/plugin_auth_qa_3.test25
-rw-r--r--mysql-test/t/plugin_load_option-master.opt3
-rw-r--r--mysql-test/t/plugin_load_option.test8
-rw-r--r--mysql-test/t/plugin_not_embedded.test4
-rw-r--r--mysql-test/t/profiling.test6
-rw-r--r--mysql-test/t/ps-master.opt2
-rw-r--r--mysql-test/t/ps.test260
-rw-r--r--mysql-test/t/ps_1general.test3
-rw-r--r--mysql-test/t/ps_3innodb-master.opt1
-rw-r--r--mysql-test/t/ps_3innodb.test4
-rw-r--r--mysql-test/t/ps_ddl.test83
-rw-r--r--mysql-test/t/ps_ddl1.test2
-rw-r--r--mysql-test/t/ps_not_windows.test4
-rw-r--r--mysql-test/t/query_cache.test145
-rw-r--r--mysql-test/t/query_cache_28249.test8
-rw-r--r--mysql-test/t/query_cache_debug.test143
-rw-r--r--mysql-test/t/query_cache_disabled-master.opt1
-rw-r--r--mysql-test/t/query_cache_disabled.test15
-rw-r--r--mysql-test/t/query_cache_notembedded.test1
-rw-r--r--mysql-test/t/read_only_innodb.test148
-rw-r--r--mysql-test/t/rename.test14
-rw-r--r--mysql-test/t/repair.test30
-rw-r--r--mysql-test/t/rpl_mysqldump_slave.test30
-rw-r--r--mysql-test/t/schema.test143
-rw-r--r--mysql-test/t/select.test151
-rw-r--r--mysql-test/t/select_safe.test4
-rw-r--r--mysql-test/t/shm.test15
-rw-r--r--mysql-test/t/show_check-master.opt2
-rw-r--r--mysql-test/t/show_check.test243
-rw-r--r--mysql-test/t/show_profile.test18
-rw-r--r--mysql-test/t/signal.test2688
-rw-r--r--mysql-test/t/signal_code.test57
-rw-r--r--mysql-test/t/signal_demo1.test345
-rw-r--r--mysql-test/t/signal_demo2.test207
-rw-r--r--mysql-test/t/signal_demo3.test159
-rw-r--r--mysql-test/t/signal_sqlmode.test123
-rw-r--r--mysql-test/t/single_delete_update.test481
-rw-r--r--mysql-test/t/skip_name_resolve.test2
-rw-r--r--mysql-test/t/sp-code.test53
-rw-r--r--mysql-test/t/sp-destruct.test83
-rw-r--r--mysql-test/t/sp-error.test425
-rw-r--r--mysql-test/t/sp-lock.test1141
-rw-r--r--mysql-test/t/sp-no-code.test12
-rw-r--r--mysql-test/t/sp-security.test37
-rw-r--r--mysql-test/t/sp-ucs2.test120
-rw-r--r--mysql-test/t/sp-vars.test39
-rw-r--r--mysql-test/t/sp.test484
-rw-r--r--mysql-test/t/sp_notembedded.test54
-rw-r--r--mysql-test/t/sp_sync.test161
-rw-r--r--mysql-test/t/sp_trans.test70
-rw-r--r--mysql-test/t/sp_trans_log.test7
-rw-r--r--mysql-test/t/sql_mode.test15
-rw-r--r--mysql-test/t/ssl-big.test4
-rw-r--r--mysql-test/t/ssl.test4
-rw-r--r--mysql-test/t/ssl_8k_key.test4
-rw-r--r--mysql-test/t/ssl_and_innodb.test11
-rw-r--r--mysql-test/t/ssl_cipher-master.opt1
-rw-r--r--mysql-test/t/ssl_cipher.test23
-rw-r--r--mysql-test/t/ssl_compress.test4
-rw-r--r--mysql-test/t/ssl_connect.test5
-rw-r--r--mysql-test/t/status.test3
-rw-r--r--mysql-test/t/status_bug17954.test54
-rw-r--r--mysql-test/t/strict-master.opt1
-rw-r--r--mysql-test/t/strict.test99
-rw-r--r--mysql-test/t/subselect.test321
-rw-r--r--mysql-test/t/subselect3.test47
-rw-r--r--mysql-test/t/subselect4.test29
-rw-r--r--mysql-test/t/subselect_innodb.test9
-rw-r--r--mysql-test/t/symlink.test38
-rw-r--r--mysql-test/t/system_mysql_db_fix30020.test108
-rw-r--r--mysql-test/t/system_mysql_db_fix40123.test10
-rw-r--r--mysql-test/t/system_mysql_db_fix50030.test12
-rw-r--r--mysql-test/t/system_mysql_db_fix50117.test10
-rw-r--r--mysql-test/t/tablespace.test122
-rw-r--r--mysql-test/t/temp_table.test15
-rw-r--r--mysql-test/t/trigger-compat.test180
-rw-r--r--mysql-test/t/trigger-trans.test5
-rw-r--r--mysql-test/t/trigger.test161
-rw-r--r--mysql-test/t/trigger_notembedded.test2
-rw-r--r--mysql-test/t/truncate.test96
-rw-r--r--mysql-test/t/truncate_coverage.test228
-rw-r--r--mysql-test/t/type_blob.test33
-rw-r--r--mysql-test/t/type_date.test38
-rw-r--r--mysql-test/t/type_datetime.test81
-rw-r--r--mysql-test/t/type_decimal.test63
-rw-r--r--mysql-test/t/type_float.test33
-rw-r--r--mysql-test/t/type_newdecimal.test31
-rw-r--r--mysql-test/t/type_time.test20
-rw-r--r--mysql-test/t/type_timestamp.test92
-rw-r--r--mysql-test/t/type_varchar.test18
-rw-r--r--mysql-test/t/type_year.test10
-rw-r--r--mysql-test/t/udf.test83
-rw-r--r--mysql-test/t/union-master.opt2
-rw-r--r--mysql-test/t/union.test193
-rw-r--r--mysql-test/t/user_limits.test2
-rw-r--r--mysql-test/t/user_var.test55
-rw-r--r--mysql-test/t/variables-big.test3
-rw-r--r--mysql-test/t/variables-notembedded.test27
-rw-r--r--mysql-test/t/variables.test295
-rw-r--r--mysql-test/t/variables_community.test2
-rw-r--r--mysql-test/t/variables_debug.test85
-rw-r--r--mysql-test/t/view.test195
-rw-r--r--mysql-test/t/view_grant.test12
-rw-r--r--mysql-test/t/warnings.test45
-rw-r--r--[-rwxr-xr-x]mysql-test/t/windows.test0
-rw-r--r--mysql-test/t/wl4435_generated.inc588
-rw-r--r--mysql-test/t/xa.test156
-rw-r--r--mysql-test/t/xml.test20
384 files changed, 41541 insertions, 2190 deletions
diff --git a/mysql-test/t/alias.test b/mysql-test/t/alias.test
index 6546581eef2..0e2d57598e2 100644
--- a/mysql-test/t/alias.test
+++ b/mysql-test/t/alias.test
@@ -86,3 +86,132 @@ ASC LIMIT 1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#27249 table_wild with alias: select t1.* as something
+#
+
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+create table t1 (a int, b int, c int);
+create table t2 (d int);
+create table t3 (a1 int, b1 int, c1 int);
+insert into t1 values(1,2,3);
+insert into t1 values(11,22,33);
+insert into t2 values(99);
+
+# Invalid queries with alias on wild
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t2.* as 'with_alias' from t2;
+--error ER_PARSE_ERROR
+select t1.*, t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', t1.* from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', t1.* as 'alias2' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', a, t1.* as 'alias2' from t1;
+
+# other fields without alias
+--error ER_PARSE_ERROR
+select a, t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', a from t1;
+--error ER_PARSE_ERROR
+select a, t1.* as 'with_alias', b from t1;
+--error ER_PARSE_ERROR
+select (select d from t2 where d > a), t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', (select a from t2 where d > a) from t1;
+
+# other fields with alias
+--error ER_PARSE_ERROR
+select a as 'x', t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', a as 'x' from t1;
+--error ER_PARSE_ERROR
+select a as 'x', t1.* as 'with_alias', b as 'x' from t1;
+--error ER_PARSE_ERROR
+select (select d from t2 where d > a) as 'x', t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+select t1.* as 'with_alias', (select a from t2 where d > a) as 'x' from t1;
+
+# some more subquery
+--error ER_PARSE_ERROR
+select (select t2.* as 'x' from t2) from t1;
+--error ER_PARSE_ERROR
+select a, (select t2.* as 'x' from t2) from t1;
+--error ER_PARSE_ERROR
+select t1.*, (select t2.* as 'x' from t2) from t1;
+
+# insert
+--error ER_PARSE_ERROR
+insert into t3 select t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+insert into t3 select t2.* as 'with_alias', 1, 2 from t2;
+--error ER_PARSE_ERROR
+insert into t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2;
+--error ER_PARSE_ERROR
+insert into t3 select t2.*, t2.* as 'with_alias', 3 from t2;
+
+# create
+--error ER_PARSE_ERROR
+create table t3 select t1.* as 'with_alias' from t1;
+--error ER_PARSE_ERROR
+create table t3 select t2.* as 'with_alias', 1, 2 from t2;
+--error ER_PARSE_ERROR
+create table t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2;
+--error ER_PARSE_ERROR
+create table t3 select t2.*, t2.* as 'with_alias', 3 from t2;
+
+#
+# Valid queries without alias on wild
+# (proof the above fail due to invalid aliasing)
+#
+
+select t1.* from t1;
+select t2.* from t2;
+select t1.*, t1.* from t1;
+select t1.*, a, t1.* from t1;
+
+# other fields without alias
+select a, t1.* from t1;
+select t1.*, a from t1;
+select a, t1.*, b from t1;
+select (select d from t2 where d > a), t1.* from t1;
+select t1.*, (select a from t2 where d > a) from t1;
+
+# other fields with alias
+select a as 'x', t1.* from t1;
+select t1.*, a as 'x' from t1;
+select a as 'x', t1.*, b as 'x' from t1;
+select (select d from t2 where d > a) as 'x', t1.* from t1;
+select t1.*, (select a from t2 where d > a) as 'x' from t1;
+
+# some more subquery
+select (select t2.* from t2) from t1;
+select a, (select t2.* from t2) from t1;
+select t1.*, (select t2.* from t2) from t1;
+
+# insert
+insert into t3 select t1.* from t1;
+insert into t3 select t2.*, 1, 2 from t2;
+insert into t3 select t2.*, d as 'x', d as 'z' from t2;
+insert into t3 select t2.*, t2.*, 3 from t2;
+
+# create
+create table t4 select t1.* from t1;
+drop table t4;
+create table t4 select t2.*, 1, 2 from t2;
+drop table t4;
+create table t4 select t2.*, d as 'x', d as 'z' from t2;
+drop table t4;
+
+# end
+drop table t1,t2,t3;
+
+# End of 5.2 tests
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index 4989a6c380c..38d0d08808a 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -1074,3 +1074,105 @@ DROP TABLE t1;
--echo End of 5.1 tests
+
+#
+# Bug #31031 ALTER TABLE regression in 5.0
+#
+# The ALTER TABLE operation failed with
+# ERROR 1089 (HY000): Incorrect sub part key; ...
+#
+CREATE TABLE t1(c CHAR(10),
+ i INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY);
+INSERT INTO t1 VALUES('a',2),('b',4),('c',6);
+ALTER TABLE t1
+ DROP i,
+ ADD i INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ AUTO_INCREMENT = 1;
+DROP TABLE t1;
+
+
+#
+# Bug#50542 5.5.x doesn't check length of key prefixes:
+# corruption and crash results
+#
+# This case is related to Bug#31031 (above)
+# A statement where the index key is larger/wider than
+# the column type, should cause an error
+#
+--error ER_WRONG_SUB_KEY
+CREATE TABLE t1 (a CHAR(1), PRIMARY KEY (a(255)));
+
+# Test other variants of creating indices
+CREATE TABLE t1 (a CHAR(1));
+# ALTER TABLE
+--error ER_WRONG_SUB_KEY
+ALTER TABLE t1 ADD PRIMARY KEY (a(20));
+--error ER_WRONG_SUB_KEY
+ALTER TABLE t1 ADD KEY (a(20));
+# CREATE INDEX
+--error ER_WRONG_SUB_KEY
+CREATE UNIQUE INDEX i1 ON t1 (a(20));
+--error ER_WRONG_SUB_KEY
+CREATE INDEX i2 ON t1 (a(20));
+# cleanup
+DROP TABLE t1;
+
+
+#
+# Bug #45052 ALTER TABLE ADD COLUMN crashes server with multiple foreign key columns
+# The alter table fails if 2 or more new fields added and
+# also added a key with these fields
+#
+CREATE TABLE t1 (id int);
+INSERT INTO t1 VALUES (1), (2);
+ALTER TABLE t1 ADD COLUMN (f1 INT), ADD COLUMN (f2 INT), ADD KEY f2k(f2);
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test for bug #53820 "ALTER a MEDIUMINT column table causes full
+--echo # table copy".
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a INT, b MEDIUMINT);
+INSERT INTO t1 VALUES (1, 1), (2, 2);
+--echo # The below ALTER should not copy table and so no rows should
+--echo # be shown as affected.
+--enable_info
+ALTER TABLE t1 CHANGE a id INT;
+--disable_info
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#11754461 CANNOT ALTER TABLE WHEN KEY PREFIX TOO LONG
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+--enable_warnings
+
+CREATE DATABASE db1 CHARACTER SET utf8;
+CREATE TABLE db1.t1 (bar TINYTEXT, KEY (bar(100)));
+ALTER TABLE db1.t1 ADD baz INT;
+
+DROP DATABASE db1;
+
+
+--echo #
+--echo # Bug#11938039 RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME
+--echo # CLAUSE FAILS OR ABORTS SERVER.
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+prepare stmt1 from 'alter table t1 alter column a set default 1, rename to t2';
+execute stmt1;
+rename table t2 to t1;
+--echo # The below statement should succeed and not emit error or abort server.
+execute stmt1;
+deallocate prepare stmt1;
+drop table t2;
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index 7084f5f540e..4686b3ca1dc 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -5,6 +5,8 @@
-- source include/have_archive.inc
-- source include/have_binlog_format_mixed_or_statement.inc
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+
--disable_warnings
DROP TABLE if exists t1,t2,t3,t4,t5,t6;
--enable_warnings
@@ -1615,7 +1617,7 @@ DROP TABLE t1;
# BUG#46961 - archive engine loses rows during self joining select!
#
SET @save_join_buffer_size= @@join_buffer_size;
-SET @@join_buffer_size= 8228;
+SET @@join_buffer_size= 8192;
CREATE TABLE t1(a CHAR(255)) ENGINE=archive;
INSERT INTO t1 VALUES('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
@@ -1624,6 +1626,18 @@ SELECT COUNT(t1.a) FROM t1, t1 a, t1 b, t1 c, t1 d, t1 e;
DROP TABLE t1;
SET @@join_buffer_size= @save_join_buffer_size;
+--echo End of 5.1 tests
+
+#
+# BUG#40677 - Archive tables joined on primary return no result
+#
+CREATE TABLE t1(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t1 VALUES(NULL,'a'),(NULL,'a');
+CREATE TABLE t2(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, PRIMARY KEY(id)) ENGINE=archive;
+INSERT INTO t2 VALUES(NULL,'b'),(NULL,'b');
+SELECT t1.id, t2.id, t1.name, t2.name FROM t1,t2 WHERE t1.id = t2.id;
+DROP TABLE t1,t2;
+
#
# BUG#47012 archive tables are not upgradeable, and server crashes on any access
#
@@ -1656,6 +1670,15 @@ SELECT * FROM t1;
--error ER_BAD_TABLE_ERROR
DROP TABLE t1;
+--echo #
+--echo # Ensure that TRUNCATE fails for non-empty archive tables.
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=ARCHIVE;
+INSERT INTO t1 VALUES (1);
+--error ER_ILLEGAL_HA
+TRUNCATE TABLE t1;
+DROP TABLE t1;
+
--echo #
--echo # BUG#46565 - repair of partition fail for archive engine
@@ -1678,3 +1701,47 @@ SELECT * FROM t1;
REPAIR TABLE t1 EXTENDED;
SELECT * FROM t1;
DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a int) ENGINE=ARCHIVE;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (1);
+OPTIMIZE TABLE t1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/t1.frm;
+FLUSH TABLES;
+INSERT INTO t1 VALUES (2);
+SELECT * FROM t1 ORDER BY a;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # BUG#58205 - Valgrind failure in fn_format when called from
+--echo # archive_discover
+--echo #
+CREATE TABLE `a/../`(a INT) ENGINE=ARCHIVE;
+remove_file $MYSQLD_DATADIR/test/a@002f@002e@002e@002f.frm;
+DROP TABLE `a/../`;
+
+--echo #
+--echo # BUG#57162 - valgrind errors, random data when returning
+--echo # ordered data from archive tables
+--echo #
+SET sort_buffer_size=32804;
+CREATE TABLE t1(a INT, b CHAR(255), c CHAR(255), d CHAR(255),
+ e CHAR(255), f INT) ENGINE=ARCHIVE DEFAULT CHARSET utf8;
+INSERT INTO t1 VALUES(-1,'b','c','d','e',1);
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT t1.* FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6;
+SELECT * FROM t1 ORDER BY f LIMIT 1;
+DROP TABLE t1;
+SET sort_buffer_size=DEFAULT;
diff --git a/mysql-test/t/archive_debug.test b/mysql-test/t/archive_debug.test
new file mode 100644
index 00000000000..9cece254140
--- /dev/null
+++ b/mysql-test/t/archive_debug.test
@@ -0,0 +1,13 @@
+--source include/have_archive.inc
+--source include/have_debug.inc
+
+--echo #
+--echo # BUG#12402794 - 60976: CRASH, VALGRIND WARNING AND MEMORY LEAK
+--echo # WITH PARTITIONED ARCHIVE TABLES
+--echo #
+CREATE TABLE t1(a INT) ENGINE=ARCHIVE;
+INSERT INTO t1 VALUES(1);
+SET SESSION debug='d,simulate_archive_open_failure';
+CHECK TABLE t1;
+SET SESSION debug=DEFAULT;
+DROP TABLE t1;
diff --git a/mysql-test/t/archive_plugin-master.opt b/mysql-test/t/archive_plugin-master.opt
new file mode 100644
index 00000000000..36b21a74922
--- /dev/null
+++ b/mysql-test/t/archive_plugin-master.opt
@@ -0,0 +1 @@
+--plugin_dir=$ARCHIVE_PLUGIN_DIR
diff --git a/mysql-test/t/archive_plugin.test b/mysql-test/t/archive_plugin.test
new file mode 100644
index 00000000000..7d9b0ea065f
--- /dev/null
+++ b/mysql-test/t/archive_plugin.test
@@ -0,0 +1,35 @@
+--source include/not_windows.inc
+--source include/have_archive_plugin.inc
+
+# When running in parallel we get
+# Warning 1620 Plugin is busy and will be uninstalled on shutdown
+--source include/not_parallel.inc
+
+CREATE TABLE t1(a int) ENGINE=ARCHIVE;
+DROP TABLE t1;
+
+INSTALL PLUGIN archive SONAME 'ha_archive.so';
+--error 1125
+INSTALL PLUGIN ARCHIVE SONAME 'ha_archive.so';
+
+UNINSTALL PLUGIN archive;
+
+INSTALL PLUGIN archive SONAME 'ha_archive.so';
+
+CREATE TABLE t1(a int) ENGINE=ARCHIVE;
+
+DROP TABLE t1;
+
+# This dummy statement is required for --ps-protocol mode.
+# The thing is that last prepared statement is "cached" in mysqltest.cc
+# (unless "reconnect" is enabled, and that's not the case here).
+# This statement forces mysqltest.cc to close prepared "DROP TABLE t1".
+# Otherwise, the plugin can not be uninstalled because there is an active
+# prepared statement using it.
+SELECT 1;
+
+UNINSTALL PLUGIN archive;
+
+--error ER_SP_DOES_NOT_EXIST
+UNINSTALL PLUGIN archive;
+
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 2a621250480..2854f503034 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -334,7 +334,7 @@ INSERT INTO t1 VALUES (1), (1);
CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY );
--error ER_DUP_ENTRY
-CREATE TABLE IF NOT EXISTS t2 AS SELECT a FROM t1;
+INSERT INTO t2 SELECT a FROM t1;
UPDATE t2 SET a = 2;
diff --git a/mysql-test/t/backup-master.sh b/mysql-test/t/backup-master.sh
deleted file mode 100755
index c099064f6b7..00000000000
--- a/mysql-test/t/backup-master.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-if [ "$MYSQL_TEST_DIR" ]
-then
- rm -f $MYSQLTEST_VARDIR/tmp/*.frm $MYSQLTEST_VARDIR/tmp/*.MY?
-fi
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
deleted file mode 100644
index c761f48cbcb..00000000000
--- a/mysql-test/t/backup.test
+++ /dev/null
@@ -1,104 +0,0 @@
-
-# The server need to be started in $MYSQLTEST_VARDIR since it
-# uses ../../std_data/
---source include/uses_vardir.inc
-
-# Save the initial number of concurrent sessions
---source include/count_sessions.inc
-
-#
-# This test is a bit tricky as we can't use backup table to overwrite an old
-# table
-#
-connect (con1,localhost,root,,);
-connect (con2,localhost,root,,);
-connection con1;
-set SQL_LOG_BIN=0;
---disable_warnings
-drop table if exists t1, t2, t3, t4;
---enable_warnings
-create table t4(n int);
---replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-backup table t4 to '../../bogus';
-backup table t4 to '../../tmp';
---replace_result ": 7" ": X" ": 17" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-backup table t4 to '../../tmp';
-drop table t4;
-restore table t4 from '../../tmp';
-select count(*) from t4;
-
-create table t1(n int);
-insert into t1 values (23),(45),(67);
-backup table t1 to '../../tmp';
-drop table t1;
---replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-restore table t1 from '../../bogus';
-restore table t1 from '../../tmp';
-select n from t1;
-create table t2(m int not null primary key);
-create table t3(k int not null primary key);
-insert into t2 values (123),(145),(167);
-insert into t3 values (223),(245),(267);
-backup table t2,t3 to '../../tmp';
-drop table t1,t2,t3;
-restore table t1,t2,t3 from '../../tmp';
-select n from t1;
-select m from t2;
-select k from t3;
-drop table t1,t2,t3,t4;
-restore table t1 from '../../tmp';
-connection con2;
-rename table t1 to t5;
---send
-lock tables t5 write;
-connection con1;
---send
-backup table t5 to '../../tmp';
-connection con2;
-reap;
-unlock tables;
-connection con1;
-reap;
-drop table t5;
-connection default;
-disconnect con1;
-disconnect con2;
-remove_file $MYSQLTEST_VARDIR/tmp/t1.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t2.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t3.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t4.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t5.MYD;
-remove_file $MYSQLTEST_VARDIR/tmp/t1.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t2.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t3.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t4.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t5.frm;
-
-
-# End of 4.1 tests
-# End of 5.0 tests
-
-#
-# Bug#18775 - Temporary table from alter table visible to other threads
-#
-# Backup did not encode table names.
---disable_warnings
-DROP TABLE IF EXISTS `t+1`;
---enable_warnings
-CREATE TABLE `t+1` (c1 INT);
-INSERT INTO `t+1` VALUES (1), (2), (3);
-BACKUP TABLE `t+1` TO '../../tmp';
-DROP TABLE `t+1`;
-#
-# Same for restore.
-RESTORE TABLE `t+1` FROM '../../tmp';
-SELECT * FROM `t+1`;
-DROP TABLE `t+1`;
-#
-remove_file $MYSQLTEST_VARDIR/tmp/t@002b1.frm;
-remove_file $MYSQLTEST_VARDIR/tmp/t@002b1.MYD;
-
-
-# Wait till all disconnects are completed
---source include/wait_until_count_sessions.inc
-
diff --git a/mysql-test/t/blackhole_plugin-master.opt b/mysql-test/t/blackhole_plugin-master.opt
new file mode 100644
index 00000000000..e78cd2b1662
--- /dev/null
+++ b/mysql-test/t/blackhole_plugin-master.opt
@@ -0,0 +1 @@
+--plugin_dir=$BLACKHOLE_PLUGIN_DIR
diff --git a/mysql-test/t/blackhole_plugin.test b/mysql-test/t/blackhole_plugin.test
new file mode 100644
index 00000000000..448104bed2b
--- /dev/null
+++ b/mysql-test/t/blackhole_plugin.test
@@ -0,0 +1,34 @@
+--source include/not_windows.inc
+--source include/have_blackhole_plugin.inc
+
+# When running in parallel we get
+# Warning 1620 Plugin is busy and will be uninstalled on shutdown
+--source include/not_parallel.inc
+
+CREATE TABLE t1(a int) ENGINE=BLACKHOLE;
+DROP TABLE t1;
+
+eval INSTALL PLUGIN blackhole SONAME 'ha_blackhole.so';
+--error 1125
+eval INSTALL PLUGIN BLACKHOLE SONAME 'ha_blackhole.so';
+
+UNINSTALL PLUGIN blackhole;
+
+eval INSTALL PLUGIN blackhole SONAME 'ha_blackhole.so';
+
+CREATE TABLE t1(a int) ENGINE=BLACKHOLE;
+
+DROP TABLE t1;
+
+# This dummy statement is required for --ps-protocol mode.
+# The thing is that last prepared statement is "cached" in mysqltest.cc
+# (unless "reconnect" is enabled, and that's not the case here).
+# This statement forces mysqltest.cc to close prepared "DROP TABLE t1".
+# Otherwise, the plugin can not be uninstalled because there is an active
+# prepared statement using it.
+SELECT 1;
+
+UNINSTALL PLUGIN blackhole;
+--error ER_SP_DOES_NOT_EXIST
+UNINSTALL PLUGIN blackhole;
+
diff --git a/mysql-test/t/bootstrap-master.opt b/mysql-test/t/bootstrap-master.opt
new file mode 100644
index 00000000000..31a799e4d9b
--- /dev/null
+++ b/mysql-test/t/bootstrap-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM --skip-innodb
diff --git a/mysql-test/t/bootstrap.test b/mysql-test/t/bootstrap.test
index db89269b35d..5b432653e45 100644
--- a/mysql-test/t/bootstrap.test
+++ b/mysql-test/t/bootstrap.test
@@ -8,8 +8,7 @@ drop table if exists t1;
# Add the datadir to the bootstrap command
let $MYSQLD_DATADIR= `select @@datadir`;
-let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR;
-
+let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --default-storage-engine=MyISAM --skip-innodb;
#
# Check that --bootstrap reads from stdin
#
@@ -20,7 +19,6 @@ EOF
--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
drop table t1;
remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql;
-
#
# Check that --bootstrap of file with SQL error returns error
#
@@ -51,3 +49,15 @@ remove_file $MYSQLTEST_VARDIR/tmp/long_query.sql;
set global max_allowed_packet=@my_max_allowed_packet;
drop table t1;
+--echo End of 5.1 tests
+
+--echo #
+--echo # Bug #11766306: 59393: HAVE_INNODB=YES WHEN MYSQLD
+--echo # STARTED WITH --SKIP-INNODB
+--echo #
+
+# need the --skip-innodb option present for the test to succeed
+SHOW VARIABLES LIKE 'have_innodb';
+SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb';
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/bug46080-master.opt b/mysql-test/t/bug46080-master.opt
index f59740afe60..1be97e178ed 100644
--- a/mysql-test/t/bug46080-master.opt
+++ b/mysql-test/t/bug46080-master.opt
@@ -1 +1 @@
---skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=4000000
+--loose-performance-schema=0 --skip-grant-tables --skip-name-resolve
diff --git a/mysql-test/t/bug46080.test b/mysql-test/t/bug46080.test
index ed4a16fdf51..ed824529a9b 100644
--- a/mysql-test/t/bug46080.test
+++ b/mysql-test/t/bug46080.test
@@ -3,6 +3,8 @@
--echo # sort_buffer_size cannot allocate
--echo #
+--source include/have_debug.inc
+
call mtr.add_suppression("Out of memory at line .*, '.*my_alloc.c'");
call mtr.add_suppression("needed .* byte (.*k)., memory in use: .* bytes (.*k)");
diff --git a/mysql-test/t/bug46261.test b/mysql-test/t/bug46261.test
index 67bdc995850..e0eae9b86fb 100644
--- a/mysql-test/t/bug46261.test
+++ b/mysql-test/t/bug46261.test
@@ -7,7 +7,7 @@
--replace_regex /\.dll/.so/
--error ER_OPTION_PREVENTS_STATEMENT
-eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
--replace_regex /\.dll/.so/
--error ER_OPTION_PREVENTS_STATEMENT
diff --git a/mysql-test/t/bug46760.test b/mysql-test/t/bug46760.test
index f55edbbfa42..e7f57549250 100644
--- a/mysql-test/t/bug46760.test
+++ b/mysql-test/t/bug46760.test
@@ -29,7 +29,7 @@ DROP TABLE t1;
--echo # ROW_FORMAT=COMPRESSED
--echo #
-CREATE TABLE t1 (a INT) ROW_FORMAT=compressed;
+CREATE TABLE t1 (a INT) ROW_FORMAT=compressed, ENGINE=MyISAM;
SHOW CREATE TABLE t1;
OPTIMIZE TABLE t1;
SHOW CREATE TABLE t1;
diff --git a/mysql-test/t/bug47671-master.opt b/mysql-test/t/bug47671-master.opt
index 0afdf49e022..ad54fbc3467 100644
--- a/mysql-test/t/bug47671-master.opt
+++ b/mysql-test/t/bug47671-master.opt
@@ -1 +1 @@
---default-character-set=utf8 --skip-character-set-client-handshake
+--character-set-server=utf8 --skip-character-set-client-handshake
diff --git a/mysql-test/t/bug58669-master.opt b/mysql-test/t/bug58669-master.opt
new file mode 100644
index 00000000000..6d909680527
--- /dev/null
+++ b/mysql-test/t/bug58669-master.opt
@@ -0,0 +1 @@
+--read-only
diff --git a/mysql-test/t/bug58669.test b/mysql-test/t/bug58669.test
new file mode 100644
index 00000000000..332c104cfea
--- /dev/null
+++ b/mysql-test/t/bug58669.test
@@ -0,0 +1,22 @@
+--source include/not_embedded.inc
+
+--echo #
+--echo # Bug#58669: read_only not enforced on 5.5.x
+--echo #
+
+CREATE USER user1@localhost;
+CREATE DATABASE db1;
+GRANT ALL PRIVILEGES ON db1.* TO user1@localhost;
+CREATE TABLE db1.t1(a INT);
+
+connect (con1,localhost,user1,,);
+connection con1;
+SELECT CURRENT_USER();
+SHOW VARIABLES LIKE "%read_only%";
+--error ER_OPTION_PREVENTS_STATEMENT
+INSERT INTO db1.t1 VALUES (1);
+
+connection default;
+disconnect con1;
+DROP DATABASE db1;
+DROP USER user1@localhost;
diff --git a/mysql-test/t/cache_innodb-master.opt b/mysql-test/t/cache_innodb-master.opt
index 5f0ebff98f6..6672b4ddce1 100644
--- a/mysql-test/t/cache_innodb-master.opt
+++ b/mysql-test/t/cache_innodb-master.opt
@@ -1 +1 @@
---set-variable=query_cache_size=1M
+--query_cache_size=1M
diff --git a/mysql-test/t/cache_innodb.test b/mysql-test/t/cache_innodb.test
index 33a328d1d6c..f7102627506 100644
--- a/mysql-test/t/cache_innodb.test
+++ b/mysql-test/t/cache_innodb.test
@@ -14,3 +14,18 @@ let $engine_type= InnoDB;
let $test_foreign_keys= 1;
--source include/query_cache.inc
+
+#
+# Bug#56452 Assertion failed: thd->transaction.stmt.is_empty() ||
+# thd->in_sub_stmt
+#
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+BEGIN;
+ INSERT INTO t1 VALUES(1);
+ROLLBACK WORK AND CHAIN NO RELEASE;
+SELECT a FROM t1;
+ROLLBACK WORK AND CHAIN NO RELEASE;
+SELECT a FROM t1;
+ROLLBACK;
+DROP TABLE t1;
+
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index 028c64d6de7..e1c807fe32b 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -111,6 +111,9 @@ explain extended SELECT
SHOW CREATE TABLE t1;
DROP TABLE t1;
+--error 1267
+CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin);
+
# Test for BUG#10151
SELECT 'case+union+test'
UNION
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 8e60d548c2f..a922cc9aaf7 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -177,8 +177,6 @@ select cast(1.0e+300 as signed int);
CREATE TABLE t1 (f1 double);
INSERT INTO t1 SET f1 = -1.0e+30 ;
INSERT INTO t1 SET f1 = +1.0e+30 ;
-# Expected result is +-1e+30, but Windows returns +-1e+030.
---replace_result 1e+030 1e+30
SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1;
DROP TABLE t1;
@@ -282,5 +280,19 @@ SELECT 1 FROM
) AS s LIMIT 1;
DROP TABLE t1;
+--echo #
+--echo # Bug #11765023: 57934: DOS POSSIBLE SINCE BINARY CASTING
+--echo # DOESN'T ADHERE TO MAX_ALLOWED_PACKET
+
+SET @@GLOBAL.max_allowed_packet=2048;
+# reconnect to make the new max packet size take effect
+--connect (newconn, localhost, root,,)
+
+SELECT CONVERT('a', BINARY(2049));
+SELECT CONVERT('a', CHAR(2049));
+
+connection default;
+disconnect newconn;
+SET @@GLOBAL.max_allowed_packet=default;
--echo End of 5.1 tests
diff --git a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test
index 3ed798e8d36..1879dbc53cf 100644
--- a/mysql-test/t/change_user.test
+++ b/mysql-test/t/change_user.test
@@ -1,4 +1,52 @@
#
+# functional change user tests
+#
+
+grant select on test.* to test_nopw;
+grant select on test.* to test_oldpw identified by password "09301740536db389";
+grant select on test.* to test_newpw identified by "newpw";
+
+select user(), current_user(), database();
+#
+# massaging the data for tests to pass in the embedded server,
+# that has authentication completely disabled.
+#
+
+--replace_result <@> <test_nopw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+
+
+change_user test_nopw;
+--replace_result <@> <test_nopw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user test_oldpw, oldpw;
+--replace_result <@> <test_oldpw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user test_newpw, newpw;
+--replace_result <@> <test_newpw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user root;
+--replace_result <@> <root@localhost> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+
+change_user test_nopw,,test;
+--replace_result <@> <test_nopw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user test_oldpw,oldpw,test;
+--replace_result <@> <test_oldpw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user test_newpw,newpw,test;
+--replace_result <@> <test_newpw@%> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+change_user root,,test;
+--replace_result <@> <root@localhost> @> @localhost>
+select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
+
+drop user test_nopw;
+drop user test_oldpw;
+drop user test_newpw;
+
+#
# Bug#20023 mysql_change_user() resets the value of SQL_BIG_SELECTS
#
@@ -69,7 +117,7 @@ let $before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1);
let $after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1);
-if (`select $after != $before`){
+if ($after != $before){
SHOW GLOBAL STATUS LIKE 'com_select';
die The value of com_select changed during change_user;
}
diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test
index ff23b352b5a..2234d2c680f 100644
--- a/mysql-test/t/check.test
+++ b/mysql-test/t/check.test
@@ -53,5 +53,29 @@ REPAIR TABLE t1;
DROP TABLE t1;
+--echo #
+--echo # Bug#56422 CHECK TABLE run when the table is locked reports corruption
+--echo # along with timeout
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+LOCK TABLE t1 WRITE;
+
+--echo # Connection con1
+connect(con1, localhost, root);
+SET lock_wait_timeout= 1;
+CHECK TABLE t1;
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+DROP TABLE t1;
+disconnect con1;
+
+
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/comment_column.test b/mysql-test/t/comment_column.test
new file mode 100644
index 00000000000..90976d143b5
--- /dev/null
+++ b/mysql-test/t/comment_column.test
@@ -0,0 +1,130 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'Abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd', c2 INTEGER COMMENT 'aBcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd',c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='ABCDEFGHIJabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ADD COLUMN c8 INTEGER COMMENT 'ABCdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+ALTER TABLE t1 ADD COLUMN c9 INTEGER COMMENT 'ABCDefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+ALTER TABLE t1 ADD COLUMN c10 INTEGER COMMENT 'ABCDEfghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+ALTER TABLE t1 MODIFY COLUMN c8 CHAR(10);
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 CHANGE COLUMN c9 c9_1 INTEGER COMMENT '1234567890';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 DROP COLUMN c1;
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+# comment overflow(warning)
+ALTER TABLE t1 ADD COLUMN c11 INTEGER COMMENT 'ABCDEfghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdABCDEfghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdABCDEfghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+# comment overflow(error)
+set sql_mode='TRADITIONAL';
+--error ER_TOO_LONG_FIELD_COMMENT
+ALTER TABLE t1 ADD COLUMN c12 INTEGER COMMENT 'ABCDEfghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdABCDEfghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdABCDEfghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+set sql_mode='';
+ALTER TABLE t1 ADD COLUMN c12 CHAR(100) COMMENT 'ABCDefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+# comment overflow(warning)
+drop table t1;
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'Abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd', c2 INTEGER COMMENT 'aBcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdaBcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd',c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='ABCDEFGHIJabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+# comment overflow(error)
+DROP TABLE t1;
+set sql_mode='TRADITIONAL';
+--error ER_TOO_LONG_FIELD_COMMENT
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'Abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd', c2 INTEGER COMMENT 'aBcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdaBcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd',c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='ABCDEFGHIJabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+
+# bug#48077
+SET sql_mode='';
+CREATE TABLE t1_toupg (c1 INT, c2 VARCHAR(10) COMMENT
+'01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234')
+COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde';
+# Alter the existing table, change comment
+ALTER TABLE t1_toupg COMMENT='012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012301234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
+# Alter existing table, add new column with comment
+ALTER TABLE t1_toupg ADD c3 TIMESTAMP COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde';
+# Alter existing table, add index with comment
+ALTER TABLE t1_toupg ADD INDEX i1(c1) COMMENT '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
+# Add index with comment using CREATE INDEX
+CREATE INDEX i2 ON t1_toupg(c2) COMMENT '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234';
+drop table t1_toupg;
+
+
diff --git a/mysql-test/t/comment_column2.test b/mysql-test/t/comment_column2.test
new file mode 100644
index 00000000000..ea66ab3b066
--- /dev/null
+++ b/mysql-test/t/comment_column2.test
@@ -0,0 +1,172 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+create table t1 (
+c1 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c2 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c3 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c4 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c5 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c6 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c7 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c8 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c9 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c10 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c11 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c12 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c13 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c14 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c15 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c16 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c17 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c18 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c19 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c20 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c21 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c22 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c23 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c24 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c25 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c26 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c27 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c28 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c29 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c30 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c31 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c32 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c33 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c34 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c35 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c36 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c37 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c38 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c39 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c40 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c41 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c42 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c43 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c44 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c45 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c46 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c47 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c48 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c49 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c50 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij');
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+
+ALTER TABLE t1 ADD COLUMN c51 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',ADD COLUMN c52 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+
+ALTER TABLE t1 ADD COLUMN c53 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c54 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c55 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c56 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c57 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c58 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c59 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c60 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c61 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c62 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+
+ALTER TABLE t1 ADD COLUMN c63 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+
+--error 1117
+ALTER TABLE t1 ADD COLUMN c64 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+
+
+
+
+drop table t1;
+--error 1117
+create table t1 (
+c1 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c2 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c3 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c4 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c5 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c6 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c7 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c8 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c9 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c10 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c11 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c12 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c13 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c14 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c15 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c16 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c17 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c18 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c19 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c20 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c21 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c22 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c23 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c24 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c25 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c26 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c27 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c28 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c29 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c30 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c31 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c32 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c33 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c34 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c35 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c36 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c37 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c38 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c39 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c40 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c41 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c42 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c43 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c44 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c45 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c46 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c47 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c48 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c49 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c50 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c51 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c52 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c53 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c54 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c55 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c56 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c57 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c58 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c59 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c60 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c61 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c62 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c63 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c64 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij',
+c65 INTEGER COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij')
+;
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+
+
diff --git a/mysql-test/t/comment_index.test b/mysql-test/t/comment_index.test
new file mode 100644
index 00000000000..7857d54080e
--- /dev/null
+++ b/mysql-test/t/comment_index.test
@@ -0,0 +1,100 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'Abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd', c2 INTEGER COMMENT 'aBcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd',c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, c8 VARCHAR(100), c9 CHAR(50), c10 DATETIME, c11 DATETIME, c12 DATETIME,c13 DATETIME, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='ABCDEFGHIJabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+CREATE INDEX i4 ON t1(c4) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+ALTER TABLE t1 ADD INDEX (c6) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+DROP INDEX i1 ON t1;
+ALTER TABLE t1 DROP INDEX i2, DROP INDEX i4;
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ADD INDEX i8(c8) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd', ADD INDEX i10(c10) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+# multicolumn index
+CREATE INDEX i1_3 ON t1(c1,c2,c3) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+# comment overflow(warning)
+CREATE INDEX i11 ON t1(c11) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 ADD INDEX (c13) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+
+# comment overflow(error)
+set sql_mode='TRADITIONAL';
+--error ER_TOO_LONG_INDEX_COMMENT
+ALTER TABLE t1 ADD INDEX i12 (c12) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+
+set sql_mode='TRADITIONAL';
+--error ER_TOO_LONG_INDEX_COMMENT
+CREATE INDEX i12 ON t1(c12) COMMENT 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+SELECT comment,index_comment,char_length(index_comment) FROM information_schema.statistics WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+
+drop table t1;
diff --git a/mysql-test/t/comment_table.test b/mysql-test/t/comment_table.test
new file mode 100644
index 00000000000..2a85fbac571
--- /dev/null
+++ b/mysql-test/t/comment_table.test
@@ -0,0 +1,55 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+#1024 bytes
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+drop table t1;
+
+#1025 bytes
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+drop table t1;
+set sql_mode='TRADITIONAL';
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+drop table t1;
+
+
+#2048 bytes
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+let $ENGINE=`select variable_value from information_schema.global_variables where variable_name='STORAGE_ENGINE'`;
+--replace_result $ENGINE ENGINE
+SHOW CREATE TABLE t1;
+drop table t1;
+
+
+#2049 bytes(warning)
+SET SQL_MODE='';
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+drop table t1;
+SET SQL_MODE='TRADITIONAL';
+
+--error ER_TOO_LONG_TABLE_COMMENT
+create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
+) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde';
+SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
+SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
diff --git a/mysql-test/t/commit.test b/mysql-test/t/commit.test
new file mode 100644
index 00000000000..261867bd5cc
--- /dev/null
+++ b/mysql-test/t/commit.test
@@ -0,0 +1,350 @@
+--source include/have_innodb.inc
+
+connect (con1,localhost,root,,);
+
+--echo #
+--echo # Bug#20837 Apparent change of isolation level
+--echo # during transaction
+--echo #
+--echo # Bug#53343 completion_type=1, COMMIT/ROLLBACK
+--echo # AND CHAIN don't preserve the isolation
+--echo # level
+#
+# A set of test cases that verifies operation of
+# transaction isolation level and chaining is
+# provided
+
+# init
+--echo connection default;
+connection default;
+
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+CREATE TABLE t1 (s1 INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2);
+COMMIT;
+
+#
+# Verify that SET TRANS ISO LEVEL is not allowed
+# inside a transaction
+#
+START TRANSACTION;
+--error ER_CANT_CHANGE_TX_ISOLATION
+SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+COMMIT;
+
+#
+# Verify consistent output from
+# SELECT @@tx_isolation (Bug#20837)
+#
+# The transaction will be in READ UNCOMMITTED mode,
+# but SELECT @@tx_isolation should report the session
+# value, which is REPEATABLE READ
+#
+SET @@autocommit=0;
+COMMIT;
+SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+START TRANSACTION;
+SELECT @@tx_isolation;
+--echo Should be REPEATABLE READ
+SELECT * FROM t1;
+SELECT @@tx_isolation;
+--echo Should be REPEATABLE READ
+INSERT INTO t1 VALUES (-1);
+SELECT @@tx_isolation;
+--echo Should be REPEATABLE READ
+COMMIT;
+
+#
+# Verify that a change in the session variable
+# does not affect the currently started
+# transaction
+#
+START TRANSACTION;
+SELECT * FROM t1;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+
+--echo connection con1
+connection con1;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1000);
+COMMIT;
+
+--echo connection default
+connection default;
+--echo We should not be able to read the '1000'
+SELECT * FROM t1;
+COMMIT;
+
+--echo Now, the '1000' should appear.
+START TRANSACTION;
+SELECT * FROM t1;
+COMMIT;
+
+# restore the session value
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+
+#
+# A set of test cases for verification that
+# isolation level during chaining works. MySQL
+# has three variants of chaining, i.e
+# COMMIT AND CHAIN, ROLLBACK AND CHAIN, and
+# the use of @completion_type
+#
+
+#
+# Verify isolation level with COMMIT AND CHAIN
+#
+# COMMIT AND CHAIN causes a new transaction to
+# begin as soon as the current ends, and the new
+# transaction will have the same tran. iso. level
+# as the first.
+#
+--echo connection default
+connection default;
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+
+--echo connection con1
+connection con1;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1001);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT COUNT(*) FROM t1 WHERE s1 = 1001;
+--echo Should be 1
+COMMIT AND CHAIN;
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1002);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT COUNT(*) FROM t1 WHERE s1 = 1002;
+--echo Should be 1
+COMMIT;
+SELECT * FROM t1;
+DELETE FROM t1 WHERE s1 >= 1000;
+COMMIT;
+
+#
+# Verify isolation level with ROLLBACK AND CHAIN
+#
+--echo connection default
+connection default;
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+
+--echo connection con1
+connection con1;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1001);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT COUNT(*) FROM t1 WHERE s1 = 1001;
+--echo Should be 1
+ROLLBACK AND CHAIN;
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1002);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT COUNT(*) FROM t1 WHERE s1 = 1002;
+--echo Should be 1
+COMMIT;
+SELECT * FROM t1;
+DELETE FROM t1 WHERE s1 >= 1000;
+COMMIT;
+
+#
+# Verify isolation level with @completion_type=1.
+# (A @@completion_type value of 1 is equivalentl to
+# explicitly adding "AND CHAIN" to COMMIT or ROLLBACK)
+#
+
+#
+# Verify that COMMIT AND NO CHAIN overrides the value
+# of @@completion_type
+#
+SET @@completion_type=1;
+
+--echo connection default
+connection default;
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+
+--echo connection con1
+connection con1;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1001);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1 WHERE s1 >= 1000;
+--echo Should see 1001
+COMMIT AND NO CHAIN;
+--echo default transaction is now in REPEATABLE READ
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1002);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1 WHERE s1 >= 1000;
+--echo Should see 1001 and 1002
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1003);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1 WHERE s1 >= 1000;
+--echo Should see 1001 and 1002, but NOT 1003
+COMMIT;
+
+SELECT * FROM t1;
+DELETE FROM t1 WHERE s1 >= 1000;
+COMMIT AND NO CHAIN;
+SET @@completion_type=0;
+COMMIT;
+
+#
+# Verify that ROLLBACK AND NO CHAIN overrides the value
+# of @@completion_type
+#
+--echo connection default
+connection default;
+SET @@completion_type=1;
+COMMIT AND NO CHAIN;
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+
+--echo connection con1
+connection con1;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1001);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1 WHERE s1 >= 1000;
+--echo Should see 1001
+ROLLBACK AND NO CHAIN;
+--echo default transaction is now in REPEATABLE READ
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1002);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1 WHERE s1 >= 1000;
+--echo Should see 1001 and 1002
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1003);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1 WHERE s1 >= 1000;
+--echo Should see 1001 and 1002, but NOT 1003
+
+COMMIT;
+SELECT * FROM t1;
+DELETE FROM t1 WHERE s1 >= 1000;
+COMMIT AND NO CHAIN;
+SET @@completion_type=0;
+COMMIT;
+
+#
+# Verify that in the sequence:
+# SET TRANSACTION ISOLATION LEVEL
+# SET SESSION ISOLATION LEVEL
+#
+# SET SESSION ISOLATION LEVEL has precedence over
+# SET TRANSACTION. (Note that this is _not_
+# in accordance with ISO 9075.)
+#
+--echo connection default
+connection default;
+
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+START TRANSACTION;
+SELECT * FROM t1;
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1000);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1;
+--echo Should get same result as above (i.e should not read '1000')
+COMMIT;
+
+DELETE FROM t1 WHERE s1 >= 1000;
+COMMIT;
+
+
+#
+# Verify that a transaction ended with an
+# implicit commit (i.e a DDL statement), the
+# @@completetion_type setting is ignored, and
+# the next transaction's isolation level is
+# the session level.
+#
+SET @@completion_type=1;
+COMMIT AND NO CHAIN;
+SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+TRUNCATE TABLE t1;
+INSERT INTO t1 VALUES (1000);
+SELECT * FROM t1;
+--echo Should read '1000'
+
+--echo connection con1
+connection con1;
+INSERT INTO t1 VALUES (1001);
+COMMIT;
+
+--echo connection default
+connection default;
+SELECT * FROM t1;
+--echo Should only read the '1000' as this transaction is now in REP READ
+COMMIT AND NO CHAIN;
+
+SET @@completion_type=0;
+COMMIT AND NO CHAIN;
+
+
+#
+# Cleanup
+#
+SET @autocommit=1;
+COMMIT;
+
+disconnect con1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # End of test cases for Bug#20837
+--echo #
diff --git a/mysql-test/t/commit_1innodb.test b/mysql-test/t/commit_1innodb.test
index c4a29acdddd..a2337094f1a 100644
--- a/mysql-test/t/commit_1innodb.test
+++ b/mysql-test/t/commit_1innodb.test
@@ -1,6 +1,8 @@
-- source include/have_log_bin.inc
-- source include/have_innodb.inc
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+
let $engine_type = InnoDB;
-- source include/commit.inc
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
index d0b79ab6bd3..9a29e4ff861 100644
--- a/mysql-test/t/connect.test
+++ b/mysql-test/t/connect.test
@@ -293,34 +293,6 @@ SET GLOBAL event_scheduler = OFF;
--echo # -- End of Bug#35074.
--echo
-
-###########################################################################
-
---echo #
---echo # -- Bug#49752: 2469.126.2 unintentionally breaks authentication
---echo # against MySQL 5.1 server
---echo #
-
-GRANT ALL ON test.* TO 'Azundris12345678'@'localhost' IDENTIFIED BY 'test123';
-
-FLUSH PRIVILEGES;
-
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
-connect (con1,localhost,Azundris123456789,test123,test);
-disconnect con1;
-
-connection default;
-
-DROP USER 'Azundris12345678'@'localhost';
-
-FLUSH PRIVILEGES;
-
---echo #
---echo # -- End of Bug#49752
---echo #
-
-
-
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test
index ed268ab5846..70a95e5f16e 100644
--- a/mysql-test/t/constraints.test
+++ b/mysql-test/t/constraints.test
@@ -10,7 +10,7 @@ create table t1 (a int check (a>0));
insert into t1 values (1);
insert into t1 values (0);
drop table t1;
-create table t1 (a int ,b int, check a>b);
+create table t1 (a int, b int, check (a>b));
insert into t1 values (1,0);
insert into t1 values (0,1);
drop table t1;
@@ -29,3 +29,45 @@ show create table t1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#35578 (Parser allows useless/illegal CREATE TABLE syntax)
+#
+
+--disable_warnings
+drop table if exists t_illegal;
+--enable_warnings
+
+--error ER_PARSE_ERROR
+create table t_illegal (a int, b int, check a>b);
+
+--error ER_PARSE_ERROR
+create table t_illegal (a int, b int, constraint abc check a>b);
+
+--error ER_PARSE_ERROR
+create table t_illegal (a int, b int, constraint abc);
+
+#
+# Bug#11714 (Non-sensical ALTER TABLE ADD CONSTRAINT allowed)
+#
+
+--disable_warnings
+drop table if exists t_11714;
+--enable_warnings
+
+create table t_11714(a int, b int);
+
+--error ER_PARSE_ERROR
+alter table t_11714 add constraint cons1;
+
+drop table t_11714;
+
+#
+# Bug#38696 (CREATE TABLE ... CHECK ... allows illegal syntax)
+
+--error ER_PARSE_ERROR
+CREATE TABLE t_illegal (col_1 INT CHECK something (whatever));
+
+--error ER_PARSE_ERROR
+CREATE TABLE t_illegal (col_1 INT CHECK something);
+
diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test
index d0996689aeb..10b4ac6f0e7 100644
--- a/mysql-test/t/count_distinct.test
+++ b/mysql-test/t/count_distinct.test
@@ -96,3 +96,14 @@ insert into t1 values (0,1),(1,2);
select count(distinct if(f1,3,f2)) from t1;
drop table t1;
+#
+# Bug #51980 "mysqld service crashes with a simple COUNT(DISTINCT) query
+# over a view"
+#
+
+create table t1 (i int);
+insert into t1 values (0), (1);
+create view v1 as select * from t1;
+select count(distinct i) from v1;
+drop table t1;
+drop view v1;
diff --git a/mysql-test/t/count_distinct2-master.opt b/mysql-test/t/count_distinct2-master.opt
index d81cc55090d..2fa4c2b903d 100644
--- a/mysql-test/t/count_distinct2-master.opt
+++ b/mysql-test/t/count_distinct2-master.opt
@@ -1 +1 @@
---set-variable=max_heap_table_size=16384
+--max_heap_table_size=16384
diff --git a/mysql-test/t/crash_commit_before-master.opt b/mysql-test/t/crash_commit_before-master.opt
index a745693594e..cd2ae9b1455 100644
--- a/mysql-test/t/crash_commit_before-master.opt
+++ b/mysql-test/t/crash_commit_before-master.opt
@@ -1,2 +1,3 @@
--skip-stack-trace --skip-core-file
-
+--default-storage-engine=MyISAM
+--innodb-file-per-table=0
diff --git a/mysql-test/t/crash_commit_before.test b/mysql-test/t/crash_commit_before.test
index e3dba58d4df..6e36d2345e1 100644
--- a/mysql-test/t/crash_commit_before.test
+++ b/mysql-test/t/crash_commit_before.test
@@ -1,6 +1,8 @@
-- source include/not_embedded.inc
# Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 692721b5955..8181b873029 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -5,6 +5,7 @@
--disable_warnings
drop table if exists t1,t2,t3,t4,t5;
drop database if exists mysqltest;
+drop view if exists v1;
--enable_warnings
create table t1 (b char(0));
@@ -102,6 +103,22 @@ create table t1 (`` int);
create table t1 (i int, index `` (i));
#
+# CREATE TABLE under LOCK TABLES
+#
+# We don't allow creation of non-temporary tables under LOCK TABLES
+# as following meta-data locking protocol in this case can lead to
+# deadlock.
+create table t1 (i int);
+lock tables t1 read;
+--error ER_TABLE_NOT_LOCKED
+create table t2 (j int);
+# OTOH creating of temporary table should be OK
+create temporary table t2 (j int);
+drop temporary table t2;
+unlock tables;
+drop table t1;
+
+#
# Test of CREATE ... SELECT with indexes
#
@@ -216,7 +233,6 @@ drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
---error 1136
create table if not exists t1 select 1,2,3,4;
create table if not exists t1 select 1;
select * from t1;
@@ -232,8 +248,6 @@ insert into t1 values (1,1);
create table if not exists t1 select 2;
select * from t1;
create table if not exists t1 select 3 as 'a',4 as 'b';
---error ER_DUP_ENTRY
-create table if not exists t1 select 3 as 'a',3 as 'b';
show warnings;
show status like "Opened_tables";
select * from t1;
@@ -315,6 +329,26 @@ drop table t3;
drop database mysqltest;
#
+# CREATE TABLE LIKE under LOCK TABLES
+#
+# Similarly to ordinary CREATE TABLE we don't allow creation of
+# non-temporary tables under LOCK TABLES. Also we require source
+# table to be locked.
+create table t1 (i int);
+create table t2 (j int);
+lock tables t1 read;
+--error ER_TABLE_NOT_LOCKED
+create table t3 like t1;
+# OTOH creating of temporary table should be OK
+create temporary table t3 like t1;
+drop temporary table t3;
+# Source table should be locked
+--error ER_TABLE_NOT_LOCKED
+create temporary table t3 like t2;
+unlock tables;
+drop tables t1, t2;
+
+#
# Test default table type
#
SET SESSION storage_engine="heap";
@@ -481,7 +515,7 @@ drop table t1,t2;
# an improper fix is present.
#
create table t1 (a int);
---error 1093
+--error ER_TABLE_EXISTS_ERROR
create table t1 select * from t1;
--error ER_WRONG_OBJECT
create table t2 union = (t1) select * from t1;
@@ -683,8 +717,8 @@ drop table t1;
# Error during open_and_lock_tables() of tables
--error ER_NO_SUCH_TABLE
create table t1 select * from t2;
-# Rather special error which also caught during open tables pahse
---error ER_UPDATE_TABLE_USED
+# A special case which is also caught during open tables pahse
+--error ER_NO_SUCH_TABLE
create table t1 select * from t1;
# Error which happens before select_create::prepare()
--error ER_CANT_AGGREGATE_2COLLATIONS
@@ -694,7 +728,6 @@ create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1
create table t1 (primary key(a)) select "b" as b;
# Error in select_create::prepare() which is not related to table creation
create table t1 (a int);
---error ER_WRONG_VALUE_COUNT_ON_ROW
create table if not exists t1 select 1 as a, 2 as b;
drop table t1;
# Finally error which happens during insert
@@ -706,16 +739,13 @@ create table t1 (i int);
create table t1 select 1 as i;
create table if not exists t1 select 1 as i;
select * from t1;
+# After WL#5370, it just generates a warning that the table already exists.
+create table if not exists t1 select * from t1;
+select * from t1;
+drop table t1;
# Error before select_create::prepare()
--error ER_CANT_AGGREGATE_2COLLATIONS
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
-select * from t1;
-# Error which happens during insertion of rows
-alter table t1 add primary key (i);
---error ER_DUP_ENTRY
-create table if not exists t1 (select 2 as i) union all (select 2 as i);
-select * from t1;
-drop table t1;
# Base vs temporary tables dillema (a.k.a. bug#24508 "Inconsistent
@@ -1189,11 +1219,9 @@ INSERT IGNORE INTO t1 (b) VALUES (5);
CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
SELECT a FROM t1;
--error 1062
-CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
- SELECT a FROM t1;
+INSERT INTO t2 SELECT a FROM t1;
--error 1062
-CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
- SELECT a FROM t1;
+INSERT INTO t2 SELECT a FROM t1;
DROP TABLE t1, t2;
@@ -1233,7 +1261,7 @@ CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
drop table if exists t2;
CREATE TABLE t2 (a int, b int, primary key (a));
--error ER_DUP_ENTRY
-CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
+INSERT INTO t2 select * from t1;
SELECT * from t2;
TRUNCATE table t2;
--error ER_DUP_ENTRY
@@ -1243,11 +1271,7 @@ drop table t2;
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
--error ER_DUP_ENTRY
-CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
-SELECT * from t2;
-TRUNCATE table t2;
---error ER_DUP_ENTRY
-INSERT INTO t2 select * from t1;
+INSERT INTO t2 SELECT * FROM t1;
SELECT * from t2;
drop table t1,t2;
@@ -1581,3 +1605,415 @@ create table t3 (a int) row_format=page;
--echo
--echo End of 5.1 tests
+
+
+###########################################################################
+
+--echo
+--echo # --
+--echo # -- Bug #43054 Assertion `!table->auto_increment_field_not_null'
+--echo # -- failed when redefining trigger
+--echo
+
+#--disable_abort_on_error
+
+CREATE TABLE B (
+ pk INTEGER AUTO_INCREMENT,
+ int_key INTEGER NOT NULL,
+ PRIMARY KEY (pk),
+ KEY (int_key)
+);
+
+INSERT IGNORE INTO B VALUES ('9', '9');
+
+CREATE TABLE IF NOT EXISTS t1 (
+ `pk` INTEGER NOT NULL AUTO_INCREMENT ,
+ `int` INTEGER ,
+ PRIMARY KEY ( `pk` )
+) SELECT `pk` , `int_key` FROM B ;
+
+--delimiter |
+
+CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ INSERT INTO t1 ( `int` ) VALUES (4 ),( 8 ),( 2 ) ;
+END ; |
+
+--delimiter ;
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+INSERT INTO t1 (pk, int_key) SELECT `pk` , `int_key` FROM B ;
+
+--delimiter |
+--error ER_NOT_SUPPORTED_YET
+CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ UPDATE A SET `pk`=1 WHERE `pk`=0 ;
+END ;|
+
+--delimiter ;
+
+DROP TABLE t1;
+DROP TABLE B;
+
+--echo #
+--echo # Bug #47107 assert in notify_shared_lock on incorrect
+--echo # CREATE TABLE , HANDLER
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(f1 integer);
+
+--echo # The following CREATE TABLEs before gave an assert.
+
+HANDLER t1 OPEN AS A;
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1 SELECT 1 AS f2;
+
+HANDLER t1 OPEN AS A;
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1(f1 integer);
+
+CREATE TABLE t2(f1 integer);
+HANDLER t1 OPEN AS A;
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1 LIKE t2;
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #48800 CREATE TABLE t...SELECT fails if t is a
+--echo # temporary table
+--echo #
+
+CREATE TEMPORARY TABLE t1 (a INT);
+CREATE TABLE t1 (a INT);
+
+CREATE TEMPORARY TABLE t2 (a INT);
+CREATE VIEW t2 AS SELECT 1;
+
+CREATE TABLE t3 (a INT);
+CREATE TEMPORARY TABLE t3 SELECT 1;
+
+CREATE TEMPORARY TABLE t4 (a INT);
+CREATE TABLE t4 AS SELECT 1;
+
+DROP TEMPORARY TABLE t1, t2, t3, t4;
+DROP TABLE t1, t3, t4;
+DROP VIEW t2;
+
+--echo #
+--echo # Bug #49193 CREATE TABLE reacts differently depending
+--echo # on whether data is selected or not
+--echo #
+
+CREATE TEMPORARY TABLE t2 (ID INT);
+INSERT INTO t2 VALUES (1),(2),(3);
+
+# Case 1 -- did not fail
+CREATE TEMPORARY TABLE t1 (ID INT);
+CREATE TABLE IF NOT EXISTS t1 (ID INT);
+INSERT INTO t1 SELECT * FROM t2;
+SELECT * FROM t1;
+DROP TEMPORARY TABLE t1;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+# Case 2 -- The DROP TABLE t1 failed with
+# Table 'test.t1' doesn't exist in the SELECT *
+# as the (permanent) table was not created
+CREATE TEMPORARY TABLE t1 (ID INT);
+CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
+SELECT * FROM t1;
+DROP TEMPORARY TABLE t1;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+# Case 3 -- The CREATE TABLE failed with
+# Table 't1' already exists
+CREATE TEMPORARY TABLE t1 (ID INT);
+CREATE TABLE t1 SELECT * FROM t2;
+SELECT * FROM t1;
+DROP TEMPORARY TABLE t1;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+DROP TEMPORARY TABLE t2;
+
+
+--echo #
+--echo # Bug #22909 "Using CREATE ... LIKE is possible to create field
+--echo # with invalid default value"
+--echo #
+--echo # Altough original bug report suggests to use older version of MySQL
+--echo # for producing .FRM with invalid defaults we use sql_mode to achieve
+--echo # the same effect.
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+--echo # Attempt to create table with invalid default should fail in normal mode
+--error ER_INVALID_DEFAULT
+create table t1 (dt datetime default '2008-02-31 00:00:00');
+set @old_mode= @@sql_mode;
+set @@sql_mode='ALLOW_INVALID_DATES';
+--echo # The same should be possible in relaxed mode
+create table t1 (dt datetime default '2008-02-31 00:00:00');
+set @@sql_mode= @old_mode;
+--echo # In normal mode attempt to create copy of table with invalid
+--echo # default should fail
+--error ER_INVALID_DEFAULT
+create table t2 like t1;
+set @@sql_mode='ALLOW_INVALID_DATES';
+--echo # But should work in relaxed mode
+create table t2 like t1;
+--echo # Check that table definitions match
+show create table t1;
+show create table t2;
+set @@sql_mode= @old_mode;
+drop tables t1, t2;
+#
+# Bug#47132 CREATE TABLE.. SELECT.. data not inserted if table
+# is view over multiple tables
+#
+
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int);
+INSERT INTO t1 VALUES (1), (1);
+INSERT INTO t2 VALUES (2), (2);
+
+CREATE VIEW v1 AS SELECT id FROM t2;
+CREATE TABLE IF NOT EXISTS v1(a int, b int) SELECT id, id FROM t1;
+SHOW CREATE TABLE v1;
+SELECT * FROM t2;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+CREATE TEMPORARY TABLE tt1 AS SELECT id FROM t2;
+CREATE TEMPORARY TABLE IF NOT EXISTS tt1(a int, b int) SELECT id, id FROM t1;
+SELECT * FROM t2;
+SELECT * FROM tt1;
+DROP TEMPORARY TABLE tt1;
+
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # WL#5370 "Changing 'CREATE TABLE IF NOT EXISTS ... SELECT'
+--echo # behaviour.
+--echo #
+
+--echo #
+--echo # 1. Basic case: a base table.
+--echo #
+
+create table if not exists t1 (a int) select 1 as a;
+select * from t1;
+--error ER_TABLE_EXISTS_ERROR
+create table t1 (a int) select 2 as a;
+select * from t1;
+--echo # Produces an essential warning ER_TABLE_EXISTS.
+create table if not exists t1 (a int) select 2 as a;
+--echo # No new data in t1.
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # 2. A temporary table.
+--echo #
+
+create temporary table if not exists t1 (a int) select 1 as a;
+select * from t1;
+--error ER_TABLE_EXISTS_ERROR
+create temporary table t1 (a int) select 2 as a;
+select * from t1;
+--echo # An essential warning.
+create temporary table if not exists t1 (a int) select 2 as a;
+--echo # No new data in t1.
+select * from t1;
+drop temporary table t1;
+
+--echo #
+--echo # 3. Creating a base table in presence of a temporary table.
+--echo #
+
+create table t1 (a int);
+--echo # Create a view for convenience of querying t1 shadowed by a temp.
+create view v1 as select a from t1;
+drop table t1;
+create temporary table t1 (a int) select 1 as a;
+create table if not exists t1 (a int) select 2 as a;
+select * from t1;
+select * from v1;
+--echo # Note: an essential warning.
+create table if not exists t1 (a int) select 3 as a;
+select * from t1;
+select * from v1;
+drop temporary table t1;
+select * from t1;
+drop view v1;
+drop table t1;
+
+--echo #
+--echo # 4. Creating a temporary table in presence of a base table.
+--echo #
+
+create table t1 (a int) select 1 as a;
+create temporary table if not exists t1 select 2 as a;
+select * from t1;
+--echo # Note: an essential warning.
+create temporary table if not exists t1 select 3 as a;
+select * from t1;
+drop temporary table t1;
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # 5. Creating a base table in presence of an updatable view.
+--echo #
+create table t2 (a int unique);
+create view t1 as select a from t2;
+insert into t1 (a) values (1);
+--error ER_TABLE_EXISTS_ERROR
+create table t1 (a int);
+--echo # Note: an essential warning.
+create table if not exists t1 (a int);
+--error ER_TABLE_EXISTS_ERROR
+create table t1 (a int) select 2 as a;
+select * from t1;
+--echo # Note: an essential warning.
+create table if not exists t1 (a int) select 2 as a;
+select * from t1;
+select * from t2;
+create temporary table if not exists t1 (a int) select 3 as a;
+select * from t1;
+select * from t2;
+--echo # Note: an essential warning.
+create temporary table if not exists t1 (a int) select 4 as a;
+select * from t1;
+select * from t2;
+drop temporary table t1;
+
+--echo #
+--echo # Repeating the test with a non-updatable view.
+--echo #
+drop view t1;
+create view t1 as select a + 5 as a from t2;
+--error ER_NON_INSERTABLE_TABLE
+insert into t1 (a) values (1);
+--error ER_NONUPDATEABLE_COLUMN
+update t1 set a=3 where a=2;
+
+--error ER_TABLE_EXISTS_ERROR
+create table t1 (a int);
+--echo # Note: an essential warning.
+create table if not exists t1 (a int);
+--error ER_TABLE_EXISTS_ERROR
+create table t1 (a int) select 2 as a;
+select * from t1;
+--echo # Note: an essential warning.
+create table if not exists t1 (a int) select 2 as a;
+select * from t1;
+select * from t2;
+create temporary table if not exists t1 (a int) select 3 as a;
+select * from t1;
+select * from t2;
+--echo # Note: an essential warning.
+create temporary table if not exists t1 (a int) select 4 as a;
+select * from t1;
+select * from t2;
+drop temporary table t1;
+drop view t1;
+drop table t2;
+
+--echo #
+--echo # Repeating the test with a view select a constant number
+--echo #
+create view t1 as select 1 as a;
+--error ER_NON_INSERTABLE_TABLE
+insert into t1 (a) values (1);
+--error ER_NON_UPDATABLE_TABLE
+update t1 set a=3 where a=2;
+
+--error ER_TABLE_EXISTS_ERROR
+create table t1 (a int);
+--echo # Note: an essential warning.
+create table if not exists t1 (a int);
+--error ER_TABLE_EXISTS_ERROR
+create table t1 (a int) select 2 as a;
+select * from t1;
+--echo # Note: an essential warning.
+create table if not exists t1 (a int) select 2 as a;
+select * from t1;
+create temporary table if not exists t1 (a int) select 3 as a;
+select * from t1;
+--echo # Note: an essential warning.
+create temporary table if not exists t1 (a int) select 4 as a;
+select * from t1;
+drop temporary table t1;
+drop view t1;
+
+
+--echo #
+--echo # 6. Test of unique_table().
+--echo #
+
+create table t1 (a int) select 1 as a;
+create temporary table if not exists t1 (a int) select * from t1;
+--error ER_CANT_REOPEN_TABLE
+create temporary table if not exists t1 (a int) select * from t1;
+select * from t1;
+drop temporary table t1;
+select * from t1;
+drop table t1;
+create temporary table t1 (a int) select 1 as a;
+create table if not exists t1 (a int) select * from t1;
+create table if not exists t1 (a int) select * from t1;
+select * from t1;
+drop temporary table t1;
+select * from t1;
+drop table t1;
+--error ER_NO_SUCH_TABLE
+create table if not exists t1 (a int) select * from t1;
+
+--echo #
+--echo # 7. Test of non-matching columns, REPLACE and IGNORE.
+--echo #
+
+create table t1 (a int) select 1 as b, 2 as c;
+select * from t1;
+drop table t1;
+create table if not exists t1 (a int, b date, c date) select 1 as b, 2 as c;
+select * from t1;
+drop table t1;
+set @@session.sql_mode='STRICT_ALL_TABLES';
+--error ER_TRUNCATED_WRONG_VALUE
+create table if not exists t1 (a int, b date, c date) select 1 as b, 2 as c;
+--error ER_NO_SUCH_TABLE
+select * from t1;
+--error ER_TRUNCATED_WRONG_VALUE
+create table if not exists t1 (a int, b date, c date)
+ replace select 1 as b, 2 as c;
+--error ER_NO_SUCH_TABLE
+select * from t1;
+
+create table if not exists t1 (a int, b date, c date)
+ ignore select 1 as b, 2 as c;
+select * from t1;
+set @@session.sql_mode=default;
+drop table t1;
+
+create table if not exists t1 (a int unique, b int)
+ replace select 1 as a, 1 as b union select 1 as a, 2 as b;
+select * from t1;
+drop table t1;
+create table if not exists t1 (a int unique, b int)
+ ignore select 1 as a, 1 as b union select 1 as a, 2 as b;
+select * from t1;
+drop table t1;
+--echo #
diff --git a/mysql-test/t/create_select_tmp.test b/mysql-test/t/create_select_tmp.test
index a61f9f2466c..ef3315aed97 100644
--- a/mysql-test/t/create_select_tmp.test
+++ b/mysql-test/t/create_select_tmp.test
@@ -8,6 +8,10 @@
# This does not work for RBR yet.
--source include/have_binlog_format_mixed_or_statement.inc
+--disable_query_log
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+--enable_query_log
+
-- source include/have_innodb.inc
--disable_warnings
drop table if exists t1, t2;
diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test
index 4e337d54660..028b6453a04 100644
--- a/mysql-test/t/csv.test
+++ b/mysql-test/t/csv.test
@@ -1818,4 +1818,84 @@ SELECT * FROM t1;
DROP TABLE t1;
+#
+# Bug #40814 CSV engine does not parse \X characters when they occur in unquoted fields
+#
+
+--echo #
+--echo # Test for the following cases
+--echo # 1) integers and strings enclosed in quotes
+--echo # 2) integers and strings not enclosed in quotes
+--echo # 3) \X characters with quotes
+--echo # 4) \X characters outside quotes
+--echo #
+
+CREATE TABLE t1(c1 INT NOT NULL, c2 VARCHAR(50) NOT NULL) ENGINE=csv;
+
+--echo # remove the already existing .CSV file if any
+--remove_file $MYSQLD_DATADIR/test/t1.CSV
+
+--echo # create the .CSV file that contains the hard-coded data used in
+--echo # testing
+--write_file $MYSQLD_DATADIR/test/t1.CSV
+1,"integer sans quotes"
+1,string sans quotes
+1,quotes"in between" strings
+"1",Integer with quote and string with no quote
+1,"escape sequence \n \" \\ \r \a within quotes"
+1,escape sequence \n \" \\ \r \a without quotes
+EOF
+--cat_file $MYSQLD_DATADIR/test/t1.CSV
+
+--echo # select from the table in which the data has been filled in using
+--echo # the hard-coded .CSV file
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo # Test for the case when a field begins with a quote, but does not end in a
+--echo # quote.
+--echo # Note: This results in an error.
+
+CREATE TABLE t1(c1 INT NOT NULL, c2 VARCHAR(50) NOT NULL) ENGINE=csv;
+
+--echo # remove the already existing .CSV file if any
+--remove_file $MYSQLD_DATADIR/test/t1.CSV
+
+--echo # create the .CSV file that contains the hard-coded data used in
+--echo # testing
+--write_file $MYSQLD_DATADIR/test/t1.CSV
+1,"string only at the beginning quotes
+EOF
+--cat_file $MYSQLD_DATADIR/test/t1.CSV
+
+--echo # select from the table in which the data has been filled in using
+--echo # the hard-coded .CSV file
+--error ER_CRASHED_ON_USAGE
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo # Test for the case when a field ends with a quote, but does not begin in a
+--echo # quote.
+--echo # Note: This results in an error.
+
+CREATE TABLE t1(c1 INT NOT NULL, c2 VARCHAR(50) NOT NULL) ENGINE=csv;
+
+--echo # remove the already existing .CSV file if any
+--remove_file $MYSQLD_DATADIR/test/t1.CSV
+
+--echo # create the .CSV file that contains the hard-coded data used in
+--echo # testing
+--write_file $MYSQLD_DATADIR/test/t1.CSV
+1,string with only ending quotes"
+EOF
+--cat_file $MYSQLD_DATADIR/test/t1.CSV
+
+--echo # select from the table in which the data has been filled in using
+--echo # the hard-coded .CSV file
+--error ER_CRASHED_ON_USAGE
+SELECT * FROM t1;
+
+DROP TABLE t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test
index a75fd917052..b024420dee3 100644
--- a/mysql-test/t/ctype_big5.test
+++ b/mysql-test/t/ctype_big5.test
@@ -84,3 +84,64 @@ select hex(a) from t1;
drop table t1;
--echo End of 5.0 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=big5_chinese_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+DROP TABLE t1;
+#
+# Populate table t1 with all values [80..FF][20..FF]
+# Expected valid big5 codes: [A1..F9][40..7E,A1..FE] (89x157=13973)
+#
+CREATE TABLE t1 AS
+SELECT concat(head, tail) AS code, ' ' AS a
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+SELECT COUNT(*) FROM t1;
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1 WHERE a<>'';
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a) FROM t1 WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a));
+#
+# Make sure all possible conversion happened
+#
+# Expect U+2160 to U+2169 ROMAN NUMERAL ONE to ROMAN NUMERAL TEN
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# Expect U+0430 to U+0433 CYRILLIC SMALL LETTER A, BE, VE, GHE
+# Expect U+043D to U+0442 CYRILLIC SMALL LETTER EN, O, PE, ER, ES, TE
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_binary.test b/mysql-test/t/ctype_binary.test
new file mode 100644
index 00000000000..8b57854de83
--- /dev/null
+++ b/mysql-test/t/ctype_binary.test
@@ -0,0 +1,12 @@
+
+set names binary;
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--source include/ctype_numconv.inc
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test
index 6b6abbcfbcc..cb2113277b9 100644
--- a/mysql-test/t/ctype_collate.test
+++ b/mysql-test/t/ctype_collate.test
@@ -172,6 +172,18 @@ DROP TABLE t1;
#
# Test that optimizer doesn't use indexes with wrong collation
#
+#
+# BUG#48447, Delivering too few records with indexes using collate syntax
+#
+create table t1 (a varchar(1) character set latin1 collate latin1_general_ci);
+insert into t1 values ('A'),('a'),('B'),('b'),('C'),('c');
+select * from t1 where a > 'B' collate latin1_bin;
+select * from t1 where a <> 'B' collate latin1_bin;
+create index i on t1 (a);
+select * from t1 where a > 'B' collate latin1_bin;
+select * from t1 where a <> 'B' collate latin1_bin;
+drop table t1;
+
SET NAMES latin1;
CREATE TABLE t1
(s1 char(10) COLLATE latin1_german1_ci,
diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test
index 1fb656f2a01..a4c59f494a7 100644
--- a/mysql-test/t/ctype_cp1250_ch.test
+++ b/mysql-test/t/ctype_cp1250_ch.test
@@ -72,3 +72,13 @@ select a from t1 where a like "abcdefghá";
drop table t1;
# End of 4.1 tests
+
+#
+# Bug #48053 String::c_ptr has a race and/or does an invalid
+# memory reference
+# (triggered by Valgrind tests)
+# (see also ctype_eucjpms.test, ctype_cp1250.test, ctype_cp1251.test)
+#
+--error 1649
+set global LC_MESSAGES=convert((@@global.log_bin_trust_function_creators)
+ using cp1250);
diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test
index 2331c731061..aae50944456 100644
--- a/mysql-test/t/ctype_cp1251.test
+++ b/mysql-test/t/ctype_cp1251.test
@@ -47,6 +47,16 @@ insert into t1 (a) values ('air'),
select * from t1 where a like 'we_%';
drop table t1;
+#
+# Bug#158 ENUM and SET types does not accept valid cp1251 character
+#
+CREATE TABLE t1 (
+ e1 enum('ÿáúëêà'),
+ e2 enum('ìëÿêî')
+) ENGINE=MYISAM character set cp1251;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
# End of 4.1 tests
--echo #
@@ -55,6 +65,36 @@ drop table t1;
--source include/ctype_8bit.inc
+#
+# Bug #48053 String::c_ptr has a race and/or does an invalid
+# memory reference
+# (triggered by Valgrind tests)
+# (see also ctype_eucjpms.test, ctype_cp1250.test, ctype_cp1251.test)
+#
+--error 1649
+set global LC_TIME_NAMES=convert((-8388608) using cp1251);
+
+
--echo #
--echo # End of 5.1 tests
--echo #
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--source include/ctype_numconv.inc
+
+--echo #
+--echo # Bug#60101 COALESCE with cp1251 tables causes [Err] 1267 - Illegal mix of collations
+--echo #
+CREATE TABLE t1 (test1 INT, test2 VARCHAR(255));
+SHOW CREATE TABLE t1;
+SELECT COALESCE(IF(test1=1, 1, NULL), test2) FROM t1;
+SELECT COALESCE(IF(test1=1, NULL, 1), test2) FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test
index f3038ccfa61..c36dcf4dc2d 100644
--- a/mysql-test/t/ctype_cp932_binlog_stm.test
+++ b/mysql-test/t/ctype_cp932_binlog_stm.test
@@ -4,6 +4,11 @@
-- source include/have_binlog_format_mixed_or_statement.inc
-- source extra/binlog_tests/ctype_cp932_binlog.test
+call mtr.add_suppression('Error in Log_event::read_log_event()');
+--disable_query_log
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+--enable_query_log
+
#
# Bug#18293: Values in stored procedure written to binlog unescaped
#
@@ -30,11 +35,8 @@ delimiter ;|
#
# #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump
-# Note: 364 is a magic position (found experimentally, depends on
-# the log's contents) that caused the server crash.
-
--error 1220
-SHOW BINLOG EVENTS FROM 365;
+SHOW BINLOG EVENTS FROM 490;
--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
CREATE TABLE t1 (a varchar(16)) character set cp932;
@@ -43,3 +45,98 @@ SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a);
DROP TABLE t1;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=cp932_japanese_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+--disable_warnings
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+--enable_warnings
+DROP TABLE t1;
+#
+# Populate table t1 with all codes [80..FF][20..FF]
+# excluding Half Width Kana [A1..DF]
+# Expected valid cp932 multibyte codes:
+# [81..9F,E0..FC][40..7E,80..fC] (60x188=11280 characters)
+#
+CREATE TABLE t1 AS
+SELECT concat(head, tail) AS code, ' ' AS a
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (head NOT BETWEEN 'A1' AND 'DF')
+AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+#
+# Populate t1 with Half Width Kana [A1..DF]
+#
+--disable_warnings
+INSERT t1 (code) SELECT head FROM head
+WHERE (head BETWEEN 'A1' AND 'DF')
+ORDER BY head;
+--enable_warnings
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=1;
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=2;
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a) FROM t1
+WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a))
+ORDER BY code;
+#
+# Make sure all possible conversion happened
+#
+# Expect U+212B ANGSTROM SIGN
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# Expect no results
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test cp932->Unicode conversion
+--echo #
+SELECT HEX(a), HEX(CONVERT(a USING utf8)) as b FROM t1
+WHERE a<>'' HAVING b<>'3F' ORDER BY code;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test Unicode->cp932 conversion
+--echo #
+--source include/ctype_utf8_table.inc
+SELECT HEX(a), HEX(CONVERT(a using cp932)) as b FROM t1 HAVING b<>'3F' ORDER BY BINARY a;
+DROP TABLE t1;
+
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_errors.test b/mysql-test/t/ctype_errors.test
new file mode 100644
index 00000000000..3c73fdae264
--- /dev/null
+++ b/mysql-test/t/ctype_errors.test
@@ -0,0 +1,47 @@
+--echo Start of 5.4 tests
+
+#
+# ls_messages
+#
+CREATE TABLE t1(f1 INT);
+connect (con1,localhost,root,,test);
+connection con1;
+SET lc_messages=ru_RU;
+SHOW VARIABLES LIKE 'lc_messages';
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1(f1 INT);
+SET NAMES utf8;
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1(f1 INT);
+connection default;
+SHOW VARIABLES LIKE 'lc_messages';
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1(f1 INT);
+
+SHOW GLOBAL VARIABLES LIKE 'lc_messages';
+SET GLOBAL lc_messages=ru_RU;
+SHOW GLOBAL VARIABLES LIKE 'lc_messages';
+SET GLOBAL lc_messages=en_US;
+
+disconnect con1;
+DROP TABLE t1;
+
+#
+# Bug#1406 Tablename in Errormessage not in default characterset
+#
+--error ER_BAD_TABLE_ERROR
+drop table `ק`;
+
+#
+# Bug#14602 Error messages not returned in character_set_results
+#
+connect (con1,localhost,root,,test);
+connection con1;
+SET lc_messages=cs_CZ;
+SET NAMES UTF8;
+--error ER_BAD_DB_ERROR
+USE nonexistant;
+disconnect con1;
+connection default;
+
+--echo End of 5.4 tests
diff --git a/mysql-test/t/ctype_eucjpms.test b/mysql-test/t/ctype_eucjpms.test
index ec358d94900..fea48061c69 100644
--- a/mysql-test/t/ctype_eucjpms.test
+++ b/mysql-test/t/ctype_eucjpms.test
@@ -381,3 +381,116 @@ select hex(convert(_eucjpms 0xA5FE41 using ucs2));
# the next character, which is a single byte character 0x41.
select hex(convert(_eucjpms 0x8FABF841 using ucs2));
+
+#
+# Bug #48053 String::c_ptr has a race and/or does an invalid
+# memory reference
+# (triggered by Valgrind tests)
+# (see also ctype_eucjpms.test, ctype_cp1250.test, ctype_cp1251.test)
+#
+--error 1649
+set global LC_TIME_NAMES=convert((convert((0x63) using eucjpms)) using utf8);
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=eucjpms_japanese_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+DROP TABLE t1;
+#
+# Populate table t1 with all eucjpms codes.
+#
+CREATE TABLE t1 AS SELECT 'XXXXXX' AS code, ' ' AS a LIMIT 0;
+#
+# Pupulate JIS-X-0201 range (Half Width Kana)
+# Expected valid code range: [8E][A1..DF] (1x63 characters)
+#
+INSERT INTO t1 (code) SELECT concat('8E', head) FROM head
+WHERE (head BETWEEN 'A1' AND 'DF') ORDER BY head;
+#
+# Populate JIS-X-0208 range
+# Expected valid codes: [A1..FE][A1..FE] (94x94=8836 characters)
+#
+INSERT INTO t1 (code) SELECT concat(head, tail)
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (head NOT BETWEEN '8E' AND '8F')
+AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+#
+# Populate JIS-X-0212 range
+# Expected valid codes [8F][A1..FE][A1..FE] (1x94x94=8836 characters)
+#
+INSERT INTO t1 (code) SELECT concat('8F', head, tail)
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t1 WHERE a<>'';
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=2;
+SELECT * FROM t1 WHERE CHAR_LENGTH(a)=2;
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=3;
+
+
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a) FROM t1 WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a)) ORDER BY code;
+#
+# Make sure all possible conversion happened
+#
+# Expect U+0122 LATIN CAPITAL LETTER G WITH CEDILLA
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# Expect U+00F0 LATIN SMALL LETTER ETH
+# Expect U+01F5 LATIN SMALL LETTER G WITH ACUTE
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test sjis->Unicode conversion
+--echo #
+SELECT HEX(a), HEX(CONVERT(a USING utf8)) as b FROM t1
+WHERE a<>'' HAVING b<>'3F' ORDER BY code;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test Unicode->sjis conversion
+--echo #
+--source include/ctype_utf8_table.inc
+SELECT HEX(a), HEX(CONVERT(a using sjis)) as b FROM t1 HAVING b<>'3F' ORDER BY BINARY a;
+DROP TABLE t1;
+
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_euckr.test b/mysql-test/t/ctype_euckr.test
index fcb94e7b6d1..644ffbb96d9 100644
--- a/mysql-test/t/ctype_euckr.test
+++ b/mysql-test/t/ctype_euckr.test
@@ -107,3 +107,68 @@ SELECT s, hex(a), hex(u), hex(a2) FROM t2 ORDER BY s;
DROP TABLE t1, t2;
--echo End of 5.4 tests
+
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=euckr_korean_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+DROP TABLE t1;
+#
+# Populate table t1 with all codes [80..FF][20..FF]
+# Expected valid euckr codes: [81..FE][41..5A,61..7A,81..FE]
+#
+CREATE TABLE t1 AS
+SELECT concat(head, tail) AS code, ' ' AS a
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1 WHERE a<>'';
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a) FROM t1 WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a));
+#
+# Make sure all possible conversion happened
+#
+# Expect U+212B ANGSTROM SIGN
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# Expect U+0111 LATIN SMALL LETTER D WITH STROKE
+# Expect U+24D0 to U+24E9 CIRCLED LATIN SMALL LETTER A to Z
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+
+DROP TABLE t1;
+
+
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_gb2312.test b/mysql-test/t/ctype_gb2312.test
index 86d1c7f72c9..f092a0a501f 100644
--- a/mysql-test/t/ctype_gb2312.test
+++ b/mysql-test/t/ctype_gb2312.test
@@ -33,3 +33,94 @@ SELECT hex(a) FROM t1 ORDER BY a;
DROP TABLE t1;
# End of 4.1 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=gb2312_chinese_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+DROP TABLE t1;
+#
+# Populate table t1 with all codes [80..FF][20..FF]
+# Expected valid gb2312 codes [A1..F7][A1..FE]
+#
+CREATE TABLE t1 AS
+SELECT concat(head, tail) AS code, ' ' AS a
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1 WHERE a<>'';
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a) FROM t1 WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a));
+#
+# Make sure all possible conversion happened
+#
+# Expect U+2160 to U+216B ROMAN NUMERAL ONE to ROMAN NUMERAL TWELVE
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# Expect
+# U+00E0 LATIN SMALL LETTER A WITH GRAVE
+# U+00E1 LATIN SMALL LETTER A WITH ACUTE
+# U+00E8 LATIN SMALL LETTER E WITH GRAVE
+# U+00E9 LATIN SMALL LETTER E WITH ACUTE
+# U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX
+# U+00EC LATIN SMALL LETTER I WITH GRAVE
+# U+00ED LATIN SMALL LETTER I WITH ACUTE
+# U+00F2 LATIN SMALL LETTER O WITH GRAVE
+# U+00F3 LATIN SMALL LETTER O WITH ACUTE
+# U+00F9 LATIN SMALL LETTER U WITH GRAVE
+# U+00FA LATIN SMALL LETTER U WITH ACUTE
+# U+00FC LATIN SMALL LETTER U WITH DIAERESIS
+# U+0101 LATIN SMALL LETTER A WITH MACRON
+# U+0113 LATIN SMALL LETTER E WITH MACRON
+# U+011B LATIN SMALL LETTER E WITH CARON
+# U+012B LATIN SMALL LETTER I WITH MACRON
+# U+0144 LATIN SMALL LETTER N WITH ACUTE
+# U+0148 LATIN SMALL LETTER N WITH CARON
+# U+014D LATIN SMALL LETTER O WITH MACRON
+# U+016B LATIN SMALL LETTER U WITH MACRON
+# U+01CE LATIN SMALL LETTER A WITH CARON
+# U+01D0 LATIN SMALL LETTER I WITH CARON
+# U+01D2 LATIN SMALL LETTER O WITH CARON
+# U+01D4 LATIN SMALL LETTER U WITH CARON
+# U+01D6 LATIN SMALL LETTER U WITH DIAERESIS AND MACRON
+# U+01D8 LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE
+# U+01DA LATIN SMALL LETTER U WITH DIAERESIS AND CARON
+# U+01DC LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+
+DROP TABLE t1;
+
+
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test
index 91fe50d89b9..b9e25e97a3c 100644
--- a/mysql-test/t/ctype_gbk.test
+++ b/mysql-test/t/ctype_gbk.test
@@ -68,3 +68,94 @@ SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll;
DROP TABLES t1;
--echo End of 5.0 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=gbk_chinese_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+DROP TABLE t1;
+#
+# Populate table t1 with all codes [80..FF][20..FF]
+# Expected valid gbk codes [81..FE][40..7E,80..FE]
+#
+CREATE TABLE t1 AS
+SELECT concat(head, tail) AS code, ' ' AS a
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1 WHERE a<>'';
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a) FROM t1 WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a));
+#
+# Make sure all possible conversion happened
+#
+# Expect U+216A to U+216B ROMAN NUMERAL ELEVEN to ROMAN TWELVE
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# Expect
+# U+00E0 LATIN SMALL LETTER A WITH GRAVE
+# U+00E1 LATIN SMALL LETTER A WITH ACUTE
+# U+00E8 LATIN SMALL LETTER E WITH GRAVE
+# U+00E9 LATIN SMALL LETTER E WITH ACUTE
+# U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX
+# U+00EC LATIN SMALL LETTER I WITH GRAVE
+# U+00ED LATIN SMALL LETTER I WITH ACUTE
+# U+00F2 LATIN SMALL LETTER O WITH GRAVE
+# U+00F3 LATIN SMALL LETTER O WITH ACUTE
+# U+00F9 LATIN SMALL LETTER U WITH GRAVE
+# U+00FA LATIN SMALL LETTER U WITH ACUTE
+# U+00FC LATIN SMALL LETTER U WITH DIAERESIS
+# U+0101 LATIN SMALL LETTER A WITH MACRON
+# U+0113 LATIN SMALL LETTER E WITH MACRON
+# U+011B LATIN SMALL LETTER E WITH CARON
+# U+012B LATIN SMALL LETTER I WITH MACRON
+# U+0144 LATIN SMALL LETTER N WITH ACUTE
+# U+0148 LATIN SMALL LETTER N WITH CARON
+# U+014D LATIN SMALL LETTER O WITH MACRON
+# U+016B LATIN SMALL LETTER U WITH MACRON
+# U+01CE LATIN SMALL LETTER A WITH CARON
+# U+01D0 LATIN SMALL LETTER I WITH CARON
+# U+01D2 LATIN SMALL LETTER O WITH CARON
+# U+01D4 LATIN SMALL LETTER U WITH CARON
+# U+01D6 LATIN SMALL LETTER U WITH DIAERESIS AND MACRON
+# U+01D8 LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE
+# U+01DA LATIN SMALL LETTER U WITH DIAERESIS AND CARON
+# U+01DC LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+
+DROP TABLE t1;
+
+
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test
index a7e6351161b..5d1acf107d7 100644
--- a/mysql-test/t/ctype_latin1.test
+++ b/mysql-test/t/ctype_latin1.test
@@ -128,7 +128,36 @@ select hex(cast(_ascii 0x7f as char(1) character set latin1));
--echo End of 5.0 tests
+
--echo #
--echo # Bug#58022 ... like ... escape export_set ( ... ) crashes when export_set returns warnings
--echo #
SELECT '' LIKE '' ESCAPE EXPORT_SET(1, 1, 1, 1, '');
+
+--echo End of 5.1 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--source include/ctype_numconv.inc
+
+--echo #
+--echo # Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters
+--echo #
+# Test latin1 client erroneously started with --default-character-set=utf8
+# EXPLAIN output should still be pretty readable.
+# We're using 'ó' (\xC3\xB3) as a magic sequence:
+# - it's "LATIN CAPITAL LETTER A WITH TILDE ABOVE + SUPERSCRIPT 3" in latin1
+# - it's "LATIN SMALL LETTER O WITH ACUTE ABOVE" in utf8.
+SET NAMES utf8;
+EXPLAIN EXTENDED SELECT 'abcdó', _latin1'abcdó', _utf8'abcdó';
+# Test normal latin1
+SET NAMES latin1;
+EXPLAIN EXTENDED SELECT 'abcdó', _latin1'abcdó', _utf8'abcdó';
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_latin1_de-master.opt b/mysql-test/t/ctype_latin1_de-master.opt
index 79fdb1c63dc..0c072424de9 100644
--- a/mysql-test/t/ctype_latin1_de-master.opt
+++ b/mysql-test/t/ctype_latin1_de-master.opt
@@ -1 +1 @@
---default-character-set=latin1 --default-collation=latin1_german2_ci
+--character-set-server=latin1 --collation-server=latin1_german2_ci
diff --git a/mysql-test/t/ctype_ldml.test b/mysql-test/t/ctype_ldml.test
index 9ab458ba516..4a867d85454 100644
--- a/mysql-test/t/ctype_ldml.test
+++ b/mysql-test/t/ctype_ldml.test
@@ -1,14 +1,36 @@
--source include/have_ucs2.inc
+--source include/have_utf8mb4.inc
+--source include/have_utf16.inc
+--source include/have_utf32.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
+--echo In the following tests we change the order of letter "b"
+--echo making it equal to letter "a", and check that it works
+--echo with all Unicode character sets
set names utf8;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
show variables like 'character_sets_dir%';
+show collation like 'utf8_phone_ci';
+CREATE TABLE t1 (
+ name VARCHAR(64),
+ phone VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_phone_ci
+);
+INSERT INTO t1 VALUES ('Svoj','+7 912 800 80 02');
+INSERT INTO t1 VALUES ('Hf','+7 (912) 800 80 04');
+INSERT INTO t1 VALUES ('Bar','+7-912-800-80-01');
+INSERT INTO t1 VALUES ('Ramil','(7912) 800 80 03');
+INSERT INTO t1 VALUES ('Sanja','+380 (912) 8008005');
+SELECT * FROM t1 ORDER BY phone;
+SELECT * FROM t1 WHERE phone='+7(912)800-80-01';
+SELECT * FROM t1 WHERE phone='79128008001';
+SELECT * FROM t1 WHERE phone='7 9 1 2 8 0 0 8 0 0 1';
+DROP TABLE t1;
+
show collation like 'utf8_test_ci';
create table t1 (c1 char(1) character set utf8 collate utf8_test_ci);
insert into t1 values ('a');
@@ -21,6 +43,24 @@ insert into t1 values ('a');
select * from t1 where c1='b';
drop table t1;
+show collation like 'utf8mb4_test_ci';
+create table t1 (c1 char(1) character set utf8mb4 collate utf8mb4_test_ci);
+insert into t1 values ('a');
+select * from t1 where c1='b';
+drop table t1;
+
+show collation like 'utf16_test_ci';
+create table t1 (c1 char(1) character set utf16 collate utf16_test_ci);
+insert into t1 values ('a');
+select * from t1 where c1='b';
+drop table t1;
+
+show collation like 'utf32_test_ci';
+create table t1 (c1 char(1) character set utf32 collate utf32_test_ci);
+insert into t1 values ('a');
+select * from t1 where c1='b';
+drop table t1;
+
#
# Bug#41084 full-text index added to custom UCA collation not working
@@ -65,6 +105,7 @@ DROP TABLE t1;
#
# Vietnamese experimental collation
#
+--echo Vietnamese experimental collation
show collation like 'ucs2_vn_ci';
create table t1 (c1 char(1) character set ucs2 collate ucs2_vn_ci);
@@ -107,3 +148,36 @@ drop table t1;
set names latin1;
show collation like 'latin1_test';
select "foo" = "foo " collate latin1_test;
+
+-- echo The following tests check that two-byte collation IDs work
+# The file ../std-data/Index.xml has a number of collations with high IDs.
+
+# Test that the "ID" column in I_S and SHOW queries can handle two bytes
+select * from information_schema.collations where id>256 order by id;
+show collation like '%test%';
+
+# Test that two-byte collation ID is correctly transfered to the client side.
+show collation like 'ucs2_vn_ci';
+create table t1 (c1 char(1) character set ucs2 collate ucs2_vn_ci);
+insert into t1 values (0x0061);
+--enable_metadata
+set @@character_set_results=NULL;
+select * from t1;
+--disable_metadata
+drop table t1;
+
+#
+# Check maximum collation ID (2047 as of MySQL-6.0.9)
+#
+CREATE TABLE t1 (s1 char(10) character set utf8 collate utf8_maxuserid_ci);
+INSERT INTO t1 VALUES ('a'),('b');
+SELECT * FROM t1 WHERE s1='a' ORDER BY BINARY s1;
+DROP TABLE t1;
+
+
+#
+# Bug#47756 Setting 2byte collation ID with 'set names' crashes the server
+#
+SET NAMES utf8 COLLATE utf8_phone_ci;
+SHOW COLLATION LIKE 'utf8_phone_ci';
+SET NAMES utf8;
diff --git a/mysql-test/t/ctype_like_range.test b/mysql-test/t/ctype_like_range.test
new file mode 100644
index 00000000000..34a7637222b
--- /dev/null
+++ b/mysql-test/t/ctype_like_range.test
@@ -0,0 +1,87 @@
+--source include/have_debug.inc
+--source include/have_ucs2.inc
+--source include/have_utf16.inc
+--source include/have_utf32.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a VARBINARY(32));
+INSERT INTO t1 (a) VALUES (''),('_'),('%'),('\_'),('\%'),('\\');
+INSERT INTO t1 (a) VALUES ('a'),('c');
+INSERT INTO t1 (a) VALUES ('a_'),('c_');
+INSERT INTO t1 (a) VALUES ('a%'),('c%');
+INSERT INTO t1 (a) VALUES ('aa'),('cc'),('ch');
+INSERT INTO t1 (a) VALUES ('aa_'),('cc_'),('ch_');
+INSERT INTO t1 (a) VALUES ('aa%'),('cc%'),('ch%');
+INSERT INTO t1 (a) VALUES ('aaa'),('ccc'),('cch');
+INSERT INTO t1 (a) VALUES ('aaa_'),('ccc_'),('cch_');
+INSERT INTO t1 (a) VALUES ('aaa%'),('ccc%'),('cch%');
+INSERT INTO t1 (a) VALUES ('aaaaaaaaaaaaaaaaaaaa');
+
+CREATE VIEW v1 AS
+ SELECT id, 'a' AS name, a AS val FROM t1
+UNION
+ SELECT id, 'mn', HEX(LIKE_RANGE_MIN(a, 16)) AS min FROM t1
+UNION
+ SELECT id, 'mx', HEX(LIKE_RANGE_MAX(a, 16)) AS max FROM t1
+UNION
+ SELECT id, 'sp', REPEAT('-', 32) AS sep FROM t1
+ORDER BY id, name;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET latin1;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_danish_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_danish_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf16 COLLATE utf16_danish_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_unicode_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_czech_ci;
+SELECT * FROM v1;
+
+ALTER TABLE t1 MODIFY a VARCHAR(32) CHARACTER SET utf32 COLLATE utf32_danish_ci;
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test
index 84048761228..060cf9fcf92 100644
--- a/mysql-test/t/ctype_many.test
+++ b/mysql-test/t/ctype_many.test
@@ -1,4 +1,7 @@
-- source include/have_ucs2.inc
+-- source include/have_utf8mb4.inc
+-- source include/have_utf16.inc
+-- source include/have_utf32.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
@@ -227,3 +230,92 @@ DO CONVERT(CAST(SUBSTRING_INDEX(FORMAT(1,'1111'), FORMAT('','Zpq'),1)
--echo #
--echo # End of 5.1 tests
--echo #
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # WL#1213 Implement 4-byte UTF8, UTF16 and UTF32
+--echo # Testing that only utf8mb4 is superset for utf8
+--echo # No other Unicode character set pairs have superset/subset relations
+--echo #
+
+CREATE TABLE t1 (
+ utf8 CHAR CHARACTER SET utf8,
+ utf8mb4 CHAR CHARACTER SET utf8mb4,
+ ucs2 CHAR CHARACTER SET ucs2,
+ utf16 CHAR CHARACTER SET utf16,
+ utf32 CHAR CHARACTER SET utf32
+);
+INSERT INTO t1 VALUES ('','','','','');
+
+# utf8mb4 is superset only for utf8
+SELECT CHARSET(CONCAT(utf8, utf8mb4)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf8, ucs2)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf8, utf16)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf8, utf32)) FROM t1;
+
+
+# utf8mb4 is superset only for utf8
+SELECT CHARSET(CONCAT(utf8mb4, utf8)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf8mb4, ucs2)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf8mb4, utf16)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf8mb4, utf32)) FROM t1;
+
+
+# ucs2 is not a superset for the other Unicode character sets
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(ucs2, utf8)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(ucs2, utf8mb4)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(ucs2, utf16)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(ucs2, utf32)) FROM t1;
+
+
+# utf16 is not a superset for the other Unicode character sets
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf16, utf8)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf16, ucs2)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf16, utf8mb4)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf16, utf32)) FROM t1;
+
+
+# utf32 is not a superset for the other Unicode character sets
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf32, utf8)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf32, ucs2)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf32, utf8mb4)) FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CHARSET(CONCAT(utf32, utf16)) FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#58321 No warning when characters outside BMP0 is converted to UCS2
+--echo #
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32);
+CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES (0x10082), (0x12345);
+INSERT INTO t2 SELECT * FROM t1;
+SELECT HEX(a) FROM t2;
+DROP TABLE t1;
+DROP TABLE t2;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test
index 7de94e34dea..f45e6ab9b54 100644
--- a/mysql-test/t/ctype_sjis.test
+++ b/mysql-test/t/ctype_sjis.test
@@ -92,4 +92,101 @@ INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a);
DROP TABLE t1;
+--echo #
+--echo # Bug#11766519 - Bug#59648: MY_STRTOLL10_MB2: ASSERTION `(*ENDPTR - S) % 2 == 0' FAILED.
+--echo #
+# In the below string backslash (0x5C) is a part of a multi-byte
+# character, so it should not be quoted.
+SELECT QUOTE('ƒ\');
+
+
--echo # End of 5.1 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=sjis_japanese_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+DROP TABLE t1;
+#
+# Populate table t1 with all codes [80..FF][20..FF]
+# excluding Half Width Kana [A1..DF]
+# Expected valid sjis codes:
+# [81..9F,E0..FC][40..7E,80..fC] (60x188=11280 characters)
+#
+CREATE TABLE t1 AS
+SELECT concat(head, tail) AS code, ' ' AS a
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (head NOT BETWEEN 'A1' AND 'DF')
+AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+#
+# Populate Half Width Kana: [A1..DF]
+#
+INSERT t1 (code) SELECT head FROM head WHERE (head BETWEEN 'A1' AND 'DF');
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=1;
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=2;
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a)
+FROM t1
+WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a))
+ORDER BY code;
+#
+# Make sure all possible conversion happened
+#
+# Expect U+212B ANGSTROM SIGN
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# Expect no results
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test sjis->Unicode conversion
+--echo #
+SELECT HEX(a), HEX(CONVERT(a USING utf8)) as b FROM t1
+WHERE a<>'' HAVING b<>'3F' ORDER BY code;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test Unicode->sjis conversion
+--echo #
+--source include/ctype_utf8_table.inc
+SELECT HEX(a), HEX(CONVERT(a using sjis)) as b FROM t1 HAVING b<>'3F' ORDER BY BINARY a;
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test
index 11a489ba24d..723962bbb3f 100644
--- a/mysql-test/t/ctype_uca.test
+++ b/mysql-test/t/ctype_uca.test
@@ -545,3 +545,19 @@ set collation_connection=ucs2_unicode_ci;
set names utf8;
-- echo End for 5.0 tests
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+#
+# Test my_like_range and contractions
+#
+SET collation_connection=utf8_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+SET collation_connection=ucs2_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index fd10ee3fdd6..24e68f2dab3 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -741,4 +741,24 @@ WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
+--echo #
+SELECT HEX(CHAR(COALESCE(NULL, CHAR(COUNT('%s') USING ucs2), 1, @@global.license, NULL) USING cp850));
+SELECT CONVERT(QUOTE(CHAR(0xf5 using ucs2)), SIGNED);
+
--echo End of 5.0 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+SET NAMES latin1;
+SET collation_connection=ucs2_general_ci;
+--source include/ctype_numconv.inc
+SET NAMES latin1;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_ucs2_def-master.opt b/mysql-test/t/ctype_ucs2_def-master.opt
index 84d2a52b639..711ec42bd8a 100644
--- a/mysql-test/t/ctype_ucs2_def-master.opt
+++ b/mysql-test/t/ctype_ucs2_def-master.opt
@@ -1 +1 @@
---default-collation=ucs2_unicode_ci --default-character-set=ucs2,latin1
+--collation-server=ucs2_unicode_ci --character-set-server=ucs2,latin1
diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test
index 4c29a2e11a0..4e1ee55e019 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -1219,3 +1219,105 @@ SELECT CONVERT(REPLACE(EXPORT_SET('a','a','a','','a'),'00','') USING ujis);
set names default;
set character_set_database=default;
set character_set_server=default;
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Testing WL#4583 Case conversion in Asian character sets
+--echo #
+#
+# Populate t1 with all hex digits
+#
+SET NAMES utf8;
+SET collation_connection=ujis_japanese_ci;
+CREATE TABLE t1 (b VARCHAR(2));
+INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+#
+# Populate tables head and tail with values '00'-'FF'
+#
+CREATE TEMPORARY TABLE head AS SELECT concat(b1.b, b2.b) AS head FROM t1 b1, t1 b2;
+CREATE TEMPORARY TABLE tail AS SELECT concat(b1.b, b2.b) AS tail FROM t1 b1, t1 b2;
+DROP TABLE t1;
+#
+# Populate table t1 with all ujis codes.
+#
+#
+CREATE TABLE t1 AS SELECT 'XXXXXX' AS code, ' ' AS a LIMIT 0;
+#
+# Pupulate JIS-X-0201 range (Half Width Kana)
+# Valid characters: [8E][A1-DF]
+#
+INSERT INTO t1 (code) SELECT concat('8E', head) FROM head
+WHERE (head BETWEEN 'A1' AND 'DF') ORDER BY head;
+#
+# Populate JIS-X-0208 range
+# Expected valid range: [A1..FE][A1..FE]
+#
+INSERT INTO t1 (code) SELECT concat(head, tail)
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (head NOT BETWEEN '8E' AND '8F')
+AND (tail BETWEEN '20' AND 'FF')
+ORDER BY head, tail;
+#
+# Populate JIS-X-0212 range
+# Expected valid range: [8F][A1..FE][A1..FE]
+#
+INSERT INTO t1 (code) SELECT concat('8F', head, tail)
+FROM head, tail
+WHERE (head BETWEEN '80' AND 'FF') AND (tail BETWEEN '80' AND 'FF')
+ORDER BY head, tail;
+DROP TEMPORARY TABLE head, tail;
+SHOW CREATE TABLE t1;
+
+UPDATE t1 SET a=unhex(code) ORDER BY code;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t1 WHERE a<>'';
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=2;
+SELECT COUNT(*) FROM t1 WHERE a<>'' AND OCTET_LENGTH(a)=3;
+#
+# Display all characters that have upper or lower case mapping.
+#
+SELECT code, hex(upper(a)), hex(lower(a)),a, upper(a), lower(a) FROM t1 WHERE hex(a)<>hex(upper(a)) OR hex(a)<>hex(lower(a)) ORDER BY code;
+#
+# Make sure all possible conversion happened
+#
+# Expect U+0122 LATIN CAPITAL LETTER G WITH CEDILLA
+#
+SELECT * FROM t1
+WHERE HEX(CAST(LOWER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(LOWER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+#
+# U+00F0 LATIN SMALL LETTER ETH
+# U+01F5 LATIN SMALL LETTER G WITH ACUTE
+#
+SELECT * FROM t1
+WHERE HEX(CAST(UPPER(a) AS CHAR CHARACTER SET utf8)) <>
+ HEX(UPPER(CAST(a AS CHAR CHARACTER SET utf8))) ORDER BY code;
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test sjis->Unicode conversion
+--echo #
+SELECT HEX(a), HEX(CONVERT(a USING utf8)) as b FROM t1
+WHERE a<>'' HAVING b<>'3F' ORDER BY code;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # WL#3090 Japanese Character Set adjustments
+--echo # Test Unicode->sjis conversion
+--echo #
+--source include/ctype_utf8_table.inc
+SELECT HEX(a), HEX(CONVERT(a using sjis)) as b FROM t1 HAVING b<>'3F' ORDER BY BINARY a;
+DROP TABLE t1;
+
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf16.test b/mysql-test/t/ctype_utf16.test
new file mode 100644
index 00000000000..2f1651d0f40
--- /dev/null
+++ b/mysql-test/t/ctype_utf16.test
@@ -0,0 +1,764 @@
+-- source include/have_utf16.inc
+-- source include/have_utf8mb4.inc
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+SET NAMES latin1;
+SET character_set_connection=utf16;
+select hex('a'), hex('a ');
+-- source include/endspace.inc
+
+
+# Check that incomplete utf16 characters in HEX notation
+# are left-padded with zeros
+#
+select hex(_utf16 0x44);
+select hex(_utf16 0x3344);
+select hex(_utf16 0x113344);
+
+
+# Check that 0x20 is only trimmed when it is
+# a part of real SPACE character, not just a part
+# of a multibyte sequence.
+# Note, CYRILLIC LETTER ER is used as an example, which
+# is stored as 0x0420 in utf16, thus contains 0x20 in the
+# low byte. The second character is THREE-PER-M, U+2004,
+# which contains 0x20 in the high byte.
+
+CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf16;
+INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004');
+SELECT hex(word) FROM t1 ORDER BY word;
+SELECT hex(word2) FROM t1 ORDER BY word2;
+DELETE FROM t1;
+
+#
+# Check that real spaces are correctly trimmed.
+#
+INSERT INTO t1 VALUES (X'042000200020',X'042000200020'), (X'200400200020', X'200400200020');
+SELECT hex(word) FROM t1 ORDER BY word;
+SELECT hex(word2) FROM t1 ORDER BY word2;
+DROP TABLE t1;
+
+
+#
+# Check LPAD/RPAD
+#
+SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'0421'));
+SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'04210422'));
+SELECT hex(LPAD(_utf16 X'0420',10,_utf16 X'042104220423'));
+SELECT hex(LPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423'));
+SELECT hex(LPAD(_utf16 X'D800DC00', 10, _utf16 X'0421'));
+SELECT hex(LPAD(_utf16 X'0421', 10, _utf16 X'D800DC00'));
+
+SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'0421'));
+SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'04210422'));
+SELECT hex(RPAD(_utf16 X'0420',10,_utf16 X'042104220423'));
+SELECT hex(RPAD(_utf16 X'0420042104220423042404250426042704280429042A042B',10,_utf16 X'042104220423'));
+SELECT hex(RPAD(_utf16 X'D800DC00', 10, _utf16 X'0421'));
+SELECT hex(RPAD(_utf16 X'0421', 10, _utf16 X'D800DC00'));
+
+CREATE TABLE t1 SELECT
+LPAD(_utf16 X'0420',10,_utf16 X'0421') l,
+RPAD(_utf16 X'0420',10,_utf16 X'0421') r;
+SHOW CREATE TABLE t1;
+select hex(l), hex(r) from t1;
+DROP TABLE t1;
+
+create table t1 (f1 char(30));
+insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000");
+select lpad(f1, 12, "-o-/") from t1;
+drop table t1;
+
+######################################################
+#
+# Test of like
+#
+
+SET NAMES latin1;
+SET character_set_connection=utf16;
+--source include/ctype_like.inc
+
+SET NAMES utf8;
+SET character_set_connection=utf16;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf16);
+INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывÐ'),('ФЫВÐ');
+INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж');
+INSERT INTO t1 VALUES ('фывÐпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж');
+INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВÐПРОЛДЖ');
+SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a;
+SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a;
+SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a;
+SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf16_bin ORDER BY BINARY a;
+DROP TABLE t1;
+
+CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word))
+ENGINE=MyISAM CHARACTER SET utf16;
+INSERT INTO t1 (word) VALUES ("cat");
+SELECT * FROM t1 WHERE word LIKE "c%";
+SELECT * FROM t1 WHERE word LIKE "ca_";
+SELECT * FROM t1 WHERE word LIKE "cat";
+SELECT * FROM t1 WHERE word LIKE _utf16 x'00630025'; # "c%"
+SELECT * FROM t1 WHERE word LIKE _utf16 x'00630061005F'; # "ca_"
+DROP TABLE t1;
+
+
+#
+# Check that INSERT() works fine.
+# This invokes charpos() function.
+select insert(_utf16 0x006100620063,10,2,_utf16 0x006400650066);
+select insert(_utf16 0x006100620063,1,2,_utf16 0x006400650066);
+
+########################################################
+#
+# Bug 1264
+#
+# Description:
+#
+# When using a ucs2 table in MySQL,
+# either with ucs2_general_ci or ucs2_bin collation,
+# words are returned in an incorrect order when using ORDER BY
+# on an _indexed_ CHAR or VARCHAR column. They are sorted with
+# the longest word *first* instead of last. I.E. The word "aardvark"
+# is in the results before the word "a".
+#
+# If there is no index for the column, the problem does not occur.
+#
+# Interestingly, if there is no second column, the words are returned
+# in the correct order.
+#
+# According to EXPLAIN, it looks like when the output includes columns that
+# are not part of the index sorted on, it does a filesort, which fails.
+# Using a straight index yields correct results.
+
+SET NAMES latin1;
+
+#
+# Two fields, index
+#
+
+CREATE TABLE t1 (
+ word VARCHAR(64),
+ bar INT(11) default 0,
+ PRIMARY KEY (word))
+ ENGINE=MyISAM
+ CHARSET utf16
+ COLLATE utf16_general_ci ;
+
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+SELECT * FROM t1 ORDER BY word;
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+SELECT word FROM t1 ORDER by word;
+DROP TABLE t1;
+
+
+#
+# One field, index
+#
+
+CREATE TABLE t1 (
+ word VARCHAR(64) ,
+ PRIMARY KEY (word))
+ ENGINE=MyISAM
+ CHARSET utf16
+ COLLATE utf16_general_ci;
+
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY WORD;
+SELECT * FROM t1 ORDER BY word;
+DROP TABLE t1;
+
+
+#
+# Two fields, no index
+#
+
+CREATE TABLE t1 (
+ word TEXT,
+ bar INT(11) AUTO_INCREMENT,
+ PRIMARY KEY (bar))
+ ENGINE=MyISAM
+ CHARSET utf16
+ COLLATE utf16_general_ci ;
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a" );
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+SELECT * FROM t1 ORDER BY word;
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+SELECT word FROM t1 ORDER BY word;
+DROP TABLE t1;
+
+#
+# END OF Bug 1264 test
+#
+########################################################
+
+
+#
+# Check alignment for from-binary-conversion with CAST and CONVERT
+#
+SELECT hex(cast(0xAA as char character set utf16));
+SELECT hex(convert(0xAA using utf16));
+
+#
+# Check alignment for string types
+#
+CREATE TABLE t1 (a char(10) character set utf16);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a varchar(10) character set utf16);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a text character set utf16);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a mediumtext character set utf16);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a longtext character set utf16);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+##
+## Bug #5024 Server crashes with queries on fields
+## with certain charset/collation settings
+##
+##
+#create table t1 (s1 char character set utf16 collate utf16_czech_ci);
+#insert into t1 values ('0'),('1'),('2'),('a'),('b'),('c');
+#select s1 from t1 where s1 > 'a' order by s1;
+#drop table t1;
+#
+
+#
+# Bug #5081 : UCS2 fields are filled with '0x2020'
+# after extending field length
+#
+create table t1(a char(1)) default charset utf16;
+insert into t1 values ('a'),('b'),('c');
+alter table t1 modify a char(5);
+select a, hex(a) from t1;
+drop table t1;
+
+#
+# Check prepare statement from an UTF16 string
+#
+set @ivar= 1234;
+set @str1 = 'select ?';
+set @str2 = convert(@str1 using utf16);
+prepare stmt1 from @str2;
+execute stmt1 using @ivar;
+
+#
+# Check that utf16 works with ENUM and SET type
+#
+set names utf8;
+create table t1 (a enum('x','y','z') character set utf16);
+show create table t1;
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+select a, hex(a) from t1 order by a;
+alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set utf16;
+show create table t1;
+insert into t1 values ('D');
+insert into t1 values ('E ');
+insert into t1 values ('ä');
+insert into t1 values ('ö');
+insert into t1 values ('ü');
+select a, hex(a) from t1 order by a;
+drop table t1;
+
+create table t1 (a set ('x','y','z','ä','ö','ü') character set utf16);
+show create table t1;
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+insert into t1 values ('x,y');
+insert into t1 values ('x,y,z,ä,ö,ü');
+select a, hex(a) from t1 order by a;
+drop table t1;
+
+#
+# Bug#7302 UCS2 data in ENUM fields get truncated when new column is added
+#
+create table t1(a enum('a','b','c')) default character set utf16;
+insert into t1 values('a'),('b'),('c');
+alter table t1 add b char(1);
+show warnings;
+select * from t1 order by a;
+drop table t1;
+
+SET NAMES latin1;
+SET collation_connection='utf16_general_ci';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_escape.inc
+SET NAMES latin1;
+SET collation_connection='utf16_bin';
+-- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
+-- source include/ctype_like_escape.inc
+
+#
+# Bug#10344 Some string functions fail for UCS2
+#
+select hex(substr(_utf16 0x00e400e50068,1));
+select hex(substr(_utf16 0x00e400e50068,2));
+select hex(substr(_utf16 0x00e400e50068,3));
+select hex(substr(_utf16 0x00e400e50068,-1));
+select hex(substr(_utf16 0x00e400e50068,-2));
+select hex(substr(_utf16 0x00e400e50068,-3));
+select hex(substr(_utf16 0x00e400e5D800DC00,1));
+select hex(substr(_utf16 0x00e400e5D800DC00,2));
+select hex(substr(_utf16 0x00e400e5D800DC00,3));
+select hex(substr(_utf16 0x00e400e5D800DC00,-1));
+select hex(substr(_utf16 0x00e400e5D800DC00,-2));
+select hex(substr(_utf16 0x00e400e5D800DC00,-3));
+
+SET NAMES latin1;
+
+##
+## Bug#8235
+##
+## This bug also helped to find another problem that
+## INSERT of a UCS2 string containing a negative number
+## into a unsigned int column didn't produce warnings.
+## This test covers both problems.
+##
+##SET collation_connection='ucs2_swedish_ci';
+##CREATE TABLE t1 (Field1 int(10) default '0');
+### no warnings, negative numbers are allowed
+##INSERT INTO t1 VALUES ('-1');
+##SELECT * FROM t1;
+##DROP TABLE t1;
+##CREATE TABLE t1 (Field1 int(10) unsigned default '0');
+### this should generate a "Data truncated" warning
+##INSERT INTO t1 VALUES ('-1');
+##DROP TABLE t1;
+##SET NAMES latin1;
+
+###
+### Bug #14583 Bug on query using a LIKE on indexed field with ucs2_bin collation
+###
+##--disable_warnings
+##create table t1(f1 varchar(5) CHARACTER SET utf16 COLLATE utf16_bin NOT NULL) engine=InnoDB;
+##--enable_warnings
+##insert into t1 values('a');
+##create index t1f1 on t1(f1);
+##select f1 from t1 where f1 like 'a%';
+##drop table t1;
+
+#
+# Bug#9442 Set parameter make query fail if column character set is UCS2
+#
+create table t1 (utext varchar(20) character set utf16);
+insert into t1 values ("lily");
+insert into t1 values ("river");
+prepare stmt from 'select utext from t1 where utext like ?';
+set @param1='%%';
+execute stmt using @param1;
+execute stmt using @param1;
+select utext from t1 where utext like '%%';
+drop table t1;
+deallocate prepare stmt;
+
+#
+# Bug#22052 Trailing spaces are not removed from UNICODE fields in an index
+#
+create table t1 (
+ a char(10) character set utf16 not null,
+ index a (a)
+) engine=myisam;
+insert into t1 values (repeat(0x201f, 10));
+insert into t1 values (repeat(0x2020, 10));
+insert into t1 values (repeat(0x2021, 10));
+# make sure "index read" is used
+explain select hex(a) from t1 order by a;
+select hex(a) from t1 order by a;
+alter table t1 drop index a;
+select hex(a) from t1 order by a;
+drop table t1;
+
+##
+## Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation
+## over a 'ucs2' field uses a temporary table
+##
+##CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci);
+##INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
+##SELECT id, MIN(s) FROM t1 GROUP BY id;
+##DROP TABLE t1;
+
+###
+### Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb
+###
+##
+##--disable_warnings
+##drop table if exists bug20536;
+##--enable_warnings
+##
+##set names latin1;
+##create table bug20536 (id bigint not null auto_increment primary key, name
+##varchar(255) character set ucs2 not null);
+##insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
+##select md5(name) from bug20536;
+##select sha1(name) from bug20536;
+##select make_set(3, name, upper(name)) from bug20536;
+##select export_set(5, name, upper(name)) from bug20536;
+##select export_set(5, name, upper(name), ",", 5) from bug20536;
+
+#
+# Bug #20108: corrupted default enum value for a ucs2 field
+#
+
+CREATE TABLE t1 (
+ status enum('active','passive') character set utf16 collate utf16_general_ci
+ NOT NULL default 'passive'
+);
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD a int NOT NULL AFTER status;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+##CREATE TABLE t2 (
+## status enum('active','passive') collate ucs2_turkish_ci
+## NOT NULL default 'passive'
+##);
+##SHOW CREATE TABLE t2;
+##ALTER TABLE t2 ADD a int NOT NULL AFTER status;
+##DROP TABLE t2;
+
+
+--echo End of 4.1 tests
+
+#
+# Conversion from an UTF16 string to a decimal column
+#
+CREATE TABLE t1 (a varchar(64) character set utf16, b decimal(10,3));
+INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
+update t1 set b=a;
+SELECT *, hex(a) FROM t1;
+DROP TABLE t1;
+
+#
+# Bug#9442 Set parameter make query fail if column character set is UCS2
+#
+create table t1 (utext varchar(20) character set utf16);
+insert into t1 values ("lily");
+insert into t1 values ("river");
+prepare stmt from 'select utext from t1 where utext like ?';
+set @param1='%%';
+execute stmt using @param1;
+execute stmt using @param1;
+select utext from t1 where utext like '%%';
+drop table t1;
+deallocate prepare stmt;
+
+#
+# Bug#22638 SOUNDEX broken for international characters
+#
+set names latin1;
+set character_set_connection=utf16;
+select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
+select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb'));
+select 'mood' sounds like 'mud';
+# Cyrillic A, BE, VE
+select hex(soundex(_utf16 0x041004110412));
+# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter
+select hex(soundex(_utf16 0x00BF00C0));
+set names latin1;
+
+#
+# Bug #14290: character_maximum_length for text fields
+#
+create table t1(a blob, b text charset utf16);
+select data_type, character_octet_length, character_maximum_length
+ from information_schema.columns where table_name='t1';
+drop table t1;
+
+
+set names latin1;
+set collation_connection=utf16_general_ci;
+#
+# Testing cs->coll->instr()
+#
+select position('bb' in 'abba');
+
+#
+# Testing cs->coll->hash_sort()
+#
+create table t1 (a varchar(10) character set utf16) engine=heap;
+insert into t1 values ('a'),('A'),('b'),('B');
+select * from t1 where a='a' order by binary a;
+select hex(min(binary a)),count(*) from t1 group by a;
+drop table t1;
+
+#
+# Testing cs->cset->numchars()
+#
+select char_length('abcd'), octet_length('abcd');
+select char_length(_utf16 0xD800DC00), octet_length(_utf16 0xD800DC00);
+select char_length(_utf16 0xD87FDFFF), octet_length(_utf16 0xD87FDFFF);
+
+#
+# Testing cs->cset->charpos()
+#
+select left('abcd',2);
+select hex(left(_utf16 0xD800DC00D87FDFFF, 1));
+select hex(right(_utf16 0xD800DC00D87FDFFF, 1));
+
+#
+# Testing cs->cset->well_formed_length()
+#
+create table t1 (a varchar(10) character set utf16);
+# Bad sequences
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf16 0xD800);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf16 0xDC00);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf16 0xD800D800);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf16 0xD800E800);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf16 0xD8000800);
+# Good sequences
+insert into t1 values (_utf16 0xD800DC00);
+insert into t1 values (_utf16 0xD800DCFF);
+insert into t1 values (_utf16 0xDBFFDC00);
+insert into t1 values (_utf16 0xDBFFDCFF);
+select hex(a) from t1;
+drop table t1;
+
+#
+# Bug#32393 Character sets: illegal characters in utf16 columns
+#
+# Tests that cs->cset->wc_mb() doesn't accept surrogate parts
+#
+# via alter
+#
+create table t1 (s1 varchar(50) character set ucs2);
+insert into t1 values (0xdf84);
+alter table t1 modify column s1 varchar(50) character set utf16;
+select hex(s1) from t1;
+drop table t1;
+#
+# via update
+#
+create table t1 (s1 varchar(5) character set ucs2, s2 varchar(5) character set utf16);
+insert into t1 (s1) values (0xdf84);
+update t1 set s2 = s1;
+select hex(s2) from t1;
+drop table t1;
+
+
+
+#
+# Testing cs->cset->lengthsp()
+#
+create table t1 (a char(10)) character set utf16;
+insert into t1 values ('a ');
+select hex(a) from t1;
+drop table t1;
+
+#
+# Testing cs->cset->caseup() and cs->cset->casedn()
+#
+select upper('abcd'), lower('ABCD');
+
+#
+# TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf16
+# Testing cs->cset->snprintf()
+#
+#create table t1 (a date);
+#insert into t1 values ('2007-09-16');
+#select * from t1;
+#drop table t1;
+
+#
+# Testing cs->cset->l10tostr
+# !!! Not used in the code
+
+#
+# Testing cs->cset->ll10tostr
+#
+create table t1 (a varchar(10) character set utf16);
+insert into t1 values (123456);
+select a, hex(a) from t1;
+drop table t1;
+
+
+# Testing cs->cset->fill
+# SOUNDEX fills strings with DIGIT ZERO up to four characters
+select hex(soundex('a'));
+
+#
+# Testing cs->cset->strntol
+# !!! Not used in the code
+
+#
+# Testing cs->cset->strntoul
+#
+create table t1 (a enum ('a','b','c')) character set utf16;
+insert into t1 values ('1');
+select * from t1;
+drop table t1;
+
+#
+# Testing cs->cset->strntoll and cs->cset->strntoull
+#
+set names latin1;
+select hex(conv(convert('123' using utf16), -10, 16));
+select hex(conv(convert('123' using utf16), 10, 16));
+
+#
+# Testing cs->cset->strntod
+#
+set names latin1;
+set character_set_connection=utf16;
+select 1.1 + '1.2';
+select 1.1 + '1.2xxx';
+
+# Testing strntoll10_utf16
+# Testing cs->cset->strtoll10
+select left('aaa','1');
+
+#
+# Testing cs->cset->strntoull10rnd
+#
+create table t1 (a int);
+insert into t1 values ('-1234.1e2');
+insert into t1 values ('-1234.1e2xxxx');
+insert into t1 values ('-1234.1e2 ');
+select * from t1;
+drop table t1;
+
+#
+# Testing cs->cset->scan
+#
+create table t1 (a int);
+insert into t1 values ('1 ');
+insert into t1 values ('1 x');
+select * from t1;
+drop table t1;
+
+#
+# Testing auto-conversion to TEXT
+#
+create table t1 (a varchar(17000) character set utf16);
+show create table t1;
+drop table t1;
+
+#
+# Testing that maximim possible key length is 1000 bytes
+#
+create table t1 (a varchar(250) character set utf16 primary key);
+show create table t1;
+drop table t1;
+--error ER_TOO_LONG_KEY
+create table t1 (a varchar(334) character set utf16 primary key);
+
+#
+# Conversion to utf8
+#
+create table t1 (a char(1) character set utf16);
+insert into t1 values (0xD800DC00),(0xD800DCFF),(0xDB7FDC00),(0xDB7FDCFF);
+insert into t1 values (0x00C0), (0x00FF),(0xE000), (0xFFFF);
+select hex(a), hex(@a:=convert(a using utf8mb4)), hex(convert(@a using utf16)) from t1;
+drop table t1;
+
+#
+# Test basic regex functionality
+#
+set collation_connection=utf16_general_ci;
+--source include/ctype_regex.inc
+set names latin1;
+
+#
+# Test how character set works with date/time
+#
+SET collation_connection=utf16_general_ci;
+--source include/ctype_datetime.inc
+SET NAMES latin1;
+
+#
+# Bug#33073 Character sets: ordering fails with utf32
+#
+SET collation_connection=utf16_general_ci;
+CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
+SELECT * FROM t1 ORDER BY s1;
+SET max_sort_length=4;
+SELECT * FROM t1 ORDER BY s1;
+DROP TABLE t1;
+SET max_sort_length=DEFAULT;
+SET NAMES latin1;
+
+--echo #
+--echo # Bug#52520 Difference in tinytext utf column metadata
+--echo #
+CREATE TABLE t1 (
+ s1 TINYTEXT CHARACTER SET utf16,
+ s2 TEXT CHARACTER SET utf16,
+ s3 MEDIUMTEXT CHARACTER SET utf16,
+ s4 LONGTEXT CHARACTER SET utf16
+);
+--enable_metadata
+SET NAMES utf8, @@character_set_results=NULL;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES latin1;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES utf8;
+SELECT *, HEX(s1) FROM t1;
+--disable_metadata
+CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug#11753363 (Bug#44793) Character sets: case clause, ucs2 or utf32, failure
+--echo #
+SELECT CASE _latin1'a' WHEN _utf16'a' THEN 'A' END;
+SELECT CASE _utf16'a' WHEN _latin1'a' THEN 'A' END;
+CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf16);
+INSERT INTO t1 VALUES ('a');
+SELECT CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END FROM t1;
+DROP TABLE t1;
+
+#
+## TODO: add tests for all engines
+#
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf16_def-master.opt b/mysql-test/t/ctype_utf16_def-master.opt
new file mode 100644
index 00000000000..55bb5d14bbd
--- /dev/null
+++ b/mysql-test/t/ctype_utf16_def-master.opt
@@ -0,0 +1 @@
+--character-set-server=utf16,latin1
diff --git a/mysql-test/t/ctype_utf16_def.test b/mysql-test/t/ctype_utf16_def.test
new file mode 100644
index 00000000000..d8ef4a4278b
--- /dev/null
+++ b/mysql-test/t/ctype_utf16_def.test
@@ -0,0 +1,8 @@
+--source include/have_utf16.inc
+
+#
+# Bug #32391 Character sets: crash with --character-set-server
+#
+SHOW VARIABLES LIKE 'collation_server';
+SHOW VARIABLES LIKE 'character_set_server';
+SHOW VARIABLES LIKE 'ft_stopword_file';
diff --git a/mysql-test/t/ctype_utf16_uca.test b/mysql-test/t/ctype_utf16_uca.test
new file mode 100644
index 00000000000..a6295c82dec
--- /dev/null
+++ b/mysql-test/t/ctype_utf16_uca.test
@@ -0,0 +1,297 @@
+-- source include/have_utf16.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+set names utf8;
+set collation_connection=utf16_unicode_ci;
+select hex('a'), hex('a ');
+-- source include/endspace.inc
+
+#
+# Bug #6787 LIKE not working properly with _ and utf8 data
+#
+select 'c' like '\_' as want0;
+
+#
+# Bug #5679 utf8_unicode_ci LIKE--trailing % doesn't equal zero characters
+#
+CREATE TABLE t (
+ c char(20) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARACTER SET utf16 COLLATE utf16_unicode_ci;
+INSERT INTO t VALUES ('a'),('ab'),('aba');
+ALTER TABLE t ADD INDEX (c);
+SELECT c FROM t WHERE c LIKE 'a%';
+DROP TABLE t;
+
+
+create table t1 (c1 char(10) character set utf16 collate utf16_bin);
+
+#
+# Basic Latin
+#
+insert into t1 values ('A'),('a');
+insert into t1 values ('B'),('b');
+insert into t1 values ('C'),('c');
+insert into t1 values ('D'),('d');
+insert into t1 values ('E'),('e');
+insert into t1 values ('F'),('f');
+insert into t1 values ('G'),('g');
+insert into t1 values ('H'),('h');
+insert into t1 values ('I'),('i');
+insert into t1 values ('J'),('j');
+insert into t1 values ('K'),('k');
+insert into t1 values ('L'),('l');
+insert into t1 values ('M'),('m');
+insert into t1 values ('N'),('n');
+insert into t1 values ('O'),('o');
+insert into t1 values ('P'),('p');
+insert into t1 values ('Q'),('q');
+insert into t1 values ('R'),('r');
+insert into t1 values ('S'),('s');
+insert into t1 values ('T'),('t');
+insert into t1 values ('U'),('u');
+insert into t1 values ('V'),('v');
+insert into t1 values ('W'),('w');
+insert into t1 values ('X'),('x');
+insert into t1 values ('Y'),('y');
+insert into t1 values ('Z'),('z');
+
+#
+# Latin1 suppliment
+#
+insert into t1 values (0x00e0),(0x00c0);
+insert into t1 values (0x00e1),(0x00c1);
+insert into t1 values (0x00e2),(0x00c2);
+insert into t1 values (0x00e3),(0x00c3);
+insert into t1 values (0x00e4),(0x00c4);
+insert into t1 values (0x00e5),(0x00c5);
+insert into t1 values (0x00e6),(0x00c6);
+insert into t1 values (0x00e7),(0x00c7);
+insert into t1 values (0x00e8),(0x00c8);
+insert into t1 values (0x00e9),(0x00c9);
+insert into t1 values (0x00ea),(0x00ca);
+insert into t1 values (0x00eb),(0x00cb);
+insert into t1 values (0x00ec),(0x00cc);
+insert into t1 values (0x00ed),(0x00cd);
+insert into t1 values (0x00ee),(0x00ce);
+insert into t1 values (0x00ef),(0x00cf);
+
+insert into t1 values (0x00f0),(0x00d0);
+insert into t1 values (0x00f1),(0x00d1);
+insert into t1 values (0x00f2),(0x00d2);
+insert into t1 values (0x00f3),(0x00d3);
+insert into t1 values (0x00f4),(0x00d4);
+insert into t1 values (0x00f5),(0x00d5);
+insert into t1 values (0x00f6),(0x00d6);
+insert into t1 values (0x00f7),(0x00d7);
+insert into t1 values (0x00f8),(0x00d8);
+insert into t1 values (0x00f9),(0x00d9);
+insert into t1 values (0x00fa),(0x00da);
+insert into t1 values (0x00fb),(0x00db);
+insert into t1 values (0x00fc),(0x00dc);
+insert into t1 values (0x00fd),(0x00dd);
+insert into t1 values (0x00fe),(0x00de);
+insert into t1 values (0x00ff),(0x00df);
+
+#
+# Latin extended-A, 0100-017F
+#
+insert into t1 values (0x0100),(0x0101),(0x0102),(0x0103);
+insert into t1 values (0x0104),(0x0105),(0x0106),(0x0107);
+insert into t1 values (0x0108),(0x0109),(0x010a),(0x010b);
+insert into t1 values (0x010c),(0x010d),(0x010e),(0x010f);
+insert into t1 values (0x0110),(0x0111),(0x0112),(0x0113);
+insert into t1 values (0x0114),(0x0115),(0x0116),(0x0117);
+insert into t1 values (0x0118),(0x0119),(0x011a),(0x011b);
+insert into t1 values (0x011c),(0x011d),(0x011e),(0x011f);
+insert into t1 values (0x0120),(0x0121),(0x0122),(0x0123);
+insert into t1 values (0x0124),(0x0125),(0x0126),(0x0127);
+insert into t1 values (0x0128),(0x0129),(0x012a),(0x012b);
+insert into t1 values (0x012c),(0x012d),(0x012e),(0x012f);
+insert into t1 values (0x0130),(0x0131),(0x0132),(0x0133);
+insert into t1 values (0x0134),(0x0135),(0x0136),(0x0137);
+insert into t1 values (0x0138),(0x0139),(0x013a),(0x013b);
+insert into t1 values (0x013c),(0x013d),(0x013e),(0x013f);
+insert into t1 values (0x0140),(0x0141),(0x0142),(0x0143);
+insert into t1 values (0x0144),(0x0145),(0x0146),(0x0147);
+insert into t1 values (0x0148),(0x0149),(0x014a),(0x014b);
+insert into t1 values (0x014c),(0x014d),(0x014e),(0x014f);
+insert into t1 values (0x0150),(0x0151),(0x0152),(0x0153);
+insert into t1 values (0x0154),(0x0155),(0x0156),(0x0157);
+insert into t1 values (0x0158),(0x0159),(0x015a),(0x015b);
+insert into t1 values (0x015c),(0x015d),(0x015e),(0x015f);
+insert into t1 values (0x0160),(0x0161),(0x0162),(0x0163);
+insert into t1 values (0x0164),(0x0165),(0x0166),(0x0167);
+insert into t1 values (0x0168),(0x0169),(0x016a),(0x016b);
+insert into t1 values (0x016c),(0x016d),(0x016e),(0x016f);
+insert into t1 values (0x0170),(0x0171),(0x0172),(0x0173);
+insert into t1 values (0x0174),(0x0175),(0x0176),(0x0177);
+insert into t1 values (0x0178),(0x0179),(0x017a),(0x017b);
+insert into t1 values (0x017c),(0x017d),(0x017e),(0x017f);
+
+#
+# Latin extended-B, 0180-024F
+#
+insert into t1 values (0x0180),(0x0181),(0x0182),(0x0183);
+insert into t1 values (0x0184),(0x0185),(0x0186),(0x0187);
+insert into t1 values (0x0188),(0x0189),(0x018a),(0x018b);
+insert into t1 values (0x018c),(0x018d),(0x018e),(0x018f);
+insert into t1 values (0x0190),(0x0191),(0x0192),(0x0193);
+insert into t1 values (0x0194),(0x0195),(0x0196),(0x0197);
+insert into t1 values (0x0198),(0x0199),(0x019a),(0x019b);
+insert into t1 values (0x019c),(0x019d),(0x019e),(0x019f);
+insert into t1 values (0x01a0),(0x01a1),(0x01a2),(0x01a3);
+insert into t1 values (0x01a4),(0x01a5),(0x01a6),(0x01a7);
+insert into t1 values (0x01a8),(0x01a9),(0x01aa),(0x01ab);
+insert into t1 values (0x01ac),(0x01ad),(0x01ae),(0x01af);
+insert into t1 values (0x01b0),(0x01b1),(0x01b2),(0x01b3);
+insert into t1 values (0x01b4),(0x01b5),(0x01b6),(0x01b7);
+insert into t1 values (0x01b8),(0x01b9),(0x01ba),(0x01bb);
+insert into t1 values (0x01bc),(0x01bd),(0x01be),(0x01bf);
+insert into t1 values (0x01c0),(0x01c1),(0x01c2),(0x01c3);
+insert into t1 values (0x01c4),(0x01c5),(0x01c6),(0x01c7);
+insert into t1 values (0x01c8),(0x01c9),(0x01ca),(0x01cb);
+insert into t1 values (0x01cc),(0x01cd),(0x01ce),(0x01cf);
+insert into t1 values (0x01d0),(0x01d1),(0x01d2),(0x01d3);
+insert into t1 values (0x01d4),(0x01d5),(0x01d6),(0x01d7);
+insert into t1 values (0x01d8),(0x01d9),(0x01da),(0x01db);
+insert into t1 values (0x01dc),(0x01dd),(0x01de),(0x01df);
+insert into t1 values (0x01e0),(0x01e1),(0x01e2),(0x01e3);
+insert into t1 values (0x01e4),(0x01e5),(0x01e6),(0x01e7);
+insert into t1 values (0x01e8),(0x01e9),(0x01ea),(0x01eb);
+insert into t1 values (0x01ec),(0x01ed),(0x01ee),(0x01ef);
+insert into t1 values (0x01f0),(0x01f1),(0x01f2),(0x01f3);
+insert into t1 values (0x01f4),(0x01f5),(0x01f6),(0x01f7);
+insert into t1 values (0x01f8),(0x01f9),(0x01fa),(0x01fb);
+insert into t1 values (0x01fc),(0x01fd),(0x01fe),(0x01ff);
+
+
+insert into t1 values ('AA'),('Aa'),('aa'),('aA');
+insert into t1 values ('CH'),('Ch'),('ch'),('cH');
+insert into t1 values ('DZ'),('Dz'),('dz'),('dZ');
+insert into t1 values ('IJ'),('Ij'),('ij'),('iJ');
+insert into t1 values ('LJ'),('Lj'),('lj'),('lJ');
+insert into t1 values ('LL'),('Ll'),('ll'),('lL');
+insert into t1 values ('NJ'),('Nj'),('nj'),('nJ');
+insert into t1 values ('OE'),('Oe'),('oe'),('oE');
+insert into t1 values ('SS'),('Ss'),('ss'),('sS');
+insert into t1 values ('RR'),('Rr'),('rr'),('rR');
+
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_unicode_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_icelandic_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_latvian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_romanian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovenian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_polish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_estonian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_swedish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_turkish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_czech_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_danish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_lithuanian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_slovak_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_spanish2_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_roman_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_esperanto_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf16_hungarian_ci;
+
+drop table t1;
+
+#
+# Bug#5324
+#
+SET NAMES utf8;
+
+CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_general_ci NOT NULL, INDEX (c));
+INSERT INTO t1 VALUES (0x039C03C903B403B11F770308);
+#Check one row
+SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_general_ci;
+INSERT INTO t1 VALUES (0x039C03C903B4);
+#Check two rows
+SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025
+COLLATE utf16_general_ci ORDER BY c;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c));
+INSERT INTO t1 VALUES (0x039C03C903B403B11F770308);
+#Check one row
+SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci;
+INSERT INTO t1 VALUES (0x039C03C903B4);
+#Check two rows
+SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025
+COLLATE utf16_unicode_ci ORDER BY c;
+DROP TABLE t1;
+
+CREATE TABLE t1 (c varchar(200) CHARACTER SET utf16 COLLATE utf16_unicode_ci NOT NULL, INDEX (c));
+INSERT INTO t1 VALUES (0x039C03C903B403B11F770308);
+#Check one row row
+SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025 COLLATE utf16_unicode_ci;
+INSERT INTO t1 VALUES (0x039C03C903B4);
+#Check two rows
+SELECT * FROM t1 WHERE c LIKE _utf16 0x039C0025
+COLLATE utf16_unicode_ci ORDER BY c;
+DROP TABLE t1;
+
+
+SET NAMES utf8;
+SET @test_character_set='utf16';
+SET @test_collation='utf16_swedish_ci';
+-- source include/ctype_common.inc
+
+
+SET collation_connection='utf16_unicode_ci';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_escape.inc
+
+--echo End of 4.1 tests
+
+#
+# Check UPPER/LOWER changing length
+#
+# Result shorter than argument
+CREATE TABLE t1 (id int, a varchar(30) character set utf16);
+INSERT INTO t1 VALUES (1, 0x01310069), (2, 0x01310131);
+INSERT INTO t1 VALUES (3, 0x00690069), (4, 0x01300049);
+INSERT INTO t1 VALUES (5, 0x01300130), (6, 0x00490049);
+SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu
+FROM t1 ORDER BY id;
+ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf16 collate utf16_turkish_ci;
+SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu
+FROM t1 ORDER BY id;
+DROP TABLE t1;
+
+#
+# Bug #27079 Crash while grouping empty ucs2 strings
+#
+CREATE TABLE t1 (
+ c1 text character set utf16 collate utf16_polish_ci NOT NULL
+) ENGINE=MyISAM;
+insert into t1 values (''),('a');
+SELECT COUNT(*), c1 FROM t1 GROUP BY c1;
+DROP TABLE IF EXISTS t1;
+
+
+#
+# Test basic regex functionality
+#
+set collation_connection=utf16_unicode_ci;
+--source include/ctype_regex.inc
+
+#
+# Test my_like_range and contractions
+#
+SET collation_connection=utf16_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf32.test b/mysql-test/t/ctype_utf32.test
new file mode 100644
index 00000000000..10d365572bf
--- /dev/null
+++ b/mysql-test/t/ctype_utf32.test
@@ -0,0 +1,845 @@
+-- source include/have_utf32.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+SET NAMES latin1;
+SET character_set_connection=utf32;
+select hex('a'), hex('a ');
+-- source include/endspace.inc
+
+#
+# Check that incomplete utf32 characters in HEX notation
+# are left-padded with zeros
+#
+select hex(_utf32 0x44);
+select hex(_utf32 0x3344);
+select hex(_utf32 0x103344);
+
+select hex(_utf32 X'44');
+select hex(_utf32 X'3344');
+select hex(_utf32 X'103344');
+
+
+#
+# Check that 0x20 is only trimmed when it is
+# a part of real SPACE character, not just a part
+# of a multibyte sequence.
+# Note, CYRILLIC LETTER ER is used as an example, which
+# is stored as 0x0420 in UCS2, thus contains 0x20 in the
+# low byte. The second character is THREE-PER-M, U+2004,
+# which contains 0x20 in the high byte.
+#
+
+CREATE TABLE t1 (word VARCHAR(64), word2 CHAR(64)) CHARACTER SET utf32;
+INSERT INTO t1 VALUES (_koi8r 0xF2, _koi8r 0xF2), (X'2004',X'2004');
+SELECT hex(word) FROM t1 ORDER BY word;
+SELECT hex(word2) FROM t1 ORDER BY word2;
+DELETE FROM t1;
+
+#
+# Check that real spaces are correctly trimmed.
+#
+
+INSERT INTO t1 VALUES
+ (X'000004200000002000000020',X'000004200000002000000020'),
+ (X'000020040000002000000020',X'000020040000002000000020');
+SELECT hex(word) FROM t1 ORDER BY word;
+SELECT hex(word2) FROM t1 ORDER BY word2;
+DROP TABLE t1;
+
+#
+# Check LPAD/RPAD
+#
+SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0421'));
+SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'0000042100000422'));
+SELECT hex(LPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423'));
+SELECT hex(LPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423'));
+
+SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0421'));
+SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'0000042100000422'));
+SELECT hex(RPAD(_utf32 X'0420',10,_utf32 X'000004210000042200000423'));
+SELECT hex(RPAD(_utf32 X'000004200000042100000422000004230000042400000425000004260000042700000428000004290000042A0000042B',10,_utf32 X'000004210000042200000423'));
+
+CREATE TABLE t1 SELECT
+LPAD(_utf32 X'0420',10,_utf32 X'0421') l,
+RPAD(_utf32 X'0420',10,_utf32 X'0421') r;
+SHOW CREATE TABLE t1;
+select hex(l), hex(r) from t1;
+DROP TABLE t1;
+
+create table t1 (f1 char(30));
+insert into t1 values ("103000"), ("22720000"), ("3401200"), ("78000");
+select lpad(f1, 12, "-o-/") from t1;
+drop table t1;
+
+######################################################
+#
+# Test of like
+#
+
+SET NAMES latin1;
+SET character_set_connection=utf32;
+--source include/ctype_like.inc
+
+SET NAMES utf8;
+SET character_set_connection=utf32;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf32);
+INSERT INTO t1 VALUES ('фыва'),('Фыва'),('фЫва'),('фыВа'),('фывÐ'),('ФЫВÐ');
+INSERT INTO t1 VALUES ('фывапролдж'),('Фывапролдж'),('фЫвапролдж'),('фыВапролдж');
+INSERT INTO t1 VALUES ('фывÐпролдж'),('фываПролдж'),('фывапРолдж'),('фывапрОлдж');
+INSERT INTO t1 VALUES ('фывапроЛдж'),('фывапролДж'),('фывапролдЖ'),('ФЫВÐПРОЛДЖ');
+SELECT * FROM t1 WHERE a LIKE '%фЫва%' ORDER BY BINARY a;
+SELECT * FROM t1 WHERE a LIKE '%фЫв%' ORDER BY BINARY a;
+SELECT * FROM t1 WHERE a LIKE 'фЫва%' ORDER BY BINARY a;
+SELECT * FROM t1 WHERE a LIKE 'фЫва%' COLLATE utf32_bin ORDER BY BINARY a;
+DROP TABLE t1;
+
+CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word))
+ENGINE=MyISAM CHARACTER SET utf32;
+INSERT INTO t1 (word) VALUES ("cat");
+SELECT * FROM t1 WHERE word LIKE "c%";
+SELECT * FROM t1 WHERE word LIKE "ca_";
+SELECT * FROM t1 WHERE word LIKE "cat";
+SELECT * FROM t1 WHERE word LIKE _utf32 x'0000006300000025'; # "c%"
+SELECT * FROM t1 WHERE word LIKE _utf32 x'00000063000000610000005F'; # "ca_"
+DROP TABLE t1;
+
+
+#
+# Check that INSERT() works fine.
+# This invokes charpos() function.
+select insert(_utf32 0x000000610000006200000063,10,2,_utf32 0x000000640000006500000066);
+select insert(_utf32 0x000000610000006200000063,1,2,_utf32 0x000000640000006500000066);
+
+#######################################################
+
+#
+# Bug 1264
+#
+# Description:
+#
+# When using a ucs2 table in MySQL,
+# either with ucs2_general_ci or ucs2_bin collation,
+# words are returned in an incorrect order when using ORDER BY
+# on an _indexed_ CHAR or VARCHAR column. They are sorted with
+# the longest word *first* instead of last. I.E. The word "aardvark"
+# is in the results before the word "a".
+#
+# If there is no index for the column, the problem does not occur.
+#
+# Interestingly, if there is no second column, the words are returned
+# in the correct order.
+#
+# According to EXPLAIN, it looks like when the output includes columns that
+# are not part of the index sorted on, it does a filesort, which fails.
+# Using a straight index yields correct results.
+
+SET NAMES latin1;
+
+#
+# Two fields, index
+#
+
+CREATE TABLE t1 (
+ word VARCHAR(64),
+ bar INT(11) default 0,
+ PRIMARY KEY (word))
+ ENGINE=MyISAM
+ CHARSET utf32
+ COLLATE utf32_general_ci ;
+
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+SELECT * FROM t1 ORDER BY word;
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+SELECT word FROM t1 ORDER by word;
+DROP TABLE t1;
+
+
+#
+# One field, index
+#
+
+CREATE TABLE t1 (
+ word VARCHAR(64) ,
+ PRIMARY KEY (word))
+ ENGINE=MyISAM
+ CHARSET utf32
+ COLLATE utf32_general_ci;
+
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY WORD;
+SELECT * FROM t1 ORDER BY word;
+DROP TABLE t1;
+
+
+#
+# Two fields, no index
+#
+
+CREATE TABLE t1 (
+ word TEXT,
+ bar INT(11) AUTO_INCREMENT,
+ PRIMARY KEY (bar))
+ ENGINE=MyISAM
+ CHARSET utf32
+ COLLATE utf32_general_ci ;
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a" );
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+SELECT * FROM t1 ORDER BY word;
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+SELECT word FROM t1 ORDER BY word;
+DROP TABLE t1;
+
+#
+# END OF Bug 1264 test
+#
+########################################################
+
+
+#
+# Check alignment for from-binary-conversion with CAST and CONVERT
+#
+SELECT hex(cast(0xAA as char character set utf32));
+SELECT hex(convert(0xAA using utf32));
+
+#
+# Check alignment for string types
+#
+CREATE TABLE t1 (a char(10) character set utf32);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a varchar(10) character set utf32);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a text character set utf32);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a mediumtext character set utf32);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a longtext character set utf32);
+INSERT INTO t1 VALUES (0x1),(0x11),(0x111),(0x1111),(0x11111);
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+##
+## Bug #5024 Server crashes with queries on fields
+## with certain charset/collation settings
+##
+#
+#create table t1 (s1 char character set `ucs2` collate `ucs2_czech_ci`);
+#insert into t1 values ('0'),('1'),('2'),('a'),('b'),('c');
+#select s1 from t1 where s1 > 'a' order by s1;
+#drop table t1;
+
+#
+# Bug #5081 : UCS2 fields are filled with '0x2020'
+# after extending field length
+#
+create table t1(a char(1)) default charset utf32;
+insert into t1 values ('a'),('b'),('c');
+alter table t1 modify a char(5);
+select a, hex(a) from t1;
+drop table t1;
+
+#
+# Check prepare statement from an UTF32 string
+#
+set @ivar= 1234;
+set @str1 = 'select ?';
+set @str2 = convert(@str1 using utf32);
+prepare stmt1 from @str2;
+execute stmt1 using @ivar;
+
+#
+# Check that utf32 works with ENUM and SET type
+#
+set names utf8;
+create table t1 (a enum('x','y','z') character set utf32);
+show create table t1;
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+select a, hex(a) from t1 order by a;
+alter table t1 change a a enum('x','y','z','d','e','ä','ö','ü') character set utf32;
+show create table t1;
+insert into t1 values ('D');
+insert into t1 values ('E ');
+insert into t1 values ('ä');
+insert into t1 values ('ö');
+insert into t1 values ('ü');
+select a, hex(a) from t1 order by a;
+drop table t1;
+
+create table t1 (a set ('x','y','z','ä','ö','ü') character set utf32);
+show create table t1;
+insert into t1 values ('x');
+insert into t1 values ('y');
+insert into t1 values ('z');
+insert into t1 values ('x,y');
+insert into t1 values ('x,y,z,ä,ö,ü');
+select a, hex(a) from t1 order by a;
+drop table t1;
+
+#
+# Bug#7302 UCS2 data in ENUM fields get truncated when new column is added
+#
+create table t1(a enum('a','b','c')) default character set utf32;
+insert into t1 values('a'),('b'),('c');
+alter table t1 add b char(1);
+show warnings;
+select * from t1 order by a;
+drop table t1;
+
+SET NAMES latin1;
+SET collation_connection='utf32_general_ci';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_escape.inc
+SET NAMES latin1;
+SET collation_connection='utf32_bin';
+-- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
+-- source include/ctype_like_escape.inc
+
+#
+# Bug#10344 Some string functions fail for UCS2
+#
+select hex(substr(_utf32 0x000000e4000000e500000068,1));
+select hex(substr(_utf32 0x000000e4000000e500000068,2));
+select hex(substr(_utf32 0x000000e4000000e500000068,3));
+select hex(substr(_utf32 0x000000e4000000e500000068,-1));
+select hex(substr(_utf32 0x000000e4000000e500000068,-2));
+select hex(substr(_utf32 0x000000e4000000e500000068,-3));
+
+#SET NAMES latin1;
+#
+# Bug#8235
+#
+# This bug also helped to find another problem that
+# INSERT of a UCS2 string containing a negative number
+# into a unsigned int column didn't produce warnings.
+# This test covers both problems.
+#
+#SET collation_connection='ucs2_swedish_ci';
+#CREATE TABLE t1 (Field1 int(10) default '0');
+## no warnings, negative numbers are allowed
+#INSERT INTO t1 VALUES ('-1');
+#SELECT * FROM t1;
+#DROP TABLE t1;
+#CREATE TABLE t1 (Field1 int(10) unsigned default '0');
+## this should generate a "Data truncated" warning
+#INSERT INTO t1 VALUES ('-1');
+#DROP TABLE t1;
+#SET NAMES latin1;
+
+#
+##
+## Bug#18691 Converting number to UNICODE string returns invalid result
+##
+#SELECT CONVERT(103, CHAR(50) UNICODE);
+#SELECT CONVERT(103.0, CHAR(50) UNICODE);
+#SELECT CONVERT(-103, CHAR(50) UNICODE);
+#SELECT CONVERT(-103.0, CHAR(50) UNICODE);
+
+#
+# Bug#9557 MyISAM utf8 table crash
+#
+CREATE TABLE t1 (
+ a varchar(250) NOT NULL default '',
+ KEY a (a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf32 COLLATE utf32_general_ci;
+insert into t1 values (0x803d);
+insert into t1 values (0x005b);
+select hex(a) from t1;
+drop table t1;
+
+##
+## Bug #14583 Bug on query using a LIKE on indexed field with ucs2_bin collation
+##
+#--disable_warnings
+#create table t1(f1 varchar(5) CHARACTER SET utf32 COLLATE utf32_bin NOT NULL) engine=InnoDB;
+#--enable_warnings
+#insert into t1 values('a');
+#create index t1f1 on t1(f1);
+#select f1 from t1 where f1 like 'a%';
+#drop table t1;
+
+#
+# Bug#9442 Set parameter make query fail if column character set is UCS2
+#
+create table t1 (utext varchar(20) character set utf32);
+insert into t1 values ("lily");
+insert into t1 values ("river");
+prepare stmt from 'select utext from t1 where utext like ?';
+set @param1='%%';
+execute stmt using @param1;
+execute stmt using @param1;
+select utext from t1 where utext like '%%';
+drop table t1;
+deallocate prepare stmt;
+
+#
+# Bug#22052 Trailing spaces are not removed from UNICODE fields in an index
+#
+create table t1 (
+ a char(10) character set utf32 not null,
+ index a (a)
+) engine=myisam;
+insert into t1 values (repeat(0x0000201f, 10));
+insert into t1 values (repeat(0x00002020, 10));
+insert into t1 values (repeat(0x00002021, 10));
+# make sure "index read" is used
+explain select hex(a) from t1 order by a;
+select hex(a) from t1 order by a;
+alter table t1 drop index a;
+select hex(a) from t1 order by a;
+drop table t1;
+
+#
+# Bug #20076: server crashes for a query with GROUP BY if MIN/MAX aggregation
+# over a 'ucs2' field uses a temporary table
+#
+#CREATE TABLE t1 (id int, s char(5) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci);
+#INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
+#SELECT id, MIN(s) FROM t1 GROUP BY id;
+#DROP TABLE t1;
+
+##
+## Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb
+##
+#
+#--disable_warnings
+#drop table if exists bug20536;
+#--enable_warnings
+#
+#set names latin1;
+#create table bug20536 (id bigint not null auto_increment primary key, name
+#varchar(255) character set ucs2 not null);
+#insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
+#select md5(name) from bug20536;
+#select sha1(name) from bug20536;
+#select make_set(3, name, upper(name)) from bug20536;
+#select export_set(5, name, upper(name)) from bug20536;
+#select export_set(5, name, upper(name), ",", 5) from bug20536;
+
+#
+# Bug #20108: corrupted default enum value for a ucs2 field
+#
+
+CREATE TABLE t1 (
+ status enum('active','passive') character set utf32 collate utf32_general_ci
+ NOT NULL default 'passive'
+);
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD a int NOT NULL AFTER status;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#CREATE TABLE t2 (
+# status enum('active','passive') collate ucs2_turkish_ci
+# NOT NULL default 'passive'
+#);
+#SHOW CREATE TABLE t2;
+#ALTER TABLE t2 ADD a int NOT NULL AFTER status;
+#DROP TABLE t2;
+
+
+## Some broken functions: add these tests just to document current behavior.
+#
+## PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would
+## not be backwards compatible in all cases, so it's best to leave it alone
+#select password(name) from bug20536;
+#select old_password(name) from bug20536;
+#
+## Disable test case as encrypt relies on 'crypt' function.
+## "decrypt" is noramlly tested in func_crypt.test which have a
+## "have_crypt.inc" test
+#--disable_parsing
+## ENCRYPT relies on OS function crypt() which takes a NUL-terminated string; it
+## doesn't return good results for strings with embedded 0 bytes. It won't be
+## fixed unless we choose to re-implement the crypt() function ourselves to take
+## an extra size_t string_length argument.
+#select encrypt(name, 'SALT') from bug20536;
+#--enable_parsing
+#
+## QUOTE doesn't work with UCS2 data. It would require a total rewrite
+## of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is
+## supported fully as a client character set.
+#select quote(name) from bug20536;
+#
+#drop table bug20536;
+#
+--echo End of 4.1 tests
+
+
+#
+# Conversion from an UTF32 string to a decimal column
+#
+CREATE TABLE t1 (a varchar(64) character set utf32, b decimal(10,3));
+INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
+update t1 set b=a;
+SELECT *, hex(a) FROM t1;
+DROP TABLE t1;
+
+#
+# Bug#9442 Set parameter make query fail if column character set is UCS2
+#
+create table t1 (utext varchar(20) character set utf32);
+insert into t1 values ("lily");
+insert into t1 values ("river");
+prepare stmt from 'select utext from t1 where utext like ?';
+set @param1='%%';
+execute stmt using @param1;
+execute stmt using @param1;
+select utext from t1 where utext like '%%';
+drop table t1;
+deallocate prepare stmt;
+
+#
+# Bug#22638 SOUNDEX broken for international characters
+#
+set names latin1;
+set character_set_connection=utf32;
+select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
+select hex(soundex('')),hex(soundex('he')),hex(soundex('hello all folks')),hex(soundex('#3556 in bugdb'));
+select 'mood' sounds like 'mud';
+# Cyrillic A, BE, VE
+select hex(soundex(_utf32 0x000004100000041100000412));
+# Make sure that "U+00BF INVERTED QUESTION MARK" is not considered as letter
+select hex(soundex(_utf32 0x000000BF000000C0));
+set names latin1;
+
+#
+# Bug #14290: character_maximum_length for text fields
+#
+create table t1(a blob, b text charset utf32);
+select data_type, character_octet_length, character_maximum_length
+ from information_schema.columns where table_name='t1';
+drop table t1;
+
+
+set names latin1;
+set collation_connection=utf32_general_ci;
+#
+# Testing cs->coll->instr()
+#
+select position('bb' in 'abba');
+
+#
+# Testing cs->coll->hash_sort()
+#
+create table t1 (a varchar(10) character set utf32) engine=heap;
+insert into t1 values ('a'),('A'),('b'),('B');
+select * from t1 where a='a' order by binary a;
+select hex(min(binary a)),count(*) from t1 group by a;
+drop table t1;
+
+#
+# Testing cs->cset->numchars()
+#
+select char_length('abcd'), octet_length('abcd');
+
+#
+# Testing cs->cset->charpos()
+#
+select left('abcd',2);
+
+#
+# Testing cs->cset->well_formed_length()
+#
+create table t1 (a varchar(10) character set utf32);
+insert into t1 values (_utf32 0x0010FFFF);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf32 0x00110000);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf32 0x00110101);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf32 0x01000101);
+--error ER_INVALID_CHARACTER_STRING
+insert into t1 values (_utf32 0x11000101);
+select hex(a) from t1;
+drop table t1;
+
+#
+# Bug#32914 Character sets: illegal characters in utf8 and utf32 columns
+#
+create table t1 (utf32 varchar(2) character set utf32);
+--echo Wrong character with pad
+insert into t1 values (0x110000);
+--echo Wrong chsaracter without pad
+insert into t1 values (0x00110000);
+--echo Wrong character with pad followed by another wrong character
+insert into t1 values (0x11000000110000);
+--echo Good character with pad followed by bad character
+insert into t1 values (0x10000000110000);
+--echo Good character without pad followed by bad character
+insert into t1 values (0x0010000000110000);
+--echo Wrong character with the second byte higher than 0x10
+insert into t1 values (0x00800037);
+--echo Wrong character with pad with the second byte higher than 0x10
+insert into t1 values (0x00800037);
+drop table t1;
+
+#
+# Bug#32394 Character sets: crash if comparison with 0xfffd
+#
+select _utf32'a' collate utf32_general_ci = 0xfffd;
+select hex(concat(_utf32 0x0410 collate utf32_general_ci, 0x61));
+create table t1 (s1 varchar(5) character set utf32);
+insert into t1 values (0xfffd);
+select case when s1 = 0xfffd then 1 else 0 end from t1;
+select hex(s1) from t1 where s1 = 0xfffd;
+drop table t1;
+
+#
+# Testing cs->cset->lengthsp()
+#
+create table t1 (a char(10)) character set utf32;
+insert into t1 values ('a ');
+select hex(a) from t1;
+drop table t1;
+
+#
+# Testing cs->cset->caseup() and cs->cset->casedn()
+#
+select upper('abcd'), lower('ABCD');
+
+#
+# TODO: str_to_datetime() is broken and doesn't work with ucs2 and utf32
+# Testing cs->cset->snprintf()
+#
+#create table t1 (a date);
+#insert into t1 values ('2007-09-16');
+#select * from t1;
+#drop table t1;
+
+#
+# Testing cs->cset->l10tostr
+# !!! Not used in the code
+
+#
+# Testing cs->cset->ll10tostr
+#
+create table t1 (a varchar(10) character set utf32);
+insert into t1 values (123456);
+select a, hex(a) from t1;
+drop table t1;
+
+#
+# Testing cs->cset->fill
+# SOUNDEX fills strings with DIGIT ZERO up to four characters
+select hex(soundex('a'));
+
+#
+# Testing cs->cset->strntol
+# !!! Not used in the code
+
+#
+# Testing cs->cset->strntoul
+#
+create table t1 (a enum ('a','b','c')) character set utf32;
+insert into t1 values ('1');
+select * from t1;
+drop table t1;
+
+#
+# Testing cs->cset->strntoll and cs->cset->strntoull
+#
+set names latin1;
+select hex(conv(convert('123' using utf32), -10, 16));
+select hex(conv(convert('123' using utf32), 10, 16));
+
+#
+# Testing cs->cset->strntod
+#
+set names latin1;
+set character_set_connection=utf32;
+select 1.1 + '1.2';
+select 1.1 + '1.2xxx';
+
+# Testing strntoll10_utf32
+# Testing cs->cset->strtoll10
+select left('aaa','1');
+
+#
+# Testing cs->cset->strntoull10rnd
+#
+create table t1 (a int);
+insert into t1 values ('-1234.1e2');
+insert into t1 values ('-1234.1e2xxxx');
+insert into t1 values ('-1234.1e2 ');
+select * from t1;
+drop table t1;
+
+#
+# Testing cs->cset->scan
+#
+create table t1 (a int);
+insert into t1 values ('1 ');
+insert into t1 values ('1 x');
+select * from t1;
+drop table t1;
+
+#
+# Testing auto-conversion to TEXT
+#
+create table t1 (a varchar(17000) character set utf32);
+show create table t1;
+drop table t1;
+
+#
+# Testing that maximim possible key length is 1332 bytes
+#
+create table t1 (a varchar(250) character set utf32 primary key);
+show create table t1;
+drop table t1;
+--error ER_TOO_LONG_KEY
+create table t1 (a varchar(334) character set utf32 primary key);
+
+#
+# Testing mi_check with long key values
+#
+create table t1 (a varchar(333) character set utf32, key(a));
+insert into t1 values (repeat('a',333)), (repeat('b',333));
+flush tables;
+check table t1;
+drop table t1;
+
+#
+# Test how character set works with date/time
+#
+SET collation_connection=utf32_general_ci;
+--source include/ctype_datetime.inc
+SET NAMES latin1;
+
+#
+# Test basic regex functionality
+#
+set collation_connection=utf32_general_ci;
+--source include/ctype_regex.inc
+set names latin1;
+
+
+# TODO: add tests for all engines
+
+#
+# Bug #36418 Character sets: crash if char(256 using utf32)
+#
+select hex(char(0x01 using utf32));
+select hex(char(0x0102 using utf32));
+select hex(char(0x010203 using utf32));
+select hex(char(0x01020304 using utf32));
+create table t1 (s1 varchar(1) character set utf32, s2 text character set utf32);
+create index i on t1 (s1);
+insert into t1 values (char(256 using utf32), char(256 using utf32));
+select hex(s1), hex(s2) from t1;
+drop table t1;
+
+
+#
+# Bug#33073 Character sets: ordering fails with utf32
+#
+SET collation_connection=utf32_general_ci;
+CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
+SELECT * FROM t1 ORDER BY s1;
+SET max_sort_length=4;
+SELECT * FROM t1 ORDER BY s1;
+DROP TABLE t1;
+SET max_sort_length=DEFAULT;
+SET NAMES latin1;
+
+--echo #
+--echo # Bug#52520 Difference in tinytext utf column metadata
+--echo #
+CREATE TABLE t1 (
+ s1 TINYTEXT CHARACTER SET utf32,
+ s2 TEXT CHARACTER SET utf32,
+ s3 MEDIUMTEXT CHARACTER SET utf32,
+ s4 LONGTEXT CHARACTER SET utf32
+);
+--enable_metadata
+SET NAMES utf8mb4, @@character_set_results=NULL;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES latin1;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES utf8mb4;
+SELECT *, HEX(s1) FROM t1;
+--disable_metadata
+CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Bug#45263 utf32_general_ci, bad effects around CREATE TABLE AS SELECT
+--echo #
+SET collation_connection=utf32_general_ci;
+CREATE TABLE t1 AS SELECT HEX(0x00) AS my_col;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#55912 FORMAT with locale set fails for numbers < 1000
+--echo #
+SET collation_connection=utf32_general_ci;
+CREATE TABLE t1 AS SELECT format(123,2,'no_NO');
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#42511 mysqld: ctype-ucs2.c:2044: my_strnncollsp_utf32: Assertion (tlen % 4) == 0' faied
+--echo #
+CREATE TABLE t1 (
+ b char(250) CHARACTER SET utf32,
+ key (b)
+) ENGINE=MYISAM;
+INSERT INTO t1 VALUES ('d'),('f');
+SELECT * FROM t1 WHERE b BETWEEN 'a' AND 'z';
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11753363 (Bug#44793) Character sets: case clause, ucs2 or utf32, failure
+--echo #
+SELECT CASE _latin1'a' WHEN _utf32'a' THEN 'A' END;
+SELECT CASE _utf32'a' WHEN _latin1'a' THEN 'A' END;
+CREATE TABLE t1 (s1 CHAR(5) CHARACTER SET utf32);
+INSERT INTO t1 VALUES ('a');
+SELECT CASE s1 WHEN 'a' THEN 'b' ELSE 'c' END FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf32_uca.test b/mysql-test/t/ctype_utf32_uca.test
new file mode 100644
index 00000000000..a62ffbf95c7
--- /dev/null
+++ b/mysql-test/t/ctype_utf32_uca.test
@@ -0,0 +1,299 @@
+-- source include/have_ucs2.inc
+-- source include/have_utf32.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+set names utf8;
+set collation_connection=utf32_unicode_ci;
+select hex('a'), hex('a ');
+-- source include/endspace.inc
+
+#
+# Bug #6787 LIKE not working properly with _ and utf8 data
+#
+select 'c' like '\_' as want0;
+
+#
+# Bug #5679 utf8_unicode_ci LIKE--trailing % doesn't equal zero characters
+#
+CREATE TABLE t (
+ c char(20) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARACTER SET utf32 COLLATE=utf32_unicode_ci;
+INSERT INTO t VALUES ('a'),('ab'),('aba');
+ALTER TABLE t ADD INDEX (c);
+SELECT c FROM t WHERE c LIKE 'a%';
+DROP TABLE t;
+
+
+create table t1 (c1 char(10) character set utf32 collate utf32_bin);
+
+#
+# Basic Latin
+#
+insert into t1 values ('A'),('a');
+insert into t1 values ('B'),('b');
+insert into t1 values ('C'),('c');
+insert into t1 values ('D'),('d');
+insert into t1 values ('E'),('e');
+insert into t1 values ('F'),('f');
+insert into t1 values ('G'),('g');
+insert into t1 values ('H'),('h');
+insert into t1 values ('I'),('i');
+insert into t1 values ('J'),('j');
+insert into t1 values ('K'),('k');
+insert into t1 values ('L'),('l');
+insert into t1 values ('M'),('m');
+insert into t1 values ('N'),('n');
+insert into t1 values ('O'),('o');
+insert into t1 values ('P'),('p');
+insert into t1 values ('Q'),('q');
+insert into t1 values ('R'),('r');
+insert into t1 values ('S'),('s');
+insert into t1 values ('T'),('t');
+insert into t1 values ('U'),('u');
+insert into t1 values ('V'),('v');
+insert into t1 values ('W'),('w');
+insert into t1 values ('X'),('x');
+insert into t1 values ('Y'),('y');
+insert into t1 values ('Z'),('z');
+
+#
+# Latin1 suppliment
+#
+insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0);
+insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1);
+insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2);
+insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3);
+insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4);
+insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5);
+insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6);
+insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7);
+insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8);
+insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9);
+insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca);
+insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb);
+insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc);
+insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd);
+insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce);
+insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf);
+
+insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0);
+insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1);
+insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2);
+insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3);
+insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4);
+insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5);
+insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6);
+insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7);
+insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8);
+insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9);
+insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da);
+insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db);
+insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc);
+insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd);
+insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de);
+insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df);
+
+#
+# Latin extended-A, 0100-017F
+#
+insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103);
+insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107);
+insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b);
+insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f);
+insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113);
+insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117);
+insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b);
+insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f);
+insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123);
+insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127);
+insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b);
+insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f);
+insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133);
+insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137);
+insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b);
+insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f);
+insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143);
+insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147);
+insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b);
+insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f);
+insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153);
+insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157);
+insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b);
+insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f);
+insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163);
+insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167);
+insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b);
+insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f);
+insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173);
+insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177);
+insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b);
+insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f);
+
+#
+# Latin extended-B, 0180-024F
+#
+insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183);
+insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187);
+insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b);
+insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f);
+insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193);
+insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197);
+insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b);
+insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f);
+insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3);
+insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7);
+insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab);
+insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af);
+insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3);
+insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7);
+insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb);
+insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf);
+insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3);
+insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7);
+insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb);
+insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf);
+insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3);
+insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7);
+insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db);
+insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df);
+insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3);
+insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7);
+insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb);
+insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef);
+insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3);
+insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7);
+insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb);
+insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff);
+
+
+insert into t1 values ('AA'),('Aa'),('aa'),('aA');
+insert into t1 values ('CH'),('Ch'),('ch'),('cH');
+insert into t1 values ('DZ'),('Dz'),('dz'),('dZ');
+insert into t1 values ('IJ'),('Ij'),('ij'),('iJ');
+insert into t1 values ('LJ'),('Lj'),('lj'),('lJ');
+insert into t1 values ('LL'),('Ll'),('ll'),('lL');
+insert into t1 values ('NJ'),('Nj'),('nj'),('nJ');
+insert into t1 values ('OE'),('Oe'),('oe'),('oE');
+insert into t1 values ('SS'),('Ss'),('ss'),('sS');
+insert into t1 values ('RR'),('Rr'),('rr'),('rR');
+
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_unicode_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_icelandic_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_latvian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_romanian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovenian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_polish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_estonian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_swedish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_turkish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_czech_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_danish_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_lithuanian_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_slovak_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_spanish2_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_roman_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_esperanto_ci;
+select group_concat(c1 order by binary c1 separator '') from t1 group by c1 collate utf32_hungarian_ci;
+
+drop table t1;
+
+#
+# Bug#5324
+#
+SET NAMES utf8;
+#test1
+CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL, INDEX (c));
+INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308);
+#Check one row
+SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_general_ci;
+INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8));
+#Check two rows
+SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025
+COLLATE utf32_general_ci ORDER BY c;
+DROP TABLE t1;
+#test2
+CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c));
+INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308);
+#Check one row
+SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025 COLLATE utf32_unicode_ci;
+INSERT INTO t1 VALUES (_ucs2 0x039C03C903B4);
+#Check two rows
+SELECT * FROM t1 WHERE c LIKE _utf32 0x0000039C00000025
+COLLATE utf32_unicode_ci ORDER BY c;
+DROP TABLE t1;
+#test 3
+CREATE TABLE t1 (c varchar(200) CHARACTER SET utf32 COLLATE utf32_unicode_ci NOT NULL, INDEX (c));
+INSERT INTO t1 VALUES (_ucs2 0x039C03C903B403B11F770308);
+#Check one row row
+SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32) COLLATE utf32_unicode_ci;
+INSERT INTO t1 VALUES (CONVERT(_ucs2 0x039C03C903B4 USING utf8));
+#Check two rows
+SELECT * FROM t1 WHERE c LIKE CONVERT(_ucs2 0x039C0025 USING utf32)
+COLLATE utf32_unicode_ci ORDER BY c;
+DROP TABLE t1;
+
+
+SET NAMES utf8;
+SET @test_character_set='utf32';
+SET @test_collation='utf32_swedish_ci';
+-- source include/ctype_common.inc
+
+
+SET collation_connection='utf32_unicode_ci';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_escape.inc
+
+--echo End of 4.1 tests
+
+#
+# Check UPPER/LOWER changing length
+#
+# Result shorter than argument
+CREATE TABLE t1 (id int, a varchar(30) character set utf32);
+INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131);
+INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049);
+INSERT INTO t1 VALUES (5, _ucs2 0x01300130), (6, _ucs2 0x00490049);
+SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu
+FROM t1 ORDER BY id;
+ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf32 collate utf32_turkish_ci;
+SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu
+FROM t1 ORDER BY id;
+DROP TABLE t1;
+
+#
+# Bug #27079 Crash while grouping empty ucs2 strings
+#
+CREATE TABLE t1 (
+ c1 text character set utf32 collate utf32_polish_ci NOT NULL
+) ENGINE=MyISAM;
+insert into t1 values (''),('a');
+SELECT COUNT(*), c1 FROM t1 GROUP BY c1;
+DROP TABLE IF EXISTS t1;
+
+
+#
+# Test basic regex functionality
+#
+set collation_connection=utf32_unicode_ci;
+--source include/ctype_regex.inc
+
+
+#
+# Test my_like_range and contractions
+#
+SET collation_connection=utf32_czech_ci;
+--source include/ctype_czech.inc
+--source include/ctype_like_ignorable.inc
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf8-master.opt b/mysql-test/t/ctype_utf8-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/ctype_utf8-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 8e9f09d1e56..a519a417192 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -2,6 +2,8 @@
# Tests with the utf8 character set
#
+--source include/have_innodb.inc
+
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
@@ -256,9 +258,7 @@ drop table t1;
# Bug 4521: unique key prefix interacts poorly with utf8
# InnoDB: keys with prefix compression, case insensitive collation.
#
---disable_warnings
create table t1 (c varchar(30) character set utf8, unique(c(10))) engine=innodb;
---enable_warnings
insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
insert into t1 values ('aaaaaaaaaa');
--error ER_DUP_ENTRY
@@ -306,9 +306,7 @@ drop table t1;
# Bug 4521: unique key prefix interacts poorly with utf8
# InnoDB: fixed length keys, case insensitive collation
#
---disable_warnings
create table t1 (c char(3) character set utf8, unique (c(2))) engine=innodb;
---enable_warnings
insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
insert into t1 values ('a');
insert into t1 values ('aa');
@@ -383,12 +381,10 @@ drop table t1;
# Bug 4531: unique key prefix interacts poorly with utf8
# Check BDB, case insensitive collation
#
---disable_warnings
create table t1 (
c char(10) character set utf8,
unique key a (c(1))
) engine=innodb;
---enable_warnings
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error ER_DUP_ENTRY
insert into t1 values ('aa');
@@ -506,12 +502,10 @@ drop table t1;
# Bug 4531: unique key prefix interacts poorly with utf8
# Check BDB, binary collation
#
---disable_warnings
create table t1 (
c char(10) character set utf8 collate utf8_bin,
unique key a (c(1))
) engine=innodb;
---enable_warnings
insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
--error ER_DUP_ENTRY
insert into t1 values ('aa');
@@ -543,12 +537,10 @@ drop table t1;
# Bug#4594: column index make = failed for gbk, but like works
# Check InnoDB
#
---disable_warnings
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=innodb;
---enable_warnings
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
@@ -581,12 +573,10 @@ drop table t1;
# the same for BDB
#
---disable_warnings
create table t1 (
str varchar(255) character set utf8 not null,
key str (str(2))
) engine=innodb;
---enable_warnings
INSERT INTO t1 VALUES ('str');
INSERT INTO t1 VALUES ('str2');
select * from t1 where str='str';
@@ -603,14 +593,11 @@ DROP TABLE t1;
#
# Bug #5723: length(<varchar utf8 field>) returns varying results
#
---disable_warnings
SET NAMES utf8;
---disable_warnings
CREATE TABLE t1 (
subject varchar(255) character set utf8 collate utf8_unicode_ci,
p varchar(15) character set utf8
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
---enable_warnings
INSERT INTO t1 VALUES ('è°·å·ä¿ŠäºŒã¨ç”³ã—ã¾ã™ãŒã€ã‚¤ãƒ³ã‚¿ãƒ¼ãƒãƒƒãƒˆäºˆç´„ã®ä¼šå“¡ç™»éŒ²ã‚’ã—ã¾ã—ãŸã¨ã“ã‚ã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’é–“é•ãˆã¦ã—ã¾ã„会員IDãŒå—ã‘å–ã‚‹ã“ã¨ãŒå‡ºæ¥ã¾ã›ã‚“ã§ã—ãŸã€‚é–“é•ãˆã‚¢ãƒ‰ãƒ¬ã‚¹ã¯tani-shun@n.vodafone.ne.jpを書ãè¾¼ã¿ã¾ã—ãŸã€‚ã©ã†ã™ã‚Œã°ã‚ˆã„ã§ã™ã‹ï¼Ÿ ãã®ä»–ã€ä½æ‰€ç­‰ã¯é–“é•ãˆã‚ã‚Šã¾ã›ã‚“。連絡ãã ã•ã„。よã‚ã—ããŠé¡˜ã„ã—ã¾ã™ã€‚m(__)m','040312-000057');
INSERT INTO t1 VALUES ('aaa','bbb');
SELECT length(subject) FROM t1;
@@ -661,18 +648,14 @@ DROP TABLE t1;
# Bug #6019 SELECT tries to use too short prefix index on utf8 data
#
set names utf8;
---disable_warnings
create table t1 (
a int primary key,
b varchar(6),
index b3(b(3))
) engine=innodb character set=utf8;
---enable_warnings
insert into t1 values(1,'foo'),(2,'foobar');
select * from t1 where b like 'foob%';
---disable_warnings
alter table t1 engine=innodb;
---enable_warnings
select * from t1 where b like 'foob%';
drop table t1;
@@ -841,14 +824,12 @@ INSERT INTO t1 VALUES
(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Ðфимим.Ðеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ðд.Д имдимримрад.Ðдимримримрмдиримримримр м.Дадимфшьмримд им.Ðдимимрн имадми','ИМРИ.ÐФИМИМ.ÐЕИМИМРИМДМРИМРМРИРОР',3,'2005-06-01 17:30:43','1234567890'),
(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
---disable_warnings
CREATE TABLE t2 (
`msisdn` varchar(15) NOT NULL default '',
`operator_id` int(11) NOT NULL default '0',
`created` datetime NOT NULL default '0000-00-00 00:00:00',
UNIQUE KEY `PK_user` (`msisdn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
---enable_warnings
INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
@@ -1013,10 +994,8 @@ drop table t1;
# additional tests from duplicate bug#20744 MySQL return no result
set names utf8;
---disable_warnings
create table t1 (a varchar(30) not null primary key)
engine=innodb default character set utf8 collate utf8_general_ci;
---enable_warnings
insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã');
insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ');
select a as gci1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%';
@@ -1024,10 +1003,8 @@ select a as gci2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã
drop table t1;
set names utf8;
---disable_warnings
create table t1 (a varchar(30) not null primary key)
engine=innodb default character set utf8 collate utf8_unicode_ci;
---enable_warnings
insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã');
insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ');
select a as uci1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%';
@@ -1035,10 +1012,8 @@ select a as uci2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã
drop table t1;
set names utf8;
---disable_warnings
create table t1 (a varchar(30) not null primary key)
engine=innodb default character set utf8 collate utf8_bin;
---enable_warnings
insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã');
insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ');
select a as bin1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%';
@@ -1363,26 +1338,22 @@ select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1;
drop table t1;
-
#
# Bug#19960: Inconsistent results when joining
# InnoDB tables using partial UTF8 indexes
#
---disable_warnings
+
CREATE TABLE t1 (
colA int(11) NOT NULL,
colB varchar(255) character set utf8 NOT NULL,
PRIMARY KEY (colA)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
---enable_warnings
INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
---disable_warnings
CREATE TABLE t2 (
colA int(11) NOT NULL,
colB varchar(255) character set utf8 NOT NULL,
KEY bad (colA,colB(3))
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
---enable_warnings
INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
WHERE t1.colA < 3;
@@ -1486,3 +1457,110 @@ SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20));
--echo End of 5.1 tests
+
+
+--echo Start of 5.4 tests
+
+#
+# WL#1213: utf8mb3 is an alias for utf8
+#
+SET NAMES utf8mb3;
+SHOW VARIABLES LIKE 'character_set_results%';
+CREATE TABLE t1 (a CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SELECT _utf8mb3'test';
+
+#
+# Bug#26180: Can't add columns to tables created with utf8 text indexes
+#
+CREATE TABLE t1 (
+ clipid INT NOT NULL,
+ Tape TINYTEXT,
+ PRIMARY KEY (clipid),
+ KEY tape(Tape(255))
+) CHARACTER SET=utf8;
+ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (
+ predicted_order int NOT NULL,
+ utf8_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8;
+INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
+SELECT predicted_order, hex(utf8_encoding) FROM t1 ORDER BY utf8_encoding COLLATE utf8_sinhala_ci;
+DROP TABLE t1;
+#
+# Postfix for Bug#26474
+#
+SET NAMES utf8 COLLATE utf8_sinhala_ci;
+CREATE TABLE t1 (s1 VARCHAR(10) COLLATE utf8_sinhala_ci);
+INSERT INTO t1 VALUES ('a'),('ae'),('af');
+SELECT s1,hex(s1) FROM t1 ORDER BY s1;
+SELECT * FROM t1 ORDER BY s1;
+DROP TABLE t1;
+
+--echo End of 5.4 tests
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Bug#52520 Difference in tinytext utf column metadata
+--echo #
+CREATE TABLE t1 (
+ s1 TINYTEXT CHARACTER SET utf8,
+ s2 TEXT CHARACTER SET utf8,
+ s3 MEDIUMTEXT CHARACTER SET utf8,
+ s4 LONGTEXT CHARACTER SET utf8
+);
+--enable_metadata
+SET NAMES utf8, @@character_set_results=NULL;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES latin1;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES utf8;
+SELECT *, HEX(s1) FROM t1;
+--disable_metadata
+CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+
+SET NAMES utf8;
+--source include/ctype_numconv.inc
+
+--echo #
+--echo # Bug#57687 crash when reporting duplicate group_key error and utf8
+--echo # Make sure to modify this when Bug#58081 is fixed.
+--echo #
+SET NAMES utf8;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0), (0), (1), (0), (0);
+--error ER_DUP_ENTRY
+SELECT COUNT(*) FROM t1, t1 t2
+GROUP BY INSERT('', t2.a, t1.a, (@@global.max_binlog_size));
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11764503 (Bug#57341) Query in EXPLAIN EXTENDED shows wrong characters
+--echo #
+# Emulate utf8 client erroneously started with --default-character-set=latin1,
+# as in the bug report. EXPLAIN output should still be pretty readable
+SET NAMES latin1;
+EXPLAIN EXTENDED SELECT 'abcdÃÂÃÄÅ', _latin1'abcdÃÂÃÄÅ', _utf8'abcdÃÂÃÄÅ' AS u;
+# Test normal utf8
+SET NAMES utf8;
+EXPLAIN EXTENDED SELECT 'abcdÃÂÃÄÅ', _latin1'abcdÃÂÃÄÅ', _utf8'abcdÃÂÃÄÅ';
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/ctype_utf8mb4-master.opt b/mysql-test/t/ctype_utf8mb4-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/ctype_utf8mb4-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/ctype_utf8mb4.test b/mysql-test/t/ctype_utf8mb4.test
new file mode 100644
index 00000000000..03696f385b5
--- /dev/null
+++ b/mysql-test/t/ctype_utf8mb4.test
@@ -0,0 +1,1820 @@
+--source include/have_utf8mb4.inc
+
+#
+# Tests with the utf8mb4 character set
+#
+
+--source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+set names utf8mb4;
+
+select left(_utf8mb4 0xD0B0D0B1D0B2,1);
+select right(_utf8mb4 0xD0B0D0B2D0B2,1);
+
+select locate('he','hello');
+select locate('he','hello',2);
+select locate('lo','hello',2);
+select locate('HE','hello');
+select locate('HE','hello',2);
+select locate('LO','hello',2);
+select locate('HE','hello' collate utf8mb4_bin);
+select locate('HE','hello' collate utf8mb4_bin,2);
+select locate('LO','hello' collate utf8mb4_bin,2);
+
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2);
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2);
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2);
+select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin);
+select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin);
+
+select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1);
+
+select 'a' like 'a';
+select 'A' like 'a';
+select 'A' like 'a' collate utf8mb4_bin;
+select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%');
+
+# Bug #6040: can't retrieve records with umlaut
+# characters in case insensitive manner.
+# Case insensitive search LIKE comparison
+# was broken for multibyte characters:
+select convert(_latin1'Günter André' using utf8mb4) like CONVERT(_latin1'GÜNTER%' USING utf8mb4);
+select CONVERT(_koi8r'×ÁÓÑ' USING utf8mb4) LIKE CONVERT(_koi8r'÷áóñ' USING utf8mb4);
+select CONVERT(_koi8r'÷áóñ' USING utf8mb4) LIKE CONVERT(_koi8r'×ÁÓÑ' USING utf8mb4);
+
+#
+# Check the following:
+# "a" == "a "
+# "a\0" < "a"
+# "a\0" < "a "
+
+SELECT 'a' = 'a ';
+SELECT 'a\0' < 'a';
+SELECT 'a\0' < 'a ';
+SELECT 'a\t' < 'a';
+SELECT 'a\t' < 'a ';
+
+#
+# The same for binary collation
+#
+SELECT 'a' = 'a ' collate utf8mb4_bin;
+SELECT 'a\0' < 'a' collate utf8mb4_bin;
+SELECT 'a\0' < 'a ' collate utf8mb4_bin;
+SELECT 'a\t' < 'a' collate utf8mb4_bin;
+SELECT 'a\t' < 'a ' collate utf8mb4_bin;
+
+CREATE TABLE t1 (a char(10) character set utf8mb4 not null);
+INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a ');
+SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1;
+DROP TABLE t1;
+
+#
+# Fix this, it should return 1:
+#
+#select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD091,_utf8mb4 '%');
+#
+
+#
+# Bug 2367: INSERT() behaviour is different for different charsets.
+#
+select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
+select insert("aa",100,1,"b"),insert("aa",1,3,"b");
+
+#
+# LELF() didn't work well with utf8mb4 in some cases too.
+#
+select char_length(left(@a:='теÑÑ‚',5)), length(@a), @a;
+
+
+#
+# CREATE ... SELECT
+#
+create table t1 select date_format("2004-01-19 10:10:10", "%Y-%m-%d");
+show create table t1;
+select * from t1;
+drop table t1;
+
+#
+# Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails
+#
+set names utf8mb4;
+set LC_TIME_NAMES='fr_FR';
+create table t1 (s1 char(20) character set latin1);
+insert into t1 values (date_format('2004-02-02','%M'));
+select hex(s1) from t1;
+drop table t1;
+create table t1 (s1 char(20) character set koi8r);
+set LC_TIME_NAMES='ru_RU';
+insert into t1 values (date_format('2004-02-02','%M'));
+insert into t1 values (date_format('2004-02-02','%b'));
+insert into t1 values (date_format('2004-02-02','%W'));
+insert into t1 values (date_format('2004-02-02','%a'));
+select hex(s1), s1 from t1;
+drop table t1;
+set LC_TIME_NAMES='en_US';
+
+
+#
+# Bug #2366 Wrong utf8mb4 behaviour when data is truncated
+#
+set names koi8r;
+create table t1 (s1 char(1) character set utf8mb4);
+insert into t1 values (_koi8r'ÁÂ');
+select s1,hex(s1),char_length(s1),octet_length(s1) from t1;
+drop table t1;
+
+create table t1 (s1 tinytext character set utf8mb4);
+insert into t1 select repeat('a',300);
+insert into t1 select repeat('Ñ',300);
+insert into t1 select repeat('aÑ',300);
+insert into t1 select repeat('Ña',300);
+insert into t1 select repeat('ÑÑ',300);
+select hex(s1) from t1;
+select length(s1),char_length(s1) from t1;
+drop table t1;
+
+create table t1 (s1 text character set utf8mb4);
+insert into t1 select repeat('a',66000);
+insert into t1 select repeat('Ñ',66000);
+insert into t1 select repeat('aÑ',66000);
+insert into t1 select repeat('Ña',66000);
+insert into t1 select repeat('ÑÑ',66000);
+select length(s1),char_length(s1) from t1;
+drop table t1;
+
+#
+# Bug #2368 Multibyte charsets do not check that incoming data is well-formed
+#
+create table t1 (s1 char(10) character set utf8mb4);
+insert into t1 values (0x41FF);
+select hex(s1) from t1;
+drop table t1;
+
+create table t1 (s1 varchar(10) character set utf8mb4);
+insert into t1 values (0x41FF);
+select hex(s1) from t1;
+drop table t1;
+
+create table t1 (s1 text character set utf8mb4);
+insert into t1 values (0x41FF);
+select hex(s1) from t1;
+drop table t1;
+
+#
+# Bug 2699
+# UTF8 breaks primary keys for cols > 333 characters
+#
+--error 1071
+create table t1 (a text character set utf8mb4, primary key(a(371)));
+
+
+#
+# Bug 2959
+# UTF8 charset breaks joins with mixed column/string constant
+#
+CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4;
+INSERT INTO t1 VALUES ( 'test' );
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a;
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test';
+SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test';
+DROP TABLE t1;
+
+create table t1 (a char(255) character set utf8mb4);
+insert into t1 values('b'),('b');
+select * from t1 where a = 'b';
+select * from t1 where a = 'b' and a = 'b';
+select * from t1 where a = 'b' and a != 'b';
+drop table t1;
+
+#
+# Testing regexp
+#
+set collation_connection=utf8mb4_general_ci;
+--source include/ctype_regex.inc
+set names utf8mb4;
+
+#
+# Bug #3928 regexp [[:>:]] and UTF-8
+#
+set names utf8mb4;
+
+# This should return TRUE
+select 'ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select 'ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select ' ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select ' ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+
+# This should return FALSE
+select 'ваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select 'zваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select 'zваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]';
+
+#
+# Bug #4555
+# ALTER TABLE crashes mysqld with enum column collated utf8mb4_unicode_ci
+#
+CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci);
+ALTER TABLE t1 ADD COLUMN b CHAR(20);
+DROP TABLE t1;
+
+# Customer Support Center issue # 3299
+# ENUM and SET multibyte fields computed their length wronly
+# when converted into a char field
+set names utf8mb4;
+create table t1 (a enum('aaaa','проба') character set utf8mb4);
+show create table t1;
+insert into t1 values ('проба');
+select * from t1;
+create table t2 select ifnull(a,a) from t1;
+show create table t2;
+select * from t2;
+drop table t1;
+drop table t2;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: keys with prefix compression, case insensitive collation.
+#
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10)));
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaaa');
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+select c c2 from t1 where c='2';
+select c c3 from t1 where c='3';
+select c cx from t1 where c='x';
+select c cy from t1 where c='y';
+select c cz from t1 where c='z';
+select c ca10 from t1 where c='aaaaaaaaaa';
+select c cb20 from t1 where c=repeat('b',20);
+drop table t1;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# InnoDB: keys with prefix compression, case insensitive collation.
+#
+--disable_warnings
+create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=innodb;
+--enable_warnings
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaaa');
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+select c c2 from t1 where c='2';
+select c c3 from t1 where c='3';
+select c cx from t1 where c='x';
+select c cy from t1 where c='y';
+select c cz from t1 where c='z';
+select c ca10 from t1 where c='aaaaaaaaaa';
+select c cb20 from t1 where c=repeat('b',20);
+drop table t1;
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: fixed length keys, case insensitive collation
+#
+create table t1 (c char(3) character set utf8mb4, unique (c(2)));
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('b');
+insert into t1 values ('bb');
+--error ER_DUP_ENTRY
+insert into t1 values ('bbb');
+insert into t1 values ('а');
+insert into t1 values ('аа');
+--error ER_DUP_ENTRY
+insert into t1 values ('ааа');
+insert into t1 values ('б');
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+--error ER_DUP_ENTRY
+insert into t1 values ('ꪪꪪꪪ');
+drop table t1;
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# InnoDB: fixed length keys, case insensitive collation
+#
+--disable_warnings
+create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=innodb;
+--enable_warnings
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('b');
+insert into t1 values ('bb');
+--error ER_DUP_ENTRY
+insert into t1 values ('bbb');
+insert into t1 values ('а');
+insert into t1 values ('аа');
+--error ER_DUP_ENTRY
+insert into t1 values ('ааа');
+insert into t1 values ('б');
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+--error ER_DUP_ENTRY
+insert into t1 values ('ꪪꪪꪪ');
+drop table t1;
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+HASH, case insensitive collation
+#
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using hash (c(1))
+) engine=heap;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+BTREE, case insensitive collation
+#
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a using btree (c(1))
+) engine=heap;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check BDB, case insensitive collation
+#
+--disable_warnings
+create table t1 (
+c char(10) character set utf8mb4,
+unique key a (c(1))
+) engine=innodb;
+--enable_warnings
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: keys with prefix compression, binary collation.
+#
+create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10)));
+insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z');
+insert into t1 values ('aaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaaaaaaaaaaa');
+insert into t1 values (repeat('b',20));
+select c c1 from t1 where c='1';
+select c c2 from t1 where c='2';
+select c c3 from t1 where c='3';
+select c cx from t1 where c='x';
+select c cy from t1 where c='y';
+select c cz from t1 where c='z';
+select c ca10 from t1 where c='aaaaaaaaaa';
+select c cb20 from t1 where c=repeat('b',20);
+drop table t1;
+
+#
+# Bug 4521: unique key prefix interacts poorly with utf8mb4
+# MYISAM: fixed length keys, binary collation
+#
+create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2)));
+insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z');
+insert into t1 values ('a');
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('b');
+insert into t1 values ('bb');
+--error ER_DUP_ENTRY
+insert into t1 values ('bbb');
+insert into t1 values ('а');
+insert into t1 values ('аа');
+--error ER_DUP_ENTRY
+insert into t1 values ('ааа');
+insert into t1 values ('б');
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+insert into t1 values ('ꪪ');
+insert into t1 values ('ꪪꪪ');
+--error ER_DUP_ENTRY
+insert into t1 values ('ꪪꪪꪪ');
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+HASH, binary collation
+#
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using hash (c(1))
+) engine=heap;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check HEAP+BTREE, binary collation
+#
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a using btree (c(1))
+) engine=heap;
+show create table t1;
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+#
+# Bug 4531: unique key prefix interacts poorly with utf8mb4
+# Check BDB, binary collation
+#
+--disable_warnings
+create table t1 (
+c char(10) character set utf8mb4 collate utf8mb4_bin,
+unique key a (c(1))
+) engine=innodb;
+--enable_warnings
+insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f');
+--error ER_DUP_ENTRY
+insert into t1 values ('aa');
+--error ER_DUP_ENTRY
+insert into t1 values ('aaa');
+insert into t1 values ('б');
+--error ER_DUP_ENTRY
+insert into t1 values ('бб');
+--error ER_DUP_ENTRY
+insert into t1 values ('ббб');
+select c as c_all from t1 order by c;
+select c as c_a from t1 where c='a';
+select c as c_a from t1 where c='б';
+drop table t1;
+
+
+# Bug#4594: column index make = failed for gbk, but like works
+# Check MYISAM
+#
+create table t1 (
+ str varchar(255) character set utf8mb4 not null,
+ key str (str(2))
+) engine=myisam;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# Bug#4594: column index make = failed for gbk, but like works
+# Check InnoDB
+#
+--disable_warnings
+create table t1 (
+ str varchar(255) character set utf8mb4 not null,
+ key str (str(2))
+) engine=innodb;
+--enable_warnings
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# the same for HEAP+BTREE
+#
+
+create table t1 (
+ str varchar(255) character set utf8mb4 not null,
+ key str using btree (str(2))
+) engine=heap;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# the same for HEAP+HASH
+#
+
+create table t1 (
+ str varchar(255) character set utf8mb4 not null,
+ key str using hash (str(2))
+) engine=heap;
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+# the same for BDB
+#
+
+--disable_warnings
+create table t1 (
+ str varchar(255) character set utf8mb4 not null,
+ key str (str(2))
+) engine=innodb;
+--enable_warnings
+INSERT INTO t1 VALUES ('str');
+INSERT INTO t1 VALUES ('str2');
+select * from t1 where str='str';
+drop table t1;
+
+#
+# Bug #5397: Crash with varchar binary and LIKE
+#
+CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4;
+INSERT INTO t1 VALUES ('test');
+SELECT a FROM t1 WHERE a LIKE '%te';
+DROP TABLE t1;
+
+#
+# Bug #5723: length(<varchar utf8mb4 field>) returns varying results
+#
+--disable_warnings
+SET NAMES utf8mb4;
+--disable_warnings
+CREATE TABLE t1 (
+ subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,
+ p varchar(15) character set utf8mb4
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+--enable_warnings
+INSERT INTO t1 VALUES ('è°·å·ä¿ŠäºŒã¨ç”³ã—ã¾ã™ãŒã€ã‚¤ãƒ³ã‚¿ãƒ¼ãƒãƒƒãƒˆäºˆç´„ã®ä¼šå“¡ç™»éŒ²ã‚’ã—ã¾ã—ãŸã¨ã“ã‚ã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’é–“é•ãˆã¦ã—ã¾ã„会員IDãŒå—ã‘å–ã‚‹ã“ã¨ãŒå‡ºæ¥ã¾ã›ã‚“ã§ã—ãŸã€‚é–“é•ãˆã‚¢ãƒ‰ãƒ¬ã‚¹ã¯tani-shun@n.vodafone.ne.jpを書ãè¾¼ã¿ã¾ã—ãŸã€‚ã©ã†ã™ã‚Œã°ã‚ˆã„ã§ã™ã‹ï¼Ÿ ãã®ä»–ã€ä½æ‰€ç­‰ã¯é–“é•ãˆã‚ã‚Šã¾ã›ã‚“。連絡ãã ã•ã„。よã‚ã—ããŠé¡˜ã„ã—ã¾ã™ã€‚m(__)m','040312-000057');
+INSERT INTO t1 VALUES ('aaa','bbb');
+SELECT length(subject) FROM t1;
+SELECT length(subject) FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
+#
+# Bug #5832 SELECT doesn't return records in some cases
+#
+CREATE TABLE t1 (
+ id int unsigned NOT NULL auto_increment,
+ list_id smallint unsigned NOT NULL,
+ term TEXT NOT NULL,
+ PRIMARY KEY(id),
+ INDEX(list_id, term(4))
+) ENGINE=MYISAM CHARSET=utf8mb4;
+INSERT INTO t1 SET list_id = 1, term = "letterc";
+INSERT INTO t1 SET list_id = 1, term = "letterb";
+INSERT INTO t1 SET list_id = 1, term = "lettera";
+INSERT INTO t1 SET list_id = 1, term = "letterd";
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc");
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb");
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera");
+SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
+DROP TABLE t1;
+
+
+#
+# Bug #6043 erratic searching for diacriticals in indexed MyISAM UTF-8 table
+#
+SET NAMES latin1;
+CREATE TABLE t1 (
+ id int unsigned NOT NULL auto_increment,
+ list_id smallint unsigned NOT NULL,
+ term text NOT NULL,
+ PRIMARY KEY(id),
+ INDEX(list_id, term(19))
+) ENGINE=MyISAM CHARSET=utf8mb4;
+INSERT INTO t1 set list_id = 1, term = "testétest";
+INSERT INTO t1 set list_id = 1, term = "testetest";
+INSERT INTO t1 set list_id = 1, term = "testètest";
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "testétest");
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest");
+SELECT id, term FROM t1 where (list_id = 1) AND (term = "testètest");
+DROP TABLE t1;
+
+#
+# Bug #6019 SELECT tries to use too short prefix index on utf8mb4 data
+#
+set names utf8mb4;
+--disable_warnings
+create table t1 (
+ a int primary key,
+ b varchar(6),
+ index b3(b(3))
+) engine=innodb character set=utf8mb4;
+--enable_warnings
+insert into t1 values(1,'foo'),(2,'foobar');
+select * from t1 where b like 'foob%';
+--disable_warnings
+alter table t1 engine=innodb;
+--enable_warnings
+select * from t1 where b like 'foob%';
+drop table t1;
+
+#
+# Test for calculate_interval_lengths() function
+#
+create table t1 (
+ a enum('петÑ','ваÑÑ','анюта') character set utf8mb4 not null default 'анюта',
+ b set('петÑ','ваÑÑ','анюта') character set utf8mb4 not null default 'анюта'
+);
+create table t2 select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1;
+show create table t2;
+drop table t2;
+drop table t1;
+
+#
+# Bug #6787 LIKE not working properly with _ and utf8mb4 data
+#
+select 'c' like '\_' as want0;
+
+#
+# SUBSTR with negative offset didn't work with multi-byte strings
+#
+SELECT SUBSTR('ваÑÑ',-2);
+
+
+#
+# Bug #7730 Server crash using soundex on an utf8mb4 table
+#
+create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci);
+insert into t1 values (1, 'Test');
+select * from t1 where soundex(a) = soundex('Test');
+select * from t1 where soundex(a) = soundex('TEST');
+select * from t1 where soundex(a) = soundex('test');
+drop table t1;
+
+#
+# Bug#22638 SOUNDEX broken for international characters
+#
+select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB);
+select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB));
+select soundex(_utf8mb4 0xD091D092D093);
+select hex(soundex(_utf8mb4 0xD091D092D093));
+
+
+SET collation_connection='utf8mb4_general_ci';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_escape.inc
+-- source include/ctype_german.inc
+SET collation_connection='utf8mb4_bin';
+-- source include/ctype_filesort.inc
+-- source include/ctype_filesort2.inc
+-- source include/ctype_like_escape.inc
+
+#
+# Bug #7874 CONCAT() gives wrong results mixing
+# latin1 field and utf8mb4 string literals
+#
+CREATE TABLE t1 (
+ user varchar(255) NOT NULL default ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('one'),('two');
+SELECT CHARSET('a');
+SELECT user, CONCAT('<', user, '>') AS c FROM t1;
+DROP TABLE t1;
+
+#
+# Bug#8785
+# the same problem with the above, but with nested CONCATs
+#
+create table t1 (f1 varchar(1) not null) default charset utf8mb4;
+insert into t1 values (''), ('');
+select concat(concat(_latin1'->',f1),_latin1'<-') from t1;
+drop table t1;
+
+#
+# Bug#8385: utf8mb4_general_ci treats Cyrillic letters I and SHORT I as the same
+#
+select convert(_koi8r'É' using utf8mb4) < convert(_koi8r'Ê' using utf8mb4);
+
+#
+# Bugs#5980: NULL requires a characterset in a union
+#
+set names latin1;
+create table t1 (a varchar(10)) character set utf8mb4;
+insert into t1 values ('test');
+select ifnull(a,'') from t1;
+drop table t1;
+select repeat(_utf8mb4'+',3) as h union select NULL;
+select ifnull(NULL, _utf8mb4'string');
+
+#
+# Bug#9509 Optimizer: wrong result after AND with comparisons
+#
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci);
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+select * from t1 where 'K' > s1 and s1 = 'Y';
+drop table t1;
+
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci);
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+select * from t1 where 'd' < s1 and s1 = 'CH';
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+drop table t1;
+
+#
+# Bug#10714: Inserting double value into utf8mb4 column crashes server
+#
+create table t1 (a varchar(255)) default character set utf8mb4;
+insert into t1 values (1.0);
+drop table t1;
+
+#
+# Bug#10253 compound index length and utf8mb4 char set
+# produces invalid query results
+#
+create table t1 (
+ id int not null,
+ city varchar(20) not null,
+ key (city(7),id)
+) character set=utf8mb4;
+insert into t1 values (1,'Durban North');
+insert into t1 values (2,'Durban');
+select * from t1 where city = 'Durban';
+select * from t1 where city = 'Durban ';
+drop table t1;
+
+#
+# Bug #11819 CREATE TABLE with a SET DEFAULT 0 and UTF8 crashes server.
+#
+--error 1067
+create table t1 (x set('A', 'B') default 0) character set utf8mb4;
+--error 1067
+create table t1 (x enum('A', 'B') default 0) character set utf8mb4;
+
+
+#
+# Test for bug #11167: join for utf8mb4 varchar value longer than 255 bytes
+#
+
+SET NAMES UTF8;
+
+CREATE TABLE t1 (
+ `id` int(20) NOT NULL auto_increment,
+ `country` varchar(100) NOT NULL default '',
+ `shortcode` varchar(100) NOT NULL default '',
+ `operator` varchar(100) NOT NULL default '',
+ `momid` varchar(30) NOT NULL default '',
+ `keyword` varchar(160) NOT NULL default '',
+ `content` varchar(160) NOT NULL default '',
+ `second_token` varchar(160) default NULL,
+ `gateway_id` int(11) NOT NULL default '0',
+ `created` datetime NOT NULL default '0000-00-00 00:00:00',
+ `msisdn` varchar(15) NOT NULL default '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`),
+ KEY `IX_mobile_originated_message_keyword` (`keyword`),
+ KEY `IX_mobile_originated_message_created` (`created`),
+ KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+
+INSERT INTO t1 VALUES
+(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Ðфимим.Ðеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ðд.Д имдимримрад.Ðдимримримрмдиримримримр м.Дадимфшьмримд им.Ðдимимрн имадми','ИМРИ.ÐФИМИМ.ÐЕИМИМРИМДМРИМРМРИРОР',3,'2005-06-01 17:30:43','1234567890'),
+(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890');
+
+--disable_warnings
+CREATE TABLE t2 (
+ `msisdn` varchar(15) NOT NULL default '',
+ `operator_id` int(11) NOT NULL default '0',
+ `created` datetime NOT NULL default '0000-00-00 00:00:00',
+ UNIQUE KEY `PK_user` (`msisdn`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+--enable_warnings
+
+INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
+
+SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
+
+DROP TABLE t1,t2;
+
+#
+# Bug#11591: CHAR column with utf8mb4 does not work properly
+# (more chars than expected)
+#
+create table t1 (a char(20) character set utf8mb4);
+insert into t1 values ('123456'),('андрей');
+alter table t1 modify a char(2) character set utf8mb4;
+select char_length(a), length(a), a from t1 order by a;
+drop table t1;
+
+#
+# Bugs#12611
+# ESCAPE + LIKE do not work when the escape char is a multibyte one
+#
+set names utf8mb4;
+select 'andre%' like 'andreñ%' escape 'ñ';
+
+#
+# Bugs#11754: SET NAMES utf8mb4 followed by SELECT "A\\" LIKE "A\\" returns 0
+#
+set names utf8mb4;
+select 'a\\' like 'a\\';
+select 'aa\\' like 'a%\\';
+
+create table t1 (a char(10), key(a)) character set utf8mb4;
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+select * from t1 where a like "abc%";
+select * from t1 where a like concat("abc","%");
+select * from t1 where a like "ABC%";
+select * from t1 where a like "test%";
+select * from t1 where a like "te_t";
+select * from t1 where a like "%a%";
+select * from t1 where a like "%abcd%";
+select * from t1 where a like "%abc\d%";
+drop table t1;
+
+
+#
+# Bug#9557 MyISAM utf8mb4 table crash
+#
+CREATE TABLE t1 (
+ a varchar(255) NOT NULL default '',
+ KEY a (a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
+insert into t1 values (_utf8mb4 0xe880bd);
+insert into t1 values (_utf8mb4 0x5b);
+select hex(a) from t1;
+drop table t1;
+
+#
+# Bug#13751 find_in_set: Illegal mix of collations
+#
+set names 'latin1';
+create table t1 (a varchar(255)) default charset=utf8mb4;
+select * from t1 where find_in_set('-1', a);
+drop table t1;
+
+#
+# Bug#13233: select distinct char(column) fails with utf8mb4
+#
+create table t1 (a int);
+insert into t1 values (48),(49),(50);
+set names utf8mb4;
+select distinct char(a) from t1;
+drop table t1;
+
+#
+# Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values
+#
+CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4);
+INSERT INTO t1 VALUES(REPEAT('a', 100));
+CREATE TEMPORARY TABLE t2 SELECT COALESCE(t) AS bug FROM t1;
+SELECT LENGTH(bug) FROM t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+#
+# Bug#17313: N'xxx' and _utf8mb4'xxx' are not equivalent
+#
+CREATE TABLE t1 (item varchar(255)) default character set utf8mb4;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8mb4'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+DROP TABLE t1;
+
+#
+# Bug#17705: Corruption of compressed index when index length changes between
+# 254 and 256
+#
+
+SET NAMES utf8mb4;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+INSERT INTO t1 VALUES('uu');
+check table t1;
+INSERT INTO t1 VALUES('uU');
+check table t1;
+INSERT INTO t1 VALUES('uu');
+check table t1;
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+INSERT INTO t1 VALUES('UuABC');
+check table t1;
+INSERT INTO t1 VALUES('uuABC');
+check table t1;
+alter table t1 add b int;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2);
+delete from t1 where b=1;
+INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1);
+check table t1;
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4);
+delete from t1 where b=3;
+INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3);
+check table t1;
+drop table t1;
+
+#
+# Bug#20471 LIKE search fails with indexed utf8mb4 char column
+#
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4);
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_general_ci from t1 where s1 like 'ペテ%';
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_general_ci from t1 where s1 like 'ペテ%';
+drop table t1;
+
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci);
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_unicode_ci from t1 where s1 like 'ペテ%';
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_unicode_ci from t1 where s1 like 'ペテ%';
+drop table t1;
+
+set names utf8mb4;
+create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin);
+insert into t1 values
+('a'),('b'),(null),('ペテルグル'),('ü'),('Y');
+create index it1 on t1 (s1);
+select s1 as before_delete_bin from t1 where s1 like 'ペテ%';
+delete from t1 where s1 = 'Y';
+select s1 as after_delete_bin from t1 where s1 like 'ペテ%';
+drop table t1;
+
+# additional tests from duplicate bug#20744 MySQL return no result
+
+set names utf8mb4;
+--disable_warnings
+create table t1 (a varchar(30) not null primary key)
+engine=innodb default character set utf8mb4 collate utf8mb4_general_ci;
+--enable_warnings
+insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã');
+insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ');
+select a as gci1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%';
+select a as gci2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã';
+drop table t1;
+
+set names utf8mb4;
+--disable_warnings
+create table t1 (a varchar(30) not null primary key)
+engine=innodb default character set utf8mb4 collate utf8mb4_unicode_ci;
+--enable_warnings
+insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã');
+insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ');
+select a as uci1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%';
+select a as uci2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã';
+drop table t1;
+
+set names utf8mb4;
+--disable_warnings
+create table t1 (a varchar(30) not null primary key)
+engine=innodb default character set utf8mb4 collate utf8mb4_bin;
+--enable_warnings
+insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã');
+insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ');
+select a as bin1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%';
+select a as bin2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã';
+drop table t1;
+
+
+
+#
+# Bug#14896: Comparison with a key in a partial index over mb chararacter field
+#
+
+SET NAMES utf8mb4;
+CREATE TABLE t1 (id int PRIMARY KEY,
+ a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '',
+ b int,
+ f varchar(128) default 'XXX',
+ INDEX (a(4))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+INSERT INTO t1(id, a, b) VALUES
+ (1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30),
+ (4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40),
+ (7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50),
+ (10, 'eeeee', 40), (11, 'bbbbbb', 60);
+
+SELECT id, a, b FROM t1;
+
+SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb';
+
+SELECT id, a FROM t1 WHERE a='bbbbbb';
+SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b;
+
+DROP TABLE t1;
+
+#
+# Bug#16674: LIKE predicate for a utf8mb4 character set column
+#
+
+SET NAMES utf8mb4;
+
+CREATE TABLE t1 (
+ a CHAR(13) DEFAULT '',
+ INDEX(a)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES
+ ('Käli Käli 2-4'), ('Käli Käli 2-4'),
+ ('Käli Käli 2+4'), ('Käli Käli 2+4'),
+ ('Käli Käli 2-6'), ('Käli Käli 2-6');
+INSERT INTO t1 SELECT * FROM t1;
+
+CREATE TABLE t2 (
+ a CHAR(13) DEFAULT '',
+ INDEX(a)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
+INSERT INTO t2 VALUES
+ ('Kali Kali 2-4'), ('Kali Kali 2-4'),
+ ('Kali Kali 2+4'), ('Kali Kali 2+4'),
+ ('Kali Kali 2-6'), ('Kali Kali 2-6');
+INSERT INTO t2 SELECT * FROM t2;
+
+SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+
+EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4';
+EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4';
+EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4';
+EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4';
+
+DROP TABLE t1,t2;
+
+CREATE TABLE t1 (
+ a char(255) DEFAULT '',
+ KEY(a(10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+ a char(255) DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+INSERT INTO t1 VALUES ('Käli Käli 2-4');
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+ALTER TABLE t1 ADD KEY (a(10));
+SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%';
+DROP TABLE t1;
+
+#
+# Bug#18359: LIKE predicate for a 'utf8mb4' text column with a partial index
+# (see bug #16674 as well)
+#
+
+SET NAMES latin2;
+
+CREATE TABLE t1 (
+ id int(11) NOT NULL default '0',
+ tid int(11) NOT NULL default '0',
+ val text NOT NULL,
+ INDEX idx(tid, val(10))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
+
+INSERT INTO t1 VALUES
+ (40988,72,'VOLNÝ ADSL'),(41009,72,'VOLNÝ ADSL'),
+ (41032,72,'VOLNÝ ADSL'),(41038,72,'VOLNÝ ADSL'),
+ (41063,72,'VOLNÝ ADSL'),(41537,72,'VOLNÝ ADSL Office'),
+ (42141,72,'VOLNÝ ADSL'),(42565,72,'VOLNÝ ADSL Combi'),
+ (42749,72,'VOLNÝ ADSL'),(44205,72,'VOLNÝ ADSL');
+
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL';
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL';
+SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLNÝ ADSL';
+
+ALTER TABLE t1 DROP KEY idx;
+ALTER TABLE t1 ADD KEY idx (tid,val(11));
+
+SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL';
+
+DROP TABLE t1;
+
+#
+# Bug 20709: problem with utf8mb4 fields in temporary tables
+#
+
+create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '')
+ default charset=utf8mb4 collate=utf8mb4_unicode_ci;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+select distinct a from t1;
+explain select a from t1 group by a;
+select a from t1 group by a;
+drop table t1;
+
+#
+# Bug #20204: "order by" changes the results returned
+#
+
+create table t1(a char(10)) default charset utf8mb4;
+insert into t1 values ('123'), ('456');
+explain
+ select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1;
+drop table t1;
+
+#
+# Bug #34349: Passing invalid parameter to CHAR() in an ORDER BY causes
+# MySQL to hang
+#
+
+SET CHARACTER SET utf8mb4;
+SHOW VARIABLES LIKE 'character\_set\_%';
+CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
+USE crashtest;
+CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4;
+INSERT INTO crashtest VALUES ('35'), ('36'), ('37');
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+INSERT INTO crashtest VALUES ('-1000');
+EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4);
+DROP TABLE crashtest;
+DROP DATABASE crashtest;
+USE test;
+SET CHARACTER SET default;
+
+# End of 4.1 tests
+
+#
+# Test for bug #11484: wrong results for a DISTINCT varchar column in uft8.
+#
+
+CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4;
+INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
+
+SELECT id FROM t1;
+SELECT DISTINCT id FROM t1;
+SELECT DISTINCT id FROM t1 ORDER BY id;
+
+DROP TABLE t1;
+
+#
+# Bug#20095 Changing length of VARCHAR field with UTF8
+# collation does not truncate values
+#
+create table t1 (
+ a varchar(26) not null
+) default character set utf8mb4;
+insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz');
+select * from t1;
+# varchar to varchar
+alter table t1 change a a varchar(20) character set utf8mb4 not null;
+select * from t1;
+# varchar to char
+alter table t1 change a a char(15) character set utf8mb4 not null;
+select * from t1;
+# char to char
+alter table t1 change a a char(10) character set utf8mb4 not null;
+select * from t1;
+# char to varchar
+alter table t1 change a a varchar(5) character set utf8mb4 not null;
+select * from t1;
+drop table t1;
+
+#
+# Check that do_varstring2_mb produces a warning
+#
+create table t1 (
+ a varchar(4000) not null
+) default character set utf8mb4;
+insert into t1 values (repeat('a',4000));
+alter table t1 change a a varchar(3000) character set utf8mb4 not null;
+select length(a) from t1;
+drop table t1;
+
+
+#
+# Bug#10504: Character set does not support traditional mode
+# Bug#14146: CHAR(...USING ...) and CONVERT(CHAR(...) USING...)
+# produce different results
+#
+set names utf8mb4;
+# correct value
+select hex(char(1 using utf8mb4));
+select char(0xd1,0x8f using utf8mb4);
+select char(0xd18f using utf8mb4);
+select char(53647 using utf8mb4);
+# incorrect value: return with warning
+select char(0xff,0x8f using utf8mb4);
+select convert(char(0xff,0x8f) using utf8mb4);
+# incorrect value in strict mode: return NULL with "Error" level warning
+set sql_mode=traditional;
+select char(0xff,0x8f using utf8mb4);
+select char(195 using utf8mb4);
+select char(196 using utf8mb4);
+select char(2557 using utf8mb4);
+select convert(char(0xff,0x8f) using utf8mb4);
+
+#
+# Check convert + char + using
+#
+select hex(convert(char(2557 using latin1) using utf8mb4));
+
+#
+# char() without USING returns "binary" by default, any argument is ok
+#
+select hex(char(195));
+select hex(char(196));
+select hex(char(2557));
+
+
+
+#
+# Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters
+#
+set names utf8mb4;
+create table t1 (a char(1)) default character set utf8mb4;
+create table t2 (a char(1)) default character set utf8mb4;
+insert into t1 values('a'),('a'),(0xE38182),(0xE38182);
+insert into t1 values('i'),('i'),(0xE38184),(0xE38184);
+select * from t1 union distinct select * from t2;
+drop table t1,t2;
+
+
+#
+# Bug#12371: executing prepared statement fails (illegal mix of collations)
+#
+set names utf8mb4;
+create table t1 (a char(10), b varchar(10));
+insert into t1 values ('bar','kostja');
+insert into t1 values ('kostja','bar');
+prepare my_stmt from "select * from t1 where a=?";
+set @a:='bar';
+execute my_stmt using @a;
+set @a:='kostja';
+execute my_stmt using @a;
+set @a:=null;
+execute my_stmt using @a;
+drop table if exists t1;
+
+
+#
+# Bug#21505 Create view - illegal mix of collation for operation 'UNION'
+#
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1, v2;
+--enable_warnings
+set names utf8mb4;
+create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci);
+insert into t1 values('t1_val');
+create view v1 as select 'v1_val' as col1;
+select coercibility(col1), collation(col1) from v1;
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1)from v2;
+drop view v1, v2;
+create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1;
+select coercibility(col1), collation(col1) from v1;
+create view v2 as select col1 from v1 union select col1 from t1;
+select coercibility(col1), collation(col1) from v2;
+drop view v1, v2;
+drop table t1;
+
+#
+# Check conversion of NCHAR strings to subset (e.g. latin1).
+# Conversion is possible if string repertoire is ASCII.
+# Conversion is not possible if the string have extended characters
+#
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int);
+insert into t1 values ('a',1);
+select concat(a, if(b>10, N'x', N'y')) from t1;
+--error 1267
+select concat(a, if(b>10, N'æ', N'ß')) from t1;
+drop table t1;
+
+# Conversion tests for character set introducers
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int);
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1;
+--error 1267
+select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'ß')) from t1;
+drop table t1;
+
+# Conversion tests for introducer + HEX string
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int);
+insert into t1 values ('a',1);
+select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1;
+--error 1267
+select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1;
+drop table t1;
+
+# Conversion tests for "text_literal TEXT_STRING_literal" syntax structure
+set names utf8mb4;
+create table t1 (a varchar(10) character set latin1, b int);
+insert into t1 values ('a',1);
+select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1;
+--error 1267
+select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1;
+drop table t1;
+
+
+#
+# Bug#19960: Inconsistent results when joining
+# InnoDB tables using partial UTF8 indexes
+#
+--disable_warnings
+CREATE TABLE t1 (
+ colA int(11) NOT NULL,
+ colB varchar(255) character set utf8mb4 NOT NULL,
+ PRIMARY KEY (colA)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+--enable_warnings
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+--disable_warnings
+CREATE TABLE t2 (
+ colA int(11) NOT NULL,
+ colB varchar(255) character set utf8mb4 NOT NULL,
+ KEY bad (colA,colB(3))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+--enable_warnings
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+DROP TABLE t1, t2;
+
+#
+# Bug#29205: truncation of UTF8 values when the UNION statement
+# forces collation to the binary charset
+#
+
+SELECT 'н1234567890' UNION SELECT _binary '1';
+SELECT 'н1234567890' UNION SELECT 1;
+
+SELECT '1' UNION SELECT 'н1234567890';
+SELECT 1 UNION SELECT 'н1234567890';
+
+CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4;
+CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT);
+
+INSERT INTO t1 (c) VALUES ('н1234567890');
+INSERT INTO t2 (b, i) VALUES ('1', 1);
+
+SELECT c FROM t1 UNION SELECT b FROM t2;
+SELECT c FROM t1 UNION SELECT i FROM t2;
+
+SELECT b FROM t2 UNION SELECT c FROM t1;
+SELECT i FROM t2 UNION SELECT c FROM t1;
+
+DROP TABLE t1, t2;
+
+#
+# Bug#30982: CHAR(..USING..) can return a not-well-formed string
+# Bug #30986: Character set introducer followed by a HEX string can return bad result
+#
+set sql_mode=traditional;
+select hex(char(0xFF using utf8mb4));
+select hex(convert(0xFF using utf8mb4));
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 0x616263FF);
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 X'616263FF');
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 B'001111111111');
+--error ER_INVALID_CHARACTER_STRING
+select (_utf8mb4 X'616263FF');
+set sql_mode=default;
+select hex(char(0xFF using utf8mb4));
+select hex(convert(0xFF using utf8mb4));
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 0x616263FF);
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 X'616263FF');
+--error ER_INVALID_CHARACTER_STRING
+select hex(_utf8mb4 B'001111111111');
+--error ER_INVALID_CHARACTER_STRING
+select (_utf8mb4 X'616263FF');
+
+#
+# Bug #36772: When using UTF8, CONVERT with GROUP BY returns truncated results
+#
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL);
+INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1;
+ALTER TABLE t1 ADD UNIQUE (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+DROP INDEX b ON t1;
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
+ALTER TABLE t1 ADD INDEX (b);
+SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (
+ predicted_order int NOT NULL,
+ utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4;
+INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
+SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns
+--echo #
+create table t1 (utf8mb4 char(1) character set utf8mb4);
+--echo Testing [F0][90..BF][80..BF][80..BF]
+insert into t1 values (0xF0908080);
+insert into t1 values (0xF0BFBFBF);
+insert into t1 values (0xF08F8080);
+select hex(utf8mb4) from t1;
+delete from t1;
+
+--echo Testing [F2..F3][80..BF][80..BF][80..BF]
+insert into t1 values (0xF2808080);
+insert into t1 values (0xF2BFBFBF);
+select hex(utf8mb4) from t1;
+delete from t1;
+
+--echo Testing [F4][80..8F][80..BF][80..BF]
+insert into t1 values (0xF4808080);
+insert into t1 values (0xF48F8080);
+insert into t1 values (0xF4908080);
+select hex(utf8mb4) from t1;
+drop table t1;
+
+
+--echo #
+--echo # Check strnxfrm() with odd length
+--echo #
+set max_sort_length=5;
+select @@max_sort_length;
+create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci);
+insert into t1 values ('a'),('b'),('c');
+select * from t1 order by a;
+alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin;
+select * from t1 order by a;
+drop table t1;
+set max_sort_length=default;
+
+--echo #
+--echo # Bug#26180: Can't add columns to tables created with utf8mb4 text indexes
+--echo #
+CREATE TABLE t1 (
+ clipid INT NOT NULL,
+ Tape TINYTEXT,
+ PRIMARY KEY (clipid),
+ KEY tape(Tape(255))
+) CHARACTER SET=utf8mb4;
+ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+#--echo #
+#--echo # Check that supplementary characters are not allowed in identifiers
+#--echo #
+# TODO: activate this when system_charset_info is changed to utf8mb4
+#--error 1300
+#CREATE DATABASE `ð€€`;
+#--error 1300
+#CREATE TABLE `ð€€` (a int);
+#--error 1166
+#CREATE TABLE test.t1 SELECT 'ð€€';
+#--error 1300
+#CREATE USER `ð€€`;
+
+--echo #
+--echo # Testing 4-byte values.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (
+ u_decimal int NOT NULL,
+ utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4;
+# Source of the following values: http://www.fileformat.info/info/unicode/block/index.htm
+# SINGLE BARLINE
+INSERT INTO t1 VALUES (119040, x'f09d8480'),
+# G CLEF
+ (119070, x'f09d849e'),
+# HALF NOTE
+ (119134, x'f09d859e'),
+# MUSICAL SYMBOL CROIX
+ (119247, x'f09d878f'),
+# MATHEMATICAL BOLD ITALIC CAPITAL DELTA
+ (120607, x'f09d9c9f'),
+# SANS-SERIF BOLD ITALIC CAPITAL PI
+ (120735, x'f09d9e9f'),
+# <Plane 16 Private Use, Last> (last 4 byte character)
+ (1114111, x'f48fbfbf'),
+# VARIATION SELECTOR-256
+ (917999, x'f3a087af');
+# All from musical chars
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480');
+# Mix of 3-byte and 4-byte chars
+INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab');
+# All from musical chars, but 11 instead of 10 chars. truncated
+INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0');
+
+SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding;
+
+# First invalid 4 byte value
+INSERT INTO t1 VALUES (1114111, x'f5808080');
+
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+ table_name= 't1' AND column_name= 'utf8mb4_encoding';
+
+--disable_warnings
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+CREATE TABLE t2 (
+ u_decimal int NOT NULL,
+ utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb3;
+# LATIN CAPITAL LETTER VEND
+INSERT INTO t2 VALUES (42856, x'ea9da8');
+# SMALL COMMERCIAL AT
+INSERT INTO t2 VALUES (65131, x'efb9ab');
+# <Plane 16 Private Use, Last> (last 4 byte character)
+INSERT INTO t2 VALUES (1114111, x'f48fbfbf');
+
+SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE
+ table_name= 't2' AND column_name= 'utf8mb3_encoding';
+
+# Update a 3-byte char col with a 4-byte char, error
+UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856;
+
+# Update to a 3-byte char casted to 4-byte, error?
+UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856;
+
+# Returns utfmb4
+SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1;
+SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2;
+
+#--error ER_INVALID_CHARACTER_STRING
+#SELECT CONCAT(_utf8 utf8mb4_encoding, _utf8 '|') FROM t1;
+#--error ER_INVALID_CHARACTER_STRING
+#SELECT CONCAT(_utf8mb3 utf8mb4_encoding, _utf8 '|') FROM t1;
+
+SELECT count(*) FROM t1, t2
+ WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding;
+
+# Alter from 4-byte charset to 3-byte charset, error
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1;
+
+# Alter table from utf8 to utf8mb4
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+# Alter table back from utf8mb4 to utf8
+ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t2;
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+# ALter of utf8mb4 column to utf8
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3;
+SHOW CREATE TABLE t1;
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+
+# ALter of utf8 column to utf8mb4
+ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t1;
+SELECT u_decimal,hex(utf8mb4_encoding) FROM t1;
+
+# ALter of utf8 column to utf8mb4
+ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4;
+SHOW CREATE TABLE t2;
+SELECT u_decimal,hex(utf8mb3_encoding) FROM t2;
+
+--disable_warnings
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+CREATE TABLE t3 (
+ u_decimal int NOT NULL,
+ utf8mb3_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8;
+
+# Insert select utf8mb4 (4-byte) into utf8 (3-byte), error
+#--error ER_INVALID_CHARACTER_STRING
+INSERT INTO t3 SELECT * FROM t1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t4;
+--enable_warnings
+CREATE TABLE t4 (
+ u_decimal int NOT NULL,
+ utf8mb4_encoding VARCHAR(10) NOT NULL
+) CHARACTER SET utf8mb4;
+
+# Insert select utf8 (3-byte) into utf8mb4 (4-byte)
+INSERT INTO t3 SELECT * FROM t2;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+DROP TABLE t4;
+
+--echo #
+--echo # Testing that mixing utf8 and utf8mb4 collations returns utf8mb4
+--echo #
+SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b'));
+
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL);
+INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf');
+SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0;
+
+CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL);
+INSERT INTO t2 VALUES (x'ea9da8');
+
+SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1;
+SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1;
+
+CREATE TEMPORARY TABLE t3 AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2;
+SHOW CREATE TABLE t3;
+DROP TEMPORARY TABLE t3;
+
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3;
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3;
+SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3;
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+--echo #
+--echo # Check that mixing utf8mb4 with an invalid utf8 constant returns error
+--echo #
+# This should perhaps be changed to return ER_INVALID_CHARACTER_STRING
+CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4);
+INSERT INTO t1 VALUES (x'f48fbfbf');
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CONCAT(utf8mb4, _utf8 '¿') FROM t1;
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT CONCAT('a', _utf8 '¿') FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#51675 Server crashes on inserting 4 byte char.
+--echo # after ALTER TABLE to 'utf8mb4'
+--echo #
+SET NAMES utf8;
+CREATE TABLE t1 (
+ subject varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci,
+ p VARCHAR(15) CHARACTER SET utf8
+) DEFAULT CHARSET=latin1;
+
+# Alter old table, add index
+ALTER TABLE t1 ADD INDEX (subject);
+
+# Alter old 'utf8' table to new 'utf8mb4'
+ALTER TABLE t1
+ DEFAULT CHARACTER SET utf8,
+ MODIFY subject varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
+ MODIFY p varchar(255) CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1(subject) VALUES ('abcd');
+# Insert 4 byte characters
+INSERT INTO t1(subject) VALUES(x'f0909080');
+DROP TABLE t1;
+
+#
+# Make sure fulltext does not crash on supplementary characters
+#
+CREATE TABLE t1 (a TEXT CHARACTER SET utf8mb4, FULLTEXT INDEX(a));
+INSERT INTO t1 VALUES (0xF0A08080 /* U+20000 */ );
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #51676 Server crashes on SELECT, ORDER BY on 'utf8mb4' column
+--echo #
+SET NAMES utf8mb4;
+CREATE TABLE t1 (
+ subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci,
+ p varchar(15) character set utf8mb4
+) DEFAULT CHARSET=latin1;
+# Insert 4 byte characters
+# 4byte character
+INSERT INTO t1(subject) VALUES(0xF0909080);
+# mix of 3 byte & 4 byte
+INSERT INTO t1(subject) VALUES(0x616263F0909080646566);
+SHOW CREATE TABLE t1;
+SELECT * FROM t1 ORDER BY 1;
+SELECT hex(subject), length(subject), char_length(subject), octet_length(subject) FROM t1 ORDER BY 1;
+SELECT subject FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#52520 Difference in tinytext utf column metadata
+--echo #
+CREATE TABLE t1 (
+ s1 TINYTEXT CHARACTER SET utf8mb4,
+ s2 TEXT CHARACTER SET utf8mb4,
+ s3 MEDIUMTEXT CHARACTER SET utf8mb4,
+ s4 LONGTEXT CHARACTER SET utf8mb4
+);
+--enable_metadata
+SET NAMES utf8mb4, @@character_set_results=NULL;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES latin1;
+SELECT *, HEX(s1) FROM t1;
+SET NAMES utf8mb4;
+SELECT *, HEX(s1) FROM t1;
+--disable_metadata
+CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
+
+--echo #
+--echo # End of tests
+--echo #
diff --git a/mysql-test/t/ctype_utf8mb4_heap.test b/mysql-test/t/ctype_utf8mb4_heap.test
new file mode 100644
index 00000000000..5611ea9746f
--- /dev/null
+++ b/mysql-test/t/ctype_utf8mb4_heap.test
@@ -0,0 +1,6 @@
+--source include/have_utf8mb4.inc
+
+let $engine= heap;
+let $is_heap= 1;
+--source include/ctype_utf8mb4.inc
+
diff --git a/mysql-test/t/ctype_utf8mb4_innodb-master.opt b/mysql-test/t/ctype_utf8mb4_innodb-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/ctype_utf8mb4_innodb-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/ctype_utf8mb4_innodb.test b/mysql-test/t/ctype_utf8mb4_innodb.test
new file mode 100644
index 00000000000..3bf0612a1ab
--- /dev/null
+++ b/mysql-test/t/ctype_utf8mb4_innodb.test
@@ -0,0 +1,6 @@
+--source include/have_utf8mb4.inc
+--source include/have_innodb.inc
+
+let $engine= InnoDB;
+--source include/ctype_utf8mb4.inc
+
diff --git a/mysql-test/t/ctype_utf8mb4_myisam.test b/mysql-test/t/ctype_utf8mb4_myisam.test
new file mode 100644
index 00000000000..e7ec43633f9
--- /dev/null
+++ b/mysql-test/t/ctype_utf8mb4_myisam.test
@@ -0,0 +1,5 @@
+--source include/have_utf8mb4.inc
+
+let $engine= MyISAM;
+--source include/ctype_utf8mb4.inc
+
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index 2a5de8ca9ba..669a66bc6c5 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -17,82 +17,77 @@ WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
ORDER BY variable_name;
#
-# Test setting a lot of different formats to see which formats are accepted and
-# which aren't
-#
-
-SET time_format='%H%i%s';
-SET time_format='%H:%i:%s.%f';
-SET time_format='%h-%i-%s.%f%p';
-SET time_format='%h:%i:%s.%f %p';
-SET time_format='%h:%i:%s%p';
-
-SET date_format='%Y%m%d';
-SET date_format='%Y.%m.%d';
-SET date_format='%d.%m.%Y';
-SET date_format='%m-%d-%Y';
-
-set datetime_format= '%Y%m%d%H%i%s';
-set datetime_format= '%Y-%m-%d %H:%i:%s';
-set datetime_format= '%m-%d-%y %H:%i:%s.%f';
-set datetime_format= '%d-%m-%Y %h:%i:%s%p';
-set datetime_format= '%H:%i:%s %Y-%m-%d';
-set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
-set datetime_format= '%h:%i:%s %p %Y-%m-%d';
-set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
-
-SELECT variable_name, variable_value
-FROM information_schema.session_variables
-WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
-ORDER BY variable_name;
-
---error 1231
-SET time_format='%h:%i:%s';
---error 1231
-SET time_format='%H %i:%s';
---error 1231
-SET time_format='%H::%i:%s';
---error 1231
-SET time_format='%H:%i:%s%f';
---error 1231
-SET time_format='%H:%i.%f:%s';
---error 1231
-SET time_format='%H:%i:%s%p';
---error 1231
-SET time_format='%h:%i:%s.%f %p %Y-%m-%d';
---error 1231
-SET time_format='%H%i%s.%f';
---error 1231
-SET time_format='%H:%i-%s.%f';
---error 1231
-SET date_format='%d.%m.%d';
---error 1231
-SET datetime_format='%h.%m.%y %d.%i.%s';
---error 1231
-set datetime_format= '%H:%i:%s.%f %p %Y-%m-%d';
-
-#
-# Test GLOBAL values
-
-set GLOBAL datetime_format= '%H:%i:%s %Y-%m-%d';
-SET SESSION datetime_format=default;
-select @@global.datetime_format, @@session.datetime_format;
-SET GLOBAL datetime_format=default;
-SET SESSION datetime_format=default;
-select @@global.datetime_format, @@session.datetime_format;
-
-SET GLOBAL date_format=default;
-SET GLOBAL time_format=default;
-SET GLOBAL datetime_format=default;
-SET time_format=default;
-SET date_format=default;
-SET datetime_format=default;
-
-#
# The following tests will work only when we at some point will enable
# dynamic changing of formats
#
+# SET time_format='%H%i%s';
+# SET time_format='%H:%i:%s.%f';
+# SET time_format='%h-%i-%s.%f%p';
+# SET time_format='%h:%i:%s.%f %p';
+# SET time_format='%h:%i:%s%p';
+#
+# SET date_format='%Y%m%d';
+# SET date_format='%Y.%m.%d';
+# SET date_format='%d.%m.%Y';
+# SET date_format='%m-%d-%Y';
+#
+# set datetime_format= '%Y%m%d%H%i%s';
+# set datetime_format= '%Y-%m-%d %H:%i:%s';
+# set datetime_format= '%m-%d-%y %H:%i:%s.%f';
+# set datetime_format= '%d-%m-%Y %h:%i:%s%p';
+# set datetime_format= '%H:%i:%s %Y-%m-%d';
+# set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
+# set datetime_format= '%h:%i:%s %p %Y-%m-%d';
+# set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
+#
+# SELECT variable_name, variable_value
+# FROM information_schema.session_variables
+# WHERE variable_name IN ('date_format', 'datetime_format', 'time_format')
+# ORDER BY variable_name;
+#
+# --error 1231
+# SET time_format='%h:%i:%s';
+# --error 1231
+# SET time_format='%H %i:%s';
+# --error 1231
+# SET time_format='%H::%i:%s';
+# --error 1231
+# SET time_format='%H:%i:%s%f';
+# --error 1231
+# SET time_format='%H:%i.%f:%s';
+# --error 1231
+# SET time_format='%H:%i:%s%p';
+# --error 1231
+# SET time_format='%h:%i:%s.%f %p %Y-%m-%d';
+# --error 1231
+# SET time_format='%H%i%s.%f';
+# --error 1231
+# SET time_format='%H:%i-%s.%f';
+# --error 1231
+# SET date_format='%d.%m.%d';
+# --error 1231
+# SET datetime_format='%h.%m.%y %d.%i.%s';
+# --error 1231
+# set datetime_format= '%H:%i:%s.%f %p %Y-%m-%d';
+#
+# #
+# # Test GLOBAL values
+#
+# set GLOBAL datetime_format= '%H:%i:%s %Y-%m-%d';
+# SET SESSION datetime_format=default;
+# select @@global.datetime_format, @@session.datetime_format;
+# SET GLOBAL datetime_format=default;
+# SET SESSION datetime_format=default;
+# select @@global.datetime_format, @@session.datetime_format;
+#
+# SET GLOBAL date_format=default;
+# SET GLOBAL time_format=default;
+# SET GLOBAL datetime_format=default;
+# SET time_format=default;
+# SET date_format=default;
+# SET datetime_format=default;
+
# SET date_format='%d.%m.%Y';
# select CAST('01.01.2001' as DATE) as a;
# SET datetime_format='%d.%m.%Y %H.%i.%s';
diff --git a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test
index fecef2f95d5..7ad46ae5f61 100644
--- a/mysql-test/t/ddl_i18n_koi8r.test
+++ b/mysql-test/t/ddl_i18n_koi8r.test
@@ -148,7 +148,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --databases mysqltest1 > $views_dump1
# - Clean mysqltest1;
@@ -408,22 +408,22 @@ set names koi8r|
--echo
--echo ---> Dump of mysqltest1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest1 > $sp_dump1
--echo
--echo ---> Dump of mysqltest2
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest2 > $sp_dump2
# - Clean mysqltest1, mysqltest2;
@@ -685,22 +685,22 @@ use mysqltest1|
--echo
--echo ---> Dump of mysqltest1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest1 > $triggers_dump1
--echo
--echo ---> Dump of mysqltest2
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest2 > $triggers_dump2
# - Clean mysqltest1, mysqltest2;
@@ -946,22 +946,22 @@ set names koi8r|
--echo
--echo ---> Dump of mysqltest1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest1 > $events_dump1
--echo
--echo ---> Dump of mysqltest2
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.events.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest2 > $events_dump2
# - Clean mysqltest1, mysqltest2;
diff --git a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test
index 8788d0604f2..6ef418fc6e7 100644
--- a/mysql-test/t/ddl_i18n_utf8.test
+++ b/mysql-test/t/ddl_i18n_utf8.test
@@ -148,7 +148,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --databases mysqltest1 > $views_dump1
# - Clean mysqltest1;
@@ -408,22 +408,22 @@ set names utf8|
--echo
--echo ---> Dump of mysqltest1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest1 > $sp_dump1
--echo
--echo ---> Dump of mysqltest2
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --routines --databases mysqltest2 > $sp_dump2
# - Clean mysqltest1, mysqltest2;
@@ -685,22 +685,22 @@ use mysqltest1|
--echo
--echo ---> Dump of mysqltest1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest1 > $triggers_dump1
--echo
--echo ---> Dump of mysqltest2
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --triggers --databases mysqltest2 > $triggers_dump2
# - Clean mysqltest1, mysqltest2;
@@ -946,22 +946,22 @@ set names utf8|
--echo
--echo ---> Dump of mysqltest1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest1
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest1 > $events_dump1
--echo
--echo ---> Dump of mysqltest2
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest2
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8events.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --compact --events --databases mysqltest2 > $events_dump2
# - Clean mysqltest1, mysqltest2;
diff --git a/mysql-test/t/debug_sync.test b/mysql-test/t/debug_sync.test
index 514e471b603..ebeeec61632 100644
--- a/mysql-test/t/debug_sync.test
+++ b/mysql-test/t/debug_sync.test
@@ -390,7 +390,7 @@ DROP TABLE IF EXISTS t1;
#
# Test.
CREATE TABLE t1 (c1 INT);
-LOCK TABLE t1 WRITE;
+LOCK TABLE t1 READ;
--echo connection con1
connect (con1,localhost,root,,);
# Retain action after use. First used by general_log.
diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test
index 689341391c9..c47db78a11b 100644
--- a/mysql-test/t/delayed.test
+++ b/mysql-test/t/delayed.test
@@ -247,7 +247,7 @@ DROP TABLE t1;
# Bug #32676: insert delayed crash with wrong column and function specified
#
CREATE TABLE t1 (a INT);
---error ER_BAD_FIELD_ERROR
+--error 1305
INSERT DELAYED INTO t1 SET b= b();
DROP TABLE t1;
@@ -307,7 +307,7 @@ connection update;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where command = "Delayed insert" and state = "upgrading lock";
+ where command = "Delayed insert" and state = "Waiting for table level lock";
--source include/wait_condition.inc
connect (select,localhost,root,,);
--echo connection: select
@@ -353,3 +353,266 @@ DROP TABLE t1, t2;
--echo End of 5.1 tests
+
+
+
+--echo #
+--echo # Bug #47274 assert in open_table on CREATE TABLE <already existing>
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 ( f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
+
+--echo # The following CREATE TABLEs before gave an assert.
+
+INSERT DELAYED t1 VALUES (4);
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1 AS SELECT 1 AS f1;
+
+REPLACE DELAYED t1 VALUES (5);
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1 AS SELECT 1 AS f1;
+
+INSERT DELAYED t1 VALUES (6);
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1 (f1 INTEGER);
+
+CREATE TABLE t2 (f1 INTEGER);
+INSERT DELAYED t1 VALUES (7);
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE t1 LIKE t2;
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
+--echo #
+
+--echo # This test is not supposed to work under --ps-protocol since
+--echo # INSERT DELAYED doesn't work under LOCK TABLES with this protocol.
+--disable_ps_protocol
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+CREATE TABLE t3 (a INT);
+
+--echo # Test 1: Using LOCK TABLE
+
+--echo # Connection con1
+connect (con1, localhost, root);
+LOCK TABLE t1 WRITE;
+
+--echo # Connection default
+connection default;
+LOCK TABLE t2 WRITE;
+--echo # Sending:
+--send INSERT DELAYED INTO t1 VALUES (1)
+
+--echo # Connection con1
+connection con1;
+--echo # Wait until INSERT DELAYED is blocked on table 't1'.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock"
+ AND info = "INSERT DELAYED INTO t1 VALUES (1)";
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+INSERT DELAYED INTO t2 VALUES (1);
+UNLOCK TABLES;
+
+--echo # Connection default
+connection default;
+--echo # Reaping: INSERT DELAYED INTO t1 VALUES (1)
+--reap
+UNLOCK TABLES;
+
+--echo # Test 2: Using ALTER TABLE
+
+START TRANSACTION;
+SELECT * FROM t1 WHERE a=0;
+
+--echo # Connection con1
+connection con1;
+--echo # Sending:
+--send ALTER TABLE t1 COMMENT 'test'
+
+--echo # Connection default
+connection default;
+--echo # Wait until ALTER TABLE is blocked on table 't1'.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock"
+ AND info = "ALTER TABLE t1 COMMENT 'test'";
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+INSERT DELAYED INTO t1 VALUES (3);
+COMMIT;
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: ALTER TABLE t1 COMMENT 'test'
+--reap
+
+--echo # Test 3: Using RENAME TABLE
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+INSERT INTO t2 VALUES (1);
+
+--echo # Connection con1
+connection con1;
+--echo # Sending:
+--send RENAME TABLE t1 to t5, t2 to t4
+
+--echo # Connection default
+connection default;
+--echo # Wait until RENAME TABLE is blocked on table 't1'.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock"
+ AND info = "RENAME TABLE t1 to t5, t2 to t4";
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+INSERT DELAYED INTO t1 VALUES (4);
+COMMIT;
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: RENAME TABLE t1 to t5, t2 to t4
+--reap
+
+--echo # Connection default
+connection default;
+--echo # Reverting the renames
+RENAME TABLE t5 to t1, t4 to t2;
+
+--echo # Test 4: Two INSERT DELAYED on the same table
+
+START TRANSACTION;
+INSERT INTO t2 VALUES (1);
+
+--echo # Connection con2
+connect (con2, localhost, root);
+--send LOCK TABLE t1 WRITE, t2 WRITE
+
+--echo # Connection con1
+connection con1;
+--echo # Wait until LOCK TABLE is blocked on table 't2'.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock"
+ AND info = "LOCK TABLE t1 WRITE, t2 WRITE";
+--source include/wait_condition.inc
+--send INSERT DELAYED INTO t1 VALUES (5)
+
+--echo # Connection default
+connection default;
+--echo # Wait until INSERT DELAYED is blocked on table 't1'.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock"
+ AND info = "INSERT DELAYED INTO t1 VALUES (5)";
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+INSERT DELAYED INTO t1 VALUES (6);
+COMMIT;
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: LOCK TABLE t1 WRITE, t2 WRITE
+--reap
+UNLOCK TABLES;
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: INSERT DELAYED INTO t1 VALUES (5)
+--reap
+
+--echo # Connection default
+connection default;
+
+--echo # Test 5: LOCK TABLES + INSERT DELAYED in one connection.
+--echo # This test has triggered some asserts in metadata locking
+--echo # subsystem at some point in time..
+LOCK TABLE t1 WRITE;
+INSERT DELAYED INTO t2 VALUES (7);
+UNLOCK TABLES;
+SET AUTOCOMMIT= 0;
+LOCK TABLE t1 WRITE;
+INSERT DELAYED INTO t2 VALUES (8);
+UNLOCK TABLES;
+SET AUTOCOMMIT= 1;
+
+--echo # Connection con2
+connection con2;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+--echo # Connection con1
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection default
+connection default;
+DROP TABLE t1, t2, t3;
+--enable_ps_protocol
+
+
+--echo #
+--echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables".
+--echo #
+connect (con1,localhost,root,,);
+connection default;
+--disable_warnings
+drop table if exists t1, t2, tm;
+--enable_warnings
+create table t1(a int);
+create table t2(a int);
+create table tm(a int) engine=merge union=(t1, t2);
+begin;
+select * from t1;
+
+--echo # Connection 'con1'.
+connection con1;
+--echo # Sending:
+--send alter table t1 comment 'test'
+
+--echo # Connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE blocks and starts waiting
+--echo # for connection 'default'. It should wait with a
+--echo # pending SNW lock on 't1'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 comment 'test'";
+--source include/wait_condition.inc
+--echo # Attempt to perform delayed insert into 'tm' should not lead
+--echo # to a deadlock. Instead error ER_DELAYED_NOT_SUPPORTED should
+--echo # be emitted.
+--error ER_DELAYED_NOT_SUPPORTED
+insert delayed into tm values (1);
+--echo # Unblock ALTER TABLE.
+commit;
+
+--echo # Connection 'con1'.
+connection con1;
+--echo # Reaping ALTER TABLE:
+--reap
+
+disconnect con1;
+--source include/wait_until_disconnected.inc
+--echo # Connection 'default'.
+connection default;
+drop tables tm, t1, t2;
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index ea5c87babbb..6a72ae9c38b 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -265,8 +265,8 @@ DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
--error ER_PARSE_ERROR
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
---error ER_UNKNOWN_TABLE
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
+--error ER_UNKNOWN_TABLE
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
DELETE FROM t1 USING t1 WHERE a = 1;
SELECT * FROM t1;
@@ -308,6 +308,159 @@ DROP TABLE t1;
--echo End of 5.0 tests
+#
+# Bug#27525: table not found when using multi-table-deletes with aliases over
+# several databas
+# Bug#21148: MULTI-DELETE fails to resolve a table by alias if it's from a
+# different database
+#
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+DROP DATABASE IF EXISTS db3;
+DROP DATABASE IF EXISTS db4;
+DROP TABLE IF EXISTS t1, t2;
+DROP PROCEDURE IF EXISTS count;
+--enable_warnings
+USE test;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+CREATE TABLE db1.t1 (a INT, b INT);
+INSERT INTO db1.t1 VALUES (1,1),(2,2),(3,3);
+CREATE TABLE db1.t2 AS SELECT * FROM db1.t1;
+CREATE TABLE db2.t1 AS SELECT * FROM db1.t2;
+CREATE TABLE db2.t2 AS SELECT * FROM db2.t1;
+CREATE TABLE t1 AS SELECT * FROM db2.t2;
+CREATE TABLE t2 AS SELECT * FROM t1;
+
+delimiter |;
+CREATE PROCEDURE count_rows()
+BEGIN
+ SELECT COUNT(*) AS "COUNT(db1.t1)" FROM db1.t1;
+ SELECT COUNT(*) AS "COUNT(db1.t2)" FROM db1.t2;
+ SELECT COUNT(*) AS "COUNT(db2.t1)" FROM db2.t1;
+ SELECT COUNT(*) AS "COUNT(db2.t2)" FROM db2.t2;
+ SELECT COUNT(*) AS "COUNT(test.t1)" FROM test.t1;
+ SELECT COUNT(*) AS "COUNT(test.t2)" FROM test.t2;
+END|
+delimiter ;|
+
+#
+# Testing without a selected database
+#
+
+CREATE DATABASE db3;
+USE db3;
+DROP DATABASE db3;
+--error ER_NO_DB_ERROR
+SELECT * FROM t1;
+
+# Detect missing table references
+
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_DB_ERROR
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+
+# Ambiguous table references
+
+--error ER_NO_DB_ERROR
+DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
+--error ER_NO_DB_ERROR
+DELETE a1 FROM db1.a1, db2.t2 AS a1;
+--error ER_NO_DB_ERROR
+DELETE a1 FROM a1, db1.t1 AS a1;
+--error ER_NO_DB_ERROR
+DELETE t1 FROM db1.t1, db2.t1 AS a1;
+--error ER_NO_DB_ERROR
+DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
+--error ER_NO_DB_ERROR
+DELETE t1 FROM db1.t1, db2.t1;
+
+# Test all again, now with a selected database
+
+USE test;
+
+# Detect missing table references
+
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1 AS a1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE a1,a2 FROM db1.t1, db2.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE a1,a2 FROM db3.t1 AS a1, db4.t2 AS a2;
+
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1 AS a1, db2.t2;
+--error ER_UNKNOWN_TABLE
+DELETE FROM a1,a2 USING db1.t1, db2.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+--error ER_NO_SUCH_TABLE
+DELETE FROM a1,a2 USING db3.t1 AS a1, db4.t2 AS a2;
+
+# Ambiguous table references
+
+--error ER_NONUNIQ_TABLE
+DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
+--error ER_NO_SUCH_TABLE
+DELETE a1 FROM db1.a1, db2.t2 AS a1;
+--error ER_NONUNIQ_TABLE
+DELETE a1 FROM a1, db1.t1 AS a1;
+--error ER_UNKNOWN_TABLE
+DELETE t1 FROM db1.t1, db2.t1 AS a1;
+--error ER_UNKNOWN_TABLE
+DELETE t1 FROM db1.t1 AS a1, db2.t1 AS a2;
+--error ER_UNKNOWN_TABLE
+DELETE t1 FROM db1.t1, db2.t1;
+
+# Test multiple-table cross database deletes
+
+DELETE t1 FROM db1.t2 AS t1, db2.t2 AS t2 WHERE t2.a = 1 AND t1.a = t2.a;
+SELECT ROW_COUNT();
+CALL count_rows();
+DELETE a1, a2 FROM db2.t1 AS a1, t2 AS a2 WHERE a1.a = 2 AND a2.a = 2;
+SELECT ROW_COUNT();
+CALL count_rows();
+
+DROP DATABASE db1;
+DROP DATABASE db2;
+DROP PROCEDURE count_rows;
+DROP TABLE t1, t2;
+
--echo #
--echo # Bug#46958: Assertion in Diagnostics_area::set_ok_status, trigger,
--echo # merge table
@@ -401,3 +554,29 @@ DELETE FROM t1.*, test.t2.*, a.* USING t1, t2, t3 AS a;
DROP TABLE t1, t2, t3;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug#51099 Assertion in mysql_multi_delete_prepare()
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v1, v2;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(b INT);
+CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
+CREATE VIEW v2 AS SELECT a FROM v1;
+
+# This is a normal delete
+--error ER_VIEW_DELETE_MERGE_VIEW
+DELETE FROM v2;
+# This is a multi table delete, check that we get the same error
+# This caused the assertion.
+--error ER_VIEW_DELETE_MERGE_VIEW
+DELETE v2 FROM v2;
+
+DROP VIEW v2, v1;
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/deprecated_features.test b/mysql-test/t/deprecated_features.test
new file mode 100644
index 00000000000..002f4ad1122
--- /dev/null
+++ b/mysql-test/t/deprecated_features.test
@@ -0,0 +1,27 @@
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+set global log_bin_trust_routine_creators=1;
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+set table_type='MyISAM';
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+select @@table_type='MyISAM';
+--error ER_PARSE_ERROR
+backup table t1 to 'data.txt';
+--error ER_PARSE_ERROR
+restore table t1 from 'data.txt';
+--error ER_PARSE_ERROR
+show plugin;
+--error ER_PARSE_ERROR
+load table t1 from master;
+--error ER_PARSE_ERROR
+load data from master;
+--error ER_PARSE_ERROR
+SHOW INNODB STATUS;
+--error ER_PARSE_ERROR
+create table t1 (t6 timestamp(6));
+--error ER_PARSE_ERROR
+create table t1 (t6 timestamp) type=myisam;
+--error ER_PARSE_ERROR
+show table types;
+--error ER_PARSE_ERROR
+show mutex status;
+
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 5ce6b52b74f..9711482c639 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -158,7 +158,7 @@ UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) >
delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
select * from t1;
--replace_result P2 p2
---error ER_UNKNOWN_TABLE
+--error ER_NON_UPDATABLE_TABLE
delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
-- error 1054
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
@@ -313,3 +313,25 @@ WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
DROP TABLE t1;
--echo # End of 5.0 tests
+
+
+--echo #
+--echo # Bug#58730 Assertion failed: table->key_read == 0 in close_thread_table,
+--echo # temptable views
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT, KEY (b));
+INSERT INTO t1 VALUES (1),(1);
+INSERT INTO t2 VALUES (1),(1);
+
+CREATE algorithm=temptable VIEW v1 AS
+ SELECT 1 FROM t1 LEFT JOIN t1 t3 ON 1 > (SELECT 1 FROM t1);
+CREATE algorithm=temptable VIEW v2 AS SELECT 1 FROM t2;
+
+# This caused the assert to be triggered.
+--error ER_SUBQUERY_NO_1_ROW
+EXPLAIN SELECT 1 FROM t1 JOIN v1 ON 1 > (SELECT 1 FROM v2);
+
+DROP TABLE t1, t2;
+DROP VIEW v1, v2;
diff --git a/mysql-test/t/dirty_close.test b/mysql-test/t/dirty_close.test
index 1bbd53e8c06..e49618170ab 100644
--- a/mysql-test/t/dirty_close.test
+++ b/mysql-test/t/dirty_close.test
@@ -1,3 +1,4 @@
+--source include/not_embedded.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
@@ -22,6 +23,38 @@ disconnect con2;
# End of 4.1 tests
+#
+# Bug#10374 GET_LOCK does not let connection to close on the server side if it's aborted
+#
+
+connection default;
+SELECT GET_LOCK("dangling", 0);
+connect(con1, localhost, root,,);
+connection con1;
+--send SELECT GET_LOCK('dangling', 3600);
+connection default;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = "User lock"
+ AND INFO = "SELECT GET_LOCK('dangling', 3600)";
+--source include/wait_condition.inc
+dirty_close con1;
+let $wait_condition=
+ SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = "User lock"
+ AND INFO = "SELECT GET_LOCK('dangling', 3600)";
+--source include/wait_condition.inc
+connect(con1, localhost, root,,);
+--send SELECT GET_LOCK('dangling', 3600);
+connection default;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = "User lock"
+ AND INFO = "SELECT GET_LOCK('dangling', 3600)";
+--source include/wait_condition.inc
+SELECT RELEASE_LOCK('dangling');
+connection con1;
+--reap
+connection default;
+disconnect con1;
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index c244d08e308..ebcfa6b1845 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -9,7 +9,10 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
-kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
-query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
-log_tables-big : Bug#48646 2010-11-15 mattiasj report already exists
-read_many_rows_innodb : Bug#37635 2010-11-15 mattiasj report already exists
+lowercase_table3 : Bug#11762269 2010-06-30 alik main.lowercase_table3 on Mac OSX
+read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists
+sum_distinct-big : Bug#11764126 2010-11-15 mattiasj was not tested
+alter_table-big : Bug#11748731 2010-11-15 mattiasj was not tested
+create-big : Bug#11748731 2010-11-15 mattiasj was not tested
+archive-big : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc
+log_tables-big : Bug#11756699 2010-11-15 mattiasj report already exists
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index bf4c23562cf..84073d15109 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -614,3 +614,16 @@ SET @@sort_buffer_size = @old_sort_buffer_size;
SET @@max_heap_table_size = @old_max_heap_table_size;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug #11744875: 4082: integer lengths cause truncation with distinct concat and innodb
+--echo #
+
+CREATE TABLE t1 (a INT(1), b INT(1));
+INSERT INTO t1 VALUES (1111, 2222), (3333, 4444);
+SELECT DISTINCT CONCAT(a,b) AS c FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/drop-no_root.test b/mysql-test/t/drop-no_root.test
new file mode 100644
index 00000000000..8fb5b3f74a8
--- /dev/null
+++ b/mysql-test/t/drop-no_root.test
@@ -0,0 +1,85 @@
+# This test uses chmod, can't be run with root permissions
+--source include/not_as_root.inc
+
+###########################################################################
+
+--echo
+--echo # --
+--echo # -- Bug#26704: Failing DROP DATABASE brings mysql-client out of sync.
+--echo # --
+
+--echo
+--disable_warnings
+DROP DATABASE IF EXISTS mysql_test;
+--enable_warnings
+
+--echo
+CREATE DATABASE mysql_test;
+CREATE TABLE mysql_test.t1(c INT);
+
+use mysql_test;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+--echo
+--echo chmod 000 mysql_test/t1.frm
+--chmod 0000 $MYSQLD_DATADIR/mysql_test/t1.frm
+
+# NOTE: For the DROP DATABASE below we need:
+# - disable result log because ER_DB_DROP_RMDIR contains errno, which can be
+# different on different platforms.
+# - expect different error codes, because Windows and UNIX behaves
+# differently (see below).
+#
+# NOTE: Windows and UNIX behaves differently in this test case:
+#
+# - on UNIX when t1.frm is chmoded to 000, it is perfectly deleted
+# by the first DROP DATABASE, but some other files (t1.MYI and t1.MYD) left
+# in the directory. So, we have to explicitly removes them before the
+# second DROP DATABASE.
+#
+# - on Windows when t1.frm is chmoded to 000, it is not deleted by the first
+# DROP DATABASE, but all other files in the database directory are deleted.
+# Thus, we have to change the t1.frm permissions again and delete it
+# explicitly before the second DROP DATABASE.
+#
+# All those differences do not really matter for the idea of this test case:
+# checking that if DROP DATABASE failed, the client is Ok.
+
+--echo
+--disable_result_log
+--error ER_DB_DROP_RMDIR,6
+DROP DATABASE mysql_test;
+--enable_result_log
+
+--echo
+SELECT DATABASE();
+
+# Remove t1.MYI and t1.MYD. On UNIX it should succeed. On Windows, it fails.
+--echo
+--echo rm -f mysql_test/t1.MYD mysql_test/t1.MYI
+--error 0, 1
+--remove_file $MYSQLD_DATADIR/mysql_test/t1.MYD
+--error 0, 1
+--remove_file $MYSQLD_DATADIR/mysql_test/t1.MYI
+
+# Make t1.frm removable: fail on UNIX, succeed on Windows.
+--echo chmod 666 mysql_test/t1.frm
+--error 0, 1
+--chmod 0666 $MYSQLD_DATADIR/mysql_test/t1.frm
+
+# Remove t1.frm: fail on UNIX, succeed on Windows.
+--echo rm -f mysql_test/t1.frm
+--error 0, 1
+--remove_file $MYSQLD_DATADIR/mysql_test/t1.frm
+
+--echo
+DROP DATABASE mysql_test;
+
+--echo
+use test;
+
+--echo
+--echo # -- End of Bug#26704.
+
+###########################################################################
diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test
index bb4dd3e11f9..b5ca0817b6f 100644
--- a/mysql-test/t/drop.test
+++ b/mysql-test/t/drop.test
@@ -100,8 +100,8 @@ drop database if exists mysqltest;
drop table if exists t1;
--enable_warnings
create table t1 (i int);
-lock tables t1 read;
create database mysqltest;
+lock tables t1 read;
connect (addconroot1, localhost, root,,);
--send drop table t1
connect (addconroot2, localhost, root,,);
@@ -124,6 +124,39 @@ disconnect addconroot1;
--source include/wait_until_disconnected.inc
connection default;
+#
+# Bug#25858 Some DROP TABLE under LOCK TABLES can cause deadlocks
+#
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+create table t1 (a int);
+create table t2 (a int);
+lock table t1 read;
+--error ER_TABLE_NOT_LOCKED
+drop table t2;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+drop table t1;
+unlock tables;
+drop table t1,t2;
+connect (addconroot, localhost, root,,);
+connection default;
+create table t1 (i int);
+create table t2 (i int);
+lock tables t1 read;
+connection addconroot;
+lock tables t2 read;
+--error ER_TABLE_NOT_LOCKED
+drop table t1;
+connection default;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+drop table t1,t2;
+disconnect addconroot;
+connection default;
+unlock tables;
+drop table t1,t2;
+
--echo End of 5.0 tests
#
@@ -202,3 +235,41 @@ use test;
drop database mysqltestbug26703;
--echo End of 5.1 tests
+
+###########################################################################
+
+--echo
+--echo # --
+--echo # -- Bug#37431 (DROP TABLE does not report errors correctly).
+--echo # --
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--error ER_BAD_TABLE_ERROR
+DROP TABLE t1;
+
+SHOW WARNINGS;
+
+--echo
+--echo # --
+--echo # -- End of Bug#37431.
+--echo # --
+
+
+--echo #
+--echo # Bug#54282 Crash in MDL_context::upgrade_shared_lock_to_exclusive
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+LOCK TABLE t1 WRITE;
+--error ER_NONUNIQ_TABLE
+DROP TABLE t1, t1;
+
+UNLOCK TABLES;
+DROP TABLE t1;
diff --git a/mysql-test/t/drop_debug.test b/mysql-test/t/drop_debug.test
new file mode 100644
index 00000000000..63c85d9246b
--- /dev/null
+++ b/mysql-test/t/drop_debug.test
@@ -0,0 +1,38 @@
+#
+# DROP-related tests which execution requires debug server.
+#
+--source include/have_debug.inc
+
+###########################################################################
+--echo
+--echo # --
+--echo # -- Bug#43138: DROP DATABASE failure does not clean up message list.
+--echo # --
+--echo
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysql_test;
+--enable_warnings
+
+--echo
+CREATE DATABASE mysql_test;
+CREATE TABLE mysql_test.t1(a INT);
+CREATE TABLE mysql_test.t2(b INT);
+CREATE TABLE mysql_test.t3(c INT);
+
+--echo
+SET SESSION DEBUG = "+d,bug43138";
+
+--echo
+--sorted_result
+DROP DATABASE mysql_test;
+
+--echo
+SET SESSION DEBUG = "-d,bug43138";
+
+--echo
+--echo # --
+--echo # -- End of Bug#43138.
+--echo # --
+
+###########################################################################
diff --git a/mysql-test/t/endspace.test b/mysql-test/t/endspace.test
index b223c683cde..7c71b05f687 100644
--- a/mysql-test/t/endspace.test
+++ b/mysql-test/t/endspace.test
@@ -27,7 +27,7 @@ alter table t1 modify text1 char(32) binary not null;
check table t1;
select * from t1 ignore key (key1) where text1='teststring' or
text1 like 'teststring_%' ORDER BY text1;
-select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
+select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c;
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
select text1, length(text1) from t1 order by text1;
select text1, length(text1) from t1 order by binary text1;
@@ -44,14 +44,14 @@ select concat('|', text1, '|') from t1 where text1='teststring';
select concat('|', text1, '|') from t1 where text1='teststring ';
explain select concat('|', text1, '|') from t1 where text1='teststring ';
select concat('|', text1, '|') from t1 where text1 like 'teststring_%';
-select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
+select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c;
select concat('|', text1, '|') from t1 where text1='teststring' or text1 > 'teststring\t';
select concat('|', text1, '|') from t1 order by text1;
drop table t1;
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) pack_keys=0;
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
-select concat('|', text1, '|') from t1 where text1='teststring' or text1 like 'teststring_%';
+select concat('|', text1, '|') as c from t1 where text1='teststring' or text1 like 'teststring_%' order by c;
select concat('|', text1, '|') from t1 where text1='teststring' or text1 >= 'teststring\t';
drop table t1;
diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test
index 89579ec1739..82822c87e89 100644
--- a/mysql-test/t/errors.test
+++ b/mysql-test/t/errors.test
@@ -67,3 +67,107 @@ SHOW ERRORS;
INSERT INTO t1 SELECT b FROM t1;
DROP TABLE t1;
# End of 5.0 tests
+
+flush status;
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+create table t1 (a int unique);
+create table t2 (a int);
+drop function if exists f1;
+drop function if exists f2;
+
+delimiter |;
+
+create function f1() returns int
+begin
+ insert into t1 (a) values (1);
+ insert into t1 (a) values (1);
+ return 1;
+end|
+create function f2() returns int
+begin
+ insert into t2 (a) values (1);
+ return 2;
+end|
+delimiter ;|
+
+flush status;
+--error 1062
+select f1(), f2();
+show status like 'Com_insert';
+select * from t1;
+select * from t2;
+drop table t1;
+drop table t2;
+drop function f1;
+drop function f2;
+
+#
+# testing the value encoding in the error messages
+#
+# should be TR\xC3\x9CE, TRÜE, TRÜE
+#
+SET NAMES utf8;
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create= _binary x'5452C39C45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create= _utf8 x'5452C39C45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create=_latin1 x'5452DC45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create='TRÃœE';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create=TRÃœE;
+
+SET NAMES latin1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create= _binary x'5452C39C45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create= _utf8 x'5452C39C45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create=_latin1 x'5452DC45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create='TRÜE';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create=TRÜE;
+
+SET NAMES binary;
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create= _binary x'5452C39C45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create= _utf8 x'5452C39C45';
+--error ER_WRONG_VALUE_FOR_VAR
+SET sql_quote_show_create=_latin1 x'5452DC45';
+
+--echo #
+--echo # Bug#52430 Incorrect key in the error message for duplicate key error involving BINARY type
+--echo #
+CREATE TABLE t1(c1 BINARY(10), c2 BINARY(10), c3 BINARY(10),
+PRIMARY KEY(c1,c2,c3));
+INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
+DROP TABLE t1;
+
+CREATE TABLE t1 (f1 VARBINARY(19) PRIMARY KEY);
+INSERT INTO t1 VALUES ('abc\0\0');
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES ('abc\0\0');
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#57882: Item_func_conv_charset::val_str(String*):
+--echo # Assertion `fixed == 1' failed
+--echo #
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),''));
+
+SET NAMES utf8 COLLATE utf8_latvian_ci ;
+--error ER_DATA_OUT_OF_RANGE
+SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null);
+
+--echo #
+--echo # End Bug#57882
+--echo #
diff --git a/mysql-test/t/events_1.test b/mysql-test/t/events_1.test
index ccdeb70d291..7f31e3fc881 100644
--- a/mysql-test/t/events_1.test
+++ b/mysql-test/t/events_1.test
@@ -4,6 +4,8 @@
# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
+call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
+
--disable_warnings
drop database if exists events_test;
drop database if exists db_x;
@@ -270,23 +272,28 @@ SHOW EVENTS;
--echo Try to alter mysql.event: the server should fail to load
--echo event information after mysql.event was tampered with.
--echo
---echo First, let's add a column to the end and make sure everything
---echo works as before
+--echo First, let's add a column to the end and check the error is emitted.
--echo
ALTER TABLE mysql.event ADD dummy INT;
---replace_column 8 # 9 #
+--error ER_EVENT_OPEN_TABLE_FAILED
SHOW EVENTS;
+--error ER_EVENT_OPEN_TABLE_FAILED
SELECT event_name FROM INFORMATION_SCHEMA.events;
---replace_regex /STARTS '[^']+'/STARTS '#'/
+--error ER_EVENT_OPEN_TABLE_FAILED
SHOW CREATE EVENT intact_check;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT no_such_event;
+--error ER_EVENT_OPEN_TABLE_FAILED
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
+--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
+--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_1;
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_2;
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check;
DROP DATABASE IF EXISTS mysqltest_no_such_database;
CREATE DATABASE mysqltest_db2;
@@ -296,6 +303,7 @@ SHOW VARIABLES LIKE 'event_scheduler';
SET GLOBAL event_scheduler=OFF;
# Clean up
ALTER TABLE mysql.event DROP dummy;
+DROP EVENT intact_check;
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
--echo
--echo Now let's add a column to the first position: the server
@@ -303,24 +311,26 @@ CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
--echo
ALTER TABLE mysql.event ADD dummy INT FIRST;
--error ER_CANNOT_LOAD_FROM_TABLE
+--error ER_EVENT_OPEN_TABLE_FAILED
SHOW EVENTS;
--error ER_CANNOT_LOAD_FROM_TABLE
+--error ER_EVENT_OPEN_TABLE_FAILED
SELECT event_name FROM INFORMATION_SCHEMA.events;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
SHOW CREATE EVENT intact_check;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT no_such_event;
---error ER_EVENT_STORE_FAILED
+--error ER_EVENT_OPEN_TABLE_FAILED
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_1;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_2;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check;
# Should work OK
DROP DATABASE IF EXISTS mysqltest_no_such_database;
@@ -341,25 +351,25 @@ INSERT INTO event_like SELECT * FROM mysql.event;
--echo
--echo
ALTER TABLE mysql.event DROP comment, DROP starts;
---error ER_CANNOT_LOAD_FROM_TABLE
+--error ER_EVENT_OPEN_TABLE_FAILED
SHOW EVENTS;
---error ER_CANNOT_LOAD_FROM_TABLE
+--error ER_EVENT_OPEN_TABLE_FAILED
SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
---error ER_CANNOT_LOAD_FROM_TABLE
+--error ER_EVENT_OPEN_TABLE_FAILED
SHOW CREATE EVENT intact_check;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT no_such_event;
---error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED
+--error ER_EVENT_OPEN_TABLE_FAILED
CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
ALTER EVENT intact_check_1 RENAME TO intact_check_2;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_1;
---error ER_EVENT_DOES_NOT_EXIST
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check_2;
-# Should succeed
+--error ER_EVENT_OPEN_TABLE_FAILED
DROP EVENT intact_check;
DROP DATABASE IF EXISTS mysqltest_no_such_database;
CREATE DATABASE mysqltest_db2;
@@ -407,9 +417,54 @@ CREATE TABLE mysql.event like event_like;
DROP TABLE event_like;
--replace_column 8 # 9 #
SHOW EVENTS;
-#
-# End of tests
-#
+
+--echo
+--echo #
+--echo # Bug#12394306: the sever may crash if mysql.event is corrupted
+--echo #
+
+--echo
+CREATE EVENT ev1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
+ALTER EVENT ev1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8;
+
+--echo
+CREATE TABLE event_original LIKE mysql.event;
+INSERT INTO event_original SELECT * FROM mysql.event;
+
+--echo
+ALTER TABLE mysql.event MODIFY modified CHAR(1);
+
+--echo
+--error ER_EVENT_OPEN_TABLE_FAILED
+SHOW EVENTS;
+
+--echo
+--error ER_EVENT_OPEN_TABLE_FAILED
+SELECT event_name, created, last_altered FROM information_schema.events;
+
+--echo
+--error ER_EVENT_OPEN_TABLE_FAILED
+CREATE EVENT ev2 ON SCHEDULE EVERY 5 HOUR DO SELECT 5;
+
+--echo
+--error ER_EVENT_OPEN_TABLE_FAILED
+ALTER EVENT ev1 ON SCHEDULE EVERY 9 HOUR DO SELECT 9;
+
+--echo
+DROP TABLE mysql.event;
+RENAME TABLE event_original TO mysql.event;
+
+--echo
+DROP EVENT ev1;
+
+--echo
+SHOW EVENTS;
+
+
+--echo
+--echo #
+--echo # End of tests
+--echo #
let $wait_condition=
select count(*) = 0 from information_schema.processlist
diff --git a/mysql-test/t/events_2.test b/mysql-test/t/events_2.test
index a50255e9f8b..3d609654b21 100644
--- a/mysql-test/t/events_2.test
+++ b/mysql-test/t/events_2.test
@@ -25,15 +25,6 @@ set names utf8;
create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1;
drop event задачка;
-# event_scheduler is a global var
---error ER_GLOBAL_VARIABLE
-set event_scheduler=off;
-# event_scheduler could be only either 1 or 2
---error ER_WRONG_VALUE_FOR_VAR
-set global event_scheduler=3;
---error ER_WRONG_VALUE_FOR_VAR
-set global event_scheduler=disabled;
-
--echo "DISABLE the scheduler. Testing that it does not work when the variable is 0"
set global event_scheduler=off;
select definer, name, db from mysql.event;
@@ -221,15 +212,15 @@ lock table t1 read;
--replace_regex /STARTS '[^']+'/STARTS '#'/
show create event e1;
select event_name from information_schema.events;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
create event e2 on schedule every 10 hour do select 1;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 disable;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 rename to e3;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e2;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e1;
unlock tables;
#
@@ -238,15 +229,15 @@ lock table t1 write;
--replace_regex /STARTS '[^']+'/STARTS '#'/
show create event e1;
select event_name from information_schema.events;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
create event e2 on schedule every 10 hour do select 1;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 disable;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 rename to e3;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e2;
---error ER_TABLE_NOT_LOCKED
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e1;
unlock tables;
#
@@ -255,15 +246,15 @@ lock table t1 read, mysql.event read;
--replace_regex /STARTS '[^']+'/STARTS '#'/
show create event e1;
select event_name from information_schema.events;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
create event e2 on schedule every 10 hour do select 1;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 disable;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 rename to e3;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e2;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e1;
unlock tables;
#
@@ -272,15 +263,15 @@ lock table t1 write, mysql.event read;
--replace_regex /STARTS '[^']+'/STARTS '#'/
show create event e1;
select event_name from information_schema.events;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
create event e2 on schedule every 10 hour do select 1;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 disable;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 rename to e3;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e2;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e1;
unlock tables;
#
@@ -294,12 +285,18 @@ lock table mysql.event write;
--replace_regex /STARTS '[^']+'/STARTS '#'/
show create event e1;
select event_name from information_schema.events;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
create event e2 on schedule every 10 hour do select 1;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 disable;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter event e2 rename to e3;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e3;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop event e1;
unlock tables;
+drop event e1;
--echo Make sure we have left no events
select event_name from information_schema.events;
--echo
diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test
index 81397b333f9..3a840aedc7c 100644
--- a/mysql-test/t/events_bugs.test
+++ b/mysql-test/t/events_bugs.test
@@ -857,6 +857,7 @@ DROP EVENT e2;
DROP EVENT e1;
SET TIME_ZONE=@save_time_zone;
+SET TIMESTAMP=DEFAULT;
#
# START - BUG#28666 CREATE EVENT ... EVERY 0 SECOND let server crash
@@ -1199,14 +1200,14 @@ DROP USER mysqltest_u1@localhost;
drop procedure if exists p;
--enable_warnings
set @old_mode= @@sql_mode;
-set @@sql_mode= pow(2,32)-1;
+set @@sql_mode= cast(pow(2,32)-1 as unsigned integer);
create event e1 on schedule every 1 day do select 1;
-select @@sql_mode;
+select @@sql_mode into @full_mode;
set @@sql_mode= @old_mode;
# Rename SQL modes that differ in name between the server and the table definition.
-select replace(@full_mode, '?', 'NOT_USED') into @full_mode;
+select replace(@full_mode, ',,,', ',NOT_USED,') into @full_mode;
select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode;
-select name from mysql.event where name = 'p' and sql_mode = @full_mode;
+select name from mysql.event where name = 'e1' and sql_mode = @full_mode;
drop event e1;
#
@@ -1221,6 +1222,87 @@ SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS;
DROP EVENT ev1;
SET GLOBAL server_id = @old_server_id;
+#
+# Bug#11751148: show events shows events in other schema
+#
+
+CREATE DATABASE event_test12;
+USE event_test12;
+CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+CREATE DATABASE event_test1;
+USE event_test1;
+# Following show events should not show ev1
+SHOW EVENTS;
+DROP DATABASE event_test1;
+DROP DATABASE event_test12;
+
+--echo #
+--echo # Bug#12546938 (formerly known as bug#61005):
+--echo # CREATE IF NOT EXIST EVENT WILL CREATE MULTIPLE RUNNING EVENTS
+--echo #
+USE events_test;
+SET GLOBAL event_scheduler = ON;
+
+--disable_warnings
+DROP TABLE IF EXISTS table_bug12546938;
+DROP EVENT IF EXISTS event_Bug12546938;
+--enable_warnings
+CREATE TABLE table_bug12546938 (i INT);
+
+delimiter |;
+
+--echo # Create an event which will be executed with a small delay
+--echo # and won't be automatically dropped after that.
+CREATE EVENT event_Bug12546938
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE
+ENABLE DO
+BEGIN
+ INSERT INTO table_bug12546938 VALUES(1);
+END
+|
+
+--echo # Now try to create the same event using CREATE EVENT IF NOT EXISTS.
+--echo # A warning should be emitted. A new event should not be created nor
+--echo # the old event should be re-executed.
+CREATE EVENT IF NOT EXISTS event_bug12546938
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE
+ENABLE DO
+BEGIN
+ INSERT INTO table_bug12546938 VALUES (1);
+END
+|
+
+delimiter ;|
+
+--echo # Wait until at least one instance of event is executed.
+let $wait_condition= SELECT COUNT(*) FROM table_bug12546938;
+--source include/wait_condition.inc
+
+--echo # Check that only one instance of our event was executed.
+SELECT COUNT(*) FROM table_bug12546938;
+
+--echo # Clean-up.
+DROP EVENT IF EXISTS event_Bug12546938;
+DROP TABLE table_bug12546938;
+SET GLOBAL EVENT_SCHEDULER = OFF;
+
+#
+# Bug#11764334 - 57156: ALTER EVENT CHANGES THE EVENT STATUS
+#
+--disable_warnings
+DROP DATABASE IF EXISTS event_test11764334;
+--enable_warnings
+CREATE DATABASE event_test11764334;
+USE event_test11764334;
+CREATE EVENT ev1 ON SCHEDULE EVERY 3 SECOND DISABLE DO SELECT 1;
+--replace_column 9 # 10 #
+SHOW EVENTS IN event_test11764334 WHERE NAME='ev1';
+ALTER EVENT ev1 ON SCHEDULE EVERY 4 SECOND;
+--replace_column 9 # 10 #
+SHOW EVENTS IN event_test11764334 WHERE NAME='ev1';
+DROP EVENT ev1;
+DROP DATABASE event_test11764334;
+USE test;
###########################################################################
#
# End of tests
diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test
index e155fe2ea16..facf2912087 100644
--- a/mysql-test/t/events_restart.test
+++ b/mysql-test/t/events_restart.test
@@ -1,6 +1,8 @@
# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
+call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
+
#
# Test that when the server is restarted, it checks mysql.event table,
# and disables the scheduler if it's not up to date.
diff --git a/mysql-test/t/events_trans.test b/mysql-test/t/events_trans.test
index a94b75bb812..4cf2583ac96 100644
--- a/mysql-test/t/events_trans.test
+++ b/mysql-test/t/events_trans.test
@@ -121,3 +121,28 @@ let $wait_condition=
drop database events_test;
+
+--echo #
+--echo # Bug#54105 assert in MDL_context::release_locks_stored_before
+--echo #
+
+USE test;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP EVENT IF EXISTS e1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (a INT);
+CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+SAVEPOINT A;
+--replace_regex /STARTS '[^']+'/STARTS '#'/
+SHOW CREATE EVENT e1;
+SELECT * FROM t2;
+ROLLBACK WORK TO SAVEPOINT A;
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/exampledb.test b/mysql-test/t/exampledb.test
deleted file mode 100644
index fbb2a18f344..00000000000
--- a/mysql-test/t/exampledb.test
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Simple test for the example storage engine
-# Taken fromm the select test
-#
--- source include/have_exampledb.inc
-
---disable_warnings
-# Clean up if event's test fails
-drop database if exists events_test;
-drop database if exists events_test2;
-
-drop table if exists t1;
---enable_warnings
-
-CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
- Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
-) ENGINE=example;
-
-drop table t1;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/execution_constants.test b/mysql-test/t/execution_constants.test
index e61d79f5249..92b1deb9921 100644
--- a/mysql-test/t/execution_constants.test
+++ b/mysql-test/t/execution_constants.test
@@ -49,7 +49,7 @@ while ($i)
let $i = 1//
# Check that mysql_errno is 1436
- if (`select $mysql_errno != 1436`)
+ if ($mysql_errno != 1436)
{
die Wrong error triggered, expected 1436 but got $mysql_errno//
}
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index c6c30b58341..8376fdf1ad1 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -1,5 +1,5 @@
#
-# Test of different EXPLAIN's
+# Test of different EXPLAINs
--disable_warnings
drop table if exists t1;
@@ -198,11 +198,21 @@ INSERT INTO t2 VALUES (NULL), (0);
EXPLAIN EXTENDED SELECT (SELECT 1 FROM t2 WHERE d = c) FROM t1;
DROP TABLE t1, t2;
+--echo #
+--echo # Bug#30302: Tables that were optimized away are printed in the
+--echo # EXPLAIN EXTENDED warning.
+--echo #
+create table t1(f1 int);
+create table t2(f2 int);
+insert into t1 values(1);
+insert into t2 values(1),(2);
+explain extended select * from t1 where f1=1;
+explain extended select * from t1 join t2 on f1=f2 where f1=1;
+drop table t1,t2;
--echo #
--echo # Bug #48419: another explain crash..
--echo #
-
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b BLOB, KEY b(b(100)));
INSERT INTO t2 VALUES ('1'), ('2'), ('3');
@@ -265,3 +275,24 @@ DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo End of 5.1 tests.
+
+--echo #
+--echo # Bug#11829785 EXPLAIN EXTENDED CRASH WITH RIGHT OUTER JOIN, SUBQUERIES
+--echo #
+
+CREATE TABLE t1(a INT);
+
+INSERT INTO t1 VALUES (0), (0);
+
+PREPARE s FROM
+'EXPLAIN EXTENDED
+SELECT SUBSTRING(1, (SELECT 1 FROM t1 a1 RIGHT OUTER JOIN t1 ON 0)) AS d
+FROM t1 WHERE 0 > ANY (SELECT @a FROM t1)';
+
+--error ER_SUBQUERY_NO_1_ROW
+EXECUTE s;
+
+DEALLOCATE PREPARE s;
+DROP TABLE t1;
+
+--echo #
diff --git a/mysql-test/t/file_contents.test b/mysql-test/t/file_contents.test
new file mode 100644
index 00000000000..33cd65fb2b4
--- /dev/null
+++ b/mysql-test/t/file_contents.test
@@ -0,0 +1,68 @@
+#
+# Testing files that were built to be packaged, both for existence and for contents
+#
+
+#
+# Bug #42969: Create MANIFEST files
+#
+# Use a Perl script to verify that files "docs/INFO_BIN" and "docs/INFO_SRC" do exist
+# and have the expected contents.
+
+--perl
+print "\nChecking 'INFO_SRC' and 'INFO_BIN'\n";
+$dir_bin = $ENV{'MYSQL_BINDIR'};
+if ($dir_bin =~ m|/usr/|) {
+ # RPM package
+ $dir_docs = $dir_bin;
+ $dir_docs =~ s|/lib|/share/doc|;
+ if(-d "$dir_docs/packages/MySQL-server") {
+ # SuSE
+ $dir_docs = "$dir_docs/packages/MySQL-server";
+ } else {
+ # RedHat: version number in directory name
+ $dir_docs = glob "$dir_docs/MySQL-server*";
+ }
+} elsif ($dir_bin =~ m|/usr$|) {
+ # RPM build during development
+ $dir_docs = "$dir_bin/share/doc";
+ if(-d "$dir_docs/packages/MySQL-server") {
+ # SuSE
+ $dir_docs = "$dir_docs/packages/MySQL-server";
+ } else {
+ # RedHat: version number in directory name
+ $dir_docs = glob "$dir_docs/MySQL-server*";
+ }
+} else {
+ # tar.gz package, Windows, or developer work (in BZR)
+ $dir_docs = $dir_bin;
+ $dir_docs =~ s|/lib||;
+ if(-d "$dir_docs/docs") {
+ $dir_docs = "$dir_docs/docs"; # package
+ } else {
+ $dir_docs = "$dir_docs/Docs"; # development tree
+ }
+}
+$found_version = "No line 'MySQL source #.#.#'";
+$found_revision = "No line 'revision-id: .....'";
+open(I_SRC,"<","$dir_docs/INFO_SRC") or print "Cannot open 'INFO_SRC' in '$dir_docs' (starting from bindir '$dir_bin')\n";
+while(defined ($line = <I_SRC>)) {
+ if ($line =~ m|^MySQL source \d\.\d\.\d+|) {$found_version = "Found MySQL version number";}
+ if ($line =~ m|^revision-id: .*@.*-2\d{13}-\w+$|) {$found_revision = "Found BZR revision id";}
+}
+close I_SRC;
+print "INFO_SRC: $found_version / $found_revision\n";
+$found_compiler = "No line about compiler information";
+$found_features = "No line 'Feature flags'";
+open(I_BIN,"<","$dir_docs/INFO_BIN") or print "Cannot open 'INFO_BIN' in '$dir_docs' (starting from bindir '$dir_bin')\n";
+while(defined ($line = <I_BIN>)) {
+ # "generator" on Windows, "flags" on Unix:
+ if (($line =~ m| Compiler / generator used: |) ||
+ ($line =~ m| Compiler flags used |)) {$found_compiler = "Found 'Compiler ... used' line";}
+ if ($line =~ m| Feature flags used:|) {$found_features = "Found 'Feature flags' line";}
+}
+close I_BIN;
+print "INFO_BIN: $found_compiler / $found_features\n";
+EOF
+
+--echo
+--echo End of tests
diff --git a/mysql-test/t/filesort_debug.test b/mysql-test/t/filesort_debug.test
new file mode 100644
index 00000000000..724ebc90368
--- /dev/null
+++ b/mysql-test/t/filesort_debug.test
@@ -0,0 +1,59 @@
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/count_sessions.inc
+
+SET @old_debug= @@session.debug;
+
+--echo #
+--echo # Bug#36022 please log more information about "Sort aborted" queries
+--echo #
+
+CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
+INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
+
+SET session debug= '+d,make_char_array_fail';
+CALL mtr.add_suppression("Out of sort memory");
+--error ER_OUT_OF_SORTMEMORY
+SELECT * FROM t1 ORDER BY f1 ASC, f0;
+SET session debug= @old_debug;
+
+CREATE FUNCTION f1() RETURNS INT RETURN 1;
+--error ER_SP_WRONG_NO_OF_ARGS
+DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1;
+
+DROP TABLE t1;
+DROP FUNCTION f1;
+
+--echo #
+--echo # Bug #11747102
+--echo # 30771: LOG MORE INFO ABOUT THREADS KILL'D AND SORT ABORTED MESSAGES
+--echo #
+
+connect (con1, localhost, root);
+connect (con2, localhost, root);
+
+--echo # connection 1
+connection con1;
+CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
+INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
+
+let $ID= `SELECT @id := CONNECTION_ID()`;
+
+SET DEBUG_SYNC='filesort_start SIGNAL filesort_started WAIT_FOR filesort_killed';
+--echo # Sending: (not reaped since connection is killed later)
+--send SELECT * FROM t1 ORDER BY f1 ASC, f0
+
+--echo # connection 2
+connection con2;
+let $ignore= `SELECT @id := $ID`;
+SET DEBUG_SYNC='now WAIT_FOR filesort_started';
+KILL @id;
+SET DEBUG_SYNC='now SIGNAL filesort_killed';
+
+--echo # connection default
+connection default;
+disconnect con1;
+disconnect con2;
+--source include/wait_until_count_sessions.inc
+SET DEBUG_SYNC= "RESET";
+DROP TABLE t1;
diff --git a/mysql-test/t/fix_priv_tables.test b/mysql-test/t/fix_priv_tables.test
index eeda9bc8d15..f68c8b518c8 100644
--- a/mysql-test/t/fix_priv_tables.test
+++ b/mysql-test/t/fix_priv_tables.test
@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
-if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
+if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test need MYSQL_FIX_PRIVILEGE_TABLES;
}
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index f27d4cf2fad..52ee6d2cf87 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -68,10 +68,13 @@ drop table t1;
create table t1 (c1 int);
lock table t1 write;
# Cannot get the global read lock with write locked tables.
---error 1192
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
flush tables with read lock;
lock table t1 read;
-# Can get the global read lock with read locked tables.
+# Cannot get the global read lock with read locked tables.
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables with read lock;
+unlock tables;
flush tables with read lock;
--error 1223
lock table t1 write;
@@ -84,12 +87,12 @@ create table t2 (c1 int);
create table t3 (c1 int);
lock table t1 read, t2 read, t3 write;
# Cannot get the global read lock with write locked tables.
---error 1192
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
flush tables with read lock;
lock table t1 read, t2 read, t3 read;
-# Can get the global read lock with read locked tables.
+# Cannot get the global read lock with read locked tables.
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
flush tables with read lock;
-# Release all table locks and the global read lock.
unlock tables;
drop table t1, t2, t3;
@@ -157,6 +160,7 @@ flush tables with read lock;
unlock tables;
lock tables t1 read;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
flush tables with read lock;
unlock tables;
@@ -199,3 +203,468 @@ set global general_log= @old_general_log;
set global read_only= @old_read_only;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Additional test for bug #51136 "Crash in pthread_rwlock_rdlock
+--echo # on TEMPORARY + HANDLER + LOCK + SP".
+--echo # Also see the main test for this bug in include/handler.inc.
+--echo #
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+create table t1 (i int);
+create temporary table t2 (j int);
+flush tables with read lock;
+lock table t2 read;
+--echo # This commit should not release any MDL locks.
+commit;
+--echo # The below statement crashed before the bug fix as it
+--echo # has attempted to release global shared metadata lock
+--echo # which was already released by commit.
+unlock tables;
+drop tables t1, t2;
+
+
+
+--echo #
+--echo # Tests for WL#5000 FLUSH TABLES|TABLE table_list WITH READ LOCK
+--echo #
+--echo # I. Check the incompatible changes in the grammar.
+--echo #
+--error ER_PARSE_ERROR
+flush tables with read lock, hosts;
+--error ER_PARSE_ERROR
+flush privileges, tables;
+--error ER_PARSE_ERROR
+flush privileges, tables with read lock;
+--error ER_PARSE_ERROR
+flush privileges, tables;
+--error ER_PARSE_ERROR
+flush tables with read lock, tables;
+show tables;
+--echo #
+--echo # II. Check the allowed syntax.
+--echo #
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+create table t1 (a int);
+create table t2 (a int);
+create table t3 (a int);
+lock table t1 read, t2 read;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables with read lock;
+unlock tables;
+flush tables with read lock;
+flush tables t1, t2 with read lock;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables t1, t2 with read lock;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+flush tables with read lock;
+select * from t1;
+select * from t2;
+--error ER_TABLE_NOT_LOCKED
+select * from t3;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t1 (a) values (1);
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t2 (a) values (1);
+--error ER_TABLE_NOT_LOCKED
+insert into t3 (a) values (1);
+--error ER_NO_SUCH_TABLE
+lock table no_such_table read;
+--echo #
+--echo # We implicitly left the locked tables
+--echo # mode but still have the read lock.
+--echo #
+--error ER_CANT_UPDATE_WITH_READLOCK
+insert into t2 (a) values (1);
+unlock tables;
+insert into t1 (a) values (1);
+insert into t2 (a) values (1);
+flush table t1, t2 with read lock;
+select * from t1;
+select * from t2;
+--error ER_TABLE_NOT_LOCKED
+select * from t3;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t1 (a) values (2);
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+insert into t2 (a) values (2);
+--error ER_TABLE_NOT_LOCKED
+insert into t3 (a) values (2);
+--error ER_NO_SUCH_TABLE
+lock table no_such_table read;
+insert into t3 (a) values (2);
+
+
+--echo #
+--echo # III. Concurrent tests.
+--echo #
+connect (con1,localhost,root,,);
+--echo # --> connection default
+--echo #
+--echo # Check that flush tables <list> with read lock
+--echo # does not affect non-locked tables.
+connection default;
+--echo #
+flush tables t1 with read lock;
+--echo # --> connection con1;
+connection con1;
+select * from t1;
+select * from t2;
+insert into t2 (a) values (3);
+--echo # --> connection default;
+connection default;
+unlock tables;
+--echo #
+--echo # Check that "FLUSH TABLES <list> WITH READ LOCK" is
+--echo # compatible with active "FLUSH TABLES WITH READ LOCK".
+--echo # Vice versa it is not true, since tables read-locked by
+--echo # "FLUSH TABLES <list> WITH READ LOCK" can't be flushed.
+flush tables with read lock;
+--echo # --> connection con1;
+connection con1;
+flush table t1 with read lock;
+select * from t1;
+unlock tables;
+--echo # --> connection default;
+connection default;
+unlock tables;
+--echo #
+--echo # Check that FLUSH TABLES t1 WITH READ LOCK
+--echo # does not conflict with an existing FLUSH TABLES t2
+--echo # WITH READ LOCK.
+--echo #
+flush table t1 with read lock;
+--echo # --> connection con1
+connection con1;
+flush table t2 with read lock;
+unlock tables;
+--echo # --> connection default
+connection default;
+unlock tables;
+--echo #
+--echo # Check that FLUSH TABLES t1 WITH READ LOCK
+--echo # does not conflict with SET GLOBAL read_only=1.
+--echo #
+set global read_only=1;
+--echo # connection con1
+connection con1;
+flush table t1 with read lock;
+unlock tables;
+--echo # connection default
+connection default;
+set global read_only=0;
+--echo #
+--echo # Check that it's possible to read-lock
+--echo # tables locked with FLUSH TABLE <list> WITH READ LOCK.
+--echo #
+flush tables t1, t2 with read lock;
+--echo # connection con1
+connection con1;
+lock table t1 read, t2 read;
+unlock tables;
+--echo # connection default
+connection default;
+unlock tables;
+
+--echo # --> connection con1
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+connection default;
+drop table t1, t2, t3;
+
+--echo #
+--echo # Bug#51710 FLUSH TABLES <view> WITH READ LOCK kills the server
+--echo #
+--disable_warnings
+drop view if exists v1, v2, v3;
+drop table if exists t1, v1;
+--enable_warnings
+create table t1 (a int);
+create view v1 as select 1;
+create view v2 as select * from t1;
+create view v3 as select * from v2;
+
+--error ER_WRONG_OBJECT
+flush table v1, v2, v3 with read lock;
+--error ER_WRONG_OBJECT
+flush table v1 with read lock;
+--error ER_WRONG_OBJECT
+flush table v2 with read lock;
+--error ER_WRONG_OBJECT
+flush table v3 with read lock;
+create temporary table v1 (a int);
+--error ER_WRONG_OBJECT
+flush table v1 with read lock;
+drop view v1;
+create table v1 (a int);
+flush table v1 with read lock;
+drop temporary table v1;
+unlock tables;
+drop view v2, v3;
+drop table t1, v1;
+
+
+--echo #
+--echo # FLUSH TABLES <list> WITH READ LOCK and HANDLER
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int, key a (a));
+insert into t1 (a) values (1), (2), (3);
+handler t1 open;
+handler t1 read a next;
+handler t1 read a next;
+flush tables t1 with read lock;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+handler t1 read a next;
+unlock tables;
+--echo #
+--echo # Sic: lost handler position.
+--echo #
+handler t1 read a next;
+handler t1 close;
+drop table t1;
+
+--echo #
+--echo # Bug#52117 Pending FLUSH TALBES <list> aborts
+--echo # transactions unnecessarily.
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+--echo # --> conection default
+connection default;
+
+create table t1 (a int);
+begin;
+select * from t1;
+--echo # --> connection con1
+connection con1;
+--echo #
+--echo # Issue a LOCK TABLE t1 READ. We could use HANDLER t1 OPEN
+--echo # or a long-running select -- anything that
+--echo # prevents FLUSH TABLE t1 from immediate completion would do.
+--echo #
+lock table t1 read;
+--echo # --> connection con2
+connection con2;
+--echo #
+--echo # FLUSH TABLE expels the table definition from the cache.
+--echo # Sending 'flush table t1'...
+send flush table t1;
+--echo # --> connection default
+connection default;
+--echo # Let flush table sync in.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush"
+ and info = "flush table t1";
+--source include/wait_condition.inc
+send select * from t1;
+--echo # --> connection con1
+connection con1;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush"
+ and info = "select * from t1";
+select * from t1;
+unlock tables;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'flush table t1'...
+reap;
+--echo # --> connection default
+connection default;
+--echo # Reaping 'select * from t1'...
+reap;
+commit;
+
+--echo #
+--echo # Repeat the same test but with FLUSH TABLES
+--echo #
+
+begin;
+select * from t1;
+--echo # --> connection con1
+connection con1;
+--echo #
+--echo # Issue a LOCK TABLE t1 READ.
+--echo #
+lock table t1 read;
+--echo # --> connection con2
+connection con2;
+--echo #
+--echo # FLUSH TABLES expels the table definition from the cache.
+--echo # Sending 'flush tables'...
+send flush tables;
+--echo # --> connection default
+connection default;
+--echo # Let flush table sync in.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush"
+ and info = "flush tables";
+--source include/wait_condition.inc
+send select * from t1;
+--echo # --> connection con1
+connection con1;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush"
+ and info = "select * from t1";
+select * from t1;
+unlock tables;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'flush tables'...
+reap;
+--echo # --> connection default
+connection default;
+--echo # Reaping 'select * from t1'...
+reap;
+commit;
+
+--echo # Cleanup
+
+--echo # --> connection con1
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+--echo # --> connection con2
+connection con2;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+--echo # --> connection default
+connection default;
+drop table t1;
+
+
+--echo #
+--echo # Test for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table
+--echo # causes assert failure".
+--echo #
+--disable_warnings
+drop table if exists t1, t2, tm;
+--enable_warnings
+create table t1 (i int);
+create table t2 (i int);
+create table tm (i int) engine=merge union=(t1, t2);
+insert into t1 values (1), (2);
+insert into t2 values (3), (4);
+--echo # The below statement should succeed and lock merge
+--echo # table for read. Only merge table gets flushed and
+--echo # not underlying tables.
+flush tables tm with read lock;
+select * from tm;
+--echo # Check that underlying tables are locked.
+select * from t1;
+select * from t2;
+unlock tables;
+--echo # This statement should succeed as well and flush
+--echo # all tables in the list.
+flush tables tm, t1, t2 with read lock;
+select * from tm;
+--echo # Naturally, underlying tables should be locked in this case too.
+select * from t1;
+select * from t2;
+unlock tables;
+drop tables tm, t1, t2;
+
+
+--echo #
+--echo # Test for bug #57006 "Deadlock between HANDLER and
+--echo # FLUSH TABLES WITH READ LOCK".
+--echo #
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connection default;
+create table t1 (i int);
+create table t2 (i int);
+handler t1 open;
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Sending:
+--send flush tables with read lock
+
+--echo # Switching to connection 'con2'.
+connection con2;
+--echo # Wait until FTWRL starts waiting for 't1' to be closed.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush"
+ and info = "flush tables with read lock";
+--source include/wait_condition.inc
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # The below statement should not cause deadlock.
+--echo # Sending:
+--send insert into t2 values (1)
+
+--echo # Switching to connection 'con2'.
+connection con2;
+--echo # Wait until INSERT starts to wait for FTWRL to go away.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock"
+ and info = "insert into t2 values (1)";
+--source include/wait_condition.inc
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # FTWRL should be able to continue now.
+--echo # Reap FTWRL.
+--reap
+unlock tables;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap INSERT.
+--reap
+handler t1 close;
+
+--echo # Cleanup.
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+connection con2;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+connection default;
+drop tables t1, t2;
+
+
+--echo #
+--echo # Bug#57649 FLUSH TABLES under FLUSH TABLES <list> WITH READ LOCK leads
+--echo # to assert failure.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+FLUSH TABLES t1 WITH READ LOCK;
+
+# All these triggered the assertion
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a= 1;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+ALTER TABLE t1 COMMENT 'test';
+
+UNLOCK TABLES;
+DROP TABLE t1;
diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test
index 74892def63f..90443dc9242 100644
--- a/mysql-test/t/flush_block_commit.test
+++ b/mysql-test/t/flush_block_commit.test
@@ -6,7 +6,7 @@
# And it requires InnoDB
--source include/have_innodb.inc
-# Save the initial number of concurrent sessions
+--echo # Save the initial number of concurrent sessions
--source include/count_sessions.inc
--echo # Establish connection con1 (user=root)
@@ -30,18 +30,24 @@ INSERT INTO t1 VALUES(1);
--echo # Switch to connection con2
connection con2;
FLUSH TABLES WITH READ LOCK;
-SELECT * FROM t1;
--echo # Switch to connection con1
connection con1;
-send COMMIT; # blocked by con2
-sleep 1;
+--echo # Sending:
+--send COMMIT
--echo # Switch to connection con2
connection con2;
-SELECT * FROM t1; # verify con1 was blocked and data did not move
+--echo # Wait until COMMIT gets blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and info = "COMMIT";
+--source include/wait_condition.inc
+--echo # Verify that 'con1' was blocked and data did not move.
+SELECT * FROM t1;
UNLOCK TABLES;
--echo # Switch to connection con1
connection con1;
-reap;
+--echo # Reaping COMMIT
+--reap
# No deadlock ?
@@ -63,6 +69,7 @@ COMMIT; # should not be blocked by con3
--echo # Switch to connection con2
connection con2;
reap;
+COMMIT;
--echo # Switch to connection con3
connection con3;
reap;
@@ -79,8 +86,6 @@ connection con1;
BEGIN;
INSERT INTO t1 VALUES(10);
FLUSH TABLES WITH READ LOCK;
-COMMIT;
-UNLOCK TABLES;
--echo # Switch to connection con2
connection con2;
FLUSH TABLES WITH READ LOCK; # bug caused hang here
@@ -91,19 +96,21 @@ UNLOCK TABLES;
BEGIN;
SELECT * FROM t1;
SHOW CREATE DATABASE test;
-
-DROP TABLE t1;
+COMMIT;
-# Cleanup
+--echo # Cleanup
--echo # Switch to connection default and close connections con1, con2, con3
connection default;
disconnect con1;
disconnect con2;
disconnect con3;
-# End of 4.1 tests
+--echo # We commit open transactions when we disconnect: only then we can
+--echo # drop the table.
+DROP TABLE t1;
+--echo # End of 4.1 tests
-# Wait till all disconnects are completed
+--echo # Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/flush_block_commit_notembedded.test b/mysql-test/t/flush_block_commit_notembedded.test
index b774d7ec069..fe9dbf7c19e 100644
--- a/mysql-test/t/flush_block_commit_notembedded.test
+++ b/mysql-test/t/flush_block_commit_notembedded.test
@@ -9,7 +9,7 @@
--source include/have_log_bin.inc
--source include/have_innodb.inc
-# Save the initial number of concurrent sessions
+--echo # Save the initial number of concurrent sessions
--source include/count_sessions.inc
@@ -24,14 +24,14 @@ connection con1;
CREATE TABLE t1 (a INT) ENGINE=innodb;
RESET MASTER;
SET AUTOCOMMIT=0;
-INSERT t1 VALUES (1);
+SELECT 1;
--echo # Switch to connection con2
connection con2;
FLUSH TABLES WITH READ LOCK;
--source include/show_binlog_events.inc
--echo # Switch to connection con1
connection con1;
-send COMMIT;
+send INSERT INTO t1 VALUES (1);
--echo # Switch to connection con2
connection con2;
sleep 1;
@@ -43,11 +43,30 @@ reap;
DROP TABLE t1;
SET AUTOCOMMIT=1;
+# GLR blocks new transactions
+create table t1 (a int) engine=innodb;
+connection con1;
+flush tables with read lock;
+connection con2;
+begin;
+--send insert into t1 values (1);
+connection con1;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "insert into t1 values (1)";
+--source include/wait_condition.inc
+unlock tables;
+connection con2;
+--reap
+commit;
+drop table t1;
+
--echo # Switch to connection default and close connections con1 and con2
connection default;
disconnect con1;
disconnect con2;
-# Wait till all disconnects are completed
+--echo # Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/flush_read_lock.test b/mysql-test/t/flush_read_lock.test
new file mode 100644
index 00000000000..9da93dd40a1
--- /dev/null
+++ b/mysql-test/t/flush_read_lock.test
@@ -0,0 +1,2192 @@
+#
+# Test coverage for various aspects of FLUSH TABLES WITH READ LOCK
+# functionality.
+#
+
+# We need InnoDB for COMMIT/ROLLBACK related tests.
+--source include/have_innodb.inc
+# We need the Debug Sync Facility.
+--source include/have_debug_sync.inc
+# Parts of this test use DDL on events, BINLOG statement and
+# other statements which are not supported in embedded server.
+-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+--echo # FTWRL takes two global metadata locks -- a global shared
+--echo # metadata lock and the commit blocker lock.
+--echo # The first lock prevents DDL from taking place.
+--echo # Let's say that all DDL statements that take metadata
+--echo # locks form class #1 -- incompatible with FTWRL because
+--echo # take incompatible MDL table locks.
+--echo # The first global lock doesn't, however, prevent standalone
+--echo # COMMITs (or implicit COMMITs) from taking place, since a
+--echo # COMMIT doesn't take table locks. It doesn't prevent
+--echo # DDL on temporary tables either, since they don't
+--echo # take any table locks either.
+--echo # Most DDL statements do not perform an implicit commit
+--echo # if operate on a temporary table. Examples are CREATE
+--echo # TEMPORARY TABLE and DROP TEMPORARY TABLE.
+--echo # Thus, these DDL statements can go through in presence
+--echo # of FTWRL. This is class #2 -- compatible because
+--echo # do not take incompatible MDL locks and do not issue
+--echo # implicit commit..
+--echo # (Although these operations do not commit, their effects
+--echo # cannot be rolled back either.)
+--echo # ALTER TABLE, ANALYZE, OPTIMIZE and some others always
+--echo # issue an implicit commit, even if its argument is a
+--echo # temporary table.
+--echo # *Howewer* an implicit commit is a no-op if all engines
+--echo # used since the start of transactiona are non-
+--echo # transactional. Thus, for non-transactional engines,
+--echo # these operations are not blocked by FTWRL.
+--echo # This is class #3 -- compatible because do not take
+--echo # MDL table locks and are non-transactional.
+--echo # On the contrary, for transactional engines, there
+--echo # is always a commit, regardless of whether a table
+--echo # is temporary or not. Thus, for example, ALTER TABLE
+--echo # for a transactional engine will wait for FTWRL,
+--echo # even if the subject table is temporary.
+--echo # Thus ALTER TABLE <temporary> is incompatible
+--echo # with FTWRL. This is class #4 -- incompatible
+--echo # becuase issue implicit COMMIT which is not a no-op.
+--echo # Finally, there are administrative statements (such as
+--echo # RESET SLAVE) that do not take any locks and do not
+--echo # issue COMMIT.
+--echo # This is class #5.
+--echo # The goal of this coverage is to test statements
+--echo # of all classes.
+--echo # @todo: documents the effects of @@autocommit,
+--echo # DML and temporary transactional tables.
+
+--echo # Use MyISAM engine for the most of the tables
+--echo # used in this test in order to be able to
+--echo # check that DDL statements on temporary tables
+--echo # are compatible with FTRWL.
+--disable_warnings
+drop tables if exists t1_base, t2_base, t3_trans;
+drop tables if exists tm_base, tm_base_temp;
+drop database if exists mysqltest1;
+--echo # We're going to test ALTER DATABASE UPGRADE
+drop database if exists `#mysql50#mysqltest-2`;
+drop procedure if exists p1;
+drop function if exists f1;
+drop view if exists v1;
+drop procedure if exists p2;
+drop function if exists f2_base;
+drop function if exists f2_temp;
+drop event if exists e1;
+drop event if exists e2;
+--enable_warnings
+create table t1_base(i int) engine=myisam;
+create table t2_base(j int) engine=myisam;
+create table t3_trans(i int) engine=innodb;
+create temporary table t1_temp(i int) engine=myisam;
+create temporary table t2_temp(j int) engine=myisam;
+create temporary table t3_temp_trans(i int) engine=innodb;
+create database mysqltest1;
+create database `#mysql50#mysqltest-2`;
+create procedure p1() begin end;
+create function f1() returns int return 0;
+create view v1 as select 1 as i;
+create procedure p2(i int) begin end;
+delimiter |;
+create function f2_base() returns int
+begin
+ insert into t1_base values (1);
+ return 0;
+end|
+create function f2_temp() returns int
+begin
+ insert into t1_temp values (1);
+ return 0;
+end|
+delimiter ;|
+create event e1 on schedule every 1 minute do begin end;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,root,,);
+connection default;
+
+--echo #
+--echo # Test compatibility of FLUSH TABLES WITH READ LOCK
+--echo # with various statements.
+--echo #
+--echo # These tests don't cover some classes of statements:
+--echo # - Replication-related - CHANGE MASTER TO, START/STOP SLAVE and etc
+--echo # (all compatible with FTWRL).
+--echo # - Plugin-related - INSTALL/UNINSTALL (incompatible with FTWRL,
+--echo # require plugin support).
+
+let $con_aux1=con1;
+let $con_aux2=con2;
+let $cleanup_stmt2= ;
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 1) ALTER variants.
+--echo #
+--echo # 1.1) ALTER TABLE
+--echo #
+--echo # 1.1.a) For base table should be incompatible with FTWRL.
+--echo #
+let $statement= alter table t1_base add column c1 int;
+let $cleanup_stmt1= alter table t1_base drop column c1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 1.1.b) For a temporary table should be compatible with FTWRL.
+--echo #
+let $statement= alter table t1_temp add column c1 int;
+let $cleanup_stmt= alter table t1_temp drop column c1;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 1.2) ALTER DATABASE should be incompatible with FTWRL.
+--echo #
+let $statement= alter database mysqltest1 default character set utf8;
+let $cleanup_stmt1= alter database mysqltest1 default character set latin1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 1.3) ALTER DATABASE UPGRADE DATA DIRECTORY NAME should be
+--echo # incompatible with FTWRL.
+--echo #
+let $statement= alter database `#mysql50#mysqltest-2` upgrade data directory name;
+let $cleanup_stmt1= drop database `mysqltest-2`;
+let $cleanup_stmt2= create database `#mysql50#mysqltest-2`;
+--source include/check_ftwrl_incompatible.inc
+let $cleanup_stmt2= ;
+
+--echo #
+--echo # 1.4) ALTER PROCEDURE should be incompatible with FTWRL.
+--echo #
+let $statement= alter procedure p1 comment 'a';
+let $cleanup_stmt1= alter procedure p1 comment '';
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 1.5) ALTER FUNCTION should be incompatible with FTWRL.
+--echo #
+let $statement= alter function f1 comment 'a';
+let $cleanup_stmt1= alter function f1 comment '';
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 1.6) ALTER VIEW should be incompatible with FTWRL.
+--echo #
+let $statement= alter view v1 as select 2 as j;
+let $cleanup_stmt1= alter view v1 as select 1 as i;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 1.7) ALTER EVENT should be incompatible with FTWRL.
+--echo #
+let $statement= alter event e1 comment 'test';
+let $cleanup_stmt1= alter event e1 comment '';
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 1.x) The rest of ALTER statements (ALTER TABLESPACE,
+--echo # ALTER LOGFILE GROUP and ALTER SERVER) are too
+--echo # special to be tested here.
+--echo #
+
+
+--echo #
+--echo # 2) ANALYZE TABLE statement is compatible with FTWRL.
+--echo # See Bug#43336 ANALYZE and OPTIMIZE do not honour
+--echo # --read-only for a discussion why.
+--echo #
+let $statement= analyze table t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 3) BEGIN, ROLLBACK and COMMIT statements.
+--echo # BEGIN and ROLLBACK are compatible with FTWRL.
+--echo # COMMIT is not.
+--echo #
+--echo # We need a special test for these statements as
+--echo # FTWRL commits a transaction and because COMMIT
+--echo # is handled in a special way.
+flush tables with read lock;
+begin;
+--echo # ROLLBACK is allowed under FTWRL although there
+--echo # no much sense in it. FTWRL commits any previous
+--echo # changes and doesn't allows any DML after it.
+--echo # So such a ROLLBACK is always a no-op.
+rollback;
+--echo # Although COMMIT is incompatible with FTWRL in
+--echo # other senses it is still allowed under FTWRL.
+--echo # This fact relied upon by some versions of
+--echo # innobackup tool.
+--echo # Similarly to ROLLBACK it is a no-op in this situation.
+commit;
+unlock tables;
+--echo # Check that BEGIN/ROLLBACK are not blocked and
+--echo # COMMIT is blocked by active FTWRL in another
+--echo # connection.
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Do some work so ROLLBACK is not a no-op.
+insert into t3_trans values (1);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+rollback;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+--echo # Do some work so COMMIT is not a no-op.
+insert into t3_trans values (1);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Send:
+--send commit
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Wait until COMMIT is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "commit";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap COMMIT.
+--reap
+delete from t3_trans;
+--echo #
+--echo # Check that COMMIT blocks FTWRL in another connection.
+begin;
+insert into t3_trans values (1);
+set debug_sync='RESET';
+set debug_sync='ha_commit_trans_after_acquire_commit_lock SIGNAL parked WAIT_FOR go';
+--send commit
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+--send flush tables with read lock
+--echo # Switching to connection '$con_aux2'.
+connection $con_aux2;
+--echo # Wait until FTWRL is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "flush tables with read lock";
+--source include/wait_condition.inc
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap COMMIT.
+--reap
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Reap FTWRL.
+--reap
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+delete from t3_trans;
+set debug_sync= "RESET";
+--echo # We don't run similar test for BEGIN and ROLLBACK as
+--echo # they release metadata locks in non-standard place.
+
+
+--echo #
+--echo # 4) BINLOG statement should be incompatible with FTWRL.
+--echo #
+--echo #
+--echo # Provide format description BINLOG statement first.
+BINLOG '
+MfmqTA8BAAAAZwAAAGsAAAABAAQANS41LjctbTMtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAx+apMEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
+';
+--echo # Now test compatibility for BINLOG statement which is
+--echo # equivalent to INSERT INTO t1_base VALUES (1).
+let $statement= BINLOG '
+MfmqTBMBAAAALgAAAN0AAAAAACgAAAAAAAEABHRlc3QAB3QxX2Jhc2UAAQMAAQ==
+MfmqTBcBAAAAIgAAAP8AAAAAACgAAAAAAAEAAf/+AQAAAA==
+';
+let $cleanup_stmt1= delete from t1_base where i = 1 limit 1;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_incompatible.inc
+let $skip_3rd_check= ;
+
+
+--echo #
+--echo # 5) CALL statement. This statement uses resources in two
+--echo # ways: through expressions used as parameters and through
+--echo # sub-statements. This test covers only usage through
+--echo # parameters as sub-statements do locking individually.
+--echo #
+--echo # 5.a) In simple cases a parameter expression should be
+--echo # compatible with FTWRL.
+let $statement= call p2((select count(*) from t1_base));
+let $cleanup_stmt1= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 5.b) In case when an expression uses function which updates
+--echo # base tables CALL should be incompatible with FTWRL.
+--echo #
+let $statement= call p2(f2_base());
+let $cleanup_stmt1= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_incompatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 5.c) If function used as argument updates temporary tables
+--echo # CALL statement should be compatible with FTWRL.
+--echo #
+let $statement= call p2(f2_temp());
+let $cleanup_stmt1= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+
+--echo #
+--echo # 6) CHECK TABLE statement is compatible with FTWRL.
+--echo #
+let $statement= check table t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 7) CHECKSUM TABLE statement is compatible with FTWRL.
+--echo #
+let $statement= checksum table t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 8) CREATE variants.
+--echo #
+--echo # 8.1) CREATE TABLE statement.
+--echo #
+--echo # 8.1.a) CREATE TABLE is incompatible with FTWRL when
+--echo # base table is created.
+let $statement= create table t3_base(i int);
+let $cleanup_stmt1= drop table t3_base;
+--source include/check_ftwrl_incompatible.inc
+
+--echo # 8.1.b) CREATE TABLE is compatible with FTWRL when
+--echo # temporary table is created.
+let $statement= create temporary table t3_temp(i int);
+let $cleanup_stmt= drop temporary tables t3_temp;
+--source include/check_ftwrl_compatible.inc
+
+--echo # 8.1.c) CREATE TABLE LIKE is incompatible with FTWRL when
+--echo # base table is created.
+let $statement= create table t3_base like t1_temp;
+let $cleanup_stmt1= drop table t3_base;
+--source include/check_ftwrl_incompatible.inc
+
+--echo # 8.1.d) CREATE TABLE LIKE is compatible with FTWRL when
+--echo # temporary table is created.
+let $statement= create temporary table t3_temp like t1_base;
+let $cleanup_stmt= drop temporary table t3_temp;
+--source include/check_ftwrl_compatible.inc
+
+--echo # 8.1.e) CREATE TABLE SELECT is incompatible with FTWRL when
+--echo # base table is created.
+let $statement= create table t3_base select 1 as i;
+let $cleanup_stmt1= drop table t3_base;
+--source include/check_ftwrl_incompatible.inc
+
+--echo # 8.1.f) CREATE TABLE SELECT is compatible with FTWRL when
+--echo # temporary table is created.
+let $statement= create temporary table t3_temp select 1 as i;
+let $cleanup_stmt= drop temporary table t3_temp;
+--source include/check_ftwrl_compatible.inc
+
+--echo # 8.2) CREATE INDEX statement.
+--echo #
+--echo # 8.2.a) CREATE INDEX is incompatible with FTWRL when
+--echo # applied to base table.
+let $statement= create index i on t1_base (i);
+let $cleanup_stmt1= drop index i on t1_base;
+--source include/check_ftwrl_incompatible.inc
+
+--echo # 8.2.b) CREATE INDEX is compatible with FTWRL when
+--echo # applied to temporary table.
+let $statement= create index i on t1_temp (i);
+let $cleanup_stmt= drop index i on t1_temp;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 8.3) CREATE DATABASE is incompatible with FTWRL.
+--echo #
+let $statement= create database mysqltest2;
+let $cleanup_stmt1= drop database mysqltest2;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 8.4) CREATE VIEW is incompatible with FTWRL.
+--echo #
+let $statement= create view v2 as select 1 as j;
+let $cleanup_stmt1= drop view v2;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 8.5) CREATE TRIGGER is incompatible with FTWRL.
+--echo #
+let $statement= create trigger t1_bi before insert on t1_base for each row begin end;
+let $cleanup_stmt1= drop trigger t1_bi;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 8.6) CREATE FUNCTION is incompatible with FTWRL.
+--echo #
+let $statement= create function f2() returns int return 0;
+let $cleanup_stmt1= drop function f2;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 8.7) CREATE PROCEDURE is incompatible with FTWRL.
+--echo #
+let $statement= create procedure p3() begin end;
+let $cleanup_stmt1= drop procedure p3;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 8.8) CREATE EVENT should be incompatible with FTWRL.
+--echo #
+let $statement= create event e2 on schedule every 1 minute do begin end;
+let $cleanup_stmt1= drop event e2;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 8.9) CREATE USER should be incompatible with FTWRL.
+--echo #
+let $statement= create user mysqltest_u1;
+let $cleanup_stmt1= drop user mysqltest_u1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 8.x) The rest of CREATE variants (CREATE LOGFILE GROUP,
+--echo # CREATE TABLESPACE and CREATE SERVER) are too special
+--echo # to test here.
+--echo #
+
+
+--echo #
+--echo # 9) PREPARE, EXECUTE and DEALLOCATE PREPARE statements.
+--echo #
+--echo # 9.1) PREPARE statement is compatible with FTWRL as it
+--echo # doesn't change any data.
+--echo #
+--echo # 9.1.a) Prepare of simple INSERT statement.
+--echo #
+let $statement= prepare stmt1 from 'insert into t1_base values (1)';
+let $cleanup_stmt= deallocate prepare stmt1;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 9.1.b) Prepare of multi-UPDATE. At some point such statements
+--echo # tried to acquire thr_lock.c locks during prepare phase.
+--echo # This no longer happens and thus it is compatible with
+--echo # FTWRL.
+let $statement= prepare stmt1 from 'update t1_base, t2_base set t1_base.i= 1 where t1_base.i = t2_base.j';
+let $cleanup_stmt= deallocate prepare stmt1;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 9.1.c) Prepare of multi-DELETE. Again PREPARE of such
+--echo # statement should be compatible with FTWRL.
+let $statement= prepare stmt1 from 'delete t1_base from t1_base, t2_base where t1_base.i = t2_base.j';
+let $cleanup_stmt= deallocate prepare stmt1;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 9.2) Compatibility of EXECUTE statement depends on statement
+--echo # to be executed.
+--echo #
+--echo # 9.2.a) EXECUTE for statement which is itself compatible with
+--echo # FTWRL should be compatible.
+prepare stmt1 from 'select * from t1_base';
+let $statement= execute stmt1;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+deallocate prepare stmt1;
+
+call mtr.add_suppression("Slave SQL.*Can.t execute the query because you have a conflicting read lock., Error_code: 1223");
+
+--echo #
+--echo # 9.2.b) EXECUTE for statement which is incompatible with FTWRL
+--echo # should be also incompatible.
+--echo #
+--echo # Check that EXECUTE is not allowed under FTWRL.
+prepare stmt1 from 'insert into t1_base values (1)';
+flush tables with read lock;
+--error ER_CANT_UPDATE_WITH_READLOCK
+execute stmt1;
+unlock tables;
+--echo # Check that active FTWRL in another connection
+--echo # blocks EXECUTE which changes data.
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send execute stmt1
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that EXECUTE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "insert into t1_base values (1)";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap EXECUTE.
+--reap
+set debug_sync='RESET';
+set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
+--send execute stmt1;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+--send flush tables with read lock
+--echo # Switching to connection '$con_aux2'.
+connection $con_aux2;
+--echo # Wait until FTWRL is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "flush tables with read lock";
+--source include/wait_condition.inc
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap EXECUTE.
+--reap
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Reap FTWRL.
+--reap
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= "RESET";
+delete from t1_base;
+deallocate prepare stmt1;
+
+--echo #
+--echo # 9.3) DEALLOCATE PREPARE is compatible with FTWRL.
+--echo #
+prepare stmt1 from 'insert into t1_base values (1)';
+let $statement= deallocate prepare stmt1;
+let $cleanup_stmt= prepare stmt1 from 'insert into t1_base values (1)';
+--source include/check_ftwrl_compatible.inc
+deallocate prepare stmt1;
+
+
+--echo #
+--echo # 10) DELETE variations.
+--echo #
+--echo # 10.1) Simple DELETE.
+--echo #
+--echo # 10.1.a) Simple DELETE on base table is incompatible with FTWRL.
+let $statement= delete from t1_base;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 10.1.b) Simple DELETE on temporary table is compatible with FTWRL.
+let $statement= delete from t1_temp;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 10.2) Multi DELETE.
+--echo #
+--echo # 10.2.a) Multi DELETE on base tables is incompatible with FTWRL.
+let $statement= delete t1_base from t1_base, t2_base where t1_base.i = t2_base.j;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 10.2.b) Multi DELETE on temporary tables is compatible with FTWRL.
+let $statement= delete t1_temp from t1_temp, t2_temp where t1_temp.i = t2_temp.j;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 11) DESCRIBE should be compatible with FTWRL.
+--echo #
+let $statement= describe t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 12) Compatibility of DO statement with FTWRL depends on its
+--echo # expression.
+--echo #
+--echo # 12.a) DO with expression which does not change base table
+--echo # should be compatible with FTWRL.
+let $statement= do (select count(*) from t1_base);
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 12.b) DO which calls SF updating base table should be
+--echo # incompatible with FTWRL.
+let $statement= do f2_base();
+let $cleanup_stmt1= delete from t1_base limit 1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 12.c) DO which calls SF updating temporary table should be
+--echo # compatible with FTWRL.
+let $statement= do f2_temp();
+let $cleanup_stmt= delete from t1_temp limit 1;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 13) DROP variants.
+--echo #
+--echo # 13.1) DROP TABLES.
+--echo #
+--echo # 13.1.a) DROP TABLES which affects base tables is incompatible
+--echo # with FTWRL.
+let $statement= drop table t2_base;
+let $cleanup_stmt1= create table t2_base(j int);
+--source include/check_ftwrl_incompatible.inc
+
+--echo # 13.1.b) DROP TABLES which affects only temporary tables
+--echo # in theory can be compatible with FTWRL.
+--echo # In practice it is not yet.
+let $statement= drop table t2_temp;
+let $cleanup_stmt1= create temporary table t2_temp(j int);
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 13.1.c) DROP TEMPORARY TABLES should be compatible with FTWRL.
+let $statement= drop temporary table t2_temp;
+let $cleanup_stmt= create temporary table t2_temp(j int);
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 13.2) DROP INDEX.
+--echo #
+--echo # 13.2.a) DROP INDEX on a base table is incompatible with FTWRL.
+create index i on t1_base (i);
+let $statement= drop index i on t1_base;
+let $cleanup_stmt1= create index i on t1_base (i);
+--source include/check_ftwrl_incompatible.inc
+drop index i on t1_base;
+
+--echo #
+--echo # 13.2.b) DROP INDEX on a temporary table is compatible with FTWRL.
+create index i on t1_temp (i);
+let $statement= drop index i on t1_temp;
+let $cleanup_stmt= create index i on t1_temp (i);
+--source include/check_ftwrl_compatible.inc
+drop index i on t1_temp;
+
+--echo #
+--echo # 13.3) DROP DATABASE is incompatible with FTWRL
+--echo #
+let $statement= drop database mysqltest1;
+let $cleanup_stmt1= create database mysqltest1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 13.4) DROP FUNCTION is incompatible with FTWRL.
+--echo #
+let $statement= drop function f1;
+let $cleanup_stmt1= create function f1() returns int return 0;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 13.5) DROP PROCEDURE is incompatible with FTWRL.
+--echo #
+let $statement= drop procedure p1;
+let $cleanup_stmt1= create procedure p1() begin end;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 13.6) DROP USER should be incompatible with FTWRL.
+--echo #
+create user mysqltest_u1;
+let $statement= drop user mysqltest_u1;
+let $cleanup_stmt1= create user mysqltest_u1;
+--source include/check_ftwrl_incompatible.inc
+drop user mysqltest_u1;
+
+--echo #
+--echo # 13.7) DROP VIEW should be incompatible with FTWRL.
+--echo #
+let $statement= drop view v1;
+let $cleanup_stmt1= create view v1 as select 1 as i;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 13.8) DROP EVENT should be incompatible with FTWRL.
+--echo #
+let $statement= drop event e1;
+let $cleanup_stmt1= create event e1 on schedule every 1 minute do begin end;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 13.9) DROP TRIGGER is incompatible with FTWRL.
+--echo #
+create trigger t1_bi before insert on t1_base for each row begin end;
+let $statement= drop trigger t1_bi;
+let $cleanup_stmt1= create trigger t1_bi before insert on t1_base for each row begin end;
+--source include/check_ftwrl_incompatible.inc
+drop trigger t1_bi;
+
+--echo #
+--echo # 13.x) The rest of DROP variants (DROP TABLESPACE, DROP LOGFILE
+--echo # GROUP and DROP SERVER) are too special to test here.
+--echo #
+
+
+--echo #
+--echo # 14) FLUSH variants.
+--echo #
+--echo # Test compatibility of _some_ important FLUSH variants with FTWRL.
+--echo #
+--echo # 14.1) FLUSH TABLES WITH READ LOCK is compatible with itself.
+--echo #
+--echo # Check that FTWRL statements can be run while FTWRL
+--echo # is active in another connection.
+--echo #
+--echo # Switching to connection '$con_aux1'.
+flush tables with read lock;
+--echo # The second FTWRL in a row is allowed at the moment.
+--echo # It does not make much sense as it does only flush.
+flush tables with read lock;
+unlock tables;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+flush tables with read lock;
+unlock tables;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo #
+--echo # 14.2) FLUSH TABLES <list> WITH READ LOCK is not blocked by
+--echo # active FTWRL. But since the latter keeps tables open
+--echo # FTWRL is blocked by FLUSH TABLES <list> WITH READ LOCK.
+flush tables with read lock;
+--echo # FT <list> WRL is allowed under FTWRL at the moment.
+--echo # It does not make much sense though.
+flush tables t1_base, t2_base with read lock;
+unlock tables;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+flush tables t1_base, t2_base with read lock;
+unlock tables;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+flush tables t1_base, t2_base with read lock;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--send flush tables with read lock
+--echo # Switching to connection '$con_aux2'.
+connection $con_aux2;
+--echo # Wait until FTWRL is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush" and
+ info = "flush tables with read lock";
+--source include/wait_condition.inc
+--echo # Switching to connection 'default'.
+connection default;
+unlock tables;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Reap FTWRL.
+--reap
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+
+
+--echo #
+--echo # 14.3) FLUSH TABLES is compatible with FTWRL.
+let $statement= flush tables;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 14.4) FLUSH TABLES <list> is compatible with FTWRL.
+let $statement= flush table t1_base, t2_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 14.5) FLUSH PRIVILEGES is compatible with FTWRL.
+let $statement= flush privileges;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 15) GRANT statement should be incompatible with FTWRL.
+--echo #
+let $statement= grant all privileges on t1_base to mysqltest_u1;
+let $cleanup_stmt1= revoke all privileges on t1_base from mysqltest_u1;
+--source include/check_ftwrl_incompatible.inc
+drop user mysqltest_u1;
+
+
+--echo #
+--echo # 16) All HANDLER variants are half-compatible with FTWRL.
+--echo # I.e. they are not blocked by active FTWRL. But since open
+--echo # HANDLER means open table instance FTWRL is blocked while
+--echo # HANDLER is not closed.
+--echo #
+--echo # Check that HANDLER statements succeed under FTWRL.
+flush tables with read lock;
+handler t1_base open;
+handler t1_base read first;
+handler t1_base close;
+unlock tables;
+--echo # Check that HANDLER statements can be run while FTWRL
+--echo # is active in another connection.
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+handler t1_base open;
+handler t1_base read first;
+handler t1_base close;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+
+
+--echo #
+--echo # 17) HELP statement is compatible with FTWRL.
+--echo #
+let $statement= help no_such_topic;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 18) INSERT statement.
+--echo #
+--echo # 18.a) Ordinary INSERT into base table is incompatible with FTWRL.
+let $statement= insert into t1_base values (1);
+let $cleanup_stmt1= delete from t1_base limit 1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 18.b) Ordinary INSERT into temp table is compatible with FTWRL.
+let $statement= insert into t1_temp values (1);
+let $cleanup_stmt= delete from t1_temp limit 1;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 18.c) INSERT DELAYED is incompatible with FTWRL.
+let $statement= insert delayed into t1_base values (1);
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+delete from t1_base;
+
+--echo #
+--echo # 18.d) INSERT SELECT into base table is incompatible with FTWRL.
+let $statement= insert into t1_base select * from t1_temp;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 18.e) INSERT SELECT into temp table is compatible with FTWRL.
+let $statement= insert into t1_temp select * from t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 19) KILL statement is compatible with FTWRL.
+--echo #
+--echo # Check that KILL can be run under FTWRL.
+flush tables with read lock;
+set @id:= connection_id();
+--error ER_QUERY_INTERRUPTED
+kill query @id;
+unlock tables;
+--echo # Check that KILL statements can be run while FTWRL
+--echo # is active in another connection.
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--error ER_QUERY_INTERRUPTED
+kill query @id;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Finally check that KILL doesn't block FTWRL
+set debug_sync='RESET';
+set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
+--send kill query @id
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+flush tables with read lock;
+unlock tables;
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap KILL.
+--error ER_QUERY_INTERRUPTED
+--reap
+set debug_sync='RESET';
+
+
+--echo #
+--echo # 20) LOAD DATA statement.
+--echo #
+--echo # 20.a) LOAD DATA into base table is incompatible with FTWRL.
+let $statement= load data infile '../../std_data/rpl_loaddata.dat' into table t1_base (@dummy, i);
+let $cleanup_stmt1= delete from t1_base;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 20.b) LOAD DATA into temporary table is compatible with FTWRL.
+let $statement= load data infile '../../std_data/rpl_loaddata.dat' into table t1_temp (@dummy, i);
+let $cleanup_stmt= delete from t1_temp;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 21) LOCK/UNLOCK TABLES statements.
+--echo #
+--echo # LOCK TABLES statement always (almost) blocks FTWRL as it
+--echo # keeps tables open until UNLOCK TABLES.
+--echo # Active FTWRL on the other hand blocks only those
+--echo # LOCK TABLES which allow updating of base tables.
+--echo #
+--echo # 21.a) LOCK TABLES READ is allowed under FTWRL and
+--echo # is not blocked by active FTWRL.
+flush tables with read lock;
+lock tables t1_base read;
+unlock tables;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+lock tables t1_base read;
+unlock tables;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo #
+--echo # 21.b) LOCK TABLES WRITE on a base table is disallowed
+--echo # under FTWRL and should be blocked by active FTWRL.
+flush tables with read lock;
+--error ER_CANT_UPDATE_WITH_READLOCK
+lock tables t1_base write;
+unlock tables;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send lock tables t1_base write
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that LOCK TABLES WRITE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "lock tables t1_base write";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap LOCK TABLES WRITE
+--reap
+unlock tables;
+
+--echo #
+--echo # 21.c) LOCK TABLES WRITE on temporary table doesn't
+--echo # make much sense but is allowed under FTWRL
+--echo # and should not be blocked by active FTWRL.
+flush tables with read lock;
+lock tables t1_temp write;
+unlock tables;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+lock tables t1_temp write;
+unlock tables;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+
+
+--echo #
+--echo # 22) OPTIMIZE TABLE statement.
+--echo #
+--echo # 22.a) OPTIMIZE TABLE of base table is incompatible with FTWRL.
+flush tables with read lock;
+--echo # OPTIMIZE statement returns errors as part of result-set.
+optimize table t1_base;
+unlock tables;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send optimize table t1_base
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that OPTIMIZE TABLE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "optimize table t1_base";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap OPTIMIZE TABLE
+--reap
+--echo # We don't check that active OPTIMIZE TABLE blocks
+--echo # FTWRL as this one of statements releasing metadata
+--echo # locks in non-standard place.
+
+--echo #
+--echo # 22.b) OPTIMIZE TABLE of temporary table is compatible with FTWRL.
+let $statement= optimize table t1_temp;
+let $cleanup_stmt= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+
+--echo #
+--echo # 23) CACHE statement is compatible with FTWRL.
+--echo #
+let $statement= cache index t1_base in default;
+let $cleanup_stmt= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+
+--echo #
+--echo # 24) LOAD INDEX statement is compatible with FTWRL.
+--echo #
+let $statement= load index into cache t1_base;
+let $cleanup_stmt= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+
+--echo #
+--echo # 25) SAVEPOINT/RELEASE SAVEPOINT/ROLLBACK TO SAVEPOINT are
+--echo # compatible with FTWRL.
+--echo #
+--echo # Since manipulations on savepoint have to be done
+--echo # inside transaction and FTWRL commits transaction we
+--echo # need a special test for these statements.
+flush tables with read lock;
+begin;
+savepoint sv1;
+rollback to savepoint sv1;
+release savepoint sv1;
+unlock tables;
+commit;
+--echo # Check that these statements are not blocked by
+--echo # active FTWRL in another connection.
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Do some changes to avoid SAVEPOINT and friends
+--echo # being almost no-ops.
+insert into t3_trans values (1);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+savepoint sv1;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+insert into t3_trans values (2);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+rollback to savepoint sv1;
+release savepoint sv1;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+rollback;
+--echo # Check that these statements don't block FTWRL in
+--echo # another connection.
+begin;
+--echo # Do some changes to avoid SAVEPOINT and friends
+--echo # being almost no-ops.
+insert into t3_trans values (1);
+set debug_sync='RESET';
+set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
+--send savepoint sv1
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+flush tables with read lock;
+unlock tables;
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap SAVEPOINT
+--reap
+insert into t3_trans values (2);
+set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
+--send rollback to savepoint sv1
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+flush tables with read lock;
+unlock tables;
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap ROLLBACK TO SAVEPOINT
+--reap
+set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
+--send release savepoint sv1
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+flush tables with read lock;
+unlock tables;
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap RELEASE SAVEPOINT
+--reap
+rollback;
+set debug_sync= "RESET";
+
+
+--echo #
+--echo # 26) RENAME variants.
+--echo #
+--echo # 26.1) RENAME TABLES is incompatible with FTWRL.
+let $statement= rename table t1_base to t3_base;
+let $cleanup_stmt1= rename table t3_base to t1_base;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 26.2) RENAME USER is incompatible with FTWRL.
+create user mysqltest_u1;
+let $statement= rename user mysqltest_u1 to mysqltest_u2;
+let $cleanup_stmt1= rename user mysqltest_u2 to mysqltest_u1;
+--source include/check_ftwrl_incompatible.inc
+drop user mysqltest_u1;
+
+
+--echo #
+--echo # 27) REPAIR TABLE statement.
+--echo #
+--echo # 27.a) REPAIR TABLE of base table is incompatible with FTWRL.
+flush tables with read lock;
+--echo # REPAIR statement returns errors as part of result-set.
+repair table t1_base;
+unlock tables;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send repair table t1_base
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that REPAIR TABLE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "repair table t1_base";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap REPAIR TABLE
+--reap
+--echo # We don't check that active REPAIR TABLE blocks
+--echo # FTWRL as this one of statements releasing metadata
+--echo # locks in non-standard place.
+
+--echo #
+--echo # 27.b) REPAIR TABLE of temporary table is compatible with FTWRL.
+let $statement= repair table t1_temp;
+let $cleanup_stmt= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+
+--echo #
+--echo # 28) REPLACE statement.
+--echo #
+--echo # 28.a) Ordinary REPLACE into base table is incompatible with FTWRL.
+let $statement= replace into t1_base values (1);
+let $cleanup_stmt1= delete from t1_base limit 1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 28.b) Ordinary REPLACE into temp table is compatible with FTWRL.
+let $statement= replace into t1_temp values (1);
+let $cleanup_stmt= delete from t1_temp limit 1;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 28.c) REPLACE SELECT into base table is incompatible with FTWRL.
+let $statement= replace into t1_base select * from t1_temp;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 28.d) REPLACE SELECT into temp table is compatible with FTWRL.
+let $statement= replace into t1_temp select * from t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 29) REVOKE variants.
+--echo #
+--echo # 29.1) REVOKE privileges is incompatible with FTWRL.
+grant all privileges on t1_base to mysqltest_u1;
+let $statement= revoke all privileges on t1_base from mysqltest_u1;
+let $cleanup_stmt1= grant all privileges on t1_base to mysqltest_u1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 29.2) REVOKE ALL PRIVILEGES, GRANT OPTION is incompatible with FTWRL.
+let $statement= revoke all privileges, grant option from mysqltest_u1;
+let $cleanup_stmt1= grant all privileges on t1_base to mysqltest_u1;
+--source include/check_ftwrl_incompatible.inc
+drop user mysqltest_u1;
+
+
+--echo #
+--echo # 30) Compatibility of SELECT statement with FTWRL depends on
+--echo # locking mode used and on functions being invoked by it.
+--echo #
+--echo # 30.a) Simple SELECT which does not change tables should be
+--echo # compatible with FTWRL.
+let $statement= select count(*) from t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo # 30.b) SELECT ... FOR UPDATE is incompatible with FTWRL.
+let $statement= select count(*) from t1_base for update;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo # 30.c) SELECT ... LOCK IN SHARE MODE is compatible with FTWRL.
+let $statement= select count(*) from t1_base lock in share mode;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 30.d) SELECT which calls SF updating base table should be
+--echo # incompatible with FTWRL.
+let $statement= select f2_base();
+let $cleanup_stmt1= delete from t1_base limit 1;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 30.e) SELECT which calls SF updating temporary table should be
+--echo # compatible with FTWRL.
+let $statement= select f2_temp();
+let $cleanup_stmt= delete from t1_temp limit 1;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 31) Compatibility of SET statement with FTWRL depends on its
+--echo # expression and on whether it is a special SET statement.
+--echo #
+--echo # 31.a) Ordinary SET with expression which does not
+--echo # changes base table should be compatible with FTWRL.
+let $statement= set @a:= (select count(*) from t1_base);
+let $cleanup_stmt= ;
+--echo # Skip last part of compatibility testing as our helper debug
+--echo # sync-point doesn't work for SET statements.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 31.b) Ordinary SET which calls SF updating base table should
+--echo # be incompatible with FTWRL.
+let $statement= set @a:= f2_base();
+let $cleanup_stmt1= delete from t1_base limit 1;
+--echo # Skip last part of compatibility testing as our helper debug
+--echo # sync-point doesn't work for SET statements.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_incompatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 31.c) Ordinary SET which calls SF updating temporary table
+--echo # should be compatible with FTWRL.
+let $statement= set @a:= f2_temp();
+let $cleanup_stmt= delete from t1_temp limit 1;
+--echo # Skip last part of compatibility testing as our helper debug
+--echo # sync-point doesn't work for SET statements.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 31.d) Special SET variants have different compatibility with FTWRL.
+--echo #
+--echo # 31.d.I) SET PASSWORD is incompatible with FTWRL as it changes data.
+create user mysqltest_u1;
+let $statement= set password for 'mysqltest_u1' = password('');
+let $cleanup_stmt1= ;
+--echo # Skip last part of compatibility testing as our helper debug
+--echo # sync-point doesn't work for SET statements.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_incompatible.inc
+let $skip_3rd_check= ;
+drop user mysqltest_u1;
+--echo #
+--echo # 31.d.II) SET READ_ONLY is compatible with FTWRL (but has no
+--echo # effect when executed under it).
+let $statement= set global read_only= 1;
+let $cleanup_stmt= set global read_only= 0;
+--echo # Skip last part of compatibility testing as our helper debug
+--echo # sync-point doesn't work for SET statements.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+--echo #
+--echo # 31.d.III) Situation with SET AUTOCOMMIT is complex.
+--echo # Turning auto-commit off is always compatible with FTWRL.
+--echo # Turning auto-commit on causes implicit commit and so
+--echo # is incompatible with FTWRL if there are changes to be
+--echo # committed.
+flush tables with read lock;
+set autocommit= 0;
+--echo # Turning auto-commit on causes implicit commit so can
+--echo # be incompatible with FTWRL if there is something to
+--echo # commit. But since even in this case we allow commits
+--echo # under active FTWRL such statement should always succeed.
+insert into t3_temp_trans values (1);
+set autocommit= 1;
+unlock tables;
+delete from t3_temp_trans;
+--echo # Check that SET AUTOCOMMIT=0 is not blocked and
+--echo # SET AUTOCOMMIT=1 is blocked by active FTWRL in
+--echo # another connection.
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+set autocommit= 0;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Do some work so implicit commit in SET AUTOCOMMIT=1
+--echo # is not a no-op.
+insert into t3_trans values (1);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Send:
+--send set autocommit= 1
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Wait until SET AUTOCOMMIT=1 is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "set autocommit= 1";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap SET AUTOCOMMIT=1.
+--reap
+delete from t3_trans;
+--echo #
+--echo # Check that SET AUTOCOMMIT=1 blocks FTWRL in another connection.
+set autocommit= 0;
+insert into t3_trans values (1);
+set debug_sync='RESET';
+set debug_sync='ha_commit_trans_after_acquire_commit_lock SIGNAL parked WAIT_FOR go';
+--send set autocommit= 1
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+--send flush tables with read lock
+--echo # Switching to connection '$con_aux2'.
+connection $con_aux2;
+--echo # Wait until FTWRL is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "flush tables with read lock";
+--source include/wait_condition.inc
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap SET AUTOCOMMIT=1.
+--reap
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Reap FTWRL.
+--reap
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+delete from t3_trans;
+set debug_sync= "RESET";
+
+
+--echo #
+--echo # 32) SHOW statements are compatible with FTWRL.
+--echo # Let us test _some_ of them.
+--echo #
+--echo # 32.1) SHOW TABLES.
+let $statement= show tables from test;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 32.1) SHOW TABLES.
+let $statement= show tables from test;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 32.2) SHOW EVENTS.
+let $statement= show events from test;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 32.3) SHOW GRANTS.
+create user mysqltest_u1;
+let $statement= show grants for mysqltest_u1;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+drop user mysqltest_u1;
+
+--echo #
+--echo # 32.4) SHOW CREATE TABLE.
+let $statement= show create table t1_base;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 32.5) SHOW CREATE FUNCTION.
+let $statement= show create function f1;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 33) SIGNAL statement is compatible with FTWRL.
+--echo #
+--echo # Note that we don't cover RESIGNAL as it requires
+--echo # active handler context.
+let $statement= signal sqlstate '01000';
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 34) TRUNCATE TABLE statement.
+--echo #
+--echo # 34.a) TRUNCATE of base table is incompatible with FTWRL.
+let $statement= truncate table t1_base;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 34.b) TRUNCATE of temporary table is compatible with FTWRL.
+let $statement= truncate table t1_temp;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 35) UPDATE variants.
+--echo #
+--echo # 35.1) Simple UPDATE.
+--echo #
+--echo # 35.1.a) Simple UPDATE on base table is incompatible with FTWRL.
+let $statement= update t1_base set i= 1 where i = 0;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 35.1.b) Simple UPDATE on temporary table is compatible with FTWRL.
+let $statement= update t1_temp set i= 1 where i = 0;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 35.2) Multi UPDATE.
+--echo #
+--echo # 35.2.a) Multi UPDATE on base tables is incompatible with FTWRL.
+let $statement= update t1_base, t2_base set t1_base.i= 1 where t1_base.i = t2_base.j;
+let $cleanup_stmt1= ;
+--source include/check_ftwrl_incompatible.inc
+
+--echo #
+--echo # 35.2.b) Multi UPDATE on temporary tables is compatible with FTWRL.
+let $statement= update t1_temp, t2_temp set t1_temp.i= 1 where t1_temp.i = t2_temp.j;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 36) USE statement is compatible with FTWRL.
+--echo #
+let $statement= use mysqltest1;
+let $cleanup_stmt= use test;
+--source include/check_ftwrl_compatible.inc
+
+
+--echo #
+--echo # 37) XA statements.
+--echo #
+--echo # XA statements are similar to BEGIN/COMMIT/ROLLBACK.
+--echo #
+--echo # XA BEGIN, END, PREPARE, ROLLBACK and RECOVER are compatible
+--echo # with FTWRL. XA COMMIT is not.
+flush tables with read lock;
+--echo # Although all below statements are allowed under FTWRL they
+--echo # are almost no-ops as FTWRL does commit and does not allows
+--echo # any non-temporary DML under it.
+xa start 'test1';
+xa end 'test1';
+xa prepare 'test1';
+xa rollback 'test1';
+xa start 'test1';
+xa end 'test1';
+xa prepare 'test1';
+xa commit 'test1';
+--disable_result_log
+xa recover;
+--enable_result_log
+unlock tables;
+--echo # Check that XA non-COMMIT statements are not and COMMIT is
+--echo # blocked by active FTWRL in another connection
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+xa start 'test1';
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+insert into t3_trans values (1);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+xa end 'test1';
+xa prepare 'test1';
+xa rollback 'test1';
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+xa start 'test1';
+insert into t3_trans values (1);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+connection default;
+xa end 'test1';
+xa prepare 'test1';
+--echo # Send:
+--send xa commit 'test1';
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Wait until XA COMMIT is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "xa commit 'test1'";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap XA COMMIT.
+--reap
+delete from t3_trans;
+--echo #
+--echo # Check that XA COMMIT blocks FTWRL in another connection.
+xa start 'test1';
+insert into t3_trans values (1);
+xa end 'test1';
+xa prepare 'test1';
+set debug_sync='RESET';
+set debug_sync='trans_xa_commit_after_acquire_commit_lock SIGNAL parked WAIT_FOR go';
+--send xa commit 'test1'
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+--send flush tables with read lock
+--echo # Switching to connection '$con_aux2'.
+connection $con_aux2;
+--echo # Wait until FTWRL is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "flush tables with read lock";
+--source include/wait_condition.inc
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap XA COMMIT.
+--reap
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Reap FTWRL.
+--reap
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+delete from t3_trans;
+set debug_sync= "RESET";
+
+
+--echo #
+--echo # 38) Test effect of auto-commit mode for DML on transactional
+--echo # temporary tables.
+--echo #
+--echo # 38.1) When auto-commit is on each such a statement ends with commit
+--echo # of changes to temporary tables. But since transactions doing
+--echo # such changes are considered read only [sic!/QQ] this commit
+--echo # is compatible with FTWRL.
+--echo #
+--echo # Let us demostrate this fact for some common DML statements.
+let $statement= delete from t3_temp_trans;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+let $statement= insert into t3_temp_trans values (1);
+let $cleanup_stmt= delete from t3_temp_trans limit 1;
+--source include/check_ftwrl_compatible.inc
+
+let $statement= update t3_temp_trans, t2_temp set t3_temp_trans.i= 1 where t3_temp_trans.i = t2_temp.j;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+--echo #
+--echo # 38.2) When auto-commit is off DML on transaction temporary tables
+--echo # is compatible with FTWRL.
+--echo #
+set autocommit= 0;
+let $statement= delete from t3_temp_trans;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+
+let $statement= insert into t3_temp_trans values (1);
+let $cleanup_stmt= delete from t3_temp_trans limit 1;
+--source include/check_ftwrl_compatible.inc
+
+let $statement= update t3_temp_trans, t2_temp set t3_temp_trans.i= 1 where t3_temp_trans.i = t2_temp.j;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+set autocommit= 1;
+
+
+--echo #
+--echo # 39) Test effect of DDL on transactional tables.
+--echo #
+--echo # 39.1) Due to implicit commit at the end of statement some of DDL
+--echo # statements which are compatible with FTWRL in non-transactional
+--echo # case are not compatible in case of transactional tables.
+--echo #
+--echo # 39.1.a) ANALYZE TABLE for transactional table is incompatible with
+--echo # FTWRL.
+flush tables with read lock;
+--echo # Implicit commits are allowed under FTWRL.
+analyze table t3_trans;
+unlock tables;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send analyze table t3_trans
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that ANALYZE TABLE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "analyze table t3_trans";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap ANALYZE TABLE
+--reap
+
+--echo #
+--echo # 39.1.b) CHECK TABLE for transactional table is compatible with FTWRL.
+--echo # Although it does implicit commit at the end of statement it
+--echo # is considered to be read-only operation.
+let $statement= check table t3_trans;
+let $cleanup_stmt= ;
+--echo # Skip last part of compatibility testing as this statement
+--echo # releases metadata locks in non-standard place.
+let $skip_3rd_check= 1;
+--source include/check_ftwrl_compatible.inc
+let $skip_3rd_check= ;
+
+--echo #
+--echo # 39.2) Situation with DDL on temporary transactional tables is
+--echo # complex.
+--echo #
+--echo # 39.2.a) Some statements compatible with FTWRL since they don't
+--echo # do implicit commit.
+--echo #
+--echo # For example, CREATE TEMPORARY TABLE:
+let $statement= create temporary table t4_temp_trans(i int) engine=innodb;
+let $cleanup_stmt= drop temporary tables t4_temp_trans;
+--source include/check_ftwrl_compatible.inc
+--echo #
+--echo # Or DROP TEMPORARY TABLE:
+let $statement= drop temporary tables t3_temp_trans;
+let $cleanup_stmt= create temporary table t3_temp_trans(i int) engine=innodb;
+--source include/check_ftwrl_compatible.inc
+--echo #
+--echo # 39.2.b) Some statements do implicit commit but are considered
+--echo # read-only and so are compatible with FTWRL.
+--echo #
+--echo # For example, REPAIR TABLE:
+let $statement= repair table t3_temp_trans;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+--echo #
+--echo # And ANALYZE TABLE:
+let $statement= analyze table t3_temp_trans;
+let $cleanup_stmt= ;
+--source include/check_ftwrl_compatible.inc
+--echo #
+--echo # 39.2.c) Some statements do implicit commit and not
+--echo # considered read-only. As result they are
+--echo # not compatible with FTWRL.
+--echo #
+flush tables with read lock;
+--echo # Implicit commits are allowed under FTWRL.
+alter table t3_temp_trans add column c1 int;
+unlock tables;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send alter table t3_temp_trans drop column c1
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that ALTER TABLE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "alter table t3_temp_trans drop column c1";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap ALTER TABLE
+--reap
+
+
+--echo #
+--echo # 40) Test effect of implicit commit for DDL which is otherwise
+--echo # compatible with FTWRL. Implicit commit at the start of DDL
+--echo # statement can make it incompatible with FTWRL if there are
+--echo # some changes to be commited even in case when DDL statement
+--echo # itself is compatible with FTWRL.
+--echo #
+--echo # For example CHECK TABLE for base non-transactional tables and
+--echo # ALTER TABLE for temporary non-transactional tables are affected.
+begin;
+insert into t3_trans values (1);
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send check table t1_base
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that CHECK TABLE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "check table t1_base";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap CHECK TABLE
+--reap
+begin;
+delete from t3_trans;
+--echo #
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--send alter table t1_temp add column c1 int
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Check that ALTER TABLE is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for commit lock" and
+ info = "alter table t1_temp add column c1 int";
+--source include/wait_condition.inc
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap ALTER TABLE
+--reap
+alter table t1_temp drop column c1;
+
+
+--echo #
+--echo # Check that FLUSH TABLES WITH READ LOCK is blocked by individual
+--echo # statements and is not blocked in the presence of transaction which
+--echo # has done some changes earlier but is idle now (or does only reads).
+--echo # This allows to use this statement even on systems which has long
+--echo # running transactions.
+--echo #
+begin;
+insert into t1_base values (1);
+insert into t3_trans values (1);
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # The below FTWRL should not be blocked by transaction in 'default'.
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Transaction still is able to read even with FTWRL active in another
+--echo # connection.
+select * from t1_base;
+select * from t2_base;
+select * from t3_trans;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+commit;
+delete from t1_base;
+delete from t3_trans;
+
+
+--echo #
+--echo # Check that impending FTWRL blocks new DML statements and
+--echo # so can't be starved by a constant flow of DML.
+--echo # (a.k.a. test for bug #54673 "It takes too long to get
+--echo # readlock for 'FLUSH TABLES WITH READ LOCK'").
+--echo #
+set debug_sync='RESET';
+set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
+--send insert into t1_base values (1)
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+set debug_sync='now WAIT_FOR parked';
+--send flush tables with read lock
+--echo # Switching to connection '$con_aux2'.
+connection $con_aux2;
+--echo # Wait until FTWRL is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "flush tables with read lock";
+--source include/wait_condition.inc
+--echo # Try to run another INSERT and see that it is blocked.
+--send insert into t2_base values (1);
+--echo # Switching to connection 'con3'.
+connection con3;
+--echo # Wait until new INSERT is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "insert into t2_base values (1)";
+--echo # Unblock INSERT in the first connection.
+set debug_sync='now SIGNAL go';
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap first INSERT.
+--reap
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # Reap FTWRL.
+--reap
+unlock tables;
+--echo # Switching to connection '$con_aux2'.
+connection $con_aux2;
+--echo # Reap second INSERT.
+--reap
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= "RESET";
+delete from t1_base;
+delete from t2_base;
+
+--echo
+--echo # Check that COMMIT thas is issued after
+--echo # FLUSH TABLES WITH READ LOCK is not blocked by
+--echo # FLUSH TABLES WITH READ LOCK from another connection.
+--echo # This scenario is used in innobackup.pl. The COMMIT goes
+--echo # through because the transaction started by FTWRL does
+--echo # not modify any tables, and the commit blocker lock is
+--echo # only taken when there were such modifications.
+--echo
+flush tables with read lock;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+--echo # The below FTWRL should not be blocked by transaction in 'default'.
+flush tables with read lock;
+--echo # Switching to connection 'default'.
+connection default;
+select * from t1_base;
+select * from t3_trans;
+commit;
+--echo # Switching to connection '$con_aux1'.
+connection $con_aux1;
+select * from t1_base;
+select * from t3_trans;
+commit;
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+unlock tables;
+
+
+--echo #
+--echo # Check how FLUSH TABLE WITH READ LOCK is handled for MERGE tables.
+--echo # As usual there are tricky cases related to this type of tables.
+--echo #
+--echo #
+--echo # 1) Most typical case - base MERGE table with base underlying tables.
+--echo #
+--echo # 1.a) DML statements which change data should be incompatible with FTWRL.
+create table tm_base (i int) engine=merge union=(t1_base) insert_method=last;
+let $statement= insert into tm_base values (1);
+let $cleanup_stmt1= delete from tm_base;
+--source include/check_ftwrl_incompatible.inc
+--echo #
+--echo # 1.b) DDL statement on such table should be incompatible with FTWRL as well.
+let $statement= alter table tm_base insert_method=first;
+let $cleanup_stmt1= alter table tm_base insert_method=last;
+--source include/check_ftwrl_incompatible.inc
+drop table tm_base;
+
+--echo #
+--echo # 2) Temporary MERGE table with base underlying tables.
+--echo #
+--echo # 2.a) DML statements which change data should be incompatible with FTWRL
+--echo # as they affect base tables.
+create temporary table tm_temp_base (i int) engine=merge union=(t1_base) insert_method=last;
+let $statement= insert into tm_temp_base values (1);
+let $cleanup_stmt1= delete from tm_temp_base;
+--source include/check_ftwrl_incompatible.inc
+--echo #
+--echo # 2.b) Some of DDL statements on such table can be compatible with FTWRL
+--echo # as they don't affect base tables.
+let $statement= drop temporary tables tm_temp_base;
+let $cleanup_stmt= create temporary table tm_temp_base (i int) engine=merge union=(t1_base) insert_method=last;
+--source include/check_ftwrl_compatible.inc
+--echo #
+--echo # 2.c) ALTER statement is incompatible with FTWRL. Even though it does
+--echo # not change data in base table it still acquires strong metadata
+--echo # locks on them.
+let $statement= alter table tm_temp_base insert_method=first;
+let $cleanup_stmt1= alter table tm_temp_base insert_method=last;
+--source include/check_ftwrl_incompatible.inc
+drop table tm_temp_base;
+
+--echo #
+--echo # 3) Temporary MERGE table with temporary underlying tables.
+--echo #
+--echo # 3.a) DML statements should be compatible with FTWRL as
+--echo # no base table is going to be affected.
+create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last;
+let $statement= insert into tm_temp_temp values (1);
+let $cleanup_stmt= delete from tm_temp_temp;
+--source include/check_ftwrl_compatible.inc
+--echo #
+--echo # 3.b) DDL statements should be compatible with FTWRL as well
+--echo # as no base table is going to be affected too.
+let $statement= alter table tm_temp_temp union=(t1_temp) insert_method=first;
+let $cleanup_stmt= alter table tm_temp_temp union=(t1_temp) insert_method=last;
+--source include/check_ftwrl_compatible.inc
+drop table tm_temp_temp;
+
+--echo #
+--echo # 4) For the sake of completeness let us check that base MERGE tables
+--echo # with temporary underlying tables are not functional.
+create table tm_base_temp (i int) engine=merge union=(t1_temp) insert_method=last;
+--error ER_WRONG_MRG_TABLE
+select * from tm_base_temp;
+drop table tm_base_temp;
+
+
+--echo #
+--echo # Clean-up.
+--echo #
+drop event e1;
+drop function f2_temp;
+drop function f2_base;
+drop procedure p2;
+drop view v1;
+drop function f1;
+drop procedure p1;
+drop database `#mysql50#mysqltest-2`;
+drop database mysqltest1;
+drop temporary tables t1_temp, t2_temp;
+drop tables t1_base, t2_base, t3_trans;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+# 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
diff --git a/mysql-test/t/flush_read_lock_kill-master.opt b/mysql-test/t/flush_read_lock_kill-master.opt
deleted file mode 100644
index 61e2b242351..00000000000
--- a/mysql-test/t/flush_read_lock_kill-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---loose-debug=+d,make_global_read_lock_block_commit_loop
diff --git a/mysql-test/t/flush_read_lock_kill.test b/mysql-test/t/flush_read_lock_kill.test
index 2d359383949..a672fa5dfc5 100644
--- a/mysql-test/t/flush_read_lock_kill.test
+++ b/mysql-test/t/flush_read_lock_kill.test
@@ -2,24 +2,19 @@
# for running commits to finish (in the past it could not)
# This will not be a meaningful test on non-debug servers so will be
# skipped.
-# If running mysql-test-run --debug, the --debug added by
-# mysql-test-run to the mysqld command line will override the one of
-# -master.opt. But this test is designed to still pass then (though it
-# won't test anything interesting).
# This also won't work with the embedded server test
--source include/not_embedded.inc
--source include/have_debug.inc
+# This test needs transactional engine as otherwise COMMIT
+# won't block FLUSH TABLES WITH GLOBAL READ LOCK.
+--source include/have_innodb.inc
+
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
-# Disable concurrent inserts to avoid test failures when reading the
-# connection id which was inserted into a table by another thread.
-SET @old_concurrent_insert= @@global.concurrent_insert;
-SET @@global.concurrent_insert= 0;
-
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
@@ -27,47 +22,64 @@ connection con1;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
-CREATE TABLE t1 (kill_id INT);
+SET DEBUG_SYNC= 'RESET';
+CREATE TABLE t1 (kill_id INT) engine = InnoDB;
+INSERT INTO t1 VALUES(connection_id());
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Start transaction.
+BEGIN;
INSERT INTO t1 VALUES(connection_id());
+--echo # Ensure that COMMIT will pause once it acquires protection
+--echo # against its global read lock.
+SET DEBUG_SYNC='ha_commit_trans_after_acquire_commit_lock SIGNAL acquired WAIT_FOR go';
-# Thanks to the parameter we passed to --debug, this FLUSH will
-# block on a debug build running with our --debug=make_global... It
-# will block until killed. In other cases (non-debug build or other
-# --debug) it will succeed immediately
+--echo # Sending:
+--send COMMIT
+--echo # Switching to 'con1'.
connection con1;
+--echo # Wait till COMMIT acquires protection against global read
+--echo # lock and pauses.
+SET DEBUG_SYNC='now WAIT_FOR acquired';
+--echo # Sending:
send FLUSH TABLES WITH READ LOCK;
-# kill con1
+--echo # Switching to 'con2'.
connection con2;
-SELECT ((@id := kill_id) - kill_id) FROM t1;
+SELECT ((@id := kill_id) - kill_id) FROM t1 LIMIT 1;
-# Wait for the debug sync point, test won't run on non-debug
-# builds anyway.
+--echo # Wait till FLUSH TABLES WITH READ LOCK blocks due
+--echo # to active COMMIT
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Waiting for all running commits to finish"
+ where state = "Waiting for commit lock"
and info = "flush tables with read lock";
--source include/wait_condition.inc
+--echo # Kill connection 'con1'.
KILL CONNECTION @id;
+--echo # Switching to 'con1'.
connection con1;
-# On debug builds it will be error 1053 (killed); on non-debug, or
-# debug build running without our --debug=make_global..., will be
-# error 0 (no error). The only important thing to test is that on
-# debug builds with our --debug=make_global... we don't hang forever.
---error 0,1317,2013
+--echo # Try to reap FLUSH TABLES WITH READ LOCK,
+--echo # it fail due to killed statement and connection.
+--error 1317,2013
reap;
+--echo # Switching to 'con2'.
connection con2;
-DROP TABLE t1;
+--echo # Resume COMMIT.
+SET DEBUG_SYNC='now SIGNAL go';
+--echo # Switching to 'default'.
connection default;
+--echo # Reaping COMMIT.
+--reap
disconnect con2;
-
-# Restore global concurrent_insert value
-SET @@global.concurrent_insert= @old_concurrent_insert;
+DROP TABLE t1;
+SET DEBUG_SYNC= 'RESET';
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/flush_table.test b/mysql-test/t/flush_table.test
index 50e7e91419a..e4fc1b0c39f 100644
--- a/mysql-test/t/flush_table.test
+++ b/mysql-test/t/flush_table.test
@@ -15,30 +15,21 @@ insert into t1 values(0);
# Test for with read lock + flush
lock table t1 read;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
flush table t1;
-check table t1;
unlock tables;
-# Test for with 2 read lock in different thread + flush
+# Test for with write lock + flush
-lock table t1 read;
-connect (locker,localhost,root,,test);
-connection locker;
-lock table t1 read;
-connection default;
-send flush table t1;
-connection locker;
---sleep 2
-select * from t1;
-unlock tables;
-connection default;
-reap;
-select * from t1;
+lock table t1 write;
+flush table t1;
+check table t1;
unlock tables;
# Test for with a write lock and a waiting read lock + flush
lock table t1 write;
+connect (locker,localhost,root,,test);
connection locker;
send lock table t1 read;
connection default;
@@ -51,9 +42,9 @@ reap;
unlock tables;
connection default;
-# Test for with a read lock and a waiting write lock + flush
+# Test for with a write lock and a waiting write lock + flush
-lock table t1 read;
+lock table t1 write;
connection locker;
send lock table t1 write;
connection default;
diff --git a/mysql-test/t/foreign_key.test b/mysql-test/t/foreign_key.test
index 0a3708e6dc8..2a6ab01f511 100644
--- a/mysql-test/t/foreign_key.test
+++ b/mysql-test/t/foreign_key.test
@@ -23,3 +23,75 @@ create unique index b on t1 (a,b);
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#34455 (Ambiguous foreign keys syntax is accepted)
+#
+
+--disable_warnings
+drop table if exists t_34455;
+--enable_warnings
+
+# 2 match clauses, illegal
+--error ER_PARSE_ERROR
+create table t_34455 (
+ a int not null,
+ foreign key (a) references t3 (a) match full match partial);
+
+# match after on delete, illegal
+--error ER_PARSE_ERROR
+create table t_34455 (
+ a int not null,
+ foreign key (a) references t3 (a) on delete set default match full);
+
+# match after on update, illegal
+--error ER_PARSE_ERROR
+create table t_34455 (
+ a int not null,
+ foreign key (a) references t3 (a) on update set default match full);
+
+# 2 on delete clauses, illegal
+--error ER_PARSE_ERROR
+create table t_34455 (
+ a int not null,
+ foreign key (a) references t3 (a)
+ on delete set default on delete set default);
+
+# 2 on update clauses, illegal
+--error ER_PARSE_ERROR
+create table t_34455 (
+ a int not null,
+ foreign key (a) references t3 (a)
+ on update set default on update set default);
+
+create table t_34455 (a int not null);
+
+# 2 match clauses, illegal
+--error ER_PARSE_ERROR
+alter table t_34455
+ add foreign key (a) references t3 (a) match full match partial);
+
+# match after on delete, illegal
+--error ER_PARSE_ERROR
+alter table t_34455
+ add foreign key (a) references t3 (a) on delete set default match full);
+
+# match after on update, illegal
+--error ER_PARSE_ERROR
+alter table t_34455
+ add foreign key (a) references t3 (a) on update set default match full);
+
+# 2 on delete clauses, illegal
+--error ER_PARSE_ERROR
+alter table t_34455
+ add foreign key (a) references t3 (a)
+ on delete set default on delete set default);
+
+# 2 on update clauses, illegal
+--error ER_PARSE_ERROR
+alter table t_34455
+ add foreign key (a) references t3 (a)
+ on update set default on update set default);
+
+drop table t_34455;
+
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 6de8b87197c..db7d9fd2d08 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -420,6 +420,15 @@ DROP TABLE t1;
# End of 4.1 tests
#
+# bug#34374 - mysql generates incorrect warning
+#
+create table t1(a text,b date,fulltext index(a))engine=myisam;
+insert into t1 set a='water',b='2008-08-04';
+select 1 from t1 where match(a) against ('water' in boolean mode) and b>='2008-08-01';
+drop table t1;
+show warnings;
+
+#
# BUG#38842 - Fix for 25951 seems incorrect
#
CREATE TABLE t1 (a VARCHAR(255), b INT, FULLTEXT(a), KEY(b));
@@ -591,7 +600,7 @@ DROP TABLE t1;
CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1));
INSERT INTO t1 VALUES ('test');
-
+--disable_warnings
SELECT 1 FROM t1 WHERE 1 >
ALL((SELECT 1 FROM t1 JOIN t1 a
ON (MATCH(t1.f1) against (""))
@@ -618,6 +627,7 @@ EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
+--enable_warnings
DROP TABLE t1;
diff --git a/mysql-test/t/fulltext_plugin.test b/mysql-test/t/fulltext_plugin.test
index 31978dadc51..b591a7949e5 100644
--- a/mysql-test/t/fulltext_plugin.test
+++ b/mysql-test/t/fulltext_plugin.test
@@ -3,7 +3,8 @@
#
# BUG#39746 - Debug flag breaks struct definition (server crash)
#
-INSTALL PLUGIN simple_parser SONAME 'mypluglib.so';
+--replace_regex /\.dll/.so/
+eval INSTALL PLUGIN simple_parser SONAME '$SIMPLE_PARSER';
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser);
ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser;
DROP TABLE t1;
diff --git a/mysql-test/t/analyse.test b/mysql-test/t/func_analyse.test
index 05f739bfd69..c77967a0cc9 100644
--- a/mysql-test/t/analyse.test
+++ b/mysql-test/t/func_analyse.test
@@ -1,6 +1,7 @@
#
# Test of procedure analyse
#
+-- source include/have_innodb.inc
--disable_warnings
drop table if exists t1,t2;
@@ -133,3 +134,26 @@ DROP TABLE t1;
--echo End of 5.0 tests
+
+--echo #
+--echo # Bug#11765202: Dbug_violation_helper::~Dbug_violation_helper(): Assertion `!_entered' failed.
+--echo #
+
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a VARCHAR(2) CHARSET UTF8 NOT NULL);
+INSERT INTO t1 VALUES ('e'),('e'),('e-');
+SELECT * FROM t1 PROCEDURE ANALYSE();
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11756242 48137: PROCEDURE ANALYSE() LEAKS MEMORY WHEN RETURNING NULL
+--echo #
+
+CREATE TABLE t1(f1 INT) ENGINE=MYISAM;
+CREATE TABLE t2(f2 INT) ENGINE=INNODB;
+INSERT INTO t2 VALUES (1);
+SELECT DISTINCTROW f1 FROM t1 NATURAL RIGHT OUTER JOIN t2 PROCEDURE ANALYSE();
+SELECT * FROM t2 LIMIT 1 PROCEDURE ANALYSE();
+DROP TABLE t1, t2;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/func_des_encrypt.test b/mysql-test/t/func_des_encrypt.test
index 2c364a40090..e121aedab06 100644
--- a/mysql-test/t/func_des_encrypt.test
+++ b/mysql-test/t/func_des_encrypt.test
@@ -1,4 +1,4 @@
--- source include/have_ssl.inc
+-- source include/have_ssl_crypto_functs.inc
# This test can't be in func_encrypt.test, because it requires
# --des-key-file to not be set.
diff --git a/mysql-test/t/func_digest.test b/mysql-test/t/func_digest.test
new file mode 100644
index 00000000000..81f19c7e091
--- /dev/null
+++ b/mysql-test/t/func_digest.test
@@ -0,0 +1,496 @@
+-- source include/have_ssl_crypto_functs.inc
+
+# These test data are from the NIST SHA Test Vectors for Hashing
+# Byte-Oriented Messages. See http://csrc.nist.gov/cryptval/shs.htm
+# Only the "ShortMsg" test data are used here.
+# Values of x'00' in the test data have been excluded; it is not clear
+# how to specify a length of 8 bits for a binary value like that.
+
+SELECT SHA1( x'a8' ) = '99f2aa95e36f95c2acb0eaf23998f030638f3f15' as NIST_SHA1_test_vector;
+SELECT SHA1( x'3000' ) = 'f944dcd635f9801f7ac90a407fbc479964dec024' as NIST_SHA1_test_vector;
+SELECT SHA1( x'42749e' ) = 'a444319e9b6cc1e8464c511ec0969c37d6bb2619' as NIST_SHA1_test_vector;
+SELECT SHA1( x'9fc3fe08' ) = '16a0ff84fcc156fd5d3ca3a744f20a232d172253' as NIST_SHA1_test_vector;
+SELECT SHA1( x'b5c1c6f1af' ) = 'fec9deebfcdedaf66dda525e1be43597a73a1f93' as NIST_SHA1_test_vector;
+SELECT SHA1( x'e47571e5022e' ) = '8ce051181f0ed5e9d0c498f6bc4caf448d20deb5' as NIST_SHA1_test_vector;
+SELECT SHA1( x'3e1b28839fb758' ) = '67da53837d89e03bf652ef09c369a3415937cfd3' as NIST_SHA1_test_vector;
+SELECT SHA1( x'a81350cbb224cb90' ) = '305e4ff9888ad855a78573cddf4c5640cce7e946' as NIST_SHA1_test_vector;
+SELECT SHA1( x'c243d167923dec3ce1' ) = '5902b77b3265f023f9bbc396ba1a93fa3509bde7' as NIST_SHA1_test_vector;
+SELECT SHA1( x'50ac18c59d6a37a29bf4' ) = 'fcade5f5d156bf6f9af97bdfa9c19bccfb4ff6ab' as NIST_SHA1_test_vector;
+SELECT SHA1( x'98e2b611ad3b1cccf634f6' ) = '1d20fbe00533c10e3cbd6b27088a5de0c632c4b5' as NIST_SHA1_test_vector;
+SELECT SHA1( x'73fe9afb68e1e8712e5d4eec' ) = '7e1b7e0f7a8f3455a9c03e9580fd63ae205a2d93' as NIST_SHA1_test_vector;
+SELECT SHA1( x'9e701ed7d412a9226a2a130e66' ) = '706f0677146307b20bb0e8d6311e329966884d13' as NIST_SHA1_test_vector;
+SELECT SHA1( x'6d3ee90413b0a7cbf69e5e6144ca' ) = 'a7241a703aaf0d53fe142f86bf2e849251fa8dff' as NIST_SHA1_test_vector;
+SELECT SHA1( x'fae24d56514efcb530fd4802f5e71f' ) = '400f53546916d33ad01a5e6df66822dfbdc4e9e6' as NIST_SHA1_test_vector;
+SELECT SHA1( x'c5a22dd6eda3fe2bdc4ddb3ce6b35fd1' ) = 'fac8ab93c1ae6c16f0311872b984f729dc928ccd' as NIST_SHA1_test_vector;
+SELECT SHA1( x'd98cded2adabf08fda356445c781802d95' ) = 'fba6d750c18da58f6e2aab10112b9a5ef3301b3b' as NIST_SHA1_test_vector;
+SELECT SHA1( x'bcc6d7087a84f00103ccb32e5f5487a751a2' ) = '29d27c2d44c205c8107f0351b05753ac708226b6' as NIST_SHA1_test_vector;
+SELECT SHA1( x'36ecacb1055434190dbbc556c48bafcb0feb0d' ) = 'b971bfc1ebd6f359e8d74cb7ecfe7f898d0ba845' as NIST_SHA1_test_vector;
+SELECT SHA1( x'5ff9edb69e8f6bbd498eb4537580b7fba7ad31d0' ) = '96d08c430094b9fcc164ad2fb6f72d0a24268f68' as NIST_SHA1_test_vector;
+SELECT SHA1( x'c95b441d8270822a46a798fae5defcf7b26abace36' ) = 'a287ea752a593d5209e287881a09c49fa3f0beb1' as NIST_SHA1_test_vector;
+SELECT SHA1( x'83104c1d8a55b28f906f1b72cb53f68cbb097b44f860' ) = 'a06c713779cbd88519ed4a585ac0cb8a5e9d612b' as NIST_SHA1_test_vector;
+SELECT SHA1( x'755175528d55c39c56493d697b790f099a5ce741f7754b' ) = 'bff7d52c13a3688132a1d407b1ab40f5b5ace298' as NIST_SHA1_test_vector;
+SELECT SHA1( x'088fc38128bbdb9fd7d65228b3184b3faac6c8715f07272f' ) = 'c7566b91d7b6f56bdfcaa9781a7b6841aacb17e9' as NIST_SHA1_test_vector;
+SELECT SHA1( x'a4a586eb9245a6c87e3adf1009ac8a49f46c07e14185016895' ) = 'ffa30c0b5c550ea4b1e34f8a60ec9295a1e06ac1' as NIST_SHA1_test_vector;
+SELECT SHA1( x'8e7c555270c006092c2a3189e2a526b873e2e269f0fb28245256' ) = '29e66ed23e914351e872aa761df6e4f1a07f4b81' as NIST_SHA1_test_vector;
+SELECT SHA1( x'a5f3bfa6bb0ba3b59f6b9cbdef8a558ec565e8aa3121f405e7f2f0' ) = 'b28cf5e5b806a01491d41f69bd9248765c5dc292' as NIST_SHA1_test_vector;
+SELECT SHA1( x'589054f0d2bd3c2c85b466bfd8ce18e6ec3e0b87d944cd093ba36469' ) = '60224fb72c46069652cd78bcd08029ef64da62f3' as NIST_SHA1_test_vector;
+SELECT SHA1( x'a0abb12083b5bbc78128601bf1cbdbc0fdf4b862b24d899953d8da0ff3' ) = 'b72c4a86f72608f24c05f3b9088ef92fba431df7' as NIST_SHA1_test_vector;
+SELECT SHA1( x'82143f4cea6fadbf998e128a8811dc75301cf1db4f079501ea568da68eeb' ) = '73779ad5d6b71b9b8328ef7220ff12eb167076ac' as NIST_SHA1_test_vector;
+SELECT SHA1( x'9f1231dd6df1ff7bc0b0d4f989d048672683ce35d956d2f57913046267e6f3' ) = 'a09671d4452d7cf50015c914a1e31973d20cc1a0' as NIST_SHA1_test_vector;
+SELECT SHA1( x'041c512b5eed791f80d3282f3a28df263bb1df95e1239a7650e5670fc2187919' ) = 'e88cdcd233d99184a6fd260b8fca1b7f7687aee0' as NIST_SHA1_test_vector;
+SELECT SHA1( x'17e81f6ae8c2e5579d69dafa6e070e7111461552d314b691e7a3e7a4feb3fae418' ) = '010def22850deb1168d525e8c84c28116cb8a269' as NIST_SHA1_test_vector;
+SELECT SHA1( x'd15976b23a1d712ad28fad04d805f572026b54dd64961fda94d5355a0cc98620cf77' ) = 'aeaa40ba1717ed5439b1e6ea901b294ba500f9ad' as NIST_SHA1_test_vector;
+SELECT SHA1( x'09fce4d434f6bd32a44e04b848ff50ec9f642a8a85b37a264dc73f130f22838443328f' ) = 'c6433791238795e34f080a5f1f1723f065463ca0' as NIST_SHA1_test_vector;
+SELECT SHA1( x'f17af27d776ec82a257d8d46d2b46b639462c56984cc1be9c1222eadb8b26594a25c709d' ) = 'e21e22b89c1bb944a32932e6b2a2f20d491982c3' as NIST_SHA1_test_vector;
+SELECT SHA1( x'b13ce635d6f8758143ffb114f2f601cb20b6276951416a2f94fbf4ad081779d79f4f195b22' ) = '575323a9661f5d28387964d2ba6ab92c17d05a8a' as NIST_SHA1_test_vector;
+SELECT SHA1( x'5498793f60916ff1c918dde572cdea76da8629ba4ead6d065de3dfb48de94d234cc1c5002910' ) = 'feb44494af72f245bfe68e86c4d7986d57c11db7' as NIST_SHA1_test_vector;
+SELECT SHA1( x'498a1e0b39fa49582ae688cd715c86fbaf8a81b8b11b4d1594c49c902d197c8ba8a621fd6e3be5' ) = 'cff2290b3648ba2831b98dde436a72f9ebf51eee' as NIST_SHA1_test_vector;
+SELECT SHA1( x'3a36ae71521f9af628b3e34dcb0d4513f84c78ee49f10416a98857150b8b15cb5c83afb4b570376e' ) = '9b4efe9d27b965905b0c3dab67b8d7c9ebacd56c' as NIST_SHA1_test_vector;
+SELECT SHA1( x'dcc76b40ae0ea3ba253e92ac50fcde791662c5b6c948538cffc2d95e9de99cac34dfca38910db2678f' ) = 'afedb0ff156205bcd831cbdbda43db8b0588c113' as NIST_SHA1_test_vector;
+SELECT SHA1( x'5b5ec6ec4fd3ad9c4906f65c747fd4233c11a1736b6b228b92e90cddabb0c7c2fcf9716d3fad261dff33' ) = '8deb1e858f88293a5e5e4d521a34b2a4efa70fc4' as NIST_SHA1_test_vector;
+SELECT SHA1( x'df48a37b29b1d6de4e94717d60cdb4293fcf170bba388bddf7a9035a15d433f20fd697c3e4c8b8c5f590ab' ) = '95cbdac0f74afa69cebd0e5c7defbc6faf0cbeaf' as NIST_SHA1_test_vector;
+SELECT SHA1( x'1f179b3b82250a65e1b0aee949e218e2f45c7a8dbfd6ba08de05c55acfc226b48c68d7f7057e5675cd96fcfc' ) = 'f0307bcb92842e5ae0cd4f4f14f3df7f877fbef2' as NIST_SHA1_test_vector;
+SELECT SHA1( x'ee3d72da3a44d971578972a8e6780ce64941267e0f7d0179b214fa97855e1790e888e09fbe3a70412176cb3b54' ) = '7b13bb0dbf14964bd63b133ac85e22100542ef55' as NIST_SHA1_test_vector;
+SELECT SHA1( x'd4d4c7843d312b30f610b3682254c8be96d5f6684503f8fbfbcd15774fc1b084d3741afb8d24aaa8ab9c104f7258' ) = 'c314d2b6cf439be678d2a74e890d96cfac1c02ed' as NIST_SHA1_test_vector;
+SELECT SHA1( x'32c094944f5936a190a0877fb9178a7bf60ceae36fd530671c5b38c5dbd5e6a6c0d615c2ac8ad04b213cc589541cf6' ) = '4d0be361e410b47a9d67d8ce0bb6a8e01c53c078' as NIST_SHA1_test_vector;
+SELECT SHA1( x'e5d3180c14bf27a5409fa12b104a8fd7e9639609bfde6ee82bbf9648be2546d29688a65e2e3f3da47a45ac14343c9c02' ) = 'e5353431ffae097f675cbf498869f6fbb6e1c9f2' as NIST_SHA1_test_vector;
+SELECT SHA1( x'e7b6e4b69f724327e41e1188a37f4fe38b1dba19cbf5a7311d6e32f1038e97ab506ee05aebebc1eed09fc0e357109818b9' ) = 'b8720a7068a085c018ab18961de2765aa6cd9ac4' as NIST_SHA1_test_vector;
+SELECT SHA1( x'bc880cb83b8ac68ef2fedc2da95e7677ce2aa18b0e2d8b322701f67af7d5e7a0d96e9e33326ccb7747cfff0852b961bfd475' ) = 'b0732181568543ba85f2b6da602b4b065d9931aa' as NIST_SHA1_test_vector;
+SELECT SHA1( x'235ea9c2ba7af25400f2e98a47a291b0bccdaad63faa2475721fda5510cc7dad814bce8dabb611790a6abe56030b798b75c944' ) = '9c22674cf3222c3ba921672694aafee4ce67b96b' as NIST_SHA1_test_vector;
+SELECT SHA1( x'07e3e29fed63104b8410f323b975fd9fba53f636af8c4e68a53fb202ca35dd9ee07cb169ec5186292e44c27e5696a967f5e67709' ) = 'd128335f4cecca9066cdae08958ce656ff0b4cfc' as NIST_SHA1_test_vector;
+SELECT SHA1( x'65d2a1dd60a517eb27bfbf530cf6a5458f9d5f4730058bd9814379547f34241822bf67e6335a6d8b5ed06abf8841884c636a25733f' ) = '0b67c57ac578de88a2ae055caeaec8bb9b0085a0' as NIST_SHA1_test_vector;
+SELECT SHA1( x'dcc86b3bd461615bab739d8daafac231c0f462e819ad29f9f14058f3ab5b75941d4241ea2f17ebb8a458831b37a9b16dead4a76a9b0e' ) = 'c766f912a89d4ccda88e0cce6a713ef5f178b596' as NIST_SHA1_test_vector;
+SELECT SHA1( x'4627d54f0568dc126b62a8c35fb46a9ac5024400f2995e51635636e1afc4373dbb848eb32df23914230560b82477e9c3572647a7f2bb92' ) = '9aa3925a9dcb177b15ccff9b78e70cf344858779' as NIST_SHA1_test_vector;
+SELECT SHA1( x'ba531affd4381168ef24d8b275a84d9254c7f5cc55fded53aa8024b2c5c5c8aa7146fe1d1b83d62b70467e9a2e2cb67b3361830adbab28d7' ) = '4811fa30042fc076acf37c8e2274d025307e5943' as NIST_SHA1_test_vector;
+SELECT SHA1( x'8764dcbcf89dcf4282eb644e3d568bdccb4b13508bfa7bfe0ffc05efd1390be22109969262992d377691eb4f77f3d59ea8466a74abf57b2ef4' ) = '6743018450c9730761ee2b130df9b91c1e118150' as NIST_SHA1_test_vector;
+SELECT SHA1( x'497d9df9ddb554f3d17870b1a31986c1be277bc44feff713544217a9f579623d18b5ffae306c25a45521d2759a72c0459b58957255ab592f3be4' ) = '71ad4a19d37d92a5e6ef3694ddbeb5aa61ada645' as NIST_SHA1_test_vector;
+SELECT SHA1( x'72c3c2e065aefa8d9f7a65229e818176eef05da83f835107ba90ec2e95472e73e538f783b416c04654ba8909f26a12db6e5c4e376b7615e4a25819' ) = 'a7d9dc68dacefb7d6116186048cb355cc548e11d' as NIST_SHA1_test_vector;
+SELECT SHA1( x'7cc9894454d0055ab5069a33984e2f712bef7e3124960d33559f5f3b81906bb66fe64da13c153ca7f5cabc89667314c32c01036d12ecaf5f9a78de98' ) = '142e429f0522ba5abf5131fa81df82d355b96909' as NIST_SHA1_test_vector;
+SELECT SHA1( x'74e8404d5a453c5f4d306f2cfa338ca65501c840ddab3fb82117933483afd6913c56aaf8a0a0a6b2a342fc3d9dc7599f4a850dfa15d06c61966d74ea59' ) = 'ef72db70dcbcab991e9637976c6faf00d22caae9' as NIST_SHA1_test_vector;
+SELECT SHA1( x'46fe5ed326c8fe376fcc92dc9e2714e2240d3253b105adfbb256ff7a19bc40975c604ad7c0071c4fd78a7cb64786e1bece548fa4833c04065fe593f6fb10' ) = 'f220a7457f4588d639dc21407c942e9843f8e26b' as NIST_SHA1_test_vector;
+SELECT SHA1( x'836dfa2524d621cf07c3d2908835de859e549d35030433c796b81272fd8bc0348e8ddbc7705a5ad1fdf2155b6bc48884ac0cd376925f069a37849c089c8645' ) = 'ddd2117b6e309c233ede85f962a0c2fc215e5c69' as NIST_SHA1_test_vector;
+SELECT SHA1( x'7e3a4c325cb9c52b88387f93d01ae86d42098f5efa7f9457388b5e74b6d28b2438d42d8b64703324d4aa25ab6aad153ae30cd2b2af4d5e5c00a8a2d0220c6116' ) = 'a3054427cdb13f164a610b348702724c808a0dcc' as NIST_SHA1_test_vector;
+
+# See Bug#13174 and WL#3986 -- SHA2 implementation
+
+SELECT SHA2( x'ff', 224 ) = 'e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5' as NIST_SHA224_test_vector;
+SELECT SHA2( x'984c', 224 ) = '2fa9df9157d9e027cfbc4c6a9df32e1adc0cbe2328ec2a63c5ae934e' as NIST_SHA224_test_vector;
+SELECT SHA2( x'50efd0', 224 ) = 'b5a9820413c2bf8211fbbf5df1337043b32fa4eafaf61a0c8e9ccede' as NIST_SHA224_test_vector;
+SELECT SHA2( x'e5e09924', 224 ) = 'fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d' as NIST_SHA224_test_vector;
+SELECT SHA2( x'21ebecb914', 224 ) = '78f4a71c21c694499ce1c7866611b14ace70d905012c356323c7c713' as NIST_SHA224_test_vector;
+SELECT SHA2( x'76aa302bc7bb', 224 ) = '8e0f460d8c1f9d9a850a3a0b06408becc4950a77d5e8f94dc8e86fd3' as NIST_SHA224_test_vector;
+SELECT SHA2( x'510db320ebc443', 224 ) = 'df4fc9bcd967feb83146fd4d2a7448d7d54119a14cb7ffc6753de703' as NIST_SHA224_test_vector;
+SELECT SHA2( x'17040eed0880ed95', 224 ) = '5c81df5f342d1284a08d846c223f0367ca385ba60908a7fc93470317' as NIST_SHA224_test_vector;
+SELECT SHA2( x'a92d4c1b971b963f65', 224 ) = 'a45eb31a2482b4581ac321b9175a386c69eb80d43191459e2de6bd0d' as NIST_SHA224_test_vector;
+SELECT SHA2( x'49c7e96152a2b42ab57f', 224 ) = '53953c275c4fc2f87ca044760a861920fbfc1550a4c822e47457f038' as NIST_SHA224_test_vector;
+SELECT SHA2( x'becc72bd1596ed064bfbdc', 224 ) = '98ec4bf49071d1b164fdbb415c67db965b7c5f191bb1801c76ea9dc1' as NIST_SHA224_test_vector;
+SELECT SHA2( x'635afe6c43cabe340d430b69', 224 ) = 'c3a2de40958d2a35e3775eb60aab09fb3097658ac96fe2e142d28dfc' as NIST_SHA224_test_vector;
+SELECT SHA2( x'c997165324078ed6160077dfea', 224 ) = '17c6235304dd830349bfd8ce7f8f1f41e52fc53bec7bb23382d2d598' as NIST_SHA224_test_vector;
+SELECT SHA2( x'f871896748653be45dcb64a2bd1a', 224 ) = '3ff8e241b0895a06854d6f660cd7ddfc9a6b36ca73092f2f0cf54109' as NIST_SHA224_test_vector;
+SELECT SHA2( x'b0ccdd6e9ed398117e1d3cd94b89c2', 224 ) = 'f38dc0dc7f1f93e95030db63f1231df91de8aaef76a39b1c08a6490b' as NIST_SHA224_test_vector;
+SELECT SHA2( x'0b6ea2ddda429ccbb8f5de3332ac8a00', 224 ) = 'd9f4451ec9baba4c98a9c02b41442c58e1cc3eeb1bcb6d00a2b488c1' as NIST_SHA224_test_vector;
+SELECT SHA2( x'9ab41a3b8c6c886dc3a57fdfad67fc655f', 224 ) = '2b82967b0e46d8cdc7ecab68a69e177dc01f665dcecc8de824f1bc2b' as NIST_SHA224_test_vector;
+SELECT SHA2( x'785eabb7e7ca7c476cdd9b227f015d905368', 224 ) = '5617b3824c26b7a8ed43d636ce27a8f1e65b23e307e4d05422d94b56' as NIST_SHA224_test_vector;
+SELECT SHA2( x'395883570fbfdbf39659bc838fb802c5cc323d', 224 ) = '4169ffec25b0c49a22cc7912f830d443ca4d3b0377ea0d22ca17f4e4' as NIST_SHA224_test_vector;
+SELECT SHA2( x'6e5ecbbc6f36ec985c253f7e4bb6b1f8ab6c4942', 224 ) = 'db29fe2091df09f0fb0483a11e8134ecd480a3e4ca60dd12bab1543b' as NIST_SHA224_test_vector;
+SELECT SHA2( x'393d8ef3671232dc6efcb3d6426fc88f730e946b5d', 224 ) = '6d34ae1f00d1d63a39209d15acb2c2420ff0899e11c3e673cd51cd24' as NIST_SHA224_test_vector;
+SELECT SHA2( x'f222e611d99b3728b5e308f9b9b637b9d493528c2865', 224 ) = '93552ec989b20284010fb79cc7001ba7a59754f1485f3a3c1b361d70' as NIST_SHA224_test_vector;
+SELECT SHA2( x'16cd2320dd785b07b681c86ad39e56549ee4d71aa9e69e', 224 ) = 'b9920881629965613c70a9b0a65eb9cd9b08945135fd2113586ba38c' as NIST_SHA224_test_vector;
+SELECT SHA2( x'ceef92454528483f45a6992d179abff266145f2da2d10eb1', 224 ) = 'b7c5e536233ce1c24c2ef6f502246fcedb0d746cade7c849f17d32f1' as NIST_SHA224_test_vector;
+SELECT SHA2( x'c2770ed3d60c1e7aa1a794818c1fbb9ad5cc5ef7329a8802b8', 224 ) = 'ec36a23fc74263583f1ae65daa968636c15a02e7ff72b0762fb7779f' as NIST_SHA224_test_vector;
+SELECT SHA2( x'cbf96bd642247c2dd8cf7593f3d88cf61aba22c059604751e737', 224 ) = 'db2ae7e115b8b441de017133c775496efa4a0958d5a322bab780f50e' as NIST_SHA224_test_vector;
+SELECT SHA2( x'be0a3d0d539017795cc9b21a6a10cd3fdc575f9303bedb4e8464b2', 224 ) = 'c2684880b50e9e8b8adcf348b71ff4fdbde66fe0c6b6b7197f87002b' as NIST_SHA224_test_vector;
+SELECT SHA2( x'8530e9fdb69ed9bd05466ab4639e47affb7a05c2212fb38c85f9b2bc', 224 ) = 'fa6d9af7f6f5d0da8ea58a00c3c8714673e6112a6405887fd77e56e3' as NIST_SHA224_test_vector;
+SELECT SHA2( x'd564b9e358cbee4766391e8679cc41c7f1f64f3713765ea151860a40cb', 224 ) = '9b93bf21dd9b587b1e7dccf3cc5df4f193a744a1a082ebf8df65c577' as NIST_SHA224_test_vector;
+SELECT SHA2( x'12841b7f08bf555156c996ad24ff5c6df0b23c1f25721b63f08ca1954fd1', 224 ) = '98586368ba2d17eef435c6225f3337e4ba21a8657bf3a84ae75f38a3' as NIST_SHA224_test_vector;
+SELECT SHA2( x'c90824f4096dcbc0a6d70cc1937c1306f501c66c85484b133689ca0e19a474', 224 ) = '735ab14d634b95c24e353ccafd4ab40fa5718e18eeb568905e79cfee' as NIST_SHA224_test_vector;
+SELECT SHA2( x'd28f6765c7c1e5f05c9ebd6065b9020d255f9dce6d2b932504d586b64b4b7ffe', 224 ) = '2a97b7e1e67a3e22230e51bd6d44a203ca4d3406a11e16f949b0a6c8' as NIST_SHA224_test_vector;
+SELECT SHA2( x'7a4464bb000276dfc851d80f73dcd7775141e8c427c48e7f30457e99616f0247f1', 224 ) = 'cc70020d59321c4ab85d60278e94b224d4d5aaa8491ab6a4bbbb04ca' as NIST_SHA224_test_vector;
+SELECT SHA2( x'852368eb5a59e558acd85299955c47760a17ffcebf045d8b45782dd575faad861254', 224 ) = 'f6da08d8f011b7c7b6feaa0e49a864499dfa6bd1e2da81d8c195884e' as NIST_SHA224_test_vector;
+SELECT SHA2( x'c90e047cf70ea40566ebd269b0e0b2cbc63245b84a06eba13975278fcde2a312a28b74', 224 ) = 'ce4e5baa8acd7653a3a8e62f0464ca286b41935864378c7667db6afc' as NIST_SHA224_test_vector;
+SELECT SHA2( x'887fd70602e7599169d276dfd8bf44f93fae5188b52794f40f7da3ccb1542769a4618dce', 224 ) = 'be05c2526351af82cad735f69f46ed8b3202b5c170098c932a8e9d84' as NIST_SHA224_test_vector;
+SELECT SHA2( x'ec1cd5fa0dfbb142e3b222664e2dbbc209d09c00e6addeea5bfb327c3ec3c43ecddd66d1f1', 224 ) = '85956e2a952ecf3b845268708ded872e1b1366b84f87e4775e668b76' as NIST_SHA224_test_vector;
+SELECT SHA2( x'b67734b20bbaec455be457845bf058599c33bbeaf734be122fbdd011d23298826022398eaf1c', 224 ) = 'd5ed34af21626fe43634ba7df4f569d8186d43c061e63cdb038dbc36' as NIST_SHA224_test_vector;
+SELECT SHA2( x'e09e7100af3ead397f9f5812a74e19a6a7571c7fb1b8b8ac69164f13eaaf760909905620dd0852', 224 ) = '41bcff813625d927814a70e78b22597d2119174f08ef28a1d9d6e654' as NIST_SHA224_test_vector;
+SELECT SHA2( x'1d6613e39dde0059bc3bfd6da940cd9d740a2b8dc5f31907ceb775407ed5cd5df73874354317d559', 224 ) = '675468fc5f71d5e53b913350355990a19c3677b76e0daf1dbac0aa24' as NIST_SHA224_test_vector;
+SELECT SHA2( x'57271ff1795bf74ef6668da1fe8ab0ccfd5050547015eb0af8c449eaace56943b4d7bb18145990c6c5', 224 ) = '6e3d10fb8d3c815636455b08fb1a732fe6ed542ab2e8325c314b6e49' as NIST_SHA224_test_vector;
+SELECT SHA2( x'3f91d8bf80cb744fe79360f6ecd3f482b95dc8f2dece127e46b82fd76a007fafc484767c8701f0798d35', 224 ) = '34233d574c300c57f481f0568cc43f71c07d9f25c59ef49de74ad2db' as NIST_SHA224_test_vector;
+SELECT SHA2( x'2408966adf5d3fba570366393882c3d68b5140dd3749a310c75a6efa6d7d038047e90cb9e28a1a00fdaf8c', 224 ) = 'ff0c34018f6c80705cacb86180f887491cd98d4a573f33c87398bb7a' as NIST_SHA224_test_vector;
+SELECT SHA2( x'adf2e47a62db5003a2d2893c917686cb8dc41fbbc92cd02b37eaba43ac93ea6d3feedec1f20645c0947d0746', 224 ) = 'e91f826d6b7fee1cf731fd3a47d00b17edf669e1471644f0a3bf8365' as NIST_SHA224_test_vector;
+SELECT SHA2( x'a8f17ae01bd749341b1cea3f73ef22c3a84e4ac38276f497c79ed23f4ae4d4f82488910d4258e8f0206be789d3', 224 ) = '026f1a48b71cdddd0335fc736cc9f6877bd67dc31e43f87cc04efb32' as NIST_SHA224_test_vector;
+SELECT SHA2( x'eab69fea2590a847e6046aeb81e201cf1797b8636baf7d30f09893bb27a987ad276265327df62b9f37067e573cb0', 224 ) = '7b626a24d06c3f41d458edb360bef9456fda3e90d3fcc546ad2a79cd' as NIST_SHA224_test_vector;
+SELECT SHA2( x'de1c468c1f27fc265a9497eb8dba257c5dfb8ff708ec27309bb6803e65bd823aab7fbd439dbefec589e120fb4f9825', 224 ) = '02fb84e794a91206437848a4449a2389343f42cbd2877a42d270d51f' as NIST_SHA224_test_vector;
+SELECT SHA2( x'8a01037a92ff0ba48edd3707f2533723890ade105ef3256fdddd73a236471b38027226ab29bb544e03285d81bd417c27', 224 ) = '67ab2856e368a0bd0fea2042217b31c238fdb73ff8f4ed33090edeb8' as NIST_SHA224_test_vector;
+SELECT SHA2( x'c9cc53bf67d6bf14d67e2ddc8e6683ef574961ff698f61cdd11e9d9c167272e61df0844f4a7702d7e8392c53cbc9121e33', 224 ) = 'ec263fa2ddfe9c7c05c2a025271176f703d487ea6067e35372d8c75f' as NIST_SHA224_test_vector;
+SELECT SHA2( x'6380c0a6b3439be6ba13bc10db16c212d8569eeb4567a56d3c49e341538fb32bcbc18d8f0a001e354be89e4995bb5ea6e9bb', 224 ) = 'c577e8faf9233892919ac571c2248d94d47cb7451b847d6628dfa52b' as NIST_SHA224_test_vector;
+SELECT SHA2( x'85f318cdefb50f71afb880ee058ad2e0b4310223b511f3da2d1006b69df7eb75581bb7a83b3e36ba98b0822e73b9d428f13c9b', 224 ) = '41b8b1081eb8571a8dd2af57f28336a77a47d0bb4d5968ee65d96ba0' as NIST_SHA224_test_vector;
+SELECT SHA2( x'faa67b20b0b7f00960a5681df1d18eeb0265b50e19e8195cfd0f686060d6810bc1d07ba691bbe90b95585c158b7a2a55105c6e06', 224 ) = '58757f96ba28896e079fd76a578bb1b98ac3c178af2840b327a238ab' as NIST_SHA224_test_vector;
+SELECT SHA2( x'b1f83a5ea85d72c9721d166b1e9c51d6cb0dd6fe6b2ac88fc728d883c4eaadf3e475882d0fa42808941ceb746b833755bded1892a5', 224 ) = '0a53a62f28cc4db2025dd9175e571912c1a8bd0b293d235f7a0c568a' as NIST_SHA224_test_vector;
+SELECT SHA2( x'ce2b647be7bf54ea15fe79121bb04f0a04cbc49bbf89f7f70dbe40a79d6970c674895a6d9332926ed4df7445160a684b99fa652dabdd', 224 ) = '0dd413647bb39859aa84933a49af8fc9009690be7fbfb05f7f383015' as NIST_SHA224_test_vector;
+SELECT SHA2( x'80d1d261afc7a40e810609b92e3617f68a2770a77f705ec2bb562354a6ef8ac69787c25f47426c0b8603f35b2c8d1ccc53e8de4cc30773', 224 ) = '1d47aa5186c55bad63f8a13f0e4543a6ef86ce6a18faade4d4d65ef7' as NIST_SHA224_test_vector;
+SELECT SHA2( x'3b51a4dbd579846dcadae119be589a91a7dd84a727595f6b1a0709946bf1f2222bb6d041e48b946f2a809ce174052a232aac1500ff30bea1', 224 ) = 'd9c6c0f3b8102496d408388660765ba83b601ee3bffc2d3013f095d5' as NIST_SHA224_test_vector;
+SELECT SHA2( x'9c76043970f3e2e1f533f85d86b41d394d8570270afe3f500fae28e88f957e051993efb16021633d3d3f26d9f7ad4a62c15e477b842ae5dfdf', 224 ) = '94a7213f15373971b135b47986b3135df4dd45589ba91562313dd70d' as NIST_SHA224_test_vector;
+SELECT SHA2( x'738b98206d062d99a1d1d7b43f6bed03e01875006c322ffb3bc0d6577a4aa2f6d1eb11f242a7e78e55ff736c72c315008e28fd440a1a35add7d3', 224 ) = 'c40bbb13d17298721c32ed46254a0cba547c4c2086902fadf739802b' as NIST_SHA224_test_vector;
+SELECT SHA2( x'88ff5518acc6aa5484d8e68c5731a04e877c692f68924a6d4e3d6ed3ea411bddd69de71d6e0e28dde2d5ac0689baaa417851f95b547c80ee6431ee', 224 ) = '9716f750b69fbf537147d5ef468b807425127d6c1df07ab085eb3fa5' as NIST_SHA224_test_vector;
+SELECT SHA2( x'eaf46a39648bd2baf7d240eb37d812ff9b0f8a838b097f41ba7f5265b69724debe664607d3b4f1871100387640c43ac1a7fb9ccf20df376472f70dc6', 224 ) = 'd180561849855da0369998d10c0ba2775ecd3bc7392a8da1014116f3' as NIST_SHA224_test_vector;
+SELECT SHA2( x'ef15b0ac7f267e7d9f4fab40b52ee9321a877fcd72443eed39bab7329f2eaba59698c39e29a681e50f04771780dbb74b47988af619ee650c251e1868ec', 224 ) = 'e75969253ec7b8caba5bdb0b024948430a217b3076fa90d4c881a8fa' as NIST_SHA224_test_vector;
+SELECT SHA2( x'71482c3b0c0b65470314c4028b9343cd9092579a4d3623501941ec7184dccefaa294ad8aa7a26ec7b46f66fdf1571209dcad0976e10030e52a9d2db2b855', 224 ) = 'cee2546181cf14a689f5c66a6141f171a0d2fb116e880778c13ba220' as NIST_SHA224_test_vector;
+SELECT SHA2( x'de38350f3fe504643d318bd131e6fb14f24e0762eaf5995170b1c4f552e0fb49b0f180d111261e7eb0971bd2177b6944efa31ce617472145f3052c910727f2', 224 ) = '7741192f3dfc1a50166dc6e6f18f6e8580bf45f098fd0559139d8adf' as NIST_SHA224_test_vector;
+SELECT SHA2( x'81675f6f8ac523cabf94a8a43370a91d9717826e5026e6cdcd23d49217c0c797a95e2ee483d11b8c7a633fd2d21b16900e3f5fda0717cfde3cf4060e6971c282', 224 ) = '3c699b3b62e432e10a255fa7f6a6dbfc6d4b5813d6dcae32142e09fa' as NIST_SHA224_test_vector;
+SELECT SHA2( x'bd', 256 ) = '68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b' as NIST_SHA256_test_vector;
+SELECT SHA2( x'5fd4', 256 ) = '7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788' as NIST_SHA256_test_vector;
+SELECT SHA2( x'b0bd69', 256 ) = '4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803' as NIST_SHA256_test_vector;
+SELECT SHA2( x'c98c8e55', 256 ) = '7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504' as NIST_SHA256_test_vector;
+SELECT SHA2( x'81a723d966', 256 ) = '7516fb8bb11350df2bf386bc3c33bd0f52cb4c67c6e4745e0488e62c2aea2605' as NIST_SHA256_test_vector;
+SELECT SHA2( x'c97a2db566e5', 256 ) = '0eb0281b27a4604709b0513b43ad29fdcff9a7a958554abc689d7fe35af703e4' as NIST_SHA256_test_vector;
+SELECT SHA2( x'f53210aa6ed72e', 256 ) = 'dee684641421d1ba5a65c71f986a117cbb3d619a052a0b3409306c629575c00f' as NIST_SHA256_test_vector;
+SELECT SHA2( x'0df1cd526b5a4edd', 256 ) = '47f527210d6e8f940b5082fec01b7305908fa2b49ea3ae597c19a3986097153c' as NIST_SHA256_test_vector;
+SELECT SHA2( x'b80233e2c53ab32cc3', 256 ) = 'c60d239cc6da3ad31f4de0c2d58a73ccf3f9279e504fa60ad55a31dcf686f3ca' as NIST_SHA256_test_vector;
+SELECT SHA2( x'5d54ed5b52d879aeb5dd', 256 ) = 'e0164d90dbfcf173bb88044fac596ccd03b8d247c79907aaa5701767fad7b576' as NIST_SHA256_test_vector;
+SELECT SHA2( x'df866ecb67ab00515f6247', 256 ) = 'dc990ef3109a7bcf626199db9ab7801213ceb0ad2ee398963b5061e39c05c7b5' as NIST_SHA256_test_vector;
+SELECT SHA2( x'0757de9485a2eaea51126077', 256 ) = 'c1c9a4daadcc8678835872c7f1f8824376ac7b412e1fc2285069b41afd51397e' as NIST_SHA256_test_vector;
+SELECT SHA2( x'7c66f5d443c11cfb39dd0aa715', 256 ) = '6840619417b4d8ecaa7902f8eaf2e82be2638dec97cb7e8fcc377007cc176718' as NIST_SHA256_test_vector;
+SELECT SHA2( x'329624fed35639fe54957b7d47a9', 256 ) = '0f5308ff22b828e18bd65afbc427e3c1a678962832519df5f2f803f68f55e10b' as NIST_SHA256_test_vector;
+SELECT SHA2( x'c34e59652acc043873ecf6a4ab1060', 256 ) = '0fdf1604ac0d717ec9587b4de5444aaade807589d90eb326eaf6acb58a051e79' as NIST_SHA256_test_vector;
+SELECT SHA2( x'fdf4700984ee11b70af1880d0e0fefd4', 256 ) = 'b01ae16eed3b4a770f127b98469ba26fe3d8e9f59d8a2983214afe6cff0e6b6c' as NIST_SHA256_test_vector;
+SELECT SHA2( x'ea40aadbefedb0e0d78d067c6cd65c2c87', 256 ) = '36157bbe61931d58a3a644953eaf131bbc2591c673a1f20353f51ca5054fc1c2' as NIST_SHA256_test_vector;
+SELECT SHA2( x'6d1092004670efab3af483d265d8e7b3da73', 256 ) = '67fbf35d360d72b101410794ccf197106c0e784afa9c80206a550b600dbf1f16' as NIST_SHA256_test_vector;
+SELECT SHA2( x'55a10148ae7b09ac4e71df438135bc70e873eb', 256 ) = 'cbe7965513af46dfd596dc5839cb82a5c6c7328034b1dd0042a9f4b71fb14430' as NIST_SHA256_test_vector;
+SELECT SHA2( x'a03f8fcd777bd933b4b0af8c5ce3d61308565649', 256 ) = 'ddfce4e8c7b38845e2a81b7fc27a06366467a9e111316014013f9701e2413ce0' as NIST_SHA256_test_vector;
+SELECT SHA2( x'8e5d6cba8d4b206381e33ca7339bec504f3d6119ba', 256 ) = '92f678a3e59d0dd3610eec3222b8c6ebd28eead530723fbd226747534da22b6c' as NIST_SHA256_test_vector;
+SELECT SHA2( x'96db1b62eed85f2628d0c25da534401fe80d13d09beb', 256 ) = '725bab4457c789d6a4cc4736b9c2c662cda18407150844d74d6aa4efd72dbb05' as NIST_SHA256_test_vector;
+SELECT SHA2( x'1c482a45dfbcda549729126b533477edfaf7476fde498f', 256 ) = '6523f24f225b996aad1a8b317e6e0f8e97673dcff3fd62a27ff9f3888ea1302d' as NIST_SHA256_test_vector;
+SELECT SHA2( x'0f677d8e4c6d6a057492670d99adb870adf68a36ead37919', 256 ) = '44acbbc6b48bf37ee088b9c8546fc46e5a5f0d637b5e444f628de186144087fd' as NIST_SHA256_test_vector;
+SELECT SHA2( x'c09056d597816542bffe4bb33e475dfb2d6293016906ddc18c', 256 ) = 'f4baeaef70588a0820d63c2401dd84f98adf7366782d196f8698d7dfd3db1c29' as NIST_SHA256_test_vector;
+SELECT SHA2( x'72f313fdcf52d0749c9937cc2e53f50b44d65a544876bab7d2f8', 256 ) = 'cfa67aa52fd675fca985f69f9ca58af62baead8c39723bb6bfbae8a5d4bb9beb' as NIST_SHA256_test_vector;
+SELECT SHA2( x'09f6fe6cbe6744149f792a4a827e4e8909627abf75301bf7bbd7f5', 256 ) = '657633891dc6274d6aeda78e7313dfb960eac9a24d29293a057b9746a18de4ec' as NIST_SHA256_test_vector;
+SELECT SHA2( x'9e1cfeb335bc331744247df4bbd56876a7f69298aaf6b9e7a8731889', 256 ) = '930058dd21cb48b2cf90eaca55322ddf48582687838a584928440504a2fde578' as NIST_SHA256_test_vector;
+SELECT SHA2( x'b8913001efb1b7f4bd975e349c5b2cbe66045bf0d2fb019b3bc0f059a4', 256 ) = 'a0eb0b7fad1d1b6de4f9096724a621720538a9c3f2f6d11134d68cb9ee52fc88' as NIST_SHA256_test_vector;
+SELECT SHA2( x'8f08537d50928c911a68b071d65b9e8f038264d3b62c5f33de18a484cde9', 256 ) = '10aad5cd4484387373577a881974f1a550782108bc88b4e2e8085e9c3e938bbb' as NIST_SHA256_test_vector;
+SELECT SHA2( x'fd846162c4da936d004ffe0cbe844d940f1c2953157cf4765dceba2a6f4c64', 256 ) = 'c13ba769aea0e478816f2f608b5cec3fe14672ea033088a8641cfe69b4ff57cb' as NIST_SHA256_test_vector;
+SELECT SHA2( x'8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb', 256 ) = '56059e8cb3c2978b198208bf5ca1e1ea5659b737a506324b7cec75b5ebaf057d' as NIST_SHA256_test_vector;
+SELECT SHA2( x'1bbc2b15253c126e301f9f64b97be4ce13e96337687e2e78fbfd4c8daf4a5fa1cd', 256 ) = 'd973b5dcdae4cf2599f4db4068e4aa354f22d8901adc463ca3938c465578147b' as NIST_SHA256_test_vector;
+SELECT SHA2( x'c1bdb3bfc65dfe9a393331266c58d05fb9c8b7476bb717dadc29bc43dabd91504fc9', 256 ) = '57844e1d762e6b7bb86dbfcc5c5a59578d39cc665d1ddbe4de03a61778061af1' as NIST_SHA256_test_vector;
+SELECT SHA2( x'26eb621a45bd9c9c764ccbb672b99f2a8379c7bbf4fb07eec58a8b0ea4747b72196ccf', 256 ) = '73dc27bd45daccd0f811381230cf7f2a1d3ed1202e9a770af733146b1e166315' as NIST_SHA256_test_vector;
+SELECT SHA2( x'7e3e3986109162e0c56357048bbd86ff49b93644b7fb064e7280968650978466f02c9adf', 256 ) = '682c474799f5103252c3e2efef7f747783e514b54e93b8303b0e07ee4218f78e' as NIST_SHA256_test_vector;
+SELECT SHA2( x'763c1a9ea50bd72bfc516989ddf3eff2f208f64fccea3cf0ca8dba7f3d10e237c99226510f', 256 ) = '54d6cb2b09825eab064c8952113b9897a3344737cd186a8e6be0a0b258da3e57' as NIST_SHA256_test_vector;
+SELECT SHA2( x'e1a7ffea8417e7cd49b96e355fd44f3f7a150fab6dd8343dfba3b262eaf3a6175a3c4607552b', 256 ) = '83baa80caade404c446833ecef2e595bba6dce2cb7f7422fad2972a9fe327aca' as NIST_SHA256_test_vector;
+SELECT SHA2( x'692a18effad8317a11a5cddb917f7389e1be6dba34572a300e52e056047e758bc363a0be53784c', 256 ) = '0c0c6a6b27a6d7a7a5130d70db3b8bc1bd8001d103efe72f45b082cadbd03742' as NIST_SHA256_test_vector;
+SELECT SHA2( x'73fda1e1cb7dc9a9ece858d040d7105cc126eab153fb0bb55703f4317dfff97bd980f4523aee3a09', 256 ) = '9878f8804e00828b39261843f2b3eda19a7e9b9ff4cc2e23f7ea1f62f4491ff2' as NIST_SHA256_test_vector;
+SELECT SHA2( x'2321d88c19e3e6a8309a09a5428c01991e16446823f13b2f0db4ade30e9a7c3521868fb99b440f4802', 256 ) = 'f1bd3a8a74c8f0093038499ef63794d86fc6d82602a802a435718e61e7b396cc' as NIST_SHA256_test_vector;
+SELECT SHA2( x'b9eaebda29172b052bcc1e3a9c7f2eced43c084a86f89f61e7237425137c167aac29e4cac4071afafd3f', 256 ) = 'ea43ec91285145d8f29915b227a0e35c89f90d968f9a14332dad275cfd52d619' as NIST_SHA256_test_vector;
+SELECT SHA2( x'332daf07d3a6775b18572549a6e12b8a27d81b7c4abcc5bd0b2b9ff936546b0026af131cd3ecd8a10c29ab', 256 ) = 'a573959ba6b1c3bebfd6288c806b72a65650d23bd46d123816a2a6a0e47d1e66' as NIST_SHA256_test_vector;
+SELECT SHA2( x'30ac7eace1f2e41034c25a3d3e2db979c23dfaa7a4914b0da147625b3e1f12e9fedc1c41d8ee47dde84fb332', 256 ) = 'c0c3f40d34e711bfadf517b3a78140e379fba5f7edf2c1bc3ce82469dae4d2d5' as NIST_SHA256_test_vector;
+SELECT SHA2( x'02c3964c4ad9c4af97d373099302c2cd770ad06c7d8bd11c970161d861e917a854265e223da28031ee38041534', 256 ) = 'c13c622bf08a3d3cf1fd6fa5e26e505e551b1643bc5a0f59ed29541235218f77' as NIST_SHA256_test_vector;
+SELECT SHA2( x'b9eed82edcf0c7ba69f6f6ac5722cb61daecaf30437511582117ad36ad410ebc6582511ef6e32dce5f7a30ab543c', 256 ) = '6ac64caaeda4763d28a44b363823a6b819285410fb4162af6ca657396f6028d0' as NIST_SHA256_test_vector;
+SELECT SHA2( x'b574865024828bf651df070ac0cec1849aa6470901d2e30fa01dcb43862d9827344cf900f46fa9ef6d709e5e759f84', 256 ) = '4c839e8f8f373c25a9a3351257c6152258ff8e6a88dad42f30f2bbecab56c20b' as NIST_SHA256_test_vector;
+SELECT SHA2( x'eebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a', 256 ) = 'c117b9dce689c399ec99008788cd5d24d8396fab7d96315c4f3fe6d56da63bb3' as NIST_SHA256_test_vector;
+SELECT SHA2( x'1b7a73770d168da45bf2e512eee45153e02f4dfe3b42e50304a3d63d7826f0469562be8fdc6569b056a7dafcd53d1f597c', 256 ) = '0b42cfc3dd3d3198f06c30e087837ec6a6dd35d08e54e886c682709f8f42457a' as NIST_SHA256_test_vector;
+SELECT SHA2( x'0072ae2f3bda67736b9c66e2130260b3a4847bc3968e037cb6835efcc2014273336725cd5a94f592aef20a0a65b459a4415b', 256 ) = '217cf25b8b343c28336b1c1e9bed29e0c96045bc93daf426e490b608b0905c90' as NIST_SHA256_test_vector;
+SELECT SHA2( x'2ac748680f3bc1bf098c4be38c7194643b0d009e51c43630404cdfaf9807aa9b299094916c9466c31fe37fa630c6d3eadc9434', 256 ) = '3ea59e2e79513679a22e962f22408306f7e8f6e562c2f1f210e279fad8eaacc6' as NIST_SHA256_test_vector;
+SELECT SHA2( x'893d1a8863d234ee50e5a8c7650a4de047230ad03d268dde8921401ff97b79dfb97cf2426b0f782b79c7e75daa2155e1f4098ea7', 256 ) = 'f7808e03e5d5af43c2bffb66e35d1ecbd79f4d8fec44f821f73a235d17c70a89' as NIST_SHA256_test_vector;
+SELECT SHA2( x'cf673b96eaf241cfa3e262dc6fe65f08bcc2be56d8a2c9710eaddae212ded6859f0ff83e5e57d0e80a968b8ed24e74defeb5bbdad6', 256 ) = '9bdb7cf0492ace4620a47660acd127f951767b0738b5504451d6ed56e4fa3cbd' as NIST_SHA256_test_vector;
+SELECT SHA2( x'0d545be1f47b966214691c21278704e89a17d52dd96aeeeacc5325a9a1ddafdecd39407a4dfa72bd32856b4c5cc2ba838618830c8399', 256 ) = 'ad53e0db7e63211c8b00947908ce29660c4376e244e19cd30a659af65dc6f1fe' as NIST_SHA256_test_vector;
+SELECT SHA2( x'9eabfcd3603337df3dcd119d6287a9bc8bb94d650ef29bcf1b32e60d425adc2a35e06577d0c7ce2456cf260efee9e8d8aeeddb3d068f37', 256 ) = '83eeed2dfeb8d2604ab5ec1ac9b5dcab8cc2222518468bc5c24c16ce72e70687' as NIST_SHA256_test_vector;
+SELECT SHA2( x'2fc7b9e8b8dcaac64ecef4c5f91877543ac36ae494d9faf84b1d347b6cf925570db84043d6f500dcc153cef81d6f2437d913f3dbffad42d9', 256 ) = '6ef7e9f12267ebc4901267da147effdcdebcd6ec5393c7f62ec4c4f06ca72649' as NIST_SHA256_test_vector;
+SELECT SHA2( x'cf95929ab732f9ef5e8c3e6b4ed753852ee74e4fddf31b56c29a6ec95d23fcde2209eb7288b787f05d9036735c32ae2f01fc650d9cce4995a5', 256 ) = '3e5854169da065407fa465a4694f3fcb1d141480a8f84c970a0f63364ec8f590' as NIST_SHA256_test_vector;
+SELECT SHA2( x'826378013988684c40f4d917c7ed8b72aba66fd68f085d0b2eb20948ef3f349dbbc71f8e0ba845014586495a48902ee44505c673d2f76d473950', 256 ) = '5b506b823ef6658939aca22f52bbe5a4b849c31b8fa1d09139352e501137bc04' as NIST_SHA256_test_vector;
+SELECT SHA2( x'0cab6d38ce9849fcbd589f7235a6d2c2cb933e26e1ca6f4e78189104452c280c069b024e162769373f409d5cd0cb8160f0239418325d23ee6ad1bd', 256 ) = '92943076cda4c46718e55df64d7580e12b8fb2c2911e87851246ccf6791fa3e6' as NIST_SHA256_test_vector;
+SELECT SHA2( x'3fb4a8c5b57c14731179256608614c95c9725ddad5fbfa99111d4fa319d3015ad830601556e8e4c6d012d7da0e2c4f60f1605f6e4c058ec0f46988a3', 256 ) = '8e90da3eb146935264576f874fcc5a64b7a90ab6c8a36c15d855b0179f52f899' as NIST_SHA256_test_vector;
+SELECT SHA2( x'9050a6d002c90f6036c592b0f6b866713e7894d29645f4a19e0858b3ebd8078711c26d2601ca104d962dc6ce6ae92634ee7f3ca6baf8810e2126097a09', 256 ) = '03c516677735ae83dbe5a7e4c22c1ac1bfedcd46e7dd785f8bfe38e148eda632' as NIST_SHA256_test_vector;
+SELECT SHA2( x'd659ec136bacfa0b5c906aabedc93c01c5f1efa3f370a1432ea8778461703f0c67c454da12bac2da73b8abb755e5eaf10bddf52f6ca908d61bee80da0c64', 256 ) = 'fff2852957a0eeb577e73fd7d827f650261dfb9a8a65f52df4bbbc9b2d0ae50e' as NIST_SHA256_test_vector;
+SELECT SHA2( x'b498555658332b197bc5cb7adc5c1997aabbdcf1f7ffcc2b6b82eb0f350019d247f8e399c3559d3bb04eb049f28b344c7989c24db83f839b59028dc82fa670', 256 ) = 'bfbbf242f79bff4ae0aafb4ccf69b24fdca4342d83db1dfd1822c74a9e218e8d' as NIST_SHA256_test_vector;
+SELECT SHA2( x'3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad', 256 ) = '105a60865830ac3a371d3843324d4bb5fa8ec0e02ddaa389ad8da4f10215c454' as NIST_SHA256_test_vector;
+SELECT SHA2( x'ab', 384 ) = 'fb94d5be118865f6fcbc978b825da82cff188faec2f66cb84b2537d74b4938469854b0ca89e66fa2e182834736629f3d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'7c27', 384 ) = '3d80be467df86d63abb9ea1d3f9cb39cd19890e7f2c53a6200bedc5006842b35e820dc4e0ca90ca9b97ab23ef07080fc' as NIST_SHA384_test_vector;
+SELECT SHA2( x'31f5ca', 384 ) = '78d54b943421fdf7ba90a7fb9637c2073aa480454bd841d39ff72f4511fc21fb67797b652c0c823229342873d3bef955' as NIST_SHA384_test_vector;
+SELECT SHA2( x'7bdee3f8', 384 ) = '8bdafba0777ee446c3431c2d7b1fbb631089f71d2ca417abc1d230e1aba64ec2f1c187474a6f4077d372c14ad407f99a' as NIST_SHA384_test_vector;
+SELECT SHA2( x'8f05604915', 384 ) = '504e414bf1db1060f14c8c799e25b1e0c4dcf1504ebbd129998f0ae283e6de86e0d3c7e879c73ec3b1836c3ee89c2649' as NIST_SHA384_test_vector;
+SELECT SHA2( x'665da6eda214', 384 ) = '4c022f112010908848312f8b8f1072625fd5c105399d562ea1d56130619a7eac8dfc3748fd05ee37e4b690be9daa9980' as NIST_SHA384_test_vector;
+SELECT SHA2( x'333b2459200d2b', 384 ) = '5dc6eb1bf26c54f2e0409f5a31aa97c37c8e168d0226e7d2764a11aff3fb76d15e9348520386d730e1998e530c59b56c' as NIST_SHA384_test_vector;
+SELECT SHA2( x'ad46049e0230c70e', 384 ) = 'c0bc9050670743f554a639e21a5870c864ef56ca831fceb7295b4c3050c3c20876839cfb0d1bcc11c9d64304ed008517' as NIST_SHA384_test_vector;
+SELECT SHA2( x'ffa6f17b0798388a71', 384 ) = '026c58cab40b45e5909bde1af1bc1ab2669af98a9e3eff10d1ba68f5e3f2adf47038c03b3cc0e07d5353b6ed4d0027e6' as NIST_SHA384_test_vector;
+SELECT SHA2( x'7eb8d60bf02398ffa689', 384 ) = '683c413c0bb9ecf3a0da7a88c314e85d4658ea4c7ea21b48ea5adafe66746a97e9fe40d7a3b4f1c3fd4a1fab75dcf422' as NIST_SHA384_test_vector;
+SELECT SHA2( x'c0cf1a3f73dfae7c114118', 384 ) = 'be9839e9ac6ac7a06dbc494823e52b43427b649d6c00d7be2a4ee1c99e75096a82aa9546f804f4c5e2d62afe3b269b06' as NIST_SHA384_test_vector;
+SELECT SHA2( x'ad5f06ce6e1632966e4a3bcb', 384 ) = '33e29cf43f8cf3c3680710b342126a020e72398ad4be6bae86511a7771d563bf6e76867eb8890d31fea793adb2843481' as NIST_SHA384_test_vector;
+SELECT SHA2( x'cb3d16ad70bf80e5a9b1113cc7', 384 ) = '64ea8d5538a7ad26c87ac68f5e30c454d150cd3311066124dfc11fd58a56b1d42339f410a09fe7478ffad037f412f992' as NIST_SHA384_test_vector;
+SELECT SHA2( x'842562ff1d0fc2c173825395a03a', 384 ) = '638c3239fa399faa786a12eae1acda4744cd8d65b7be4532d40de84a994096e929ac6d385d84183637cadfedf2941e86' as NIST_SHA384_test_vector;
+SELECT SHA2( x'cc95dd4d94b075071b31eeecbe9421', 384 ) = 'ebefdbf6230a671d7b1e31b26fd386f792074f8a897e395c5cf327b5cf9019220e661ed1edd1eb35ca5dd8fb4ba90389' as NIST_SHA384_test_vector;
+SELECT SHA2( x'daf8002b9394138220770bf3026ba123', 384 ) = 'ada9fb71becbea38bd3378b87d8b67906298d8a57b9c371462e88fce6528d30756dce80691c484f0ed787d4165d09aa0' as NIST_SHA384_test_vector;
+SELECT SHA2( x'7464d6ecd83a91466fcb1b2c671fae075c', 384 ) = '1cfc153ff54c2eb7825a8772da16b2a39f817fe2e27ec73f7393b3999102d02b480d25b22112aed7f44207d81ead5e2e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'5520843bdf4af949ae3764b5a9c57c64f513', 384 ) = '8bbf382a606b530cae88e084c944cd32e1690139698e8c92edca1d330cc6675ecdc31c49101467737b0fca2ca71e83e9' as NIST_SHA384_test_vector;
+SELECT SHA2( x'b2a41b40e3b53d1dc5e37570193f9f76bb80a8', 384 ) = '78df76c6bf5f95fdce5e015eaa37a7e0782b42185c9c989903c26fd43015dd93d949c9ef1a21c858901a60633e840ce8' as NIST_SHA384_test_vector;
+SELECT SHA2( x'aa986e747d04b932ab8266f259f1ee18e87fd7e6', 384 ) = '81f50207238b98d4eac5907d3c61a982f0cd155a15a100659ea3cdd88cd705e282227161359cfed12ed384a82cf96bc0' as NIST_SHA384_test_vector;
+SELECT SHA2( x'948b333f042cc18a82cec0177f33c3bdbf185b5803', 384 ) = '5ca83aec2a89bb12ba15cd5c28bc685998f6e62de2ea2706144aa4e073b6b97be7750d0fb86e4a32499920d721a8e59b' as NIST_SHA384_test_vector;
+SELECT SHA2( x'57271feb9fadb6ef7c9c988258889583a7e2ed86bf7a', 384 ) = '8308f23dbd930f511998ec5cc95428870abb156729a166902b268bd6992ba335d81d9881035d4ec3509fea18015a4c4e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'b1e6d9be83ca63c0dfd043898cf49690b30aeff093a6a7', 384 ) = '3a94cc56c3c7cc17d54a836b2920edacb0e27a93d63cc152da25010cfab7776bfbb2505af2a0528a1f0198a6375dbcd2' as NIST_SHA384_test_vector;
+SELECT SHA2( x'c030bb7a49275a4c0a80bc24c6c1d86f4467ca2aa1e6c900', 384 ) = 'ee66585df3f2e40a86d29f15a0f6e7674bf258d0c8dbf78698401fdf0f8b94fe45de202748024d244eb2b8d6e4bb6371' as NIST_SHA384_test_vector;
+SELECT SHA2( x'aead39a90fed8eaa4bbbe3b2641ef21f8e89321e94af581e78', 384 ) = '55836ec67d5b81f77b38300b7d13db81bcac7fa6b1d8839f65806965978f4fab0db69e50b74d3d1698ab9e10131fe28d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'2b9e8d1adc0c06a4961299400245d54fd2258b6cff50314455f5', 384 ) = 'b858bf457211e1e10ceff855552eb4ce5067a7664d7008df210cb63502d04f5a03250b64acbdba78f2c30f4820204bb1' as NIST_SHA384_test_vector;
+SELECT SHA2( x'8e4a0b1b68b8115aee9569c4a1f33109373b790be267a8a8d5721a', 384 ) = '8e97304e6222cc6a93fedb2d526aea034c3d706ff59c1bac6b9c88c3afd15d2328c1615e94c43262d338ec89a545b855' as NIST_SHA384_test_vector;
+SELECT SHA2( x'300d1802549eaea76f75f4ad10b123bc55ca60afbc17353b369342d1', 384 ) = 'b9c1ea27080cffb70a36b07a44cefad77917d3e7c2429cc196175b21018c99d94e1bb125cb180d45b3241dc210536abc' as NIST_SHA384_test_vector;
+SELECT SHA2( x'fd628596a69e7038d31e1cf2acba11fb20f7cf9ed72b658668e23f38cd', 384 ) = '8bbb105eb0be34dfcb9b3dae06f77a3e21cce06f701339cbc3844237383295270af51ca28dc893108de65b163a75cc20' as NIST_SHA384_test_vector;
+SELECT SHA2( x'6d8393d6679e69244db604ea71226fdb4ad3e70e223832020f6032de245f', 384 ) = '4f200337cfa5b77032a7e5e0fa6dbd35a85e4cdba9e2d61d69f3d82dbc4d64e4ff2d029dc52cd2cff90270a0a5a016e8' as NIST_SHA384_test_vector;
+SELECT SHA2( x'922110e043965d39c2c124499d47877f1e9e33a27b72365b4d4812f443620f', 384 ) = '2ec96054f9d4b87ffb2b447eff8aa44d40200a099c8f6698ae7c86889d3b2beb7ba60634525c4cd3f4635191c822811a' as NIST_SHA384_test_vector;
+SELECT SHA2( x'b8211b7aa8ae99d26e35c06ea4b226e0a6e52172a40e7f0df5f67759ae2ee026', 384 ) = '093945494108573fbff96c4ea888181f798a022ee5e89137b688a15c5ac85c4da72b8c44558e62323b4de180962aea53' as NIST_SHA384_test_vector;
+SELECT SHA2( x'6966ef05235dddff26bec1853eb36840434604a79cd4d11702bff9258664b633d6', 384 ) = '8de0abf7a039124ebaf3570db07f3e7547633a5ac56f8c86f8bdcea7296033d7e19c329c381afc050002b7a7b219234c' as NIST_SHA384_test_vector;
+SELECT SHA2( x'11e8a909b7335c7713671d545943c7e24ec07a8d453935284dcfa67aa90c40f980c7', 384 ) = '4c07b1ac241d727cb0face5e306cbf5672f560acd8e26c7d6cf52782cafb5341733f167237ec56a8e245761c99508844' as NIST_SHA384_test_vector;
+SELECT SHA2( x'508d360e41e4f2d5356d6d63d1069d21ebfb2e60a0cd2e3fa0320acecd5cb973057e37', 384 ) = '5933be6cb65ba0c9aa50377f93f5b4311961739ba8de3407284974e8a659b900289da049161036278c77dc3e4f16f232' as NIST_SHA384_test_vector;
+SELECT SHA2( x'a382f5d82a34420b8779a3980ea138f4ea7aa5fe1074ae40760305727f455f40bae5cd4e', 384 ) = '381728f154103fc0de79131de07de5b81ab8e51a9b470e0dbf860f0f7cb6d8418cc604d00895634b2becea268c6e230a' as NIST_SHA384_test_vector;
+SELECT SHA2( x'63fe4a7f46ad6ebbd8644a6750c601ed00357c5f3ff602bba68f086e7f744a167ae31a8ca2', 384 ) = '1a9bf6ca1f0f435da889c59bec482755926e80b06bd46f80bbda9bf4a30a1630db22837380522146a36e5fb954a7779e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'94d972dab4e15e51e8bf91890d2ef1a155e26ea03eb48fb7c5ff51c6d64a322208278996875a', 384 ) = '4926848163c834639686244f89c64bc90ebb2c57456a2c56705a7039dc1389fe81bfc3e4d4ac526173a53a2064604a3e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'0c555adb19cd55039a9e27028184e89f44a8725f28cfc457bfd2a43eaf4e89c6b69cb72ceb04ac', 384 ) = 'b00119ff6f8d405608c74185121c05f76f2268a3726bfe3ffadf7b338b1df0e0557080ae533c56a31b8959037a88d69e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'567c3828db664ac1e31624b8b5c7e344f39eebcbc43a2b0e318ca2a2d0e9219fa05d539c3543fcda', 384 ) = '636a24bf0d53cb13c27441633781005baec355c2ebd231e393df934275c404150b46d39f100b245064dd2d9f4e19f453' as NIST_SHA384_test_vector;
+SELECT SHA2( x'32a59e2acdff4c2aee788ab4c7cc36fd477ade2a906dd512acdc86467b6f094ff0a3f4367d6f744acc', 384 ) = '0749c3b9c115b3e29731947878fab9c9cff2286e3f9a24d62240278514c41bef220bbde040f23db4692f915ef40cc92e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'cfc3ef84e70f9247d9c123de7be8c6e9ba4c7395dfa5556f110a707a1bac877e70c43da46cca7a40dde8', 384 ) = '2b3a9ee9aa7fdaa27d23fdecdf0a7da71d2e9b8e9948c5912f5d2d02a42f22d4e29c179b1c38a1e463569cdc9c2063cb' as NIST_SHA384_test_vector;
+SELECT SHA2( x'eaa144363d47bcd68c0c950be45ce1b87043c87140256fd449af1f1cad0da3f33d5df1883c640de266802b', 384 ) = '5263e9f3e8a1bb5634050ca89916a961a0ced1a92950ec20aef411e431d16cf9f77ef414b75ad922d9308f9dfe571e75' as NIST_SHA384_test_vector;
+SELECT SHA2( x'c63da62dc71e97de646f695b5a8c58fa6fae08e5fb622529a83a460976c2189802b5b8870771603b25a94622', 384 ) = 'f63558786f3f06cc84884f14a93a9ef96b1174af8e15296380f7057320bf21e2b5c0684b00a00d895267c3e1404142ff' as NIST_SHA384_test_vector;
+SELECT SHA2( x'5225b6563257ef806fb0eea5df034cc319db7a5b295f1075887861e64b3653ce9a706e6464ab32f6513dae2bf8', 384 ) = '5be5579e0bc2404523392f95cac2e3e9e59d398b11143e481594edc57cd04247355bee2fa80d0ef2e5dfc0f6f45c4fb4' as NIST_SHA384_test_vector;
+SELECT SHA2( x'c0b22bc12ecee79ea76f1907a8f435f657b7bb375c92ae11f2a248283e4aeca2df7b5c89c6332c704844775a7157', 384 ) = '1ea1bffd5aee1377de1af01d7c895ef5ebe1c1d72b532b43d5e264c158637414ad1416f21e9a32b194415d6e3e982906' as NIST_SHA384_test_vector;
+SELECT SHA2( x'0dd0f1807170ea493604c82293732648a106786e1a1df10d6021a4fcc1b9e940f9410225f878fe8ee678de8965ecf7', 384 ) = '2482561cd0e3468a5d8c75c3a1261cb36257536cb165c0f29f817d80833b6a002eee5dc778a953124d79d4d4835b12c4' as NIST_SHA384_test_vector;
+SELECT SHA2( x'78334108ce6261ddee5d98045bb307a6e8f3d0ee65c1d9bc7d28cd9edf3264fc9cb6e592d072e9238559616cd42eda58', 384 ) = '87feb45250c1e5b4cf701f86fb24d6a49b2c0d2de92db884e2fcdf5e323c0539c78e5a99fdaf56896eed27b897095741' as NIST_SHA384_test_vector;
+SELECT SHA2( x'e9d96ef05a41486b10ea2e5a9c7059e227ac4d4b61db664cbbfdb488d67c09583b0e4fcb4cdc1feb7be49042b99c4d9d31', 384 ) = 'c0d72a3a4cbee53ce48df9574b65dd0791b15b03202f7c13ada8cde3a4e8c220d9f3d00a3e37b31f44cf6fb5c7134e18' as NIST_SHA384_test_vector;
+SELECT SHA2( x'90413184900f9c0de1a1983e1eb348bd2c2654aa7b3e4474880d2df2a72f90afffb87f85d66b016d0f2db895f0b9c1b32994', 384 ) = '5c06fbe39a401c80f0463a485d6a32250218db63fb8ad77d1cfce824849d0a61b4acd5a36fa14b22a62beb758b780e6a' as NIST_SHA384_test_vector;
+SELECT SHA2( x'630fb204cedd5efd2a3c272e318e3b1b3277f8bb12d90b139203d90acf251e780f07d380bafb5620a711c5069989aaa50a8ede', 384 ) = '73e862668fab744ef2768a9bd2fc382532b99c03c4cdbd88eea4a224c56c187d48f8f9985b73d283ce03d71d49dd1c41' as NIST_SHA384_test_vector;
+SELECT SHA2( x'0f372d71e1c9941d7872956309db44db57108d8be1e0106859862f1a5989640052e0d874c55a3250b53dadb05c2d6efa1d50141c', 384 ) = '13712a36f85a7ff0b98838d674b058bafd11c8a3a9c5ce505bbab1eef6bd640644f94e47a73fd7cfda5a1ff30d830b2c' as NIST_SHA384_test_vector;
+SELECT SHA2( x'50dd69e3080e0d8a9713202b68c4e87fa2b57bdb940a39a8568c9a13adfc2a0530a7d156a93a583ebed8290cd16a561a2436dd0041', 384 ) = 'd22632b3ed8e83b528e40beb2ae4e01bdcff0e62cd0d48a35f92cd2d286ce5d72a597e0ff2cafbe9ea7eaef32ce5343d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'ef4501c9eaca54649b6e7dea45005ec7716d7c787b37a79e5122de5178316db650d058d49853fca3349ff4662e273a3bfc1b8ef101db', 384 ) = 'a7574f6b0f1872483ee52be517172dd2193e67cf5b3994947dcbc2866274868c70391dadd8d81de7573ba658e2615871' as NIST_SHA384_test_vector;
+SELECT SHA2( x'9fa31c5626eee059714e363391284189666594b7ab694f6732498b637138f9a73e43c5bbd73fc13f25ffbfc742ca3eea380b4a960c4b9d', 384 ) = '055c9415e4a5c921eb9721cb32a5c0b47fb57b1af4884332557946717942615ca6251694381537f2a7edc490dfaa82f9' as NIST_SHA384_test_vector;
+SELECT SHA2( x'e2b76d556ee3b9475a1c54e18ebb0854c7971f543d1a25c9839bf0c7aee7dec0b9215ef828cdb23aec27f3ca87b9559a702cacc0b95f2f28', 384 ) = '6cae189d9765f9a56c825f5e24f5f5c9f60d80f57a35f788ea548e7755844e2592db2c7244a26d7c37ba9a3e5f744a3d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'd189c6cfa4c14712cfae7fae68d66907595151886e88888bac3d5c79e5cc473289b067afbf482ee6b4db5bed33db29637766c60c3d1206bb1d', 384 ) = 'fc72b66aaead15676fea59cbbc20d39c929c8590a50a0a05d146c41fd92272da3a56f58f6cc93149fd65e91b3f1655a2' as NIST_SHA384_test_vector;
+SELECT SHA2( x'31981d12960c16661b3f7c7952871a7b00a975677da7557d5ed980f3523fc9e84a164999dda9edd7ea6a31b97f412a8ef924ca156de860f14757', 384 ) = 'a470316104c9828cd96f2b76886a37d01ae5c5a0e537097c4e397dda1c49c59a78d33f4c4d5dd634b7956920760eb0bf' as NIST_SHA384_test_vector;
+SELECT SHA2( x'44eb420655c5cb6e54645bb6d41dc4f8d5ffafcaeb61e06d9cbebb4709c30793d1a5f35832b85697713e3bc97c7c9d89cf146f8d948ee0da0e38dc', 384 ) = 'b0b028aca4364c92427c4d8edaa5f6dbe2b30e626433d20ce27e5bb74b17dc59f3e9e23e08ce9d49882cc26118e8fae1' as NIST_SHA384_test_vector;
+SELECT SHA2( x'0871e0c4f2885572f7847cec0629592df48515d2c3225be3248001f13ac2eb61a1a82c07afbd6ff7fad296971aaaa0f9b0f7d068a7850b41b9b68305', 384 ) = '503fb0ecc8b6bfbeff397b9fc02598651ebec429acd50e3add6a9752f576e24c5d933573ebcc23cdf06f807000370825' as NIST_SHA384_test_vector;
+SELECT SHA2( x'32a5984a4510ac51a9b876ef1eaed25e82a9adab45a817721dd99ae9fbbaca1f3d7e1e8625b2feb08a201d56cdf4099e0f1d019da1f6061bbc26349773', 384 ) = '0ba492631a4261465c137033eb1492ff8cdb0e06f8494e2c52fcf029b157f2127e0f4f75b5d3a10209ba70bd7eddec9d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'3d62c78e081a996ea4ce2124d6816a62112b9c7eea5c142ecc23ba90ed2e8f6d803286be2d8e956fbe2b0b641ba624ba78b1db4fcdb6ff8486be89417c92', 384 ) = 'e6b6eb5d03c7caaca9f7a62c6cb48c0c5662686c975325d7b94878a43b64fc38a884b2c3635ba7f74df36402c974a7c8' as NIST_SHA384_test_vector;
+SELECT SHA2( x'78817bc3f6285eca108e54b14091d1ebb9ecb1b7555dcc5acf07cbab32153ad591a0de59f9d24852a44caafd6fc6ea788ef5f5ca7fb256243c580767b56e86', 384 ) = 'a0ed388522b9bf2737b10071c9e22c9d6db99bb3808ea3248959d075062d845b872d2eeabfa4e123b4f738a685a3c41d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'58beabf979ab35abba29376d5dc227abb3d2ff4d90304982fc1079bc2b2880fcb0129e4fedf27898ce586a91b7681e0dba385e800e7926c0bc5afe0d9ca98650', 384 ) = 'a0888e1c4d7e80cbaaafa8bb1ca1ca912a932175c2ef982ce1f123a8c1aee9635ad75be52590a924bed3f5ec36c35690' as NIST_SHA384_test_vector;
+SELECT SHA2( x'd03e8048b7c387b43067b039e5b9a0f353d94824862dc485235683daac63a9c90044b1ec218157253a2cb532e114ac81993b85459b8ad8c9d6c4ad0434b9e26f1f', 384 ) = '370629f3dc8c8d4b79c3fe8f9033de2a4bd42874f7b3ffedb4b38d73e7959896c45572f08f2974c86e7a51a6117d1dbc' as NIST_SHA384_test_vector;
+SELECT SHA2( x'296a9a5b9a0d101f186d9fa6288c912202547cdf958569d2cbf235740eed38d10b0025dbb6de31058e98780d22149c19d4bcaf06dd7353fd91cd1f47e47f45622e14', 384 ) = '66d6336d30e32ca8ae874fd4869dc3ae94edd97484c385bc93a6384353ed358cebea55bfbda954ac16972596ea51384c' as NIST_SHA384_test_vector;
+SELECT SHA2( x'fe4d2ae2bd5484c7782648130e33f1e478a2deacaca1572ac1f9cb9953e55b2729249da8154d998c1c63180ed7a91faf19b7b6e3d3ceed0a346921a114147cba9281bb', 384 ) = '1df79be52e4a50b6fd14cae825139a39c30829081342b9c4de4fae59df8a0ff20c8a9fe3c498c9ff567a89a32b2e7210' as NIST_SHA384_test_vector;
+SELECT SHA2( x'6ff84418235fc6ab5d12c1bc6591c66a689e9f21b59e2b1d2c416929f265d2ad6a38ece7619d1c7989d2bb24294f6dd312f1aedbd557ae81338d5fbdd5e7cc3d3e30acad', 384 ) = '75df8657107143d13f309094728c3edc8e92dd36a504e0c0f5c9e8ce64bcc40af18630a1913e9f2214e6638c2bd68552' as NIST_SHA384_test_vector;
+SELECT SHA2( x'22817ea8761a32516e99c2c00a4d4e6290b46f3d819bcb31cb87e77e40543d87471c8fd6d25a7a5f904f4e0963a51d6a145312d246c0048ca82b4b606f4ad35c04316fd5f9', 384 ) = '51c1275486c73022fe476005a436a0f8623683d568a7e804d81329726fb30a64778b559cb2152a8a7d7889b67c77b1ce' as NIST_SHA384_test_vector;
+SELECT SHA2( x'd4070bd6e39c3da7751a714915e73e85b73ccb7857379044dc2c6105423da807f82af236876aadd5757a2f736975fb1b8fe540cc3ed8a328d9373e70f354e9b0b6c2b8378569', 384 ) = '87510a9917a6b12fadb3da68908606fab3c76b8e94e250eeae2817dfd4365991b1b517bcda578875fbfddcfdf1b7b142' as NIST_SHA384_test_vector;
+SELECT SHA2( x'f61034de4f9b0c2d203170cf0d344bd869fba4fca977bb5218175558ccea5438d8048a49c322cfd93991512a014b2cba2f643bc79ba42d139176dbe5ca00d8509b944ab76d47f9', 384 ) = '4c0e7b2409850cb0d22b8944d44876f097a40ee7a5e3cc4a7a20269516d1a3ae5b0b52b5af33d7a7cc5c839966c712ea' as NIST_SHA384_test_vector;
+SELECT SHA2( x'39b82498bfb4c821096255f6555e0638d06d9a7a4f62a8c83f4233e8dfa67edfad6121b81d635d8091ddad9586a69d210bdedfe178d19c2b5c1d082fb718397d6a6c39c7eb045ae8', 384 ) = '4dddda1188954064b4d134d8be7acc52207945894f97402cb0e8b2519c2b2ca449ca96a4ab4bdf078b0ef2fc9814a74d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'2477a617791efe62db70e5592e0f815edc0dacaacb0c92928ca37b08d504e56431dcd665f67b70727735c6267c08ee0cef7f58a7d8d55db68c5e1bb5202381a724cca6138ec45f4df5', 384 ) = 'bee03bed3eaceb6d7ddfbfd5bac017fe346928f5a128b2fc0bba965d80cdcdac653af7dd433feaa6fbbe4c415d24ff3c' as NIST_SHA384_test_vector;
+SELECT SHA2( x'12812e2b54e6b89b199fbe3b695bbedaea02953969f5aa6cb6976983b50cf36ab241130ef52c75c1965512e09395efb3201d07943ebb85548f5937da69c7400d29ba0df5ca148a1cb665', 384 ) = '19227eb974a9f7079479e27ebd95aed4cdfed11ee12395cb5ac3ed04e384b6bbc174800ed6455c5a354f669b0ee90b62' as NIST_SHA384_test_vector;
+SELECT SHA2( x'e4776aff9f9176054f80f5edac658c95b0aa114a039fa08ab765ec0e350cd40877f837a9788908e6e9fba57c268a643168da6f5d3c97d3aa3458d318dcca8244ef0a91e9cb5265a723d86c', 384 ) = '37d1224bcc443bfc2d1770098da71b98fdf3256210c1eb4b489d3766de535f7aac9431a6cf37cb87dc5cebb5adf220fa' as NIST_SHA384_test_vector;
+SELECT SHA2( x'060e912736074954f440871c4b64d92e452ba79bb9dcad7f6510aee43cb867e30161c30c15b74d098e48ea7d888bc832c02192745f5ae6b813fb0882643fd885461b010beac67497da7915c9', 384 ) = '9f54ebcdfcf95e7acb00e6e99a8409c10eaf9cf9967266f8524f9467925b9525af07940227d2d947f9642eaab289bbc7' as NIST_SHA384_test_vector;
+SELECT SHA2( x'647ccd775229a0b7b1f4c4f81e58dc2963432954edc0a06981d3403d2aa4a2d276e0d2d9e15d5d7592fdab4245d48f96898d1d072b09bc2df24a7ca98c90a965c9c1a01e070ee120eed466515d', 384 ) = '938e9d2cb62164167b2d8ba8300ffcf007e0fdcc80f236ce113c304ae4bc589fcae301bff4e72a7f5179f397fe012915' as NIST_SHA384_test_vector;
+SELECT SHA2( x'717a756d3b651897c7dd97a926431d3277ca5d29aa2f7a3989a4245cf80d05ab7b6e5b75faa4e68ec15404e9cb221b69402337f53c94f4cbd2cc9f16516f98c2c5e5fa8fc10a7e645c279de77a22', 384 ) = '9ecf76b5e05ac4704389b2ef4f7205ace4d152ced735cdb451801eb709702b264aa02aa5efa9cb7c37b526ecd238a319' as NIST_SHA384_test_vector;
+SELECT SHA2( x'95530985e73134f6fef027c8c61f4b9308afd67de19ce70173d0d2efda44b8b461685cdcf6c531d5dce0b8f6a06208bf4e77ae63e474b88307bc0d3df5e40065bb152412a8b2615d013b4765f672a3', 384 ) = '5f181e9003766e88b6118b2d9bc8cf9425e34a6881a91fd87c5bba87121e6954b8599d6dbed8f2e7a74f2ea0755909ee' as NIST_SHA384_test_vector;
+SELECT SHA2( x'a707cfaea184546db789b53ac256c2f23563a767b1a11abed303d916513d546b45cca6b9c836ca64c3930cd7024cbd6b8a232b8b2d73d1175bb9ca053b548c4efa89d20864cadacfb138d16aa1668cac', 384 ) = '4a62f6f793b9f8c5e89498c5d45e52c50a3a004dd1c9213d9d1d0cb40f5fb0610cbe5eb261752764ff3fc35a32fd9aaa' as NIST_SHA384_test_vector;
+SELECT SHA2( x'9241ecb23c7fc0cd69bdfb825614de606332f0256a5ef0df4fb60d51d8bb5a98bf107c0f067fa56f8b3dc73bdc6f015b4cec5e064745bee6e2031477b62fd2b1ef18a2e6a05057ed5af82380fc3d0ae3cc', 384 ) = '9c3bdd4f0b8edd507740d4bc873e35d0963e4cafd27188cc0d63341d25dbf09912ef03903230b1f5c2d0a1c1b9e4b1c9' as NIST_SHA384_test_vector;
+SELECT SHA2( x'89f96eb0353730367f030d1e91b09debf27ab965570feb3ebd4e24f5b44eadfbfea2601558db1801984f665cf81986c3b2619139cddef3c83698206b12f3832c53e9b78a8997fa1dfbfbdf7df7fc435f66aa', 384 ) = 'a7ca6ca52bfa61a490b7de070ff6279ea87d816ad8754a6e529946141954aebcd9c1b1ca1d9fd39137f062c6a2eb7ddd' as NIST_SHA384_test_vector;
+SELECT SHA2( x'cd42b8496d6c5f23b06b440d6a17f03991e02140eeb51d1e1824477ea3c2f03995cd6f19191074e27807999344443ae9d7118725fc57d70febbe403b7b16648b93f68df5e1a2fd86cf327fa7b3f142a04604e7', 384 ) = 'f9910144685987e9500f006d3360d1c270bbe1a90fe658e2a1cf87f4aa32d9e41097cd964964b78589db448fc4de3900' as NIST_SHA384_test_vector;
+SELECT SHA2( x'105f9d121228137fa8138ca3c84d503d89a1d087874a2db18905fa8f616a438f147bceed3b7ea02aa908c3ba4e5b47fd5bf18770a759ae2552427970a8d63ee448492d7d85b1d61f0c18eb3fc7cf47e0020630c2', 384 ) = '8a98f8c9d86edaf0c6dc59be207cfc8ab18dc0b384d2fd9f4a358f42890a919de839eff5388327dc7b175f89e9168c55' as NIST_SHA384_test_vector;
+SELECT SHA2( x'd7448b7ffb746ec0bdd88106a725b84b59cccd317c21d446f8bc1687671f1c23c99a0a81796c2f83602bd90d68666ec13388b80d0eff8168209e60d8e740d2b8e6af8cb897c41025a7cf7f6b6238aed86d677ba2b3', 384 ) = 'fcfbdf092f428b59a1c51c55d0c09d68863c0d2b76368d80f106e0d24b25c4caae1f8a18de689ad0bf6327ff118295c1' as NIST_SHA384_test_vector;
+SELECT SHA2( x'd44bb6b3ebe582bec0c602118f430ac362547eb2ede95d78b681fe9a79f89a03caa00bb1fc94d3af4249604314668f68d4d66e7eb21b4641cde5d9f89ae3e8ee8ad9f826e7f3564bff5959e68503e7d434cf3af6b5d0', 384 ) = '4a6de936a59f5b85d03caece8be0eb1940a20afd38fcff9e83d3ca57d9da95344878528b42d4ce4931e8426a893124cd' as NIST_SHA384_test_vector;
+SELECT SHA2( x'9082f0080bd1030f74595b75376a5b1f7b1ffd2fa3d9751e1beb110a51976451013aa35eb6c34fc38e6914883d9ef2c3543e9a69c40d1b649d60bde61c1a2dfce5dadb668d73a1a65b9da55750ea80c064fba0a913f3ea', 384 ) = 'a3336329854e6dcac625ab1f10cce649687e431009071c9d4fe91bd9da82badc84aeb107ce4d226adb32adc39b66412b' as NIST_SHA384_test_vector;
+SELECT SHA2( x'14d5039c17beb28e8200a3d4a4febe87c23891c90d6fe903d00ba471eeb9c1e18c58b9b70b16123539d631f9c8d670c7ff8e7089afdbb194695c5f2dee1c6f4ce772eba0d6268ad24dd5840e5e97a4c052de9f9b9da2a4e0', 384 ) = '3af733d34b8905c0a06d8cb459e092546cc3e5b90b3e635bb090d871609932b2a219b577181edfbffa67ac7738450c84' as NIST_SHA384_test_vector;
+SELECT SHA2( x'95c025f86b7d76b086a8c592b2e9eca1397b0717bc837c5762a0392335c33d0fc8415a351d26392bc7cd9e324cadedb0cd76eee1e95dcdc9deb3656df1bdbd4211c0d3e6b75b990e10193ec05e47aec29c035c5260963f1706', 384 ) = '1ef611d4aa2ee16894eb7e17905f3d66bff8596811f20ef5906d71f9bd0ee3040269efa8ca4273ca43387241c624144d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'984beb16e04ba209ff4dc567d53edda1de37eac9b8f805a5df924402bc63de4ade478f59870d3e8d6a28de1cb3a792ab4868141c4e8857a7f01d6b2c5b28a2c70dc5f1a650a5981701be05e59641f6e560cddfcc0ce28b437098', 384 ) = '47898d856fb815e3d208df5670acfec6c436eab9b0b1ec63f298a2b81e8d5d326562fbb284f3f7bc70024b5269e2ec2b' as NIST_SHA384_test_vector;
+SELECT SHA2( x'964c2903d33e9c10b8a7573f4ebdc7178decba00cd7971067d65f6da1794b019532e34d19c465e42c0b9a1e1eb599ba3d64bec773cae49148e7dccf6e7b78ea342bd7833ebfb560f33ca2df96895cf4d043bac8625b5eb033df9ba', 384 ) = 'b7ed21b6f2e1370febc83bc27479757bee06c4065f143d6dd93553448950361815c7ee09e961a98ed21100934a13bc23' as NIST_SHA384_test_vector;
+SELECT SHA2( x'00633ae4c920f41f16796c713bfd43ff92323a9b7b865350a088333a7e58cb9b215c372c2e35e6b127f2fcd0eb83f4237c708a8c05cbd8c91c63bf48443a883cb639cbf06123905b2fc8b5f68a7b90ca1fc5d4cde15bb96e514e576f', 384 ) = 'f0a86c75dab5034adf835bf62498226b9d4c5d0bf5237b371654058a024e06630c63c7d8ef8d0879e4767e9821d47599' as NIST_SHA384_test_vector;
+SELECT SHA2( x'6ad118436ce2e22a2b8b7118c8bc081ca9925ddb6f7a37d528983beac66a031cd1a87196586f43ee2d9fe7a7528290faaeae89d5042cca2526d9c951660d92064e7b1a3a9158d06b40c0762841552fd3fe29d9a55ade9cf2e90bc3af60', 384 ) = 'b4460710cf4d9147e9f73e26d97f039533a98ab4cd66399451318bf09a912ccf5267b39a0c8d4c2eeca1e9370a998dcb' as NIST_SHA384_test_vector;
+SELECT SHA2( x'330ecd4f7820328eb2d1442c9ff555c1c705cbac5f7223056e3936d32eb8bb7fb5bf0e89d4eb307a402f0e1aefb406e2c5e3a7b470c0b8ca91797ced1c3e35e70154e73a0c655e12091b72792ded8acab1385f68c09103af935a212bdb93', 384 ) = 'd8d0edefc5881544f7e72431b41b1b2fcfc198a47ae1b89d43bf118200b8529c60eab34963855283291386aadb0e67e9' as NIST_SHA384_test_vector;
+SELECT SHA2( x'32d5e868b0b48239a6d74799ae8046f4d98faa564f9b80233541c108d4bc8c31f7b6b3bc945e796eafbb9aa57c408c8ec4a0059889e4bd29edba758f50103839b9e1e127774fdd9f08f332223971c09e8f4fc7e5e607aa5e585af3fa60e896', 384 ) = '01817497f65899ff7dbd32c4a1c34fb0f6d1c9dc426cdaf6bc42d14c68a6e610aac9fcc47c02076162f1510777a416a5' as NIST_SHA384_test_vector;
+SELECT SHA2( x'57b51d10a4d2fb17ef0f204aa53cf112e1130c21d411cdf16a84176d2ae451ee5f66ae6875cfb2e6a586f233d5ee1bdab9f235513fe229722a7d812afc4f70751a3d128a2b5ef452c10cd71f3b3bb19bea0af5ff729814857319441f69298069', 384 ) = 'cb84599cf288ffa81aa50e0d1c4dfe30777e1b79d82fa05b45707a2e7dd747cd81b1af269206579cc183119f25997263' as NIST_SHA384_test_vector;
+SELECT SHA2( x'ca536a7bf66c8b1e451edc371699dc1afb79cfd06ea20f19bf6fa3ad510d12c7062179e4f8b1dcc86a41bac3fe3ce43228968f48e2b0a70fa17c66a988e126dcdc6173ceb9f9650c03482cd19ef4ed86e24acd8549244b226b10d2ec2dae8e3035', 384 ) = '8a740cb9d4a5432fa53d497ee3620b675b770ab29cb9c51a5a55eef75c7421b4e0dc2399f1e6bbe54690a88f8afc356b' as NIST_SHA384_test_vector;
+SELECT SHA2( x'bc57c2803382d1deb56a146767ac80c89183382e01990bb5aa1d3d2391168ad6eaf768fb7d738d014f92b14d7f0595306eb7441622a49800edee0134492d82320707fceba902af2e0c95fe634a85727bde6f022709a09248752db9a71941c7e75cb1', 384 ) = '33a9b367f842da5f8852a0c4c94594db7283f491ddc8b1cfcaf24681abebb912bd44abb46c18035ef2e4b6e009939228' as NIST_SHA384_test_vector;
+SELECT SHA2( x'cd23cfb189f7797d05244e2abb0db5d26d3ca0f0b8a5bec5ec2ff1fb1b70028970b894d6c252562169067d2051e272e74d3bc70cadee700912eb30e181f55107b7a3987bbcab7836bb5f86c811782d40a413a34c76f91ba17a233d9da67ed32b49ebc5', 384 ) = '2880eccd4926d1ccb4a364d0d2782af372dd22d2b99d3d66849aa04748687ae8e43898e01690bec09725642042442a1f' as NIST_SHA384_test_vector;
+SELECT SHA2( x'b85559ebc62b0b6fa87e6a8aef273808037cc5036a7e59b54753d68a21f69a79e62da39530bbf6dfc6d7415f66debf73c2455c66c8d11a44260ab3ed0eed806936e1997b24ec3e79a827755aaa6ff511255e431a74791b52cdab110b0bf37860b05983c6', 384 ) = '452ac0db3a324b2e6e566c7455e08b898ac5d87b401bef9cd5f8fcba22679a63ba70762127d44ad4c54d621dda18ca4e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'2fa9d04bfab983c02abc09c3a30c22a4c0b086c6ae2f700b12a65d8df219118fd207dcb31d411b6dc7fc01b7312498064df3027d02c30561d220c7ceba22d5a859f96ad355caefa7fbbabe9e25482b5061dfc5a24fabd93a4bad38364c0a3a1d0ca903156a', 384 ) = 'be7f7895d6e7642f417141319ee4d2921ff385ac2821eb66f8fa4309de24d0986dee9040ec25a80f18738a7a48260374' as NIST_SHA384_test_vector;
+SELECT SHA2( x'beeb5575701b32d3b182bd37bb0692d7b9b2dd43cdae7bf5576f5c29752b2cefc690327e74b578cb71512c5a002b465478d16bdb448d119a2f95e5a0df82696e9e03e24e61d371e702e8800fd1ee5fe04bf32f0e296400779d3836fcd86b3190cfae2d8e3f5d', 384 ) = '4b4dc610f079c44075d6b171efc637ae14777331bfe9cb8fbc2f7c0123b37fb978ed15adab3ddcf821cd5457fb996217' as NIST_SHA384_test_vector;
+SELECT SHA2( x'e4a7bb1d0a354ced4b9fc7983c37002b06900ef50d920a3bcfcd132d0e0e95193130cbdfe83583a50f9622cbd5d6e7211d5d745824848ab764ed140fb91567f1c32cc81e8b242e3f69084ad7258fc5755cf1c92e25f9c24af55b663ec049f3db6141b7c43c29d6', 384 ) = 'c21e70712390ea83b033043f31e866b2c466d5371568104b00d788e6f1e66aab07a214484531e4d6293e7d38ce09539e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'2dbf241980678ef9c529d4bdf273c2d44dc5e36bdd5a96331e0c6464f9729102f24bf15fa41ffde16a232605605e6aa48a0a2475523d28d438c80fc1c55fd02cc0fb9170a57dbc1d539454fa05e08a4a83588b4f9ae99d0dc95f6a503d899bf00098a9546dc9f035', 384 ) = '266afecf77e96fb08c2daa5f64c0da97c7791e0ae23bb22e7427226c717bcdcd5aeced0d942d5d10990a4ab37a6c6cbe' as NIST_SHA384_test_vector;
+SELECT SHA2( x'8bade35ccd57d6f8e2a3960cecf685c3787daf4b0f6efe360791ad219f00fe944c2b302a4d1eabf285077f148af20cb8fad802230ed88d2371c4c9ae52df7cc6b8e5049f154c8e041fca89f7db175b98faf45248696cdd0d245afc384b2bf54677e549054e68e6f855', 384 ) = 'b56d9b3094271468e18c7a59187c5eb1c29d3bf681c72941b13c30505ebddee94c004552cd766f69d734e2d82e644ab0' as NIST_SHA384_test_vector;
+SELECT SHA2( x'd5d4c78a18de6c9070dba887c956e407ec435936f69e228f084e96e2414fd69ce910a249ef1a715796f3c01d6b42aa1c7a33b984c11dfcfae5635998249825358be6f2e769b0a8c70376d8f489f94cdb49a0e3b5231b9c503d46f013f850653d221c606d6de73a671f2c', 384 ) = '2c8050c6f7b38754ca49ea444852d09a41d785a05844755ad6d7b731016b96a9fac81394af2bf24a4ba174d5b5f5cb13' as NIST_SHA384_test_vector;
+SELECT SHA2( x'2beec0efa2362159f8b84c089a0320ad88ded8e8f48d3cad0b4f18ec132bee71b6ece8099d6b10e6410cc344fe8b634d6af94d3ae4010bbc7070ca9ac2f50e9b9824a4a64dc1d928ab3ce9b60278baf476d0cab59d5c66634a701ea2a36675307a9edd0fdac2e2e7df4fa5', 384 ) = '833547cc4b44fa04763f5780be550528bc895ea70484fd53115993753236b514794a702b80bf50936b57093c5c0ffc28' as NIST_SHA384_test_vector;
+SELECT SHA2( x'31dad5b0ae329c30ef6c36cc1d1fadf533638b9faae39df25533f7438a64384282d60f75024efee53b485e17f08fa43dd60ae2ae40d99194fba18de4772361942814c5082c2865cd2e71e4898ae72132b248b97fd022cd9cad2d0522d1dfd446ec3bfe5174ea5850908ccf0c', 384 ) = 'df5bf69680ba0d6cbbb7fb564f13e41725c0de4bd7ec79dd01ffc138d1e9806360004fd836276b8abfa73f740dcacead' as NIST_SHA384_test_vector;
+SELECT SHA2( x'452faeebb6bf93bff2216f6788f66e2f2585cc300a5eec18bd3ca42eff30db90fffc57bfcdbdd05e11ce4937fde8a07f808e635bbda8e5a3bb6e91e55e877fad96724503d6261036c8f5f3d83fb67e0a6d2393fa568075a9847e22f2fc5ee3c8725921bfb9407acd7d60145234', 384 ) = '4c60377833fc16e4462001dd21a12ac0f0dd4f7f711f22595af6421f5f5f58d51e22a3b480bad1408f00868e9181eb4e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'6a253181a99b76fd9206fe4e25fc55def54d5a217339a16e6fe1150ddcfce291d4cb9267dc4f75b068b9474ca2220d37677c401992c92d187e8b9cf1c67bb0474f7d0e3b89d4413cf1925e20db53e3746e2be511f0dd6bf0444e1540b03901b5e423ee223892a24a367a8af458f8', 384 ) = 'd1181abb0c8d93a166551accff380396e5ac90144416766108907e9dec4c514219bdc7fb3db6ae68eff12bd4d5765894' as NIST_SHA384_test_vector;
+SELECT SHA2( x'fc25ba418cf60566488551d34fc1e48246119bb0063739e1917aff244b047d986789a72f9f292bb228980205e57c45addb16438fe525d0faa807e0e8ca2254815f8213e1a4c35d1bf0325c7ee72ffc17f1d6fd76ebde47b51cc07db76a1cd4aecd5926e0058d42aa889c87c5bfa3b1', 384 ) = 'a4d8781fc35d998a62237b4344f8e1c26feecfba971adc0d7e09e887340cbe745778f714638571a813df1da0222e4011' as NIST_SHA384_test_vector;
+SELECT SHA2( x'0f44a8a890cd290806ec8fd8d502fcbed910c4cfa8e1d25c1886480f020366374548ad610d63442855f39a4eaae04d0b32494ba4eebe37403cb00ef8a0250a2dc3b0c61ebca1a4b98f796cb2f3a135d3595b899329f8c4e94f4cbd62f65fa87293653b0726f01064bd654b2d39ac7cbe', 384 ) = '0040f15059fb0fb7ad066670f88f23fb2c640459ca4682547e1d910187012c5c2dcb0c0113b049b73499cb596b0ecedd' as NIST_SHA384_test_vector;
+SELECT SHA2( x'7330de53e9fa3b47273102ec8b4c22841ebc8e421a6ae65ca9605362f0c6b3ce4c11f6dcdb77c79c3fa66f459eb5f7cced5b8db56f5f2a2a784f714a7775d9c333070ea3559e956b27e9af659ba381388fc271ba4ff2d3055c41c5cd6c1c57f1b17af04f5e57eddd68648af689fd06f18b', 384 ) = '95f2071081e32a72f1070ca99b9aeec8ee3a2ed9e5fa2d1cf5f16aa2bc98f5e0f9b5a6008cd2ce75e080d1b385df0782' as NIST_SHA384_test_vector;
+SELECT SHA2( x'95322db3ee47d16157f4508f0d52f3b1c31b1afaf2b12e7d7162d69245ea6e7bba39b547b377c5f73e4649e06b47ea505fdf0a74a43bb579c391d4f215a9a47ad69d679a7bdd5aed4575e68117931a81854359112d7e507a4a632b8786c4092f10e4ad73ef7f768a960b913cb83e6d8c5dd0', 384 ) = '21289bb824ff515e45c237d1c79891377f04c40107e71e1db95a9b83b088eaea76e7a4f3019bed4a759f236b2371b76e' as NIST_SHA384_test_vector;
+SELECT SHA2( x'845b92a5775471ed2fb6eae84e70bfa0c28184a8e0bb5403b7c6c2419e6912eb1005aa21ba62c382d1ae644ca9c391c484a9c0d9a85c8c04b4cfad7233302865726ec3d88ff9bc62d3c9ba5c41a104466f95f16795caa0b4e47de8f319469220519ec6101fa0c454dc0cd5603e9180ed2c4c00', 384 ) = 'a43a1e67855b8d2864e8c8b9eea2875f5ce21f33eb2ee9048e90a9665471653330df8f8b5209194125d8e12239c2d56a' as NIST_SHA384_test_vector;
+SELECT SHA2( x'6a34a6d3f5032aaf62f4eedfa3038eda5d0efe173fdc7b2e935dc13a12337f81fd72085769a44b3fdb110554143d35e72eb1d16ae8feb78c3f00e6a63e60ee56165ca56971cb1cff045bd1e9631e26561a4512aff92b17bfaf9574179b389bb1de7be5d3b57f8536065cbb6838ae4a6f48512baf', 384 ) = '0026006d0a5b8f44291f4a8ff8628d8dc428544eabde63c6be478fdbacb6215a4f35bc4e1dc66dacd1020d3012bb01e9' as NIST_SHA384_test_vector;
+SELECT SHA2( x'ba362b818e274a898553d9eb777e934416e3df2f238ea5c6e2076166cb3076b38270c4dc09117c2135e733925e3336195bc61ebaad6aa41afb7db63ebfdfca963e0f723abd903073f2928c7db9ce658b08b2850c25be782d162e9d9f5ad97d9ad6595c22126c0e89a59a0c35ee18c7a305ed3cacf1', 384 ) = '13229cc315e40b044dc9953a5c460b627113d5241885c37f26801c3aec167a3986ab60cdb4a41668c514d9df51a18405' as NIST_SHA384_test_vector;
+SELECT SHA2( x'17a761e66e007e550ab117c35550fc0fc34d6bccaa7986e855c4038b544b26421592ec5db90d8a9620e615f346fa83edd325d2d1edbf876751665ad2a2fe30b700f749a1ddcebba40cd71f411b398a8ae33abf865dbda2d7b808f09aa8cb2e8f005edf7a834bfac9f70c9b767c16f92f1c1698b5a37a', 384 ) = '60044682f7c4736dac3652052ab1eb5d48a24fa94e43b2a5ce55db1c9e569012a392ee690d5e17384631aba65e7533a1' as NIST_SHA384_test_vector;
+SELECT SHA2( x'8ae7073088b58154a7f6257657ea7e0615a7a0d834c60c7ade5cd4c5562c00b27f1a2f6fa2e382b26c0cb54e36188f048afe7d9be2da7a32b2e331d6a99d66503450924045b8cd7052fef162a0e7fd2bc14cb7845cca961f2cbade374b630d6bb16f76ccf79c2c3561b421db1cbf8f24c47797bd2afc29', 384 ) = 'bda24dcb1a3f7f52addd1baa0677918927656d7b458c11034f2166b2f8d72db2d1101e589541087ed9c72191260f8318' as NIST_SHA384_test_vector;
+SELECT SHA2( x'7b0f2d2f4522e57a4d9237d8778644360fead8815db49c0b796c8d3161ebac3b4963f783329f99dabe8c5e2743f969511e9b295f4a5489de31b46783c1c14812c3f34a7e68835a5225e6a64fc1945557ad0d768a931e37ae316058d46803df3890c90c6a0f558fab2aa6f99a1bdf71106349a848619a0f43', 384 ) = '5341d46e6d469718f54e0ad44e5e8cbfb091d9a156eaa1d7695764e6fd70770933f86090701b0404c0a2c9944a49c7f5' as NIST_SHA384_test_vector;
+SELECT SHA2( x'b98c44b9f1339dfd730270012ebcc5bc0c317aa777b4e5cb1cceb91eee342e0f6ef75c602afbe83484aae369b5e9ef27124ba4b98d85329c7e2347d6a479338966db4ac85f1189a91a057d9c1abf61fb1e9387e2a399f940a95e5f2ebad9238029a1d49a985dc886bc7b06436525625fb870eac8bfd781df25', 384 ) = '9bec1d2fd1e4ef91dc70589e4c50c06673b134720f1e0faa14a94c65fc6c3ff6c1934768b832da6d6342800b46c3a558' as NIST_SHA384_test_vector;
+SELECT SHA2( x'48e12a838c285b198e16f759d75ef1361c35b9316eb710d8b1861c8d4fb4b7892ee30d21dfaa6647183b40536443a1041912abc18afc71257fff09bbe2a6e306bb2c58c55fe58674e3da5c16d7b3f13231db1a1c88de3b7583165df590868168d90634f774a164a9d93b722a9a7688ca4ed72dc8ce2517d1a512', 384 ) = 'b6efc213b9396389f4ce18e2cfd22733dca2be8c611ee5b94a9a7be1e8f9c78d7736b49520d8ba9ee09ce16ab76fbba0' as NIST_SHA384_test_vector;
+SELECT SHA2( x'a34dbe4c6f53b1a60cba0260124ba5b3a72395bb4664bccdbf2a130a7fc10a3412152ac1e669f92e524c1e96d6c9c583a5df45046031000025fd8bc9c85210f4607ef06906c6acb6d95b05a94689621d863073146778140650c174797fd976d29672576b56d392e5aacd00c0e7f1442852006612e3a3be88485c14', 384 ) = '723f8ef0f28a234f8dda9f687ab51b2874b91a69ac7a20b107064e7b7c87c849f3ea39471e11ba43499d458e9044d4c4' as NIST_SHA384_test_vector;
+SELECT SHA2( x'd800e0a7cdd96a08ecf6e65dd4ca095605237cc6970932a62ce9fa5d23f3503f0ec079536638cf597eb3590bb65e9ea4f1e1bb9f493eb4c101fc0859ba8688c7eace683b8b3597bf10af4c789d22e2287710e5f8ba766d754af4aad80b2dc18a5571d6e7a29a6a438a33e82af2e07aec80f92159527905caef170a61', 384 ) = '0e1c22ae4d049d23cd7b332359a246e199d4d9b417aae5695874d5cd9ed61d76d2cde81cdb2beac9c4f1d53e00fa0c7d' as NIST_SHA384_test_vector;
+SELECT SHA2( x'cc8470e78492e4ed8598fd5f35ae83b4c49a37781bf066930f7ebdcedbe65f93cd8d35f43fb485f0c9e5c7f1b591b498b3f79fbdce4708b29f086fc8c1b7661585b1ea74e653f3ccbf5f4a963ba19b998dd3cbf8e2bf8b6f94a32edaa1d9b7f75bb7376c61b5560ccdcd2f56af28613ebbf662313e9e17535717a20b63', 384 ) = '3ff1a9007cb18a7e8be1e151ed4ec424bc1c813ab05a092d655d48e69a3cdcf395d204bf3979b0499b1cb18bf80bf8ce' as NIST_SHA384_test_vector;
+SELECT SHA2( x'30b06afaba1d3f66f8213d8f52cf3bc3727f3ebeb0739271ceba1a02e655e413a0990047a8d4930260332771d2e345cbe87746d6df8a66acf9a51abf7263a41bb6d2e4ebd11d713f2768e80c65fc8474b7a4ef483c5658ccb716c6ba8718ac89d925bdee1c3f01a4b5882969f460204947cee21eae2191586fd7c6fa0bbd', 384 ) = 'e399f9c298dffebc1ef90faca476ad2c478879705b9d988f66f320c7c8459fc6f42ac53197fddf3b1654157e3874e8ed' as NIST_SHA384_test_vector;
+SELECT SHA2( x'9551164bd1bcb607023b4572bd5c2e19e7bf9b4a28c08dd69d562c15cd3b5c2bdf4e908a0a35e3b84c4665535fa8b252e9b5ca8df3a31c809c64e44b0ecab7feb2ef5c14a0d4de3d5a48df61b90c2fe127349e200fd00e4292cccc337c1520eb76fd22f17de1d01e92095ea4b3cfcd4f0b04bf0a668f8aa4e7578bd4fd64bd', 384 ) = '4c41ea97b719f84239b3a19f96cd19e39daed16913d1d8767eaba572e29b0cc24bb864a4725d1f55440a5df7c35ee686' as NIST_SHA384_test_vector;
+SELECT SHA2( x'e06e21e2449ad75182808668167ca41150711fd4a8c64ffb51ae29f411adb5f84f58c2ea6e5cd88259c16eaa5f705d2842f3957e8a7d0e0e1f2a028217875a6bcd556628338ad00a6999d3b68ef3a8cad6ce41c3dc253a1e3a000dbd58f5858d81ef75663c2ea932d98f1d524a0e6d3d34898d6a46c7ba71cab8b06d79fe1ea4', 384 ) = 'fa707a7639a6ec82ff72db0490409ef3e8cef1cece79f11600cecd1f7ac71c13b09975f1e2a768840dab12863bc69b1c' as NIST_SHA384_test_vector;
+SELECT SHA2( x'8f', 512 ) = 'e4cd2d19931b5aad9c920f45f56f6ce34e3d38c6d319a6e11d0588ab8b838576d6ce6d68eea7c830de66e2bd96458bfa7aafbcbec981d4ed040498c3dd95f22a' as NIST_SHA512_test_vector;
+SELECT SHA2( x'e724', 512 ) = '7dbb520221a70287b23dbcf62bfc1b73136d858e86266732a7fffa875ecaa2c1b8f673b5c065d360c563a7b9539349f5f59bef8c0c593f9587e3cd50bb26a231' as NIST_SHA512_test_vector;
+SELECT SHA2( x'de4c90', 512 ) = '33ce98281045a5c4c9df0363d8196f1d7dfcd5ee46ac89776fd8a4344c12f123a66788af5bd41ceff1941aa5637654b4064c88c14e00465ab79a2fc6c97e1014' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a801e94b', 512 ) = 'dadb1b5a27f9fece8d86adb2a51879beb1787ff28f4e8ce162cad7fee0f942efcabbf738bc6f797fc7cc79a3a75048cd4c82ca0757a324695bfb19a557e56e2f' as NIST_SHA512_test_vector;
+SELECT SHA2( x'94390d3502', 512 ) = 'b6175c4c4cccf69e0ce5f0312010886ea6b34d43673f942ae42483f9cbb7da817de4e11b5d58e25a3d9bd721a22cdffe1c40411cc45df1911fa5506129b69297' as NIST_SHA512_test_vector;
+SELECT SHA2( x'49297dd63e5f', 512 ) = '1fcc1e6f6870859d11649f5e5336a9cd16329c029baf04d5a6edf257889a2e9522b497dd656bb402da461307c4ee382e2e89380c8e6e6e7697f1e439f650fa94' as NIST_SHA512_test_vector;
+SELECT SHA2( x'c197f08557e421', 512 ) = 'ce69dec20db2e702f51c6232ab79f0890d6f82aaed54d8d0b15d8b02095957b4442a23b8d164be7b1f3669c7981b58ff6cd853149a625771bd666b19d8f0c35d' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a90596a7112d3b9f', 512 ) = '7c42d9b5f5a215db32cfbff9e0e57716e2e4b1a7f87a7bc8121229c6d1fe5989df3dbf20fc71281dcbeb55743bfeab9346e7feeeb07e3cabfb2aaf6cfbc02bfa' as NIST_SHA512_test_vector;
+SELECT SHA2( x'3ae1953415660623c0', 512 ) = 'ac2501818c6d49f5f20534fbaf751f4d6f7288252298ea5a7011f2736200cd9721ff64ad6e672b08bcb2f463a251e9533c3f77465f4db3dd69be1d8b2c52937a' as NIST_SHA512_test_vector;
+SELECT SHA2( x'2bfc3a1b9cdf3485939b', 512 ) = '59dff49557ca098bdbb60cf9934f038890df27431b81369d0fdf92d22ccbbd3a90bc5d060ab2e974af784872e4567d4e2c42bb6375fd9a4ed3a434fc9f23a918' as NIST_SHA512_test_vector;
+SELECT SHA2( x'50f3b7d106cd77e9eec0d6', 512 ) = '814a68eca10f8861b7ac73d9d10a83d1d2f546dfe4c989b49fe9f17cc27d2897245b02f4bbbed4fda8d230534f0caaf2556126d69095e9bc8a4bf5eda4c351f8' as NIST_SHA512_test_vector;
+SELECT SHA2( x'3f08c108cce3eaa5f3bfa6bb', 512 ) = '8b7acaf0d36f877ece73f9318b20828fd79d2a3f28c71069b61ba88d455e4928e9744029bc7f12b417700fd195ee49ef337877bca76251123dd72365f10e36ae' as NIST_SHA512_test_vector;
+SELECT SHA2( x'1e1c81a3f9b48383e68487560f', 512 ) = 'e46861bf4c6b85af4366d6917b19f51efe66eaff16c7865a28d267125f8849244fa04b0b07f07274de2ca150a0549edb3628b87d4a5f73791de0930a702f604d' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b48ada2484dcd78e6617c724b537', 512 ) = 'a1886c390fdd1503a6659f615403d0df814a50bc27854836ea40c90a04680a092733ea4deb7edf2d8cb6a35cef40f20d7b0f9fb0e42305087cbd813aabf599a6' as NIST_SHA512_test_vector;
+SELECT SHA2( x'bbd0a4de4250249c873f5b289159a7', 512 ) = '90953e45ef6c1fe975805ee62ab6431834c0934a81205d7e089068c157c9e2ddced188d869659457788f472f777273c76cb97a00807c83a769e651e11fb59f0d' as NIST_SHA512_test_vector;
+SELECT SHA2( x'cae35cda11064e34b54647556c105523', 512 ) = '72ee08a00931be0bf39f68575c256a1c5661a1b0ed3599c684be4d1f4412094178294773dd23a6adb8f6daebed0683f5750a59602a7244a667d5d8f74cca5b18' as NIST_SHA512_test_vector;
+SELECT SHA2( x'625656f0bf2e3f1dc2c9c4d310c650e016', 512 ) = '47eb9110c93ff62130fa987478cc72b403e019aee6a1c20d20a7d5122bc1ad9d97dbdc40346aa9c624054f76ac7fcefb72975ed946a4c1af04f82f5c137439d2' as NIST_SHA512_test_vector;
+SELECT SHA2( x'c7b15d4f0ace943eba8c3af2f51913285149', 512 ) = 'b0ce8a67c15c98176b787459fe2f1bb5fb01d505930805c0cd9f363f24f5b8dc4a16bd4c9c8ba354f726ca60cccc28bc540819ae1bbe50f6b6acfeeb86f03e88' as NIST_SHA512_test_vector;
+SELECT SHA2( x'62149e4dcc5b79f473d115629f2da21d8c4ad9', 512 ) = '15c77f321a179485aea271dfd0c1be284ecac543fc96a478a0ba93fb640ee708a6367c7123d35cd39be323c9beacb42c63046d7ca8f9bc749f800dde0e4d0dcf' as NIST_SHA512_test_vector;
+SELECT SHA2( x'5b9d847b7ef0965dd053a4d2da3b1e1637e71095', 512 ) = '9681299a52f5949e08b35563d6d35e9f72169f84ba76b9c01be6fbc81dee6000134e691a9b9bd7bc8940de1fc7e173261683b5c8ef7b0fc5bc014714971b0146' as NIST_SHA512_test_vector;
+SELECT SHA2( x'1b1045583ca3e8a0116521b9bcbd4dd7b613c34b1d', 512 ) = '888e6d7fea0c37b40ec32852879131cb0068c580e4280e80b74d204f9c90ea3e943fd27cf2b7ba3111340f8be68b5af89a4b5086de075de25697b9272e0c7278' as NIST_SHA512_test_vector;
+SELECT SHA2( x'938d2d59a18fdf52c343b632301344d6a5d9c70a07f4', 512 ) = '42d70b8a3bedcc1b23f7466f34aac87241c807a87283686cc15cdffed68a257dce74bfa708cc684f1c93142cbeab751070e9852d368a378495e6ad9f8d27e873' as NIST_SHA512_test_vector;
+SELECT SHA2( x'77d59ae1bbd09376bcc9f5ac46ee834bc979e07ca5e2f4', 512 ) = '9c229867a7f26055471f0174fa141f8a5e6ea6a11fc9efdc6cebac2f243467804cdc2e617be5a99e32e10a00550995f728c72c4fb25cb2b17164058ab4f7f3f6' as NIST_SHA512_test_vector;
+SELECT SHA2( x'370995549d249c7eab97a577c09920c3df6c545fa885f4ff', 512 ) = 'bb607aa94d04f3a81b6b48fdae601e15ba8d43805f5a0b096b843ae6a2b25ba58b8b4f78257b8110cac1e61d27c01a2c6e3738cad3a01150cbbc332b8ad42dd6' as NIST_SHA512_test_vector;
+SELECT SHA2( x'8a639dcf06aad53bc991d177c3d7a1661c96431876790f9d72', 512 ) = '5613c1ef219d4de9a3dd4081bb121671060616b3ec8b5cda50361c3d03a362e2c8559bd8cf421834109684adcac9bcfaf6d47e02ed3a39cd7bc2f52d0c81b329' as NIST_SHA512_test_vector;
+SELECT SHA2( x'9f311495c97643482637b51790bd1e3086571f05c4a173ae1605', 512 ) = 'ddc9b2687ab1d99038032deec57fed9f19e69fc2c550d9074099490d1e72751fd95cba099f5dc9c303a3b3e22b949ba8a04d26de046e14339333cc31e78f4f7e' as NIST_SHA512_test_vector;
+SELECT SHA2( x'69b522dae987f8b48864744dd571b39efa0051229011dc80b81989', 512 ) = 'd2f7740090d249237cd1acdbefc584b79aaccfc0e90e19a9f822f9e041e519928e5755a8ce91b4ca67c1355134e22a33fd5cad20d35f3fc58415fc12c6602acd' as NIST_SHA512_test_vector;
+SELECT SHA2( x'c9260d92c68ff1c5cae8f7c3e98869b66f13aa8b6cf1d5ff70ffa1fd', 512 ) = 'dcc1967130f155cfe1422048b8a7b559ce90b5182528310f9fdf93dee9b72029bda0b5a9c474c48c38ccd63915fa60197a87043fd9c399117dbc4c47a4ae5389' as NIST_SHA512_test_vector;
+SELECT SHA2( x'baf280aa618c46d1b4713d42a324e34fc13a8fc33e7703261534443c86', 512 ) = '40f3057c2e02fcff3915744d2a87a7cbed4d1ace0a62658694a5c0ada892dcf25202a5821f37f4842c4d631fb0b5795f3d252e6ab914556801ec99c4002c0510' as NIST_SHA512_test_vector;
+SELECT SHA2( x'9f91b4d09ebfef181f76596bb060085b3323185cd786460f47d6bac72188', 512 ) = 'eda1dda078e4245c51e837c2a8360b1440acfe2d58f7f32ea9a63dc2105e80ec5e162a23d8041cac382de7464c166e7162c620bbcc11d14d8e9b3cc88692b5f3' as NIST_SHA512_test_vector;
+SELECT SHA2( x'376549419a41ecf6e1776679cc9b87a4ddf70a9daf8880fd894a8a3233b64b', 512 ) = 'a971341f79a1081653952b717c7e18e2e2289a4551cec34eb15944f28abfffc7b23e6121ea52efdd4f5c615414d2a59df02392c4740d8f678a773f1e6cce2fe2' as NIST_SHA512_test_vector;
+SELECT SHA2( x'5f264a9fce6c0416c3c399c6a2912a5f33125616a24a5b3cca3e7e16b263aee9', 512 ) = 'dadd0e04ad21dee2937facaf3671e0e026b0d947b377bab623ad45e94872ee8767c2983a10f53f92072eabf9fe3b41b12211e442763274a24f553c658bdabeaa' as NIST_SHA512_test_vector;
+SELECT SHA2( x'6989bf1032bcbf82c96f7a140042dc9ba9cafb5d439be5c6daa69b5d28c65df600', 512 ) = '0044e76560daeedebf0b72b9be8a1437f5a9937e1f6ec8efa0bae0a490808e9d0d4babd3683b4414baf0e033c36b7748635ef9e745cd1dbab547af8e287d9644' as NIST_SHA512_test_vector;
+SELECT SHA2( x'4edbb49bbf3acb02ce83c5cc7f83d2c386e873ada14976712b67277cefb3c5633a10', 512 ) = 'fbe69d13bbb3b9aeb8fb67cea126302adf2984ed02168a13519dca66e56eb0b189587b3b6ca9f14efd8e0a434db7b0caf337d62b4cc0752ccb942f3ca29b4596' as NIST_SHA512_test_vector;
+SELECT SHA2( x'f0b1231cf60536f768e62f79dae86374660bde91a2e2fa94cff531e2536530406ace2c', 512 ) = '9bf2258b1ce68fa5982c296fec10c8343fdf5f995e82ea985b93f5437ab48e6615c7b7e9847c3c545ab909d5e54a6c3ea0166bb0bdfe838278dfd9834f5d25b0' as NIST_SHA512_test_vector;
+SELECT SHA2( x'785db29d4a665e802b68a406cd21dc776ea84e4daaf5a1df93a4973c03f6f75a3119ca70', 512 ) = '6e659b4a07e3aaaea4b49c211a2720f5db8fc81d9749c0a8c0ffce189de896cd3dcc1a1b6381e3d82230715840d4c6ada741d64bf76234ce98b28b2afc96ad74' as NIST_SHA512_test_vector;
+SELECT SHA2( x'8efcd15f3ff1156dcd64ad17bb1566c466429842f2cbb40a84941dc6b12b391037abc77deb', 512 ) = 'bfd174600f799e4a9aea0739fe5b4deb43baa809ee46ac27f59ab5e44d10f9a69c81eed24cfb1b4c6e6fd1c51925fa0b380e5d0cc9f36262d6e0c0cc1abd6331' as NIST_SHA512_test_vector;
+SELECT SHA2( x'807eb33d10722e025b01739f82d7494d242cdf137f510df5d888db691d19470acaa2439009af', 512 ) = 'c2c8abde43c0c73fa9392e7b262d453a3c0ee4aca293dc866defe6e07c0d717319eb3fe6a33775ca5949b20617df03152339af03bf89634d9865f7f1eff633d1' as NIST_SHA512_test_vector;
+SELECT SHA2( x'282cd5ebe30187854c5fdd6b1ab4e49143addc3dc0f12561900e6328ffb3dacf28211ab6b9dce1', 512 ) = 'de42e2933c0fd240d4025dfea77fa4763b55620230668acbfd2e6a6426c2d6446de71976009e77f7b3e17bac91259902f7dfe4f8142f7e65008b6ee2207268d9' as NIST_SHA512_test_vector;
+SELECT SHA2( x'4fb6eb7cec250c1763280b41b215f89791137212a67c758afc867478b223a800f025a72f1fa63881', 512 ) = '99ece2524110af64cf89eaed97b520343a97c859e3873860c2077b06e33337f0886af348bbdba1b41c0366d8a09db1ce2fb726d5d282525fcd1cc45aaf0e75dd' as NIST_SHA512_test_vector;
+SELECT SHA2( x'dbc0d771769987ed9c9a72a44a5728f929653d3d12c9efc7d1b109472962085719727b535e37b06b39', 512 ) = '1aac04e1cc461ca665bf12a578f8f32a6ebb7725686b5a6f461a5a035dad6d7565831caad2364f063ad73edcb210bb2fd04c2539c6eda849ec79baa934d7af94' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b8c17a3fd266ed0374f61c19840f3db5f819271c9029acabc5252a1bfd2a5d03002a779eafda73cff4cb', 512 ) = '4800cbfbe54fbcd8c012180ccd82bbcc783b3413cdec87bd236786ebcb40eb3ad23f509eec53b23c2655959a0a2c53e81b5f3177e6c57883c0e09b48a09050b7' as NIST_SHA512_test_vector;
+SELECT SHA2( x'7ac3e7ae32d0677b28165d829a6b966b5fe032eb25f40299fe0735fd1b1134ead693ca0ef6ce88c82f3468', 512 ) = 'ebc398731a33113646c7c4dfc01fb0aa35214a2de32cbfa99f300b2feb1dbdce203fcea6625b7c2a7205ff1b08096b29b58581a2ea7326163a4f52cdbccd2b44' as NIST_SHA512_test_vector;
+SELECT SHA2( x'4c2645d588b606782a6f45c3725d69d31a251115e6494cad7ca80c197644d811b648c2b2f94a99dcafcd5fd9', 512 ) = '80d1d9053acc378f88f37cb828d3140a16f10810b3a515af301dcc1c7f030d752599a5f437bcde5ecf288afac9e1fb6c9a5e365c82afdf900a0eed6517d4be38' as NIST_SHA512_test_vector;
+SELECT SHA2( x'85ae73d64a09ac922396f80bd94d868a2359e3361bbe0fdbef3fd6e9d97f5dc05166fc2a81c64b29f93f80f4a4', 512 ) = '6a2ff2ef58640bc69dfbff046c6d8fb4a59a85dec77bf06346def8026dfa954e07992ffc364ccfe179e2949826b65db58dc53a05f61c5d6a279193203de9a2f9' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b63a627c6923e0998c8c789f56dac741fe7c567cdb7bd4ccca52a39fd001970a005dfabb9faad32f876b6725c979', 512 ) = 'fe69011bfeb12b7987a1251b225575448d22fb46ca08e909574b96a1611433e0109619cb4c1489e101283d7d2c2dc163cac3ce2416cb06dc27820818f482b3aa' as NIST_SHA512_test_vector;
+SELECT SHA2( x'0261fbf7d72dfa185d1fd999c17e588ae37d6a646505e7ef03b581622228f9ccab7693b419fdc7fcd161390cb2d1eb', 512 ) = '29f146b6ca892586f198f2ba3f58c67d17199e34c19ac32e284047181d57e6bf4c176eb6ee084171ff2a96bd4bc312014351326ea3387e78e78687ee3127426a' as NIST_SHA512_test_vector;
+SELECT SHA2( x'7486acd86f8813a2583ce981d1cc8602864594b611ea132b1bce9f1cc4a2f6e545cbb539d4b86217c972affafe74fd51', 512 ) = '65cf4354a97b963597884f00701b8d4399e9b80612c3410bb223ef4523dd9ee19ab348e8a849128377a6c75622ef06e844b2b758c4aefa5d28c46d6e4dc7cba9' as NIST_SHA512_test_vector;
+SELECT SHA2( x'c33fe419b91191e51dc9fb32d40b43701e63d81d11e3918a460df9e1d2f3ea67779c5dff1caa80f07b3a09e71a0cca407c', 512 ) = 'ed5c3016c805319872023a70d900cc8a301738149ea83dc130a6ca19fc5348b2f4d7fc3b456d0cda749a72da116e6491dda0855ea7aa9b5bab9b7ce5efa423e0' as NIST_SHA512_test_vector;
+SELECT SHA2( x'bd50e2fe1f8f39f96e2044def04afd4c16c01bb1ed7694bab5b2610ece66813bdcbd40f023f4b96e336b9a39cafc2713f68b', 512 ) = '729c1246e155e8b36e92a6fafcdff556df95e7c131c65df68e710b5f04f6552914ee5aa2faa33e8c5827e1781c5af5320f158cebe481d7d0ac54be07c865ba39' as NIST_SHA512_test_vector;
+SELECT SHA2( x'5178db5a599b0664da75988433807d0a44a73d6e754220e3f948952e54c0d4b91a79c3e3fafb169bfcbdbb2d0799755ba67cc7', 512 ) = 'b3723d26e481feba3e3dbae2e36d9b29dd8636d34570d7ea3d6bbf8ce7a254ba2677107fad2decee62d8f27728d9cc433cee34e42b2c4f473153f697145684f5' as NIST_SHA512_test_vector;
+SELECT SHA2( x'e42a2a5e142f98e06ec42f5c78684269c4719c3317a4c5b8c90381386fe69ae6b84ddfe495756d6e9da92d56af5b9eb0d973d5ce', 512 ) = '5f51ff37bb70ceab5c1f5feb33f4f6ddcb7545d22249cff63bbe1a57be8e0ddd7d86131306b599fd8bd5a044daf9bcbb2a8c80eef2079bbd377e0b4acdd408d6' as NIST_SHA512_test_vector;
+SELECT SHA2( x'550495b8bf8bf10bca9a70cf0599a6cd61c1bd22da2e2def5935c753d9f7f896c9364ca7b26831c91a0afe89a83733f38979020511', 512 ) = '4cf0a13f66ac155088a8da8a344b1c4c62ef13ef0237966134345abb11dd0c456f25710ab13148510a6fd615e1863970e8277f45733b95fdf627a4321a48c595' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b6cc4def48738118c35fe4bab82fa61ae8efb930fcf428aa7606aa34e8c577f763455a5f33fc0722c9deb07ef9c6d3c26618560f3aa4', 512 ) = 'e04a1c30b76920518af66f5db87d7642fc1ef2b903e45a8215bf1a5b6de6772427d9b576329c28b3262ff0c1802dc0e6c7b2ac21a0df26a867abf509619c8403' as NIST_SHA512_test_vector;
+SELECT SHA2( x'143c7d79790a56697dc803ec93e6c68f27f6761ce9b374bf6843e167e2b90e6f5ade347eec3166ac5e2cc3e6f7c9f0939445c677f82447', 512 ) = 'c9e076e1ea43672b08036e87afb175e32013da88408c92e5895165fe31a1c02d09c6246fe17e9e1696614e28b53ac0a6c50ade5f10949730b98d110c92cbd9b6' as NIST_SHA512_test_vector;
+SELECT SHA2( x'bb9e6086c137d0c68e6ba728f8c516a65b3ffe303d58b1593266fd51fe2e6713fab2b4dfb94aaeebeaf6245680f3335d118cc4d17c3356c8', 512 ) = '1c0294a68024d098e7fdc14490a34dd579f47a6abd96acddca73a450dc608a840cf308a873376b6917e17c237df0ab76a736105734623e72024b41504e0ebeb9' as NIST_SHA512_test_vector;
+SELECT SHA2( x'8dbe0cf088e68bd30156ebdcad3cb932a69bf8a11c36719948b04a7aa2f1da0e54ccbc57eede228c5bb96c5e1442fa7f93573e650bb5154c56', 512 ) = '77d81a877dab2228601a42bce6839f31b21e2b7964c308555a5462516b635e0f4d4d56b39778987c24b35f666b1667aafa4ecb3784d2ad130fd9882ecf1461b5' as NIST_SHA512_test_vector;
+SELECT SHA2( x'2de3f31fb5182e1cef0f982d0e001be75dda7753d3877f4fe8718530a84513ac06f7dcf87206f12dae0138f0dd4a1b52dd1a7df5d6c5f271133f', 512 ) = '588da105790cd974ecb2988ac398a72ceda9c5bcde026877b67b21443acb4434b78923a57341cb3da465b44a21717c42603bd904e2213b562c732342e26e61aa' as NIST_SHA512_test_vector;
+SELECT SHA2( x'c7680a02334453cf17fa4cd27cbf668e6cc12447aa0d710aa0b037ed991c2d9830cef104082e5683beb7ff011c572d899019d50bdc01f65c0e3729', 512 ) = '94829820a81040b549e89e7df9ac1d99851d57805a95cfd4044d09432f9f3abc803580a2397f38231ad391a1634c2f879e790f6e85045dd972dc080e3e7bc1b3' as NIST_SHA512_test_vector;
+SELECT SHA2( x'ab1d93fdd1d247ad983728157e634612c12d6d5223e204aeea3935ba2c884f9a49376817b97546f2082b80771e2ee056c4b90caf641a656c10ab30d3', 512 ) = 'e7e13c2abb76234415acaffa97ff804f22f20c9ef692044a00d4d49bf656963ab0770d19640081dbc9389d1382bad4fbc3dcd47fb1da671d0d046c34aed476bd' as NIST_SHA512_test_vector;
+SELECT SHA2( x'd3ad500384e30bf680afa762bbc558be9f7281ec53d51d113d4b5da5c62b92c65db44ed2be43c63474c97b7e9c7d1ab9edcea0f8f59cc134a5a78b5310', 512 ) = '54a49b06b483faa6d34a8e1ea7ff5bbc44af9bfceba30f62993093e0bef1134ddef01355b04b5b7678f8446b6cc9eb017d79723de360ff9c6a0adb3679cd03d1' as NIST_SHA512_test_vector;
+SELECT SHA2( x'9c542e4dd9a660850dc22a081c07453f233148f117726e00a9c59a536d7f98133c26a61ad78733a8cc03e6589e2ae253208b49c422c9fe8c4ff2b036560d', 512 ) = '8377f49071ee63696d231d960fc8f37f4a7751ece2121c4f59e00bec6a38f19148269e385a0d66b10246d3837a7eafd259dfa827fa0f961ff4baa9008bf81fcf' as NIST_SHA512_test_vector;
+SELECT SHA2( x'7bdee3f83c1af1cb0ffe6f1235d44f88d2436f234f211b8efd88d4dafb2c4f7159ebc14b7da65a64c6500f6d70449dc1b8dccb9c403fef87b47ab317aed319', 512 ) = 'b908c46311cf787a042a54756dc751d995ea57a76624940f70a18ae369ae82c9ce61ff819dbe95f2dab0886718055cb3a39e39a969277205290fa090d3d7fa6d' as NIST_SHA512_test_vector;
+SELECT SHA2( x'095c7f30824fc92858cc9347c085d578885ff3614dd38ee7ee94a0f44072c877047ee2ad166fdba0e744c3ed2c2b24c9d8a2934648dc84d3be666302110ae08f', 512 ) = 'd5cdaf83bb4a27eaad8d8f18e4bee9c25be949a761a0fd0fb2284cab143cad60beb5688734b2f81e9e2d640b425fd32ccb3d20d02d63c2c94c03ab3d9e7d9b4a' as NIST_SHA512_test_vector;
+SELECT SHA2( x'baf66cf83ab8a22878d02194b7c56599717cd3db4a594a8942a7fce32e3a7cf9695217b5c7c3681bca5327d0196442d92dd32fa64e1f804fbeceb81d340c5d4c8b', 512 ) = 'f63022f528910ee310028dfb0782db51b79f4b8063543f15eb008618c50f9b8721603f7381baf083b34beb01cbb8d985db3b8e1eb53854ce3bb62ce7434373b3' as NIST_SHA512_test_vector;
+SELECT SHA2( x'aaa20338001d524041919bbb13926d0729a099c27c599598d8ec22599bd12d4fbab8f3ce04bf690cabe7db3300c9d3b57e853ce00afcc7b2793f8eee5346f86fd6e6', 512 ) = 'af4a2fc9681166fe70d4f0fb8d219d56a1f4ce532a7db8f94c4432ac41e370295977dbb0c4e356a8d2b1d791d513029f96d144cd92f45bd4230cda84bfd04a69' as NIST_SHA512_test_vector;
+SELECT SHA2( x'8cf929dee0a854f7071f7062c911338e298655e0462f97a983f60455e6da77e5befa5d9f89efbc03145f7502e4cfc66bd5b912a601dfe5a4e3de3316bd06e0dd366985', 512 ) = 'f499e9f1b19c614857b63bb44c095cb19b7cf48c5d6e0a6eb15cbe0eeb61e0bdf7bf0f049cd3d146748196718698248360a174f878113305c6633f10ddff0b8f' as NIST_SHA512_test_vector;
+SELECT SHA2( x'47b8bae735771d17d740f537bfeeff1d4012d80379e81d238e89d1843961ff1382e4a0f5ca7dbe1c0ec7da186a008c30dcbb69b24bd42987c8a90a0a13876f1b6163cd6e', 512 ) = '6869157dbbb2117c0cadbd3402203fd7ccf22acb6a85b9efda4f3d3f54903a65b39260bcf8fae978f1559492113081171b7425bbd15b40a2a1c7d2557fe7cf44' as NIST_SHA512_test_vector;
+SELECT SHA2( x'eac31a21d4943d32747d63604d09b9b29a97f0a632b04024af98adb1cf2389e51bca3a1fc6fe3d77d7bd6bf48b627b00f4c1c918e77355c8156f0fd778da52bff121ae5f2f', 512 ) = '149e8b8ff19a532d22a72d9d0390d51a365f0c2fc288acffe99efa5cd21c37f9d39cd307faca020df2aab996fc6b46815133c52a87a3b1ae350833e3e6adb1ba' as NIST_SHA512_test_vector;
+SELECT SHA2( x'28cf2204c192776c904b1288b5b398f99c9189cd6988c4f69a334efbe7744fee6d085d9e0c5ffd0d0eab672509388aa606fb5063e26d23aef59ab011f274eb3f0e6e53496546', 512 ) = 'a6f42a3755bd9940d2f464b2efd42e26e7ad63b2ce26d39dccfe73aa7017e0d5babdc6ca8b8b0fdb27f014537863db09b92f100ea503490e4d1c7a4618372777' as NIST_SHA512_test_vector;
+SELECT SHA2( x'6efc3166fc8a21022171a50e793248b418dfe339c180728058b420d09a9ca4d60cf4d0ee3183679e00b63063958848b127a4bc353ace575d167fb91a77cfa9e58698ad0008d9d7', 512 ) = 'ce34cabc906f67243ccd62ea6363f7ecbb7da3c8640799ddcb5783946d54d68f98e743b4028c5800a7716d524b171920b3b3fa95b19991032622ff9ee90771d5' as NIST_SHA512_test_vector;
+SELECT SHA2( x'f278f968b3b8eac25ed38b4ac7d605930510bc8531c62eb06a281de11c84f0f382ba57e86af02e393986a4692e4c9ce0ebf353f731c24350eb8a48686edc026fff797a57950a082b', 512 ) = '08cfdf043c67b265027c343e05e188a78646414f7f2adbba5fe0a9409b8ce173edc93db26e0e79c191c909ee21c7307ea7c582be30d5377512088c791ea20bd6' as NIST_SHA512_test_vector;
+SELECT SHA2( x'816958892728429100099fbfe5512a367cd7ee2154c6fe99319f67c9a47d6350df9dcfe6c81ddf434c04113df6835f30c07bb9a2293eb227879a7a839f140c0f7371a85e5b7b841f57', 512 ) = '901313c1af212cdcb56cfdd1e2642c0387d6152368a8150cfb3ec6758b45eebced1a50dfbb473c9809accfb575e1eb653a8138080ae08fe85c7010ba8626853f' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a2a1de6f0ea927b132bf987abdaa725b0e1e274e46830e99a2f75af608964df0dff9a99024fc6839bac5acd10202f921ac71a27fcda681aa3109ebf5f21ee3a849098ea3a551e844fae4', 512 ) = '6985aae9d3e97d29b4ba174b4aed7abc5beacc4946a00e6b0921f7978b8cd62fdf897a9ecf94ea2e053bb732f2d6b1a44c1eff9c0ce43bd5ad2aff41121aa12c' as NIST_SHA512_test_vector;
+SELECT SHA2( x'e17c9c1af29e6c3c10f97fdde3a35cf4d37157176fc711ef10ae42eab927b62f42c096d7b664e95af9775a47ae233c3957eccb06be8bb53995f9d9c359ca4eed7cbca791c290758aec180e', 512 ) = '07d0426622c4f5c5dadfd3978fe9edd52b90bd8a9cea32eec6dfbb5cbbaa2549bc7ff15b8568ec716bf315e28b108f35274e4d4cba1f97e7dd7d54d63f8128f4' as NIST_SHA512_test_vector;
+SELECT SHA2( x'45527df1eb7033e31c0733d7a384c642359a6118018ad43488a2c5faaf035d3b12a841589ca4c4ab55ab5b227ad4512dd39dbbdb4130af4097e5b119aa076eb3acdbad08b5de822ba34fc4e7', 512 ) = 'ac0fc8acd30a0c7d4e1a3f965d157af94c4c9d0fa172ad1d4e6b200cec02cf345f0318cc11aa2c9de2867f7c6768aa75548c30c6ae711a6e68ddd0b27be808e5' as NIST_SHA512_test_vector;
+SELECT SHA2( x'eb41a4fa67ff100792cdf1b7c3b8f88dc276ce1a2c3f9d7219dfd1defb0820d0caecc71c5e0b17641c4a31d4d4460e10eae7c26bb438015a2476e228a767e3eb4cec2db629da1a10fb06f5a50c', 512 ) = '382ce23a5bcd95acfb9dc3c9e6962a8ceac1512a0df09ce741fe4c2890e268c637826ee229869663dd8dc9cc83ca5802aba02a769a667dc0d180a24af90dec7c' as NIST_SHA512_test_vector;
+SELECT SHA2( x'dde16e701bf40e42cbb1ad213a84167da405963befd455b699c7e504f0481c7a81f81f72d299c04b542a0ab293531920b00430a4115a05e357c25f5d9060e3f2aeb22ba43970199e40b76b769567', 512 ) = 'd202fc7a97202fea9fdffda2f7cb874e2054c7d6747f904d198cf8d1831eadda653fe79198fe264ef88e480ec731af47165b080ea6078cb7c5bc71dc3fd4c65f' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a530841c4cc46eafe5435317a3651d69db7aeb1ab75062092f5743c0350343f73072175aac4fce8d50f6636c10d99397a422ec2e389a27d965c9b70c605fa28971d29026a74921d0cbb984d0924d46', 512 ) = 'f7cedc950dd26e26b087940306a92f43f77ae039c34144aff8c5c2cb01214f18108f913e81d621e45a53e035a7f578fbe2d7831bf39c71ed9e7694d95d69efa5' as NIST_SHA512_test_vector;
+SELECT SHA2( x'd7289cfbdbb66582d93c8d1f03f9e3b4c57955c69a18622623c2d2d07afca413c42848f205040ecb3975df36a0832b3059a42279323d273abf6681eba9ee5474499ed09275c2a97d9ae6c7c80bde3e88', 512 ) = 'c527bb959f9b7314e10b83a89e22d52e9a47437050b67bf47be7805eb151e5bb08e3ecf4b78d3fbd40c115dab9ddd27fe033cae82e259a880872f74413d2945a' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b6aa7703b126ffbcdaee16664e82ce20be9a90fa0968575a101d1b9fc6ae910586d811c8aa62d78d59a26ffda0426bb3c4445758d744ef0c8afd8f08420fea826e00ffd1178049d2b8f1368a5126db0db7', 512 ) = '0b54fd35a70ff3abc587670afba9c671c57a50bc6a2cdc2deae2a0c98495adfa4559519184f9812c844eb3dd4621facac85de88fdb2eba9fd38cbbea697923a8' as NIST_SHA512_test_vector;
+SELECT SHA2( x'1263458e97c49296f48ed339144f682a6fefb11b824c20807c2192953b2cdfa27690af7d3c7890519dfd469fa74a628294fd173741d148dce27ae578f5d1783c7431fb094f21ed321933a582012ce5810564', 512 ) = '4961166aacf83cba8b42614ac5e699788a995462be37019bc6d8281dc84ff07a19840d9e2e3f1fcbd995903b537de325087d81a85bee94430d96de56c2d6a275' as NIST_SHA512_test_vector;
+SELECT SHA2( x'caa784bf0dd2605026635e8b19db46249da32fe523fda345133afe3b592e175420e12204dd87d53990b2ca3647c7259fe3ae76d01ecee173cd397c526323f869b79984400770ee783c7b0ba36f015a59ad6de4', 512 ) = 'f6335ee270b1a6795528df400d0daec52eddfd0571a2c2c3722047fc1e08498263d43e2900150fc2d098ef1b72c6a28054a620d5f2bfde80714f0f07093cc14e' as NIST_SHA512_test_vector;
+SELECT SHA2( x'e1b77436f6d15a209fdc68a636d96cf38c6850d388dfe369119ddd242e9c1def6c4634a8818a27d42e2e71916a6748cbbca721b3e9b6766dcf04c709913edfb5f41f5831098961830dd4bfeb8d661219cd835a9e', 512 ) = '84067e9bd1a74088edbab9182a39a43e8fa9669a7918a5dd2b0dabe0daf2395b6d41ec828e89ae9ac5e63f54a0dbf7659c13ddc20d2d3d33f30fe5d1747ac341' as NIST_SHA512_test_vector;
+SELECT SHA2( x'cff920294053417495f5ba31281eda43e264ef8bad555fae2c5ff419a9ed78434fd3823299ec8f410a0154201fed531c82ffada180a037fdbd36cf662648f13f28e285971f3bfbf312959a4d9d65155c2eb4601675', 512 ) = '7a1d2a43df8e5f2521d93269d5fe069a555e460d0fb72bee3795c018d77ced248876f86f4e668756f035f2af5fb23c78529278c2a8d773eb060713c450f94559' as NIST_SHA512_test_vector;
+SELECT SHA2( x'03a0c0668e3984b2292d9bd4cf57051ba2240b053b9a2a5f3e9954ae316158ce8e559ed916ff174b69537463d43896cc6a44467c56c727dd6f0ce82a0ddbbe1c1b4212c76e9677be55b4de7e728c0d0ac8e14dd2144a', 512 ) = 'f1c616ce75361a068fc44e8626712dfd535dd37a0a9e8b3b1dfe9cc7b320864664b96193c3728450114c0f4093595202f82b7dd2a37d4b55f01ac24e6f108366' as NIST_SHA512_test_vector;
+SELECT SHA2( x'814c6906076a3a531d6cabd94025549fe78576b671bd8c785ca42212b75aea40da2b0d5854b6bf8a254e16662ea01c9ee596230e4d7c58f926629b9660c18ecbd661ec3839791d774a1907a24dc52616ba62df77355711', 512 ) = '52d5bd5dad0f1340fa3213ba2e94db95ac2bffacea3647bfb94163427fe7eebe5fe6f49160776da6cd9670a617aaab39bb73c5307424e61eb2cd03bdf186eeed' as NIST_SHA512_test_vector;
+SELECT SHA2( x'4edbba7c47286bdb1343da9127a036624ab9a42cec0e3412ba6a13d96f670392ed34097a8c96651eb22dc7c3a4f9c0049b1d77bd1be29d2880fea346da172a81fa83bb8fcd52b899e98e929d66c13d11efb8e1c91887d31a', 512 ) = '036b62ec6673ed63f225f6feb88933809c32edae2292925fb888181c1a0b36cae40e22aaa6db0061e92001e63e4e25886c1d5e8d49b84b928161ddcde950ad64' as NIST_SHA512_test_vector;
+SELECT SHA2( x'267b4d93feba7d7927ea2def7a11994cc35a8d3dc50e85607fbf130eaec7817893f1b7f5f675609a6b2a490cd4f70992278ae76e724df86e1c9688be6d1fbb0050b5749e5834765f02b2ca393afb6067203ef9bb0b054334ce', 512 ) = '7e2ecfef69de2b9fbf553e274dfdd983bf712ef581c4996c0e80590cc7e4e884842561a4690bc5e7c3b5299565f9374b0c97f8e966982a5b15699113541ba784' as NIST_SHA512_test_vector;
+SELECT SHA2( x'ee4ce14bfebdec4ae1b84d73bc62e143ec3098f5905a1e99478dba663be176515e0a80dff3d2d03751c70b7be330a758744651dca9a18b88cff19aa7d7ee9fde9f92040374851932d4d9ff1e78f7c6a692d9d2a9537a831ab08b', 512 ) = '3f2f168af618dc5fcafc8dd644295da4a022f975e3518ec5d1046a3e9ed16756dd5019e98fb85cdea2abf5e47c955c064f7bcdefb02d49c1f92b151c215217ea' as NIST_SHA512_test_vector;
+SELECT SHA2( x'e742e8c107336988161ca3343f532b59df8e6c02dceb9ce03833efa8e65f0ab6dc5bbaf6690be604c98cc292f7bc460bc2fcdf752334649cce184b6d07aa1da0b700279abf4873918c09f6f1ebac0bfe1f3a20bb3267af0b88d071', 512 ) = '745f4cbc34ca7727bf2ecd38aa24126e0566eb0ed633b5f3ddd92ecd74fea28059fd5d7b0810177f22be7d776aba3f63269328b7451b336cdfc78724c6c329b4' as NIST_SHA512_test_vector;
+SELECT SHA2( x'1511d4d2b955be39525983b9a9144e9f60eff6362928d3493675d1e3f1ebc259ec1df98a1b881466412f19ada882c5f9158420fffb2d5512ef0dc1e95c334aa1784df2057611ab0efedb6ea6da9787b1f2e1334e7a6b6c5a6a9f0437', 512 ) = 'd9bcfb54e8dcea3f8d6c7110e7fd397e52d6d62be2fa758e30d79c7ae89ddff0447e01414c7b9b6057fa1d70f064c27da9f5c4122d46c91ee2c1573ccc65c24c' as NIST_SHA512_test_vector;
+SELECT SHA2( x'5a040538682bda120fdc18b072408abd5f7627681d43f0b865051c1faee97353ae5ef8591dcacae2bc7b4cdb96e0844085f9c131f90c8147f59a91285a91765968c30c5482976ddb31fe148b6ca943b4177aa168c93828d2d2863ec97d', 512 ) = '45e61293e86f22b3a3f24f21a9297dbfda1c414d691606599030816332a0f73ca3e7f6d6cd5120e1274e91427e4305cd4599d60f8d2b3069430da6caf8fce103' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a9abd6f42a85681483904d9a94b70dfec552f073495865bea4d0a4496a8993734a0be62b4ccd8bbd57a945ebf68c97405b72e3a1a592d3255ed5f827488db19959644f9a0492764bba54c6dfb199bbf2e4fed21c5bfceec5ac60f93bc2fc', 512 ) = '7aebcf0b69968dec55525b90722e5cfddae97e4bc0dd6630a88c24560ce7f6dc5ad365e1394c162b1fbab7dd159fac8d10e036e12da9102b36541486bf3a9273' as NIST_SHA512_test_vector;
+SELECT SHA2( x'55218435049cb8e9346c6e9602c3601c9fa5d2bf0c9c757d21ae8a9ed48c4a8eb80c86e8c4d98bd3566948917730b355611468553f209321337c11339d9dd2c79bb982edcc7e68dc5a038e8937ff2278a6391cd2fe3f21b9aa5ba7d875c35b', 512 ) = 'd78f40b72a42cbd0309417deea33ea3a317869e5242a6ef94aed63b96bfae036acdcd5144761e5077f8faf79d10c681a7c1144de553bdd9b742eb9aab76edd2a' as NIST_SHA512_test_vector;
+SELECT SHA2( x'e9a6317e3bc4d6cdd5a0833e52fb48baca16a9ba9b6c8ca469a0555763b54f04c87d4e41aa549258f30eefe5a52d2ba06657a8773b0842e094857b6d8911d6a0636280025e56356fade362b4bf4c875cc19be0c6644b447be0454dbf390eb966', 512 ) = 'b79ba8a1dabe9a89a383e8bb61750b4b84c90846671129abd1bed826345d97127c406b447664e3cf5305b5709baa29998c0f74b9f0038965be53a7620917d9c0' as NIST_SHA512_test_vector;
+SELECT SHA2( x'8d3108ebfbd2a6d248234e4eb76af905a899a886bcdba67e3a6d0e2eb2af8e1ce07b6a09d2b5c4244d231a7d6e7f10bc8dcb701366e56f717b5b32f9b48090b249c01a80e1305853fc69569e8e975f0beccd096dec9c72f548e3c8aa44e80f1391', 512 ) = '6d32fec68eba7bcd27a1ca2395e582add90bf74c8cc0926249dcfc333240cbec609976134c541796ff86e6c4481960339b06d00b4a4c55b423ddff52e9595be9' as NIST_SHA512_test_vector;
+SELECT SHA2( x'71599aa11c29f6629aacb58f1478e19988a504746cdeeb4894b7aa6a5541e08aebdd3c2e184d405f0e1145a18ff0c02953d5c34baadcc73262ada8d3eb09f123b9a25a88ea308f8e29c133dcd2502566569a02e4e22deb823bc288d9edcc4c1ea451', 512 ) = '30a38eaecdf787a4a2bc2e7e31e1c908112cea639cd882c0e88f0b3b8c131b5d791028150a3970ed79aba63421fb7735c068ccc3ef2ce500ba574f4e0515c360' as NIST_SHA512_test_vector;
+SELECT SHA2( x'c436115d8fa97b11dbca495353e7a37a82b0816c44e3c1647a2977f2023b8443e7486aa2d49b5e3fcf799f2f234807b59ef7dfc0fd99f8b4a553f76d9479f18296f438c6bce774150a92f54d7076479afcb907f74dcdf6f14b4d4cae15274f2f3b0023', 512 ) = '9a3bf2d701b6817baea83cd359257da3f6eb8cc34bf5169ec22a1dfc33001d6c4e7f866c2fb863dbe06106471437d0094215b9b17e7e27e90bd2eb05006e3d6a' as NIST_SHA512_test_vector;
+SELECT SHA2( x'5e2a3dcd2f860045cce291de5f501048a724cbacf9f1604085b4221adb4ebe42ae381f0ad7728ea29cbc1ee73309477c8231d11c29e6f32ec2e9bd9a677db3dc751dbb57906a39ebe86778c9bae84c861948f56fee5b471d3ea30849abc79ae13e40d95a', 512 ) = '2828051603cc729ddc9feede736ca9f352b69ab5a916042cf1f9f90cf1d529d7dd0577da13f11f4f7bfac4c4f2d9a327d4c9924ccc93b8c14428c6824c939a14' as NIST_SHA512_test_vector;
+SELECT SHA2( x'e5f4f4d833fc49da6dd083442214cb70d889efbefd2efdd820ac113b61f06bf3261ac4a51096e2d32e886b5c706ef7425e0168b0095b7e3c425fa6690b5613704bd61040c6e895c34b6918632fb1a5cdfb7331f462e42c597620558b1bc9d2e9bbf180af3b', 512 ) = 'bb66ae70b600735d0e9098f12fcd9aaac1f2141291e9bf54bb8e0013fce25ac1b878dfa5d0378814d84dd8892391da402891fbd7bcfec344ffe3272c5be7be66' as NIST_SHA512_test_vector;
+SELECT SHA2( x'85c2ce900c00d962f759c2091dd6c2e9211c36f7f7e348caa3aaccf444a968925208f822244e3095b51c83a5a71b446988330c2755fe5b693c7c8253a608c033758aab5a8aefd12b8bd6a071e38c83f60a3b4e51065edcff3278f6b53e0677f577b2aee048c9', 512 ) = 'ef50d18489656f7af6148e897d4ab3e631f0fd4f9fbd7f232a0ee288980b4cb10c2a1f890c77d13b4646ef133bb8816998dc8f88d5798ec7515f2c8ce607b655' as NIST_SHA512_test_vector;
+SELECT SHA2( x'f7f7f3bc1615653f479acd63042a0d15d636a071bdd02433d2bd156f2bccdc83ff6708490a68db91332e08ce6defbb0fdb4fda3137328a5374cff68ba2074cd713f40757bcc474b9ddc86ff4e5c86e39909ac22652f2193ef87c46968d2845d07ac6794df2d239', 512 ) = '11eb07f3a5c143026a7824197c02e2a52281fa82e15ef976a7e63941e16951f00321f206f09c2ebc0bf6fd00bb879df894952b98151b0e8cc27b34515e1bf4c0' as NIST_SHA512_test_vector;
+SELECT SHA2( x'd12a258ef4cc5ae35ba4e63aa23165945516f464aa098b966feb8ecf41389ef7ffa2b5f57ef972b97e4eb180dd585f530b178dd1beb6c22fe7b6967de4497c2bf7fce0cbf7997218454cc13802040b3e7f1c53f3f53bb5d67779f76124c3608ea180cd9ac7740109', 512 ) = 'a8e4b47f67f1541c7fc0f2a13c5abb33a1d4a5d733d794f22edf760b146485ac53bd03038ee76e322fcc23667c4c209f6c61287a8c9c044f0c9922752a9efc0c' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a71a304ec61763764ad7881d54fe7d394e658e7588253ce223f23ce92fabc385102e01af2671eb19adcf3e1ee19fc1f9660bca36e8200367ff216e185521a7050ad06a8a5796545a72deee74b2b5e753f493a1653d78f0bfa13b1e0f631f32d25da871c7a2ad26a363', 512 ) = '2609ef79ea747fe6b00a50a2316c9d3ed2946adfd71cb3b1ad1262b3911add77c2bc76d121444c905ae865703e208bffd759b222b42b02cd13764c04298aab15' as NIST_SHA512_test_vector;
+SELECT SHA2( x'63df67c7eb2829ee72dd694949d92a24a0622c8f54ab6003089d9e4877d79a9508f415faa40c50fbc47dc67eceeb1ae7a1854f816e8a3720cb0c2e0402f50801af4747dd8aa891fa811d62340a16ff0db7abab080a251c528cc030a719afdd747e6166394603d532d046', 512 ) = '42463a62b1c92b3982dc4d666f8bf30ad5b3f383fc00ae3e65b5d4787ba0ce9f0c5e6d4d6446f1f480460fcac237dd1d82657b14dd8e4044954321ccba7f478f' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b95900674bc78a86f4f9b2203b2950f6eac9a59665804c833b6f6e90fbb8368d4941842530b5e607baccc444becddaf8fa51eb2d6149b4fcb64220f55ae8bac263c96706ed5c558bb5422f9de4cb93b128bcc54b0950a51e7b7cde74af7761d02f7a12d22ac5c05c0ce25b', 512 ) = 'd420448ee2c6eabadfce5856fe93383ef559d144c97349bc0af48b1c19a926bb40b62d3cc9334804e6991cb073baf976dfb52ddee24b5ce36d1f6789eed83574' as NIST_SHA512_test_vector;
+SELECT SHA2( x'fe59b2da7c365a64901f6a132c957105844578ee0a2c955f9dfebd49fdc9dabd83d51df50fd096984127023aecb7e422c7a5d751668a22c069d48de8f46973875f8d19a22e053ec6437cf3945227ad7d96a599c9c2292fde3bda0abf847af7d3f9464ce8c11e7b77fee6e629', 512 ) = 'cc7cb1a4a616ae4806e48cbc176542a4d75a5b07c25d9324c124db13328e656ccd1cda4f946f0425c5d79c1ba165b1a12933b92f7bc3296fe98c72b15cad2d51' as NIST_SHA512_test_vector;
+SELECT SHA2( x'71f7ff4ba87d2bcb5ff81a1f42f47756f5189e6b5458011bff6ccaf41680c2af412d71bff4a8872af1397a980eef71a93893618cb8da75ceb5deb46ffacfde3bfae69657119bc61b0d18401fededa199e9057be6b2d9b366fae3278d37569437a40cb83c89c0b345bd7db3de69', 512 ) = '31b446c44b0aa2791cb7ab5834e4b8cdd2e3c5b4a96234b338c7b9431dab2bc532e4d71c7f84f07372c8a3f08feac37d0254cead9a9aa619d312a3c006992caa' as NIST_SHA512_test_vector;
+SELECT SHA2( x'52b5a7af72437136650e64a49078aa831d8d715c46364c88d0b0d543d53d9802c71a2c07b2b0a332c10e251a0497d75c70f80133285e7149fbe51acd2d5301c67a065aa7582bed237d31bf42a17defb58560de673446925488305d9ef164b9dd726277b7ec1b19b29f5e7c45ee93', 512 ) = '02bdc51f3e4e129a4b21347d835b3611165424eb6607440c816979e6806e27df12c50413740b1602da26db7ee3e55e5ab4a62a8eaae24ef1c68d1510fc824932' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b698108304a44fda03e02fbd13bdaf3ae1c7786de61f7796312bcc6e678ce3bc0850e023f369413e2d5ebeefde4174f39ce143baec4075760648a073d9b9cda64f66d988d2a11c250ff4496ffa1295d9120c1c21e6c8806dd8b0d39a21a7b7d11541c35ba83329b6320896e86f165a', 512 ) = '131ecdf4840cdc45557516205f07cc277b7641d05afc57cb7fe534f59d9cbe611e0e6a7b6aad61f1d39fdc7559f3048ac4d0a41234ddf07423dc61dbfddb7a65' as NIST_SHA512_test_vector;
+SELECT SHA2( x'65f571e86f04f86dca7079e2ce8619a1f52057fed7cc9e88592a1a8c2196ccdb4d07d9cd643728868c052b78fe17fd29b8c3ae377130db99d2b88127e391125dc4adc95c9dde3b31d73e305a8dceb0863d5d619dc4ac100089cf8d12f8d6bcf732ade99c02415cf714e42d9061f35a40', 512 ) = '0cf871f3af1d3e5c9965619f479ba6b75be338afbf32b2a1fdec9361164357b2c4faebebff6e4a5af00389336434b5872285adb1e760ae99b19a812236000d22' as NIST_SHA512_test_vector;
+SELECT SHA2( x'188d1fc4347ad766311a74574b46be4c30886742bfd1eec90f6ac4a3b32dae8d3cf56a5d0053954d1a83cc97b29e12427f10713b894de4a734c075787a04a33e785706402c4c36cc7dc0e8cb7b0e5a98e987f213f91c22f1565e8e5667a971a5d39b3c9740cb818a61b8101c2f0060f976', 512 ) = 'b67a29b2280dae77184e2e7839a7f3b48f4054f9bd0ebf5ecf1694151966756ec4542b2285a53fa37515116c7db4f1aa492f9db0bbafa0567bdaea1bf0f26abd' as NIST_SHA512_test_vector;
+SELECT SHA2( x'9bae33d315dd0e4fbed1a571e7e5f902c9c027817679f46810ffaab139b92399ca6923a4c856ebe194aa0a6f61197740ebc3dd1d675c36eab58a9b2cdd8e5ac8b9274a0defb35bf5239871a86ae27342012e9ed63fc620b3c80de2e6041ea500cfb05019723d8814d2638225e88a159171c7', 512 ) = 'f3b2f66f9a9673ffc47d2c510d6de0a3ac90d59e9600f2600777b1d84446cf94588231a8b48987081209e320d62ae85acb4895731bef1710923ef0fa983340d0' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a7d58b5cfb1841f6387ff658cfc44c2b14fbd1579f6d8276f2a38e885dc15ce81f16ce7fcef0c837f9b5ecb20b2fa83d722873ff0137537693d9a325f2c31386f777f046f216a6b14b75836c6a72bd62d589b70098a280a5ea2d9c540d7108ad7621781b2e31e34e78e741ecb4359483834625', 512 ) = '90fd55013bb36a390be5bbc34bf9ef76ab200deedf3844f79bf5128fdf6fe71332a612e5bb3c4a2bfaec1bcc5510f6f8ec8414d5e13b0ebf2a67e84ce2282d2b' as NIST_SHA512_test_vector;
+SELECT SHA2( x'c3bd6ef24c7c64ba3b198a8949bb824b4642b6910b72edd8af531d0efed7805226beeafcb4b75addbfc8cfc863ef5d50720a7fd465f4afb999f134f7b84c3cd7743e2afb7c12319ea887221d777682b6bcb4e090943a65fc9b83adfb6036d5001605d6f78cd511855f1f2b926e961a058e0a80ce', 512 ) = '99163db3dae57ca20c4327b88851f3c63187e5a2bbadf3c3dab341040619d2196c84c196cee861deea363f48a9f728b4816d2831033ab472f1c92e1ce748ba4f' as NIST_SHA512_test_vector;
+SELECT SHA2( x'9b6b821c5f536bbda82ff5036b6de56eb046a596469d9427b52aa12a74d718865c6abbc65d65151c702a0ba6cc63b4f15da16bbc724322feb69af92a614b0fb1aff497c892122f6da3226ea45f06bc0790ab677d09e9f34a96aab148334f93737c4f3eab652161b62b5d45858b1ea6b831aac26473', 512 ) = 'f65de5d478319608168bde654963b9d410b6aa5bfd8d25bf2165a94b5d2ceba0eb792a7bf132c6c189748ef16fe87e196c862a884b6e2da9804c92b60bcde824' as NIST_SHA512_test_vector;
+SELECT SHA2( x'616ab1a4a7782b8e1cc098b3ae4c70f7bec742fd7681a9475dba7b9f281c43b6d489f20cf117d10f4159ba8781e188318702ccaa8ddbc28fcd9083e34edb7bb1fdc41ef2ffacd7b04690416c628c9abe9a9e753b3cadae9b31caa31cd4b5a12105a39d1f783e25b953ee962af9578ee42023a4762a01', 512 ) = '43394563a74a6d0a036b1dfc206a2ff1e8a2443d8f69b63372fa959360fafd5178d8e8793b2a44116a64313797b60cea5c93cba97a1e6309c2aa9436a2815c21' as NIST_SHA512_test_vector;
+SELECT SHA2( x'9bf0e5967fc1359ec7093f1db06144268e176e08098ba9d085d8b50fe2b779dd66a19b1df7344d038ed86ad4e8a2c1ed7f79b107b877f6b95e91c23e4f7b0f7975c63436f84cb7b3b2cd635fe4da9ae127f2ec5ca5ece8f288943187b399d5c7b0a7db6aead01bb61d3053460ad1760b6fcc479036b127', 512 ) = 'abeb62f84f587b997e09ee255819531b986c86e2568df29ed77b68a597331f2a977203a2f66566e37cbfdacc090d0464c49839cee7a8ff569c008758b0b1172b' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a19949a0d6340be4a91b7973b705bddb2021a0d58f04aad474e68ade940fb99bc48c5bacf126663d649505de44f03f8e5d68d4191f3667a5ead2e2878966175bfc82a3537a1118cfb68c5b2e626d4ae4f1e7a2cda2d420c2baefe76910432251cfe3ea3e78dc6ac12668410c166427056604d4991dc61e53', 512 ) = 'c7a4313191d56ef7a73064e271ac720322866a6ef82a42a2faeafdeb8d4da7df5200baaa286ee50c9464d0eb229b036c333ceae7b6a511af5c51dab79508641e' as NIST_SHA512_test_vector;
+SELECT SHA2( x'a949427f3fc83e578d9cc7ef6a510759f697bbe97d9739329e87b130ac7cb3c75480f16c80e547237cd9f8a9573a3bf28dabf6d6e2e7c90791554e46a6dd9fd6a9fb19317c1160fb8602a33412fc22b1f195edcd671aee5c452329e0526b4300efdf4135fbf593c7f53f51f86040c47e6c7e2837d2d8b01900', 512 ) = 'fe3347c05519b9c4a61fa289af3153c56f96d04f67041697ba09bf9722a04be2bb15ae2399170a9fe206db8d60cb9940c6d6826db99860f31fd83e9eb9f72c73' as NIST_SHA512_test_vector;
+SELECT SHA2( x'4157af0b3e7d291add80bdc7dac297a15861a6e66db24599e1eb1bd6331f3f63dd70a087d980a51f642810ee026d2835c2af1783c32491cff785b6c427073a5c388dc3b0ac1c920f6c8f664dc48c9d5dafb69d2255247283d213b8be39d7bcfed818de2fbe3a3a117b1d878b27073e43a6deff6b299b32def8fb', 512 ) = '6d90357d4fe398642e7b6099fa2fb2383dedb02db019e90b2ed4058dd55311156e79b8aa970035d098fd3c0e26626ca9af42af491b36eb40097c6223d21201ba' as NIST_SHA512_test_vector;
+SELECT SHA2( x'bc79986ccacf533b9ddbe2bcd15958c3bcd86063f325dc051007cbb8b32c70c8c764b192070dbd96c0cef1ced889fd3f0f8a42cd85057f537dbfadf3600b27ab05f80e292fc9ece157a5975cac9059d3599a4dfc06560c24a18e897e5e353abbfc9d79da4beb2942ebc79c0e5658b4a8206f49997e02cb9f06dd29', 512 ) = '1e1d4bb3839438383be702d61d60f098d70257baef0f4058260e8d300ece538a0c3133b327a7f25055916dc8c8a5c7cd419c95d0664aa53742e8be6abd4b22f5' as NIST_SHA512_test_vector;
+SELECT SHA2( x'0a45314284915ec9021fdd121a3c99e7c01bc73b696d26607131857abace8734975fa3b1e84e6ec686241d66e19f455de706e64128b9a8a6380c64925555e6314a44f2c9937384efc23e5cfc22d5babb998f6764d382f4ce9c5046e08e435349ed9d2670cf2929ae8016a3bc240580679e61518bb1ef933e65a6344c', 512 ) = 'f523ebd51c0f1d8e32a299f762f50826fd2341b8ae44d0c4841080bb626112ae1eafbb089b7adfd6e6668ac7ab684f78da2a23273058973e4cb660c297733912' as NIST_SHA512_test_vector;
+SELECT SHA2( x'8beea2e048193dfa755a594306ad9825c77659d037092ee09a6f91394a68d2364eac54042d76f9480443db08d7d73dc82582c1f3bfa1db7dda6785c762de34c391280b58c10b4f087ead1cd0e09b564f1710e12b487515b198246cbb86717ed77deb30a5a9df28810b1e8462c800cb02c7a923407a8bc5c2fc2cafde5d', 512 ) = 'a71b1ce1e582bca53d7615488335ca1ff351eb33a8c2c0105bec7ffcbd55e4533ee68209ec8b009066a2ff60b418d6b943816cca9b53b7bf64a34feaa4d63600' as NIST_SHA512_test_vector;
+SELECT SHA2( x'f4259473bfd39877bfe9597353d7ce8dd520c66d1fc7884e4e03b655c63a7721762dd4a35d7163304c1e23d4eecba8ea07b978e9f94eb4818cc5fbe7ee258b6df96fa955b51c44e71ec6d5c12726896ffe3ea23b92d71a46532e8ad838eb4bf50752db31d1bd82c5bb4a35e105d1ba4444190d0bf24b03c629a62dd1ac75', 512 ) = 'c8a04bf3881d0582e03563af73a675e40dc9918fcb5a138b8c6fdd057df0c11b112a6dc0664a0dff8a316c3a645ac87dd25b644d061700306bbd7dd805879b55' as NIST_SHA512_test_vector;
+SELECT SHA2( x'd60da691585b7c0c3714905411ae8e3515e8490dbbaf07d1b2431f501a96c7bcf4f52766d7e9b2c9e460b5cafc08303e30fce6ad78a2b055a8d31672a13d20bdc4066a33adb277171d47473a37af2c7af05dd989c134bcf09ea48e532c1628f62f8a9880417e74ffca126e2d2c6b29f23e554b29fc2cd4a77dfcae7925e784', 512 ) = 'ec83376ff6f633ee2d898d87a6a91efb0788bce188fac7d3c4c35f81ba6015640dbfad1f8584557ec210478a0cb566f1490643ce602aa5abfab63d46f7f1d4ee' as NIST_SHA512_test_vector;
+SELECT SHA2( x'b7d5d5f8955d1ad349b9e618c7987814f6dc7bdc6c4ee59a79902026685468d601cc74965361583bb0a8aa14f892e3c21be3094ad9e58b69cc5d6d28a9bea4afc39dc45ed065d81af04c91e5eb85a4b2bab76d774aafd8837c52811270d51a1f03300e7996cf6319128be5b328da818bde42ef8a471494919156a60d460191cc', 512 ) = '6e7fb797dfca7577432c0b339fe9003b36942a549b112d32016b257c9a866e4385e01d4e757d4378b8e61f5a8a29aa73f2daafdaab23dfe4e0b93df21374e594' as NIST_SHA512_test_vector;
+
+## Test some unusual parameters items.
+## First, the ones that must return NULL.
+SELECT SHA2( x'ff', 1 );
+SELECT SHA2( x'ff', 2 );
+SELECT SHA2( x'ff', 223 );
+SELECT SHA2( x'ff', 511 );
+SELECT SHA2( x'ff', least(123, 42) );
+SELECT SHA2( x'ff', 10000000000000 );
+SELECT SHA2( SHA2( NULL, 224), 224 );
+## Second, things that mustn't return NULL;
+SELECT SHA2( SHA2( x'ff', 224), 224 ) is not NULL;
+SELECT SHA2( SHA2( x'ff', NULL), 224 ) is not NULL;
+SELECT SHA2( SHA2( x'ff', 224), NULL ) is not NULL;
+SELECT SHA2( (select x'ff'), 224 ) is not NULL;
+SELECT SHA2( (select x'ff'), least(224, 500) ) is not NULL;
+SELECT SHA2( (select 1), NULL ) is not NULL;
+
+## Verify the digest lengths.
+# N bits -> N / 8 bytes -> N/8 * 2 nybbles
+SELECT LENGTH(SHA2( '', 224 )) / 2 * 8 = 224;
+SELECT LENGTH(SHA2( 'any', 256 )) / 2 * 8 = 256;
+SELECT LENGTH(SHA2( 'size', 384 )) / 2 * 8 = 384;
+SELECT LENGTH(SHA2( 'computed', 512 )) / 2 * 8 = 512;
+
+--echo #
+--echo # Bug#54661 sha2() returns BINARY result
+--echo #
+--enable_metadata
+SET NAMES binary;
+SELECT sha2('1',224);
+SET NAMES utf8;
+SELECT sha2('1',224);
+SET NAMES latin1;
+SELECT sha2('1',224);
+--disable_metadata
+
diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test
index 879732fc81f..18fb072966b 100644
--- a/mysql-test/t/func_encrypt.test
+++ b/mysql-test/t/func_encrypt.test
@@ -1,4 +1,4 @@
--- source include/have_ssl.inc
+-- source include/have_ssl_crypto_functs.inc
--disable_warnings
drop table if exists t1;
diff --git a/mysql-test/t/func_encrypt_ucs2.test b/mysql-test/t/func_encrypt_ucs2.test
new file mode 100644
index 00000000000..8b4cd44d354
--- /dev/null
+++ b/mysql-test/t/func_encrypt_ucs2.test
@@ -0,0 +1,12 @@
+-- source include/have_ssl_crypto_functs.inc
+-- source include/have_ucs2.inc
+
+--echo #
+--echo # Bug#59648 my_strtoll10_mb2: Assertion `(*endptr - s) % 2 == 0' failed.
+--echo #
+
+SELECT CHAR_LENGTH(DES_ENCRYPT(0, CHAR('1' USING ucs2)));
+SELECT CONVERT(DES_ENCRYPT(0, CHAR('1' USING ucs2)),UNSIGNED);
+
+SELECT CHAR_LENGTH(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' USING ucs2)));
+SELECT CONVERT(DES_DECRYPT(0xFF0DC9FC9537CA75F4, CHAR('1' using ucs2)), UNSIGNED);
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index 1475ca082a5..e4a1206fa9c 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -720,6 +720,10 @@ EXPLAIN EXTENDED SELECT 1 FROM
t1 t2, t1 GROUP BY t1.a) AS d;
DROP TABLE t1;
+
+--echo End of 5.0 tests
+
+
--echo #
--echo # Bug #54476: crash when group_concat and 'with rollup' in prepared statements
--echo #
@@ -758,3 +762,36 @@ SHOW WARNINGS;
DROP TABLE t1;
--echo End of 5.1 tests
+
+
+#
+# Bug#36785: Wrong error message when group_concat() exceeds max length
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (a VARCHAR(6), b INT);
+CREATE TABLE t2 (a VARCHAR(6), b INT);
+
+INSERT INTO t1 VALUES ('111111', 1);
+INSERT INTO t1 VALUES ('222222', 2);
+INSERT INTO t1 VALUES ('333333', 3);
+INSERT INTO t1 VALUES ('444444', 4);
+INSERT INTO t1 VALUES ('555555', 5);
+
+SET group_concat_max_len = 5;
+SET @old_sql_mode = @@sql_mode, @@sql_mode = 'traditional';
+
+SELECT GROUP_CONCAT(a), b FROM t1 GROUP BY b LIMIT 3;
+--error ER_CUT_VALUE_GROUP_CONCAT
+INSERT INTO t2 SELECT GROUP_CONCAT(a), b FROM t1 GROUP BY b;
+UPDATE t1 SET a = '11111' WHERE b = 1;
+UPDATE t1 SET a = '22222' WHERE b = 2;
+--error ER_CUT_VALUE_GROUP_CONCAT
+INSERT INTO t2 SELECT GROUP_CONCAT(a), b FROM t1 GROUP BY b;
+
+SET group_concat_max_len = DEFAULT;
+SET @@sql_mode = @old_sql_mode;
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 8839a28b9dd..e8309d68830 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -1117,6 +1117,69 @@ SELECT RELEASE_LOCK('aaaaaaaaaaaaaaaaa');
--enable_result_log
+
+--echo #
+--echo # Bug #11766094 - 59132: MIN() AND MAX() REMOVE UNSIGNEDNESS
+--echo #
+
+CREATE TABLE t1 (a BIGINT UNSIGNED);
+INSERT INTO t1 VALUES (18446668621106209655);
+SELECT MAX(LENGTH(a)), LENGTH(MAX(a)), MIN(a), MAX(a), CONCAT(MIN(a)), CONCAT(MAX(a)) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #11766270 59343: YEAR(4): INCORRECT RESULT AND VALGRIND WARNINGS WITH MIN/MAX, UNION
+--echo #
+
+CREATE TABLE t1(f1 YEAR(4));
+INSERT INTO t1 VALUES (0000),(2001);
+--enable_metadata
+(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
+--disable_metadata
+DROP TABLE t1;
+
+
--echo #
--echo End of 5.1 tests
+###
+--echo #
+--echo # Bug#52123 Assertion failed: aggregator == aggr->Aggrtype(),
+--echo # file .\item_sum.cc, line 587
+--echo #
+
+CREATE TABLE t1(a int, KEY(a));
+INSERT INTO t1 VALUES (1), (2);
+SELECT 1 FROM t1 ORDER BY AVG(DISTINCT a);
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#55648: Server crash on MIN/MAX on maximum time value
+--echo #
+CREATE TABLE t1(c1 TIME NOT NULL);
+INSERT INTO t1 VALUES('837:59:59');
+INSERT INTO t1 VALUES('838:59:59');
+SELECT MAX(c1) FROM t1;
+DROP TABLE t1;
+--echo # End of the bug#55648
+
+--echo #
+--echo # Bug#56120: Failed assertion on MIN/MAX on negative time value
+--echo #
+CREATE TABLE t1(c1 TIME NOT NULL);
+INSERT INTO t1 VALUES('-00:00:01');
+SELECT MAX(c1),MIN(c1) FROM t1;
+DROP TABLE t1;
+--echo # End of the bug#56120
+
+--echo #
+--echo # Bug#57932 "query with AVG(DISTINCT) returns NULL if last
+--echo # aggregated value was NULL"
+--echo #
+CREATE TABLE t1 (col_int_nokey int(11));
+INSERT INTO t1 VALUES (7),(8),(NULL);
+SELECT AVG(DISTINCT col_int_nokey) FROM t1;
+SELECT AVG(DISTINCT outr.col_int_nokey) FROM t1 AS outr LEFT JOIN t1 AS outr2 ON
+outr.col_int_nokey = outr2.col_int_nokey;
+DROP TABLE t1;
+--echo # End of the bug#57932
diff --git a/mysql-test/t/func_group_innodb.test b/mysql-test/t/func_group_innodb.test
index 1bdfd8f54bb..bbc576b0fc7 100644
--- a/mysql-test/t/func_group_innodb.test
+++ b/mysql-test/t/func_group_innodb.test
@@ -83,3 +83,53 @@ explain select count(*), min(7), max(7) from t2m, t1i;
select count(*), min(7), max(7) from t2m, t1i;
drop table t1m, t1i, t2m, t2i;
+
+
+--echo #
+--echo # Bug #57954: BIT_AND function returns incorrect results when
+--echo # semijoin=on
+
+CREATE TABLE c (
+ pk INT,
+ col_varchar_key VARCHAR(1),
+ PRIMARY KEY (pk),
+ KEY col_varchar_key (col_varchar_key)
+) ENGINE=InnoDB;
+INSERT INTO c VALUES (11,NULL);
+INSERT INTO c VALUES (16,'c');
+CREATE TABLE bb (
+ pk INT,
+ col_varchar_key VARCHAR(1),
+ PRIMARY KEY (pk),
+ KEY col_varchar_key (col_varchar_key)
+) ENGINE=InnoDB;
+INSERT INTO bb VALUES (10,NULL);
+
+SELECT straight_join BIT_AND(c.pk)
+FROM
+ bb, c
+ WHERE c.col_varchar_key='ABC'
+ORDER BY c.pk;
+
+DROP TABLE c,bb;
+
+--echo #
+--echo # Bug #58050: BIT_OR and BIT_XOR return incorrect results when
+--echo # semijoin=on
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(1, 1, 1);
+
+CREATE TABLE t2 (pk INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1, 1, NULL);
+
+SELECT t1.* FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+SELECT BIT_OR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+SELECT BIT_AND(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+SELECT BIT_XOR(t1.b) FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.pk=1;
+
+DROP TABLE t1, t2;
+
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test
index 4efea8e195e..91f70bb98d7 100644
--- a/mysql-test/t/func_if.test
+++ b/mysql-test/t/func_if.test
@@ -165,3 +165,15 @@ DROP TABLE t1;
--echo End of 5.0 tests
+
+
+--echo #
+--echo # Bug#55077: Assertion failed: width > 0 && to != ((void *)0), file .\dtoa.c
+--echo #
+
+CREATE TABLE t1 (a LONGBLOB, b DOUBLE);
+INSERT INTO t1 VALUES (NULL, 0), (NULL, 1);
+
+SELECT IF(b, (SELECT a FROM t1 LIMIT 1), b) c FROM t1 GROUP BY c;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index 6efeb2866e6..08469b37967 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -555,5 +555,11 @@ SELECT CASE a WHEN a THEN a END FROM t1 GROUP BY a WITH ROLLUP;
DROP TABLE t1;
--echo #
+--echo # Bug #11766212 59270: NOT IN (YEAR( ... ), ... ) PRODUCES MANY VALGRIND WARNINGS
+--echo #
+
+SELECT 1 IN (YEAR(FROM_UNIXTIME(NULL)) ,1);
+
+--echo #
--echo End of 5.1 tests
diff --git a/mysql-test/t/func_isnull.test b/mysql-test/t/func_isnull.test
index d3ad4614998..326574e0515 100644
--- a/mysql-test/t/func_isnull.test
+++ b/mysql-test/t/func_isnull.test
@@ -28,3 +28,15 @@ SELECT RELEASE_LOCK('Bug#53933');
DROP TABLE t1;
--echo End of 5.0 tests
+
+#
+# Bug #41371 Select returns 1 row with condition "col is not null and col is null"
+#
+
+CREATE TABLE t1 (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id));
+INSERT INTO t1( id ) VALUES ( NULL );
+SELECT t1.id FROM t1 WHERE (id is not null and id is null );
+DROP TABLE t1;
+
+# End of 5.1 tests
+
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index c8ea11c7490..0d59f98a313 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -283,12 +283,20 @@ DROP TABLE t1;
#
# Bug #31236: Inconsistent division by zero behavior for floating point numbers
#
+# After the fix for bug #8433 we throw an error in the below test cases
+# rather than just return a NULL value.
+--error ER_DATA_OUT_OF_RANGE
SELECT 1e308 + 1e308;
+--error ER_DATA_OUT_OF_RANGE
SELECT -1e308 - 1e308;
+--error ER_DATA_OUT_OF_RANGE
SELECT 1e300 * 1e300;
+--error ER_DATA_OUT_OF_RANGE
SELECT 1e300 / 1e-300;
+--error ER_DATA_OUT_OF_RANGE
SELECT EXP(750);
+--error ER_DATA_OUT_OF_RANGE
SELECT POW(10, 309);
--echo #
@@ -310,11 +318,24 @@ DROP TABLE t1;
--echo #
--echo # Bug#57477 SIGFPE when dividing a huge number a negative number
--echo #
+--error ER_DATA_OUT_OF_RANGE
SELECT -9999999999999999991 DIV -1;
+--error ER_DATA_OUT_OF_RANGE
SELECT -9223372036854775808 DIV -1;
SELECT -9223372036854775808 MOD -1;
SELECT -9223372036854775808999 MOD -1;
+#
+# Bug #8457: Precision math:
+# DIV returns incorrect result with large decimal value
+# Bug #46606:Casting error for large numbers in 5.4 when 'div' is used
+
+--error ER_DATA_OUT_OF_RANGE
+select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
+--error ER_DATA_OUT_OF_RANGE
+select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
+SHOW WARNINGS;
+
--echo #
--echo # Bug#57810 case/when/then : Assertion failed: length || !scale
--echo #
@@ -324,4 +345,194 @@ CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1
SHOW CREATE TABLE t1;
DROP TABLE t1;
+--echo #
+--echo # Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
+--echo #
+
+CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
+--echo #
+
+CREATE TABLE t1(f1 DECIMAL(22,1));
+INSERT INTO t1 VALUES (0),(1);
+SELECT ROUND(f1, f1) FROM t1;
+SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
+--echo #
+
+SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
+
+--echo #
+--echo # Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION
+--echo #
+
+SELECT SUM(DISTINCT (TRUNCATE((.1), NULL)));
+
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug #8433: Overflow must be an error
+--echo #
+
+# Floating point overflows
+# ========================
+--error ER_DATA_OUT_OF_RANGE
+SELECT 1e308 + 1e308;
+--error ER_DATA_OUT_OF_RANGE
+SELECT -1e308 - 1e308;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 1e300 * 1e300;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 1e300 / 1e-300;
+--error ER_DATA_OUT_OF_RANGE
+SELECT EXP(750);
+--error ER_DATA_OUT_OF_RANGE
+SELECT POW(10, 309);
+--error ER_DATA_OUT_OF_RANGE
+SELECT COT(0);
+--error ER_DATA_OUT_OF_RANGE
+SELECT DEGREES(1e307);
+
+# Integer overflows
+# =================
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775808 + 9223372036854775808;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 18446744073709551615 + 1;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 1 + 18446744073709551615;
+--error ER_DATA_OUT_OF_RANGE
+SELECT -2 + CAST(1 AS UNSIGNED);
+--error ER_DATA_OUT_OF_RANGE
+SELECT CAST(1 AS UNSIGNED) + -2;
+--error ER_DATA_OUT_OF_RANGE
+SELECT -9223372036854775808 + -9223372036854775808;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775807 + 9223372036854775807;
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT CAST(0 AS UNSIGNED) - 9223372036854775809;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775808 - 9223372036854775809;
+--error ER_DATA_OUT_OF_RANGE
+SELECT CAST(1 AS UNSIGNED) - 2;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 18446744073709551615 - (-1);
+--error ER_DATA_OUT_OF_RANGE
+SELECT -1 - 9223372036854775808;
+--error ER_DATA_OUT_OF_RANGE
+SELECT -1 - CAST(1 AS UNSIGNED);
+--error ER_DATA_OUT_OF_RANGE
+SELECT -9223372036854775808 - 1;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775807 - -9223372036854775808;
+
+# To test SIGNED overflow when subtraction arguments are both UNSIGNED
+set SQL_MODE='NO_UNSIGNED_SUBTRACTION';
+--error ER_DATA_OUT_OF_RANGE
+SELECT 18446744073709551615 - 1;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 18446744073709551615 - CAST(1 AS UNSIGNED);
+--error ER_DATA_OUT_OF_RANGE
+SELECT 18446744073709551614 - (-1);
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775807 - -1;
+set SQL_MODE=default;
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT 4294967296 * 4294967296;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775808 * 2;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775808 * 2;
+# The following one triggers condition #3 from the comments in
+# Item_func_mul::int_op()
+--error ER_DATA_OUT_OF_RANGE
+SELECT 7158278827 * 3221225472;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775807 * (-2);
+--error ER_DATA_OUT_OF_RANGE
+SELECT CAST(1 as UNSIGNED) * (-1);
+--error ER_DATA_OUT_OF_RANGE
+SELECT 9223372036854775807 * 2;
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT ABS(-9223372036854775808);
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT -9223372036854775808 DIV -1;
+--error ER_DATA_OUT_OF_RANGE
+SELECT 18446744073709551615 DIV -1;
+
+
+# Have to create a table because the negation op may convert literals to DECIMAL
+CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED);
+INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809);
+
+--error ER_DATA_OUT_OF_RANGE
+SELECT -a FROM t1;
+--error ER_DATA_OUT_OF_RANGE
+SELECT -b FROM t1;
+
+DROP TABLE t1;
+
+# Decimal overflows
+# =================
+
+SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999;
+--error ER_DATA_OUT_OF_RANGE
+SELECT @a + @a;
+--error ER_DATA_OUT_OF_RANGE
+SELECT @a * @a;
+--error ER_DATA_OUT_OF_RANGE
+SELECT -@a - @a;
+--error ER_DATA_OUT_OF_RANGE
+SELECT @a / 0.5;
+
+# Non-overflow tests to improve code coverage
+# ===========================================
+SELECT COT(1/0);
+SELECT -1 + 9223372036854775808;
+SELECT 2 DIV -2;
+SELECT -(1 DIV 0);
+# Crashed the server with SIGFPE before the bugfix
+SELECT -9223372036854775808 MOD -1;
+
+--echo #
+--echo # Bug #57209 valgrind + Assertion failed: dst > buf
+--echo #
+SELECT floor(log10(format(concat_ws(5445796E25, 5306463, 30837), -358821)))
+as foo;
+
+--echo #
+--echo # Bug #58137 char(0) column cause:
+--echo # my_gcvt: Assertion `width > 0 && to != ((void *)0)' failed
+--echo #
+CREATE TABLE t1(a char(0));
+INSERT INTO t1 (SELECT -pi());
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #59241 invalid memory read
+--echo # in do_div_mod with doubly assigned variables
+--echo #
+SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')));
+
+--echo #
+--echo # Bug #59498 div function broken in mysql-trunk
+--echo #
+SELECT 1 div null;
+
+--echo #
+--echo # Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONS
+--echo #
+select (1.175494351E-37 div 1.7976931348623157E+308);
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index f47418fa773..9257314013d 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -22,7 +22,7 @@ select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_ut
# between two calls should be -1
set @a= uuid_short();
set @b= uuid_short();
-select cast(@a - @b as signed);
+select @b - @a;
#
# Test for core dump with nan
@@ -487,4 +487,60 @@ SELECT INET_NTOA(0);
SELECT '1' IN ('1', INET_NTOA(0));
---echo End of tests
+--echo #
+--echo # Bug #52165: Assertion failed: file .\dtoa.c, line 465
+--echo #
+
+CREATE TABLE t1 (a SET('a'), b INT);
+INSERT INTO t1 VALUES ('', 0);
+
+SELECT COALESCE(a) = COALESCE(b) FROM t1;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug #54461: crash with longblob and union or update with subquery
+--echo #
+
+CREATE TABLE t1 (a INT, b LONGBLOB);
+INSERT INTO t1 VALUES (1, '2'), (2, '3'), (3, '2');
+
+SELECT DISTINCT LEAST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
+SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
+
+DROP TABLE t1;
+
+
+#
+# Bug #57283: inet_ntoa() crashes
+#
+SELECT INET_NTOA(0);
+SELECT '1' IN ('1', INET_NTOA(0));
+
+
+--echo #
+--echo # End of 5.1 tests
+--echo #
+
+
+--echo #
+--echo # Bug #58199: name_const in the having clause crashes
+--echo #
+
+CREATE TABLE t1 (a INT);
+
+# NAME_CONST() would seg.fault when used wrongly in a HAVING clause
+--error ER_WRONG_ARGUMENTS
+SELECT 1 from t1 HAVING NAME_CONST('', a);
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
+
+--echo #
+--echo # End of tests
+--echo #
diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test
index 1292c475732..89eae5955aa 100644
--- a/mysql-test/t/func_sapdb.test
+++ b/mysql-test/t/func_sapdb.test
@@ -169,4 +169,26 @@ SELECT TIMEDIFF(TIME('17:00:00'),TIME('17:00:00'))=TIME('00:00:00') AS 1Eq,
TIMEDIFF(TIME('17:59:00'),TIME('17:00:00')),
TIMEDIFF(TIME('17:00:00'),TIME('17:59:00'));
+#
+# Bug#42661 - sec_to_time() and signedness
+#
+
+SELECT sec_to_time(3020399)=TIME('838:59:59');
+SELECT sec_to_time(-3020399)=TIME('-838:59:59');
+SELECT sec_to_time(-3020399)='-838:59:59';
+SELECT time(sec_to_time(-3020399))=TIME('-838:59:59');
+SELECT time(sec_to_time(-3020399))=TIME('-838:59:58');
+
+#
+# Bug#42662 - maketime() and signedness
+#
+
+# TIME(...) and CAST(... AS TIME) go through the same code-path here,
+# but we'll explicitly show show that both work in case the ever changes.
+SELECT maketime(-1,0,1)='-01:00:01';
+SELECT TIME(maketime(-1,0,1))=CAST('-01:00:01' AS TIME);
+SELECT maketime(-1,0,1)=CAST('-01:00:01' AS TIME);
+SELECT maketime(1,0,1)=CAST('01:00:01' AS TIME);
+SELECT maketime(1,0,1)=CAST('01:00:02' AS TIME);
+
# End of 5.0 tests
diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test
index 294efa8caf1..3531864c860 100644
--- a/mysql-test/t/func_set.test
+++ b/mysql-test/t/func_set.test
@@ -97,3 +97,25 @@ SELECT CONVERT( a USING latin1 ) FROM t1;
SELECT CONVERT( a USING latin1 ) FROM t2;
DROP TABLE t1, t2;
+
+--echo #
+--echo # BUG#59405: FIND_IN_SET won't work normaly after upgrade from 5.1 to 5.5
+--echo #
+
+CREATE TABLE t1(days set('1','2','3','4','5','6','7'));
+INSERT INTO t1 VALUES('1,2,3,4,5,6,7'), (NULL), ('1,2,3,4,5,6,7');
+
+--echo
+SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), days);
+SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), days) IS UNKNOWN;
+SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), NULL);
+SELECT * FROM t1 WHERE FIND_IN_SET(DAYOFWEEK(CURRENT_DATE()), NULL) IS UNKNOWN;
+SELECT * FROM t1 WHERE FIND_IN_SET(7, days);
+SELECT * FROM t1 WHERE FIND_IN_SET(8, days);
+SELECT * FROM t1 WHERE FIND_IN_SET(NULL, days);
+SELECT * FROM t1 WHERE FIND_IN_SET(NULL, days) IS UNKNOWN;
+SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL);
+SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL) IS UNKNOWN;
+
+--echo
+DROP TABLE t1;
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 92c4bae5327..9a9a8110a74 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -442,7 +442,7 @@ where collation(t2.a) = _utf8'binary' order by t1.a,t2.a;
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
where charset(t2.a) = _utf8'binary' order by t1.a,t2.a;
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
-where coercibility(t2.a) = 2 order by t1.a,t2.a;
+where coercibility(t2.a) = 5 order by t1.a,t2.a;
DROP TABLE t1, t2;
#
@@ -1319,6 +1319,7 @@ explain select 1 as a from t1,(select decode(f1,f1) as b from t1) a;
explain select 1 as a from t1,(select encode(f1,f1) as b from t1) a;
drop table t1;
+
--echo #
--echo # Bug#49141: Encode function is significantly slower in 5.1 compared to 5.0
--echo #
@@ -1381,3 +1382,60 @@ SELECT * FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
+
+--echo Start of 5.4 tests
+#
+# WL#4584 Internationalized number format
+#
+SELECT format(12345678901234567890.123, 3);
+SELECT format(12345678901234567890.123, 3, NULL);
+SELECT format(12345678901234567890.123, 3, 'ar_AE');
+SELECT format(12345678901234567890.123, 3, 'ar_SA');
+SELECT format(12345678901234567890.123, 3, 'be_BY');
+SELECT format(12345678901234567890.123, 3, 'de_DE');
+SELECT format(12345678901234567890.123, 3, 'en_IN');
+SELECT format(12345678901234567890.123, 3, 'en_US');
+SELECT format(12345678901234567890.123, 3, 'it_CH');
+SELECT format(12345678901234567890.123, 3, 'ru_RU');
+SELECT format(12345678901234567890.123, 3, 'ta_IN');
+
+CREATE TABLE t1 (fmt CHAR(5) NOT NULL);
+INSERT INTO t1 VALUES ('ar_AE');
+INSERT INTO t1 VALUES ('ar_SA');
+INSERT INTO t1 VALUES ('be_BY');
+INSERT INTO t1 VALUES ('de_DE');
+INSERT INTO t1 VALUES ('en_IN');
+INSERT INTO t1 VALUES ('en_US');
+INSERT INTO t1 VALUES ('it_CH');
+INSERT INTO t1 VALUES ('ru_RU');
+INSERT INTO t1 VALUES ('ta_IN');
+SELECT fmt, format(12345678901234567890.123, 3, fmt) FROM t1 ORDER BY fmt;
+SELECT fmt, format(12345678901234567890.123, 0, fmt) FROM t1 ORDER BY fmt;
+SELECT fmt, format(12345678901234567890, 3, fmt) FROM t1 ORDER BY fmt;
+SELECT fmt, format(-12345678901234567890, 3, fmt) FROM t1 ORDER BY fmt;
+SELECT fmt, format(-02345678901234567890, 3, fmt) FROM t1 ORDER BY fmt;
+SELECT fmt, format(-00345678901234567890, 3, fmt) FROM t1 ORDER BY fmt;
+SELECT fmt, format(-00045678901234567890, 3, fmt) FROM t1 ORDER BY fmt;
+DROP TABLE t1;
+
+SELECT format(123, 1, 'Non-existent-locale');
+
+--echo End of 5.4 tests
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Bug#55912 FORMAT with locale set fails for numbers < 1000
+--echo #
+SELECT FORMAT(123.33, 2, 'no_NO'), FORMAT(1123.33, 2, 'no_NO');
+SELECT FORMAT(12333e-2, 2, 'no_NO'), FORMAT(112333e-2, 2, 'no_NO');
+CREATE TABLE t1 AS SELECT format(123,2,'no_NO');
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test
index 77bf3be5e72..f697e0b477a 100644
--- a/mysql-test/t/func_test.test
+++ b/mysql-test/t/func_test.test
@@ -24,7 +24,7 @@ select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
select 1 like 2 xor 2 like 1;
select 10 % 7, 10 mod 7, 10 div 3;
explain extended select 10 % 7, 10 mod 7, 10 div 3;
-select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
+select 18446744073709551615, 18446744073709551615 DIV 1, 18446744073709551615 DIV 2;
explain extended select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
create table t1 (a int);
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index f32110ef87c..86f465b3a6e 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -345,10 +345,6 @@ select date_add(date,INTERVAL "1" QUARTER) from t1;
select timestampadd(MINUTE, 1, date) from t1;
select timestampadd(WEEK, 1, date) from t1;
select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
-# mysqltest.c discards an expected 'deprecated' warning on prepare stage
---disable_ps_protocol
-select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
---enable_ps_protocol
select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
select timestampdiff(YEAR, '2002-05-01', '2001-01-01') as a;
@@ -360,10 +356,6 @@ select timestampdiff(SQL_TSI_HOUR, '2001-02-01', '2001-05-01') as a;
select timestampdiff(SQL_TSI_DAY, '2001-02-01', '2001-05-01') as a;
select timestampdiff(SQL_TSI_MINUTE, '2001-02-01 12:59:59', '2001-05-01 12:58:59') as a;
select timestampdiff(SQL_TSI_SECOND, '2001-02-01 12:59:59', '2001-05-01 12:58:58') as a;
-# mysqltest.c discards an expected 'deprecated' warning on prepare stage
---disable_ps_protocol
-select timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a;
---enable_ps_protocol
select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
@@ -602,9 +594,6 @@ select isnull(week(now() + 0)), isnull(week(now() + 0.2)),
--echo End of 4.1 tests
-explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
- timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
-
#
# Bug #10590: %h, %I, and %l format specifies should all return results in
# the 0-11 range
@@ -797,27 +786,21 @@ select DATE_ADD(20071108, INTERVAL 1 DAY);
select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
-#
# Bug#33834: FRAC_SECOND: Applicability not clear in documentation
#
-# Show that he use of FRAC_SECOND, for anything other than
-# TIMESTAMPADD / TIMESTAMPDIFF, is a server error.
-
-# mysqltest.c discards an expected 'deprecated' warning on prepare stage
---disable_ps_protocol
-SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
-SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
---enable_ps_protocol
+# Test case removed since FRAC_SECOND was deprecated and
+# removed as part of WL#5154
+#
---error ER_PARSE_ERROR
-SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);
---error ER_PARSE_ERROR
-SELECT DATE_SUB('2008-02-18', INTERVAL 1 FRAC_SECOND);
+#
+# Bug #36466:
+# Adding days to day_microsecond changes interpretation of microseconds
+#
---error ER_PARSE_ERROR
-SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
---error ER_PARSE_ERROR
-SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
+# show that we treat fractions of seconds correctly (zerofill from right to
+# six places) even if we left out fields on the left.
+select date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond);
+select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
--echo #
@@ -825,14 +808,12 @@ SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
--echo #
--disable_result_log
---error ER_WRONG_VALUE_FOR_VAR
SET TIMESTAMP=-147490000; SELECT UTC_TIMESTAMP();
--error ER_WRONG_VALUE_FOR_VAR
SET TIMESTAMP=2147483648; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=2147483646; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=2147483647; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=0; SELECT UTC_TIMESTAMP();
---error ER_WRONG_VALUE_FOR_VAR
SET TIMESTAMP=-1; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=1; SELECT UTC_TIMESTAMP();
--enable_result_log
@@ -881,4 +862,85 @@ INSERT INTO t1 VALUES (''),('');
SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
DROP TABLE t1;
+--echo #
+--echo # Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
+--echo #
+
+SELECT STR_TO_DATE(SPACE(2),'1');
+
+--echo #
+--echo # Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
+--echo #
+
+SET GLOBAL SQL_MODE='';
+DO STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
+SET GLOBAL SQL_MODE=DEFAULT;
+
+--echo #
+--echo # Bug#11766087 59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
+--echo #
+
+SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
+
+--echo #
+--echo # Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
+--echo #
+
+SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
+
+--echo #
+--echo # Bug#11766124 59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
+--echo #
+
+SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
+
+--echo #
+--echo # Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
+--echo #
+
+SELECT DATE_FORMAT('0000-00-11', '%W');
+SELECT DATE_FORMAT('0000-00-11', '%a');
+SELECT DATE_FORMAT('0000-00-11', '%w');
+
+--echo #
+--echo # Bug#12403504 AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
+--echo #
+
+SELECT MAKEDATE(11111111,1);
+SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
+
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug#57039: constant subtime expression returns incorrect result.
+--echo #
+CREATE TABLE t1 (`date_date` datetime NOT NULL);
+INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00');
+SELECT * FROM t1 WHERE date_date >= subtime(now(), "00:30:00");
+SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00");
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#57512 str_to_date crash...
+--echo #
+
+SELECT WEEK(STR_TO_DATE(NULL,0));
+SELECT SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR);
+
+--echo #
+--echo # BUG#59895 - setting storage engine to null segfaults mysqld
+--echo #
+SELECT MONTHNAME(0), MONTHNAME(0) IS NULL, MONTHNAME(0) + 1;
+--error ER_WRONG_VALUE_FOR_VAR
+SET storage_engine=NULL;
+
+--echo #
+--echo # Bug #59686 crash in String::copy() with time data type
+--echo #
+
+SELECT min(timestampadd(month, 1>'', from_days('%Z')));
+
+create table t1(a time);
+insert into t1 values ('00:00:00'),('00:01:00');
+select 1 from t1 where 1 < some (select cast(a as datetime) from t1);
+drop table t1;
diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
index b006096528e..e7e6fa59df0 100644
--- a/mysql-test/t/gis-rtree.test
+++ b/mysql-test/t/gis-rtree.test
@@ -928,3 +928,31 @@ DROP TABLE t1;
--echo End of 5.0 tests.
+
+
+--echo #
+--echo # Bug #57323/11764487: myisam corruption with insert ignore
+--echo # and invalid spatial data
+--echo #
+
+CREATE TABLE t1(a LINESTRING NOT NULL, b GEOMETRY NOT NULL,
+ SPATIAL KEY(a), SPATIAL KEY(b)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES(GEOMFROMTEXT("point (0 0)"), GEOMFROMTEXT("point (1 1)"));
+--error ER_CANT_CREATE_GEOMETRY_OBJECT
+INSERT IGNORE INTO t1 SET a=GEOMFROMTEXT("point (-6 0)"), b=GEOMFROMTEXT("error");
+--error ER_CANT_CREATE_GEOMETRY_OBJECT
+INSERT IGNORE INTO t1 SET a=GEOMFROMTEXT("point (-6 0)"), b=NULL;
+SELECT ASTEXT(a), ASTEXT(b) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1(a INT NOT NULL, b GEOMETRY NOT NULL,
+ KEY(a), SPATIAL KEY(b)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES(0, GEOMFROMTEXT("point (1 1)"));
+--error ER_CANT_CREATE_GEOMETRY_OBJECT
+INSERT IGNORE INTO t1 SET a=0, b=GEOMFROMTEXT("error");
+--error ER_CANT_CREATE_GEOMETRY_OBJECT
+INSERT IGNORE INTO t1 SET a=1, b=NULL;
+SELECT a, ASTEXT(b) FROM t1;
+DROP TABLE t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index bdbbfc7c064..2a800140d1f 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -353,6 +353,9 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
36.248666,-115.263639 36.247466,-115.263839 36.252766,-115.261439
36.252666,-115.261439 36.247366,-115.247239 36.247066)))'));
+# Expected result is 115.31877315203187, but IA64 returns 115.31877315203188
+# due to fused multiply-add instructions.
+--replace_result 115.31877315203188 115.31877315203187
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85998;
@@ -754,4 +757,68 @@ insert into t1 values (geomfromtext("point(1 0)"));
select * from (select polygon(t1.a) as p from t1 order by t1.a) d;
drop table t1;
+
+--echo #
+--echo # Test for bug #59888 "debug assertion when attempt to create spatial index
+--echo # on char > 31 bytes".
+--echo #
+create table t1(a char(32) not null) engine=myisam;
+--error ER_SPATIAL_MUST_HAVE_GEOM_COL
+create spatial index i on t1 (a);
+drop table t1;
+
+
--echo End of 5.1 tests
+
+#
+# Bug #50574 5.5.x allows spatial indexes on non-spatial
+# columns, causing crashes!
+# Bug#11767480 SPATIAL INDEXES ON NON-SPATIAL COLUMNS
+# CAUSE CRASHES.
+#
+CREATE TABLE t0 (a BINARY(32) NOT NULL);
+--error ER_SPATIAL_MUST_HAVE_GEOM_COL
+CREATE SPATIAL INDEX i on t0 (a);
+INSERT INTO t0 VALUES (1);
+
+--error ER_SPATIAL_MUST_HAVE_GEOM_COL
+CREATE TABLE t1(
+ col0 BINARY NOT NULL,
+ col2 TIMESTAMP,
+ SPATIAL INDEX i1 (col0)
+) ENGINE=MyISAM;
+
+# Test other ways to add indices
+CREATE TABLE t1 (
+ col0 BINARY NOT NULL,
+ col2 TIMESTAMP
+) ENGINE=MyISAM;
+
+--error ER_SPATIAL_MUST_HAVE_GEOM_COL
+CREATE SPATIAL INDEX idx0 ON t1(col0);
+
+--error ER_SPATIAL_MUST_HAVE_GEOM_COL
+ALTER TABLE t1 ADD SPATIAL INDEX i1 (col0);
+
+CREATE TABLE t2 (
+ col0 INTEGER NOT NULL,
+ col1 POINT,
+ col2 POINT
+);
+
+--error ER_WRONG_ARGUMENTS
+CREATE SPATIAL INDEX idx0 ON t2 (col1, col2);
+
+--error ER_WRONG_ARGUMENTS
+CREATE TABLE t3 (
+ col0 INTEGER NOT NULL,
+ col1 POINT,
+ col2 LINESTRING,
+ SPATIAL INDEX i1 (col1, col2)
+);
+
+# cleanup
+DROP TABLE t0, t1, t2;
+
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 2fafeb7d264..1e1cb6c24dc 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -29,7 +29,7 @@ flush privileges;
grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA";
show grants for mysqltest_1@localhost;
grant delete on mysqltest.* to mysqltest_1@localhost;
-select * from mysql.user where user="mysqltest_1";
+query_vertical select * from mysql.user where user="mysqltest_1";
show grants for mysqltest_1@localhost;
revoke delete on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
@@ -48,10 +48,10 @@ flush privileges;
delete from mysql.user where user='mysqltest_1';
flush privileges;
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 10;
-select * from mysql.user where user="mysqltest_1";
+query_vertical select * from mysql.user where user="mysqltest_1";
show grants for mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 20 max_connections_per_hour 30;
-select * from mysql.user where user="mysqltest_1";
+query_vertical select * from mysql.user where user="mysqltest_1";
show grants for mysqltest_1@localhost;
# This is just to double check that one won't ignore results of selects
flush privileges;
@@ -1295,6 +1295,284 @@ SELECT CURRENT_USER();
SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin");
SET PASSWORD FOR CURRENT_USER() = PASSWORD("");
+#
+# Bug#57952: privilege change is not taken into account by EXECUTE.
+#
+
+--echo
+--echo # Bug#57952
+--echo
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+DROP DATABASE IF EXISTS mysqltest2;
+--enable_warnings
+
+CREATE DATABASE mysqltest1;
+CREATE DATABASE mysqltest2;
+
+use mysqltest1;
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1, 1);
+
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES (2);
+
+CREATE TABLE mysqltest2.t3(a INT);
+INSERT INTO mysqltest2.t3 VALUES (4);
+
+CREATE USER testuser@localhost;
+GRANT CREATE ROUTINE, EXECUTE ON mysqltest1.* TO testuser@localhost;
+GRANT SELECT(b) ON t1 TO testuser@localhost;
+GRANT SELECT ON t2 TO testuser@localhost;
+GRANT SELECT ON mysqltest2.* TO testuser@localhost;
+
+--echo
+--echo # Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+--connect (bug57952_con1,localhost,testuser,,mysqltest1)
+PREPARE s1 FROM 'SELECT b FROM t1';
+PREPARE s2 FROM 'SELECT a FROM t2';
+PREPARE s3 FROM 'SHOW TABLES FROM mysqltest2';
+
+CREATE PROCEDURE p1() SELECT b FROM t1;
+CREATE PROCEDURE p2() SELECT a FROM t2;
+CREATE PROCEDURE p3() SHOW TABLES FROM mysqltest2;
+
+CALL p1;
+CALL p2;
+CALL p3;
+
+--echo
+--echo # Connection: default
+--connection default
+REVOKE SELECT ON t1 FROM testuser@localhost;
+GRANT SELECT(a) ON t1 TO testuser@localhost;
+REVOKE SELECT ON t2 FROM testuser@localhost;
+REVOKE SELECT ON mysqltest2.* FROM testuser@localhost;
+
+--echo
+--echo # Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+--connection bug57952_con1
+--echo # - Check column-level privileges...
+--error ER_COLUMNACCESS_DENIED_ERROR
+EXECUTE s1;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+SELECT b FROM t1;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+EXECUTE s1;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+CALL p1;
+
+--echo # - Check table-level privileges...
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT a FROM t2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+EXECUTE s2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CALL p2;
+
+--echo # - Check database-level privileges...
+--error ER_DBACCESS_DENIED_ERROR
+SHOW TABLES FROM mysqltest2;
+
+--error ER_DBACCESS_DENIED_ERROR
+EXECUTE s3;
+
+--error ER_DBACCESS_DENIED_ERROR
+CALL p3;
+
+--echo
+--echo # Connection: default
+--connection default
+--disconnect bug57952_con1
+DROP DATABASE mysqltest1;
+DROP DATABASE mysqltest2;
+DROP USER testuser@localhost;
+use test;
+--echo
+
+
+--echo #
+--echo # Test for bug #36544 "DROP USER does not remove stored function
+--echo # privileges".
+--echo #
+create database mysqltest1;
+create function mysqltest1.f1() returns int return 0;
+create procedure mysqltest1.p1() begin end;
+--echo #
+--echo # 1) Check that DROP USER properly removes privileges on both
+--echo # stored procedures and functions.
+--echo #
+create user mysqluser1@localhost;
+grant execute on function mysqltest1.f1 to mysqluser1@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser1@localhost;
+
+--echo # Quick test that granted privileges are properly reflected
+--echo # in privilege tables and in in-memory structures.
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con1' as 'mysqluser1@localhost'.
+--connect (bug36544_con1,localhost,mysqluser1,,)
+call mysqltest1.p1();
+select mysqltest1.f1();
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+drop user mysqluser1@localhost;
+
+--echo #
+--echo # Test that dropping of user is properly reflected in
+--echo # both privilege tables and in in-memory structures.
+--echo #
+--echo # Switch to connection 'bug36544_con1'.
+--connection bug36544_con1
+--echo # The connection cold be alive but should not be able to
+--echo # access to any of the stored routines.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--disconnect bug36544_con1
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Now create user with the same name and check that he
+--echo # has not inherited privileges.
+create user mysqluser1@localhost;
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con2' as 'mysqluser1@localhost'.
+--connect (bug36544_con2,localhost,mysqluser1,,)
+--echo # Newly created user should not be able to access any of the routines.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+
+--echo #
+--echo # 2) Check that RENAME USER properly updates privileges on both
+--echo # stored procedures and functions.
+--echo #
+grant execute on function mysqltest1.f1 to mysqluser1@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser1@localhost;
+--echo #
+--echo # Create one more user to make in-memory hashes non-trivial.
+--echo # User names 'mysqluser11' and 'mysqluser10' were selected
+--echo # to trigger bug discovered during code inspection.
+create user mysqluser11@localhost;
+grant execute on function mysqltest1.f1 to mysqluser11@localhost;
+grant execute on procedure mysqltest1.p1 to mysqluser11@localhost;
+--echo # Also create a couple of tables to test for another bug
+--echo # discovered during code inspection (again table names were
+--echo # chosen especially to trigger the bug).
+create table mysqltest1.t11 (i int);
+create table mysqltest1.t22 (i int);
+grant select on mysqltest1.t22 to mysqluser1@localhost;
+grant select on mysqltest1.t11 to mysqluser1@localhost;
+
+--echo # Quick test that granted privileges are properly reflected
+--echo # in privilege tables and in in-memory structures.
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Switch to connection 'bug36544_con2'.
+--connection bug36544_con2
+call mysqltest1.p1();
+select mysqltest1.f1();
+select * from mysqltest1.t11;
+select * from mysqltest1.t22;
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+rename user mysqluser1@localhost to mysqluser10@localhost;
+
+--echo #
+--echo # Test that there are no privileges left for mysqluser1.
+--echo #
+--echo # Switch to connection 'bug36544_con2'.
+--connection bug36544_con2
+--echo # The connection cold be alive but should not be able to
+--echo # access to any of the stored routines or tables.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t11;
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t22;
+--disconnect bug36544_con2
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Now create user with the old name and check that he
+--echo # has not inherited privileges.
+create user mysqluser1@localhost;
+show grants for mysqluser1@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con3' as 'mysqluser1@localhost'.
+--connect (bug36544_con3,localhost,mysqluser1,,)
+--echo # Newly created user should not be able to access to any of the
+--echo # stored routines or tables.
+--error ER_PROCACCESS_DENIED_ERROR
+call mysqltest1.p1();
+--error ER_PROCACCESS_DENIED_ERROR
+select mysqltest1.f1();
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t11;
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from mysqltest1.t22;
+--disconnect bug36544_con3
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Now check that privileges became associated with a new user
+--echo # name - mysqluser10.
+--echo #
+show grants for mysqluser10@localhost;
+select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser10' and host='localhost';
+select db, table_name, table_priv from mysql.tables_priv where user='mysqluser10' and host='localhost';
+--echo #
+--echo # Create connection 'bug_36544_con4' as 'mysqluser10@localhost'.
+--connect (bug36544_con4,localhost,mysqluser10,,)
+call mysqltest1.p1();
+select mysqltest1.f1();
+select * from mysqltest1.t11;
+select * from mysqltest1.t22;
+--disconnect bug36544_con4
+
+--echo #
+--echo # Switch to connection 'default'.
+--connection default
+--echo #
+--echo # Clean-up.
+drop user mysqluser1@localhost;
+drop user mysqluser10@localhost;
+drop user mysqluser11@localhost;
+drop database mysqltest1;
+
+
--echo End of 5.0 tests
#
@@ -1419,11 +1697,6 @@ GRANT CREATE ROUTINE ON dbbug33464.* TO 'userbug33464'@'localhost';
connect (connbug33464, localhost, userbug33464, , dbbug33464);
--source suite/funcs_1/include/show_connection.inc
---disable_warnings
-DROP PROCEDURE IF EXISTS sp3;
-DROP FUNCTION IF EXISTS fn1;
---enable_warnings
-
delimiter //;
CREATE PROCEDURE sp3(v1 char(20))
BEGIN
@@ -1526,6 +1799,34 @@ DROP USER 'user2';
DROP DATABASE db1;
+--echo #
+--echo # Bug #25863 No database selected error, but documentation
+--echo # says * for global allowed
+--echo #
+
+connect(conn1,localhost,root,,*NO-ONE*);
+
+--error ER_NO_DB_ERROR
+GRANT ALL ON * TO mysqltest_1;
+
+GRANT ALL ON *.* TO mysqltest_1;
+SHOW GRANTS FOR mysqltest_1;
+DROP USER mysqltest_1;
+
+USE test;
+
+GRANT ALL ON * TO mysqltest_1;
+SHOW GRANTS FOR mysqltest_1;
+DROP USER mysqltest_1;
+
+GRANT ALL ON *.* TO mysqltest_1;
+SHOW GRANTS FOR mysqltest_1;
+DROP USER mysqltest_1;
+
+connection default;
+disconnect conn1;
+
+
#
# Bug #53371: COM_FIELD_LIST can be abused to bypass table level grants.
#
@@ -1562,3 +1863,326 @@ flush privileges;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
+
+--echo #########################################################################
+--echo #
+--echo # Bug#38347: ALTER ROUTINE privilege allows SHOW CREATE TABLE.
+--echo #
+--echo #########################################################################
+
+--echo
+--echo # --
+--echo # -- Prepare the environment.
+--echo # --
+
+DELETE FROM mysql.user WHERE User LIKE 'mysqltest_%';
+DELETE FROM mysql.db WHERE User LIKE 'mysqltest_%';
+DELETE FROM mysql.tables_priv WHERE User LIKE 'mysqltest_%';
+DELETE FROM mysql.columns_priv WHERE User LIKE 'mysqltest_%';
+FLUSH PRIVILEGES;
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest_db1;
+--enable_warnings
+
+CREATE DATABASE mysqltest_db1;
+
+CREATE TABLE mysqltest_db1.t1(a INT);
+
+--echo
+--echo # --
+--echo # -- Check that global privileges don't allow SHOW CREATE TABLE.
+--echo # --
+
+GRANT EVENT ON mysqltest_db1.* TO mysqltest_u1@localhost;
+GRANT CREATE TEMPORARY TABLES ON mysqltest_db1.* TO mysqltest_u1@localhost;
+GRANT LOCK TABLES ON mysqltest_db1.* TO mysqltest_u1@localhost;
+GRANT ALTER ROUTINE ON mysqltest_db1.* TO mysqltest_u1@localhost;
+GRANT CREATE ROUTINE ON mysqltest_db1.* TO mysqltest_u1@localhost;
+GRANT EXECUTE ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+GRANT FILE ON *.* TO mysqltest_u1@localhost;
+GRANT CREATE USER ON *.* TO mysqltest_u1@localhost;
+GRANT PROCESS ON *.* TO mysqltest_u1@localhost;
+GRANT RELOAD ON *.* TO mysqltest_u1@localhost;
+GRANT REPLICATION CLIENT ON *.* TO mysqltest_u1@localhost;
+GRANT REPLICATION SLAVE ON *.* TO mysqltest_u1@localhost;
+GRANT SHOW DATABASES ON *.* TO mysqltest_u1@localhost;
+GRANT SHUTDOWN ON *.* TO mysqltest_u1@localhost;
+GRANT USAGE ON *.* TO mysqltest_u1@localhost;
+
+--echo
+SHOW GRANTS FOR mysqltest_u1@localhost;
+
+--echo
+--echo # connection: con1 (mysqltest_u1@mysqltest_db1)
+--connect (con1,localhost,mysqltest_u1,,mysqltest_db1)
+--connection con1
+
+--echo
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE TABLE t1;
+
+--echo
+--echo # connection: default
+--connection default
+
+--disconnect con1
+
+--echo
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
+SHOW GRANTS FOR mysqltest_u1@localhost;
+
+--echo
+--echo # --
+--echo # -- Check that global SELECT allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT SELECT ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global INSERT allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT INSERT ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global UPDATE allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT UPDATE ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global DELETE allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT DELETE ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global CREATE allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT CREATE ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global DROP allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT DROP ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global ALTER allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT ALTER ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global INDEX allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT INDEX ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global REFERENCES allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT REFERENCES ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global GRANT OPTION allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT GRANT OPTION ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global CREATE VIEW allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT CREATE VIEW ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that global SHOW VIEW allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT SHOW VIEW ON mysqltest_db1.* TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level SELECT allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT SELECT ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level INSERT allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT INSERT ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level UPDATE allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT UPDATE ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level DELETE allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT DELETE ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level CREATE allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT CREATE ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level DROP allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT DROP ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level ALTER allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT ALTER ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level INDEX allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT INDEX ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level REFERENCES allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT REFERENCES ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level GRANT OPTION allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT GRANT OPTION ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level CREATE VIEW allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT CREATE VIEW ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Check that table-level SHOW VIEW allows SHOW CREATE TABLE.
+--echo # --
+
+--echo
+GRANT SHOW VIEW ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
+
+--source include/bug38347.inc
+
+--echo
+--echo # --
+--echo # -- Cleanup.
+--echo # --
+
+--echo
+DROP DATABASE mysqltest_db1;
+
+DROP USER mysqltest_u1@localhost;
+
+--echo
+--echo # End of Bug#38347.
+--echo
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
index 447848013f9..6c2ba0dd6fc 100644
--- a/mysql-test/t/grant2.test
+++ b/mysql-test/t/grant2.test
@@ -31,7 +31,7 @@ create user mysqltest_2@localhost;
connect (user_a,localhost,mysqltest_1,,);
connection user_a;
grant select on `my\_1`.* to mysqltest_2@localhost;
---error ER_PASSWORD_NOT_ALLOWED
+--error ER_DBACCESS_DENIED_ERROR
grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
disconnect user_a;
connection default;
@@ -405,7 +405,7 @@ drop database mysqltest_1;
# But anonymous users can't change their password
connect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection n5;
---error ER_DBACCESS_DENIED_ERROR
+--error ER_PASSWORD_NO_MATCH
set password = password("changed");
disconnect n5;
connection default;
diff --git a/mysql-test/t/grant4.test b/mysql-test/t/grant4.test
new file mode 100644
index 00000000000..f3e551cd623
--- /dev/null
+++ b/mysql-test/t/grant4.test
@@ -0,0 +1,146 @@
+--source include/not_embedded.inc
+
+# Setup database, tables and user accounts
+--disable_warnings
+drop database if exists mysqltest_db1;
+--enable_warnings
+create database mysqltest_db1;
+use mysqltest_db1;
+create table t_column_priv_only (a int, b int);
+create table t_select_priv like t_column_priv_only;
+create table t_no_priv like t_column_priv_only;
+grant all privileges on test.* to mysqltest_u1@localhost;
+grant insert (a) on mysqltest_db1.t_column_priv_only to mysqltest_u1@localhost;
+grant select on mysqltest_db1.t_select_priv to mysqltest_u1@localhost;
+
+--echo ** Connect as restricted user mysqltest_u1.
+--echo
+connect (con1,localhost,mysqltest_u1,,);
+connection con1;
+
+########################################################################
+--echo ** Test column level privileges only. No SELECT privileges on the table.
+--echo ** INSERT INTO ... VALUES ...
+--echo ** Attempting to insert values to a table with only column privileges
+--echo ** should work.
+insert into mysqltest_db1.t_column_priv_only (a) VALUES (1);
+--echo
+
+#########################################################################
+--echo ** SHOW COLUMNS
+--echo ** Should succeed because we have privileges (any) on at least one of the columns.
+select column_name as 'Field',column_type as 'Type',is_nullable as 'Null',column_key as 'Key',column_default as 'Default',extra as 'Extra' from information_schema.columns where table_schema='mysqltest_db1' and table_name='t_column_priv_only';
+show columns from mysqltest_db1.t_column_priv_only;
+#########################################################################
+--echo ** SHOW COLUMNS
+--echo ** Should fail because there are no privileges on any column combination.
+--error 1142
+show columns from mysqltest_db1.t_no_priv;
+--echo ** However, select from I_S.COLUMNS will succeed but not show anything:
+select column_name as 'Field',column_type as 'Type',is_nullable as 'Null',column_key as 'Key',column_default as 'Default',extra as 'Extra' from information_schema.columns where table_schema='mysqltest_db1' and table_name='t_no_priv';
+--echo
+#########################################################################
+--echo ** CREATE TABLE ... LIKE ... require SELECT privleges and will fail.
+--error 1142
+create table test.t_no_priv like mysqltest_db1.column_priv_only;
+--echo
+#########################################################################
+--echo ** Just to be sure... SELECT also fails.
+--error 1142
+select * from mysqltest_db1.t_column_priv_only;
+--echo
+#########################################################################
+--echo ** SHOW CREATE TABLE ... require any privileges on all columns (the entire table).
+--echo ** First we try and fail on a table with only one column privilege.
+--error 1142
+show create table mysqltest_db1.t_column_priv_only;
+--echo
+#########################################################################
+--echo ** Now we do the same on a table with SELECT privileges.
+--echo
+#########################################################################
+--echo ** SHOW COLUMNS
+--echo ** Success because we got some privileges on the table (SELECT_ACL)
+show columns from mysqltest_db1.t_select_priv;
+--echo
+#########################################################################
+--echo ** CREATE TABLE ... LIKE ... require SELECT privleges and will SUCCEED.
+--disable_warnings
+drop table if exists test.t_duplicated;
+--enable_warnings
+create table test.t_duplicated like mysqltest_db1.t_select_priv;
+drop table test.t_duplicated;
+--echo
+#########################################################################
+--echo ** SHOW CREATE TABLE will succeed because we have a privilege on all columns in the table (table-level privilege).
+show create table mysqltest_db1.t_select_priv;
+--echo
+#########################################################################
+--echo ** SHOW CREATE TABLE will fail if there is no grants at all:
+--error 1142
+show create table mysqltest_db1.t_no_priv;
+--echo
+
+connection default;
+
+#
+# SHOW INDEX
+#
+use mysqltest_db1;
+CREATE TABLE t5 (s1 INT);
+CREATE INDEX i ON t5 (s1);
+CREATE TABLE t6 (s1 INT, s2 INT);
+CREATE VIEW v5 AS SELECT * FROM t5;
+CREATE VIEW v6 AS SELECT * FROM t6;
+CREATE VIEW v2 AS SELECT * FROM t_select_priv;
+CREATE VIEW v3 AS SELECT * FROM t_select_priv;
+CREATE INDEX i ON t6 (s1);
+GRANT UPDATE (s2) ON t6 to mysqltest_u1@localhost;
+GRANT UPDATE (s2) ON v6 to mysqltest_u1@localhost;
+GRANT SHOW VIEW ON v2 to mysqltest_u1@localhost;
+GRANT SHOW VIEW, SELECT ON v3 to mysqltest_u1@localhost;
+
+connection con1;
+use mysqltest_db1;
+--echo ** Connect as restricted user mysqltest_u1.
+--echo ** SELECT FROM INFORMATION_SCHEMA.STATISTICS will succeed because any privileges will do (authentication is enough).
+#
+# this result is wrong. reported as bug#34104
+#
+SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name='t5';
+#
+# Bug27145 EXTRA_ACL trouble
+#
+--echo ** SHOW INDEX FROM t5 will fail because we don't have any privileges on any column combination.
+--error 1142
+SHOW INDEX FROM t5;
+--echo ** SHOW INDEX FROM t6 will succeed because there exist a privilege on a column combination on t6.
+SHOW INDEX FROM t6;
+
+# CHECK TABLE
+--echo ** CHECK TABLE requires any privilege on any column combination and should succeed for t6:
+CHECK TABLE t6;
+--echo ** With no privileges access is naturally denied:
+--error 1142
+CHECK TABLE t5;
+
+# CHECKSUM
+--echo ** CHECKSUM TABLE requires SELECT privileges on the table. The following should fail:
+--error 1142
+CHECKSUM TABLE t6;
+--echo ** And this should work:
+CHECKSUM TABLE t_select_priv;
+
+# SHOW CREATE VIEW
+--error 1142
+SHOW CREATE VIEW v5;
+--error 1142
+SHOW CREATE VIEW v6;
+--error 1142
+SHOW CREATE VIEW v2;
+SHOW CREATE VIEW v3;
+
+connection default;
+disconnect con1;
+drop database mysqltest_db1;
+drop user mysqltest_u1@localhost;
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 580c2e5091c..0c2da4ae9f4 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -120,8 +120,9 @@ SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2
SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL;
SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
-drop table t1,t2;
+drop table t2;
unlock tables;
+drop table t1;
#
# Test of group by bug in bugzilla
@@ -1247,4 +1248,64 @@ ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1;
DROP TABLE t1;
+--echo #
+--echo # Bug#59839: Aggregation followed by subquery yields wrong result
+--echo #
+
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ c INT,
+ KEY (a, b)
+);
+
+INSERT INTO t1 VALUES
+ ( 1, 1, 1 ),
+ ( 1, 2, 2 ),
+ ( 1, 3, 3 ),
+ ( 1, 4, 6 ),
+ ( 1, 5, 5 ),
+ ( 1, 9, 13 ),
+
+ ( 2, 1, 6 ),
+ ( 2, 2, 7 ),
+ ( 2, 3, 8 );
+
+EXPLAIN
+SELECT a, AVG(t1.b),
+(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c,
+(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c
+FROM t1 GROUP BY a;
+
+SELECT a, AVG(t1.b),
+(SELECT t11.c FROM t1 t11 WHERE t11.a = t1.a AND t11.b = AVG(t1.b)) AS t11c,
+(SELECT t12.c FROM t1 t12 WHERE t12.a = t1.a AND t12.b = AVG(t1.b)) AS t12c
+FROM t1 GROUP BY a;
+
+DROP TABLE t1;
+
+
--echo # End of 5.1 tests
+
+--echo #
+--echo # Bug#49771: Incorrect MIN (date) when minimum value is 0000-00-00
+--echo #
+CREATE TABLE t1 (f1 int, f2 DATE);
+
+INSERT INTO t1 VALUES (1,'2004-04-19'), (1,'0000-00-00'), (1,'2004-04-18'),
+(2,'2004-05-19'), (2,'0001-01-01'), (3,'2004-04-10');
+
+SELECT MIN(f2),MAX(f2) FROM t1;
+SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 ( f1 int, f2 time);
+INSERT INTO t1 VALUES (1,'01:27:35'), (1,'06:11:01'), (2,'19:53:05'),
+(2,'21:44:25'), (3,'10:55:12'), (3,'05:45:11'), (4,'00:25:00');
+
+SELECT MIN(f2),MAX(f2) FROM t1;
+SELECT f1,MIN(f2),MAX(f2) FROM t1 GROUP BY 1;
+
+DROP TABLE t1;
+--echo #End of test#49771
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index 8ab7e1c9cb4..fa52da63195 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -570,13 +570,13 @@ explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
-explain extended select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
+explain extended select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
-select ord(a1) + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
+select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
#
# Queries with expressions in the select clause
@@ -1101,3 +1101,143 @@ DROP TABLE t1;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # WL#3220 (Loose index scan for COUNT DISTINCT)
+--echo #
+
+CREATE TABLE t1 (a INT, b INT, c INT, KEY (a,b));
+INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1), (1,4,1);
+INSERT INTO t1 SELECT a, b + 4, 1 FROM t1;
+INSERT INTO t1 SELECT a + 1, b, 1 FROM t1;
+CREATE TABLE t2 (a INT, b INT, c INT, d INT, e INT, f INT, KEY (a,b,c));
+INSERT INTO t2 VALUES (1,1,1,1,1,1), (1,2,1,1,1,1), (1,3,1,1,1,1),
+ (1,4,1,1,1,1);
+INSERT INTO t2 SELECT a, b + 4, c,d,e,f FROM t2;
+INSERT INTO t2 SELECT a + 1, b, c,d,e,f FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1;
+SELECT COUNT(DISTINCT a) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a,b) FROM t1;
+SELECT COUNT(DISTINCT a,b) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT b,a) FROM t1;
+SELECT COUNT(DISTINCT b,a) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT b) FROM t1;
+SELECT COUNT(DISTINCT b) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
+SELECT COUNT(DISTINCT a) FROM t1 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
+SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
+SELECT COUNT(DISTINCT a) FROM t1 GROUP BY b;
+
+EXPLAIN SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
+SELECT DISTINCT COUNT(DISTINCT a) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b + 0) FROM t1;
+SELECT COUNT(DISTINCT a, b + 0) FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
+SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10;
+
+EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
+SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10;
+
+EXPLAIN SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
+SELECT 1 FROM t1 HAVING COUNT(DISTINCT a) < 10;
+
+EXPLAIN SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
+SELECT 1 FROM t1 GROUP BY a HAVING COUNT(DISTINCT b) > 1;
+
+EXPLAIN SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
+SELECT COUNT(DISTINCT t1_1.a) FROM t1 t1_1, t1 t1_2 GROUP BY t1_1.a;
+
+EXPLAIN SELECT COUNT(DISTINCT a), 12 FROM t1;
+SELECT COUNT(DISTINCT a), 12 FROM t1;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b, c) FROM t2;
+SELECT COUNT(DISTINCT a, b, c) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
+SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT a) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
+SELECT COUNT(DISTINCT a), SUM(DISTINCT a), AVG(DISTINCT f) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, a) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, f) FROM t2;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
+SELECT COUNT(DISTINCT a, b), COUNT(DISTINCT b, d) FROM t2;
+
+EXPLAIN SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
+SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
+
+EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2
+ WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
+SELECT COUNT(DISTINCT c, a, b) FROM t2
+ WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
+
+EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5
+ GROUP BY b;
+SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 WHERE a = 5
+ GROUP BY b;
+
+EXPLAIN SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+SELECT a, COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+SELECT COUNT(DISTINCT b), SUM(DISTINCT b) FROM t2 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
+SELECT COUNT(DISTINCT a, b) FROM t2 WHERE c = 13 AND d = 42;
+
+EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
+ WHERE b = 13 AND c = 42 GROUP BY a;
+SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2
+ WHERE b = 13 AND c = 42 GROUP BY a;
+
+EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
+SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42;
+
+EXPLAIN SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
+SELECT SUM(DISTINCT a), MAX(b) FROM t2 GROUP BY a;
+
+EXPLAIN SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
+SELECT 42 * (a + c + COUNT(DISTINCT c, a, b)) FROM t2 GROUP BY a, b, c;
+
+EXPLAIN SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
+SELECT (SUM(DISTINCT a) + MAX(b)) FROM t2 GROUP BY a;
+
+DROP TABLE t1,t2;
+
+--echo # end of WL#3220 tests
+
+--echo #
+--echo # Bug#50539: Wrong result when loose index scan is used for an aggregate
+--echo # function with distinct
+--echo #
+CREATE TABLE t1 (
+ f1 int(11) NOT NULL DEFAULT '0',
+ f2 char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (f1,f2)
+) ;
+insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'),
+(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D');
+
+SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
+explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
+
+drop table t1;
+--echo # End of test#50539.
+
diff --git a/mysql-test/t/handler_read_last.test b/mysql-test/t/handler_read_last.test
new file mode 100644
index 00000000000..376829b9baf
--- /dev/null
+++ b/mysql-test/t/handler_read_last.test
@@ -0,0 +1,40 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, INDEX (a));
+INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),();
+
+FLUSH STATUS;
+SELECT a FROM t1 ORDER BY a LIMIT 1;
+SHOW STATUS LIKE 'HANDLER_READ%';
+
+FLUSH STATUS;
+SELECT a FROM t1 ORDER BY a DESC LIMIT 1;
+SHOW STATUS LIKE 'HANDLER_READ%';
+
+FLUSH STATUS;
+SELECT a FROM t1 ORDER BY a LIMIT 3;
+SHOW STATUS LIKE 'HANDLER_READ%';
+
+FLUSH STATUS;
+SELECT a FROM t1 ORDER BY a DESC LIMIT 3;
+SHOW STATUS LIKE 'HANDLER_READ%';
+
+DROP TABLE t1;
+
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index c808e747523..2ed8b40b858 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -564,4 +564,30 @@ HAVING field1 < 7;
DROP TABLE t1,t2;
+--echo #
+--echo # Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause
+--echo #
+
+CREATE TABLE t1 (f1 INT, f2 INT);
+INSERT INTO t1 VALUES (1, 0), (2, 1), (3, 2);
+CREATE TABLE t2 (f1 INT, f2 INT);
+
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT f1, f2 FROM t2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+
+SELECT t1.f1
+FROM t1
+HAVING (3, 2) IN (SELECT 4, 2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+
+SELECT t1.f1
+FROM t1
+HAVING 2 IN (SELECT f2 FROM t2) AND t1.f1 >= 0
+ORDER BY t1.f1;
+
+DROP TABLE t1,t2;
+
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test
index 1e3491f89a9..748347021fc 100644
--- a/mysql-test/t/heap_hash.test
+++ b/mysql-test/t/heap_hash.test
@@ -284,3 +284,20 @@ INSERT INTO t1 VALUES('A ', 'A ');
DROP TABLE t1;
--echo End of 5.0 tests
+
+--echo #
+--echo # Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c
+--echo # on DELETE statement
+--echo #
+
+CREATE TABLE t1 (col_int_nokey INT,
+ col_int_key INT,
+ INDEX(col_int_key) USING HASH) ENGINE = HEAP;
+INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1);
+
+DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2;
+
+DROP TABLE t1;
+
+--echo End of 5.5 tests
+
diff --git a/mysql-test/t/implicit_char_to_num_conversion.test b/mysql-test/t/implicit_char_to_num_conversion.test
new file mode 100644
index 00000000000..f3da83ff2c1
--- /dev/null
+++ b/mysql-test/t/implicit_char_to_num_conversion.test
@@ -0,0 +1,174 @@
+########### implicit_char_to_num_conversion.test #######################
+# #
+# This test aims at using string/char literal in comparison operators #
+# without explicit type-cast. This is a bug test for Bug#11766521 #
+# - Incorrect result is returned if string/char literal is used with #
+# comparision operator and bit data type column. Test is extended to #
+# include numeric data type comparison with string/char literal #
+# #
+# #
+# Creation: #
+# 2011-05-10 vfisrekar Implement this test as part of Bug#11766521 #
+# #
+########################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t5;
+--enable_warnings
+
+let $default_engine = `select @@SESSION.default_storage_engine`;
+
+# Bug#11766521 - BIT Datatype comparison in where clause return incorrect
+# result for '=' , '<=>' operators
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 BIT(2) PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (0), (1), (2);
+SELECT HEX(c1) FROM t5 ORDER BY c1;
+# Enable Following two select after Bug#11766521 fix
+# SELECT HEX(c1) FROM t5 WHERE c1 = '1' ORDER BY c1;
+# SELECT HEX(c1) FROM t5 WHERE c1 <=> '1' ORDER BY c1;
+SELECT HEX(c1) FROM t5 WHERE c1 = b'1' ORDER BY c1;
+SELECT HEX(c1) FROM t5 WHERE c1 <=> b'1' ORDER BY c1;
+SELECT HEX(c1) FROM t5 WHERE c1 != b'1' ORDER BY c1;
+SELECT HEX(c1) FROM t5 WHERE c1 >= '1' ORDER BY c1;
+SELECT HEX(c1) FROM t5 WHERE c1 <= '1' ORDER BY c1;
+SELECT HEX(c1) FROM t5 WHERE c1 < '1' ORDER BY c1;
+SELECT HEX(c1) FROM t5 WHERE c1 > '0' ORDER BY c1;
+DROP TABLE t5;
+
+# FLOAT Data-type
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 FLOAT(5,2) PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (95.95), (-10.10), (1), (0);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+# Following two queries does not return result may be due to Bug#11766521.
+# Enable them after Bug#11766521 fix.
+# SELECT c1 FROM t5 WHERE c1 = '10.10' ORDER BY c1;
+# SELECT c1 FROM t5 WHERE c2 <=> '11.11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '10.10' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '1' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '1' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '0' ORDER BY c1;
+DROP TABLE t5;
+
+# TINYINT Datatype
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 TINYINT PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (95), (10),(11),(-8);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '10' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '10' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '-8' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '10' ORDER BY c1;
+DROP TABLE t5;
+
+# SMALLINT Datatype
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 SMALLINT PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (395), (-200), (100), (111);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '100' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '100' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '395' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '-200' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '100' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '111' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '111' ORDER BY c1;
+DROP TABLE t5;
+
+# MEDIUMINT Datatype
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 MEDIUMINT PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (-8388607), (311),(215),(88608);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '311' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '311' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '215' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '88608' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '-8388607' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '215' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '215' ORDER BY c1;
+DROP TABLE t5;
+
+# INT Datatype
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 INT PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (-2147483647), (1011),(15),(9388607);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '9388607' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '9388607' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '15' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '1011' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '-2147483647' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '15' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '15' ORDER BY c1;
+DROP TABLE t5;
+
+# BIGINT Data-type
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 BIGINT PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (-9223372036854775807), (12011),(500),(3372036854775808);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '-9223372036854775807' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '-9223372036854775807' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '12011' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '500' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '3372036854775808' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '12011' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '12011' ORDER BY c1;
+DROP TABLE t5;
+
+# DOUBLE Datatype
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 DOUBLE(5,2) PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
+DROP TABLE t5;
+
+# NUMERIC Datatype
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 NUMERIC(5,2) PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
+DROP TABLE t5;
+
+# DECIMAL Datatype
+--replace_result $default_engine <default_engine>
+eval CREATE TABLE t5(c1 DECIMAL(5,2) PRIMARY KEY) ENGINE = $default_engine;
+INSERT INTO t5 VALUES (95.95), (11.11),(5),(-908.92);
+SELECT c1 FROM t5 ORDER BY c1;
+# Compare with string literal
+SELECT c1 FROM t5 WHERE c1 = '11.11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <=> '11.11' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 >= '5' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 <= '95.95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 != '-908.92' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 < '95.95' ORDER BY c1;
+SELECT c1 FROM t5 WHERE c1 > '-908.92' ORDER BY c1;
+DROP TABLE t5;
diff --git a/mysql-test/t/implicit_commit-master.opt b/mysql-test/t/implicit_commit-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/implicit_commit-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/implicit_commit.test b/mysql-test/t/implicit_commit.test
new file mode 100644
index 00000000000..b10788bd891
--- /dev/null
+++ b/mysql-test/t/implicit_commit.test
@@ -0,0 +1,1166 @@
+source include/have_innodb.inc;
+source include/not_embedded.inc;
+
+SET GLOBAL EVENT_SCHEDULER = OFF;
+SET BINLOG_FORMAT = STATEMENT;
+
+LET $OLD_DB= `SELECT DATABASE()`;
+
+CREATE DATABASE db1;
+USE db1;
+CREATE TABLE t1 (a INT, KEY a(a)) ENGINE=INNODB;
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
+CREATE TABLE t3 (a INT) ENGINE=MyISAM;
+INSERT INTO t3 SELECT * FROM t1;
+CREATE TABLE trans (a INT) ENGINE=INNODB;
+
+DELIMITER |;
+
+CREATE PROCEDURE test_if_commit()
+BEGIN
+ ROLLBACK;
+ SELECT IF (COUNT(*) > 0, "YES", "NO") AS "IMPLICIT COMMIT" FROM trans;
+ DELETE FROM trans;
+ COMMIT;
+END|
+
+DELIMITER ;|
+
+SET AUTOCOMMIT = FALSE;
+
+--echo #
+--echo # SQLCOM_SELECT
+--echo #
+
+let $statement=
+ select 1 as res from t1 where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_TABLE LIKE
+--echo #
+
+let $statement=
+ create table t2 like t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_CREATE
+--echo #
+
+let $statement=
+ show create table t2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_TABLE
+--echo #
+
+let $statement=
+ drop table t2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_TABLE TEMPORARY
+--echo #
+
+let $statement=
+ create temporary table t2 as select * from t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_TABLE TEMPORARY
+--echo #
+
+let $statement=
+ drop temporary table t2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_TABLE
+--echo #
+
+let $statement=
+ create table t2 as select * from t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_UPDATE
+--echo #
+
+let $statement=
+ update t2 set a=a+1 where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_INSERT
+--echo #
+
+let $statement=
+ insert into t2 set a=((1) in (select * from t1));
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_INSERT_SELECT
+--echo #
+
+let $statement=
+ insert into t2 select * from t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_REPLACE
+--echo #
+
+let $statement=
+ replace t2 set a=((1) in (select * from t1));
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_REPLACE_SELECT
+--echo #
+
+let $statement=
+ replace t2 select * from t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DELETE
+--echo #
+
+let $statement=
+ delete from t2 where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DELETE_MULTI
+--echo #
+
+let $statement=
+ delete t2, t3 from t2, t3 where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_UPDATE_MULTI
+--echo #
+
+select * from t2;
+let $statement=
+ update t2, t3 set t3.a=t2.a, t2.a=null where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_LOAD
+--echo #
+
+create table t4 (a varchar(100));
+
+let $statement=
+ load data infile '../../std_data/words.dat' into table t4;
+source include/implicit_commit_helper.inc;
+
+drop table t4;
+
+--echo #
+--echo # SQLCOM_SHOW_DATABASES
+--echo #
+
+let $statement=
+ show databases where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_TABLES
+--echo #
+
+let $statement=
+ show tables where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_FIELDS
+--echo #
+
+let $statement=
+ show fields from t1 where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_KEYS
+--echo #
+
+let $statement=
+ show keys from t1 where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_VARIABLES
+--echo #
+
+let $statement=
+ show variables where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_STATUS
+--echo #
+
+let $statement=
+ show status where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_ENGINE_MUTEX
+--echo #
+
+let $statement=
+ show engine all mutex;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_PROCESSLIST
+--echo #
+
+let $statement=
+ show processlist;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_ENGINE_LOGS
+--echo #
+
+let $statement=
+ show engine all logs;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_ENGINE_STATUS
+--echo #
+
+let $statement=
+ show engine all status;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_CHARSETS
+--echo #
+
+let $statement=
+ show charset where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_COLLATIONS
+--echo #
+
+let $statement=
+ show collation where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_TABLE_STATUS
+--echo #
+
+let $statement=
+ show table status where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_TRIGGERS
+--echo #
+
+let $statement=
+ show triggers where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_OPEN_TABLES
+--echo #
+
+let $statement=
+ show open tables where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_STATUS_PROC
+--echo #
+
+let $statement=
+ show procedure status where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_STATUS_FUNC
+--echo #
+
+let $statement=
+ show function status where (1) in (select * from t1);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SET_OPTION
+--echo #
+
+let $statement=
+ set @a=((1) in (select * from t1));
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DO
+--echo #
+
+let $statement=
+ do ((1) in (select * from t1));
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CALL
+--echo #
+
+create procedure p1(a int) begin end;
+
+let $statement=
+ call p1((1) in (select * from t1));
+source include/implicit_commit_helper.inc;
+
+drop procedure p1;
+
+--echo #
+--echo # SQLCOM_CREATE_VIEW
+--echo #
+
+let $statement=
+ create view v1 as select * from t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_VIEW
+--echo #
+
+let $statement=
+ alter view v1 as select 2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_VIEW
+--echo #
+
+let $statement=
+ drop view v1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_INDEX
+--echo #
+
+let $statement=
+ create index idx1 on t1(a);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_INDEX
+--echo #
+
+let $statement=
+ drop index idx1 on t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_TABLE
+--echo #
+
+let $statement=
+ alter table t1 add column b int;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ alter table t1 change b c int;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ alter table t1 drop column c;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_TABLE TEMPORARY
+--echo #
+
+create temporary table t4 (a int);
+
+let $statement=
+ alter table t1 add column b int;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ alter table t1 change b c int;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ alter table t1 drop column c;
+source include/implicit_commit_helper.inc;
+
+drop table t4;
+
+--echo #
+--echo # SQLCOM_TRUNCATE
+--echo #
+
+insert into t2 select * from t1;
+let $statement=
+ truncate table t2;
+source include/implicit_commit_helper.inc;
+insert into t2 select * from t1;
+
+--echo #
+--echo # SQLCOM_TRUNCATE TEMPORARY
+--echo #
+
+create temporary table t4 as select * from t1;
+let $statement=
+ truncate table t4;
+source include/implicit_commit_helper.inc;
+drop temporary table t4;
+
+--echo #
+--echo # SQLCOM_SHOW_MASTER_STAT
+--echo #
+
+let $statement=
+ show master status;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_SLAVE_STAT
+--echo #
+
+let $statement=
+ show slave status;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_GRANT
+--echo #
+
+let $statement=
+ grant all on test.t1 to mysqltest_2@localhost with grant option;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_REVOKE
+--echo #
+let $statement=
+ revoke select on test.t1 from mysqltest_2@localhost;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_REVOKE_ALL
+--echo #
+
+let $statement=
+ revoke all on test.t1 from mysqltest_2@localhost;
+source include/implicit_commit_helper.inc;
+
+drop user mysqltest_2@localhost;
+
+--echo #
+--echo # SQLCOM_SHOW_GRANTS
+--echo #
+
+let $statement=
+ show grants;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ show grants for current_user();
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_LOCK_TABLES
+--echo #
+
+let $statement=
+ lock tables t1 write, trans write;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_UNLOCK_TABLES
+--echo #
+
+let $statement=
+ unlock tables;
+source include/implicit_commit_helper.inc;
+
+#
+# Missing test for lock tables transactional.
+#
+
+--echo #
+--echo # SQLCOM_CREATE_DB
+--echo #
+
+let $statement=
+ create database db2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CHANGE_DB
+--echo #
+
+create table db2.t1 (a int);
+insert into db2.t1 values (1);
+commit;
+
+let $statement=
+ use db2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_CREATE_DB
+--echo #
+
+let $statement=
+ show create database db2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_DB
+--echo #
+
+#let $statement=
+# alter database db2 character set koi8r;
+#source include/implicit_commit_helper.inc;
+
+#let $statement=
+# alter database db2 collate cp1251_general_cs;
+#source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_DB_UPGRADE
+--echo #
+
+#let $statement=
+# alter database `#mysql50#db3` upgrade data directory name;
+#source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_DB
+--echo #
+
+use db1;
+
+let $statement=
+ drop database db2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_REPAIR
+--echo #
+
+let $statement=
+ repair table t2;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ repair table t2 use_frm;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_OPTIMIZE
+--echo #
+
+let $statement=
+ optimize table t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CHECK
+--echo #
+
+let $statement=
+ check table t1;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ check table t1 extended;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ASSIGN_TO_KEYCACHE
+--echo #
+
+set global keycache.key_buffer_size=128*1024;
+
+let $statement=
+ cache index t3 in keycache;
+source include/implicit_commit_helper.inc;
+
+set global keycache.key_buffer_size=0;
+
+--echo #
+--echo # SQLCOM_PRELOAD_KEYS
+--echo #
+
+let $statement=
+ load index into cache t3;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_FLUSH
+--echo #
+
+let $statement=
+ flush local privileges;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ flush privileges;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_KILL
+--echo #
+
+--echo #
+--echo # SQLCOM_ANALYZE
+--echo #
+
+let $statement=
+ analyze table t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ROLLBACK
+--echo #
+
+let $statement=
+ rollback;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ROLLBACK_TO_SAVEPOINT
+--echo #
+
+
+--echo #
+--echo # SQLCOM_COMMIT
+--echo #
+
+let $statement=
+ commit;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SAVEPOINT
+--echo #
+
+let $statement=
+ savepoint sp1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_RELEASE_SAVEPOINT
+--echo #
+
+--echo #
+--echo # SQLCOM_SLAVE_START
+--echo #
+
+--echo #
+--echo # SQLCOM_SLAVE_STOP
+--echo #
+
+--echo #
+--echo # SQLCOM_BEGIN
+--echo #
+
+let $statement=
+ begin;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CHANGE_MASTER
+--echo #
+
+--echo #
+--echo # SQLCOM_RENAME_TABLE
+--echo #
+
+let $statement=
+ rename table t3 to t4;
+source include/implicit_commit_helper.inc;
+
+let $statement=
+ rename table t4 to t3;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_RESET
+--echo #
+
+let $statement=
+ reset query cache;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_PURGE
+--echo #
+
+--echo #
+--echo # SQLCOM_PURGE_BEFORE
+--echo #
+
+--echo #
+--echo # SQLCOM_SHOW_BINLOGS
+--echo #
+
+--echo #
+--echo # SQLCOM_HA_OPEN
+--echo #
+
+let $statement=
+ handler t1 open as ha1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_HA_READ
+--echo #
+
+let $statement=
+ handler ha1 read a first;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_HA_CLOSE
+--echo #
+
+let $statement=
+ handler ha1 close;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_SLAVE_HOSTS
+--echo #
+
+let $statement=
+ show slave hosts;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_BINLOG_EVENTS
+--echo #
+
+let $statement=
+ show binlog events;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_NEW_MASTER
+--echo #
+
+--echo #
+--echo # SQLCOM_SHOW_WARNS
+--echo #
+
+let $statement=
+ show warnings;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_EMPTY_QUERY
+--echo #
+
+--echo #
+--echo # SQLCOM_SHOW_ERRORS
+--echo #
+
+let $statement=
+ show errors;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_STORAGE_ENGINES
+--echo #
+
+let $statement=
+ show engines;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_PRIVILEGES
+--echo #
+
+let $statement=
+ show privileges;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_HELP
+--echo #
+
+let $statement=
+ help 'foo';
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_USER
+--echo #
+
+let $statement=
+ create user trxusr1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_RENAME_USER
+--echo #
+
+let $statement=
+ rename user 'trxusr1' to 'trxusr2';
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_USER
+--echo #
+
+let $statement=
+ drop user trxusr2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CHECKSUM
+--echo #
+
+let $statement=
+ checksum table t1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_PROCEDURE
+--echo #
+
+let $statement=
+ create procedure p1(a int) begin end;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_PROCEDURE
+--echo #
+
+let $statement=
+ alter procedure p1 comment 'foobar';
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_CREATE_PROC
+--echo #
+
+let $statement=
+ show create procedure p1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_STATUS_PROC
+--echo #
+
+let $statement=
+ show procedure status;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_PROC_CODE
+--echo #
+
+#
+# Available only on servers with debugging support.
+#
+
+--disable_abort_on_error
+let $statement=
+ show procedure code p1;
+source include/implicit_commit_helper.inc;
+--enable_abort_on_error
+
+--echo #
+--echo # SQLCOM_DROP_PROCEDURE
+--echo #
+
+let $statement=
+ drop procedure p1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_FUNCTION
+--echo #
+
+--echo #
+--echo # SQLCOM_DROP_FUNCTION
+--echo #
+
+--echo #
+--echo # SQLCOM_CREATE_SPFUNCTION
+--echo #
+
+let $statement=
+ create function f1() returns int return 69;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_FUNCTION
+--echo #
+
+let $statement=
+ alter function f1 comment 'comment';
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_CREATE_FUNC
+--echo #
+
+let $statement=
+ show create function f1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_STATUS_FUNC
+--echo #
+
+let $statement=
+ show function status like '%f%';
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_FUNC_CODE
+--echo #
+
+#
+# Available only on servers with debugging support.
+#
+
+--disable_abort_on_error
+let $statement=
+ show function code f1;
+source include/implicit_commit_helper.inc;
+--enable_abort_on_error
+
+--echo #
+--echo # SQLCOM_PREPARE
+--echo #
+
+let $statement=
+ prepare stmt1 from "insert into t1 values (5)";
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_EXECUTE
+--echo #
+
+let $statement=
+ execute stmt1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DEALLOCATE_PREPARE
+--echo #
+
+let $statement=
+ deallocate prepare stmt1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_TRIGGER
+--echo #
+
+let $statement=
+ create trigger trg1 before insert on t1 for each row set @a:=1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_CREATE_TRIGGER
+--echo #
+
+let $statement=
+ show create trigger trg1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_TRIGGER
+--echo #
+
+let $statement=
+ drop trigger trg1;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_XA_START
+--echo #
+
+--echo #
+--echo # SQLCOM_XA_END
+--echo #
+
+--echo #
+--echo # SQLCOM_XA_PREPARE
+--echo #
+
+--echo #
+--echo # SQLCOM_XA_COMMIT
+--echo #
+
+--echo #
+--echo # SQLCOM_XA_ROLLBACK
+--echo #
+
+--echo #
+--echo # SQLCOM_XA_RECOVER
+--echo #
+
+--echo #
+--echo # SQLCOM_ALTER_TABLESPACE
+--echo #
+
+--echo #
+--echo # SQLCOM_INSTALL_PLUGIN
+--echo #
+
+--echo #
+--echo # SQLCOM_SHOW_PLUGINS
+--echo #
+
+--echo #
+--echo # SQLCOM_UNINSTALL_PLUGIN
+--echo #
+
+--echo #
+--echo # SQLCOM_SHOW_AUTHORS
+--echo #
+
+let $statement=
+ show authors;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_BINLOG_BASE64_EVENT
+--echo #
+
+--echo #
+--echo # SQLCOM_SHOW_CONTRIBUTORS
+--echo #
+
+let $statement=
+ show contributors;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_CREATE_SERVER
+--echo #
+
+--echo #
+--echo # SQLCOM_ALTER_SERVER
+--echo #
+
+--echo #
+--echo # SQLCOM_DROP_SERVER
+--echo #
+
+--echo #
+--echo # SQLCOM_CREATE_EVENT
+--echo #
+
+let $statement=
+ create event ev1 on schedule every 1 second do insert into t1 values (6);
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_ALTER_EVENT
+--echo #
+
+let $statement=
+ alter event ev1 rename to ev2 disable;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_CREATE_EVENT
+--echo #
+
+let $statement=
+ show create event ev2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_EVENTS
+--echo #
+
+let $statement=
+ show events;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_DROP_EVENT
+--echo #
+
+let $statement=
+ drop event ev2;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_BACKUP
+--echo #
+
+#create database backup_db;
+#
+#let $statement=
+# backup database db1 to 'backup_db1.ba';
+#source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_ARCHIVE
+--echo #
+
+#
+# --error ER_NOT_ALLOWED_COMMAND
+#
+#let $statement=
+# show backup 'backup_db1.ba';
+#source include/implicit_commit_helper.inc;
+#
+
+--echo #
+--echo # SQLCOM_RESTORE
+--echo #
+
+#let $statement=
+# restore from 'backup_db1.ba';
+#source include/implicit_commit_helper.inc;
+
+#--remove_file $MYSQLTEST_VARDIR/master-data/backup_db1.ba
+#
+#drop database backup_db;
+
+--echo #
+--echo # SQLCOM_BACKUP_TEST
+--echo #
+
+# BACKUP_TEST
+
+--echo #
+--echo # SQLCOM_SHOW_PROFILE
+--echo #
+
+let $statement=
+ show profile memory;
+source include/implicit_commit_helper.inc;
+
+--echo #
+--echo # SQLCOM_SHOW_PROFILES
+--echo #
+
+let $statement=
+ show profiles;
+source include/implicit_commit_helper.inc;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+eval USE $OLD_DB;
+DROP DATABASE db1;
+
+--echo End of tests
diff --git a/mysql-test/t/index_merge_innodb.test b/mysql-test/t/index_merge_innodb.test
index a3bda0ad00c..10d772797a2 100644
--- a/mysql-test/t/index_merge_innodb.test
+++ b/mysql-test/t/index_merge_innodb.test
@@ -12,17 +12,19 @@
--source include/have_innodb.inc
let $engine_type= InnoDB;
+# According to Oracle: "InnoDB's estimate for the index cardinality
+# depends on a pseudo random number generator (it picks up random
+# pages to sample). After an optimization that was made in r2625 two
+# EXPLAINs started returning a different number of rows (3 instead of
+# 4)", so:
+let $index_merge_random_rows_in_EXPLAIN = 1;
# InnoDB does not support Merge tables (affects include/index_merge1.inc)
let $merge_table_support= 0;
-# The first two tests are disabled because of non deterministic explain output.
-# If include/index_merge1.inc can be enabled for InnoDB and all other
-# storage engines, please remove the subtest for Bug#21277 from
-# include/index_merge2.inc.
-# This test exists already in include/index_merge1.inc.
+# -- [DISABLED Bug#45727]
# --source include/index_merge1.inc
# --source include/index_merge_ror.inc
+# --source include/index_merge2.inc
---source include/index_merge2.inc
--source include/index_merge_2sweeps.inc
--source include/index_merge_ror_cpk.inc
diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test
index dccaecef20a..86195cc3cd9 100644
--- a/mysql-test/t/index_merge_myisam.test
+++ b/mysql-test/t/index_merge_myisam.test
@@ -36,7 +36,6 @@ select @@optimizer_switch;
set optimizer_switch='default,index_merge_sort_union=off';
select @@optimizer_switch;
---error ER_WRONG_VALUE_FOR_VAR
set optimizer_switch=4;
--error ER_WRONG_VALUE_FOR_VAR
diff --git a/mysql-test/t/information_schema-big.test b/mysql-test/t/information_schema-big.test
new file mode 100644
index 00000000000..c9cd65f0851
--- /dev/null
+++ b/mysql-test/t/information_schema-big.test
@@ -0,0 +1,48 @@
+# This test uses grants, which can't get tested for embedded server
+-- source include/big_test.inc
+-- source include/not_embedded.inc
+
+# check that CSV engine was compiled in, as the result of the test depends
+# on the presence of the log tables (which are CSV-based).
+--source include/have_csv.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+
+--echo #
+--echo # Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
+--echo #
+
+SELECT t.table_name, c1.column_name
+ FROM information_schema.tables t
+ INNER JOIN
+ information_schema.columns c1
+ ON t.table_schema = c1.table_schema AND
+ t.table_name = c1.table_name
+ WHERE t.table_schema = 'information_schema' AND
+ c1.ordinal_position =
+ ( SELECT COALESCE(MIN(c2.ordinal_position),1)
+ FROM information_schema.columns c2
+ WHERE c2.table_schema = t.table_schema AND
+ c2.table_name = t.table_name AND
+ c2.column_name LIKE '%SCHEMA%'
+ )
+ AND t.table_name NOT LIKE 'innodb%';
+SELECT t.table_name, c1.column_name
+ FROM information_schema.tables t
+ INNER JOIN
+ information_schema.columns c1
+ ON t.table_schema = c1.table_schema AND
+ t.table_name = c1.table_name
+ WHERE t.table_schema = 'information_schema' AND
+ c1.ordinal_position =
+ ( SELECT COALESCE(MIN(c2.ordinal_position),1)
+ FROM information_schema.columns c2
+ WHERE c2.table_schema = 'information_schema' AND
+ c2.table_name = t.table_name AND
+ c2.column_name LIKE '%SCHEMA%'
+ )
+ AND t.table_name NOT LIKE 'innodb%';
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 1fa4d6da600..589bb898d6a 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -1,6 +1,9 @@
# This test uses grants, which can't get tested for embedded server
-- source include/not_embedded.inc
+#Don't run this test when thread_pool active
+--source include/not_threadpool.inc
+
# check that CSV engine was compiled in, as the result of the test depends
# on the presence of the log tables (which are CSV-based).
--source include/have_csv.inc
@@ -44,8 +47,7 @@ insert into t5 values (10);
create view v1 (c) as
SELECT table_name FROM information_schema.TABLES
WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
- table_name<>'ndb_binlog_index' AND
- table_name<>'ndb_apply_status';
+ table_name not like 'ndb_%' AND table_name not like 'innodb_%';
select * from v1;
select c,table_name from v1
@@ -367,7 +369,7 @@ show tables from information_schema like "T%";
create database information_schema;
use information_schema;
show full tables like "T%";
---error ER_UNKNOWN_TABLE
+--error ER_DBACCESS_DENIED_ERROR
create table t1(a int);
use test;
show tables;
@@ -491,7 +493,7 @@ select table_schema,table_name, column_name from
information_schema.columns
where data_type = 'longtext';
select table_name, column_name, data_type from information_schema.columns
-where data_type = 'datetime';
+where data_type = 'datetime' and table_name not like 'innodb_%';
#
# Bug#8164 subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
@@ -539,7 +541,11 @@ flush privileges;
# Bug#9404 information_schema: Weird error messages
# with SELECT SUM() ... GROUP BY queries
#
-SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
+SELECT table_schema, count(*) FROM information_schema.TABLES WHERE
+table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest')
+AND table_name not like 'ndb%' AND table_name not like 'innodb_%'
+GROUP BY TABLE_SCHEMA;
+
#
@@ -912,41 +918,8 @@ DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
#
-# Bug#18925 subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
-#
-
-SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
- information_schema.columns c1
- ON t.table_schema = c1.table_schema AND
- t.table_name = c1.table_name
- WHERE t.table_schema = 'information_schema' AND
- c1.ordinal_position =
- ( SELECT COALESCE(MIN(c2.ordinal_position),1)
- FROM information_schema.columns c2
- WHERE c2.table_schema = t.table_schema AND
- c2.table_name = t.table_name AND
- c2.column_name LIKE '%SCHEMA%'
- );
-SELECT t.table_name, c1.column_name
- FROM information_schema.tables t
- INNER JOIN
- information_schema.columns c1
- ON t.table_schema = c1.table_schema AND
- t.table_name = c1.table_name
- WHERE t.table_schema = 'information_schema' AND
- c1.ordinal_position =
- ( SELECT COALESCE(MIN(c2.ordinal_position),1)
- FROM information_schema.columns c2
- WHERE c2.table_schema = 'information_schema' AND
- c2.table_name = t.table_name AND
- c2.column_name LIKE '%SCHEMA%'
- );
-
-#
-# Bug#2123 query with a simple non-correlated subquery over
-# INFORMARTION_SCHEMA.TABLES
+# Bug#21231 query with a simple non-correlated subquery over
+# INFORMARTION_SCHEMA.TABLES
#
SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test');
@@ -1041,6 +1014,7 @@ where t.table_schema = 'information_schema' and
c2.table_schema='information_schema' and
(c2.column_type = 'varchar(7)' or c2.column_type = 'varchar(20)')
group by c2.column_type order by num limit 1)
+ and t.table_name not like 'innodb_%'
group by t.table_name order by num1, t.table_name;
#
@@ -1473,6 +1447,167 @@ DROP TABLE ubig;
--echo End of 5.1 tests.
+--echo #
+--echo # Additional test for WL#3726 "DDL locking for all metadata objects"
+--echo # To avoid possible deadlocks process of filling of I_S tables should
+--echo # use high-priority metadata lock requests when opening tables.
+--echo # Below we just test that we really use high-priority lock request
+--echo # since reproducing a deadlock will require much more complex test.
+--echo #
+--disable_warnings
+drop tables if exists t1, t2, t3;
+--enable_warnings
+create table t1 (i int);
+create table t2 (j int primary key auto_increment);
+connect (con3726_1,localhost,root,,test);
+--echo # Switching to connection 'con3726_1'
+connection con3726_1;
+lock table t2 read;
+connect (con3726_2,localhost,root,,test);
+--echo # Switching to connection 'con3726_2'
+connection con3726_2;
+--echo # RENAME below will be blocked by 'lock table t2 read' above but
+--echo # will add two pending requests for exclusive metadata locks.
+--send rename table t2 to t3
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info like "rename table t2 to t3";
+--source include/wait_condition.inc
+--echo # These statements should not be blocked by pending lock requests
+select table_name, column_name, data_type from information_schema.columns
+ where table_schema = 'test' and table_name in ('t1', 't2');
+select table_name, auto_increment from information_schema.tables
+ where table_schema = 'test' and table_name in ('t1', 't2');
+--echo # Switching to connection 'con3726_1'
+connection con3726_1;
+unlock tables;
+--echo # Switching to connection 'con3726_2'
+connection con3726_2;
+--reap
+--echo # Switching to connection 'default'
+connection default;
+disconnect con3726_1;
+disconnect con3726_2;
+drop tables t1, t3;
+
+#
+# Bug#39270 I_S optimization algorithm does not work properly in some cases
+#
+EXPLAIN SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;
+EXPLAIN SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
+EXPLAIN SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
+ WHERE CONSTRAINT_SCHEMA='test';
+EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
+ WHERE TABLE_NAME='t1' and TABLE_SCHEMA='test';
+EXPLAIN SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
+ WHERE EVENT_OBJECT_SCHEMA='test';
+
+#
+# Bug#24062 Incorrect error msg after execute DROP TABLE IF EXISTS on information_schema
+#
+--error ER_DBACCESS_DENIED_ERROR
+create table information_schema.t1 (f1 INT);
+--error ER_DBACCESS_DENIED_ERROR
+drop table information_schema.t1;
+--error ER_DBACCESS_DENIED_ERROR
+drop temporary table if exists information_schema.t1;
+--error ER_DBACCESS_DENIED_ERROR
+create temporary table information_schema.t1 (f1 INT);
+--error ER_DBACCESS_DENIED_ERROR
+drop view information_schema.v1;
+--error ER_DBACCESS_DENIED_ERROR
+create view information_schema.v1;
+--error ER_DBACCESS_DENIED_ERROR
+create trigger mysql.trg1 after insert on information_schema.t1 for each row set @a=1;
+--error 1109
+create table t1 select * from information_schema.t1;
+
+CREATE TABLE t1(f1 char(100));
+--error ER_DBACCESS_DENIED_ERROR
+REPAIR TABLE t1, information_schema.tables;
+CHECKSUM TABLE t1, information_schema.tables;
+--error ER_DBACCESS_DENIED_ERROR
+ANALYZE TABLE t1, information_schema.tables;
+CHECK TABLE t1, information_schema.tables;
+--error ER_DBACCESS_DENIED_ERROR
+OPTIMIZE TABLE t1, information_schema.tables;
+--error ER_DBACCESS_DENIED_ERROR
+RENAME TABLE v1 to v2, information_schema.tables to t2;
+--error ER_DBACCESS_DENIED_ERROR
+DROP TABLE t1, information_schema.tables;
+
+--error ER_DBACCESS_DENIED_ERROR
+LOCK TABLES t1 READ, information_schema.tables READ;
+DROP TABLE t1;
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
+#
+# Bug #43834 Assertion in Natural_join_column::db_name() on an I_S query
+#
+
+SELECT *
+FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
+LEFT JOIN INFORMATION_SCHEMA.COLUMNS
+USING (TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME)
+WHERE COLUMNS.TABLE_SCHEMA = 'test'
+AND COLUMNS.TABLE_NAME = 't1';
+
+
+--echo #
+--echo # A test case for Bug#56540 "Exception (crash) in sql_show.cc
+--echo # during rqg_info_schema test on Windows"
+--echo # Ensure that we never access memory of a closed table,
+--echo # in particular, never access table->field[] array.
+--echo # Before the fix, the below test case, produced
+--echo # valgrind errors.
+--echo #
+
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1;
+--enable_warnings
+
+create table t1 (a int, b int);
+create view v1 as select t1.a, t1.b from t1;
+alter table t1 change b c int;
+lock table t1 read;
+connect(con1, localhost, root,,);
+--echo # --> connection con1
+connection con1;
+send flush tables;
+--echo # --> connection default
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush" and
+ info = "flush tables";
+--source include/wait_condition.inc
+--vertical_results
+select * from information_schema.views;
+--horizontal_results
+unlock tables;
+
+--echo #
+--echo # Cleanup.
+--echo #
+
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'flush tables'
+reap;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+--echo # --> connection default
+connection default;
+drop table t1;
+drop view v1;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test
index 2f651057e5c..f1aebfa4bed 100644
--- a/mysql-test/t/information_schema_db.test
+++ b/mysql-test/t/information_schema_db.test
@@ -1,7 +1,10 @@
# this test mostly test privilege control (what doesn't work
-# in the embedded server by default). So disabled in embedded-server mode
+# in the embedded server by default). So skip the test in embedded-server mode.
-- source include/not_embedded.inc
+#Don't run this test when thread_pool active
+--source include/not_threadpool.inc
+
-- source include/testdb_only.inc
--disable_warnings
@@ -13,7 +16,7 @@ drop function if exists f2;
use INFORMATION_SCHEMA;
--replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema
-show tables;
+show tables where Tables_in_INFORMATION_SCHEMA NOT LIKE 'Innodb%';
--replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)'
show tables from INFORMATION_SCHEMA like 'T%';
create database `inf%`;
@@ -123,7 +126,7 @@ create view v1 as select f1 from t1;
grant insert on v1 to testdb_2@localhost;
create view v5 as select f1 from t1;
-grant show view on v5 to testdb_2@localhost;
+grant select, show view on v5 to testdb_2@localhost;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
@@ -131,7 +134,7 @@ create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
connection default;
use testdb_1;
create view v6 as select f1 from t1;
-grant show view on v6 to testdb_2@localhost;
+grant select, show view on v6 to testdb_2@localhost;
create table t2 (f1 char(4));
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
@@ -163,10 +166,10 @@ show fields from testdb_1.v7;
show create view testdb_1.v7;
revoke insert(f1) on v3 from testdb_2@localhost;
-revoke show view on v5 from testdb_2@localhost;
+revoke select,show view on v5 from testdb_2@localhost;
connection default;
use testdb_1;
-revoke show view on v6 from testdb_2@localhost;
+revoke select,show view on v6 from testdb_2@localhost;
connection testdb_2;
--error ER_TABLEACCESS_DENIED_ERROR
diff --git a/mysql-test/t/information_schema_inno.test b/mysql-test/t/information_schema_inno.test
index 1a537d740b7..657d0effd7e 100644
--- a/mysql-test/t/information_schema_inno.test
+++ b/mysql-test/t/information_schema_inno.test
@@ -89,3 +89,23 @@ from information_schema.referential_constraints
where constraint_schema = schema();
drop table t2;
set foreign_key_checks = 1;
+
+
+--echo #
+--echo # Bug#55973 Assertion `thd->transaction.stmt.is_empty()'
+--echo # on CREATE TABLE .. SELECT I_S.PART
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+CREATE VIEW v1 AS SELECT 1;
+# This used to case an assert.
+CREATE TABLE t1 engine = InnoDB AS
+ SELECT * FROM information_schema.partitions
+ WHERE table_schema= 'test' AND table_name= 'v1';
+
+DROP TABLE t1;
+DROP VIEW v1;
diff --git a/mysql-test/t/information_schema_parameters.test b/mysql-test/t/information_schema_parameters.test
new file mode 100644
index 00000000000..ec9616926b7
--- /dev/null
+++ b/mysql-test/t/information_schema_parameters.test
@@ -0,0 +1,251 @@
+#------------------------------------------------------------------------------
+# i_s_parameters.test
+# .test file for MySQL regression suite
+# Purpose: To test the presence, structure, and behavior
+# of INFORMATION_SCHEMA.PARAMETERS
+# Author: pcrews
+# Last modified: 2007-12-03
+#------------------------------------------------------------------------------
+
+###############################################################################
+# Testcase parameters.1: Verify INFORMATION_SCHEMA.PARAMETERS view has the
+# following structure:
+# SPECIFIC_CATALOG NULL
+# SPECIFIC_SCHEMA routine's database
+# SPECIFIC_NAME routine's name
+# ORDINAL_POSITION first stored routine parameter is 1,
+# always 0 for stored function RETURN
+# PARAMETER_MODE 'IN' or 'OUT' or 'INOUT'
+# PARAMETER_NAME the parameter's name
+# DATA_TYPE same as for COLUMNS
+# CHARACTER_MAXIMUM_LENGTH same as for COLUMNS
+# CHARACTER_OCTET_LENGTH same as for COLUMNS
+# CHARACTER_SET_NAME same as for COLUMNS
+# COLLATION_NAME same as for COLUMNS
+# NUMERIC_PRECISION same as for COLUMNS
+# NUMERIC_SCALE same as for COLUMNS
+# DTD_IDENTIFIER same as for PARAMETERS
+###############################################################################
+-- echo # ========== parameters.1 ==========
+USE INFORMATION_SCHEMA;
+--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
+SHOW CREATE TABLE INFORMATION_SCHEMA.PARAMETERS;
+
+# embedded server does not display privileges
+--replace_column 18 #
+query_vertical SELECT * FROM information_schema.columns
+WHERE table_schema = 'information_schema'
+ AND table_name = 'parameters'
+ORDER BY ordinal_position;
+
+DESCRIBE INFORMATION_SCHEMA.PARAMETERS;
+
+###############################################################################
+# Testcase parameters.2: Unsuccessful stored procedure CREATE will not populate
+# I_S.PARAMETERS view
+###############################################################################
+-- echo # ========== parameters.2 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+# Missing closing ')' character at the end of 's char(20) in func declaration
+--error ER_PARSE_ERROR
+CREATE FUNCTION test_func1 (s char(20) RETURNS CHAR(50)
+RETURN CONCAT('Hello', ,s,'!');
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func1';
+
+###############################################################################
+# Testcase parameters.3: DROP FUNCTION - Verify DROP of a stored procedure
+# removes I_S.PARAMETERS data for that
+# function / procedure
+###############################################################################
+-- echo # ========== parameters.3 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE FUNCTION test_func1 (s char(20)) RETURNS CHAR(50)
+RETURN CONCAT('Hello, ',s,'!');
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func1';
+DROP FUNCTION test_func1;
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func1';
+
+###############################################################################
+# Testcase parameters.4: CREATE PROCEDURE - IN
+###############################################################################
+-- echo # ========== parameters.4 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+delimiter //;
+CREATE PROCEDURE testproc (OUT param1 INT)
+ BEGIN
+ SELECT 2+2 as param1;
+ END;
+//
+delimiter ;//
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'testproc';
+
+
+###############################################################################
+# Testcase parameters.5: CREATE PROCEDURE - INOUT
+###############################################################################
+-- echo # ========== parameters.5 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE PROCEDURE test_proc(INOUT P INT) SET @x=P*2;
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_proc';
+
+###############################################################################
+# Testcase parameters.6: CREATE PROCEDURE - OUT
+###############################################################################
+-- echo # ========== parameters.6 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE PROCEDURE test_proc(OUT p VARCHAR(10)) SET P='test';
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_proc';
+
+###############################################################################
+# Testcase parameters.7: CREATE FUNCTION - ORDINAL POSITION
+# Verify proper behavior for several aspects here
+# 3 rows should be created -- 1 for each IN parameter
+# 1 for the RETURNS param
+# ORDINAL POSITION values should be 0 for RETURNS
+# 1 and 2 for IN parameters
+# PARAM NAME and MODE should = NULL for RETURNS parm
+###############################################################################
+-- echo # ========== parameters.7 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE FUNCTION test_func1 (s char(20), t char(20)) RETURNS CHAR(40)
+RETURN CONCAT(s,t);
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func1';
+
+###############################################################################
+# Testcase parameters.8: CREATE FUNCTION - CHAR parameters
+# Verify CHAR related columns are populated for such a
+# parameter -- NUMERIC columns should be NULL
+###############################################################################
+-- echo # ========== parameters.8 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE FUNCTION test_func1 (s char(20)) RETURNS CHAR(50)
+RETURN CONCAT('Hello, ',s,'!');
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func1';
+
+###############################################################################
+# Testcase parameters.9: CREATE FUNCTION - NUMERIC parameters
+# Verify NUMERIC related columns are populated for such
+# parameter -- CHAR columns should be NULL
+###############################################################################
+-- echo # ========== parameters.9 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE FUNCTION test_func2 (s int) RETURNS INT RETURN s*2;
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func2';
+
+###############################################################################
+# Testcase parameters.10: CREATE FUNCTION - DATE
+# Verify NUMERIC and CHAR related columns are NULL
+###############################################################################
+-- echo # ========== parameters.10 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE FUNCTION test_func5 (s date) RETURNS TIMESTAMP
+RETURN CURRENT_TIMESTAMP;
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func5';
+
+###############################################################################
+# Testcase parameters.11: ALTER FUNCTION
+# Quick check to ensure ALTER doesn't affect this view
+# Should have no effect -- comment visible in ROUTINES
+# tested in i_s_routines.test
+###############################################################################
+-- echo # ========== parameters.11 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test;
+USE i_s_parameters_test;
+
+CREATE FUNCTION test_func5 (s date) RETURNS TIMESTAMP
+RETURN CURRENT_TIMESTAMP;
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func5';
+ALTER FUNCTION test_func5 COMMENT 'new comment added';
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func5';
+
+###############################################################################
+# Testcase parameters.12: MULTI-BYTE CHAR SETS
+# Verify that CHAR_MAX_LENGTH and CHAR_OCTET_LENGTH
+# differ as expected for multi-byte char sets
+# Normally both values are equal
+###############################################################################
+-- echo # ========== parameters.12 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_parameters_test;
+--enable_warnings
+
+CREATE DATABASE i_s_parameters_test CHARACTER SET utf8;
+USE i_s_parameters_test;
+
+CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30)
+RETURN CONCAT('XYZ, ' ,s);
+SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
+WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'test_func5';
+
+# Cleanup
+DROP DATABASE i_s_parameters_test;
diff --git a/mysql-test/t/information_schema_routines.test b/mysql-test/t/information_schema_routines.test
new file mode 100644
index 00000000000..c107b1dc2ce
--- /dev/null
+++ b/mysql-test/t/information_schema_routines.test
@@ -0,0 +1,247 @@
+#------------------------------------------------------------------------------
+# i_s_routines.test
+# .test file for MySQL regression suite
+# Purpose: To test the presence, structure, and behavior
+# of INFORMATION_SCHEMA.ROUTINES
+# Author: pcrews
+# Last modified: 2007-12-04
+#------------------------------------------------------------------------------
+
+################################################################################
+# Testcase routines.1: Ensure that the INFORMATION_SCHEMA.ROUTINES
+# table has the following columns, in the following order:
+#
+# SPECIFIC_NAME (shows the name of an accessible stored
+# procedure, or routine),
+# ROUTINE_CATALOG (always shows NULL),
+# ROUTINE_SCHEMA (shows the database, or schema, in which
+# the routine resides),
+# ROUTINE_NAME (shows the same stored procedure name),
+# ROUTINE_TYPE (shows whether the stored procedure is a
+# procedure or a function),
+# DATA_TYPE (new column as of 6.0)
+# CHARACTER_MAXIMUM_LENGTH (new column as of 6.0)
+# CHARACTER_OCTET_LENGTH (new column as of 6.0)
+# NUMERIC_PRECISION (new column as of 6.0)
+# NUMERIC_SCALE (new column as of 6.0)
+# CHARACTER_SET_NAME (new column as of 6.0)
+# COLLATION_NAME (new column as of 6.0)
+# DTD_IDENTIFIER (shows, for a function, the complete
+# data type definition of the value the function will
+# return; otherwise NULL),
+# ROUTINE_BODY (shows the language in which the stored
+# procedure is written; currently always SQL),
+# ROUTINE_DEFINITION (shows as much of the routine body as
+# is possible in the allotted space),
+# EXTERNAL_NAME (always shows NULL),
+# EXTERNAL_LANGUAGE (always shows NULL),
+# PARAMETER_STYLE (shows the routine's parameter style;
+# always SQL),
+# IS_DETERMINISTIC (shows whether the routine is
+# deterministic),
+# SQL_DATA_ACCESS (shows the routine's defined
+# sql-data-access clause value),
+# SQL_PATH (always shows NULL),
+# SECURITY_TYPE (shows whether the routine's defined
+# security_type is 'definer' or 'invoker'),
+# CREATED (shows the timestamp of the time the routine was
+# created),
+# LAST_ALTERED (shows the timestamp of the time the routine
+# was last altered),
+# SQL_MODE (shows the sql_mode setting at the time the
+# routine was created),
+# ROUTINE_COMMENT (shows the comment, if any, defined for
+# the routine; otherwise NULL),
+# DEFINER (shows the user who created the routine).
+################################################################################
+-- echo # ========== routines.1 ==========
+USE INFORMATION_SCHEMA;
+--replace_result ENGINE=MyISAM "" ENGINE=MARIA "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
+SHOW CREATE TABLE INFORMATION_SCHEMA.ROUTINES;
+
+# embedded server does not display privileges
+--replace_column 18 #
+query_vertical SELECT * FROM information_schema.columns
+WHERE table_schema = 'information_schema'
+ AND table_name = 'routines'
+ORDER BY ordinal_position;
+
+DESCRIBE INFORMATION_SCHEMA.ROUTINES;
+
+###############################################################################
+# Testcase routines.2: Unsuccessful stored procedure CREATE will not populate
+# I_S.ROUTINES view
+###############################################################################
+-- echo # ========== routines.2 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+CREATE DATABASE i_s_routines_test;
+USE i_s_routines_test;
+
+# Missing closing ')' character at the end of 's char(20) in func declaration
+--error ER_PARSE_ERROR
+CREATE FUNCTION test_func1 (s char(20) RETURNS CHAR(50)
+RETURN CONCAT('Hello', ,s,'!');
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func1';
+
+###############################################################################
+# Testcase routines.3: DROP FUNCTION - Verify DROP of a stored procedure
+# removes I_S.PARAMETERS data for that
+# function / procedure
+###############################################################################
+-- echo # ========== routines.3 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+CREATE DATABASE i_s_routines_test;
+USE i_s_routines_test;
+
+CREATE FUNCTION test_func1 (s char(20)) RETURNS CHAR(50)
+RETURN CONCAT('Hello, ',s,'!');
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func1';
+DROP FUNCTION test_func1;
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func1';
+
+
+################################################################################
+# Testcase routines.4: Verify that the new columns from WL#2822 are NULL for a
+# stored procedure
+################################################################################
+-- echo # ========== routines.4 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+CREATE DATABASE i_s_routines_test;
+USE i_s_routines_test;
+
+delimiter //;
+CREATE PROCEDURE testproc (OUT param1 INT)
+ BEGIN
+ SELECT 2+2 as param1;
+ END;
+//
+delimiter ;//
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'testproc';
+
+
+################################################################################
+# Testcase routines.5: Verify that the new columns from WL#2822 are populated
+# for a stored function, that the NUMERIC columns
+# are not populated when the function returns non-numeric
+# data, and that the CHARACTER columns are populated
+# for CHAR functions
+################################################################################
+-- echo # ========== routines.5 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+CREATE DATABASE i_s_routines_test;
+USE i_s_routines_test;
+
+CREATE FUNCTION test_func1 (s char(20)) RETURNS CHAR(50)
+RETURN CONCAT('Hello, ',s,'!');
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func1';
+
+
+
+################################################################################
+# Testcase routines.6: Verify that the new columns from WL#2822 are populated
+# for a stored function, that the CHARACTER columns
+# are not populated when the function returns numeric
+# data, and that the NUMERIC columns are populated
+# for numeric functions
+################################################################################
+-- echo # ========== routines.6 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+CREATE DATABASE i_s_routines_test;
+USE i_s_routines_test;
+
+CREATE FUNCTION test_func2 (s int) RETURNS INT RETURN s*2;
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func2';
+
+################################################################################
+# Testcase routines.7: Verify that the new columns from WL#2822 are populated
+# for a stored function, that the CHARACTER and NUMERIC
+# columns are not populated when the function returns date
+# or time data
+################################################################################
+-- echo # ========== routines.7 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+CREATE DATABASE i_s_routines_test;
+USE i_s_routines_test;
+
+CREATE FUNCTION test_func5 (s date) RETURNS TIMESTAMP
+RETURN CURRENT_TIMESTAMP;
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func5';
+
+###############################################################################
+# Testcase routines.8: ALTER FUNCTION
+# Quick check to ensure ALTER properly updates
+# I_S.ROUTINES.COMMENT
+###############################################################################
+-- echo # ========== routines.8 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+CREATE DATABASE i_s_routines_test;
+USE i_s_routines_test;
+
+CREATE FUNCTION test_func5 (s date) RETURNS TIMESTAMP
+RETURN CURRENT_TIMESTAMP;
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func5';
+ALTER FUNCTION test_func5 COMMENT 'new comment added';
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func5';
+
+###############################################################################
+# Testcase routines.9: MULTI-BYTE CHAR SETS
+# Verify that CHAR_MAX_LENGTH and CHAR_OCTET_LENGTH
+# differ as expected for multi-byte char sets
+# Normally both values are equal
+###############################################################################
+-- echo # ========== routines.9 ==========
+--disable_warnings
+DROP DATABASE IF EXISTS i_s_routines_test;
+--enable_warnings
+
+
+CREATE DATABASE i_s_routines_test CHARACTER SET utf8;
+USE i_s_routines_test;
+
+CREATE FUNCTION test_func5 (s CHAR(20)) RETURNS VARCHAR(30)
+RETURN CONCAT('XYZ, ' ,s);
+--replace_column 23 <created> 24 <modified>
+SELECT * FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = 'i_s_routines_test' AND ROUTINE_NAME = 'test_func5';
+
+# final clean up
+DROP DATABASE i_s_routines_test;
diff --git a/mysql-test/t/init_connect-master.opt b/mysql-test/t/init_connect-master.opt
index 108a8687aa2..db17a49c058 100644
--- a/mysql-test/t/init_connect-master.opt
+++ b/mysql-test/t/init_connect-master.opt
@@ -1 +1 @@
---set-variable=init_connect="set @a='a\\0c'"
+--init_connect="set @a='a\\0c'"
diff --git a/mysql-test/t/innodb_mysql_lock-master.opt b/mysql-test/t/innodb_mysql_lock-master.opt
new file mode 100644
index 00000000000..0041949b829
--- /dev/null
+++ b/mysql-test/t/innodb_mysql_lock-master.opt
@@ -0,0 +1 @@
+--innodb_lock_wait_timeout=300
diff --git a/mysql-test/t/innodb_mysql_lock.test b/mysql-test/t/innodb_mysql_lock.test
new file mode 100644
index 00000000000..629da27660e
--- /dev/null
+++ b/mysql-test/t/innodb_mysql_lock.test
@@ -0,0 +1,320 @@
+-- source include/have_innodb.inc
+
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+--echo #
+--echo # Bug #22876 Four-way deadlock
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,root,,);
+
+--echo # Connection 1
+connection con1;
+set @@autocommit=0;
+CREATE TABLE t1(s1 INT UNIQUE) ENGINE=innodb;
+INSERT INTO t1 VALUES (1);
+
+--echo # Connection 2
+connection con2;
+set @@autocommit=0;
+INSERT INTO t1 VALUES (2);
+--send INSERT INTO t1 VALUES (1)
+
+--echo # Connection 3
+connection con3;
+set @@autocommit=0;
+--send DROP TABLE t1
+
+--echo # Connection 1
+connection con1;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE info = "INSERT INTO t1 VALUES (1)" and
+ state = "update";
+--source include/wait_condition.inc
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE info = "DROP TABLE t1" and
+ state = "Waiting for table metadata lock";
+--source include/wait_condition.inc
+--echo # Connection 1 is now holding the lock.
+--echo # Issuing insert from connection 1 while connection 2&3
+--echo # is waiting for the lock should give a deadlock error.
+--error ER_LOCK_DEADLOCK
+INSERT INTO t1 VALUES (2);
+
+--echo # Cleanup
+connection con2;
+--reap
+commit;
+set @@autocommit=1;
+connection con1;
+commit;
+set @@autocommit=1;
+connection con3;
+--reap
+set @@autocommit=1;
+connection default;
+
+disconnect con1;
+disconnect con3;
+
+
+--echo #
+--echo # Test for bug #37346 "innodb does not detect deadlock between update
+--echo # and alter table".
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (c1 int primary key, c2 int, c3 int) engine=InnoDB;
+insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
+begin;
+--echo # Run statement which acquires X-lock on one of table's rows.
+update t1 set c3=c3+1 where c2=3;
+
+--echo #
+--echo # Switching to connection 'con37346'.
+connect (con37346,localhost,root,,test,,);
+connection con37346;
+--echo # The below ALTER TABLE statement should wait till transaction
+--echo # in connection 'default' is complete and then succeed.
+--echo # It should not deadlock or fail with ER_LOCK_DEADLOCK error.
+--echo # Sending:
+--send alter table t1 add column c4 int;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until the above ALTER TABLE gets blocked because this
+--echo # connection holds SW metadata lock on table to be altered.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c4 int";
+--source include/wait_condition.inc
+
+--echo # The below statement should succeed. It should not
+--echo # deadlock or end with ER_LOCK_DEADLOCK error.
+update t1 set c3=c3+1 where c2=4;
+
+--echo # Unblock ALTER TABLE by committing transaction.
+commit;
+
+--echo #
+--echo # Switching to connection 'con37346'.
+connection con37346;
+--echo # Reaping ALTER TABLE.
+--reap
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+disconnect con37346;
+drop table t1;
+
+
+--echo #
+--echo # Bug #42147 Concurrent DML and LOCK TABLE ... READ for InnoDB
+--echo # table cause warnings in errlog
+--echo #
+
+--echo #
+--echo # Note that this test for now relies on a global suppression of
+--echo # the warning "Found lock of type 6 that is write and read locked"
+--echo # This suppression rule can be removed once Bug#42147 is properly
+--echo # fixed. See bug page for more info.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT) engine= innodb;
+
+--echo # Connection 2
+--echo # Get user-level lock
+connection con2;
+SELECT get_lock('bug42147_lock', 60);
+
+--echo # Connection 1
+connection default;
+--send INSERT INTO t1 SELECT get_lock('bug42147_lock', 60)
+
+--echo # Connection 2
+connection con2;
+let $wait_condition=
+ SELECT COUNT(*) > 0 FROM information_schema.processlist
+ WHERE state = 'User lock'
+ AND info = 'INSERT INTO t1 SELECT get_lock(\'bug42147_lock\', 60)';
+--source include/wait_condition.inc
+LOCK TABLES t1 READ;
+SELECT release_lock('bug42147_lock');
+
+--echo # Connection 1
+connection default;
+--reap
+
+--echo # Connection 2
+connection con2;
+UNLOCK TABLES;
+
+--echo # Connection 1
+connection default;
+disconnect con2;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#53798 OPTIMIZE TABLE breaks repeatable read
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT) engine=innodb;
+INSERT INTO t1 VALUES (1), (2), (3);
+
+--echo # Connection con1
+connect (con1, localhost, root);
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+SELECT * FROM t1;
+
+--echo # Connection default
+connection default;
+--echo # This should block
+--echo # Sending:
+--send OPTIMIZE TABLE t1
+
+--echo # Connection con1
+connection con1;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table metadata lock' AND info='OPTIMIZE TABLE t1';
+--source include/wait_condition.inc
+SELECT * FROM t1;
+COMMIT;
+
+--echo # Connection default
+connection default;
+--echo # Reaping OPTIMIZE TABLE t1
+--reap
+disconnect con1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#49891 View DDL breaks REPEATABLE READ
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS v2;
+--enable_warnings
+
+CREATE TABLE t1 ( f1 INTEGER ) ENGINE = innodb;
+CREATE TABLE t2 ( f1 INTEGER );
+CREATE VIEW v1 AS SELECT 1 FROM t1;
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Connection con3
+connection con3;
+LOCK TABLE t1 WRITE;
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+# This should block due to t1 being locked.
+--echo # Sending:
+--send SELECT * FROM v1
+
+--echo # Connection con2
+connection con2;
+--echo # Waiting for 'SELECT * FROM v1' to sync in.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock" AND info = "SELECT * FROM v1";
+--source include/wait_condition.inc
+# This should block due to v1 being locked.
+--echo # Sending:
+--send ALTER VIEW v1 AS SELECT 2 FROM t2
+
+--echo # Connection con3
+connection con3;
+--echo # Waiting for 'ALTER VIEW v1 AS SELECT 2 FROM t2' to sync in.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock" AND
+ info = "ALTER VIEW v1 AS SELECT 2 FROM t2";
+--source include/wait_condition.inc
+# Unlock t1 allowing SELECT * FROM v1 to proceed.
+UNLOCK TABLES;
+
+--echo # Connection default;
+connection default;
+--echo # Reaping: SELECT * FROM v1
+--reap
+SELECT * FROM v1;
+COMMIT;
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER VIEW v1 AS SELECT 2 FROM t2
+--reap
+
+--echo # Connection default
+connection default;
+DROP TABLE t1, t2;
+DROP VIEW v1;
+disconnect con2;
+disconnect con3;
+
+
+--echo #
+--echo # Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
+--echo # KEY NO 0 FOR TABLE IN ERROR LOG
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--connect (con1,localhost,root)
+
+--echo # Connection default
+connection default;
+CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE = InnoDB;
+INSERT INTO t1 VALUES (1, 12345);
+START TRANSACTION;
+SELECT * FROM t1;
+
+--echo # Connection con1
+--connection con1
+SET lock_wait_timeout=1;
+# Test with two timeouts, as the first version of this patch
+# only worked with one timeout.
+--error ER_LOCK_WAIT_TIMEOUT
+ALTER TABLE t1 ADD INDEX idx(value);
+--error ER_LOCK_WAIT_TIMEOUT
+ALTER TABLE t1 ADD INDEX idx(value);
+
+--echo # Connection default
+--connection default
+SELECT * FROM t1;
+COMMIT;
+DROP TABLE t1;
+disconnect con1;
+
+
+# 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
diff --git a/mysql-test/t/innodb_mysql_lock2.test b/mysql-test/t/innodb_mysql_lock2.test
index 79698bcd898..b7259e771ae 100644
--- a/mysql-test/t/innodb_mysql_lock2.test
+++ b/mysql-test/t/innodb_mysql_lock2.test
@@ -3,10 +3,19 @@
# This test requires statement/mixed mode binary logging.
# Row-based mode puts weaker serializability requirements
# so weaker locks are acquired for it.
+# Also in ROW mode LOCK_S row locks won't be acquired for DML
+# and test for bug#51263 won't trigger execution path on which
+# this bug was encountered.
--source include/have_binlog_format_mixed_or_statement.inc
+# Original test case for bug#51263 needs partitioning.
+--source include/have_partition.inc
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
+--disable_query_log
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+--enable_query_log
+
--echo #
--echo # Test how do we handle locking in various cases when
--echo # we read data from InnoDB tables.
@@ -29,7 +38,7 @@ select @@session.tx_isolation;
connect (con1, localhost, root,,);
connection default;
--disable_warnings
-drop table if exists t0, t1, t2, t3, t4, t5, te;
+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;
@@ -59,8 +68,6 @@ create table t4 (l int primary key) engine=innodb;
insert into t4 values (1);
create table t5 (l int primary key) engine=innodb;
insert into t5 values (1);
-create table te(e int primary key);
-insert into te values (1);
create view v1 as select i from t1;
create view v2 as select j from t2 where j in (select i from t1);
create procedure p1(k int) insert into t2 values (k);
@@ -168,12 +175,10 @@ begin
set new.l= 2;
end if;
end|
---echo # Trigger below uses insertion of duplicate key in 'te'
---echo # table as a way to abort delete operation.
create trigger t4_bd before delete on t4 for each row
begin
if !(select i from v1 where i=1) then
- insert into te values (1);
+ signal sqlstate '45000';
end if;
end|
create trigger t5_bi before insert on t5 for each row
@@ -435,17 +440,18 @@ 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 # Calls to such functions won't get into the binary log and
---echo # thus don't need to acquire strong locks.
---echo # In 5.5 due to fix for bug #53921 "Wrong locks for SELECTs
---echo # used stored functions may lead to broken SBR" strong locks
---echo # are taken (we accepted it as a trade-off for this fix).
+--echo # In theory 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.
let $statement= select f1();
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
let $statement= set @a:= f1();
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 4.2 INSERT (or other statement which modifies data) with
@@ -456,11 +462,9 @@ let $wait_statement= select i from t1 where i = 1 into j;
--echo # be serialized with concurrent statements affecting the data
--echo # it uses. Therefore it should take row locks on the data
--echo # it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= insert into t2 values (f1() + 5);
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 4.3 SELECT/SET with a stored function which
@@ -470,14 +474,12 @@ let $wait_statement= select i from t1 where i = 1 into j;
--echo # it should be serialized with concurrent statements affecting
--echo # the data it uses. Hence, row locks on the data read
--echo # should be taken.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= select f2();
let $wait_statement= select i from t1 where i = 1 into k;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
let $statement= set @a:= f2();
let $wait_statement= select i from t1 where i = 1 into k;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 4.4. SELECT/SET with a stored function which does not
@@ -539,17 +541,14 @@ let $wait_statement= insert into t2 values ((select i from t1 where i = 1) + 5);
--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. In practice this fact is discovered
+--echo # locks. But in practice this fact is discovered
--echo # too late to have any effect.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken
---echo # in case of simple SELECT.
let $statement= select f6();
let $wait_statement= select i from v1 where i = 1 into k;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
let $statement= set @a:= f6();
let $wait_statement= select i from v1 where i = 1 into k;
---source include/check_no_row_lock.inc
+--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
@@ -566,12 +565,9 @@ let $wait_statement= select j from v2 where j = 1 into k;
--echo # should be serialized with concurrent statements affecting
--echo # the data it uses. Therefore it should take row locks on
--echo # the rows it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken
---echo # in case of simple SELECT.
let $statement= insert into t3 values (f6() + 5);
let $wait_statement= select i from v1 where i = 1 into k;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
let $statement= insert into t3 values (f7() + 5);
let $wait_statement= select j from v2 where j = 1 into k;
--source include/check_shared_row_lock.inc
@@ -584,12 +580,9 @@ let $wait_statement= select j from v2 where j = 1 into k;
--echo # Since a call to such function is written to the binary log
--echo # it should be serialized with concurrent statements.
--echo # Hence, reads should take row locks.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken
---echo # in case of simple SELECT.
let $statement= select f8();
let $wait_statement= select i from v1 where i = 1 into k;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
let $statement= select f9();
let $wait_statement= update v2 set j=j+10 where j=1;
--source include/check_shared_row_lock.inc
@@ -599,14 +592,12 @@ 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 # Calls to such functions won't get into the binary log and
---echo # thus don't need to acquire strong locks.
---echo # In 5.5 due to fix for bug #53921 "Wrong locks for SELECTs
---echo # used stored functions may lead to broken SBR" strong locks
---echo # are taken (we accepted it as a trade-off for this fix).
+--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.
let $statement= select f10();
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 4.11 INSERT which uses a stored function which doesn't modify
@@ -616,11 +607,9 @@ let $wait_statement= select i from t1 where i = 1 into j;
--echo # Since such 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 row locks on data it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= insert into t2 values (f10() + 5);
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 4.12 SELECT which uses a stored function which modifies
@@ -630,11 +619,9 @@ let $wait_statement= select i from t1 where i = 1 into j;
--echo # Since a call to such function is written to the binary log
--echo # it should be serialized from concurrent statements.
--echo # Hence, reads should take row locks.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= select f11();
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 4.13 SELECT that reads a table through a subquery passed
@@ -645,13 +632,8 @@ let $wait_statement= select i from t1 where i = 1 into j;
--echo # binary log, values of its parameters are written as literals.
--echo # So there is no need to acquire row locks on rows used in
--echo # the subquery.
---echo # But due to the fact that in 5.1 for prelocked statements
---echo # THD::in_lock_tables is set to TRUE we acquire strong locks
---echo # (see also bug#44613 "SELECT statement inside FUNCTION takes
---echo # a shared lock" [sic!!!]).
let $statement= select f12((select i+10 from t1 where i=1));
-let $wait_statement= $statement;
---source include/check_shared_row_lock.inc
+--source include/check_no_row_lock.inc
--echo #
--echo # 4.14 INSERT that reads a table via a subquery passed
@@ -686,24 +668,20 @@ let $statement= call p2(@a);
--echo # Since a call to such function is written to the binary
--echo # log, it should be serialized with concurrent statements.
--echo # Hence, in this case reads should take row locks on data.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= select f14();
let $wait_statement= select i from t1 where i = 1 into p;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--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 # Calls to such functions won't get into the binary log and
---echo # thus don't need to acquire strong locks.
---echo # In 5.5 due to fix for bug #53921 "Wrong locks for SELECTs
---echo # used stored functions may lead to broken SBR" strong locks
---echo # are taken (we accepted it as a trade-off for this fix).
+--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.
let $statement= select f15();
let $wait_statement= select i from t1 where i = 1 into p;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 5.4 INSERT which calls function which doesn't modify data and
@@ -712,11 +690,9 @@ let $wait_statement= select i from t1 where i = 1 into p;
--echo # Since such statement is written to the binary log it should
--echo # be serialized with concurrent statements affecting data it
--echo # uses. Therefore it should take row locks on data it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= insert into t2 values (f15()+5);
let $wait_statement= select i from t1 where i = 1 into p;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
@@ -730,11 +706,9 @@ let $wait_statement= select i from t1 where i = 1 into p;
--echo # be serialized with concurrent statements affecting the data
--echo # it uses. Therefore, it should take row locks on the data
--echo # it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= insert into t4 values (2);
let $wait_statement= select i from t1 where i=1 into k;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 6.2 Statement invoking a trigger that reads table through
@@ -759,22 +733,18 @@ let $wait_statement= $statement;
--echo # a stored function.
--echo #
--echo # And for this statement.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= insert into t5 values (2);
let $wait_statement= select i from t1 where i = 1 into j;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo #
--echo # 6.5 Statement invoking a trigger that reads a table through
--echo # stored procedure.
--echo #
--echo # And for this statement.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" no lock is taken.
let $statement= update t5 set l= 2 where l = 1;
let $wait_statement= select i from t1 where i = 1 into p;
---source include/check_no_row_lock.inc
+--source include/check_shared_row_lock.inc
--echo # Clean-up.
drop function f1;
@@ -795,8 +765,108 @@ drop function f15;
drop view v1, v2;
drop procedure p1;
drop procedure p2;
-drop table t1, t2, t3, t4, t5, te;
+drop table t1, t2, t3, t4, t5;
+disconnect con1;
+
+
+--echo #
+--echo # Test for bug#51263 "Deadlock between transactional SELECT
+--echo # and ALTER TABLE ... REBUILD PARTITION".
+--echo #
+connect (con1,localhost,root,,test,,);
+connection default;
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+create table t1 (i int auto_increment not null primary key) engine=innodb;
+create table t2 (i int) engine=innodb;
+insert into t1 values (1), (2), (3), (4), (5);
+
+begin;
+--echo # Acquire SR metadata lock on t1 and LOCK_S row-locks on its rows.
+insert into t2 select count(*) from t1;
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Sending:
+--send alter table t1 add column j int
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER is blocked because it tries to upgrade SNW
+--echo # metadata lock to X lock.
+--echo # It should not be blocked during copying data to new version of
+--echo # table as it acquires LOCK_S locks on rows of old version, which
+--echo # are compatible with locks acquired by connection 'con1'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column j int";
+--source include/wait_condition.inc
+
+--echo # The below statement will deadlock because it will try to acquire
+--echo # SW lock on t1, which will conflict with ALTER's SNW lock. And
+--echo # ALTER will be waiting for this connection to release its SR lock.
+--echo # This deadlock should be detected by an MDL subsystem and this
+--echo # statement should be aborted with an appropriate error.
+--error ER_LOCK_DEADLOCK
+insert into t1 values (6);
+--echo # Unblock ALTER TABLE.
+commit;
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Reaping ALTER TABLE.
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo #
+--echo # Now test for scenario in which bug was reported originally.
+--echo #
+drop tables t1, t2;
+create table t1 (i int auto_increment not null primary key) engine=innodb
+ partition by hash (i) partitions 4;
+create table t2 (i int) engine=innodb;
+insert into t1 values (1), (2), (3), (4), (5);
+
+begin;
+--echo # Acquire SR metadata lock on t1.
+select * from t1;
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Sending:
+--send alter table t1 rebuild partition p0
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER is blocked because of active SR lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 rebuild partition p0";
+--source include/wait_condition.inc
+
+--echo # The below statement should succeed as transaction
+--echo # has SR metadata lock on t1 and only going to read
+--echo # rows from it.
+insert into t2 select count(*) from t1;
+--echo # Unblock ALTER TABLE.
+commit;
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Reaping ALTER TABLE.
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
disconnect con1;
+--echo # Clean-up.
+drop tables t1, t2;
+
# 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.
diff --git a/mysql-test/t/innodb_mysql_sync.test b/mysql-test/t/innodb_mysql_sync.test
new file mode 100644
index 00000000000..ec8fa55fc5c
--- /dev/null
+++ b/mysql-test/t/innodb_mysql_sync.test
@@ -0,0 +1,309 @@
+#
+# Test file for InnoDB tests that require the debug sync facility
+#
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+
+--echo #
+--echo # Bug 42074 concurrent optimize table and
+--echo # alter table = Assertion failed: thd->is_error()
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo # Create InnoDB table
+CREATE TABLE t1 (id INT) engine=innodb;
+connect (con2, localhost, root);
+
+--echo # Connection 1
+--echo # Start optimizing table
+connection default;
+SET DEBUG_SYNC='ha_admin_try_alter SIGNAL optimize_started WAIT_FOR table_altered';
+--send OPTIMIZE TABLE t1
+
+--echo # Connection 2
+--echo # Change table to engine=memory
+connection con2;
+SET DEBUG_SYNC='now WAIT_FOR optimize_started';
+ALTER TABLE t1 engine=memory;
+SET DEBUG_SYNC='now SIGNAL table_altered';
+
+--echo # Connection 1
+--echo # Complete optimization
+connection default;
+--reap
+
+disconnect con2;
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
+
+
+--echo #
+--echo # Bug#47459 Assertion in Diagnostics_area::set_eof_status on
+--echo # OPTIMIZE TABLE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1, localhost, root);
+connection default;
+
+CREATE TABLE t1(a INT) ENGINE= InnoDB;
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= "ha_admin_open_ltable SIGNAL opening WAIT_FOR dropped";
+--echo # Sending:
+--send OPTIMIZE TABLE t1
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR opening";
+DROP TABLE t1;
+SET DEBUG_SYNC= "now SIGNAL dropped";
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: OPTIMIZE TABLE t1
+--reap
+
+--echo # Connection default
+connection default;
+disconnect con1;
+SET DEBUG_SYNC= "RESET";
+
+
+--echo #
+--echo # Bug#53757 assert in mysql_truncate_by_delete
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1(a INT) Engine=InnoDB;
+CREATE TABLE t2(id INT);
+INSERT INTO t1 VALUES (1), (2);
+
+connect (con1, localhost, root);
+INSERT INTO t2 VALUES(connection_id());
+SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed";
+--echo # Sending: (not reaped since connection is killed later)
+--send TRUNCATE t1
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR opening";
+SELECT ((@id := id) - id) FROM t2;
+KILL @id;
+SET DEBUG_SYNC= "now SIGNAL killed";
+DROP TABLE t1, t2;
+disconnect con1;
+--source include/wait_until_count_sessions.inc
+SET DEBUG_SYNC= "RESET";
+
+
+--echo #
+--echo # Bug#58933 Assertion `thd- >is_error()' fails on shutdown with ongoing
+--echo # OPTIMIZE TABLE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1), (2);
+
+--echo # Connection con1
+connect (con1,localhost,root);
+let $ID= `SELECT connection_id()`;
+SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL waiting WAIT_FOR killed';
+--echo # Sending:
+--send OPTIMIZE TABLE t1
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR waiting';
+--replace_result $ID ID
+eval KILL QUERY $ID;
+SET DEBUG_SYNC= 'now SIGNAL killed';
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: OPTIMIZE TABLE t1
+--reap
+
+--echo # Connection default
+connection default;
+DROP TABLE t1;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+
+
+--echo #
+--echo # Bug#42230 during add index, cannot do queries on storage engines
+--echo # that implement add_index
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect(con1,localhost,root);
+connect(con2,localhost,root);
+
+--echo # Test 1: Secondary index, should not block reads (original test case).
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
+INSERT INTO db1.t1(value) VALUES (1), (2);
+SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+--echo # Sending:
+--send ALTER TABLE db1.t1 ADD INDEX(value)
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= "now WAIT_FOR manage";
+# Neither of these two statements should be blocked
+USE db1;
+SELECT * FROM t1;
+SET DEBUG_SYNC= "now SIGNAL query";
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
+--reap
+DROP DATABASE db1;
+
+--echo # Test 2: Primary index (implicit), should block reads.
+
+CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
+SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+--echo # Sending:
+--send ALTER TABLE t1 ADD UNIQUE INDEX(a)
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= "now WAIT_FOR manage";
+USE test;
+--echo # Sending:
+--send SELECT * FROM t1
+
+--echo # Connection con2
+connection con2;
+--echo # Waiting for SELECT to be blocked by the metadata lock on t1
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for table metadata lock'
+ AND info='SELECT * FROM t1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= "now SIGNAL query";
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
+--reap
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: SELECT * FROM t1
+--reap
+
+--echo # Test 3: Primary index (explicit), should block reads.
+
+--echo # Connection default
+connection default;
+ALTER TABLE t1 DROP INDEX a;
+SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+--echo # Sending:
+--send ALTER TABLE t1 ADD PRIMARY KEY (a)
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= "now WAIT_FOR manage";
+--echo # Sending:
+--send SELECT * FROM t1
+
+--echo # Connection con2
+connection con2;
+--echo # Waiting for SELECT to be blocked by the metadata lock on t1
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for table metadata lock'
+ AND info='SELECT * FROM t1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= "now SIGNAL query";
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
+--reap
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: SELECT * FROM t1
+--reap
+
+--echo # Test 4: Secondary unique index, should not block reads.
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= "alter_table_manage_keys SIGNAL manage WAIT_FOR query";
+--echo # Sending:
+--send ALTER TABLE t1 ADD UNIQUE (b)
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= "now WAIT_FOR manage";
+SELECT * FROM t1;
+SET DEBUG_SYNC= "now SIGNAL query";
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER TABLE t1 ADD UNIQUE (b)
+--reap
+
+disconnect con1;
+disconnect con2;
+SET DEBUG_SYNC= "RESET";
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#11853126 RE-ENABLE CONCURRENT READS WHILE CREATING SECONDARY INDEX
+--echo # IN INNODB
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
+INSERT INTO t1 VALUES (1, 12345), (2, 23456);
+
+--echo # Connection con1
+--connect (con1,localhost,root)
+SET SESSION debug= "+d,alter_table_rollback_new_index";
+--error ER_UNKNOWN_ERROR
+ALTER TABLE t1 ADD PRIMARY KEY(a);
+SELECT * FROM t1;
+
+--echo # Connection default
+--connection default
+SELECT * FROM t1;
+DROP TABLE t1;
+disconnect con1;
+
+
+# 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
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 152f43a671d..2bf543511ac 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -235,8 +235,10 @@ insert into t1 values (1,11), (2,22);
insert into t2 values (1,12), (2,24);
--error 1393
insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10;
+--error 1393
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
select * from t1;
+--error 1393
insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
select * from t1;
drop view v1;
@@ -420,9 +422,6 @@ INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3);
INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
-# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and
-# "1.3e+78" due to different rounding rules
---replace_result 12.3 12.2 1.3e+78 1.2e+78
SELECT * FROM t1;
DROP TABLE t1;
@@ -457,9 +456,6 @@ INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2);
INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0);
INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0);
-# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and
-# "1.3e+78" due to different rounding rules
---replace_result 12.3 12.2 1.3e+78 1.2e+78
SELECT * FROM t1;
DROP TABLE t1;
@@ -499,6 +495,36 @@ DROP TABLE t1, t2;
--echo End of 5.0 tests.
+--echo #
+--echo # Bug#34898 "mysql_info() reports 0 warnings while
+--echo # mysql_warning_count() reports 1"
+--echo # Check that the number of warnings reported by
+--echo # mysql_info() is correct.
+--echo #
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (data varchar(4) not null);
+
+set sql_mode='error_for_division_by_zero';
+--echo #
+--echo # Demonstrate that the number of warnings matches
+--echo # the information in mysql_info().
+--echo #
+--enable_info
+insert t1 (data) values ('letter'), (1/0);
+update t1 set data='envelope' where 1/0 or 1;
+insert t1 (data) values (default), (1/0), ('dead beef');
+--disable_info
+
+set sql_mode=default;
+drop table t1;
+
+--echo #
+--echo # End of 5.4 tests
+--echo #
--echo #
--echo # Bug#54106 assert in Protocol::end_statement,
diff --git a/mysql-test/t/insert_notembedded.test b/mysql-test/t/insert_notembedded.test
index 24040f9c310..4e5fe6f6755 100644
--- a/mysql-test/t/insert_notembedded.test
+++ b/mysql-test/t/insert_notembedded.test
@@ -174,7 +174,7 @@ connection default;
# we must wait till the insert opens and locks the table
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and id = $ID;
+ where state = "Waiting for table level lock" and id = $ID;
--source include/wait_condition.inc
connect (select,localhost,root,,);
--echo connection: select
@@ -185,5 +185,6 @@ select * from t1;
connection default;
disconnect update;
disconnect select;
+unlock tables;
drop table t1;
set low_priority_updates=default;
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index 7318e45889a..d7fe816bec7 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -407,7 +407,7 @@ SET GLOBAL myisam_data_pointer_size = 2;
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
-call mtr.add_suppression("mysqld: The table '.*#sql.*' is full");
+call mtr.add_suppression("mysqld.*: The table '.*#sql.*' is full");
--error ER_RECORD_FILE_FULL,ER_RECORD_FILE_FULL
INSERT IGNORE INTO t1 SELECT t1.a FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6,t1 t7;
diff --git a/mysql-test/t/ipv4_as_ipv6-master.opt b/mysql-test/t/ipv4_as_ipv6-master.opt
new file mode 100644
index 00000000000..f55a8e9209d
--- /dev/null
+++ b/mysql-test/t/ipv4_as_ipv6-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=0.0.0.0
diff --git a/mysql-test/t/ipv4_as_ipv6.test b/mysql-test/t/ipv4_as_ipv6.test
new file mode 100644
index 00000000000..ace3c286643
--- /dev/null
+++ b/mysql-test/t/ipv4_as_ipv6.test
@@ -0,0 +1,64 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv4 (127.0.0.1) in ipv6 format
+# Options: --skip-name-resolve, --bind-address=0.0.0.0 (see corresponding opt file).
+#
+--source include/have_ipv4_mapped.inc
+# Can't be tested with embedded server
+--source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+echo =============Test of '127.0.0.1' (IPv4) ===========================;
+let $IPv6= 127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:FFFF:127.0.0.1' ===================;
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0000:0000:0000:0000:0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0000:0000:0000:0000:0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0000:0000:0:0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0:0000:0000:0:0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0::0000:FFFF:127.0.0.1' ====;
+let $IPv6= 0::0000:FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:FFFF:127.0.0.1/96' ================;
+let $IPv6= 0:0:0:0:0:FFFF:127.0.0.1/96;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '::FFFF:127.0.0.1' ===========================;
+let $IPv6= ::FFFF:127.0.0.1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '::FFFF:127.0.0.1/96' ========================;
+let $IPv6= ::FFFF:127.0.0.1/96;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '::1' ========================;
+let $IPv6= ::1;
+--echo connect (con1, $IPv6, root, , test, MASTER_MYPORT,);
+--disable_query_log
+--error 2003,2006
+connect (con1, $IPv6, root, , test, $MASTER_MYPORT,);
+--enable_query_log
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/ipv6-master.opt b/mysql-test/t/ipv6-master.opt
new file mode 100644
index 00000000000..d705811808c
--- /dev/null
+++ b/mysql-test/t/ipv6-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=::
diff --git a/mysql-test/t/ipv6.test b/mysql-test/t/ipv6.test
new file mode 100644
index 00000000000..5c08cde3746
--- /dev/null
+++ b/mysql-test/t/ipv6.test
@@ -0,0 +1,36 @@
+# Copyright (C) 2009 SUN Microsystems
+# All rights reserved. Use is subject to license terms.
+# Author: Horst Hunger
+# Nov. 19, 2009
+# Test of ipv6 format
+# Options: --skip-name-resolve, --bind-address=:: (see corresponding opt file).
+#
+--source include/check_ipv6.inc
+# Can't be tested with embedded server
+--source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+echo =============Test of '::1' ========================================;
+let $IPv6= ::1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '::1/128' ====================================;
+let $IPv6= ::1/128;
+#--source include/ipv6_clients.inc
+#--source include/ipv6.inc
+
+echo =============Test of '0000:0000:0000:0000:0000:0000:0000:0001' ====;
+let $IPv6= 0000:0000:0000:0000:0000:0000:0000:0001;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+echo =============Test of '0:0:0:0:0:0:0:1' ============================;
+let $IPv6= 0:0:0:0:0:0:0:1;
+--source include/ipv6_clients.inc
+--source include/ipv6.inc
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/join_optimizer.test b/mysql-test/t/join_optimizer.test
new file mode 100644
index 00000000000..3afe82113b9
--- /dev/null
+++ b/mysql-test/t/join_optimizer.test
@@ -0,0 +1,45 @@
+--disable_warnings
+drop table if exists t0,t1,t2,t3;
+--enable_warnings
+
+--echo #
+--echo # BUG#38049 incorrect rows estimations with references from preceding table
+--echo #
+
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (a varchar(32));
+insert into t1 values ('owner'),('requester'),('admincc'),('cc');
+
+CREATE TABLE t2 (
+ id int(11) NOT NULL,
+ type varchar(32) default NULL,
+ PRIMARY KEY (id)
+);
+insert into t2 values (1,'owner'), (2,'admincc');
+
+
+CREATE TABLE t3 (
+ id int(11) NOT NULL,
+ domain varchar(32) default NULL,
+ type varchar(32) default NULL,
+ PRIMARY KEY (id)
+);
+
+set @domain='system';
+set @pk=0;
+INSERT INTO t3 select @pk:=@pk+1, 'system', t1.a from t1;
+INSERT INTO t3 select @pk:=@pk+1, 'queue', t1.a from t1, t0 where t0.a<3;
+INSERT INTO t3 select @pk:=@pk+1, 'ticket', t1.a from t1, t0 A, t0 B, t0 C;
+
+CREATE INDEX groups_d ON t3(domain);
+CREATE INDEX groups_t ON t3(type);
+CREATE INDEX groups_td ON t3(type, domain);
+CREATE INDEX groups_dt ON t3(domain, type);
+--echo For table g this must use ref(groups_dt) and #rows should be around 15 and not 335:
+explain
+SELECT STRAIGHT_JOIN g.id FROM t2 a, t3 g USE INDEX(groups_dt)
+WHERE g.domain = 'queue' AND g.type = a.type;
+
+drop table t0,t1,t2,t3;
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index 3251ff292b6..991854cfb78 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -1010,4 +1010,210 @@ GROUP BY t2.f1, t2.f2;
DROP TABLE t1,t2;
+--echo #
+--echo # Bug#57034 incorrect OUTER JOIN result when joined on unique key
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY,
+ col_int INT,
+ col_int_unique INT UNIQUE KEY);
+INSERT INTO t1 VALUES (1,NULL,2), (2,0,0);
+
+CREATE TABLE t2 (pk INT PRIMARY KEY,
+ col_int INT,
+ col_int_unique INT UNIQUE KEY);
+INSERT INTO t2 VALUES (1,0,1), (2,0,2);
+
+EXPLAIN
+SELECT * FROM t1 LEFT JOIN t2
+ ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int
+ WHERE t1.pk=1;
+
+SELECT * FROM t1 LEFT JOIN t2
+ ON t1.col_int_unique = t2.col_int_unique AND t1.col_int = t2.col_int
+ WHERE t1.pk=1;
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug#48046 Server incorrectly processing JOINs on NULL values
+--echo #
+
+# bug#48046 is a duplicate of bug#57034
+
+CREATE TABLE `BB` (
+ `pk` int(11) NOT NULL AUTO_INCREMENT,
+ `time_key` time DEFAULT NULL,
+ `varchar_key` varchar(1) DEFAULT NULL,
+ `varchar_nokey` varchar(1) DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `time_key` (`time_key`),
+ KEY `varchar_key` (`varchar_key`)
+) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
+
+INSERT INTO `BB` VALUES (10,'18:27:58',NULL,NULL);
+
+SELECT table1.time_key AS field1, table2.pk
+FROM BB table1 LEFT JOIN BB table2
+ ON table2.varchar_nokey = table1.varchar_key
+ HAVING field1;
+
+DROP TABLE BB;
+
+--echo #
+--echo # Bug#49600 Server incorrectly processing RIGHT JOIN with
+--echo # constant WHERE clause and no index
+--echo #
+
+# bug#49600 is a duplicate of bug#57034
+
+CREATE TABLE `BB` (
+ `col_datetime_key` datetime DEFAULT NULL,
+ `col_varchar_key` varchar(1) DEFAULT NULL,
+ `col_varchar_nokey` varchar(1) DEFAULT NULL,
+ KEY `col_datetime_key` (`col_datetime_key`),
+ KEY `col_varchar_key` (`col_varchar_key`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+INSERT INTO `BB` VALUES ('1900-01-01 00:00:00',NULL,NULL);
+
+SELECT table1.col_datetime_key
+FROM BB table1 RIGHT JOIN BB table2
+ ON table2 .col_varchar_nokey = table1.col_varchar_key
+ WHERE 7;
+
+# Disable keys, and we get incorrect result for the same query
+ALTER TABLE BB DISABLE KEYS;
+
+SELECT table1.col_datetime_key
+FROM BB table1 RIGHT JOIN BB table2
+ ON table2 .col_varchar_nokey = table1.col_varchar_key
+ WHERE 7;
+
+DROP TABLE BB;
+
+
+--echo #
+--echo # Bug#58490: Incorrect result in multi level OUTER JOIN
+--echo # in combination with IS NULL
+--echo #
+
+CREATE TABLE t1 (i INT NOT NULL);
+INSERT INTO t1 VALUES (0), (2),(3),(4);
+CREATE TABLE t2 (i INT NOT NULL);
+INSERT INTO t2 VALUES (0),(1), (3),(4);
+CREATE TABLE t3 (i INT NOT NULL);
+INSERT INTO t3 VALUES (0),(1),(2), (4);
+CREATE TABLE t4 (i INT NOT NULL);
+INSERT INTO t4 VALUES (0),(1),(2),(3) ;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( t2 LEFT JOIN
+ ( t3 LEFT JOIN
+ t4
+ ON t4.i = t3.i
+ )
+ ON t3.i = t2.i
+ )
+ ON t2.i = t1.i
+ ;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( t2 LEFT JOIN
+ ( t3 LEFT JOIN
+ t4
+ ON t4.i = t3.i
+ )
+ ON t3.i = t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t4.i IS NULL;
+
+
+# Most simplified testcase to reproduce the bug.
+# (Has to be at least a two level nested outer join)
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+ t3
+ ON t3.i = t2.i
+ )
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+
+# Extended testing:
+# We then add some equi-join inside the query above:
+# (There Used to be some problems here with first
+# proposed patch for this bug)
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+ t3
+ ON t3.i = t2.i
+ )
+ JOIN t4
+ ON t4.i=t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+ t3
+ ON t3.i = t2.i
+ )
+ JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i)
+ ON t4a.i=t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+ t3
+ ON t3.i = t2.i
+ )
+ JOIN (t4 AS t4a, t4 AS t4b)
+ ON t4a.i=t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+
+DROP TABLE t1,t2,t3,t4;
+
+## Bug#49322 & bug#58490 are duplicates. However, we include testcases
+## for both.
+--echo #
+--echo # Bug#49322(Duplicate): Server is adding extra NULL row
+--echo # on processing a WHERE clause
+--echo #
+
+CREATE TABLE h (pk INT NOT NULL, col_int_key INT);
+INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8);
+
+CREATE TABLE m (pk INT NOT NULL, col_int_key INT);
+INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9);
+CREATE TABLE k (pk INT NOT NULL, col_int_key INT);
+INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5);
+
+# Baseline query wo/ 'WHERE ... IS NULL' - was correct
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key;
+
+# Adding 'WHERE ... IS NULL' -> incorrect result
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key
+WHERE TABLE1.pk IS NULL;
+
+DROP TABLE h,m,k;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/join_outer_innodb.test b/mysql-test/t/join_outer_innodb.test
index 40add7f488f..0d47c4ea57b 100644
--- a/mysql-test/t/join_outer_innodb.test
+++ b/mysql-test/t/join_outer_innodb.test
@@ -24,3 +24,40 @@ SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%' OR FALSE;
DROP TABLE t1,t2;
+
+--echo #
+--echo # BUG#58456: Assertion 0 in QUICK_INDEX_MERGE_SELECT::need_sorted_output
+--echo # in opt_range.h
+--echo #
+
+CREATE TABLE t1 (
+ col_int INT,
+ col_int_key INT,
+ pk INT NOT NULL,
+ PRIMARY KEY (pk),
+ KEY col_int_key (col_int_key)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (NULL,1,1), (6,2,2), (5,3,3), (NULL,4,4);
+INSERT INTO t1 VALUES (1,NULL,6), (8,5,7), (NULL,8,8), (8,NULL,5);
+
+CREATE TABLE t2 (
+ pk INT PRIMARY KEY
+) ENGINE=InnoDB;
+
+let $query=
+SELECT t1.pk
+FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int
+WHERE t1.col_int_key BETWEEN 5 AND 6
+ AND t1.pk IS NULL OR t1.pk IN (5)
+ORDER BY pk;
+
+--echo
+--eval EXPLAIN $query
+--echo
+--eval $query
+--echo
+
+DROP TABLE t1,t2;
+
+--echo # End BUG#58456
diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test
index f12d20e962e..a404e9bf15a 100644
--- a/mysql-test/t/key_cache.test
+++ b/mysql-test/t/key_cache.test
@@ -149,10 +149,13 @@ 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';
-
-# Cleanup
-# We don't reset keycache2 as we want to ensure that mysqld will reset it
+create table t1 (a int primary key);
+cache index t1 in keycache2;
+insert t1 values (1),(2),(3),(4),(5),(6),(7),(8);
+# delete keycache2, t1 is reassigned to default
set global keycache2.key_buffer_size=0;
+select * from t1;
+drop table t1;
# Test to set up a too small size for a key cache (bug #2064)
set global keycache3.key_buffer_size=100;
diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test
index 3080c4847b4..08016313ca7 100644
--- a/mysql-test/t/keywords.test
+++ b/mysql-test/t/keywords.test
@@ -62,5 +62,103 @@ call p1();
drop procedure p1;
drop table t1;
-
# End of 5.0 tests
+
+#
+# BUG#57899: Certain reserved words should not be reserved
+#
+
+#
+# We are looking for SYNTAX ERRORS here, so no need to
+# log the queries
+#
+
+CREATE TABLE slow (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO slow(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO slow(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO slow(slow, general) VALUES (1,2), (5,6);
+INSERT INTO slow(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM slow ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM slow ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM slow ORDER BY slow;
+SELECT slow FROM slow ORDER BY slow;
+DROP TABLE slow;
+CREATE TABLE general (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO general(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO general(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO general(slow, general) VALUES (1,2), (5,6);
+INSERT INTO general(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM general ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM general ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM general ORDER BY slow;
+SELECT slow FROM general ORDER BY slow;
+DROP TABLE general;
+CREATE TABLE master_heartbeat_period (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO master_heartbeat_period(slow, general) VALUES (1,2), (5,6);
+INSERT INTO master_heartbeat_period(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM master_heartbeat_period ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
+SELECT slow FROM master_heartbeat_period ORDER BY slow;
+DROP TABLE master_heartbeat_period;
+CREATE TABLE ignore_server_ids (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
+INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
+INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
+INSERT INTO ignore_server_ids(slow, general) VALUES (1,2), (5,6);
+INSERT INTO ignore_server_ids(slow) VALUES (1), (5);
+SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM ignore_server_ids ORDER BY slow;
+SELECT slow, general, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
+SELECT slow, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
+SELECT slow FROM ignore_server_ids ORDER BY slow;
+DROP TABLE ignore_server_ids;
+
+CREATE TABLE t1 (slow INT, general INT, ignore_server_ids INT, master_heartbeat_period INT);
+INSERT INTO t1 VALUES (1,2,3,4);
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE slow INT;
+ DECLARE general INT;
+ DECLARE ignore_server_ids INT;
+ DECLARE master_heartbeat_period INT;
+
+ SELECT max(t1.slow) INTO slow FROM t1;
+ SELECT max(t1.general) INTO general FROM t1;
+ SELECT max(t1.ignore_server_ids) INTO ignore_server_ids FROM t1;
+ SELECT max(t1.master_heartbeat_period) INTO master_heartbeat_period FROM t1;
+
+ SELECT slow, general, ignore_server_ids, master_heartbeat_period;
+END|
+
+CREATE PROCEDURE p2()
+BEGIN
+
+ DECLARE n INT DEFAULT 2;
+ general: WHILE n > 0 DO
+ SET n = n -1;
+ END WHILE general;
+
+ SET n = 2;
+ slow: WHILE n > 0 DO
+ SET n = n -1;
+ END WHILE slow;
+
+ SET n = 2;
+ ignore_server_ids: WHILE n > 0 DO
+ SET n = n -1;
+ END WHILE ignore_server_ids;
+
+ SET n = 2;
+ master_heartbeat_period: WHILE n > 0 DO
+ SET n = n -1;
+ END WHILE master_heartbeat_period;
+
+END|
+DELIMITER ;|
+CALL p1();
+call p2();
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP TABLE t1;
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index 02b033df2e5..f36d5a2169d 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -1,307 +1,327 @@
-# This test doesn't work with the embedded version as this code
-# assumes that one query is running while we are doing queries on
-# a second connection.
-# This would work if mysqltest run would be threaded and handle each
-# connection in a separate thread.
#
+# Test KILL and KILL QUERY statements.
+#
+# Killing a connection in an embedded server does not work like in a normal
+# server, if it is waiting for a new statement. In an embedded server, the
+# connection does not read() from a socket, but returns control to the
+# application. 'mysqltest' does not handle the kill request.
+#
+
-- source include/not_embedded.inc
+-- source include/have_debug_sync.inc
+-- source include/not_threadpool.inc
-# Disable concurrent inserts to avoid test failures when reading the
-# connection id which was inserted into a table by another thread.
-set @old_concurrent_insert= @@global.concurrent_insert;
-set @@global.concurrent_insert= 0;
+--disable_warnings
+SET DEBUG_SYNC = 'RESET';
+DROP TABLE IF EXISTS t1, t2, t3;
+DROP FUNCTION IF EXISTS MY_KILL;
+--enable_warnings
+
+delimiter |;
+# Helper function used to repeatedly kill a session.
+CREATE FUNCTION MY_KILL(tid INT) RETURNS INT
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
+ KILL tid;
+ RETURN (SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID = tid);
+END|
+delimiter ;|
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
-#remember id of con1
+# Save id of con1
connection con1;
---disable_warnings
-drop table if exists t1, t2, t3;
---enable_warnings
-
--disable_reconnect
-create table t1 (kill_id int);
-insert into t1 values(connection_id());
+let $ID= `SELECT @id := CONNECTION_ID()`;
+connection con2;
+let $ignore= `SELECT @id := $ID`;
+connection con1;
+# Signal when this connection is terminating.
+SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
+# See if we can kill read().
+# Run into read() immediately after hitting 'before_do_command_net_read'.
+SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read';
-#kill con1
+# Kill con1
connection con2;
-select ((@id := kill_id) - kill_id) from t1;
-kill @id;
+SET DEBUG_SYNC='now WAIT_FOR con1_read';
+# At this point we have no way to figure out, when con1 is blocked in
+# reading from the socket. Sending KILL to early would not terminate
+# con1. So we repeat KILL until con1 terminates.
+let $wait_condition= SELECT MY_KILL(@id);
+--source include/wait_condition.inc
+# If KILL missed the read(), sync point wait will time out.
+SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
+SET DEBUG_SYNC = 'RESET';
connection con1;
---sleep 2
-
---disable_query_log
---disable_result_log
-# One of the following statements should fail
---error 0,2006,2013
-select 1;
---error 0,2006,2013
-select 1;
---enable_query_log
---enable_result_log
+--error 1053,2006,2013
+SELECT 1;
--enable_reconnect
# this should work, and we should have a new connection_id()
-select ((@id := kill_id) - kill_id) from t1;
-select @id != connection_id();
+SELECT 1;
+let $ignore= `SELECT @id := $ID`;
+SELECT @id != CONNECTION_ID();
#make sure the server is still alive
connection con2;
-select 4;
-drop table t1;
+SELECT 4;
connection default;
--error ER_NOT_SUPPORTED_YET
-kill (select count(*) from mysql.user);
+KILL (SELECT COUNT(*) FROM mysql.user);
+
+connection con1;
+let $ID= `SELECT @id := CONNECTION_ID()`;
+connection con2;
+let $ignore= `SELECT @id := $ID`;
+connection con1;
+disable_reconnect;
+# Signal when this connection is terminating.
+SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
+# See if we can kill the sync point itself.
+# Wait in 'before_do_command_net_read' until killed.
+# It doesn't wait for a signal 'kill' but for to be killed.
+# The signal name doesn't matter here.
+SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read WAIT_FOR kill';
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR con1_read';
+# Repeat KILL until con1 terminates.
+let $wait_condition= SELECT MY_KILL(@id);
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
+SET DEBUG_SYNC = 'RESET';
+
+connection con1;
+--error 1053,2006,2013
+SELECT 1;
+enable_reconnect;
+SELECT 1;
+let $ignore= `SELECT @id := $ID`;
+SELECT @id != CONNECTION_ID();
+connection con2;
+SELECT 4;
+connection default;
#
# BUG#14851: killing long running subquery processed via a temporary table.
#
-create table t1 (id int primary key);
-create table t2 (id int unsigned not null);
-
-connect (conn1, localhost, root,,);
-connection conn1;
--- disable_result_log
--- disable_query_log
-let $1 = 4096;
-while ($1)
-{
- eval insert into t1 values ($1);
- dec $1;
-}
--- enable_query_log
--- enable_result_log
+CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT);
+CREATE TABLE t2 (id INT UNSIGNED NOT NULL);
-insert into t2 select id from t1;
+INSERT INTO t1 VALUES
+(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0),
+(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0),
+(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0),
+(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0);
+INSERT t1 SELECT 0 FROM t1 AS a1, t1 AS a2 LIMIT 4032;
-create table t3 (kill_id int);
-insert into t3 values(connection_id());
+INSERT INTO t2 SELECT id FROM t1;
-connect (conn2, localhost, root,,);
-connection conn2;
+connection con1;
+let $ID= `SELECT @id := CONNECTION_ID()`;
+connection con2;
+let $ignore= `SELECT @id := $ID`;
-connection conn1;
--- disable_result_log
-# This is a very long running query. If this test start failing, it may
-# be necessary to change to an even longer query.
-send select id from t1 where id in (select distinct a.id from t2 a, t2 b, t2 c, t2 d group by a.id, b.id, c.id, d.id having a.id between 10 and 20);
--- enable_result_log
+connection con1;
+SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
+SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync';
+# This is a very long running query. If this test start failing,
+# it may be necessary to change to an even longer query.
+send SELECT id FROM t1 WHERE id IN
+ (SELECT DISTINCT a.id FROM t2 a, t2 b, t2 c, t2 d
+ GROUP BY ACOS(1/a.id), b.id, c.id, d.id
+ HAVING a.id BETWEEN 10 AND 20);
-connection conn2;
-select ((@id := kill_id) - kill_id) from t3;
--- sleep 1
-kill @id;
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL @id;
+SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
-connection conn1;
--- error 1317,2013
+connection con1;
+--error 1317,1053,2006,2013
reap;
+SELECT 1;
connection default;
-
-drop table t1, t2, t3;
-
-# End of 4.1 tests
+SET DEBUG_SYNC = 'RESET';
+DROP TABLE t1, t2;
#
-# test of blocking of sending ERROR after OK or EOF
+# Test of blocking of sending ERROR after OK or EOF
#
connection con1;
-select get_lock("a", 10);
+let $ID= `SELECT @id := CONNECTION_ID()`;
connection con2;
-let $ID= `select connection_id()`;
-send select get_lock("a", 10);
-real_sleep 2;
+let $ignore= `SELECT @id := $ID`;
connection con1;
-disable_query_log;
-eval kill query $ID;
-enable_query_log;
+SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync WAIT_FOR kill';
+send SELECT ACOS(0);
connection con2;
-reap;
-select 1;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL QUERY @id;
connection con1;
-select RELEASE_LOCK("a");
+reap;
+SELECT 1;
+SELECT @id = CONNECTION_ID();
+connection default;
+SET DEBUG_SYNC = 'RESET';
#
# Bug#27563: Stored functions and triggers wasn't throwing an error when killed.
#
-create table t1(f1 int);
+CREATE TABLE t1 (f1 INT);
delimiter |;
-create function bug27563() returns int(11)
-deterministic
-begin
- declare continue handler for sqlstate '70100' set @a:= 'killed';
- declare continue handler for sqlexception set @a:= 'exception';
- set @a= get_lock("lock27563", 10);
- return 1;
-end|
+CREATE FUNCTION bug27563() RETURNS INT(11)
+DETERMINISTIC
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '70100' SET @a:= 'killed';
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception';
+ SET DEBUG_SYNC= 'now SIGNAL in_sync WAIT_FOR kill';
+ RETURN 1;
+END|
delimiter ;|
# Test stored functions
# Test INSERT
connection con1;
-select get_lock("lock27563",10);
+let $ID= `SELECT @id := CONNECTION_ID()`;
connection con2;
-let $ID= `select connection_id()`;
-send insert into t1 values (bug27563());
-real_sleep 2;
+let $ignore= `SELECT @id := $ID`;
connection con1;
-disable_query_log;
-eval kill query $ID;
-enable_query_log;
+send INSERT INTO t1 VALUES (bug27563());
connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL QUERY @id;
+connection con1;
--error 1317
reap;
-select @a;
-connection con1;
-select * from t1;
+SELECT * FROM t1;
+connection default;
+SET DEBUG_SYNC = 'RESET';
# Test UPDATE
-insert into t1 values(0);
-connection con2;
-send update t1 set f1= bug27563();
-real_sleep 2;
+INSERT INTO t1 VALUES(0);
connection con1;
-disable_query_log;
-eval kill query $ID;
-enable_query_log;
+send UPDATE t1 SET f1= bug27563();
connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL QUERY @id;
+connection con1;
--error 1317
reap;
-select @a;
-connection con1;
-select * from t1;
+SELECT * FROM t1;
+connection default;
+SET DEBUG_SYNC = 'RESET';
# Test DELETE
-insert into t1 values(1);
-connection con2;
-send delete from t1 where bug27563() is null;
-real_sleep 2;
+INSERT INTO t1 VALUES(1);
connection con1;
-disable_query_log;
-eval kill query $ID;
-enable_query_log;
+send DELETE FROM t1 WHERE bug27563() IS NULL;
connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL QUERY @id;
+connection con1;
--error 1317
reap;
-select @a;
-connection con1;
-select * from t1;
+SELECT * FROM t1;
+connection default;
+SET DEBUG_SYNC = 'RESET';
# Test SELECT
-connection con2;
-send select * from t1 where f1= bug27563();
-real_sleep 2;
connection con1;
-disable_query_log;
-eval kill query $ID;
-enable_query_log;
-connection con2;
---error 1317
-reap;
-select @a;
-
-# Test PROCEDURE
+send SELECT * FROM t1 WHERE f1= bug27563();
connection con2;
-delimiter |;
-create procedure proc27563()
-begin
- declare continue handler for sqlstate '70100' set @a:= 'killed';
- declare continue handler for sqlexception set @a:= 'exception';
- select get_lock("lock27563",10);
- select "shouldn't be selected";
-end|
-delimiter ;|
-send call proc27563();
-real_sleep 2;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL QUERY @id;
connection con1;
-disable_query_log;
-eval kill query $ID;
-enable_query_log;
-connection con2;
--error 1317
reap;
-select @a;
+SELECT * FROM t1;
+connection default;
+SET DEBUG_SYNC = 'RESET';
+DROP FUNCTION bug27563;
# Test TRIGGERS
-connection con2;
-create table t2 (f2 int);
+CREATE TABLE t2 (f2 INT);
delimiter |;
-create trigger trg27563 before insert on t1 for each row
-begin
- declare continue handler for sqlstate '70100' set @a:= 'killed';
- declare continue handler for sqlexception set @a:= 'exception';
- set @a:= get_lock("lock27563",10);
- insert into t2 values(1);
-end|
+CREATE TRIGGER trg27563 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '70100' SET @a:= 'killed';
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception';
+ INSERT INTO t2 VALUES(0);
+ SET DEBUG_SYNC= 'now SIGNAL in_sync WAIT_FOR kill';
+ INSERT INTO t2 VALUES(1);
+END|
delimiter ;|
-send insert into t1 values(2),(3);
-real_sleep 2;
connection con1;
-disable_query_log;
-eval kill query $ID;
-enable_query_log;
+send INSERT INTO t1 VALUES(2),(3);
connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL QUERY @id;
+connection con1;
--error 1317
reap;
-select @a;
-connection con1;
-select * from t1;
-select * from t2;
-
-# Cleanup
-select release_lock("lock27563");
-drop table t1, t2;
-drop function bug27563;
-drop procedure proc27563;
+SELECT * FROM t1;
+SELECT * FROM t2;
+connection default;
+SET DEBUG_SYNC = 'RESET';
+DROP TABLE t1, t2;
#
# Bug#28598: mysqld crash when killing a long-running explain query.
#
---disable_query_log
connection con1;
-let $ID= `select connection_id()`;
+let $ID= `SELECT @id := CONNECTION_ID()`;
+connection con2;
+let $ignore= `SELECT @id := $ID`;
+connection con1;
+--disable_query_log
let $tab_count= 40;
let $i= $tab_count;
while ($i)
{
- eval CREATE TABLE t$i (a$i int, KEY(a$i));
+ eval CREATE TABLE t$i (a$i INT, KEY(a$i));
eval INSERT INTO t$i VALUES (1),(2),(3),(4),(5),(6),(7);
dec $i ;
}
-set session optimizer_search_depth=0;
+SET SESSION optimizer_search_depth=0;
let $i=$tab_count;
while ($i)
{
- let $a= a$i;
- let $t= t$i;
- dec $i;
- if ($i)
- {
- let $comma=,;
- let $from=$comma$t$from;
- let $where=a$i=$a $and $where;
- }
- if (!$i)
- {
- let $from=FROM $t$from;
- let $where=WHERE $where;
- }
- let $and=AND;
+ let $a= a$i;
+ let $t= t$i;
+ dec $i;
+ if ($i)
+ {
+ let $comma=,;
+ let $from=$comma$t$from;
+ let $where=a$i=$a $and $where;
+ }
+ if (!$i)
+ {
+ let $from=FROM $t$from;
+ let $where=WHERE $where;
+ }
+ let $and=AND;
}
--enable_query_log
+SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync';
eval PREPARE stmt FROM 'EXPLAIN SELECT * $from $where';
send EXECUTE stmt;
---disable_query_log
connection con2;
-real_sleep 2;
-eval kill query $ID;
+SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
+KILL QUERY @id;
+connection con1;
+--error 1317
+reap;
+--disable_query_log
let $i= $tab_count;
while ($i)
{
@@ -309,8 +329,8 @@ while ($i)
dec $i ;
}
--enable_query_log
-
-###########################################################################
+connection default;
+SET DEBUG_SYNC = 'RESET';
--echo #
--echo # Bug#19723: kill of active connection yields different error code
@@ -318,18 +338,265 @@ while ($i)
--echo #
--echo
---echo # Connection: con2.
---connection con2
-
-KILL CONNECTION_ID();
+--echo # Connection: con1.
+--connection con1
+let $ID= `SELECT @id := CONNECTION_ID()`;
+SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
+--disable_reconnect
+--error ER_QUERY_INTERRUPTED
+KILL @id;
---echo # CR_SERVER_LOST, CR_SERVER_GONE_ERROR, depending on the timing
---echo # of close of the connection socket
---error 2013, 2006
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
+connection con1;
+--echo # ER_SERVER_SHUTDOWN, CR_SERVER_GONE_ERROR, CR_SERVER_LOST,
+--echo # depending on the timing of close of the connection socket
+--error 1053,2006,2013
SELECT 1;
---connection default
+--enable_reconnect
+SELECT 1;
+let $ignore= `SELECT @id := $ID`;
+SELECT @id != CONNECTION_ID();
+connection default;
+SET DEBUG_SYNC = 'RESET';
+
+--echo #
+--echo # Additional test for WL#3726 "DDL locking for all metadata objects"
+--echo # Check that DDL and DML statements waiting for metadata locks can
+--echo # be killed. Note that we don't cover all situations here since it
+--echo # can be tricky to write test case for some of them (e.g. REPAIR or
+--echo # ALTER and other statements under LOCK TABLES).
+--echo #
+--disable_warnings
+drop tables if exists t1, t2, t3;
+--enable_warnings
+
+create table t1 (i int primary key);
+connect (blocker, localhost, root, , );
+connect (dml, localhost, root, , );
+connect (ddl, localhost, root, , );
+
+--echo # Test for RENAME TABLE
+--echo # Switching to connection 'blocker'
+connection blocker;
+lock table t1 read;
+--echo # Switching to connection 'ddl'
+connection ddl;
+let $ID= `select connection_id()`;
+--send rename table t1 to t2
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--echo # Test for DROP TABLE
+--send drop table t1
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "drop table t1";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--echo # Test for CREATE TRIGGER
+--send create trigger t1_bi before insert on t1 for each row set @a:=1
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "create trigger t1_bi before insert on t1 for each row set @a:=1";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--echo #
+--echo # Tests for various kinds of ALTER TABLE
+--echo #
+--echo # Full-blown ALTER which should copy table
+--send alter table t1 add column j int
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column j int";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--echo # Two kinds of simple ALTER
+--send alter table t1 rename to t2
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 rename to t2";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+--send alter table t1 disable keys
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 disable keys";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+--echo # Fast ALTER
+--send alter table t1 alter column i set default 100
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 alter column i set default 100";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+--echo # Special case which is triggered only for MERGE tables.
+--echo # Switching to connection 'blocker'
+connection blocker;
+unlock tables;
+create table t2 (i int primary key) engine=merge union=(t1);
+lock tables t2 read;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--send alter table t2 alter column i set default 100
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t2 alter column i set default 100";
+--source include/wait_condition.inc
+--replace_result $ID ID
+eval kill query $ID;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--echo # Test for DML waiting for meta-data lock
+--echo # Switching to connection 'blocker'
+connection blocker;
+unlock tables;
+lock tables t1 read;
+--echo # Switching to connection 'ddl'
+connection ddl;
+# Let us add pending exclusive metadata lock on t2
+--send truncate table t1
+--echo # Switching to connection 'dml'
+connection dml;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "truncate table t1";
+--source include/wait_condition.inc
+let $ID2= `select connection_id()`;
+--send insert into t1 values (1)
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "insert into t1 values (1)";
+--source include/wait_condition.inc
+--replace_result $ID2 ID2
+eval kill query $ID2;
+--echo # Switching to connection 'dml'
+connection dml;
+--error ER_QUERY_INTERRUPTED
+--reap
+--echo # Switching to connection 'blocker'
+connection blocker;
+unlock tables;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--reap
+
+--echo # Test for DML waiting for tables to be flushed
+--echo # Switching to connection 'blocker'
+connection blocker;
+lock tables t1 read;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--echo # Let us mark locked table t1 as old
+--send flush tables
+--echo # Switching to connection 'dml'
+connection dml;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush" and
+ info = "flush tables";
+--source include/wait_condition.inc
+--send select * from t1
+--echo # Switching to connection 'default'
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush" and
+ info = "select * from t1";
+--source include/wait_condition.inc
+--replace_result $ID2 ID2
+eval kill query $ID2;
+--echo # Switching to connection 'dml'
+connection dml;
+--error ER_QUERY_INTERRUPTED
+--reap
+--echo # Switching to connection 'blocker'
+connection blocker;
+unlock tables;
+--echo # Switching to connection 'ddl'
+connection ddl;
+--reap
+
+--echo # Cleanup.
+--echo # Switching to connection 'default'
+connection default;
+drop table t1;
+drop table t2;
###########################################################################
-# Restore global concurrent_insert value. Keep in the end of the test file.
-set @@global.concurrent_insert= @old_concurrent_insert;
+SET DEBUG_SYNC = 'RESET';
+DROP FUNCTION MY_KILL;
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 821453777f5..0bb3cf64444 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -153,16 +153,6 @@ select * from t1;
#
# It should not be possible to load from a file outside of vardir
-## The following lines were disabled because of patch for
-## bug 50373. MYSQLTEST_VARDIR doesn't rewrite symlinks
-## to real paths, but this is done for secure_file_priv.
-## Because of this the result can't be replaced if the
-## test suite runs with the --mem option which creates
-## symlinks to the ramdisk.
-#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-#show variables like "secure_file_pri%";
-#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-#select @@secure_file_priv;
--error 1238
set @@secure_file_priv= 0;
@@ -611,5 +601,33 @@ DROP TABLE t1;
let $MYSQLD_DATADIR= `select @@datadir`;
remove_file $MYSQLD_DATADIR/test/tmpp2.txt;
+--echo #
+--echo # Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
+--echo #
+
+CREATE TABLE t1(f1 INT);
+EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
+--disable_warnings
+LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
+--enable_warnings
+
+DROP TABLE t1;
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/t1.dat;
+
+--echo #
+--echo # Bug#11765141 - 58072: LOAD DATA INFILE: LEAKS IO CACHE MEMORY
+--echo # WHEN ERROR OCCURS
+--echo #
+
+--let $file=$MYSQLTEST_VARDIR/tmp/bug11735141.txt
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT '1\n' INTO DUMPFILE '$file'
+
+create table t1(a point);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--error ER_CANT_CREATE_GEOMETRY_OBJECT
+--eval LOAD DATA INFILE '$file' INTO TABLE t1
+drop table t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/loadxml.test b/mysql-test/t/loadxml.test
new file mode 100644
index 00000000000..6faf712b6ce
--- /dev/null
+++ b/mysql-test/t/loadxml.test
@@ -0,0 +1,118 @@
+#
+# Tests for "LOAD XML" - a contributed patch from Erik Wetterberg.
+#
+
+# Running the $MYSQL_DUMP tool against an embedded server does not work.
+--source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (a int, b varchar(64));
+
+
+--echo -- Load a static XML file
+load xml infile '../../std_data/loadxml.dat' into table t1
+rows identified by '<row>';
+select * from t1 order by a;
+delete from t1;
+
+
+--echo -- Load a static XML file with 'IGNORE num ROWS'
+load xml infile '../../std_data/loadxml.dat' into table t1
+rows identified by '<row>' ignore 4 rows;
+select * from t1 order by a;
+
+
+--echo -- Check 'mysqldump --xml' + 'LOAD XML' round trip
+--exec $MYSQL_DUMP --xml test t1 > "$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml" 2>&1
+delete from t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval load xml infile '$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml' into table t1 rows identified by '<row>';
+select * from t1 order by a;
+
+--echo --Check that default row tag is '<row>
+delete from t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval load xml infile '$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml' into table t1;
+select * from t1 order by a;
+
+--echo -- Check that 'xml' is not a keyword
+select 1 as xml;
+
+
+#
+# Bug #42520 killing load .. infile Assertion failed: ! is_set(), file .\sql_error.cc, line 8
+#
+
+--disable_query_log
+delete from t1;
+insert into t1 values (1, '12345678900987654321'), (2, 'asdfghjkl;asdfghjkl;');
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+--exec $MYSQL_DUMP --xml test t1 > "$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml" 2>&1
+--enable_query_log
+
+connect (addconroot, localhost, root,,);
+connection addconroot;
+create table t2(fl text);
+--let $PSEUDO_THREAD_ID=`select @@pseudo_thread_id `
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--send_eval LOAD XML LOCAL INFILE "$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml" INTO TABLE t2 ROWS IDENTIFIED BY '<person>';
+
+sleep 3;
+
+
+connection default;
+
+--disable_query_log
+--eval kill $PSEUDO_THREAD_ID
+connection addconroot;
+# Read response from connection to avoid packets out-of-order when disconnecting
+# Note, that connection can already be dead due to previously issued kill
+--error 0,2013
+--reap
+disconnect addconroot;
+connection default;
+--enable_query_log
+#
+# Clean up
+#
+remove_file $MYSQLTEST_VARDIR/tmp/loadxml-dump.xml;
+drop table t1;
+drop table t2;
+
+#
+# Bug #36750 LOAD XML doesn't understand new line (feed) characters in multi line text fields
+#
+
+create table t1 (
+ id int(11) not null,
+ text text,
+ primary key (id)
+) engine=MyISAM default charset=latin1;
+load xml infile '../../std_data/loadxml2.dat' into table t1;
+select * from t1;
+drop table t1;
+
+--echo #
+--echo # Bug#51571 load xml infile causes server crash
+--echo #
+CREATE TABLE t1 (a text, b text);
+LOAD XML INFILE '../../std_data/loadxml.dat' INTO TABLE t1
+ROWS IDENTIFIED BY '<row>' (a,@b) SET b=concat('!',@b);
+SELECT * FROM t1 ORDER BY a;
+DROP TABLE t1;
diff --git a/mysql-test/t/locale.test b/mysql-test/t/locale.test
index 7ceb49fd1f4..04ac95cea06 100644
--- a/mysql-test/t/locale.test
+++ b/mysql-test/t/locale.test
@@ -3,6 +3,44 @@ DROP TABLE IF EXISTS t1;
--enable_warnings
--echo Start of 5.4 tests
+
+--echo #
+--echo # WL#4642 Greek locale for DAYNAME, MONTHNAME, DATE_FORMAT
+--echo #
+
+SET NAMES utf8;
+
+SET @@lc_time_names=109;
+SELECT @@lc_time_names;
+
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES
+('2006-01-01'),('2006-01-02'),('2006-01-03'),
+('2006-01-04'),('2006-01-05'),('2006-01-06'),('2006-01-07');
+SELECT a, date_format(a,'%a') as abday, dayname(a) as day FROM t1 ORDER BY a;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES
+('2006-01-01'),('2006-02-01'),('2006-03-01'),
+('2006-04-01'),('2006-05-01'),('2006-06-01'),
+('2006-07-01'),('2006-08-01'),('2006-09-01'),
+('2006-10-01'),('2006-11-01'),('2006-12-01');
+SELECT a, date_format(a,'%b') as abmon, monthname(a) as mon FROM t1 ORDER BY a;
+
+SELECT format(123456.789, 3, 'el_GR');
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#46633 Obsolete Serbian locale name
+--echo #
+SET lc_messages=sr_YU;
+SHOW VARIABLES LIKE 'lc_messages';
+SET lc_messages=sr_RS;
+SHOW VARIABLES LIKE 'lc_messages';
+SET lc_time_names=sr_RS;
+SELECT format(123456.789, 3, 'sr_RS');
+
--echo #
--echo # Bug#43207 wrong LC_TIME names for romanian locale
--echo #
diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test
index 30f4d4d6c61..eda3e8451dd 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -2,8 +2,11 @@
# Testing of table locking
#
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
--disable_warnings
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
--enable_warnings
CREATE TABLE t1 ( `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
insert into t1 (id,id2) values (1,1),(1,2),(1,3);
@@ -58,6 +61,9 @@ insert into t1 select index1,nr from t1;
unlock tables;
lock tables t1 write, t1 as t1_alias read;
insert into t1 select index1,nr from t1 as t1_alias;
+--error ER_TABLE_NOT_LOCKED
+drop table t1,t2;
+unlock tables;
drop table t1,t2;
#
@@ -90,7 +96,10 @@ delete t1 from t1,t2 where t1.a=t2.a;
delete from t2 using t1,t2 where t1.a=t2.a;
--error 1099
delete t2 from t1,t2 where t1.a=t2.a;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
drop table t1,t2;
+unlock tables;
+drop table t2,t1;
--echo End of 4.1 tests.
@@ -172,6 +181,7 @@ select * from t2;
--error ER_TABLE_NOT_LOCKED
select * from t3;
select * from v_bug5719;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
drop view v_bug5719;
--echo
--echo sic: did not left LOCK TABLES mode automatically
@@ -179,7 +189,7 @@ drop view v_bug5719;
--error ER_TABLE_NOT_LOCKED
select * from t1;
unlock tables;
-create view v_bug5719 as select * from t1;
+create or replace view v_bug5719 as select * from t1;
lock tables v_bug5719 write;
select * from v_bug5719;
--echo
@@ -192,6 +202,12 @@ select * from t1;
select * from t2;
--error ER_TABLE_NOT_LOCKED
select * from t3;
+--echo Dropping of implicitly locked table is disallowed.
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+drop table t1;
+unlock tables;
+--echo Now let us also lock table explicitly and drop it.
+lock tables t1 write, v_bug5719 write;
drop table t1;
--echo
--echo sic: left LOCK TABLES mode
@@ -245,3 +261,324 @@ UNLOCK TABLES;
DROP TABLE t1,t2;
--echo End of 5.1 tests.
+
+--echo #
+--echo # Ensure that FLUSH TABLES doesn't substitute a base locked table
+--echo # with a temporary one.
+--echo #
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+create table t1 (a int);
+create table t2 (a int);
+lock table t1 write, t2 write;
+create temporary table t1 (a int);
+flush table t1;
+drop temporary table t1;
+select * from t1;
+unlock tables;
+drop table t1, t2;
+
+--echo #
+--echo # Ensure that REPAIR .. USE_FRM works under LOCK TABLES.
+--echo #
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+create table t1 (a int);
+create table t2 (a int);
+lock table t1 write, t2 write;
+repair table t1 use_frm;
+repair table t1 use_frm;
+select * from t1;
+select * from t2;
+repair table t2 use_frm;
+repair table t2 use_frm;
+select * from t1;
+unlock tables;
+drop table t1, t2;
+
+--echo #
+--echo # Ensure that mi_copy_status is called for two instances
+--echo # of the same table when it is reopened after a flush.
+--echo #
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1;
+--enable_warnings
+create table t1 (c1 int);
+create view v1 as select * from t1;
+lock tables t1 write, v1 write;
+flush table t1;
+insert into t1 values (33);
+flush table t1;
+select * from t1;
+unlock tables;
+drop table t1;
+drop view v1;
+
+--echo #
+--echo # WL#4284: Transactional DDL locking
+--echo #
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+connect(con1,localhost,root,,);
+set autocommit= 0;
+insert into t1 values (1);
+lock table t1 write;
+--echo # Disconnect
+--echo # Ensure that metadata locks will be released if there is an open
+--echo # transaction (autocommit=off) in conjunction with lock tables.
+disconnect con1;
+connection default;
+drop table t1;
+
+--echo # Same problem but now for BEGIN
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+connect(con1,localhost,root,,);
+begin;
+insert into t1 values (1);
+--echo # Disconnect
+--echo # Ensure that metadata locks held by the transaction are released.
+disconnect con1;
+connection default;
+drop table t1;
+
+
+--echo #
+--echo # Coverage for situations when we try to execute DDL on tables
+--echo # which are locked by LOCK TABLES only implicitly.
+--echo #
+--disable_warnings
+drop tables if exists t1, t2;
+drop view if exists v1;
+drop function if exists f1;
+--enable_warnings
+create table t1 (i int);
+create table t2 (j int);
+--echo #
+--echo # Try to perform DDL on table which is locked through view.
+create view v1 as select * from t2;
+lock tables t1 write, v1 write;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+flush table t2;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+drop table t2;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+alter table t2 add column k int;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+create trigger t2_bi before insert on t2 for each row set @a:=1;
+--echo # Repair produces error as part of its result set.
+repair table t2;
+unlock tables;
+drop view v1;
+--echo #
+--echo # Now, try DDL on table which is locked through routine.
+delimiter |;
+create function f1 () returns int
+begin
+ insert into t2 values (1);
+ return 0;
+end|
+delimiter ;|
+create view v1 as select f1() from t1;
+lock tables v1 read;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+flush table t2;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+drop table t2;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+alter table t2 add column k int;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+create trigger t2_bi before insert on t2 for each row set @a:=1;
+--echo # Repair produces error as part of its result set.
+repair table t2;
+unlock tables;
+drop view v1;
+drop function f1;
+--echo #
+--echo # Finally, try DDL on table which is locked thanks to trigger.
+create trigger t1_ai after insert on t1 for each row insert into t2 values (1);
+lock tables t1 write;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+flush table t2;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+drop table t2;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+alter table t2 add column k int;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+create trigger t2_bi before insert on t2 for each row set @a:=1;
+--echo # Repair produces error as part of its result set.
+repair table t2;
+unlock tables;
+drop trigger t1_ai;
+drop tables t1, t2;
+
+
+--echo #
+--echo # Bug#45035 " Altering table under LOCK TABLES results in
+--echo # "Error 1213 Deadlock found..."
+--echo #
+--echo # When reopening tables under LOCK TABLES after ALTER TABLE,
+--echo # 6.0 used to be taking thr_lock locks one by one, and
+--echo # that would lead to a lock conflict.
+--echo # Check that taking all locks at once works.
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (i int);
+lock tables t1 write, t1 as a read, t1 as b read;
+alter table t1 add column j int;
+unlock tables;
+drop table t1;
+create temporary table t1 (i int);
+--echo #
+--echo # This is just for test coverage purposes,
+--echo # when this is allowed, remove the --error.
+--echo #
+--error ER_CANT_REOPEN_TABLE
+lock tables t1 write, t1 as a read, t1 as b read;
+alter table t1 add column j int;
+unlock tables;
+drop table t1;
+--echo #
+--echo # Separate case for partitioned tables is important
+--echo # because each partition has an own thr_lock object.
+--echo #
+create table t1 (i int) partition by list (i)
+ (partition p0 values in (1),
+ partition p1 values in (2,3),
+ partition p2 values in (4,5));
+lock tables t1 write, t1 as a read, t1 as b read;
+alter table t1 add column j int;
+unlock tables;
+drop table t1;
+
+
+--echo #
+--echo # Bug #43272 HANDLER SQL command does not work under LOCK TABLES
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+LOCK TABLE t1 WRITE;
+
+--echo # HANDLER commands are not allowed in LOCK TABLES mode
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+HANDLER t1 OPEN;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+HANDLER t1 READ FIRST;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+HANDLER t1 CLOSE;
+
+UNLOCK TABLES;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#45066 FLUSH TABLES WITH READ LOCK deadlocks against
+--echo # LOCK TABLE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+
+LOCK TABLE t1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES;
+
+LOCK TABLE t1 WRITE;
+FLUSH TABLES;
+
+--echo #
+--echo # If you allow the next combination, you reintroduce bug Bug#45066
+--echo #
+LOCK TABLE t1 READ;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+FLUSH TABLES WITH READ LOCK;
+
+LOCK TABLE t1 WRITE;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+FLUSH TABLES WITH READ LOCK;
+
+UNLOCK TABLES;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Simplified test for bug #48538 "Assertion in thr_lock() on LOAD DATA
+--echo # CONCURRENT INFILE".
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (f1 INT, f2 INT) ENGINE = MEMORY;
+CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
+ UPDATE LOW_PRIORITY t1 SET f2 = 7;
+
+--echo # Statement below should fail with ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+--echo # error instead of failing on assertion in table-level locking subsystem.
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+INSERT INTO t1(f1) VALUES(0);
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#43685 Lock table affects other non-related tables
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+connect (con2, localhost, root);
+CREATE TABLE t1 (id INT);
+CREATE TABLE t2 (id INT);
+
+--echo # Connection default
+connection default;
+LOCK TABLE t1 WRITE;
+ANALYZE TABLE t1;
+
+--echo # Connection con2
+connection con2;
+LOCK TABLE t2 WRITE;
+--echo # This used to hang until the first connection
+--echo # unlocked t1.
+FLUSH TABLE t2;
+
+UNLOCK TABLES;
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+disconnect con2;
+
+
+--echo #
+--echo # End of 6.0 tests.
+--echo #
+
+# 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
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 4df1a0f3478..5bab5e647ab 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -1,5 +1,3 @@
--- source include/not_embedded.inc
-
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
@@ -10,31 +8,46 @@ drop table if exists t1,t2;
# Test to see if select will get the lock ahead of low priority update
connect (locker,localhost,root,,);
+connect (locker2,localhost,root,,);
connect (reader,localhost,root,,);
connect (writer,localhost,root,,);
connection locker;
create table t1(n int);
insert into t1 values (1);
-lock tables t1 write;
+connection locker2;
+select get_lock("mysqltest_lock", 100);
+connection locker;
+send
+update t1 set n = 2 and get_lock('mysqltest_lock', 100);
connection writer;
+# Wait till above update gets blocked on a user lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "User lock" and info = "update t1 set n = 2 and get_lock('mysqltest_lock', 100)";
+--source include/wait_condition.inc
send
update low_priority t1 set n = 4;
connection reader;
# Sleep a bit till the update of connection writer is in work and hangs
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "update low_priority t1 set n = 4";
+ where state = "Waiting for table level lock" and
+ info = "update low_priority t1 set n = 4";
--source include/wait_condition.inc
send
select n from t1;
-connection locker;
+connection locker2;
# Sleep a bit till the select of connection reader is in work and hangs
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "select n from t1";
+ where state = "Waiting for table level lock" and
+ info = "select n from t1";
--source include/wait_condition.inc
-unlock tables;
+select release_lock("mysqltest_lock");
+connection locker;
+reap;
+select release_lock("mysqltest_lock");
connection writer;
reap;
connection reader;
@@ -44,19 +57,32 @@ drop table t1;
connection locker;
create table t1(n int);
insert into t1 values (1);
-lock tables t1 read;
+connection locker2;
+select get_lock("mysqltest_lock", 100);
+connection locker;
+send
+select n from t1 where get_lock('mysqltest_lock', 100);
connection writer;
+# Wait till above select gets blocked on a user lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "User lock" and info = "select n from t1 where get_lock('mysqltest_lock', 100)";
+--source include/wait_condition.inc
send
update low_priority t1 set n = 4;
connection reader;
# Sleep a bit till the update of connection writer is in work and hangs
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "update low_priority t1 set n = 4";
+ where state = "Waiting for table level lock" and
+ info = "update low_priority t1 set n = 4";
--source include/wait_condition.inc
select n from t1;
+connection locker2;
+select release_lock("mysqltest_lock");
connection locker;
-unlock tables;
+reap;
+select release_lock("mysqltest_lock");
connection writer;
reap;
drop table t1;
@@ -78,6 +104,7 @@ update t1,t2 set c=a where b=d;
connection reader;
select c from t2;
connection locker;
+unlock tables;
drop table t1;
drop table t2;
@@ -96,9 +123,11 @@ insert t1 select * from t2;
connection locker;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "insert t1 select * from t2";
+ where state = "Waiting for table metadata lock" and
+ info = "insert t1 select * from t2";
--source include/wait_condition.inc
drop table t2;
+unlock tables;
connection reader;
--error ER_NO_SUCH_TABLE
reap;
@@ -120,9 +149,11 @@ connection locker;
# Sleep a bit till the insert of connection reader is in work and hangs
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "insert t1 select * from t2";
+ where state = "Waiting for table metadata lock" and
+ info = "insert t1 select * from t2";
--source include/wait_condition.inc
drop table t2;
+unlock tables;
connection reader;
--error ER_NO_SUCH_TABLE
reap;
@@ -164,8 +195,8 @@ SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
connection locker;
# Sleep a bit till the select of connection reader is in work and hangs
let $wait_condition=
- select count(*) = 1 from information_schema.processlist
- where state = "Waiting for table" and info =
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock" AND info =
"SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1";
--source include/wait_condition.inc
# Make test case independent from earlier grants.
@@ -197,9 +228,11 @@ connection writer;
# Sleep a bit till the flush of connection locker is in work and hangs
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
+ where state = "Waiting for global read lock" and
+ info = "FLUSH TABLES WITH READ LOCK";
--source include/wait_condition.inc
# This must not block.
+--error ER_TABLE_NOT_LOCKED
CREATE TABLE t2 (c1 int);
UNLOCK TABLES;
#
@@ -209,7 +242,7 @@ reap;
UNLOCK TABLES;
#
connection default;
-DROP TABLE t1, t2;
+DROP TABLE t1;
#
# Test if CREATE TABLE SELECT with LOCK TABLE deadlocks.
#
@@ -227,7 +260,8 @@ connection writer;
# Sleep a bit till the flush of connection locker is in work and hangs
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
+ where state = "Waiting for global read lock" and
+ info = "FLUSH TABLES WITH READ LOCK";
--source include/wait_condition.inc
--error ER_TABLE_NOT_LOCKED
CREATE TABLE t2 AS SELECT * FROM t1;
@@ -262,10 +296,11 @@ DROP DATABASE mysqltest_1;
# With bug in place: try to acquire LOCK_mysql_create_table...
# When fixed: Reject dropping db because of the read lock.
connection con1;
-# Wait a bit so that the session con2 is in state "Waiting for release of readlock"
+# Wait a bit so that the session con2 is in state
+# "Waiting for global read lock"
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Waiting for release of readlock"
+ where state = "Waiting for global read lock"
and info = "DROP DATABASE mysqltest_1";
--source include/wait_condition.inc
--error ER_CANT_UPDATE_WITH_READLOCK
@@ -299,7 +334,8 @@ connection reader;
# Wait till connection writer is blocked
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "alter table t1 auto_increment=0";
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 auto_increment=0";
--source include/wait_condition.inc
send
alter table t1 auto_increment=0;
@@ -307,7 +343,8 @@ connection locker;
# Wait till connection reader is blocked
let $wait_condition=
select count(*) = 2 from information_schema.processlist
- where state = "Locked" and info = "alter table t1 auto_increment=0";
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 auto_increment=0";
--source include/wait_condition.inc
unlock tables;
connection writer;
@@ -338,19 +375,21 @@ connection con2;
send flush tables with read lock;
connection con5;
--echo # con5
-let $show_statement= SHOW PROCESSLIST;
-let $field= State;
-let $condition= = 'Flushing tables';
---source include/wait_show_condition.inc
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "flush tables with read lock";
+--source include/wait_condition.inc
--echo # global read lock is taken
connection con3;
--echo # con3
send select * from t2 for update;
connection con5;
-let $show_statement= SHOW PROCESSLIST;
-let $field= State;
-let $condition= = 'Waiting for release of readlock';
---source include/wait_show_condition.inc
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "select * from t2 for update";
+--source include/wait_condition.inc
--echo # waiting for release of read lock
connection con4;
--echo # con4
@@ -396,10 +435,11 @@ connection con1;
send update t2 set a = 1;
connection default;
--echo # default
-let $show_statement= SHOW PROCESSLIST;
-let $field= State;
-let $condition= = 'Waiting for release of readlock';
---source include/wait_show_condition.inc
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "update t2 set a = 1";
+--source include/wait_condition.inc
--echo # statement is waiting for release of read lock
connection con2;
--echo # con2
@@ -423,10 +463,11 @@ connection con1;
send lock tables t2 write;
connection default;
--echo # default
-let $show_statement= SHOW PROCESSLIST;
-let $field= State;
-let $condition= = 'Waiting for release of readlock';
---source include/wait_show_condition.inc
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock" and
+ info = "lock tables t2 write";
+--source include/wait_condition.inc
--echo # statement is waiting for release of read lock
connection con2;
--echo # con2
@@ -462,16 +503,20 @@ update t1 set i= 10;
connection reader;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "update t1 set i= 10";
+ where state = "Waiting for table level lock" and
+ info = "update t1 set i= 10";
--source include/wait_condition.inc
send
select * from t1;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "select * from t1";
+ where state = "Waiting for table level lock" and
+ info = "select * from t1";
--source include/wait_condition.inc
-let $ID= `select id from information_schema.processlist where state = "Locked" and info = "update t1 set i= 10"`;
+let $ID= `select id from information_schema.processlist
+ where state = "Waiting for table level lock" and
+ info = "update t1 set i= 10"`;
--replace_result $ID ID
eval kill query $ID;
connection reader;
@@ -502,6 +547,7 @@ drop table t1;
# Disconnect sessions used in many subtests above
disconnect locker;
+disconnect locker2;
disconnect reader;
disconnect writer;
@@ -529,7 +575,8 @@ connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Flushing tables";
+ where state = "Waiting for global read lock" and
+ info = "flush tables with read lock";
--source include/wait_condition.inc
alter table t1 add column j int;
connect (insert,localhost,root,,test,,);
@@ -537,14 +584,16 @@ connection insert;
--echo connection: insert
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Flushing tables";
+ where state = "Waiting for global read lock" and
+ info = "flush tables with read lock";
--source include/wait_condition.inc
--send insert into t1 values (1,2);
--echo connection: default
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Waiting for release of readlock";
+ where state = "Waiting for global read lock" and
+ info = "insert into t1 values (1,2)";
--source include/wait_condition.inc
unlock tables;
connection flush;
@@ -552,7 +601,8 @@ connection flush;
--reap
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Waiting for release of readlock";
+ where state = "Waiting for global read lock" and
+ info = "insert into t1 values (1,2)";
--source include/wait_condition.inc
select * from t1;
unlock tables;
@@ -587,18 +637,14 @@ connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Flushing tables";
+ where state = "Waiting for global read lock";
--source include/wait_condition.inc
flush tables;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Flushing tables";
+ where state = "Waiting for global read lock";
--source include/wait_condition.inc
unlock tables;
-let $wait_condition=
- select count(*) = 0 from information_schema.processlist
- where state = "Flushing tables";
---source include/wait_condition.inc
connection flush;
--reap
connection default;
@@ -618,11 +664,12 @@ lock tables t1 read;
let $tlwa= `show status like 'Table_locks_waited'`;
connect (waiter,localhost,root,,);
connection waiter;
---send insert into t1 values(1);
+send insert into t1 values(1);
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and info = "insert into t1 values(1)";
+ where state = "Waiting for table level lock" and
+ info = "insert into t1 values(1)";
--source include/wait_condition.inc
let $tlwb= `show status like 'Table_locks_waited'`;
unlock tables;
@@ -639,6 +686,465 @@ select @tlwa < @tlwb;
--echo End of 5.1 tests
+#
+# Test that DROP TABLES does not wait for a impending FLUSH TABLES
+# WITH READ LOCK
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (i int);
+connect (flush,localhost,root,,test,,);
+connection default;
+--echo connection: default
+lock tables t1 write;
+connection flush;
+--echo connection: flush
+--send flush tables with read lock;
+connection default;
+--echo connection: default
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock";
+--source include/wait_condition.inc
+flush tables;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for global read lock";
+--source include/wait_condition.inc
+drop table t1;
+connection flush;
+--reap
+connection default;
+disconnect flush;
+
+
+--echo #
+--echo # Test for bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock".
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (c1 int primary key, c2 int, c3 int);
+insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
+begin;
+update t1 set c3=c3+1 where c2=3;
+
+--echo #
+--echo # Switching to connection 'con46272'.
+connect (con46272,localhost,root,,test,,);
+connection con46272;
+--echo # The below ALTER TABLE statement should wait till transaction
+--echo # in connection 'default' is complete and then succeed.
+--echo # It should not deadlock or fail with ER_LOCK_DEADLOCK error.
+--echo # Sending:
+--send alter table t1 add column c4 int;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until the above ALTER TABLE gets blocked because this
+--echo # connection holds SW metadata lock on table to be altered.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c4 int";
+--source include/wait_condition.inc
+
+--echo # The below statement should succeed. It should not
+--echo # deadlock or end with ER_LOCK_DEADLOCK error.
+update t1 set c3=c3+1 where c2=4;
+
+--echo # Unblock ALTER TABLE by committing transaction.
+commit;
+
+--echo #
+--echo # Switching to connection 'con46272'.
+connection con46272;
+--echo # Reaping ALTER TABLE.
+--reap
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+disconnect con46272;
+drop table t1;
+
+
+--echo #
+--echo # Bug#47249 assert in MDL_global_lock::is_lock_type_compatible
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+--echo #
+--echo # Test 1: LOCK TABLES v1 WRITE, t1 READ;
+--echo #
+--echo # Thanks to the fact that we no longer allow DDL on tables
+--echo # which are locked for write implicitly, the exact scenario
+--echo # in which assert was failing is no longer repeatable.
+
+CREATE TABLE t1 ( f1 integer );
+CREATE VIEW v1 AS SELECT f1 FROM t1 ;
+
+LOCK TABLES v1 WRITE, t1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLE t1;
+UNLOCK TABLES;
+
+# Cleanup
+DROP TABLE t1;
+DROP VIEW v1;
+
+--echo #
+--echo # Test 2: LOCK TABLES t1 WRITE, v1 READ;
+--echo #
+
+CREATE TABLE t1 ( f1 integer );
+CREATE VIEW v1 AS SELECT f1 FROM t1 ;
+
+--echo # Connection 2
+connect (con2,localhost,root);
+LOCK TABLES t1 WRITE, v1 READ;
+FLUSH TABLE t1;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection 1
+connection default;
+LOCK TABLES t1 WRITE;
+FLUSH TABLE t1; # Assertion happened here
+
+# Cleanup
+DROP TABLE t1;
+DROP VIEW v1;
+
+
+--echo #
+--echo # Test for bug #50913 "Deadlock between open_and_lock_tables_derived
+--echo # and MDL". Also see additional coverage in mdl_sync.test.
+--echo #
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1;
+--enable_warnings
+connect (con50913,localhost,root);
+connection default;
+create table t1 (i int);
+create view v1 as select i from t1;
+begin;
+select * from t1;
+
+--echo # Switching to connection 'con50913'.
+connection con50913;
+--echo # Sending:
+--send alter table t1 add column j int
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE gets blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column j int";
+--source include/wait_condition.inc
+--echo # The below statement should try to acquire SW lock on 't1'
+--echo # and therefore should get ER_LOCK_DEADLOCK error. Before
+--echo # bug fix it acquired SR lock and hung on thr_lock.c lock.
+--error ER_LOCK_DEADLOCK
+delete a from t1 as a where i = 1;
+--echo # Unblock ALTER TABLE.
+commit;
+
+--echo # Switching to connection 'con50913'.
+connection con50913;
+--echo # Reaping ALTER TABLE;
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+select * from v1;
+
+--echo # Switching to connection 'con50913'.
+connection con50913;
+--echo # Sending:
+--send alter table t1 drop column j
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE gets blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 drop column j";
+--source include/wait_condition.inc
+--echo # The below statement should try to acquire SW lock on 't1'
+--echo # and therefore should get ER_LOCK_DEADLOCK error. Before
+--echo # bug fix it acquired SR lock and hung on thr_lock.c lock.
+--error ER_LOCK_DEADLOCK
+insert into v1 values (1);
+--echo # Unblock ALTER TABLE.
+commit;
+
+--echo # Switching to connection 'con50913'.
+connection con50913;
+--echo # Reaping ALTER TABLE;
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
+disconnect con50913;
+drop view v1;
+drop table t1;
+
+
+--echo #
+--echo # Bug#45225 Locking: hang if drop table with no timeout
+--echo #
+--echo # These tests also provide function coverage for the
+--echo # lock_wait_timeout server variable.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (id int);
+
+connect(con2, localhost, root,,);
+SET SESSION lock_wait_timeout= 1;
+
+--echo #
+--echo # Test 1: acquire exclusive lock
+--echo #
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+
+--echo # Connection 2
+connection con2;
+--error ER_LOCK_WAIT_TIMEOUT
+DROP TABLE t1;
+
+--echo # Connection default
+connection default;
+COMMIT;
+
+--echo #
+--echo # Test 2: upgrade shared lock
+--echo #
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+SELECT * FROM t1;
+
+--echo # Connection 2
+connection con2;
+--error ER_LOCK_WAIT_TIMEOUT
+ALTER TABLE t1 RENAME TO t2;
+
+--echo # Connection default
+connection default;
+COMMIT;
+
+--echo #
+--echo # Test 3: acquire shared lock
+--echo #
+
+--echo # Connection default
+connection default;
+LOCK TABLE t1 WRITE;
+
+--echo # Connection 2
+connection con2;
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1(id) VALUES (2);
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+
+--echo #
+--echo # Test 4: table level locks
+--echo #
+
+--echo # Connection default
+connection default;
+LOCK TABLE t1 READ;
+
+--echo # Connection 2
+connection con2;
+--error ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1(id) VALUES(4);
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+
+--echo #
+--echo # Test 5: Waiting on Table Definition Cache (TDC)
+--echo #
+
+connect(con3, localhost, root);
+
+--echo # Connection default
+connection default;
+LOCK TABLE t1 READ;
+
+--echo # Connection con3
+connection con3;
+--echo # Sending:
+--send FLUSH TABLES
+
+--echo # Connection con2
+connection con2;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table flush" AND info = "FLUSH TABLES";
+--source include/wait_condition.inc
+--error ER_LOCK_WAIT_TIMEOUT
+SELECT * FROM t1;
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+
+--echo # Connection con3
+connection con3;
+--echo # Reaping: FLUSH TABLES
+--reap
+
+--echo #
+--echo # Test 6: Timeouts in I_S queries
+--echo #
+
+--echo # Connection default
+connection default;
+CREATE TABLE t2 (id INT);
+LOCK TABLE t2 WRITE;
+
+--echo # Connection con3
+connection con3;
+--echo # Sending:
+--send DROP TABLE t1, t2
+
+--echo # Connection con2
+connection con2;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock" AND
+ info = "DROP TABLE t1, t2";
+--source include/wait_condition.inc
+# Note: This query causes two timeouts.
+# 1: try_acquire_high_prio_shared_mdl_lock on t1
+# 2: recover_from_failed_open on t1
+SELECT table_name, table_comment FROM information_schema.tables
+ WHERE table_schema= 'test' AND table_name= 't1';
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+
+--echo # Connection con3
+connection con3;
+--echo # Reaping: DROP TABLE t1, t2
+--reap
+
+--echo # Connection default
+connection default;
+--echo # Cleanup
+disconnect con2;
+disconnect con3;
+
+
+--echo #
+--echo # Test for bug #51134 "Crash in MDL_lock::destroy on a concurrent
+--echo # DDL workload".
+--echo #
+--disable_warnings
+drop tables if exists t1, t2, t3;
+--enable_warnings
+connect (con1, localhost, root, , );
+connect (con2, localhost, root, , );
+connection default;
+create table t3 (i int);
+
+--echo # Switching to connection 'con1'
+connection con1;
+--echo # Lock 't3' so upcoming RENAME is blocked.
+lock table t3 read;
+
+--echo # Switching to connection 'con2'
+connection con2;
+--echo # Remember ID for this connection.
+let $ID= `select connection_id()`;
+--echo # Start statement which will try to acquire two instances
+--echo # of X metadata lock on the same object.
+--echo # Sending:
+--send rename tables t1 to t2, t2 to t3;
+
+--echo # Switching to connection 'default'
+connection default;
+--echo # Wait until RENAME TABLE is blocked on table 't3'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename tables t1 to t2, t2 to t3";
+--source include/wait_condition.inc
+--echo # Kill RENAME TABLE.
+--replace_result $ID ID
+eval kill query $ID;
+
+--echo # Switching to connection 'con2'
+connection con2;
+--echo # RENAME TABLE should be aborted but should not crash.
+--error ER_QUERY_INTERRUPTED
+--reap
+
+--echo # Switching to connection 'con1'
+connection con1;
+unlock tables;
+
+--echo # Switching to connection 'default'
+connection default;
+disconnect con1;
+disconnect con2;
+drop table t3;
+
+
+--echo #
+--echo # Test for the bug where upgradable metadata locks was acquired
+--echo # even if the table to altered was temporary.
+--echo # Bug found while working on the related bug #51240.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (id INT);
+LOCK TABLE t1 WRITE;
+
+--echo # Connection con1
+connect (con1, localhost, root);
+CREATE TEMPORARY TABLE t1 (id INT);
+# This alter should not block and timeout.
+ALTER TABLE t1 ADD COLUMN j INT;
+
+--echo # Connection default
+connection default;
+disconnect con1;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
-
diff --git a/mysql-test/t/lock_sync-master.opt b/mysql-test/t/lock_sync-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/lock_sync-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test
index 17f8abb75f3..d5ad7becd7d 100644
--- a/mysql-test/t/lock_sync.test
+++ b/mysql-test/t/lock_sync.test
@@ -2,10 +2,15 @@
# Locking related tests which use DEBUG_SYNC facility.
#
--source include/have_debug_sync.inc
+# We need InnoDB to be able use TL_WRITE_ALLOW_WRITE type of locks in our tests.
+--source include/have_innodb.inc
# This test requires statement/mixed mode binary logging.
# Row-based mode puts weaker serializability requirements
# so weaker locks are acquired for it.
--source include/have_binlog_format_mixed_or_statement.inc
+# Until bug#41971 'Thread state on embedded server is always "Writing to net"'
+# is fixed this test can't be run on embedded version of server.
+--source include/not_embedded.inc
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc
@@ -40,7 +45,7 @@ connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
connection default;
--disable_warnings
-drop table if exists t0, t1, t2, t3, t4, t5, te;
+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;
@@ -70,8 +75,6 @@ create table t4 (l int primary key);
insert into t4 values (1);
create table t5 (l int primary key);
insert into t5 values (1);
-create table te(e int primary key);
-insert into te values (1);
create view v1 as select i from t1;
create view v2 as select j from t2 where j in (select i from t1);
create procedure p1(k int) insert into t2 values (k);
@@ -179,12 +182,10 @@ begin
set new.l= 2;
end if;
end|
---echo # Trigger below uses insertion of duplicate key in 'te'
---echo # table as a way to abort delete operation.
create trigger t4_bd before delete on t4 for each row
begin
if !(select i from v1 where i=1) then
- insert into te values (1);
+ signal sqlstate '45000';
end if;
end|
create trigger t5_bi before insert on t5 for each row
@@ -313,13 +314,12 @@ unlock tables;
--echo #
--echo # 2.1 CALL with a subquery.
--echo #
---echo # In theory strong lock is not necessary as this statement
---echo # is not written to the binary log as a whole (it is written
---echo # statement-by-statement). But in practice in 5.1 for
---echo # almost everything except SELECT we take strong lock.
+--echo # A strong lock is not necessary as this statement is not
+--echo # written to the binary log as a whole (it is written
+--echo # statement-by-statement).
let $statement= call p1((select i + 5 from t1 where i = 1));
let $restore_table= t2;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 2.2 CREATE TABLE with a subquery.
@@ -356,12 +356,10 @@ let $restore_table= t2;
--echo #
--echo # 2.5 DO with a subquery.
--echo #
---echo # In theory strong lock is not necessary as it is not logged.
---echo # But in practice in 5.1 for almost everything except SELECT
---echo # we take strong lock.
+--echo # A strong lock is not necessary as it is not logged.
let $statement= do (select i from t1 where i = 1);
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 2.6 INSERT with a subquery.
@@ -408,23 +406,21 @@ let $restore_table= ;
--echo #
--echo # 2.10 SET with a subquery.
--echo #
---echo # In theory the same is true for this statement as well.
---echo # But in practice in 5.1 we acquire strong lock in this
---echo # case as well.
+--echo # The same is true for this statement as well.
let $statement= set @a:= (select i from t1 where i = 1);
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 2.11 SHOW with a subquery.
--echo #
---echo # The same is true for this statement too.
+--echo # And for this statement too.
let $statement= show tables from test where Tables_in_test = 't2' and (select i from t1 where i = 1);
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
let $statement= show columns from t2 where (select i from t1 where i = 1);
let $restore_table= ;
---source include/check_no_concurrent_insert.inc
+--source include/check_concurrent_insert.inc
--echo #
--echo # 2.12 UPDATE with a subquery.
@@ -496,17 +492,18 @@ 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 # Calls to such functions won't get into the binary log and
---echo # thus don't need to acquire strong locks.
---echo # In 5.5 due to fix for bug #53921 "Wrong locks for SELECTs
---echo # used stored functions may lead to broken SBR" strong locks
---echo # are taken (we accepted it as a trade-off for this fix).
+--echo # In theory 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.
let $statement= select f1();
let $restore_table= ;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
let $statement= set @a:= f1();
let $restore_table= ;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 4.2 INSERT (or other statement which modifies data) with
@@ -517,11 +514,9 @@ let $restore_table= ;
--echo # be serialized with concurrent statements affecting the data
--echo # it uses. Therefore it should take strong lock on the data
--echo # it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= insert into t2 values (f1() + 5);
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 4.3 SELECT/SET with a stored function which
@@ -531,14 +526,12 @@ let $restore_table= t2;
--echo # it should be serialized with concurrent statements affecting
--echo # the data it uses. Hence, a strong lock on the data read
--echo # should be taken.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= select f2();
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
let $statement= set @a:= f2();
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 4.4. SELECT/SET with a stored function which does not
@@ -600,17 +593,14 @@ let $restore_table= t2;
--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. In practice this fact is discovered
+--echo # locks. But in practice this fact is discovered
--echo # too late to have any effect.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken
---echo # in case when simple SELECT is used.
let $statement= select f6();
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
let $statement= set @a:= f6();
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
let $statement= select f7();
let $restore_table= t2;
--source include/check_no_concurrent_insert.inc
@@ -627,12 +617,9 @@ let $restore_table= t2;
--echo # should be serialized with concurrent statements affecting
--echo # the data it uses. Therefore it should take a strong lock on
--echo # the table it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken
---echo # in case when simple SELECT is used.
let $statement= insert into t3 values (f6() + 5);
let $restore_table= t3;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
let $statement= insert into t3 values (f7() + 5);
let $restore_table= t3;
--source include/check_no_concurrent_insert.inc
@@ -645,12 +632,9 @@ let $restore_table= t3;
--echo # Since a call to such function is written to the binary log
--echo # it should be serialized with concurrent statements.
--echo # Hence, reads should take strong locks.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken
---echo # in case when simple SELECT is used.
let $statement= select f8();
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
let $statement= select f9();
let $restore_table= t2;
--source include/check_no_concurrent_insert.inc
@@ -660,14 +644,12 @@ let $restore_table= t2;
--echo # data and reads a table indirectly, by calling another
--echo # function.
--echo #
---echo # Calls to such functions won't get into the binary log and
---echo # thus don't need to acquire strong locks.
---echo # In 5.5 due to fix for bug #53921 "Wrong locks for SELECTs
---echo # used stored functions may lead to broken SBR" strong locks
---echo # are taken (we accepted it as a trade-off for this fix).
+--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.
let $statement= select f10();
let $restore_table= ;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 4.11 INSERT which uses a stored function which doesn't modify
@@ -677,11 +659,9 @@ let $restore_table= ;
--echo # Since such 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 data it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= insert into t2 values (f10() + 5);
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 4.12 SELECT which uses a stored function which modifies
@@ -691,11 +671,9 @@ let $restore_table= t2;
--echo # Since a call to such function is written to the binary log
--echo # it should be serialized from concurrent statements.
--echo # Hence, read should take a strong lock.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= select f11();
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 4.13 SELECT that reads a table through a subquery passed
@@ -744,24 +722,20 @@ let $restore_table= ;
--echo # Since a call to such function is written to the binary
--echo # log, it should be serialized with concurrent statements.
--echo # Hence, in this case reads should take strong locks on data.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= select f14();
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--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 # Calls to such functions won't get into the binary log and
---echo # thus don't need to acquire strong locks.
---echo # In 5.5 due to fix for bug #53921 "Wrong locks for SELECTs
---echo # used stored functions may lead to broken SBR" strong locks
---echo # are taken (we accepted it as a trade-off for this fix).
+--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.
let $statement= select f15();
let $restore_table= ;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 5.4 INSERT which calls function which doesn't modify data and
@@ -770,11 +744,9 @@ let $restore_table= ;
--echo # Since such statement is written to the binary log it should
--echo # be serialized with concurrent statements affecting data it
--echo # uses. Therefore it should take strong locks on data it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= insert into t2 values (f15()+5);
let $restore_table= t2;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
@@ -788,11 +760,9 @@ let $restore_table= t2;
--echo # be serialized with concurrent statements affecting the data
--echo # it uses. Therefore, it should take strong locks on the data
--echo # it reads.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= insert into t4 values (2);
let $restore_table= t4;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 6.2 Statement invoking a trigger that reads table through
@@ -817,22 +787,18 @@ let $restore_table= t4;
--echo # a stored function.
--echo #
--echo # And for this statement.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= insert into t5 values (2);
let $restore_table= t5;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo #
--echo # 6.5 Statement invoking a trigger that reads a table through
--echo # stored procedure.
--echo #
--echo # And for this statement.
---echo # But due to bug #53921 "Wrong locks for SELECTs used stored
---echo # functions may lead to broken SBR" weak locks are taken.
let $statement= update t5 set l= 2 where l = 1;
let $restore_table= t5;
---source include/check_concurrent_insert.inc
+--source include/check_no_concurrent_insert.inc
--echo # Clean-up.
@@ -854,7 +820,7 @@ drop function f15;
drop view v1, v2;
drop procedure p1;
drop procedure p2;
-drop table t1, t2, t3, t4, t5, te;
+drop table t1, t2, t3, t4, t5;
disconnect con1;
disconnect con2;
@@ -862,6 +828,315 @@ disconnect con2;
set @@global.concurrent_insert= @old_concurrent_insert;
+--echo #
+--echo # Test for bug #45143 "All connections hang on concurrent ALTER TABLE".
+--echo #
+--echo # Concurrent execution of statements which required weak write lock
+--echo # (TL_WRITE_ALLOW_WRITE) on several instances of the same table and
+--echo # statements which tried to acquire stronger write lock (TL_WRITE,
+--echo # TL_WRITE_ALLOW_READ) on this table might have led to deadlock.
+#
+# Suppress warnings for INSERTs that use get_lock().
+#
+disable_query_log;
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+enable_query_log;
+
+--disable_warnings
+drop table if exists t1;
+drop view if exists v1;
+--enable_warnings
+--echo # Create auxiliary connections used through the test.
+connect (con_bug45143_1,localhost,root,,test,,);
+connect (con_bug45143_3,localhost,root,,test,,);
+connect (con_bug45143_2,localhost,root,,test,,);
+connection default;
+--echo # Reset DEBUG_SYNC facility before using it.
+set debug_sync= 'RESET';
+--echo # Turn off logging so calls to locking subsystem performed
+--echo # for general_log table won't interfere with our test.
+set @old_general_log = @@global.general_log;
+set @@global.general_log= OFF;
+
+create table t1 (i int) engine=InnoDB;
+--echo # We have to use view in order to make LOCK TABLES avoid
+--echo # acquiring SNRW metadata lock on table.
+create view v1 as select * from t1;
+insert into t1 values (1);
+--echo # Prepare user lock which will be used for resuming execution of
+--echo # the first statement after it acquires TL_WRITE_ALLOW_WRITE lock.
+select get_lock("lock_bug45143_wait", 0);
+
+--echo # Switch to connection 'con_bug45143_1'.
+connection con_bug45143_1;
+--echo # Sending:
+--send insert into t1 values (get_lock("lock_bug45143_wait", 100));
+
+--echo # Switch to connection 'con_bug45143_2'.
+connection con_bug45143_2;
+--echo # Wait until the above INSERT takes TL_WRITE_ALLOW_WRITE lock on 't1'
+--echo # and then gets blocked on user lock 'lock_bug45143_wait'.
+let $wait_condition= select count(*)= 1 from information_schema.processlist
+ where state= 'User lock' and
+ info='insert into t1 values (get_lock("lock_bug45143_wait", 100))';
+--source include/wait_condition.inc
+--echo # Ensure that upcoming SELECT waits after acquiring TL_WRITE_ALLOW_WRITE
+--echo # lock for the first instance of 't1'.
+set debug_sync='thr_multi_lock_after_thr_lock SIGNAL parked WAIT_FOR go';
+--echo # Sending:
+--send select count(*) > 0 from t1 as a, t1 as b for update;
+
+--echo # Switch to connection 'con_bug45143_3'.
+connection con_bug45143_3;
+--echo # Wait until the above SELECT ... FOR UPDATE is blocked after
+--echo # acquiring lock for the the first instance of 't1'.
+set debug_sync= 'now WAIT_FOR parked';
+--echo # Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1':
+--send lock table v1 write;
+
+--echo # Switch to connection 'default'.
+connection default;
+--echo # Wait until this LOCK TABLES statement starts waiting for table lock.
+let $wait_condition= select count(*)= 1 from information_schema.processlist
+ where state= 'Waiting for table level lock' and
+ info='lock table v1 write';
+--source include/wait_condition.inc
+--echo # Allow SELECT ... FOR UPDATE to resume.
+--echo # Since it already has TL_WRITE_ALLOW_WRITE lock on the first instance
+--echo # of 't1' it should be able to get lock on the second instance without
+--echo # waiting, even although there is another thread which has such lock
+--echo # on this table and also there is a thread waiting for a TL_WRITE on it.
+set debug_sync= 'now SIGNAL go';
+
+--echo # Switch to connection 'con_bug45143_2'.
+connection con_bug45143_2;
+--echo # Reap SELECT ... FOR UPDATE
+--reap
+
+--echo # Switch to connection 'default'.
+connection default;
+--echo # Resume execution of the INSERT statement.
+select release_lock("lock_bug45143_wait");
+
+--echo # Switch to connection 'con_bug45143_1'.
+connection con_bug45143_1;
+--echo # Reap INSERT statement.
+--echo # In Statement and Mixed replication mode we get here "Unsafe
+--echo # for binlog" warnings. In row mode there are no warnings.
+--echo # Hide the discrepancy.
+--disable_warnings
+--reap
+--enable_warnings
+
+
+--echo # Switch to connection 'con_bug45143_3'.
+connection con_bug45143_3;
+--echo # Reap LOCK TABLES statement.
+--reap
+unlock tables;
+
+--echo # Switch to connection 'default'.
+connection default;
+--echo # Do clean-up.
+disconnect con_bug45143_1;
+disconnect con_bug45143_2;
+disconnect con_bug45143_3;
+set debug_sync= 'RESET';
+set @@global.general_log= @old_general_log;
+drop view v1;
+drop table t1;
+
+
+--echo #
+--echo # Bug#50821 Deadlock between LOCK TABLES and ALTER TABLE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1(id INT);
+CREATE TABLE t2(id INT);
+
+--echo # Connection con2
+connect (con2, localhost, root);
+START TRANSACTION;
+SELECT * FROM t1;
+
+--echo # Connection default
+connection default;
+--echo # Sending:
+--send ALTER TABLE t1 ADD COLUMN j INT
+
+--echo # Connection con2
+connection con2;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock"
+ AND info = "ALTER TABLE t1 ADD COLUMN j INT";
+--source include/wait_condition.inc
+
+--echo # This used to cause a deadlock.
+INSERT INTO t2 SELECT * FROM t1;
+
+COMMIT;
+
+--echo # Connection default
+connection default;
+--echo # Reaping ALTER TABLE t1 ADD COLUMN j INT
+--reap
+
+DROP TABLE t1, t2;
+disconnect con2;
+
+
+--echo #
+--echo # Bug#51391 Deadlock involving events during rqg_info_schema test
+--echo #
+
+CREATE EVENT e1 ON SCHEDULE EVERY 5 HOUR DO SELECT 1;
+CREATE EVENT e2 ON SCHEDULE EVERY 5 HOUR DO SELECT 2;
+
+--echo # Connection con1
+connect(con1, localhost, root);
+SET DEBUG_SYNC="before_lock_tables_takes_lock SIGNAL drop WAIT_FOR query";
+--echo # Sending:
+--send DROP EVENT e1;
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC="now WAIT_FOR drop";
+SELECT name FROM mysql.event, INFORMATION_SCHEMA.GLOBAL_VARIABLES
+ WHERE definer = VARIABLE_VALUE;
+SET DEBUG_SYNC="now SIGNAL query";
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: DROP EVENT t1
+--reap
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection default
+connection default;
+DROP EVENT e2;
+SET DEBUG_SYNC="RESET";
+
+
+--echo #
+--echo # Bug#55930 Assertion `thd->transaction.stmt.is_empty() ||
+--echo # thd->in_sub_stmt || (thd->state..
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT) engine=InnoDB;
+INSERT INTO t1 VALUES (1), (2);
+
+connect (con1, localhost, root);
+connect (con2, localhost, root);
+
+--echo # Connection con1
+connection con1;
+SET SESSION lock_wait_timeout= 1;
+SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL opti_recreate WAIT_FOR opti_analyze';
+--echo # Sending:
+--send OPTIMIZE TABLE t1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR opti_recreate';
+SET DEBUG_SYNC= 'after_lock_tables_takes_lock SIGNAL thrlock WAIT_FOR release_thrlock';
+--echo # Sending:
+--send INSERT INTO t1 VALUES (3)
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR thrlock';
+SET DEBUG_SYNC= 'now SIGNAL opti_analyze';
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: OPTIMIZE TABLE t1
+--reap
+SET DEBUG_SYNC= 'now SIGNAL release_thrlock';
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: INSERT INTO t1 VALUES (3)
+--reap
+disconnect con2;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection default
+connection default;
+DROP TABLE t1;
+SET DEBUG_SYNC= 'RESET';
+
+
+--echo #
+--echo # Bug#57130 crash in Item_field::print during SHOW CREATE TABLE or VIEW
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+CREATE FUNCTION f1() RETURNS INTEGER RETURN 1;
+CREATE VIEW v1 AS SELECT * FROM t1 WHERE f1() = 1;
+DROP FUNCTION f1;
+connect(con2, localhost, root);
+
+--echo # Connection con1
+connect (con1, localhost, root);
+# Need to trigger this sync point at least twice in order to
+# get valgrind test failures without the patch
+SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped EXECUTE 2';
+--echo # Sending:
+--send SHOW CREATE VIEW v1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR opened';
+SET DEBUG_SYNC= 'now SIGNAL dropped';
+SET DEBUG_SYNC= 'now WAIT_FOR opened';
+--echo # Sending:
+--send FLUSH TABLES
+
+--echo # Connection default
+connection default;
+--echo # Waiting for FLUSH TABLES to be blocked.
+let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL dropped';
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: SHOW CREATE VIEW v1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: FLUSH TABLES
+--reap
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'RESET';
+DROP VIEW v1;
+DROP TABLE t1;
+disconnect con1;
+disconnect con2;
+
+
# 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
diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test
index 05e17dc9fa7..d47044fbbee 100644
--- a/mysql-test/t/log_state.test
+++ b/mysql-test/t/log_state.test
@@ -1,16 +1,5 @@
### t/log_state.test ###
#
-# This test suffers from server
-# Bug#38124 "general_log_file" variable silently unset when using expression
-# In short:
-# SET GLOBAL general_log_file = @<whatever>
-# SET GLOBAL slow_query_log = @<whatever>
-# cause that the value of these server system variables is set to default
-# instead of the assigned values. There comes no error message or warning.
-# If this bug is fixed please
-# 1. try this test with "let $fixed_bug38124 = 0;"
-# 2. remove all workarounds if 1. was successful.
-let $fixed_bug38124 = 0;
--source include/not_embedded.inc
--source include/have_csv.inc
@@ -166,16 +155,6 @@ SET @@global.general_log = @old_general_log;
SET @@global.general_log_file = @old_general_log_file;
SET @@global.slow_query_log = @old_slow_query_log;
SET @@global.slow_query_log_file = @old_slow_query_log_file;
-if(!$fixed_bug38124)
-{
- --disable_query_log
- let $my_var = `SELECT @old_general_log_file`;
- eval SET @@global.general_log_file = '$my_var';
- let $my_var = `SELECT @old_slow_query_log_file`;
- eval SET @@global.slow_query_log_file = '$my_var';
- --enable_query_log
-}
-
###########################################################################
@@ -278,15 +257,6 @@ SET GLOBAL slow_query_log_file= NULL;
# Reset to initial values in case a setting above was successful.
SET GLOBAL general_log_file= @old_general_log_file;
SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
-if(!$fixed_bug38124)
-{
- --disable_query_log
- let $my_var = `SELECT @old_general_log_file`;
- eval SET @@global.general_log_file = '$my_var';
- let $my_var = `SELECT @old_slow_query_log_file`;
- eval SET @@global.slow_query_log_file = '$my_var';
- --enable_query_log
-}
###########################################################################
@@ -307,15 +277,6 @@ SHOW VARIABLES LIKE '%log_file';
--echo
SET GLOBAL general_log_file = @old_general_log_file;
SET GLOBAL slow_query_log_file = @old_slow_query_log_file;
-if(!$fixed_bug38124)
-{
- --disable_query_log
- let $my_var = `SELECT @old_general_log_file`;
- eval SET @@global.general_log_file = '$my_var';
- let $my_var = `SELECT @old_slow_query_log_file`;
- eval SET @@global.slow_query_log_file = '$my_var';
- --enable_query_log
-}
--echo
--echo # -- End of Bug#32748.
@@ -351,16 +312,6 @@ SET @@global.general_log = @old_general_log;
SET @@global.general_log_file = @old_general_log_file;
SET @@global.slow_query_log = @old_slow_query_log;
SET @@global.slow_query_log_file = @old_slow_query_log_file;
-if(!$fixed_bug38124)
-{
- --disable_query_log
- let $my_var = `SELECT @old_general_log_file`;
- eval SET @@global.general_log_file = '$my_var';
- let $my_var = `SELECT @old_slow_query_log_file`;
- eval SET @@global.slow_query_log_file = '$my_var';
- --enable_query_log
-}
-
###########################################################################
@@ -400,6 +351,40 @@ TRUNCATE TABLE mysql.slow_log;
--echo End of 5.1 tests
+
+###########################################################################
+
+--echo
+--echo # --
+--echo # -- Bug#38124: "general_log_file" variable silently unset when
+--echo # -- using expression
+--echo # --
+
+# Store away the special DEFAULT value so we
+# can compare it later, then try to set the
+# general_log_file using different functions
+# and expressions.
+
+SET GLOBAL general_log_file = DEFAULT;
+SELECT @@general_log_file INTO @my_glf;
+
+SET GLOBAL general_log_file = 'BUG38124.LOG';
+SELECT @@general_log_file;
+
+SET GLOBAL general_log_file = concat('BUG38124-2.LOG');
+SELECT @@general_log_file;
+
+SET GLOBAL general_log_file = substr('BUG38124-2.LOG',3,6);
+SELECT @@general_log_file;
+
+SET GLOBAL general_log_file = DEFAULT;
+SELECT @@general_log_file = @my_glf;
+
+
+## Reset to initial values
+SET GLOBAL general_log_file = @old_general_log_file;
+
+
--enable_ps_protocol
#
@@ -418,17 +403,7 @@ SET global general_log = @old_general_log;
SET global general_log_file = @old_general_log_file;
SET global slow_query_log = @old_slow_query_log;
SET global slow_query_log_file = @old_slow_query_log_file;
-if(!$fixed_bug38124)
-{
- --disable_query_log
- let $my_var = `SELECT @old_general_log_file`;
- eval SET @@global.general_log_file = '$my_var';
- let $my_var = `SELECT @old_slow_query_log_file`;
- eval SET @@global.slow_query_log_file = '$my_var';
- --enable_query_log
-}
-
-# Remove the log files that was created in the "default location"
+
+# Remove the log file that was created in the "default location"
# i.e var/run
---remove_file $MYSQLTEST_VARDIR/run/mysqld.log
--remove_file $MYSQLTEST_VARDIR/tmp/log.master
diff --git a/mysql-test/t/log_state_bug33693-master.opt b/mysql-test/t/log_state_bug33693-master.opt
new file mode 100644
index 00000000000..9f4ae1a0c8f
--- /dev/null
+++ b/mysql-test/t/log_state_bug33693-master.opt
@@ -0,0 +1 @@
+--pid-file=$MYSQLTEST_VARDIR/run/mysqld.1.pid --log=
diff --git a/mysql-test/t/log_state_bug33693.test b/mysql-test/t/log_state_bug33693.test
new file mode 100644
index 00000000000..d67b28fc3e9
--- /dev/null
+++ b/mysql-test/t/log_state_bug33693.test
@@ -0,0 +1,18 @@
+### t/log_state_bug33693.test
+#
+# Regression test for bug #33693
+# "general log name and location depend on PID
+# file, not on predefined values"
+#
+# The server is started with a hard-coded
+# PID file in the $MYSQLTEST_VARDIR/run
+# directory, and an unspecified general log
+# file name.
+#
+# The correct result should show the log file to
+# rest in the database directory. Unfixed, the
+# log file will be in the same directory as the
+# PID.
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT INSTR(@@general_log_file, '$MYSQLTEST_VARDIR/run');
diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test
index af6c34dec37..5b6be217d9d 100644
--- a/mysql-test/t/log_tables.test
+++ b/mysql-test/t/log_tables.test
@@ -258,14 +258,21 @@ set global slow_query_log='OFF';
# check that alter table doesn't work for other engines
set @save_storage_engine= @@session.storage_engine;
set storage_engine= MEMORY;
+# After fixing bug#35765 the error behaivor changed:
+# If compiled in/enabled ER_UNSUPORTED_LOG_ENGINE
+# If not (i.e. not existant) it will show a warning
+# and use the current one.
+alter table mysql.slow_log engine=NonExistentEngine;
--error ER_UNSUPORTED_LOG_ENGINE
-alter table mysql.slow_log engine=ndb;
---error ER_UNSUPORTED_LOG_ENGINE
-alter table mysql.slow_log engine=innodb;
---error ER_UNSUPORTED_LOG_ENGINE
-alter table mysql.slow_log engine=archive;
---error ER_UNSUPORTED_LOG_ENGINE
-alter table mysql.slow_log engine=blackhole;
+alter table mysql.slow_log engine=memory;
+#--error ER_UNSUPORTED_LOG_ENGINE
+#alter table mysql.slow_log engine=ndb;
+#--error ER_UNSUPORTED_LOG_ENGINE
+#alter table mysql.slow_log engine=innodb;
+#--error ER_UNSUPORTED_LOG_ENGINE
+#alter table mysql.slow_log engine=archive;
+#--error ER_UNSUPORTED_LOG_ENGINE
+#alter table mysql.slow_log engine=blackhole;
set storage_engine= @save_storage_engine;
drop table mysql.slow_log;
diff --git a/mysql-test/t/log_tables_debug.test b/mysql-test/t/log_tables_debug.test
index 19a62614608..78a1289b689 100644
--- a/mysql-test/t/log_tables_debug.test
+++ b/mysql-test/t/log_tables_debug.test
@@ -7,6 +7,7 @@
# changed (see explanation in log_state.test)
let $fixed_bug38124 = 0;
+--source include/not_embedded.inc
--source include/have_debug.inc
# Several subtests modify global variables. Save the initial values only here,
diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test
index 86d1e084c29..1be0351f9bc 100644
--- a/mysql-test/t/lowercase_fs_off.test
+++ b/mysql-test/t/lowercase_fs_off.test
@@ -91,3 +91,14 @@ DROP DATABASE db1;
use test;
# End of 5.0 tests
+
+
+--echo #
+--echo # Extra test coverage for Bug#56595 RENAME TABLE causes assert on OS X
+--echo #
+
+CREATE TABLE t1(a INT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a= 1;
+RENAME TABLE t1 TO T1;
+ALTER TABLE T1 RENAME t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test
index 521df01cc9b..30433d15be4 100644
--- a/mysql-test/t/lowercase_table2.test
+++ b/mysql-test/t/lowercase_table2.test
@@ -16,7 +16,7 @@ DROP DATABASE IF EXISTS `test_$1`;
DROP DATABASE IF EXISTS mysqltest_LC2;
--enable_warnings
-CREATE TABLE T1 (a int);
+CREATE TABLE T1 (a int) ENGINE=MyISAM;
INSERT INTO T1 VALUES (1);
SHOW TABLES LIKE "T1";
SHOW TABLES LIKE "t1";
@@ -150,3 +150,110 @@ select TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES
where TABLE_SCHEMA ='mysqltest_LC2';
use test;
drop database mysqltest_LC2;
+
+
+--echo #
+--echo # Bug #11758687: 50924: object names not resolved correctly
+--echo # on lctn2 systems
+--echo #
+
+CREATE DATABASE BUP_XPFM_COMPAT_DB2;
+
+CREATE TABLE BUP_XPFM_COMPAT_DB2.TABLE2 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE BUP_XPFM_COMPAT_DB2.table1 (c13 INT) DEFAULT CHARSET latin1;
+CREATE TABLE bup_xpfm_compat_db2.table3 (c13 INT) DEFAULT CHARSET latin1;
+
+delimiter |;
+#
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.trigger1 AFTER INSERT
+ ON BUP_XPFM_COMPAT_DB2.table1 FOR EACH ROW
+ update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TRIGGER2 AFTER INSERT
+ ON BUP_XPFM_COMPAT_DB2.TABLE2 FOR EACH ROW
+ update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+CREATE TRIGGER BUP_XPFM_COMPAT_DB2.TrigGer3 AFTER INSERT
+ ON BUP_XPFM_COMPAT_DB2.TaBle3 FOR EACH ROW
+ update BUP_XPFM_COMPAT_DB2.table1 set c13=12;
+|
+delimiter ;|
+
+SELECT trigger_schema, trigger_name, event_object_table FROM
+INFORMATION_SCHEMA.TRIGGERS
+ WHERE trigger_schema COLLATE utf8_bin = 'BUP_XPFM_COMPAT_DB2'
+ ORDER BY trigger_schema, trigger_name;
+
+DROP DATABASE BUP_XPFM_COMPAT_DB2;
+
+--echo # End of 5.1 tests
+
+
+--echo #
+--echo # Test for bug #44738 "fill_schema_table_from_frm() opens tables without
+--echo # lowercasing table name". Due to not properly normalizing table names
+--echo # in lower_case_table_names modes in this function queries to I_S which
+--echo # were executed through it left entries with incorrect key in table
+--echo # definition cache. As result further queries to I_S that used this
+--echo # function produced stale results in cases when table definition was
+--echo # changed by a DDL statement. Also combination of this issue and a
+--echo # similar problem in CREATE TABLE (it also has peeked into table
+--echo # definition cache using non-normalized key) led to spurious
+--echo # ER_TABLE_EXISTS_ERROR errors when one tried to create table with the
+--echo # same name as a previously existing but dropped table.
+--echo #
+--disable_warnings
+drop database if exists mysqltest_UPPERCASE;
+drop table if exists t_bug44738_UPPERCASE;
+--enable_warnings
+create database mysqltest_UPPERCASE;
+use mysqltest_UPPERCASE;
+create table t_bug44738_UPPERCASE (i int) comment='Old comment';
+create table t_bug44738_lowercase (i int) comment='Old comment';
+select table_schema, table_name, table_comment from information_schema.tables
+ where table_schema like 'mysqltest_%' and table_name like 't_bug44738_%'
+ order by table_name;
+alter table t_bug44738_UPPERCASE comment='New comment';
+alter table t_bug44738_lowercase comment='New comment';
+--echo # There should be no stale entries in TDC for our tables after the
+--echo # above ALTER TABLE statements so new version of comments should be
+--echo # returned by the below query to I_S.
+select table_schema, table_name, table_comment from information_schema.tables
+ where table_schema like 'mysqltest_%' and table_name like 't_bug44738_%'
+ order by table_name;
+drop database mysqltest_UPPERCASE;
+use test;
+
+--echo # Let us check that the original test case which led to discovery
+--echo # of this problem also works.
+create table t_bug44738_UPPERCASE (i int);
+select table_schema, table_name, table_comment from information_schema.tables
+ where table_schema = 'test' and table_name like 't_bug44738_%';
+drop table t_bug44738_UPPERCASE;
+--echo # After the above DROP TABLE there are no entries in TDC which correspond
+--echo # to our table and therefore the below statement should succeed.
+create table t_bug44738_UPPERCASE (i int);
+drop table t_bug44738_UPPERCASE;
+
+--echo # Finally, let us check that another issue which was exposed by
+--echo # the original test case is solved. I.e. that the table is not
+--echo # created if there is an entry for it in TDC even though it was
+--echo # removed from disk.
+create table t_bug44738_UPPERCASE (i int) engine = myisam;
+--echo # Load table definition in TDC.
+select table_schema, table_name, table_comment from information_schema.tables
+ where table_schema = 'test' and table_name like 't_bug44738_%';
+--echo # Simulate manual removal of the table.
+let $MYSQLD_DATADIR= `select @@datadir`;
+--remove_file $MYSQLD_DATADIR/test/t_bug44738_UPPERCASE.frm
+--remove_file $MYSQLD_DATADIR/test/t_bug44738_UPPERCASE.MYD
+--remove_file $MYSQLD_DATADIR/test/t_bug44738_UPPERCASE.MYI
+--echo # Check that still there is an entry for table in TDC.
+show open tables like 't_bug44738_%';
+--echo # So attempt to create table with the same name should fail.
+--error ER_FILE_NOT_FOUND
+create table t_bug44738_UPPERCASE (i int);
+--echo # And should succeed after FLUSH TABLES.
+flush tables;
+create table t_bug44738_UPPERCASE (i int);
+drop table t_bug44738_UPPERCASE;
diff --git a/mysql-test/t/lowercase_table4.test b/mysql-test/t/lowercase_table4.test
index 93956047145..783a4fcae51 100755
--- a/mysql-test/t/lowercase_table4.test
+++ b/mysql-test/t/lowercase_table4.test
@@ -53,4 +53,56 @@ eval SELECT * FROM XY.T_$tcs LIMIT 1;
--enable_query_log
--enable_result_log
DROP DATABASE XY;
+USE TEST;
+
+--echo #
+--echo # Bug55222 Mysqldump table names case bug in REFERENCES clause
+--echo # InnoDB did not handle lower_case_table_names=2 for
+--echo # foreign_table_names and referenced_table_names.
+--echo #
+
+SHOW VARIABLES LIKE 'lower_case_table_names';
+
+--disable_warnings
+DROP TABLE IF EXISTS `Table2`;
+DROP TABLE IF EXISTS `Table1`;
+--disable_warnings
+
+CREATE TABLE `Table1`(c1 INT PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE `Table2`(c1 INT PRIMARY KEY, c2 INT) ENGINE=InnoDB;
+ALTER TABLE `Table2` ADD CONSTRAINT fk1 FOREIGN KEY(c2) REFERENCES `Table1`(c1);
+query_vertical SHOW CREATE TABLE `Table2`;
+query_vertical SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS;
+DROP TABLE `Table2`;
+DROP TABLE `Table1`;
+
+--disable_warnings
+DROP TABLE IF EXISTS Product_Order;
+DROP TABLE IF EXISTS Product;
+DROP TABLE IF EXISTS Customer;
+--enable_warnings
+
+CREATE TABLE Product (Category INT NOT NULL, Id INT NOT NULL,
+ Price DECIMAL, PRIMARY KEY(Category, Id)) ENGINE=InnoDB;
+CREATE TABLE Customer (Id INT NOT NULL, PRIMARY KEY (Id)) ENGINE=InnoDB;
+CREATE TABLE Product_Order (No INT NOT NULL AUTO_INCREMENT,
+ Product_Category INT NOT NULL,
+ Product_Id INT NOT NULL,
+ Customer_Id INT NOT NULL,
+ PRIMARY KEY(No),
+ INDEX (Product_Category, Product_Id),
+ FOREIGN KEY (Product_Category, Product_Id)
+ REFERENCES Product(Category, Id) ON UPDATE CASCADE ON DELETE RESTRICT,
+ INDEX (Customer_Id),
+ FOREIGN KEY (Customer_Id)
+ REFERENCES Customer(Id)
+ ) ENGINE=INNODB;
+
+query_vertical SHOW CREATE TABLE Product_Order;
+query_vertical SHOW CREATE TABLE Product;
+query_vertical SHOW CREATE TABLE Customer;
+query_vertical SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS;
+DROP TABLE Product_Order;
+DROP TABLE Product;
+DROP TABLE Customer;
diff --git a/mysql-test/t/mdl_sync-master.opt b/mysql-test/t/mdl_sync-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/mdl_sync-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/mdl_sync.test b/mysql-test/t/mdl_sync.test
new file mode 100644
index 00000000000..197cad536e4
--- /dev/null
+++ b/mysql-test/t/mdl_sync.test
@@ -0,0 +1,4609 @@
+#
+# We need the Debug Sync Facility.
+#
+--source include/have_debug_sync.inc
+
+# We need InnoDB tables for some of the tests.
+--source include/have_innodb.inc
+
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+
+# Clean up resources used in this test case.
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+--enable_warnings
+
+#
+# Test the case of when a exclusive lock request waits for a
+# shared lock being upgraded to a exclusive lock.
+#
+
+connect (con1,localhost,root,,test,,);
+connect (con2,localhost,root,,test,,);
+connect (con3,localhost,root,,test,,);
+
+connection default;
+
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+create table t1 (i int);
+create table t2 (i int);
+
+--echo connection: default
+lock tables t2 read;
+
+connection con1;
+--echo connection: con1
+set debug_sync='mdl_upgrade_shared_lock_to_exclusive SIGNAL parked WAIT_FOR go';
+--send alter table t1 rename t3
+
+connection default;
+--echo connection: default
+set debug_sync= 'now WAIT_FOR parked';
+
+connection con2;
+--echo connection: con2
+set debug_sync='mdl_acquire_lock_wait SIGNAL go';
+--send drop table t1,t2
+
+connection con1;
+--echo connection: con1
+--reap
+
+connection default;
+--echo connection: default
+unlock tables;
+
+connection con2;
+--echo connection: con2
+--error ER_BAD_TABLE_ERROR
+--reap
+
+connection default;
+drop table t3;
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+# Clean up resources used in this test case.
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+--enable_warnings
+
+
+--echo #
+--echo # Basic test coverage for type-of-operation aware metadata locks.
+--echo #
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+connect(mdl_con1,localhost,root,,);
+connect(mdl_con2,localhost,root,,);
+connect(mdl_con3,localhost,root,,);
+connection default;
+set debug_sync= 'RESET';
+create table t1 (c1 int);
+
+--echo #
+--echo # A) First let us check compatibility rules between differend kinds of
+--echo # type-of-operation aware metadata locks.
+--echo # Of course, these rules are already covered by the tests scattered
+--echo # across the test suite. But it still makes sense to have one place
+--echo # which covers all of them.
+--echo #
+
+--echo # 1) Acquire S (simple shared) lock on the table (by using HANDLER):
+--echo #
+handler t1 open;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that S, SH, SR and SW locks are compatible with it.
+handler t1 open t;
+handler t close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+select count(*) from t1;
+insert into t1 values (1), (1);
+--echo # Check that SNW lock is compatible with it. To do this use ALTER TABLE
+--echo # which will fail after opening the table and thus obtaining SNW metadata
+--echo # lock.
+--error ER_DUP_ENTRY
+alter table t1 add primary key (c1);
+--echo # Check that SNRW lock is compatible with S lock.
+lock table t1 write;
+insert into t1 values (1);
+unlock tables;
+--echo # Check that X lock is incompatible with S lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above RENAME is blocked because of S lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Unblock RENAME TABLE.
+handler t1 close;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping RENAME TABLE.
+--reap
+--echo # Restore the original state of the things.
+rename table t2 to t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+handler t1 open;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that upgrade from SNW to X is blocked by presence of S lock.
+--echo # Sending:
+--send alter table t1 add column c2 int;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above ALTER TABLE is blocked because of S lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c2 int";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Unblock ALTER TABLE.
+handler t1 close;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--reap
+--echo # Restore the original state of the things.
+alter table t1 drop column c2;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+handler t1 open;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that upgrade from SNRW to X is blocked by presence of S lock.
+lock table t1 write;
+--echo # Sending:
+--send alter table t1 add column c2 int;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above upgrade of SNRW to X in ALTER TABLE is blocked
+--echo # because of S lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c2 int";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Unblock ALTER TABLE.
+handler t1 close;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--reap
+--echo # Restore the original state of the things.
+alter table t1 drop column c2;
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo # 2) Acquire SH (shared high-priority) lock on the table.
+--echo # We have to involve DEBUG_SYNC facility for this as usually
+--echo # such kind of locks are short-lived.
+--echo #
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Check that S, SH, SR and SW locks are compatible with it.
+handler t1 open;
+handler t1 close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+select count(*) from t1;
+insert into t1 values (1);
+--echo # Check that SNW lock is compatible with it. To do this use ALTER TABLE
+--echo # which will fail after opening the table and thus obtaining SNW metadata
+--echo # lock.
+--error ER_DUP_ENTRY
+alter table t1 add primary key (c1);
+--echo # Check that SNRW lock is compatible with SH lock.
+lock table t1 write;
+delete from t1 limit 1;
+unlock tables;
+--echo # Check that X lock is incompatible with SH lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above RENAME is blocked because of SH lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping SELECT ... FROM I_S.
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping RENAME TABLE.
+--reap
+--echo # Restore the original state of the things.
+rename table t2 to t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Check that upgrade from SNW to X is blocked by presence of SH lock.
+--echo # Sending:
+--send alter table t1 add column c2 int;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above ALTER TABLE is blocked because of SH lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c2 int";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping SELECT ... FROM I_S.
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--reap
+--echo # Restore the original state of the things.
+alter table t1 drop column c2;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1';
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Check that upgrade from SNRW to X is blocked by presence of S lock.
+lock table t1 write;
+--echo # Sending:
+--send alter table t1 add column c2 int;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above upgrade of SNRW to X in ALTER TABLE is blocked
+--echo # because of S lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c2 int";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping SELECT ... FROM I_S.
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--reap
+--echo # Restore the original state of the things.
+alter table t1 drop column c2;
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo #
+--echo # 3) Acquire SR lock on the table.
+--echo #
+--echo #
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that S, SH, SR and SW locks are compatible with it.
+handler t1 open;
+handler t1 close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+select count(*) from t1;
+insert into t1 values (1);
+--echo # Check that SNW lock is compatible with it. To do this use ALTER TABLE
+--echo # which will fail after opening the table and thus obtaining SNW metadata
+--echo # lock.
+--error ER_DUP_ENTRY
+alter table t1 add primary key (c1);
+--echo # Check that SNRW lock is not compatible with SR lock.
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above LOCK TABLES is blocked because of SR lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Unblock LOCK TABLES.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping LOCK TABLES.
+--reap
+delete from t1 limit 1;
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that X lock is incompatible with SR lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above RENAME is blocked because of SR lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping RENAME TABLE.
+--reap
+--echo # Restore the original state of the things.
+rename table t2 to t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that upgrade from SNW to X is blocked by presence of SR lock.
+--echo # Sending:
+--send alter table t1 add column c2 int;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above ALTER TABLE is blocked because of SR lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c2 int";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Unblock ALTER TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--reap
+--echo # Restore the original state of the things.
+alter table t1 drop column c2;
+--echo #
+--echo # There is no need to check that upgrade from SNRW to X is blocked
+--echo # by presence of SR lock because SNRW is incompatible with SR anyway.
+--echo #
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo #
+--echo # 4) Acquire SW lock on the table.
+--echo #
+--echo #
+begin;
+insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that S, SH, SR and SW locks are compatible with it.
+handler t1 open;
+handler t1 close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+--echo # Disable result log to make test robust against
+--echo # effects of concurrent insert.
+--disable_result_log
+select * from t1;
+--enable_result_log
+insert into t1 values (1);
+--echo # Check that SNW lock is not compatible with SW lock.
+--echo # Again we use ALTER TABLE which fails after opening
+--echo # the table to avoid upgrade of SNW -> X.
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above ALTER TABLE is blocked because of SW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add primary key (c1)";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that SNRW lock is not compatible with SW lock.
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above LOCK TABLES is blocked because of SW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Unblock LOCK TABLES.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping LOCK TABLES.
+--reap
+delete from t1 limit 2;
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+begin;
+insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that X lock is incompatible with SW lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above RENAME is blocked because of SW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping RENAME TABLE.
+--reap
+--echo # Restore the original state of the things.
+rename table t2 to t1;
+--echo #
+--echo # There is no need to check that upgrade from SNW/SNRW to X is
+--echo # blocked by presence of SW lock because SNW/SNRW is incompatible
+--echo # with SW anyway.
+--echo #
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo #
+--echo # 5) Acquire SNW lock on the table. We have to use DEBUG_SYNC for
+--echo # this, to prevent SNW from being immediately upgraded to X.
+--echo #
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Check that S, SH and SR locks are compatible with it.
+handler t1 open;
+handler t1 close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+select count(*) from t1;
+--echo # Check that SW lock is incompatible with SNW lock.
+--echo # Sending:
+--send delete from t1 limit 2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above DELETE is blocked because of SNW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "delete from t1 limit 2";
+--source include/wait_condition.inc
+--echo # Unblock ALTER and thus DELETE.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping DELETE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Check that SNW lock is incompatible with SNW lock.
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above ALTER is blocked because of SNW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add primary key (c1)";
+--source include/wait_condition.inc
+--echo # Unblock ALTERs.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping first ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping another ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Check that SNRW lock is incompatible with SNW lock.
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above LOCK TABLES is blocked because of SNW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Unblock ALTER and thus LOCK TABLES.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping LOCK TABLES
+--reap
+insert into t1 values (1);
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Check that X lock is incompatible with SNW lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above RENAME is blocked because of SNW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Unblock ALTER and thus RENAME TABLE.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping RENAME TABLE
+--reap
+--echo # Revert back to original state of things.
+rename table t2 to t1;
+--echo #
+--echo # There is no need to check that upgrade from SNW/SNRW to X is
+--echo # blocked by presence of another SNW lock because SNW/SNRW is
+--echo # incompatible with SNW anyway.
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo #
+--echo # 6) Acquire SNRW lock on the table.
+--echo #
+--echo #
+lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that S and SH locks are compatible with it.
+handler t1 open;
+handler t1 close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+--echo # Check that SR lock is incompatible with SNRW lock.
+--echo # Sending:
+--send select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above SELECT is blocked because of SNRW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "select count(*) from t1";
+--source include/wait_condition.inc
+--echo # Unblock SELECT.
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping SELECT.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that SW lock is incompatible with SNRW lock.
+--echo # Sending:
+--send delete from t1 limit 1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above DELETE is blocked because of SNRW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "delete from t1 limit 1";
+--source include/wait_condition.inc
+--echo # Unblock DELETE.
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping DELETE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that SNW lock is incompatible with SNRW lock.
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above ALTER is blocked because of UNWR lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add primary key (c1)";
+--source include/wait_condition.inc
+--echo # Unblock ALTER.
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that SNRW lock is incompatible with SNRW lock.
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above LOCK TABLES is blocked because of SNRW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Unblock waiting LOCK TABLES.
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping LOCK TABLES
+--reap
+insert into t1 values (1);
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that X lock is incompatible with SNRW lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Check that the above RENAME is blocked because of SNRW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping RENAME TABLE
+--reap
+--echo # Revert back to original state of things.
+rename table t2 to t1;
+--echo #
+--echo # There is no need to check that upgrade from SNW/SNRW to X is
+--echo # blocked by presence of another SNRW lock because SNW/SNRW is
+--echo # incompatible with SNRW anyway.
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo #
+--echo # 7) Now do the same round of tests for X lock. We use additional
+--echo # table to get long-lived lock of this type.
+--echo #
+create table t2 (c1 int);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Take a lock on t2, so RENAME TABLE t1 TO t2 will get blocked
+--echo # after acquiring X lock on t1.
+lock tables t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME has acquired X lock on t1 and is waiting for t2.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that S lock in incompatible with X lock.
+--echo # Sending:
+--send handler t1 open;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above HANDLER statement is blocked because of X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "handler t1 open";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping HANDLER.
+--reap
+handler t1 close;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Prepare for blocking RENAME TABLE.
+lock tables t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME has acquired X lock on t1 and is waiting for t2.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SH lock in incompatible with X lock.
+--echo # Sending:
+--send select column_name from information_schema.columns where table_schema='test' and table_name='t1';
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above SELECT ... FROM I_S ... statement is blocked
+--echo # because of X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info like "select column_name from information_schema.columns%";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping SELECT ... FROM I_S.
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Prepare for blocking RENAME TABLE.
+lock tables t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME has acquired X lock on t1 and is waiting for t2.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SR lock in incompatible with X lock.
+--echo # Sending:
+--send select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above SELECT statement is blocked
+--echo # because of X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "select count(*) from t1";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping SELECT.
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Prepare for blocking RENAME TABLE.
+lock tables t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME has acquired X lock on t1 and is waiting for t2.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SW lock in incompatible with X lock.
+--echo # Sending:
+--send delete from t1 limit 1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above DELETE statement is blocked
+--echo # because of X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "delete from t1 limit 1";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping DELETE.
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Prepare for blocking RENAME TABLE.
+lock tables t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME has acquired X lock on t1 and is waiting for t2.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SNW lock is incompatible with X lock.
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above ALTER statement is blocked
+--echo # because of X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add primary key (c1)";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Prepare for blocking RENAME TABLE.
+lock tables t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME has acquired X lock on t1 and is waiting for t2.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SNRW lock is incompatible with X lock.
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above LOCK TABLE statement is blocked
+--echo # because of X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping LOCK TABLE.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Prepare for blocking RENAME TABLE.
+lock tables t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME has acquired X lock on t1 and is waiting for t2.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that X lock is incompatible with X lock.
+--echo # Sending:
+--send rename table t1 to t3;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above RENAME statement is blocked
+--echo # because of X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t3";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping RENAME.
+--reap
+rename table t3 to t1;
+
+--echo #
+--echo # B) Now let us test compatibility in cases when both locks
+--echo # are pending. I.e. let us test rules for priorities between
+--echo # different types of metadata locks.
+--echo #
+
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo #
+--echo # 1) Check compatibility for pending SNW lock.
+--echo #
+--echo # Acquire SW lock in order to create pending SNW lock later.
+begin;
+insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Add pending SNW lock.
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that ALTER TABLE is waiting with pending SNW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add primary key (c1)";
+--source include/wait_condition.inc
+--echo # Check that S, SH and SR locks are compatible with pending SNW
+handler t1 open t;
+handler t close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+select count(*) from t1;
+--echo # Check that SW is incompatible with pending SNW
+--echo # Sending:
+--send delete from t1 limit 1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above DELETE is blocked because of pending SNW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "delete from t1 limit 1";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping ALTER.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping DELETE.
+--reap
+--echo #
+--echo # We can't do similar check for SNW, SNRW and X locks because
+--echo # they will also be blocked by active SW lock.
+--echo #
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo #
+--echo # 2) Check compatibility for pending SNRW lock.
+--echo #
+--echo # Acquire SR lock in order to create pending SNRW lock.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Add pending SNRW lock.
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that LOCK TABLE is waiting with pending SNRW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Check that S and SH locks are compatible with pending SNRW
+handler t1 open t;
+handler t close;
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+--echo # Check that SR is incompatible with pending SNRW
+--echo # Sending:
+--send select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above SELECT is blocked because of pending SNRW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "select count(*) from t1";
+--source include/wait_condition.inc
+--echo # Unblock LOCK TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping LOCK TABLE.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping SELECT.
+--reap
+--echo # Restore pending SNRW lock.
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that LOCK TABLE is waiting with pending SNRW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Check that SW is incompatible with pending SNRW
+--echo # Sending:
+--send insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above INSERT is blocked because of pending SNRW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "insert into t1 values (1)";
+--source include/wait_condition.inc
+--echo # Unblock LOCK TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping LOCK TABLE.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping INSERT.
+--reap
+--echo # Restore pending SNRW lock.
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that LOCK TABLE is waiting with pending SNRW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Check that SNW is compatible with pending SNRW
+--echo # So ALTER TABLE statements are not starved by LOCK TABLEs.
+--error ER_DUP_ENTRY
+alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Unblock LOCK TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping LOCK TABLE.
+--reap
+unlock tables;
+--echo #
+--echo # We can't do similar check for SNRW and X locks because
+--echo # they will also be blocked by active SR lock.
+--echo #
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo #
+--echo # 3) Check compatibility for pending X lock.
+--echo #
+--echo # Acquire SR lock in order to create pending X lock.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Add pending X lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME TABLE is waiting with pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SH locks are compatible with pending X
+select column_name from information_schema.columns where
+ table_schema='test' and table_name='t1';
+--echo # Check that S is incompatible with pending X
+--echo # Sending:
+--send handler t1 open;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above HANDLER OPEN is blocked because of pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "handler t1 open";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping HANDLER t1 OPEN.
+--reap
+handler t1 close;
+--echo # Restore pending X lock.
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Add pending X lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME TABLE is waiting with pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SR is incompatible with pending X
+--echo # Sending:
+--send select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above SELECT is blocked because of pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "select count(*) from t1";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping SELECT.
+--reap
+--echo # Restore pending X lock.
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Add pending X lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME TABLE is waiting with pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SW is incompatible with pending X
+--echo # Sending:
+--send delete from t1 limit 1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above DELETE is blocked because of pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "delete from t1 limit 1";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping DELETE.
+--reap
+--echo # Restore pending X lock.
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Add pending X lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME TABLE is waiting with pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SNW is incompatible with pending X
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above ALTER TABLE is blocked because of pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add primary key (c1)";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo # Restore pending X lock.
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+handler t1 open;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Add pending X lock.
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that RENAME TABLE is waiting with pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that SNRW is incompatible with pending X
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'mdl_con3'.
+connection mdl_con3;
+--echo # Check that the above LOCK TABLES is blocked because of pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Unblock RENAME TABLE.
+handler t1 close;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reaping LOCK TABLES.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo #
+--echo #
+--echo # C) Now let us test how type-of-operation locks are handled in
+--echo # transactional context. Obviously we are mostly interested
+--echo # in conflicting types of locks.
+--echo #
+
+--echo #
+--echo # 1) Let us check how various locks used within transactional
+--echo # context interact with active/pending SNW lock.
+--echo #
+--echo # We start with case when we are acquiring lock on the table
+--echo # which was not used in the transaction before.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create an active SNW lock on t2.
+--echo # We have to use DEBUG_SYNC facility as otherwise SNW lock
+--echo # will be immediately released (or upgraded to X lock).
+insert into t2 values (1), (1);
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send alter table t2 add primary key (c1);
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # SR lock should be acquired without any waiting.
+select count(*) from t2;
+commit;
+--echo # Now let us check that we will wait in case of SW lock.
+begin;
+select count(*) from t1;
+--echo # Sending:
+--send insert into t2 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above INSERT is blocked.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "insert into t2 values (1)";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE and thus INSERT.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap INSERT.
+--reap
+commit;
+--echo #
+--echo # Now let us see what happens when we are acquiring lock on the table
+--echo # which is already used in transaction.
+--echo #
+--echo # *) First, case when transaction which has SR lock on the table also
+--echo # locked in SNW mode acquires yet another SR lock and then tries
+--echo # to acquire SW lock.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create an active SNW lock on t1.
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync= 'now WAIT_FOR locked';
+--echo # We should still be able to get SR lock without waiting.
+select count(*) from t1;
+--echo # Since the above ALTER TABLE is not upgrading SNW lock to X by waiting
+--echo # for SW lock we won't create deadlock.
+--echo # So the below INSERT should not end-up with ER_LOCK_DEADLOCK error.
+--echo # Sending:
+--send insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above INSERT is blocked.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "insert into t1 values (1)";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE and thus INSERT.
+set debug_sync= 'now SIGNAL finish';
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap INSERT.
+--reap
+commit;
+--echo #
+--echo # **) Now test in which transaction that has SW lock on the table
+--echo # against which there is pending SNW lock acquires SR and SW
+--echo # locks on this table.
+--echo #
+begin;
+insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create pending SNW lock on t1.
+--echo # Sending:
+--send alter table t1 add primary key (c1);
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE starts waiting for SNW lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add primary key (c1)";
+--source include/wait_condition.inc
+--echo # We should still be able to get both SW and SR locks without waiting.
+select count(*) from t1;
+delete from t1 limit 1;
+--echo # Unblock ALTER TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap ALTER TABLE.
+--error ER_DUP_ENTRY
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo # 2) Now similar tests for active SNW lock which is being upgraded
+--echo # to X lock.
+--echo #
+--echo # Again we start with case when we are acquiring lock on the
+--echo # table which was not used in the transaction before.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Start transaction which will prevent SNW -> X upgrade from
+--echo # completing immediately.
+begin;
+select count(*) from t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create SNW lock pending upgrade to X on t2.
+--echo # Sending:
+--send alter table t2 add column c2 int;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE starts waiting X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "alter table t2 add column c2 int";
+--source include/wait_condition.inc
+--echo # Check that attempt to acquire SR lock on t2 causes waiting.
+--echo # Sending:
+--send select count(*) from t2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above SELECT is blocked.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "select count(*) from t2";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap ALTER TABLE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap SELECT.
+--reap
+commit;
+--echo # Do similar check for SW lock.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Start transaction which will prevent SNW -> X upgrade from
+--echo # completing immediately.
+begin;
+select count(*) from t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create SNW lock pending upgrade to X on t2.
+--echo # Sending:
+--send alter table t2 drop column c2;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE starts waiting X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "alter table t2 drop column c2";
+--source include/wait_condition.inc
+--echo # Check that attempt to acquire SW lock on t2 causes waiting.
+--echo # Sending:
+--send insert into t2 values (1);
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above INSERT is blocked.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "insert into t2 values (1)";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap ALTER TABLE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap INSERT.
+--reap
+commit;
+--echo #
+--echo # Test for the case in which we are acquiring lock on the table
+--echo # which is already used in transaction.
+--echo #
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create SNW lock pending upgrade to X.
+--echo # Sending:
+--send alter table t1 add column c2 int;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE starts waiting X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column c2 int";
+--source include/wait_condition.inc
+--echo # Check that transaction is still able to acquire SR lock.
+select count(*) from t1;
+--echo # Waiting trying to acquire SW lock will cause deadlock and
+--echo # therefore should cause an error.
+--error ER_LOCK_DEADLOCK
+delete from t1 limit 1;
+--echo # Unblock ALTER TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap ALTER TABLE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo # 3) Check how various locks used within transactional context
+--echo # interact with active/pending SNRW lock.
+--echo #
+--echo # Once again we start with case when we are acquiring lock on
+--echo # the table which was not used in the transaction before.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+lock table t2 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Attempt to acquire SR should be blocked. It should
+--echo # not cause errors as it does not creates deadlock.
+--echo # Sending:
+--send select count(*) from t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that the above SELECT is blocked
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "select count(*) from t2";
+--source include/wait_condition.inc
+--echo # Unblock SELECT.
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap SELECT.
+--reap
+commit;
+--echo # Repeat the same test for SW lock.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+lock table t2 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Again attempt to acquire SW should be blocked and should
+--echo # not cause any errors.
+--echo # Sending:
+--send delete from t2 limit 1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Check that the above DELETE is blocked
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "delete from t2 limit 1";
+--source include/wait_condition.inc
+--echo # Unblock DELETE.
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap DELETE.
+--reap
+commit;
+--echo #
+--echo # Now coverage for the case in which we are acquiring lock on
+--echo # the table which is already used in transaction and against
+--echo # which there is a pending SNRW lock request.
+--echo #
+--echo # *) Let us start with case when transaction has only a SR lock.
+--echo #
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until LOCK TABLE is blocked creating pending request for X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Check that another instance of SR lock is granted without waiting.
+select count(*) from t1;
+--echo # Attempt to wait for SW lock will lead to deadlock, thus
+--echo # the below statement should end with ER_LOCK_DEADLOCK error.
+--error ER_LOCK_DEADLOCK
+delete from t1 limit 1;
+--echo # Unblock LOCK TABLES.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap LOCK TABLES.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo # **) Now case when transaction has a SW lock.
+--echo #
+begin;
+delete from t1 limit 1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Sending:
+--send lock table t1 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until LOCK TABLE is blocked creating pending request for X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "lock table t1 write";
+--source include/wait_condition.inc
+--echo # Check that both SR and SW locks are granted without waiting
+--echo # and errors.
+select count(*) from t1;
+insert into t1 values (1, 1);
+--echo # Unblock LOCK TABLES.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap LOCK TABLES.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo # 4) Check how various locks used within transactional context
+--echo # interact with active/pending X lock.
+--echo #
+--echo # As usual we start with case when we are acquiring lock on
+--echo # the table which was not used in the transaction before.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Start transaction which will prevent X lock from going away
+--echo # immediately.
+begin;
+select count(*) from t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create pending X lock on t2.
+--echo # Sending:
+--send rename table t2 to t3;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until RENAME TABLE starts waiting with pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t2 to t3";
+--source include/wait_condition.inc
+--echo # Check that attempt to acquire SR lock on t2 causes waiting.
+--echo # Sending:
+--send select count(*) from t2;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above SELECT is blocked.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "select count(*) from t2";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap RENAME TABLE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap SELECT.
+--error ER_NO_SUCH_TABLE
+--reap
+commit;
+rename table t3 to t2;
+--echo # The same test for SW lock.
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Start transaction which will prevent X lock from going away
+--echo # immediately.
+begin;
+select count(*) from t2;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Create pending X lock on t2.
+--echo # Sending:
+--send rename table t2 to t3;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until RENAME TABLE starts waiting with pending X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t2 to t3";
+--source include/wait_condition.inc
+--echo # Check that attempt to acquire SW lock on t2 causes waiting.
+--echo # Sending:
+--send delete from t2 limit 1;
+--echo #
+--echo # Switching to connection 'mdl_con2'.
+connection mdl_con2;
+--echo # Check that the above DELETE is blocked.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "delete from t2 limit 1";
+--source include/wait_condition.inc
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap RENAME TABLE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap DELETE.
+--error ER_NO_SUCH_TABLE
+--reap
+commit;
+rename table t3 to t2;
+--echo #
+--echo # Coverage for the case in which we are acquiring lock on
+--echo # the table which is already used in transaction and against
+--echo # which there is a pending X lock request.
+--echo #
+--echo # *) The first case is when transaction has only a SR lock.
+--echo #
+begin;
+select count(*) from t1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until RENAME TABLE is blocked creating pending request for X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that another instance of SR lock is granted without waiting.
+select count(*) from t1;
+--echo # Attempt to wait for SW lock will lead to deadlock, thus
+--echo # the below statement should end with ER_LOCK_DEADLOCK error.
+--error ER_LOCK_DEADLOCK
+delete from t1 limit 1;
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo # **) The second case is when transaction has a SW lock.
+--echo #
+begin;
+delete from t1 limit 1;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Sending:
+--send rename table t1 to t2;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until RENAME TABLE is blocked creating pending request for X lock.
+let $wait_condition=
+select count(*) = 1 from information_schema.processlist
+where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t2";
+--source include/wait_condition.inc
+--echo # Check that both SR and SW locks are granted without waiting
+--echo # and errors.
+select count(*) from t1;
+insert into t1 values (1, 1);
+--echo # Unblock RENAME TABLE.
+commit;
+--echo #
+--echo # Switching to connection 'mdl_con1'.
+connection mdl_con1;
+--echo # Reap RENAME TABLE.
+--error ER_TABLE_EXISTS_ERROR
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo # Clean-up.
+disconnect mdl_con1;
+disconnect mdl_con2;
+disconnect mdl_con3;
+set debug_sync= 'RESET';
+drop table t1, t2;
+
+
+--echo #
+--echo # Additional coverage for some scenarios in which not quite
+--echo # correct use of S metadata locks by HANDLER statement might
+--echo # have caused deadlocks.
+--echo #
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+connect(handler_con1,localhost,root,,);
+connect(handler_con2,localhost,root,,);
+connection default;
+create table t1 (i int);
+create table t2 (j int);
+insert into t1 values (1);
+
+--echo #
+--echo # First, check scenario in which we upgrade SNRW lock to X lock
+--echo # on a table while having HANDLER READ trying to acquire TL_READ
+--echo # on the same table.
+--echo #
+handler t1 open;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+lock table t1 write;
+--echo # Upgrade SNRW to X lock.
+--echo # Sending:
+--send alter table t1 add column j int;
+--echo #
+--echo # Switching to connection 'handler_con2'.
+connection handler_con2;
+--echo # Wait until ALTER is blocked during upgrade.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column j int";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # The below statement should not cause deadlock.
+--send handler t1 read first;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+--echo # Reap ALTER TABLE.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap HANDLER READ.
+--reap
+handler t1 close;
+
+--echo #
+--echo # Now, check scenario in which upgrade of SNRW lock to X lock
+--echo # can be blocked by HANDLER which is open in connection currently
+--echo # waiting to get table-lock owned by connection doing upgrade.
+--echo #
+handler t1 open;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+lock table t1 write, t2 read;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Execute statement which will be blocked on table-level lock
+--echo # owned by connection 'handler_con1'.
+--echo # Sending:
+--send insert into t2 values (1);
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+--echo # Wait until INSERT is blocked on table-level lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table level lock" and
+ info = "insert into t2 values (1)";
+--source include/wait_condition.inc
+--echo # Sending 'alter table t1 drop column j'. It should not cause
+--echo # deadlock.
+send alter table t1 drop column j;
+--echo # Switching to connection 'handler_con2'.
+connection handler_con2;
+--echo # Wait until ALTER is blocked during upgrade.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 drop column j";
+--source include/wait_condition.inc
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap INSERT.
+--error ER_LOCK_ABORTED
+--reap
+handler t1 close;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+--echo # Reaping 'alter table t1 drop column j'
+--reap
+unlock tables;
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo # Then, check the scenario in which upgrade of SNRW lock to X
+--echo # lock is blocked by HANDLER which is open in connection currently
+--echo # waiting to get SW lock on the same table.
+--echo #
+handler t1 open;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+lock table t1 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # The below insert should be blocked because active SNRW lock on 't1'.
+--echo # Sending:
+--send insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+--echo # Wait until INSERT is blocked because of SNRW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "insert into t1 values (1)";
+--source include/wait_condition.inc
+--echo # The below ALTER TABLE will be blocked because of presence of HANDLER.
+--echo # Sending:
+--send alter table t1 add column j int;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # INSERT should be chosen as victim for resolving deadlock.
+--echo # Reaping INSERT.
+--error ER_LOCK_DEADLOCK
+--reap
+--echo # Close HANDLER to unblock ALTER TABLE.
+handler t1 close;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+--echo # Reaping ALTER TABLE.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo #
+--echo # Finally, test in which upgrade of SNRW lock to X lock is blocked
+--echo # by HANDLER which is open in connection currently waiting to get
+--echo # SR lock on the table on which lock is upgraded.
+--echo #
+handler t1 open;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+lock table t1 write, t2 write;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # The below insert should be blocked because active SNRW lock on 't1'.
+--echo # Sending:
+--send insert into t2 values (1);
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+--echo # Wait until INSERT is blocked because of SNRW lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "insert into t2 values (1)";
+--source include/wait_condition.inc
+--echo # The below ALTER TABLE will be blocked because of presence of HANDLER.
+--echo # Sending:
+--send alter table t1 drop column j;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # INSERT should be chosen as victim for resolving deadlock.
+--echo # Reaping INSERT.
+--error ER_LOCK_DEADLOCK
+--reap
+--echo # Close HANDLER to unblock ALTER TABLE.
+handler t1 close;
+--echo #
+--echo # Switching to connection 'handler_con1'.
+connection handler_con1;
+--echo # Reaping ALTER TABLE.
+--reap
+unlock tables;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+
+--echo # Clean-up.
+disconnect handler_con1;
+disconnect handler_con2;
+drop tables t1, t2;
+
+
+--echo #
+--echo # Test coverage for basic deadlock detection in metadata
+--echo # locking subsystem.
+--echo #
+--disable_warnings
+drop tables if exists t0, t1, t2, t3, t4, t5;
+--enable_warnings
+set debug_sync= 'RESET';
+
+connect(deadlock_con1,localhost,root,,);
+connect(deadlock_con2,localhost,root,,);
+connect(deadlock_con3,localhost,root,,);
+connection default;
+create table t1 (i int);
+create table t2 (j int);
+create table t3 (k int);
+create table t4 (k int);
+
+--echo #
+--echo # Test for the case in which no deadlock occurs.
+--echo #
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+begin;
+insert into t1 values (1);
+
+--echo #
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+begin;
+insert into t2 values (1);
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Send:
+--send rename table t2 to t0, t3 to t2, t0 to t3;
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Wait until the above RENAME TABLE is blocked because it has to wait
+--echo # for 'deadlock_con2' which holds shared metadata lock on 't2'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t2 to t0, t3 to t2, t0 to t3";
+--source include/wait_condition.inc
+--echo # The below statement should wait for exclusive metadata lock
+--echo # on 't2' to go away and should not produce ER_LOCK_DEADLOCK
+--echo # as no deadlock is possible in this situation.
+--echo # Send:
+--send select * from t2;
+
+--echo #
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Wait until the above SELECT * FROM t2 is starts waiting
+--echo # for an exclusive metadata lock to go away.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "select * from t2";
+--source include/wait_condition.inc
+--echo #
+--echo # Unblock RENAME TABLE by releasing shared metadata lock on t2.
+commit;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap RENAME TABLE.
+--reap
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Reap SELECT.
+--reap
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo #
+--echo # Let us check that in the process of waiting for conflicting lock
+--echo # on table 't2' to go away transaction in connection 'deadlock_con1'
+--echo # has not released metadata lock on table 't1'.
+--echo # Send:
+--send rename table t1 to t0, t3 to t1, t0 to t3;
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Wait until the above RENAME TABLE is blocked because it has to wait
+--echo # for 'deadlock_con1' which should still hold shared metadata lock on
+--echo # table 't1'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t0, t3 to t1, t0 to t3";
+--source include/wait_condition.inc
+--echo # Commit transaction to unblock RENAME TABLE.
+commit;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap RENAME TABLE.
+--reap
+
+--echo #
+--echo # Test for case when deadlock occurs and should be detected immediately.
+--echo #
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+begin;
+insert into t2 values (2);
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Send:
+--send rename table t2 to t0, t1 to t2, t0 to t1;
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Wait until the above RENAME TABLE is blocked because it has to wait
+--echo # for 'deadlock_con1' which holds shared metadata lock on 't2'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t2 to t0, t1 to t2, t0 to t1";
+--source include/wait_condition.inc
+--echo #
+--echo # The below statement should not wait as doing so will cause deadlock.
+--echo # Instead it should fail and emit ER_LOCK_DEADLOCK statement.
+--error ER_LOCK_DEADLOCK
+select * from t1;
+
+--echo #
+--echo # Let us check that failure of the above statement has not released
+--echo # metadata lock on table 't1', i.e. that RENAME TABLE is still blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t2 to t0, t1 to t2, t0 to t1";
+--source include/wait_condition.inc
+--echo # Commit transaction to unblock RENAME TABLE.
+commit;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap RENAME TABLE.
+--reap
+
+--echo #
+--echo # Test for the case in which deadlock also occurs but not immediately.
+--echo #
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+begin;
+insert into t2 values (1);
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+lock table t1 write;
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # The below SELECT statement should wait for metadata lock
+--echo # on table 't1' and should not produce ER_LOCK_DEADLOCK
+--echo # immediately as no deadlock is possible at the moment.
+--send select * from t1;
+
+--echo #
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Wait until the above SELECT * FROM t1 is starts waiting
+--echo # for an UNRW metadata lock to go away.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and info = "select * from t1";
+--source include/wait_condition.inc
+
+--echo # Send RENAME TABLE statement that will deadlock with the
+--echo # SELECT statement and thus should abort the latter.
+--send rename table t1 to t0, t2 to t1, t0 to t2;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait till above RENAME TABLE is blocked while holding
+--echo # pending X lock on t1.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t0, t2 to t1, t0 to t2";
+--source include/wait_condition.inc
+--echo # Allow the above RENAME TABLE to acquire lock on t1 and
+--echo # create pending lock on t2 thus creating deadlock.
+unlock tables;
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Since the latest RENAME TABLE entered in deadlock with SELECT
+--echo # statement the latter should be aborted and emit ER_LOCK_DEADLOCK
+--echo # error.
+--echo # Reap SELECT * FROM t1.
+--error ER_LOCK_DEADLOCK
+--reap
+
+--echo #
+--echo # Again let us check that failure of the SELECT statement has not
+--echo # released metadata lock on table 't2', i.e. that the latest RENAME
+--echo # is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "rename table t1 to t0, t2 to t1, t0 to t2";
+--source include/wait_condition.inc
+--echo # Commit transaction to unblock this RENAME TABLE.
+commit;
+
+--echo #
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Reap RENAME TABLE ... .
+--reap;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+
+drop tables t1, t2, t3, t4;
+
+--echo #
+--echo # Now, test case which shows that deadlock detection empiric
+--echo # also takes into account requests for metadata lock upgrade.
+--echo #
+create table t1 (i int);
+insert into t1 values (1);
+--echo # Avoid race which occurs when SELECT in 'deadlock_con1' connection
+--echo # accesses table before the above INSERT unlocks the table and thus
+--echo # its result becomes visible to other connections.
+select * from t1;
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+begin;
+select * from t1;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Send:
+--send alter table t1 add column j int, rename to t2;
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Wait until the above ALTER TABLE ... RENAME acquires exclusive
+--echo # metadata lock on 't2' and starts waiting for connection
+--echo # 'deadlock_con1' which holds shared lock on 't1'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column j int, rename to t2";
+--source include/wait_condition.inc
+
+--echo # The below statement should not wait as it will cause deadlock.
+--echo # An appropriate error should be reported instead.
+--error ER_LOCK_DEADLOCK
+select * from t2;
+
+--echo # Again let us check that failure of the above statement has not
+--echo # released all metadata locks in connection 'deadlock_con1' and
+--echo # so ALTER TABLE ... RENAME is still blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column j int, rename to t2";
+--source include/wait_condition.inc
+
+--echo # Commit transaction to unblock ALTER TABLE ... RENAME.
+commit;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap ALTER TABLE ... RENAME.
+--reap
+
+drop table t2;
+
+--echo #
+--echo # Test that in situation when MDL subsystem detects a deadlock
+--echo # but it turns out that it can be resolved by backing-off locks
+--echo # acquired by one of participating transactions (which is
+--echo # possible when one of transactions consists only of currently
+--echo # executed statement, e.g. in autocommit mode) no error is
+--echo # reported.
+--echo #
+create table t1 (i int);
+create table t2 (j int);
+--echo # Ensure that the below SELECT stops once it has acquired metadata
+--echo # lock on table 't2'.
+set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--echo # Sending:
+--send select * from t2, t1
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Wait till SELECT acquires MDL on 't2' and starts waiting for signal.
+set debug_sync= 'now WAIT_FOR locked';
+--echo # Sending:
+--send lock tables t1 write, t2 write
+
+--echo #
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Wait until LOCK TABLES acquires SNRW lock on 't1' and is blocked
+--echo # while trying to acquire SNRW lock on 't1'.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "lock tables t1 write, t2 write";
+--source include/wait_condition.inc
+--echo # Resume SELECT execution, this should eventually unblock LOCK TABLES.
+set debug_sync= 'now SIGNAL finish';
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Reaping LOCK TABLES.
+--reap
+unlock tables;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping SELECT. It succeed and not report ER_LOCK_DEADLOCK error.
+--reap
+
+drop tables t1, t2;
+
+--echo #
+--echo # Test coverage for situation in which a race has happened
+--echo # during deadlock detection process which led to unwarranted
+--echo # ER_LOCK_DEADLOCK error.
+--echo #
+create table t1 (i int);
+
+--echo # Ensure that ALTER waits once it has acquired SNW lock.
+set debug_sync='after_open_table_mdl_shared SIGNAL parked1 WAIT_FOR go1';
+--echo # Sending:
+--send alter table t1 add column j int
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Wait till ALTER acquires SNW lock and stops.
+set debug_sync='now WAIT_FOR parked1';
+--echo # Ensure that INSERT is paused once it detects that there is
+--echo # a conflicting metadata lock so it has to wait, but before
+--echo # deadlock detection is run.
+set debug_sync='mdl_acquire_lock_wait SIGNAL parked2 WAIT_FOR go2';
+--echo # Sending:
+--send insert into t1 values ()
+
+--echo #
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Wait till INSERT is paused.
+set debug_sync='now WAIT_FOR parked2';
+--echo # Resume ALTER execution. Eventually it will release its
+--echo # metadata lock and INSERT's request for SW lock will be
+--echo # satisified.
+set debug_sync='now SIGNAL go1';
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping ALTER TABLE.
+--reap
+--echo # Add a new request for SNW lock to waiting graph.
+--echo # Sending:
+--send alter table t1 drop column j
+
+--echo #
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Wait until ALTER is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 drop column j";
+--source include/wait_condition.inc
+--echo # Resume INSERT so it can start deadlock detection.
+--echo #
+--echo # At this point there is a discrepancy between the fact that INSERT's
+--echo # SW lock is already satisfied, but INSERT's connection is still
+--echo # marked as waiting for it. Looking for a loop in waiters graph
+--echo # without additional checks has detected a deadlock (INSERT waits
+--echo # for SW lock; which is not granted because of pending SNW lock from
+--echo # ALTER; which waits for active SW lock from INSERT). Since requests
+--echo # for SW and SNW locks have same weight ALTER was selected as a victim
+--echo # and ended with ER_LOCK_DEADLOCK error.
+set debug_sync='now SIGNAL go2';
+
+--echo #
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Reaping INSERT.
+--reap
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping ALTER. It should succeed and not produce ER_LOCK_DEADLOCK.
+--reap
+
+drop table t1;
+
+--echo #
+--echo # Now, test for a situation in which deadlock involves waiting not
+--echo # only in MDL subsystem but also for TDC. Such deadlocks should be
+--echo # successfully detected. If possible, they should be resolved without
+--echo # resorting to ER_LOCK_DEADLOCK error.
+--echo #
+create table t1(i int);
+create table t2(j int);
+
+--echo #
+--echo # First, let us check how we handle a simple scenario involving
+--echo # waits in MDL and TDC.
+--echo #
+set debug_sync= 'RESET';
+
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Start a statement, which will acquire SR metadata lock on t1, open it
+--echo # and then stop, before trying to acquire SW lock on t2 and opening it.
+set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
+--echo # Sending:
+--send select * from t1 where i in (select j from t2 for update)
+
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Wait till the above SELECT stops.
+set debug_sync='now WAIT_FOR parked';
+--echo # The below FLUSH TABLES WITH READ LOCK should acquire
+--echo # SNW locks on t1 and t2 and wait till SELECT closes t1.
+--echo # Sending:
+send flush tables t1, t2 with read lock;
+
+--echo # Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
+--echo # Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting
+--echo # for SELECT to close t1.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush" and
+ info = "flush tables t1, t2 with read lock";
+--source include/wait_condition.inc
+
+--echo # Resume SELECT, so it tries to acquire SW lock on t1 and blocks,
+--echo # creating a deadlock. This deadlock should be detected and resolved
+--echo # by backing-off SELECT. As a result FTWRL should be able to finish.
+set debug_sync='now SIGNAL go';
+
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Reap FLUSH TABLES WITH READ LOCK.
+reap;
+unlock tables;
+
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Reap SELECT.
+reap;
+
+--echo #
+--echo # The same scenario with a slightly different order of events
+--echo # which emphasizes that setting correct deadlock detector weights
+--echo # for flush waits is important.
+--echo #
+set debug_sync= 'RESET';
+
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go';
+
+--echo # The below FLUSH TABLES WITH READ LOCK should acquire
+--echo # SNW locks on t1 and t2 and wait on debug sync point.
+--echo # Sending:
+send flush tables t1, t2 with read lock;
+
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Wait till FLUSH TABLE WITH READ LOCK stops.
+set debug_sync='now WAIT_FOR parked';
+
+--echo # Start statement which will acquire SR metadata lock on t1, open
+--echo # it and then will block while trying to acquire SW lock on t2.
+--echo # Sending:
+send select * from t1 where i in (select j from t2 for update);
+
+--echo # Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
+--echo # Wait till the above SELECT blocks.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "select * from t1 where i in (select j from t2 for update)";
+--source include/wait_condition.inc
+
+--echo # Resume FLUSH TABLES, so it tries to flush t1, thus creating
+--echo # a deadlock. This deadlock should be detected and resolved by
+--echo # backing-off SELECT. As a result FTWRL should be able to finish.
+set debug_sync='now SIGNAL go';
+
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Reap FLUSH TABLES WITH READ LOCK.
+reap;
+unlock tables;
+
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Reap SELECT.
+reap;
+
+--echo #
+--echo # Now a more complex scenario involving two connections
+--echo # waiting for MDL and one for TDC.
+--echo #
+set debug_sync= 'RESET';
+
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Start a statement which will acquire SR metadata lock on t2, open it
+--echo # and then stop, before trying to acquire SR on t1 and opening it.
+set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
+--echo # Sending:
+send select * from t2, t1;
+
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Wait till the above SELECT stops.
+set debug_sync='now WAIT_FOR parked';
+--echo # The below FLUSH TABLES WITH READ LOCK should acquire
+--echo # SNW locks on t2 and wait till SELECT closes t2.
+--echo # Sending:
+send flush tables t2 with read lock;
+
+--echo # Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
+--echo # Wait until FLUSH TABLES WITH READ LOCK starts waiting
+--echo # for SELECT to close t2.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush" and
+ info = "flush tables t2 with read lock";
+--source include/wait_condition.inc
+
+--echo # The below DROP TABLES should acquire X lock on t1 and start
+--echo # waiting for X lock on t2.
+--echo # Sending:
+send drop tables t1, t2;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until DROP TABLES starts waiting for X lock on t2.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "drop tables t1, t2";
+--source include/wait_condition.inc
+
+--echo # Resume SELECT, so it tries to acquire SR lock on t1 and blocks,
+--echo # creating a deadlock. This deadlock should be detected and resolved
+--echo # by backing-off SELECT. As a result, FTWRL should be able to finish.
+set debug_sync='now SIGNAL go';
+
+--echo # Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
+--echo # Reap FLUSH TABLES WITH READ LOCK.
+reap;
+--echo # Unblock DROP TABLES.
+unlock tables;
+
+--echo # Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
+--echo # Reap DROP TABLES.
+reap;
+
+--echo # Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
+--echo # Reap SELECT. It should emit error about missing table.
+--error ER_NO_SUCH_TABLE
+reap;
+
+--echo # Switching to connection 'default'.
+connection default;
+
+set debug_sync= 'RESET';
+
+disconnect deadlock_con1;
+disconnect deadlock_con2;
+disconnect deadlock_con3;
+
+
+--echo #
+--echo # Test for a scenario in which FLUSH TABLES <list> WITH READ LOCK
+--echo # used to erroneously release metadata locks.
+--echo #
+connect(con1,localhost,root,,);
+connect(con2,localhost,root,,);
+connection default;
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+set debug_sync= 'RESET';
+create table t1(i int);
+create table t2(j int);
+
+--echo # Switching to connection 'con2'.
+connection con2;
+set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
+
+--echo # The below FLUSH TABLES <list> WITH READ LOCK should acquire
+--echo # SNW locks on t1 and t2, open table t1 and block on the debug
+--echo # sync point.
+--echo # Sending:
+send flush tables t1, t2 with read lock;
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Wait till FLUSH TABLES <list> WITH READ LOCK stops.
+set debug_sync='now WAIT_FOR parked';
+
+--echo # Start a statement which will flush all tables and thus
+--echo # invalidate table t1 open by FLUSH TABLES <list> WITH READ LOCK.
+--echo # Sending:
+send flush tables;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait till the above FLUSH TABLES blocks.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table flush" and
+ info = "flush tables";
+--source include/wait_condition.inc
+
+--echo # Resume FLUSH TABLES <list> WITH READ LOCK, so it tries to open t2
+--echo # discovers that its t1 is obsolete and tries to reopen all tables.
+--echo # Such reopen should not cause releasing of SNW metadata locks
+--echo # which would result in assertion failures.
+set debug_sync='now SIGNAL go';
+
+--echo # Switching to connection 'con2'.
+connection con2;
+--echo # Reap FLUSH TABLES <list> WITH READ LOCK.
+reap;
+unlock tables;
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Reap FLUSH TABLES.
+reap;
+
+--echo # Clean-up.
+--echo # Switching to connection 'default'.
+connection default;
+drop tables t1, t2;
+set debug_sync= 'RESET';
+disconnect con1;
+disconnect con2;
+
+
+--echo #
+--echo # Test for bug #46748 "Assertion in MDL_context::wait_for_locks()
+--echo # on INSERT + CREATE TRIGGER".
+--echo #
+--disable_warnings
+drop tables if exists t1, t2, t3, t4, t5;
+--enable_warnings
+--echo # Let us simulate scenario in which we open some tables from extended
+--echo # part of prelocking set but then encounter conflicting metadata lock,
+--echo # so have to back-off and wait for it to go away.
+connect (con1root,localhost,root,,test,,);
+connect (con2root,localhost,root,,test,,);
+connection default;
+create table t1 (i int);
+create table t2 (j int);
+create table t3 (k int);
+create table t4 (l int);
+create trigger t1_bi before insert on t1 for each row
+ insert into t2 values (new.i);
+create trigger t2_bi before insert on t2 for each row
+ insert into t3 values (new.j);
+--echo #
+--echo # Switching to connection 'con1root'.
+connection con1root;
+lock tables t4 read;
+--echo #
+--echo # Switching to connection 'con2root'.
+connection con2root;
+--echo # Send :
+--send rename table t3 to t5, t4 to t3;
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until the above RENAME TABLE adds pending requests for exclusive
+--echo # metadata lock on its tables and blocks due to 't4' being used by LOCK
+--echo # TABLES.
+let $wait_condition= select count(*)= 1 from information_schema.processlist
+ where state= 'Waiting for table metadata lock' and
+ info='rename table t3 to t5, t4 to t3';
+--source include/wait_condition.inc
+--echo # Send :
+--send insert into t1 values (1);
+--echo #
+--echo # Switching to connection 'con1root'.
+connection con1root;
+--echo # Wait until INSERT statement waits due to encountering pending
+--echo # exclusive metadata lock on 't3'.
+let $wait_condition= select count(*)= 1 from information_schema.processlist
+ where state= 'Waiting for table metadata lock' and
+ info='insert into t1 values (1)';
+--source include/wait_condition.inc
+unlock tables;
+--echo #
+--echo # Switching to connection 'con2root'.
+connection con2root;
+--echo # Reap RENAME TABLE.
+--reap
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap INSERT.
+--reap
+--echo # Clean-up.
+disconnect con1root;
+disconnect con2root;
+drop tables t1, t2, t3, t5;
+
+
+--echo #
+--echo # Bug#42546 - Backup: RESTORE fails, thinking it finds an existing table
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+set @save_log_output=@@global.log_output;
+set global log_output=file;
+
+connect(con2, localhost, root,,);
+
+--echo #
+--echo # Test 1: CREATE TABLE
+--echo #
+
+--echo # Connection 2
+connection con2;
+--echo # Start insert on the not-yet existing table
+--echo # Wait after taking the MDL lock
+SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--send INSERT INTO t1 VALUES(1,"def")
+
+--echo # Connection 1
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Now INSERT has a MDL on the non-existent table t1.
+
+--echo #
+--echo # Continue the INSERT once CREATE waits for exclusive lock
+SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL finish';
+--echo # Try to create that table.
+--send CREATE TABLE t1 (c1 INT, c2 VARCHAR(100), KEY(c1))
+
+--echo # Connection 2
+--echo # Insert fails
+connection con2;
+--error ER_NO_SUCH_TABLE
+--reap
+
+--echo # Connection 1
+connection default;
+--reap;
+SET DEBUG_SYNC= 'RESET';
+SHOW TABLES;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Test 2: CREATE TABLE LIKE
+--echo #
+
+CREATE TABLE t2 (c1 INT, c2 VARCHAR(100), KEY(c1));
+
+--echo # Connection 2
+connection con2;
+--echo # Start insert on the not-yet existing table
+--echo # Wait after taking the MDL
+SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
+--send INSERT INTO t1 VALUES(1,"def")
+
+--echo # Connection 1
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Now INSERT has a MDL on the non-existent table t1.
+
+--echo #
+--echo # Continue the INSERT once CREATE waits for exclusive lock
+SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL finish';
+--echo # Try to create that table.
+--send CREATE TABLE t1 LIKE t2
+
+--echo # Connection 2
+--echo # Insert fails
+connection con2;
+--error ER_NO_SUCH_TABLE
+--reap
+
+--echo # Connection 1
+connection default;
+--reap
+SET DEBUG_SYNC= 'RESET';
+SHOW TABLES;
+
+DROP TABLE t2;
+disconnect con2;
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+set global log_output=@save_log_output;
+
+
+--echo #
+--echo # Bug #46044 "MDL deadlock on LOCK TABLE + CREATE TABLE HIGH_PRIORITY
+--echo # FOR UPDATE"
+--echo #
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+connect (con46044, localhost, root,,);
+connect (con46044_2, localhost, root,,);
+connection default;
+create table t1 (i int);
+
+--echo # Let us check that we won't deadlock if during filling
+--echo # of I_S table we encounter conflicting metadata lock
+--echo # which owner is in its turn waiting for our connection.
+lock tables t1 read;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Sending:
+--send create table t2 select * from t1 for update;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Waiting until CREATE TABLE ... SELECT ... is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table level lock" and
+ info = "create table t2 select * from t1 for update";
+--source include/wait_condition.inc
+
+--echo # First let us check that SHOW FIELDS/DESCRIBE doesn't
+--echo # gets blocked and emits and error.
+--error ER_WARN_I_S_SKIPPED_TABLE
+show fields from t2;
+
+--echo # Now test for I_S query which reads only .FRMs.
+--echo #
+--echo # Query below should only emit a warning.
+select column_name from information_schema.columns
+ where table_schema='test' and table_name='t2';
+
+--echo # Finally, test for I_S query which does full-blown table open.
+--echo #
+--echo # Query below should not be blocked. Warning message should be
+--echo # stored in the 'table_comment' column.
+select table_name, table_type, auto_increment, table_comment
+ from information_schema.tables where table_schema='test' and table_name='t2';
+
+--echo # Switching to connection 'default'.
+connection default;
+unlock tables;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Reaping CREATE TABLE ... SELECT ... .
+--reap
+drop table t2;
+
+--echo #
+--echo # Let us also check that queries to I_S wait for conflicting metadata
+--echo # locks to go away instead of skipping table with a warning in cases
+--echo # when deadlock is not possible. This is a nice thing from compatibility
+--echo # and ease of use points of view.
+--echo #
+--echo # We check same three queries to I_S in this new situation.
+
+--echo # Switching to connection 'con46044_2'.
+connection con46044_2;
+lock tables t1 read;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Sending:
+--send create table t2 select * from t1 for update;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Waiting until CREATE TABLE ... SELECT ... is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table level lock" and
+ info = "create table t2 select * from t1 for update";
+--source include/wait_condition.inc
+
+--echo # Let us check that SHOW FIELDS/DESCRIBE gets blocked.
+--echo # Sending:
+--send show fields from t2;
+
+--echo # Switching to connection 'con46044_2'.
+connection con46044_2;
+--echo # Wait until SHOW FIELDS gets blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "show fields from t2";
+--source include/wait_condition.inc
+
+unlock tables;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Reaping CREATE TABLE ... SELECT ... .
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping SHOW FIELDS ...
+--reap
+drop table t2;
+
+--echo # Switching to connection 'con46044_2'.
+connection con46044_2;
+lock tables t1 read;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Sending:
+--send create table t2 select * from t1 for update;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Waiting until CREATE TABLE ... SELECT ... is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table level lock" and
+ info = "create table t2 select * from t1 for update";
+--source include/wait_condition.inc
+
+--echo # Check that I_S query which reads only .FRMs gets blocked.
+--echo # Sending:
+--send select column_name from information_schema.columns where table_schema='test' and table_name='t2';
+
+--echo # Switching to connection 'con46044_2'.
+connection con46044_2;
+--echo # Wait until SELECT COLUMN_NAME FROM I_S.COLUMNS gets blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info like "select column_name from information_schema.columns%";
+--source include/wait_condition.inc
+
+unlock tables;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Reaping CREATE TABLE ... SELECT ... .
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping SELECT COLUMN_NAME FROM I_S.COLUMNS
+--reap
+drop table t2;
+
+--echo # Switching to connection 'con46044_2'.
+connection con46044_2;
+lock tables t1 read;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Sending:
+--send create table t2 select * from t1 for update;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Waiting until CREATE TABLE ... SELECT ... is blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table level lock" and
+ info = "create table t2 select * from t1 for update";
+--source include/wait_condition.inc
+
+--echo # Finally, check that I_S query which does full-blown table open
+--echo # also gets blocked.
+--echo # Sending:
+--send select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t2';
+
+--echo # Switching to connection 'con46044_2'.
+connection con46044_2;
+--echo # Wait until SELECT ... FROM I_S.TABLES gets blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info like "select table_name, table_type, auto_increment, table_comment from information_schema.tables%";
+--source include/wait_condition.inc
+
+unlock tables;
+
+--echo # Switching to connection 'con46044'.
+connection con46044;
+--echo # Reaping CREATE TABLE ... SELECT ... .
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping SELECT ... FROM I_S.TABLES
+--reap
+drop table t2;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Clean-up.
+disconnect con46044;
+disconnect con46044_2;
+drop table t1;
+
+
+--echo #
+--echo # Test for bug #46273 "MySQL 5.4.4 new MDL: Bug#989 is not fully fixed
+--echo # in case of ALTER".
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+set debug_sync= 'RESET';
+connect (con46273,localhost,root,,test,,);
+connection default;
+create table t1 (c1 int primary key, c2 int, c3 int);
+insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
+
+begin;
+select * from t1 where c2 = 3;
+
+--echo #
+--echo # Switching to connection 'con46273'.
+connection con46273;
+set debug_sync='after_lock_tables_takes_lock SIGNAL alter_table_locked WAIT_FOR alter_go';
+--send alter table t1 add column e int, rename to t2;
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+set debug_sync='now WAIT_FOR alter_table_locked';
+set debug_sync='mdl_acquire_lock_wait SIGNAL alter_go';
+--echo # The below statement should get ER_LOCK_DEADLOCK error
+--echo # (i.e. it should not allow ALTER to proceed, and then
+--echo # fail due to 't1' changing its name to 't2').
+--error ER_LOCK_DEADLOCK
+update t1 set c3=c3+1 where c2 = 3;
+
+--echo #
+--echo # Let us check that failure of the above statement has not released
+--echo # metadata lock on table 't1', i.e. that ALTER TABLE is still blocked.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "alter table t1 add column e int, rename to t2";
+--source include/wait_condition.inc
+
+--echo # Unblock ALTER TABLE by commiting transaction and thus releasing
+--echo # metadata lock on 't1'.
+commit;
+
+--echo #
+--echo # Switching to connection 'con46273'.
+connection con46273;
+--echo # Reap ALTER TABLE.
+--reap
+
+--echo #
+--echo # Switching to connection 'default'.
+connection default;
+disconnect con46273;
+--echo # Clean-up.
+set debug_sync= 'RESET';
+drop table t2;
+
+
+--echo #
+--echo # Test for bug #46673 "Deadlock between FLUSH TABLES WITH READ LOCK
+--echo # and DML".
+--echo #
+--disable_warnings
+drop tables if exists t1;
+--enable_warnings
+connect (con46673, localhost, root,,);
+connection default;
+create table t1 (i int);
+
+--echo # Switching to connection 'con46673'.
+connection con46673;
+begin;
+insert into t1 values (1);
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Statement below should not get blocked. And if after some
+--echo # changes to code it is there should not be a deadlock between
+--echo # it and transaction from connection 'con46673'.
+flush tables with read lock;
+unlock tables;
+
+--echo # Switching to connection 'con46673'.
+connection con46673;
+delete from t1 where i = 1;
+commit;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Clean-up
+disconnect con46673;
+drop table t1;
+
+
+--echo #
+--echo # Bug#48210 FLUSH TABLES WITH READ LOCK deadlocks
+--echo # against concurrent CREATE PROCEDURE
+--echo #
+
+connect (con2, localhost, root);
+
+--echo # Test 1: CREATE PROCEDURE
+
+--echo # Connection 1
+connection default;
+--echo # Start CREATE PROCEDURE and open mysql.proc
+SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait';
+--send CREATE PROCEDURE p1() SELECT 1
+
+--echo # Connection 2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR table_opened';
+--echo # Check that FLUSH must wait to get the GRL
+--echo # and let CREATE PROCEDURE continue
+SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait';
+--send FLUSH TABLES WITH READ LOCK
+
+--echo # Connection 1
+connection default;
+--reap
+
+--echo # Connection 2
+connection con2;
+--reap
+UNLOCK TABLES;
+
+--echo # Connection 1
+connection default;
+SET DEBUG_SYNC= 'RESET';
+
+--echo # Test 2: DROP PROCEDURE
+
+connection default;
+--echo # Start DROP PROCEDURE and open tables
+SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait';
+--send DROP PROCEDURE p1
+
+--echo # Connection 2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR table_opened';
+--echo # Check that FLUSH must wait to get the GRL
+--echo # and let DROP PROCEDURE continue
+SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait';
+--send FLUSH TABLES WITH READ LOCK
+
+--echo # Connection 1
+connection default;
+--echo # Once FLUSH TABLES WITH READ LOCK starts waiting
+--echo # DROP PROCEDURE will be waked up and will drop
+--echo # procedure. Global read lock will be granted after
+--echo # this statement ends.
+--echo #
+--echo # Reaping DROP PROCEDURE.
+--reap
+
+--echo # Connection 2
+connection con2;
+--echo # Reaping FTWRL.
+--reap
+UNLOCK TABLES;
+
+--echo # Connection 1
+connection default;
+SET DEBUG_SYNC= 'RESET';
+
+disconnect con2;
+
+
+--echo #
+--echo # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null'
+--echo # failed in open_ltable()
+--echo #
+
+--echo # Supress warnings written to the log file
+call mtr.add_suppression("Wait on a lock was aborted due to a pending exclusive lock");
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+connect (con1,localhost,root);
+connect (con2,localhost,root);
+connect (con3,localhost,root);
+connection default;
+
+CREATE TABLE t1 (i INT);
+CREATE TABLE t2 (i INT);
+
+SET @old_general_log= @@global.general_log;
+SET @@global.general_log= 1;
+
+SET @old_log_output= @@global.log_output;
+SET @@global.log_output= 'TABLE';
+
+SET @old_sql_log_off= @@session.sql_log_off;
+SET @@session.sql_log_off= 1;
+
+--echo # connection: con1
+connection con1;
+HANDLER t1 OPEN;
+
+--echo # connection: con3
+connection con3;
+SET @@session.sql_log_off= 1;
+
+--echo # connection: con2
+connection con2;
+SET DEBUG_SYNC= 'thr_multi_lock_after_thr_lock SIGNAL parked WAIT_FOR go';
+
+# The below statement will block on the debug sync point
+# after it gets write lock on mysql.general_log table.
+--echo # Sending:
+--send SELECT 1
+
+--echo # connection: con3
+connection con3;
+SET DEBUG_SYNC= 'now WAIT_FOR parked';
+
+--echo # connection: con1
+connection con1;
+# This statement will block in open_ltable() when
+# trying to write into mysql.general_log.
+--echo # Sending:
+--send SELECT 1
+
+--echo # connection: con3
+connection con3;
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table level lock" and info = "SELECT 1";
+--source include/wait_condition.inc
+# The ALTER below will try to abort the statement in connection con1,
+# since the latter waits on a table-level lock while having a HANDLER
+# open. This will cause mysql_lock_tables() in con1 fail which before
+# triggered the assert.
+ALTER TABLE t1 ADD COLUMN j INT;
+
+--echo # connection: default
+connection default;
+SET DEBUG_SYNC= 'now SIGNAL go';
+
+--echo # connection: con1
+connection con1;
+--echo # Reaping SELECT 1
+--reap
+HANDLER t1 CLOSE;
+
+--echo # connection: con2
+connection con2;
+--echo # Reaping SELECT 1
+--reap
+
+--echo # connection: default
+connection default;
+DROP TABLE t1, t2;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+disconnect con2;
+disconnect con3;
+SET @@global.general_log= @old_general_log;
+SET @@global.log_output= @old_log_output;
+SET @@session.sql_log_off= @old_sql_log_off;
+
+
+--echo #
+--echo # Additional coverage for bug #50913 "Deadlock between
+--echo # open_and_lock_tables_derived and MDL". The main test
+--echo # case is in lock_multi.test
+--echo #
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+set debug_sync= 'RESET';
+connect (con50913_1,localhost,root);
+connect (con50913_2,localhost,root);
+connection default;
+create table t1 (i int) engine=InnoDB;
+
+--echo # Switching to connection 'con50913_1'.
+connection con50913_1;
+set debug_sync= 'thr_multi_lock_after_thr_lock SIGNAL parked WAIT_FOR go';
+--echo # Sending:
+--send alter table t1 add column j int
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Wait until ALTER TABLE gets blocked on a sync point after
+--echo # acquiring thr_lock.c lock.
+set debug_sync= 'now WAIT_FOR parked';
+--echo # The below statement should wait on MDL lock and not deadlock on
+--echo # thr_lock.c lock.
+--echo # Sending:
+--send truncate table t1
+
+--echo # Switching to connection 'con50913_2'.
+connection con50913_2;
+--echo # Wait until TRUNCATE TABLE is blocked on MDL lock.
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "truncate table t1";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE.
+set debug_sync= 'now SIGNAL go';
+
+--echo # Switching to connection 'con50913_1'.
+connection con50913_1;
+--echo # Reaping ALTER TABLE.
+--reap
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reaping TRUNCATE TABLE.
+--reap
+disconnect con50913_1;
+disconnect con50913_2;
+set debug_sync= 'RESET';
+drop table t1;
+
+
+--echo #
+--echo # Test for bug #50998 "Deadlock in MDL code during test
+--echo # rqg_mdl_stability".
+--echo # Also provides coverage for the case when addition of
+--echo # waiting statement adds several loops in the waiters
+--echo # graph and therefore several searches for deadlock
+--echo # should be performed.
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+set debug_sync= 'RESET';
+connect (con1,localhost,root);
+connect (con2,localhost,root);
+connect (con3,localhost,root);
+connection default;
+create table t1 (i int);
+
+--echo # Switching to connection 'con1'.
+connection con1;
+begin;
+select * from t1;
+
+--echo # Switching to connection 'con2'.
+connection con2;
+begin;
+select * from t1;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Start ALTER TABLE which will acquire SNW lock and
+--echo # table lock and get blocked on sync point.
+set debug_sync= 'thr_multi_lock_after_thr_lock SIGNAL parked WAIT_FOR go';
+--echo # Sending:
+--send alter table t1 add column j int
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Wait until ALTER TABLE gets blocked on a sync point.
+set debug_sync= 'now WAIT_FOR parked';
+--echo # Sending:
+--send insert into t1 values (1)
+
+--echo # Switching to connection 'con2'.
+connection con2;
+--echo # Sending:
+--send insert into t1 values (1)
+
+--echo # Switching to connection 'con3'.
+connection con3;
+--echo # Wait until both 'con1' and 'con2' are blocked trying to acquire
+--echo # SW lock on the table.
+let $wait_condition=
+ select count(*) = 2 from information_schema.processlist
+ where state = "Waiting for table metadata lock" and
+ info = "insert into t1 values (1)";
+--source include/wait_condition.inc
+--echo # Unblock ALTER TABLE. Since it will try to upgrade SNW to X lock
+--echo # deadlock with two loops in waiting graph will occur. Both loops
+--echo # should be found and DML statements in both 'con1' and 'con2'
+--echo # should be aborted with ER_LOCK_DEADLOCK errors.
+set debug_sync= 'now SIGNAL go';
+
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # Reaping INSERT. It should end with ER_LOCK_DEADLOCK error and
+--echo # not wait indefinitely (as it happened before the bugfix).
+--error ER_LOCK_DEADLOCK
+--reap
+commit;
+
+--echo # Switching to connection 'con2'.
+connection con2;
+--echo # Reaping INSERT.
+--error ER_LOCK_DEADLOCK
+--reap
+commit;
+
+--echo # Switching to connection 'default'.
+connection default;
+--echo # Reap ALTER TABLE.
+--reap
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
+connection default;
+set debug_sync= 'RESET';
+drop table t1;
+
+--echo #
+--echo # Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
+--echo #
+--echo # Ensure that a acquired lock is not given up due to a conflict.
+--echo #
+
+connect (con1,localhost,root,,test,,);
+connect (con2,localhost,root,,test,,);
+connect (con3,localhost,root,,test,,);
+
+connection default;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3);
+
+--echo # Connection: con1
+connection con1;
+LOCK TABLES t1 WRITE;
+SET debug_sync='upgrade_lock_for_truncate SIGNAL parked_truncate WAIT_FOR go_truncate';
+send TRUNCATE TABLE t1;
+
+connection default;
+--echo # Connection: default
+SET debug_sync='now WAIT_FOR parked_truncate';
+
+connection con2;
+--echo # Connection: con2
+SET debug_sync='after_open_table_ignore_flush SIGNAL parked_show WAIT_FOR go_show';
+send SHOW FIELDS FROM t1;
+
+connection default;
+--echo # Connection: default
+SET debug_sync='now WAIT_FOR parked_show';
+
+connection con3;
+--echo # Connection: con3
+SET debug_sync='after_flush_unlock SIGNAL parked_flush WAIT_FOR go_flush';
+send FLUSH TABLES t1;
+
+connection default;
+--echo # Connection: default
+SET debug_sync='now WAIT_FOR parked_flush';
+SET debug_sync='now SIGNAL go_truncate';
+--echo # Ensure that truncate waits for a exclusive lock
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table metadata lock' AND info='TRUNCATE TABLE t1';
+--source include/wait_condition.inc
+SET debug_sync= 'now SIGNAL go_show';
+
+connection con1;
+--echo # Connection: con1 (TRUNCATE)
+--echo # Reaping...
+reap;
+UNLOCK TABLES;
+
+connection con2;
+--echo # Connection: con2 (SHOW FIELDS FROM t1)
+--echo # Reaping...
+reap;
+
+connection default;
+--echo # Connection: default
+SET debug_sync= 'now SIGNAL go_flush';
+
+connection con3;
+--echo # Connection: con3 (FLUSH TABLES t1)
+--echo # Reaping...
+reap;
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+connection default;
+--echo # Connection: default
+SET debug_sync= 'RESET';
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#52856 concurrent show columns or show full columns causes a crash!!!
+--echo #
+CREATE TABLE t1(a CHAR(255));
+
+connect(con1, localhost, root);
+SET DEBUG_SYNC= "get_schema_column SIGNAL waiting WAIT_FOR completed";
+--send SHOW FULL COLUMNS FROM t1
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR waiting";
+--replace_column 8 #
+SHOW FULL COLUMNS FROM t1;
+SET DEBUG_SYNC= "now SIGNAL completed";
+--replace_column 8 #
+connection con1;
+--reap
+connection default;
+DROP TABLE t1;
+disconnect con1;
+
+
+--echo #
+--echo # Tests for schema-scope locks
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+--enable_warnings
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Test 1:
+--echo # CREATE DATABASE blocks database DDL on the same database, but
+--echo # not database DDL on different databases. Tests X vs X lock.
+--echo #
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send CREATE DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send CREATE DATABASE db1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' AND info='CREATE DATABASE db1';
+--source include/wait_condition.inc
+# This should not block.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: CREATE DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: CREATE DATABASE db1
+--error ER_DB_CREATE_EXISTS
+--reap
+
+--echo # Test 2:
+--echo # ALTER DATABASE blocks database DDL on the same database, but
+--echo # not database DDL on different databases. Tests X vs X lock.
+--echo #
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock'
+ AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8';
+--source include/wait_condition.inc
+# This should not block.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should also block.
+--send DROP DATABASE db1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DROP DATABASE db1
+--reap
+# Recreate the database
+CREATE DATABASE db1;
+
+--echo # Test 3:
+--echo # Two ALTER..UPGRADE of the same database are mutually exclusive, but
+--echo # two ALTER..UPGRADE of different databases are not. Tests X vs X lock.
+--echo #
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+# Manually make a 5.0 database from the template
+--mkdir $MYSQLD_DATADIR/a-b-c
+--copy_file $MYSQLD_DATADIR/db1/db.opt $MYSQLD_DATADIR/a-b-c/db.opt
+--mkdir $MYSQLD_DATADIR/a-b-c-d
+--copy_file $MYSQLD_DATADIR/db1/db.opt $MYSQLD_DATADIR/a-b-c-d/db.opt
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock'
+ AND info='ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME';
+--source include/wait_condition.inc
+# This should not block.
+ALTER DATABASE `#mysql50#a-b-c-d` UPGRADE DATA DIRECTORY NAME;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
+--error ER_BAD_DB_ERROR
+--reap
+DROP DATABASE `a-b-c`;
+DROP DATABASE `a-b-c-d`;
+
+--echo # Test 4:
+--echo # DROP DATABASE blocks database DDL on the same database, but
+--echo # not database DDL on different databases. Tests X vs X lock.
+--echo #
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send DROP DATABASE db1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+# This should not block.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DROP DATABASE db1
+--error ER_DB_DROP_EXISTS
+--reap
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should also block.
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock'
+ AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+# Error 1 is from ALTER DATABASE when the database does not exist.
+# Listing the error twice to prevent result diffences based on filename.
+--error 1,1
+--reap
+
+
+--echo # Test 5:
+--echo # Locked database name prevents CREATE of tables in that database.
+--echo # Tests X vs IX lock.
+--echo #
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send CREATE TABLE db1.t1 (a INT)
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' AND
+ info='CREATE TABLE db1.t1 (a INT)';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: CREATE TABLE db1.t1 (a INT)
+--error ER_BAD_DB_ERROR
+--reap
+
+--echo # Test 6:
+--echo # Locked database name prevents RENAME of tables to/from that database.
+--echo # Tests X vs IX lock.
+--echo #
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send RENAME TABLE db1.t1 TO test.t1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' AND
+ info='RENAME TABLE db1.t1 TO test.t1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: RENAME TABLE db1.t1 TO test.t1
+--error ER_FILE_NOT_FOUND, ER_FILE_NOT_FOUND
+--reap
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE test.t2 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send RENAME TABLE test.t2 TO db1.t2
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' AND
+ info='RENAME TABLE test.t2 TO db1.t2';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: RENAME TABLE test.t2 TO db1.t2
+# Error 7 is from RENAME TABLE where the target database does not exist.
+# Listing the error twice to prevent result diffences based on filename.
+--error 7, 7
+--reap
+DROP TABLE test.t2;
+
+
+--echo # Test 7:
+--echo # Locked database name prevents DROP of tables in that database.
+--echo # Tests X vs IX lock.
+--echo #
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--echo # Sending:
+# This should block.
+--send DROP TABLE db1.t1
+
+--echo # Connection con3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' AND info='DROP TABLE db1.t1';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL blocked';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DROP TABLE db1.t1
+--error ER_BAD_TABLE_ERROR
+--reap
+
+--echo # Connection default
+connection default;
+disconnect con2;
+disconnect con3;
+SET DEBUG_SYNC= 'RESET';
+
+--echo #
+--echo # End of tests for schema-scope locks
+--echo #
+
+--echo #
+--echo # Tests of granted global S lock (FLUSH TABLE WITH READ LOCK)
+--echo #
+
+CREATE DATABASE db1;
+CREATE TABLE db1.t1(a INT);
+connect(con2, localhost, root);
+connect(con3, localhost, root);
+
+--echo # Connection default
+connection default;
+FLUSH TABLE WITH READ LOCK;
+
+--echo # Connection con2
+connection con2;
+# IX global lock should block
+--send CREATE TABLE db1.t2(a INT)
+
+--echo # Connection default
+connection default;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for global read lock'
+ AND info='CREATE TABLE db1.t2(a INT)';
+--source include/wait_condition.inc
+UNLOCK TABLES;
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping CREATE TABLE db1.t2(a INT)
+--reap
+
+--echo # Connection default
+connection default;
+FLUSH TABLE WITH READ LOCK;
+
+--echo # Connection con2
+connection con2;
+# X global lock should block
+--send ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+
+--echo # Connection default
+connection default;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for global read lock'
+ AND info='ALTER DATABASE db1 DEFAULT CHARACTER SET utf8';
+--source include/wait_condition.inc
+UNLOCK TABLES;
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
+--reap
+
+--echo # Connection default
+connection default;
+FLUSH TABLE WITH READ LOCK;
+
+--echo # Connection con2
+connection con2;
+# S global lock should not block
+FLUSH TABLE WITH READ LOCK;
+UNLOCK TABLES;
+
+--echo # Connection default
+connection default;
+UNLOCK TABLES;
+DROP DATABASE db1;
+disconnect con2;
+disconnect con3;
+
+
+--echo #
+--echo # Bug#56292 Deadlock with ALTER TABLE and MERGE tables
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, m1;
+--enable_warnings
+
+CREATE TABLE t1(a INT) engine=MyISAM;
+CREATE TABLE t2(a INT) engine=MyISAM;
+CREATE TABLE m1(a INT) engine=MERGE UNION=(t1, t2);
+
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (3), (4);
+
+connect(con1, localhost, root);
+connect(con2, localhost, root);
+
+--echo # Connection con1
+connection con1;
+SET DEBUG_SYNC= 'mdl_upgrade_shared_lock_to_exclusive SIGNAL upgrade WAIT_FOR continue';
+--echo # Sending:
+--send ALTER TABLE m1 engine=MERGE UNION=(t2, t1)
+
+--echo # Connection con2
+connection con2;
+--echo # Waiting for ALTER TABLE to try lock upgrade
+SET DEBUG_SYNC= 'now WAIT_FOR upgrade';
+--echo # Sending:
+--send DELETE FROM t2 WHERE a = 3
+
+--echo # Connection default
+connection default;
+--echo # Check that DELETE is waiting on a metadata lock and not a table lock.
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for table metadata lock" AND
+ info = "DELETE FROM t2 WHERE a = 3";
+--source include/wait_condition.inc
+--echo # Now that DELETE blocks on a metadata lock, we should be able to do
+--echo # SELECT * FROM m1 here. SELECT used to be blocked by a DELETE table
+--echo # lock request.
+SELECT * FROM m1;
+--echo # Resuming ALTER TABLE
+SET DEBUG_SYNC= 'now SIGNAL continue';
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: ALTER TABLE m1 engine=MERGE UNION=(t2, t1)
+--reap
+--echo # Connection con2
+connection con2;
+--echo # Reaping: DELETE FROM t2 WHERE a = 3
+--reap
+--echo # Connection default
+connection default;
+DROP TABLE m1, t1, t2;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+disconnect con2;
+
+
+# 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
diff --git a/mysql-test/t/merge-big.test b/mysql-test/t/merge-big.test
index b687973c9d1..10d36bfe2a4 100644
--- a/mysql-test/t/merge-big.test
+++ b/mysql-test/t/merge-big.test
@@ -51,7 +51,7 @@ connection default;
#--sleep 8
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
- WHERE ID = $con1_id AND STATE = 'Locked';
+ WHERE ID = $con1_id AND STATE = 'Waiting for table metadata lock';
--source include/wait_condition.inc
#SELECT NOW();
--echo # Kick INSERT out of thr_multi_lock().
@@ -61,7 +61,7 @@ FLUSH TABLES;
#--sleep 8
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
- WHERE ID = $con1_id AND STATE = 'Waiting for table';
+ WHERE ID = $con1_id AND STATE = 'Waiting for table metadata lock';
--source include/wait_condition.inc
#SELECT NOW();
--echo # Unlock and close table and wait for con1 to close too.
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index f290803bbd2..07839257a15 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -2,6 +2,15 @@
# Test of MERGE TABLES
#
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+# MERGE tables require MyISAM tables
+let $default=`select @@global.storage_engine`;
+set global storage_engine=myisam;
+set session storage_engine=myisam;
+
+# Clean up resources used in this test case.
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
drop database if exists mysqltest;
@@ -126,7 +135,6 @@ drop table t3,t2,t1;
# Test table without unions
#
create table t1 (a int not null, key(a)) engine=merge;
---error 1030
select * from t1;
drop table t1;
@@ -218,20 +226,19 @@ drop table t3,t1,t2;
#
# temporary merge tables
#
-create table t1 (a int not null);
-create table t2 (a int not null);
-insert into t1 values (1);
-insert into t2 values (2);
-create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
---error ER_WRONG_MRG_TABLE
-select * from t3;
-create temporary table t4 (a int not null);
-create temporary table t5 (a int not null);
-insert into t4 values (1);
-insert into t5 values (2);
-create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5);
-select * from t6;
-drop table t6, t3, t1, t2, t4, t5;
+CREATE TABLE t1 (c1 INT NOT NULL);
+CREATE TABLE t2 (c1 INT NOT NULL);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2);
+CREATE TEMPORARY TABLE t3 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t1,t2);
+SELECT * FROM t3;
+CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL);
+CREATE TEMPORARY TABLE t5 (c1 INT NOT NULL);
+INSERT INTO t4 VALUES (4);
+INSERT INTO t5 VALUES (5);
+CREATE TEMPORARY TABLE t6 (c1 INT NOT NULL) ENGINE=MRG_MYISAM UNION=(t4,t5);
+SELECT * FROM t6;
+DROP TABLE t6, t3, t1, t2, t4, t5;
#
# Bug#19627 - temporary merge table locking
# MERGE table and its children must match in temporary type.
@@ -255,7 +262,6 @@ create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
select * from t3;
drop table t3;
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
---error ER_WRONG_MRG_TABLE
select * from t3;
drop table t3, t2, t1;
--echo # CREATE...SELECT is not implemented for MERGE tables.
@@ -458,7 +464,7 @@ CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM t2;
DROP TABLE t1, t2;
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3);
---error 1168
+--error ER_WRONG_MRG_TABLE
SELECT * FROM t2;
DROP TABLE t2;
@@ -550,15 +556,15 @@ drop table t1;
# CREATE TABLE fails
#
CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2);
---error 1168
+--error ER_WRONG_MRG_TABLE
SELECT * FROM tm1;
CHECK TABLE tm1;
CREATE TABLE t1(a INT);
---error 1168
+--error ER_WRONG_MRG_TABLE
SELECT * FROM tm1;
CHECK TABLE tm1;
CREATE TABLE t2(a BLOB);
---error 1168
+--error ER_WRONG_MRG_TABLE
SELECT * FROM tm1;
CHECK TABLE tm1;
ALTER TABLE t2 MODIFY a INT;
@@ -576,7 +582,7 @@ DROP TABLE tm1, t1, t2;
#
CREATE TABLE t1(c1 INT);
CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST;
---error ER_UPDATE_TABLE_USED
+# After WL#5370, it just generates a warning that the table already exists
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
DROP TABLE t1, t2;
@@ -616,6 +622,14 @@ SHOW CREATE TABLE m1;
DROP TABLE t1, m1;
#
+# BUG#35274 - merge table doesn't need any base tables, gives error 124 when
+# key accessed
+#
+CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge;
+SELECT MAX(a) FROM t1;
+DROP TABLE t1;
+
+#
# BUG#32047 - 'Spurious' errors while opening MERGE tables
#
CREATE TABLE t1(a INT);
@@ -677,12 +691,16 @@ SELECT * FROM t3;
--echo # Truncate MERGE table under locked tables.
LOCK TABLE t1 WRITE, t2 WRITE, t3 WRITE;
INSERT INTO t1 VALUES (1);
---error ER_LOCK_OR_ACTIVE_TRANSACTION
TRUNCATE TABLE t3;
SELECT * FROM t3;
+UNLOCK TABLES;
+SELECT * FROM t1;
+SELECT * FROM t2;
--echo #
--echo # Truncate child table under locked tables.
---error ER_LOCK_OR_ACTIVE_TRANSACTION
+LOCK TABLE t1 WRITE, t2 WRITE, t3 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2);
TRUNCATE TABLE t1;
SELECT * FROM t3;
UNLOCK TABLES;
@@ -708,14 +726,18 @@ SELECT * FROM t3;
INSERT INTO t1 VALUES (1);
CREATE TABLE t4 (c1 INT, INDEX(c1));
LOCK TABLE t4 WRITE;
---error ER_LOCK_OR_ACTIVE_TRANSACTION
TRUNCATE TABLE t3;
SELECT * FROM t3;
+SELECT * FROM t1;
+SELECT * FROM t2;
--echo #
--echo # Truncate temporary child table under locked tables.
---error ER_LOCK_OR_ACTIVE_TRANSACTION
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2);
TRUNCATE TABLE t1;
SELECT * FROM t3;
+SELECT * FROM t1;
+SELECT * FROM t2;
UNLOCK TABLES;
DROP TABLE t1, t2, t3, t4;
@@ -848,7 +870,8 @@ SHOW CREATE TABLE t3;
DROP TABLE t1, t2;
#
--echo #
---echo # CREATE ... LIKE
+--echo # Bug#37371 "CREATE TABLE LIKE merge loses UNION parameter"
+--echo # Demonstrate that this is no longer the case.
--echo #
--echo # 1. Create like.
CREATE TABLE t1 (c1 INT);
@@ -860,20 +883,24 @@ INSERT INTO t2 VALUES (2);
INSERT INTO t3 VALUES (3);
CREATE TABLE t4 LIKE t3;
SHOW CREATE TABLE t4;
---error ER_OPEN_AS_READONLY
INSERT INTO t4 VALUES (4);
DROP TABLE t4;
--echo #
--echo # 1. Create like with locked tables.
LOCK TABLES t3 WRITE, t2 WRITE, t1 WRITE;
+--error ER_TABLE_NOT_LOCKED
CREATE TABLE t4 LIKE t3;
--error ER_TABLE_NOT_LOCKED
SHOW CREATE TABLE t4;
--error ER_TABLE_NOT_LOCKED
INSERT INTO t4 VALUES (4);
-UNLOCK TABLES;
+--echo # Temporary tables can be created in spite of LOCK TABLES.
+--echo # If the temporary MERGE table uses the locked children only,
+--echo # it can even be used.
+CREATE TEMPORARY TABLE t4 LIKE t3;
SHOW CREATE TABLE t4;
---error ER_OPEN_AS_READONLY
+INSERT INTO t4 VALUES (4);
+UNLOCK TABLES;
INSERT INTO t4 VALUES (4);
DROP TABLE t4;
#
@@ -893,7 +920,7 @@ DROP TABLE t4;
--echo # 2. Normal rename.
SELECT * FROM t3 ORDER BY c1;
RENAME TABLE t2 TO t5;
---error 1168
+--error ER_WRONG_MRG_TABLE
SELECT * FROM t3 ORDER BY c1;
RENAME TABLE t5 TO t2;
SELECT * FROM t3 ORDER BY c1;
@@ -911,7 +938,7 @@ UNLOCK TABLES;
--echo #
--echo # 4. Alter table rename.
ALTER TABLE t2 RENAME TO t5;
---error 1168
+--error ER_WRONG_MRG_TABLE
SELECT * FROM t3 ORDER BY c1;
ALTER TABLE t5 RENAME TO t2;
SELECT * FROM t3 ORDER BY c1;
@@ -971,9 +998,9 @@ CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1)
LOCK TABLES t1 WRITE, t2 WRITE;
INSERT INTO t1 VALUES (1);
DROP TABLE t1;
---error 1168
+--error ER_TABLE_NOT_LOCKED
SELECT * FROM t2;
---error ER_NO_SUCH_TABLE
+--error ER_TABLE_NOT_LOCKED
SELECT * FROM t1;
UNLOCK TABLES;
DROP TABLE t2;
@@ -1150,6 +1177,7 @@ SELECT @a;
SELECT * FROM t4 ORDER BY c1;
DELETE FROM t4 WHERE c1 = 33;
DROP TRIGGER t3_ai;
+UNLOCK TABLES;
--echo #
--echo # Trigger with table use on child
DELETE FROM t4 WHERE c1 = 4;
@@ -1253,11 +1281,12 @@ DROP TABLE t1, t2, t3;
#
# Bug#25038 - Waiting TRUNCATE
+# Truncate failed with error message when table was in use by MERGE.
#
# Show that truncate of child table after use of parent table works.
-CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
-CREATE TABLE t2 (c1 INT) ENGINE= MyISAM;
-CREATE TABLE t3 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1, t2);
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE t3 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
SELECT * FROM t3;
@@ -1784,3 +1813,999 @@ REPAIR TABLE m1;
DROP TABLE m1, t1;
--echo End of 5.1 tests
+
+--echo #
+--echo # An additional test case for Bug#27430 Crash in subquery code
+--echo # when in PS and table DDL changed after PREPARE
+--echo #
+--echo # Test merge table with too many merge children.
+--echo #
+--disable_warnings
+drop table if exists t_parent;
+--enable_warnings
+set @save_table_definition_cache=@@global.table_definition_cache;
+--echo #
+--echo # Set @@global.table_definition_cache to minimum
+--echo #
+set @@global.table_definition_cache=400;
+set @a=null;
+let $1 = 400;
+--echo #
+--echo # Create 400 merge children
+--echo #
+--disable_query_log
+while ($1)
+{
+--disable_warnings
+ eval drop table if exists t$1;
+--enable_warnings
+ eval create table t$1 (a int) engine=myisam;
+ eval set @a=ifnull(concat(@a, ", ", "t$1"), "t$1");
+ dec $1;
+}
+--enable_query_log
+set @a=concat("create table t_parent (a int) union(", @a,
+ ") insert_method=first engine=mrg_myisam");
+prepare stmt from @a;
+execute stmt;
+prepare stmt from "select * from t_parent";
+--error ER_NEED_REPREPARE
+execute stmt;
+--error ER_NEED_REPREPARE
+execute stmt;
+--error ER_NEED_REPREPARE
+execute stmt;
+deallocate prepare stmt;
+--echo #
+--echo # Create merge parent
+--echo #
+
+--echo #
+--echo # Cleanup
+--echo #
+let $1 = 400;
+--disable_query_log
+while ($1)
+{
+ eval drop table t$1;
+ dec $1;
+}
+--enable_query_log
+drop table t_parent;
+set @@global.table_definition_cache=@save_table_definition_cache;
+
+#
+# WL#4144 - Lock MERGE engine children
+#
+# Test DATA/INDEX DIRECTORY
+#
+--disable_warnings
+DROP DATABASE IF EXISTS mysql_test1;
+--enable_warnings
+CREATE DATABASE mysql_test1;
+--disable_query_log
+# data/index directory don't work in HAVE_purify builds. Disable
+# build-dependent warnings.
+--disable_warnings
+--echo CREATE TABLE t1 ... DATA DIRECTORY=... INDEX DIRECTORY=...
+eval CREATE TABLE t1 (c1 INT)
+ DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
+ INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
+--echo CREATE TABLE mysql_test1.t2 ... DATA DIRECTORY=... INDEX DIRECTORY=...
+eval CREATE TABLE mysql_test1.t2 (c1 INT)
+ DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
+ INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
+--enable_query_log
+--enable_warnings
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,mysql_test1.t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO mysql_test1.t2 VALUES (2);
+SELECT * FROM m1;
+#--copy_file $MYSQLTEST_DATADIR/test/m1.MRG /tmp/mysql-test-m1.MRG
+DROP TABLE t1, mysql_test1.t2, m1;
+DROP DATABASE mysql_test1;
+#
+# Review detected Crash #1. Detaching main tables while in sub statement.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+INSERT INTO t1 (c1) VALUES (1);
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) INSERT_METHOD=FIRST;
+CREATE TABLE t3 (c1 INT);
+INSERT INTO t3 (c1) VALUES (1);
+CREATE FUNCTION f1() RETURNS INT RETURN (SELECT MAX(c1) FROM t3);
+CREATE VIEW v1 AS SELECT foo.c1 c1, f1() c2, bar.c1 c3, f1() c4
+ FROM tm1 foo, tm1 bar, t3;
+SELECT * FROM v1;
+DROP FUNCTION f1;
+DROP VIEW v1;
+DROP TABLE tm1, t1, t2, t3;
+#
+# Review detected Crash #2. Trying to attach temporary table twice.
+#
+CREATE TEMPORARY TABLE t1 (c1 INT);
+CREATE TEMPORARY TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2)
+ INSERT_METHOD=FIRST;
+CREATE FUNCTION f1() RETURNS INT RETURN (SELECT MAX(c1) FROM tm1);
+INSERT INTO tm1 (c1) VALUES (1);
+SELECT f1() FROM (SELECT 1) AS c1;
+DROP FUNCTION f1;
+DROP TABLE tm1, t1, t2;
+#
+# Review suggested test. DDL in a stored function.
+#
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ CREATE TEMPORARY TABLE t1 (c1 INT);
+ CREATE TEMPORARY TABLE t2 (c1 INT);
+ CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2);
+ INSERT INTO t1 (c1) VALUES (1);
+ RETURN (SELECT MAX(c1) FROM tm1);
+END|
+DELIMITER ;|
+SELECT f1() FROM (SELECT 1 UNION SELECT 1) c1;
+DROP FUNCTION f1;
+DROP TABLE tm1, t1, t2;
+#
+CREATE TEMPORARY TABLE t1 (c1 INT);
+INSERT INTO t1 (c1) VALUES (1);
+CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1);
+DELIMITER |;
+--error ER_SP_BADSTATEMENT
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ CREATE TEMPORARY TABLE t2 (c1 INT);
+ ALTER TEMPORARY TABLE tm1 UNION=(t1,t2);
+ INSERT INTO t2 (c1) VALUES (2);
+ RETURN (SELECT MAX(c1) FROM tm1);
+END|
+DELIMITER ;|
+DROP TABLE tm1, t1;
+#
+# Base table. No LOCK TABLES, no functions/triggers.
+#
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST;
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+DROP TABLE tm1, t1;
+#
+# Base table. No LOCK TABLES, sub-statement that is run inside a function.
+#
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ INSERT INTO tm1 VALUES (1);
+ RETURN (SELECT MAX(c1) FROM tm1);
+END|
+DELIMITER ;|
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST;
+SELECT f1();
+DROP FUNCTION f1;
+DROP TABLE tm1, t1;
+#
+# Base table. LOCK TABLES, no functions/triggers.
+#
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST;
+LOCK TABLE tm1 WRITE;
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+UNLOCK TABLES;
+DROP TABLE tm1, t1;
+#
+# Base table. LOCK TABLES, sub-statement that is run inside a function.
+#
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ INSERT INTO tm1 VALUES (1);
+ RETURN (SELECT MAX(c1) FROM tm1);
+END|
+DELIMITER ;|
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST;
+LOCK TABLE tm1 WRITE;
+SELECT f1();
+UNLOCK TABLES;
+DROP FUNCTION f1;
+DROP TABLE tm1, t1;
+#
+# Base table. LOCK TABLES statement that locks a table that has a trigger
+# that inserts into a merge table, so an attempt is made to lock tables
+# of a sub-statement.
+#
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST;
+CREATE TRIGGER t2_ai AFTER INSERT ON t2
+ FOR EACH ROW INSERT INTO tm1 VALUES(11);
+LOCK TABLE t2 WRITE;
+INSERT INTO t2 VALUES (2);
+SELECT * FROM tm1;
+SELECT * FROM t2;
+UNLOCK TABLES;
+DROP TRIGGER t2_ai;
+DROP TABLE tm1, t1, t2;
+#
+# Temporary. No LOCK TABLES, no functions/triggers.
+#
+CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1)
+ INSERT_METHOD=LAST;
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+DROP TABLE tm1, t1;
+#
+# Temporary. No LOCK TABLES, sub-statement that is run inside a function.
+#
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ INSERT INTO tm1 VALUES (1);
+ RETURN (SELECT MAX(c1) FROM tm1);
+END|
+DELIMITER ;|
+CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1)
+ INSERT_METHOD=LAST;
+SELECT f1();
+DROP FUNCTION f1;
+DROP TABLE tm1, t1;
+#
+# Temporary. LOCK TABLES, no functions/triggers.
+#
+CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1)
+ INSERT_METHOD=LAST;
+CREATE TABLE t9 (c1 INT) ENGINE=MyISAM;
+LOCK TABLE t9 WRITE;
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+UNLOCK TABLES;
+DROP TABLE tm1, t1, t9;
+#
+# Temporary. LOCK TABLES, sub-statement that is run inside a function.
+#
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ INSERT INTO tm1 VALUES (1);
+ RETURN (SELECT MAX(c1) FROM tm1);
+END|
+DELIMITER ;|
+CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1)
+ INSERT_METHOD=LAST;
+CREATE TABLE t9 (c1 INT) ENGINE=MyISAM;
+LOCK TABLE t9 WRITE;
+SELECT f1();
+UNLOCK TABLES;
+DROP FUNCTION f1;
+DROP TABLE tm1, t1, t9;
+#
+# Temporary. LOCK TABLES statement that locks a table that has a trigger
+# that inserts into a merge table, so an attempt is made to lock tables
+# of a sub-statement.
+#
+CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1)
+ INSERT_METHOD=LAST;
+CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
+CREATE TRIGGER t2_ai AFTER INSERT ON t2
+ FOR EACH ROW INSERT INTO tm1 VALUES(11);
+LOCK TABLE t2 WRITE;
+INSERT INTO t2 VALUES (2);
+SELECT * FROM tm1;
+SELECT * FROM t2;
+UNLOCK TABLES;
+DROP TRIGGER t2_ai;
+DROP TABLE tm1, t1, t2;
+--echo #
+--echo # Don't allow an update of a MERGE child in a trigger
+--echo # if the table's already being modified by the main
+--echo # statement.
+--echo #
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1)
+ INSERT_METHOD=LAST;
+CREATE TRIGGER tm1_ai AFTER INSERT ON tm1
+ FOR EACH ROW INSERT INTO t1 VALUES(11);
+LOCK TABLE tm1 WRITE, t1 WRITE;
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+UNLOCK TABLES;
+LOCK TABLE t1 WRITE, tm1 WRITE;
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+UNLOCK TABLES;
+DROP TRIGGER tm1_ai;
+DROP TABLE tm1, t1;
+
+--echo #
+--echo # Don't select MERGE child when trying to get a prelocked table.
+--echo #
+--echo # Due to a limitation demonstrated by the previous test
+--echo # we can no longer use a write-locked prelocked table.
+--echo # The test is kept for historical purposes.
+--echo #
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1)
+ INSERT_METHOD=LAST;
+CREATE TRIGGER tm1_ai AFTER INSERT ON tm1
+ FOR EACH ROW SELECT max(c1) FROM t1 INTO @var;
+LOCK TABLE tm1 WRITE, t1 WRITE;
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+UNLOCK TABLES;
+LOCK TABLE t1 WRITE, tm1 WRITE;
+INSERT INTO tm1 VALUES (1);
+SELECT * FROM tm1;
+UNLOCK TABLES;
+DROP TRIGGER tm1_ai;
+DROP TABLE tm1, t1;
+
+# Don't resurrect chopped off prelocked tables.
+# The problem is not visible by test results; only by debugging.
+#
+CREATE TABLE t1 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE t3 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE t4 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE t5 (c1 INT) ENGINE=MyISAM;
+CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2,t3,t4,t5)
+ INSERT_METHOD=LAST;
+CREATE TRIGGER t2_au AFTER UPDATE ON t2
+ FOR EACH ROW SELECT MAX(c1) FROM t1 INTO @var;
+CREATE FUNCTION f1() RETURNS INT
+ RETURN (SELECT MAX(c1) FROM t4);
+LOCK TABLE tm1 WRITE, t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE, t5 WRITE;
+INSERT INTO t1 VALUES(1);
+INSERT INTO t2 VALUES(2);
+INSERT INTO t3 VALUES(3);
+INSERT INTO t4 VALUES(4);
+INSERT INTO t5 VALUES(5);
+ connect (con1,localhost,root,,);
+ send UPDATE t2, tm1 SET t2.c1=f1();
+connection default;
+# Force reopen in other thread.
+#sleep 1;
+FLUSH TABLES;
+#sleep 1;
+FLUSH TABLES;
+#sleep 1;
+UNLOCK TABLES;
+ connection con1;
+ reap;
+ disconnect con1;
+connection default;
+SELECT * FROM tm1;
+DROP TRIGGER t2_au;
+DROP FUNCTION f1;
+DROP TABLE tm1, t1, t2, t3, t4, t5;
+
+--echo #
+--echo # Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE
+--echo #
+CREATE TEMPORARY TABLE t1 (c1 INT);
+ALTER TABLE t1 ENGINE=MERGE UNION(t_not_exists,t1);
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
+--echo # More tests with TEMPORARY MERGE table and permanent children.
+--echo # First without locked tables.
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3, t4, m1, m2;
+--enable_warnings
+#
+--echo #
+CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+INSERT INTO t1 VALUES (111, 121);
+INSERT INTO m1 VALUES (211, 221);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+ALTER TABLE m1 RENAME m2;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+--error ER_TABLE_EXISTS_ERROR
+ALTER TABLE m2 RENAME m1;
+DROP TABLE m1;
+ALTER TABLE m2 RENAME m1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ADD COLUMN c3 INT;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (212, 222, 232);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 ADD COLUMN c3 INT;
+ALTER TABLE t2 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 DROP COLUMN c3;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (213, 223);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 DROP COLUMN c3;
+ALTER TABLE t2 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+SELECT * FROM m1;
+#
+--echo #
+CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3);
+INSERT INTO m1 VALUES (311, 321);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+#
+--echo #
+CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3,t4);
+INSERT INTO m1 VALUES (411, 421);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+SELECT * FROM t4;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MyISAM;
+SHOW CREATE TABLE m1;
+INSERT INTO m1 VALUES (511, 521);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (611, 621);
+SELECT * FROM m1;
+DROP TABLE t1;
+SELECT * FROM m1;
+#
+#
+--echo #
+--echo #
+SHOW CREATE TABLE m1;
+#
+--echo #
+CREATE TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+--error ER_WRONG_OBJECT
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+--error ER_WRONG_OBJECT
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+CREATE TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+#
+#
+--echo #
+--echo #
+LOCK TABLE m1 WRITE, m2 WRITE;
+SELECT * FROM m1,m2 WHERE m1.c1=m2.c1;
+UNLOCK TABLES;
+#
+DROP TABLE t1, t2, t3, t4, m1, m2;
+#
+#
+#
+--echo #
+--echo # Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine
+--echo # More tests with TEMPORARY MERGE table and permanent children.
+--echo # (continued) Now the same with locked table.
+--echo #
+CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+INSERT INTO t1 VALUES (111, 121);
+INSERT INTO m1 VALUES (211, 221);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+LOCK TABLE m1 WRITE, t1 WRITE, t2 WRITE;
+#
+--echo #
+ALTER TABLE m1 RENAME m2;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+--error ER_TABLE_EXISTS_ERROR
+ALTER TABLE m2 RENAME m1;
+DROP TABLE m1;
+ALTER TABLE m2 RENAME m1;
+SHOW CREATE TABLE m1;
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ADD COLUMN c3 INT;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (212, 222, 232);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 ADD COLUMN c3 INT;
+ALTER TABLE t2 ADD COLUMN c3 INT;
+INSERT INTO m1 VALUES (212, 222, 232);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 DROP COLUMN c3;
+--error ER_WRONG_MRG_TABLE
+INSERT INTO m1 VALUES (213, 223);
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+ALTER TABLE t1 DROP COLUMN c3;
+ALTER TABLE t2 DROP COLUMN c3;
+INSERT INTO m1 VALUES (213, 223);
+SELECT * FROM m1;
+#
+--echo #
+UNLOCK TABLES;
+CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3);
+LOCK TABLE m1 WRITE;
+INSERT INTO m1 VALUES (311, 321);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+#
+--echo #
+CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM;
+ALTER TABLE m1 UNION=(t1,t2,t3,t4);
+INSERT INTO m1 VALUES (411, 421);
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+SELECT * FROM t4;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MyISAM;
+SHOW CREATE TABLE m1;
+INSERT INTO m1 VALUES (511, 521);
+SELECT * FROM m1;
+#
+--echo #
+ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+SELECT * FROM m1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+#
+--echo #
+CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (611, 621);
+SELECT * FROM m1;
+DROP TABLE t1;
+SELECT * FROM m1;
+#
+#
+--echo #
+--echo #
+SHOW CREATE TABLE m1;
+--error ER_TABLE_NOT_LOCKED
+CREATE TABLE m2 SELECT * FROM m1;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 SELECT * FROM m1;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+SELECT * FROM m2;
+LOCK TABLE m1 WRITE, m2 WRITE;
+UNLOCK TABLES;
+DROP TABLE m2;
+LOCK TABLE m1 WRITE;
+#
+--echo #
+--echo # ER_TABLE_NOT_LOCKED is returned in ps-protocol
+--error ER_WRONG_OBJECT, ER_TABLE_NOT_LOCKED
+CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+--error ER_WRONG_OBJECT
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST SELECT * FROM m1;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 LIKE m1;
+SHOW CREATE TABLE m2;
+LOCK TABLE m1 WRITE, m2 WRITE;
+SHOW CREATE TABLE m2;
+SELECT * FROM m2;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2;
+#
+--echo #
+CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+#
+--echo #
+UNLOCK TABLES;
+DROP TABLE t1, t2, t3, t4, m1, m2;
+
+--echo #
+--echo # Bug47098 assert in MDL_context::destroy on HANDLER
+--echo # <damaged merge table> OPEN
+--echo #
+--echo # Test that merge tables are closed correctly when opened using
+--echo # HANDLER ... OPEN.
+--echo # The general case.
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+--echo # Connection con1.
+connect (con1,localhost,root,,);
+CREATE TABLE t1 (c1 int);
+CREATE TABLE t2 (c1 int);
+CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
+START TRANSACTION;
+--error ER_ILLEGAL_HA
+HANDLER t3 OPEN;
+DROP TABLE t1, t2, t3;
+--echo # Connection default.
+connection default;
+--echo # Disconnecting con1, all mdl_tickets must have been released.
+disconnect con1;
+--echo # The bug-specific case.
+--echo # Connection con1.
+connect (con1,localhost,root,,);
+CREATE TABLE t1 (c1 int);
+CREATE TABLE t2 (c1 int);
+CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
+DROP TABLE t2;
+START TRANSACTION;
+--error ER_WRONG_MRG_TABLE
+HANDLER t3 OPEN;
+DROP TABLE t1, t3;
+--echo # Connection default.
+connection default;
+--echo # Disconnecting con1, all mdl_tickets must have been released.
+disconnect con1;
+
+--echo #
+--echo # A test case for Bug#47648 main.merge fails sporadically
+--echo #
+--echo # Make sure we correctly maintain lex->query_tables_last_own.
+--echo #
+create table t1 (c1 int not null);
+create table t2 (c1 int not null);
+create table t3 (c1 int not null);
+
+create function f1 () returns int return (select max(c1) from t3);
+
+create table t4 (c1 int not null) engine=merge union=(t1,t2) insert_method=last ;
+
+select * from t4 where c1 < f1();
+prepare stmt from "select * from t4 where c1 < f1()";
+execute stmt;
+execute stmt;
+execute stmt;
+drop function f1;
+--error ER_SP_DOES_NOT_EXIST
+execute stmt;
+--error ER_SP_DOES_NOT_EXIST
+execute stmt;
+drop table t4, t3, t2, t1;
+
+
+--echo #
+--echo # Bug#51240 ALTER TABLE of a locked MERGE table fails
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS m1, t1;
+--enable_warnings
+
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1);
+LOCK TABLE m1 WRITE;
+# This used to cause an error.
+ALTER TABLE m1 ADD INDEX (c1);
+
+UNLOCK TABLES;
+DROP TABLE m1, t1;
+
+--echo #
+--echo # Locking the merge table won't implicitly lock children.
+--echo #
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1);
+LOCK TABLE m1 WRITE;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+ALTER TABLE t1 ADD INDEX (c1);
+LOCK TABLE m1 WRITE, t1 WRITE;
+ALTER TABLE t1 ADD INDEX (c1);
+UNLOCK TABLES;
+DROP TABLE m1, t1;
+
+--echo #
+--echo # Test for bug #37371 "CREATE TABLE LIKE merge loses UNION parameter"
+--echo #
+--disable_warnings
+drop tables if exists t1, m1, m2;
+--enable_warnings
+create table t1 (i int) engine=myisam;
+create table m1 (i int) engine=mrg_myisam union=(t1) insert_method=first;
+create table m2 like m1;
+--echo # Table definitions should match
+show create table m1;
+show create table m2;
+drop tables m1, m2, t1;
+
+--echo #
+--echo # Test case for Bug#54811 "Assert in mysql_lock_have_duplicate()"
+--echo # Check that unique_table() works correctly for merge tables.
+--echo #
+--disable_warnings
+drop table if exists t1, t2, t3, m1, m2;
+--enable_warnings
+create table t1 (a int);
+create table t2 (a int);
+create table t3 (b int);
+create view v1 as select * from t3,t1;
+create table m1 (a int) engine=merge union (t1, t2) insert_method=last;
+create table m2 (a int) engine=merge union (t1, t2) insert_method=first;
+create temporary table tmp (b int);
+insert into tmp (b) values (1);
+
+insert into t1 (a) values (1);
+insert into t3 (b) values (1);
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from m1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from m2));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t2));
+
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, m1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, m2));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, t1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from t3, t2));
+
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, m1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, m2));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, t1));
+--error ER_UPDATE_TABLE_USED
+insert into m1 (a) values ((select max(a) from tmp, t2));
+
+--error ER_VIEW_PREVENT_UPDATE
+insert into m1 (a) values ((select max(a) from v1));
+--error ER_VIEW_PREVENT_UPDATE
+insert into m1 (a) values ((select max(a) from tmp, v1));
+
+
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from m1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from m2));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t2));
+
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, m1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, m2));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, t1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from t3, t2));
+
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, m1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, m2));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, t1));
+--error ER_UPDATE_TABLE_USED
+update m1 set a = ((select max(a) from tmp, t2));
+
+--error ER_VIEW_PREVENT_UPDATE
+update m1 set a = ((select max(a) from v1));
+--error ER_VIEW_PREVENT_UPDATE
+update m1 set a = ((select max(a) from tmp, v1));
+
+
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from m1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from m2);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t2);
+
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, m1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, m2);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, t1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from t3, t2);
+
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, m1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, m2);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, t1);
+--error ER_UPDATE_TABLE_USED
+delete from m1 where a = (select max(a) from tmp, t2);
+
+--error ER_VIEW_PREVENT_UPDATE
+delete from m1 where a = (select max(a) from v1);
+--error ER_VIEW_PREVENT_UPDATE
+delete from m1 where a = (select max(a) from tmp, v1);
+
+drop view v1;
+drop temporary table tmp;
+drop table t1, t2, t3, m1, m2;
+
+
+--echo #
+--echo # Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for
+--echo # REPAIR of merge table
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t_not_exists;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+ALTER TABLE t1 engine= MERGE UNION (t_not_exists);
+# This caused the segfault
+ANALYZE TABLE t1;
+CHECK TABLE t1;
+CHECKSUM TABLE t1;
+OPTIMIZE TABLE t1;
+REPAIR TABLE t1;
+
+# This caused an assert
+REPAIR TABLE t1 USE_FRM;
+
+DROP TABLE t1;
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a INT) engine= MERGE UNION (t1);
+# This caused an assert
+REPAIR TABLE t2 USE_FRM;
+
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Bug#57002 Assert in upgrade_shared_lock_to_exclusive()
+--echo # for ALTER TABLE + MERGE tables
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, m1;
+--enable_warnings
+
+CREATE TABLE t1(a INT) engine=myisam;
+CREATE TABLE m1(a INT) engine=merge UNION(t1);
+LOCK TABLES t1 READ, m1 WRITE;
+
+# This caused an assert
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+ALTER TABLE t1 engine=myisam;
+
+UNLOCK TABLES;
+DROP TABLE m1, t1;
+
+
+--echo End of 6.0 tests
+
+--disable_result_log
+--disable_query_log
+eval set global storage_engine=$default;
+--enable_result_log
+--enable_query_log
+
+# 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
diff --git a/mysql-test/t/merge_mmap-master.opt b/mysql-test/t/merge_mmap-master.opt
new file mode 100644
index 00000000000..9606fb57187
--- /dev/null
+++ b/mysql-test/t/merge_mmap-master.opt
@@ -0,0 +1 @@
+--myisam-use-mmap
diff --git a/mysql-test/t/merge_mmap.test b/mysql-test/t/merge_mmap.test
new file mode 100644
index 00000000000..c97b029754d
--- /dev/null
+++ b/mysql-test/t/merge_mmap.test
@@ -0,0 +1,151 @@
+#
+# Test of MERGE TABLES with MyISAM memory mapping enabled (--myisam-use-mmap)
+#
+
+# MERGE tables require MyISAM tables
+--let $default=`SELECT @@global.storage_engine`
+SET GLOBAL storage_engine = MyISAM;
+SET SESSION storage_engine = MyISAM;
+
+# Clean up resources used in this test case.
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, m1, m2;
+--enable_warnings
+
+####################
+## No locked tables.
+####################
+#
+# INSERT-SELECT with no TEMPORARY table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+SELECT * FROM t2;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY select table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY insert table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY both tables.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+DROP TABLE m2, m1, t2, t1;
+
+####################
+## With LOCK TABLES.
+####################
+#
+# INSERT-SELECT with no TEMPORARY table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+SELECT * FROM t2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY select table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY insert table.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+#
+# INSERT-SELECT with TEMPORARY both tables.
+#
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2)
+ INSERT_METHOD=LAST;
+LOCK TABLE m1 WRITE, m2 WRITE;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (3), (4);
+INSERT INTO m2 SELECT * FROM m1;
+SELECT * FROM m2;
+UNLOCK TABLES;
+DROP TABLE m2, m1, t2, t1;
+
+--echo End of 6.0 tests
+
+--disable_result_log
+--disable_query_log
+eval SET GLOBAL storage_engine = $default;
+--enable_result_log
+--enable_query_log
diff --git a/mysql-test/t/merge_recover-master.opt b/mysql-test/t/merge_recover-master.opt
new file mode 100644
index 00000000000..875a25ad513
--- /dev/null
+++ b/mysql-test/t/merge_recover-master.opt
@@ -0,0 +1 @@
+--myisam-recover=force
diff --git a/mysql-test/t/merge_recover.test b/mysql-test/t/merge_recover.test
new file mode 100644
index 00000000000..f2cb204eeb6
--- /dev/null
+++ b/mysql-test/t/merge_recover.test
@@ -0,0 +1,113 @@
+--echo #
+--echo # Test of MyISAM MRG tables with corrupted children.
+--echo # Run with --myisam-recover=force option.
+--echo #
+--echo # Preparation: we need to make sure that the merge parent
+--echo # is never left in the table cache when closed, since this may
+--echo # have effect on merge children.
+--echo # For that, we set the table cache to minimal size and populate it
+--echo # in a concurrent connection.
+connect(con1,localhost,root,,test,,);
+--echo #
+--echo # Switching to connection con1
+--echo #
+connection con1;
+--echo #
+--echo # Minimal values.
+--echo #
+
+call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:");
+call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
+call mtr.add_suppression(" '\..test.t1'");
+
+set global table_open_cache=256;
+set global table_definition_cache=400;
+--disable_warnings
+drop procedure if exists p_create;
+--enable_warnings
+delimiter |;
+create procedure p_create()
+begin
+ declare i int default 1;
+ set @lock_table_stmt="lock table ";
+ set @drop_table_stmt="drop table ";
+ while i < @@global.table_definition_cache + 1 do
+ set @table_name=concat("t_", i);
+ set @opt_comma=if(i=1, "", ", ");
+ set @lock_table_stmt=concat(@lock_table_stmt, @opt_comma,
+ @table_name, " read");
+ set @drop_table_stmt=concat(@drop_table_stmt, @opt_comma, @table_name);
+ set @create_table_stmt=concat("create table if not exists ",
+ @table_name, " (a int)");
+ prepare stmt from @create_table_stmt;
+ execute stmt;
+ deallocate prepare stmt;
+ set i= i+1;
+ end while;
+end|
+delimiter ;|
+call p_create();
+drop procedure p_create;
+--disable_query_log
+let $lock=`select @lock_table_stmt`;
+eval $lock;
+--enable_query_log
+--echo #
+--echo # Switching to connection 'default'
+--echo #
+connection default;
+--echo #
+--echo # We have to disable the ps-protocol, to avoid
+--echo # "Prepared statement needs to be re-prepared" errors
+--echo # -- table def versions change all the time with full table cache.
+--echo #
+--disable_ps_protocol
+--disable_warnings
+drop table if exists t1, t1_mrg, t1_copy;
+--enable_warnings
+let $MYSQLD_DATADIR=`select @@datadir`;
+--echo #
+--echo # Prepare a MERGE engine table, that refers to a corrupted
+--echo # child.
+--echo #
+create table t1 (a int, key(a)) engine=myisam;
+create table t1_mrg (a int) union (t1) engine=merge;
+--echo #
+--echo # Create a table with a corrupted index file:
+--echo # save an old index file, insert more rows,
+--echo # overwrite the new index file with the old one.
+--echo #
+insert into t1 (a) values (1), (2), (3);
+flush table t1;
+--copy_file $MYSQLD_DATADIR/test/t1.MYI $MYSQLD_DATADIR/test/t1_copy.MYI
+insert into t1 (a) values (4), (5), (6);
+flush table t1;
+--remove_file $MYSQLD_DATADIR/test/t1.MYI
+--copy_file $MYSQLD_DATADIR/test/t1_copy.MYI $MYSQLD_DATADIR/test/t1.MYI
+--remove_file $MYSQLD_DATADIR/test/t1_copy.MYI
+--echo # check table is needed to mark the table as crashed.
+check table t1;
+--echo #
+--echo # At this point we have a merge table t1_mrg pointing to t1,
+--echo # and t1 is corrupted, and will be auto-repaired at open.
+--echo # Check that this doesn't lead to memory corruption.
+--echo #
+--replace_regex /'.*[\/\\]/'/
+select * from t1_mrg;
+--echo #
+--echo # Cleanup
+--echo #
+drop table t1, t1_mrg;
+--echo #
+--echo # Switching to connection con1
+--echo #
+connection con1;
+unlock tables;
+prepare stmt from @drop_table_stmt;
+execute stmt;
+deallocate prepare stmt;
+set @@global.table_definition_cache=default;
+set @@global.table_open_cache=default;
+disconnect con1;
+connection default;
+--enable_ps_protocol
diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test
index 9bfb47c53be..4653864a6c0 100644
--- a/mysql-test/t/metadata.test
+++ b/mysql-test/t/metadata.test
@@ -143,3 +143,60 @@ DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.0 tests
+
+# Verify that column metadata is correct for all possible data types.
+# Originally about BUG#42980 "Client doesn't set NUM_FLAG for DECIMAL"
+
+create table t1(
+# numeric types
+bool_col bool,
+boolean_col boolean,
+bit_col bit(5),
+tiny tinyint,
+tiny_uns tinyint unsigned,
+small smallint,
+small_uns smallint unsigned,
+medium mediumint,
+medium_uns mediumint unsigned,
+int_col int,
+int_col_uns int unsigned,
+big bigint,
+big_uns bigint unsigned,
+decimal_col decimal(10,5),
+# synonyms of DECIMAL
+numeric_col numeric(10),
+fixed_col fixed(10),
+dec_col dec(10),
+decimal_col_uns decimal(10,5) unsigned,
+fcol float,
+fcol_uns float unsigned,
+dcol double,
+double_precision_col double precision,
+dcol_uns double unsigned,
+# date/time types
+date_col date,
+time_col time,
+timestamp_col timestamp,
+year_col year,
+datetime_col datetime,
+# string types
+char_col char(5),
+varchar_col varchar(10),
+binary_col binary(10),
+varbinary_col varbinary(10),
+tinyblob_col tinyblob,
+blob_col blob,
+mediumblob_col mediumblob,
+longblob_col longblob,
+text_col text,
+mediumtext_col mediumtext,
+longtext_col longtext,
+enum_col enum("A","B","C"),
+set_col set("F","E","D")
+);
+
+--enable_metadata
+select * from t1;
+--disable_metadata
+
+drop table t1;
diff --git a/mysql-test/t/multi_update-master.opt b/mysql-test/t/multi_update-master.opt
index 9f1a29461ff..da78f987af3 100644
--- a/mysql-test/t/multi_update-master.opt
+++ b/mysql-test/t/multi_update-master.opt
@@ -1 +1 @@
---set-variable=tmp_table_size=1024
+--tmp_table_size=1024
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 5298701d790..496d045075a 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -474,7 +474,8 @@ drop table t1,t2;
#
# Test alter table and a concurrent multi update
-# (This will force update to reopen tables)
+# (Before we have introduced data-lock-aware metadata locks
+# this test case forced update to reopen tables).
#
create table t1 (a int, b int);
@@ -494,9 +495,9 @@ send alter table t1 add column c int default 100 after a;
connect (updater,localhost,root,,test);
connection updater;
# Wait till "alter table t1 ..." of session changer is in work.
-# = There is one session is in state "Locked".
+# = There is one session waiting.
let $wait_condition= select count(*)= 1 from information_schema.processlist
- where state= 'Locked';
+ where state= 'Waiting for table metadata lock';
--source include/wait_condition.inc
send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
@@ -505,9 +506,9 @@ connection locker;
# - "alter table t1 ..." of session changer and
# - "update t1, v1 ..." of session updater
# are in work.
-# = There are two session is in state "Locked".
+# = There are two session waiting.
let $wait_condition= select count(*)= 2 from information_schema.processlist
- where state= 'Locked';
+ where state= 'Waiting for table metadata lock';
--source include/wait_condition.inc
unlock tables;
@@ -585,8 +586,7 @@ reset master;
UPDATE t2,t1 SET t2.a=t1.a+2;
# check
select * from t2 /* must be (3,1), (4,4) */;
-let wait_binlog_event= UPDATE;
-source include/wait_for_binlog_event.inc;
+source include/show_binlog_events.inc;
# B. testing multi_update::send_error() ineffective update
# (as there is a policy described at mysql_update() still go to binlog)
@@ -597,8 +597,7 @@ insert into t2 values (1,2),(3,4),(4,4);
reset master;
--error ER_DUP_ENTRY
UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
-let wait_binlog_event= UPDATE;
-source include/wait_for_binlog_event.inc;
+source include/show_binlog_events.inc;
# cleanup
drop table t1, t2;
@@ -684,4 +683,24 @@ UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
DROP FUNCTION f1;
DROP TABLE t1;
+--echo #
+--echo # BUG#57373: Multi update+InnoDB reports ER_KEY_NOT_FOUND if a
+--echo # table is updated twice
+--echo #
+
+# Results differ between storage engines.
+# See multi_update_innodb.test for the InnoDB variant of this test
+CREATE TABLE t1(
+ pk INT,
+ a INT,
+ PRIMARY KEY (pk)
+) ENGINE=MyISAM;
+
+INSERT INTO t1 VALUES (0,0);
+UPDATE t1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+--echo
+--echo # Should be (1,2)
+SELECT * FROM t1;
+DROP TABLE t1;
+
--echo end of tests
diff --git a/mysql-test/t/multi_update2-master.opt b/mysql-test/t/multi_update2-master.opt
index 9f1a29461ff..da78f987af3 100644
--- a/mysql-test/t/multi_update2-master.opt
+++ b/mysql-test/t/multi_update2-master.opt
@@ -1 +1 @@
---set-variable=tmp_table_size=1024
+--tmp_table_size=1024
diff --git a/mysql-test/t/multi_update_innodb.test b/mysql-test/t/multi_update_innodb.test
new file mode 100644
index 00000000000..3148d009cef
--- /dev/null
+++ b/mysql-test/t/multi_update_innodb.test
@@ -0,0 +1,33 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # BUG#57373: Multi update+InnoDB reports ER_KEY_NOT_FOUND if a
+--echo # table is updated twice
+--echo #
+
+# Results differ between storage engines.
+# See multi_update.test for the MyISAM variant of this test
+CREATE TABLE t1(
+ pk INT,
+ a INT,
+ b INT,
+ PRIMARY KEY (pk)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (0,0,0);
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+SELECT * FROM t1;
+
+CREATE VIEW v1 AS SELECT * FROM t1;
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE v1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+SELECT * FROM t1;
+
+UPDATE t1 AS A, t1 AS B SET A.a = 1, B.b = 2;
+--echo # Should be (0,1,2)
+SELECT * FROM t1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
diff --git a/mysql-test/t/multi_update_tiny_hash-master.opt b/mysql-test/t/multi_update_tiny_hash-master.opt
index d81cc55090d..2fa4c2b903d 100644
--- a/mysql-test/t/multi_update_tiny_hash-master.opt
+++ b/mysql-test/t/multi_update_tiny_hash-master.opt
@@ -1 +1 @@
---set-variable=max_heap_table_size=16384
+--max_heap_table_size=16384
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 4abd7dd2b1b..d4b4d1555b6 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -503,6 +503,7 @@ insert into t2 values(2,0);
disconnect root;
connection default;
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
+unlock tables;
drop table t1,t2;
#
# Full key.
@@ -520,6 +521,7 @@ disconnect con1;
connection default;
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
+UNLOCK TABLES;
DROP TABLE t1,t2;
# End of 4.0 tests
@@ -1646,3 +1648,35 @@ SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
SET myisam_repair_threads=@@global.myisam_repair_threads;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug#51327 MyISAM table is automatically repaired on ALTER
+--echo # even if myisam-recover is OFF
+--echo #
+
+call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:");
+call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
+call mtr.add_suppression(" '\..test.t1'");
+
+let $MYSQLD_DATADIR = `SELECT @@datadir`;
+--echo # Test that we can exchange a crashed partition with a table
+SELECT @@global.myisam_recover_options;
+CREATE TABLE t1 (a INT, KEY (a)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1), (2);
+FLUSH TABLES;
+
+--echo # replacing t.MYI with a corrupt + unclosed one created by doing:
+--echo # 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI
+--remove_file $MYSQLD_DATADIR/test/t1.MYI
+--copy_file std_data/corrupt_t1.MYI $MYSQLD_DATADIR/test/t1.MYI
+
+CHECK TABLE t1;
+--echo # Alter table should report error and not auto-repair the table.
+# Remove the path to t1 to prevent platform differences
+--replace_regex /'[^']+'/'t1'/
+--error 145
+ALTER TABLE t1 ENGINE = MyISAM;
+CHECK TABLE t1;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/myisam_crash_before_flush_keys.test b/mysql-test/t/myisam_crash_before_flush_keys.test
index 1860ddd27e3..a9f36f40d10 100644
--- a/mysql-test/t/myisam_crash_before_flush_keys.test
+++ b/mysql-test/t/myisam_crash_before_flush_keys.test
@@ -8,6 +8,11 @@
--echo # Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
+call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:");
+call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+
let $MYSQLD_DATADIR= `select @@datadir`;
SET GLOBAL delay_key_write=ALL;
CREATE TABLE t1(a INT,
diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test
index 9d27ed53254..463aa559de2 100644
--- a/mysql-test/t/myisampack.test
+++ b/mysql-test/t/myisampack.test
@@ -1,3 +1,6 @@
+-- disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+-- enable_warnings
#
# BUG#31277 - myisamchk --unpack corrupts a table
#
@@ -105,5 +108,116 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYISAMCHK -srq $MYSQLD_DATADIR/mysql_db1/t1
SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5;
#
+# Bug#36573 myisampack --join does not create destination table .frm file
+#
+#############################################################################
+# Testcase myisampack.1: Positive test for myisampack --join
+# To test myisampack --join operation creates .frm file
+# If it creates .frm file, we will be able to access from mysql
+# server
+#############################################################################
+--echo # ===== myisampack.1 =====
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(20);
+
+let $i=9;
+--disable_query_log
+while ($i)
+{
+ INSERT INTO t1 SELECT a from t1;
+ dec $i;
+}
+--enable_query_log
+
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES(40);
+
+let $i=9;
+--disable_query_log
+while ($i)
+{
+ INSERT INTO t2 SELECT a from t2;
+ dec $i;
+}
+--enable_query_log
+
+FLUSH TABLE t1,t2;
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+
+--echo #If the myisampack --join operation is successful, we have table t3(.frm)
+--echo #so we should be able to query about the table from server.
+SELECT COUNT(a) FROM t3;
+
+#############################################################################
+# Testcase myisampack.2: 2nd Positive test for myisampack --join
+# Test myisampack join operation with an existing destination frm file.
+# It should finish the join operation successfully
+#############################################################################
+--echo # ===== myisampack.2 =====
+FLUSH TABLE t3;
+--remove_file $MYSQLD_DATADIR/test/t3.MYI
+--remove_file $MYSQLD_DATADIR/test/t3.MYD
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+--echo #Tests the myisampack join operation with an existing destination .frm file,
+--echo #the command should return correct exit status(0) and
+--echo #we should be able to query the table.
+
+SELECT COUNT(a) FROM t3;
+
+#############################################################################
+# Testcase myisampack.3: 3rd Positive test for myisampack --join
+# Test myisampack join operation without frm file for first table and second
+# table. It should finish the join operation successfully
+#############################################################################
+--echo # ===== myisampack.3 =====
+--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm
+--copy_file $MYSQLD_DATADIR/test/t2.frm $MYSQLTEST_VARDIR/tmp/bug36573.t2.frm
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+--remove_file $MYSQLD_DATADIR/test/t2.frm
+
+DROP TABLE t3;
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+--echo #Tests the myisampack join operation without frm file for the first and second table
+--echo #No frm file is generated in this and we shouldn't be able to access the newly
+--echo #created table
+
+--error ER_NO_SUCH_TABLE
+SELECT COUNT(a) FROM t3;
+
+--copy_file $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file $MYSQLTEST_VARDIR/tmp/bug36573.t2.frm $MYSQLD_DATADIR/test/t2.frm
+--copy_file $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm $MYSQLD_DATADIR/test/t3.frm
+--remove_file $MYSQLTEST_VARDIR/tmp/bug36573.t1.frm
+--remove_file $MYSQLTEST_VARDIR/tmp/bug36573.t2.frm
+
+#############################################################################
+# Testcase myisampack.4: Negative test for myisampack --join
+# Test myisampack join operation with an existing .MYI,.MDI,.frm files
+# the test should fail
+#############################################################################
+--echo # ===== myisampack.4 =====
+--echo #Tests the myisampack join operation with an existing destination .frm,.MYI,.MDI
+--echo #the command should fail with exit status 2
+#
+# Note: Use of regular expressions in this file is for output printed in result file
+# The main purpose of this regular expression is to supress the filenames for
+# error messages produced so that we can create a generic result file
+#
+#1. /.*myisampack(\.exe)?: Can't create\/write to file .*\(/myisampack: Can't create\/write to file (/
+# Replace everything before "myisampack" or "myisampack.exe" and followed by
+# ": Can't create\/write to file " until the first open paranthesis , with
+# "myisampack: Can't create\/write to file ("
+#
+#2. /Aborted: .*is/Aborted: file is/
+# Replace everything after starting with "Aborted: " until ending with "is" with
+# "Aborted: file is/
+#
+--replace_regex /.*myisampack(\.exe)?: Can't create\/write to file .*\(/myisampack: Can't create\/write to file (/ /Aborted: .*is/Aborted: file is/
+--error 2
+--exec $MYISAMPACK --join=$MYSQLD_DATADIR/test/t3 $MYSQLD_DATADIR/test/t1 $MYSQLD_DATADIR/test/t2 2>&1
+
+DROP TABLE t1,t2,t3;
+
DROP TABLE mysql_db1.t1;
DROP DATABASE mysql_db1;
+
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index 2dcc77a16c2..a7c9dc54042 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -367,6 +367,14 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql;
--enable_query_log
#
+# Bug#26780: patch to add auto vertical output option to the cli.
+#
+# Make this wide enough that it will wrap almost everywhere.
+--exec $MYSQL test --auto-vertical-output --table -e "SELECT 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0;"
+# Too short to wrap.
+--exec $MYSQL test --auto-vertical-output --table -e "SELECT 1;"
+
+#
# Bug #25146: Some warnings/errors not shown when using --show-warnings
#
@@ -383,6 +391,11 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql;
drop tables t1, t2;
#
+# mysql client with 'init-command' option
+#
+--exec $MYSQL --init-command="SET lc_messages=ru_RU" -e "SHOW VARIABLES LIKE 'lc_messages';"
+
+#
# Bug #27884: mysql --html does not quote HTML special characters in output
#
--write_file $MYSQLTEST_VARDIR/tmp/bug27884.sql
@@ -412,6 +425,12 @@ drop table t1;
--echo
--exec $MYSQL --skip-column-names --vertical test -e "select 1 as a"
+#
+# Bug#57450: mysql client enter in an infinite loop if the standard input is a directory
+#
+--error 1
+--exec $MYSQL < .
+
--echo
--echo #
diff --git a/mysql-test/t/mysql_client_test-master.opt b/mysql-test/t/mysql_client_test-master.opt
index 4c683f7f0a2..3dfaf15666f 100644
--- a/mysql-test/t/mysql_client_test-master.opt
+++ b/mysql-test/t/mysql_client_test-master.opt
@@ -1 +1,4 @@
---log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE,TABLE
+--log=$MYSQLTEST_VARDIR/log/master.log
+--log-output=FILE,TABLE
+$PLUGIN_AUTH_OPT
+$PLUGIN_AUTH_LOAD
diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test
index 41670117c7c..529d60517c0 100644
--- a/mysql-test/t/mysql_client_test.test
+++ b/mysql-test/t/mysql_client_test.test
@@ -1,5 +1,7 @@
# This test should work in embedded server after we fix mysqltest
-- 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_general_log= @@global.general_log;
SET @old_slow_query_log= @@global.slow_query_log;
@@ -12,10 +14,17 @@ SET @old_slow_query_log= @@global.slow_query_log;
# var/log/mysql_client_test.trace
--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
---exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
+--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M $PLUGIN_AUTH_CLIENT_OPT >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
# End of 4.1 tests
echo ok;
+--echo
+--echo # cat MYSQL_TMP_DIR/test_wl4435.out.log
+--echo # ------------------------------------
+--cat_file $MYSQL_TMP_DIR/test_wl4435.out.log
+--echo # ------------------------------------
+--echo
+
SET @@global.general_log= @old_general_log;
SET @@global.slow_query_log= @old_slow_query_log;
diff --git a/mysql-test/t/mysql_delimiter_19799.sql b/mysql-test/t/mysql_delimiter_19799.sql
index 2a3d4378492..2a3d4378492 100755..100644
--- a/mysql-test/t/mysql_delimiter_19799.sql
+++ b/mysql-test/t/mysql_delimiter_19799.sql
diff --git a/mysql-test/t/mysql_locale_posix.test b/mysql-test/t/mysql_locale_posix.test
new file mode 100644
index 00000000000..c047b7b1ae9
--- /dev/null
+++ b/mysql-test/t/mysql_locale_posix.test
@@ -0,0 +1,205 @@
+--source include/not_windows.inc
+--source include/have_case_sensitive_file_system.inc
+
+
+#
+# Note, please keep this file UTF-8 compatible.
+# After editing, make sure that
+# "file mysql_locale_posix.test"
+# says
+# "UTF-8 Unicode text"
+# or
+# "UTF-8 Unicode English text"
+#
+
+
+#
+# Check if we're running on a POSIX-locale machine
+#
+
+--disable_query_log
+--exec locale -a > $MYSQLTEST_VARDIR/tmp/locale_a.output 2>/dev/null || true
+SET @file=REPLACE(LOAD_FILE('../../tmp/locale_a.output'), '-', '');
+#
+# Note, file content must be case sensitive.
+# Some platforms are case sensitive regarding to locale name.
+# For example, on HP-UX
+# LANG=cs_CZ.iso88592 - works fine
+# LANG=cs_CZ.ISO88592 - does not work
+#
+--remove_file $MYSQLTEST_VARDIR/tmp/locale_a.output
+
+if (`SELECT (IFNULL(@file,'') NOT LIKE '%\nde_DE.iso88591\n%')`)
+{
+ Skip Need POSIX locale de_DE.iso88591;
+}
+
+if (`SELECT (IFNULL(@file,'') NOT LIKE '%\nru_RU.koi8r\n%')`)
+{
+ Skip Need POSIX locale ru_RU.koi8r;
+}
+
+if (`SELECT (IFNULL(@file,'') NOT LIKE '%\ncs_CZ.iso88592\n%')`)
+{
+ Skip Need POSIX locale cs_CZ.iso88592;
+}
+
+if (`SELECT (IFNULL(@file,'') NOT LIKE '%\nen_US.utf8\n%')`)
+{
+ Skip Need POSIX locale en_US.utf8;
+}
+--enable_query_log
+
+
+
+SET NAMES utf8;
+
+--disable_warnings
+DROP DATABASE IF EXISTS `ó`;
+DROP DATABASE IF EXISTS `Ä‚Å‚`;
+DROP DATABASE IF EXISTS `цÐ`;
+DROP DATABASE IF EXISTS `ó`;
+--enable_warnings
+
+#
+# Test some of the OS-to-MySQL character set mappings
+#
+
+
+# {"ANSI_X3.4-1968", "ascii", my_cs_exact},
+# {"ansi1251", "cp1251", my_cs_exact},
+# {"armscii8", "armscii8", my_cs_exact},
+# {"ASCII", "ascii", my_cs_exact},
+# {"Big5", "big5", my_cs_exact},
+# {"cp1251", "cp1251", my_cs_exact},
+# {"cp1255", "cp1255", my_cs_exact},
+# {"CP866", "cp866", my_cs_exact},
+# {"eucCN", "gb2312", my_cs_exact},
+# {"eucJP", "ujis", my_cs_exact},
+# {"eucKR", "euckr", my_cs_exact},
+#
+# {"gb18030", "gb18030", my_cs_exact},
+#
+# {"gb2312", "gb2312", my_cs_exact},
+# {"gbk", "gbk", my_cs_exact},
+# {"georgianps", "geostd8", my_cs_exact},
+# {"IBM-1252", "cp1252", my_cs_exact},
+#
+# {"iso88591", "latin1", my_cs_approx},
+# {"ISO_8859-1", "latin1", my_cs_approx},
+# {"ISO8859-1", "latin1", my_cs_approx},
+# {"ISO-8859-1", "latin1", my_cs_approx},
+
+
+#
+# _utf8 0xC3B3 = LATIN SMALL LETTER O WITH ACUTE
+# _latin1 0xC3 = LATIN CAPITAL LETTER A WITH TILDE
+# _latin1 0xB3 = SUPERSCRIPT THREE
+#
+--echo
+--echo iso88591
+--exec LC_ALL=fi_FI.iso88591 $MYSQL --default-character-set=auto test -e "SELECT @@character_set_client"
+--exec LC_ALL=fi_FI.iso88591 $MYSQLADMIN -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
+--exec LC_ALL=fi_FI.iso88591 $MYSQL_SHOW --default-character-set=auto ó
+--exec LC_ALL=fi_FI.iso88591 $MYSQL_CHECK --default-character-set=auto "ó"
+
+
+# {"iso885913", "latin7", my_cs_exact},
+# {"ISO_8859-13", "latin7", my_cs_exact},
+# {"ISO8859-13", "latin7", my_cs_exact},
+# {"ISO-8859-13", "latin7", my_cs_exact},
+#
+# {"iso885915", "latin9", my_cs_exact},
+# {"ISO_8859-15", "latin9", my_cs_exact},
+# {"ISO8859-15", "latin9", my_cs_exact},
+# {"ISO-8859-15", "latin9", my_cs_exact},
+#
+# {"iso88592", "latin2", my_cs_exact},
+# {"ISO_8859-2", "latin2", my_cs_exact},
+# {"ISO8859-2", "latin2", my_cs_exact},
+# {"ISO-8859-2", "latin2", my_cs_exact},
+#
+
+
+#
+# _utf8 0xC3B3 = LATIN SMALL LETTER O WITH ACUTE
+# _latin2 0xC3 = LATIN CAPITAL LETTER A WITH BREVE
+# _latin2 0xB3 = LATIN SMALL LETTER L WITH STROKE
+#
+--echo
+--echo iso88592
+--exec LC_ALL=cs_CZ.iso88592 $MYSQL --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=auto test -e "SELECT @@character_set_client"
+--exec LC_ALL=cs_CZ.iso88592 $MYSQLADMIN --character-sets-dir=$MYSQL_SHAREDIR/charsets -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
+--exec LC_ALL=cs_CZ.iso88592 $MYSQL_SHOW --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=auto ó
+--exec LC_ALL=cs_CZ.iso88592 $MYSQL_CHECK --character-sets-dir=$MYSQL_SHAREDIR/charsets--default-character-set=auto "ó"
+
+
+# {"iso88597", "greek", my_cs_exact},
+# {"ISO_8859-7", "greek", my_cs_exact},
+# {"ISO8859-7", "greek", my_cs_exact},
+# {"ISO-8859-7", "greek", my_cs_exact},
+#
+# {"iso88598", "hebrew", my_cs_exact},
+# {"ISO_8859-8", "hebrew", my_cs_exact},
+# {"ISO8859-8", "hebrew", my_cs_exact},
+# {"ISO-8859-8", "hebrew", my_cs_exact},
+#
+# {"iso88599", "latin5", my_cs_exact},
+# {"ISO_8859-9", "latin5", my_cs_exact},
+# {"ISO8859-9", "latin5", my_cs_exact},
+# {"ISO-8859-9", "latin5", my_cs_exact},
+#
+# {"koi8r", "koi8r", my_cs_exact},
+# {"KOI8-R", "koi8r", my_cs_exact},
+# {"koi8u", "koi8u", my_cs_exact},
+# {"KOI8-U", "koi8u", my_cs_exact},
+#
+
+#
+# _utf8 0xC3B3 = LATIN SMALL LETTER O WITH ACUTE
+# _koi8r 0xC3 = CYRILLIC SMALL LETTER TSE
+# _koi8r 0xB3 = CYRILLIC CAPITAL LETTER IO
+#
+
+--echo
+--echo koi8r
+--exec LC_ALL=ru_RU.koi8r $MYSQL --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=auto test -e "SELECT @@character_set_client"
+--exec LC_ALL=ru_RU.koi8r $MYSQLADMIN --character-sets-dir=$MYSQL_SHAREDIR/charsets -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
+--exec LC_ALL=ru_RU.koi8r $MYSQL_SHOW --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=auto ó
+--exec LC_ALL=ru_RU.koi8r $MYSQL_CHECK --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=auto "ó"
+
+
+# {"Shift_JIS", "sjis", my_cs_exact},
+# {"SJIS", "sjis", my_cs_exact},
+#
+# {"tis620", "tis620", my_cs_exact},
+#
+# {"ujis", "ujis", my_cs_exact},
+#
+# {"US-ASCII", "ascii", my_cs_exact},
+#
+# {"utf8", "utf8", my_cs_exact},
+# {"utf-8", "utf8", my_cs_exact},
+
+--echo
+--echo utf8
+--exec LC_ALL=en_US.utf8 $MYSQL --default-character-set=auto test -e "SELECT @@character_set_client"
+--exec LC_ALL=en_US.utf8 $MYSQLADMIN -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
+--exec LC_ALL=en_US.utf8 $MYSQL_SHOW --default-character-set=auto ó
+--exec LC_ALL=en_US.utf8 $MYSQL_SHOW --default-character-set=auto "ó"
+--exec LC_ALL=en_US.utf8 $MYSQL_SHOW --default-character-set=auto "Ä‚Å‚"
+--exec LC_ALL=en_US.utf8 $MYSQL_SHOW --default-character-set=auto "цÐ"
+--exec LC_ALL=en_US.utf8 $MYSQL_CHECK --default-character-set=auto ó
+--exec LC_ALL=en_US.utf8 $MYSQL_CHECK --default-character-set=auto "ó"
+--exec LC_ALL=en_US.utf8 $MYSQL_CHECK --default-character-set=auto "Ä‚Å‚"
+--exec LC_ALL=en_US.utf8 $MYSQL_CHECK --default-character-set=auto "цÐ"
+
+SHOW DATABASES LIKE 'ó';
+SHOW DATABASES LIKE 'Ä‚Å‚';
+SHOW DATABASES LIKE 'цÐ';
+SHOW DATABASES LIKE 'ó';
+
+DROP DATABASE `ó`;
+DROP DATABASE `Ä‚Å‚`;
+DROP DATABASE `цÐ`;
+DROP DATABASE `ó`;
diff --git a/mysql-test/t/mysql_not_windows.test b/mysql-test/t/mysql_not_windows.test
new file mode 100644
index 00000000000..66853677f7b
--- /dev/null
+++ b/mysql-test/t/mysql_not_windows.test
@@ -0,0 +1,15 @@
+-- source include/not_windows.inc
+# This test should work in embedded server after we fix mysqltest
+-- source include/not_embedded.inc
+#
+# Testing the MySQL command line client(mysql)
+#
+
+#
+# Bug #54466 client 5.5 built from source lacks "pager" support
+#
+--echo Bug #54466 client 5.5 built from source lacks "pager" support
+--exec $MYSQL --pager test -e "select 1 as a"
+
+--echo
+--echo End of tests
diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test
index 5f3ff9c7bb8..3c6cc45da38 100644
--- a/mysql-test/t/mysql_upgrade.test
+++ b/mysql-test/t/mysql_upgrade.test
@@ -1,31 +1,4 @@
-# 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:
-#
-# If running with Valgrind ($VALGRIND_TEST <> 0) then the resource
-# consumption (CPU) for upgrading a large log table will be intense.
-# Therefore, truncate the log table in advance and issue a statement
-# that should be logged.
-#
-if (`SELECT $VALGRIND_TEST`)
-{
- --disable_query_log
- --disable_result_log
- --disable_abort_on_error
- TRUNCATE TABLE mysql.general_log;
- SELECT 1;
- --enable_abort_on_error
- --enable_result_log
- --enable_query_log
-}
+-- source include/mysql_upgrade_preparation.inc
#
# Basic test that we can run mysql_upgrde and that it finds the
@@ -90,7 +63,6 @@ set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
eval set GLOBAL sql_mode=default;
-
--echo #
--echo # Bug #41569 mysql_upgrade (ver 5.1) add 3 fields to mysql.proc table
--echo # but does not set values.
@@ -124,3 +96,11 @@ SHOW GRANTS FOR 'user3'@'%';
DROP USER 'user3'@'%';
--echo End of 5.1 tests
+
+
+#
+# Test the --upgrade-system-tables option
+#
+--replace_result $MYSQLTEST_VARDIR var
+--exec $MYSQL_UPGRADE --skip-verbose --upgrade-system-tables
+
diff --git a/mysql-test/t/mysql_upgrade_ssl.test b/mysql-test/t/mysql_upgrade_ssl.test
new file mode 100644
index 00000000000..d1c029bf33a
--- /dev/null
+++ b/mysql-test/t/mysql_upgrade_ssl.test
@@ -0,0 +1,10 @@
+# mysql_upgrade tests requiring SSL support
+
+-- source include/have_ssl_communication.inc
+-- source include/mysql_upgrade_preparation.inc
+
+--echo #
+--echo # Bug#55672 mysql_upgrade dies with internal error
+--echo #
+--exec $MYSQL_UPGRADE --skip-verbose --ssl --force 2>&1
+--exit
diff --git a/mysql-test/t/mysqladmin.test b/mysql-test/t/mysqladmin.test
index a2b12dbc9b6..4811c5fdbc6 100644
--- a/mysql-test/t/mysqladmin.test
+++ b/mysql-test/t/mysqladmin.test
@@ -4,7 +4,7 @@
# Test "mysqladmin ping"
#
---exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
+--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
#
@@ -19,7 +19,7 @@ EOF
--replace_regex /.*mysqladmin.*: unknown/mysqladmin: unknown/
--error 7
---exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
+--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf;
# When mysqladmin finds "loose-database" in .cnf file it shall print
@@ -30,7 +30,7 @@ loose-database=db2
EOF
--replace_regex /Warning: .*mysqladmin.*: unknown/Warning: mysqladmin: unknown/
---exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
+--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf;
@@ -45,3 +45,17 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf;
--cat_file $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp
--remove_file $MYSQLTEST_VARDIR/tmp/mysqladmin.tmp
+
+--echo #
+--echo # BUG#11766184 - 59234: cmdline clients crash --defaults-extra-file
+--echo # with no .cnf or .ini extension.
+--echo #
+
+--echo # Creating an empty file 'cnf_file'
+--write_file $MYSQLTEST_VARDIR/tmp/cnf_file
+EOF
+
+--echo # Using --defaults-extra-file option with 'cnf_file'.
+--exec $MYSQLADMIN --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/cnf_file -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT ping 2>&1
+
+--remove_file $MYSQLTEST_VARDIR/tmp/cnf_file
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index d5dd3052269..f64d8b502ae 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -4,6 +4,10 @@
-- source include/have_log_bin.inc
+--disable_query_log
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+--enable_query_log
+
# Deletes all the binary logs
reset master;
@@ -32,6 +36,7 @@ load data infile '../../std_data/words.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1;
# simple query to show more in second binlog
+--let $binlog_start_pos=query_get_value(SHOW MASTER STATUS, Position, 1)
insert into t1 values ("Alas");
flush logs;
@@ -65,14 +70,13 @@ select "--- --database --" as "";
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLD_DATADIR/master-bin.000001 2> /dev/null
-# this test for position option
+# this test for start-position option
--disable_query_log
-select "--- --position --" as "";
+select "--- --start-position --" as "";
--enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=332 $MYSQLD_DATADIR/master-bin.000002
-
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000002
# These are tests for remote binlog.
# They should return the same as previous test.
@@ -104,11 +108,11 @@ select "--- --database --" as "";
# Strangely but this works
--disable_query_log
-select "--- --position --" as "";
+select "--- --start-position --" as "";
--enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=332 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --start-position=$binlog_start_pos --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# Bug#7853 mysqlbinlog does not accept input from stdin
--disable_query_log
@@ -120,7 +124,9 @@ select "--- reading stdin --" as "";
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
---exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
+# postion is constant to correspond to an event in pre-recorded binlog
+--let $binlog_start_pos=79
+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start_pos - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
drop table t1,t2;
#
@@ -141,7 +147,14 @@ EOF
# must be digestable for both client and server. In 4.1 the client
# should use default-character-set same as the server.
flush logs;
---exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
+# Due to BUG#18337 that wrongly suppresses the BINLOG EVENTS when
+# --short-form is used, the "insert into t5 select * from `äöüÄÖÜ`"
+# which is unsafe and thus written to the binary log in the row
+# format is not executed. This makes the assertion select * from t5
+# /* must be (1),(1) */; to fail. To temporary fix the bug, we
+# removed the option --short-form.
+#--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
select * from t5 /* must be (1),(1) */;
drop table t5;
@@ -251,7 +264,7 @@ eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat'
--echo The bug being tested was that 'Query' lines were not preceded by '#'
--echo If the line is in the table, it had to have been preceded by a '#'
--echo
-SELECT COUNT(*) AS `BUG#28293_expect_1` FROM patch WHERE a LIKE '%Query%';
+SELECT COUNT(*) AS `BUG#28293_expect_3` FROM patch WHERE a LIKE '%Query%';
DROP TABLE patch;
#
@@ -263,7 +276,7 @@ INSERT INTO t1 VALUES(connection_id());
let $a= `SELECT a FROM t1`;
FLUSH LOGS;
let $outfile= $MYSQLTEST_VARDIR/tmp/bug29928.sql;
---exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000014 > $outfile
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000015 > $outfile
DROP TABLE t1;
connect (con1, localhost, root, , test);
connection con1;
@@ -287,8 +300,8 @@ exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTES
#
FLUSH LOGS;
--error 1
---exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
---exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000017 >/dev/null 2>/dev/null
+--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000017 >/dev/null 2>/dev/null
--echo Bug#31611 Security risk with BINLOG statement
@@ -303,8 +316,8 @@ CREATE TABLE t1 (a INT, b CHAR(64));
flush logs;
INSERT INTO t1 VALUES (1,USER());
flush logs;
-echo mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql;
-exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000017 > $MYSQLTEST_VARDIR/tmp/bug31611.sql;
+echo mysqlbinlog var/log/master-bin.000018 > var/tmp/bug31611.sql;
+exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000018 > $MYSQLTEST_VARDIR/tmp/bug31611.sql;
connect (unsecure,localhost,untrusted,,mysqltest1);
echo mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql;
error 1;
@@ -337,8 +350,8 @@ FLUSH LOGS;
query_vertical SELECT * FROM t1;
DROP TABLE t1;
-echo >> mysqlbinlog var/log/master-bin.000019 > var/tmp/bug32580.sql;
-exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000019 > $MYSQLTEST_VARDIR/tmp/bug32580.sql;
+echo >> mysqlbinlog var/log/master-bin.000020 > var/tmp/bug32580.sql;
+exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000020 > $MYSQLTEST_VARDIR/tmp/bug32580.sql;
echo >> mysql test < var/tmp/bug32580.sql;
exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug32580.sql;
remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql;
@@ -476,6 +489,19 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
#
+# WL#5625: Deprecate mysqlbinlog options --base64-output=always and --base64-output
+#
+--echo # Expect deprecation warning.
+--exec $MYSQL_BINLOG --base64-output=always std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+--cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+
+--echo # Expect deprecation warning again.
+--exec $MYSQL_BINLOG --base64-output std_data/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+--cat_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+
+# Clean up this part of the test.
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
+
# BUG#50914
# This test verifies if the approach of the mysqlbinlog prints
# "use $database" statements to its output stream will cause
@@ -501,3 +527,23 @@ exec $MYSQL_BINLOG $MYSQLD_DATADIR/$master_binlog | $MYSQL test 2>&1;
let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
source include/show_binlog_events.inc;
+#
+# BUG#11766427 BUG#59530: Filter by server id in mysqlbinlog fails
+# This test checks that the format description log event is not
+# filtered out by the --server-id option.
+#
+RESET MASTER;
+USE test;
+CREATE TABLE t1 (a INT);
+--let $old_server_id= `SELECT @@GLOBAL.SERVER_ID`
+SET GLOBAL SERVER_ID = 2;
+DROP TABLE t1;
+--let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
+FLUSH LOGS;
+# The following should only create t1, not drop it.
+--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/$master_binlog | $MYSQL
+SHOW TABLES IN test;
+# The following should only drop t1, not create it.
+--exec $MYSQL_BINLOG --server-id=2 $MYSQLD_DATADIR/$master_binlog | $MYSQL
+SHOW TABLES IN test;
+eval SET GLOBAL SERVER_ID = $old_server_id;
diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test
index d6be029ea56..dcd92262a83 100644
--- a/mysql-test/t/mysqlbinlog2.test
+++ b/mysql-test/t/mysqlbinlog2.test
@@ -21,7 +21,9 @@ create table t1 (a int auto_increment not null primary key, b char(3));
insert into t1 values(null, "a");
insert into t1 values(null, "b");
set timestamp=@a+2;
+--let $binlog_pos_760=query_get_value(SHOW MASTER STATUS, Position, 1)
insert into t1 values(null, "c");
+--let $binlog_pos_951=query_get_value(SHOW BINLOG EVENTS in 'master-bin.000001' from $binlog_pos_760, Pos, 4)
set timestamp=@a+4;
insert into t1 values(null, "d");
insert into t1 values(null, "e");
@@ -29,6 +31,8 @@ insert into t1 values(null, "e");
flush logs;
set timestamp=@a+1; # this could happen on a slave
insert into t1 values(null, "f");
+--let $binlog_pos_135=query_get_value(SHOW BINLOG EVENTS in 'master-bin.000002', Pos, 3)
+--let $binlog_pos_203=query_get_value(SHOW BINLOG EVENTS in 'master-bin.000002', Pos, 4)
# delimiters are for easier debugging in future
@@ -50,15 +54,15 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_pos_760 $MYSQLD_DATADIR/master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLD_DATADIR/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --stop-position=$binlog_pos_760 $MYSQLD_DATADIR/master-bin.000001
--disable_query_log
select "--- start and stop positions ---" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 $MYSQLD_DATADIR/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_pos_760 --stop-position=$binlog_pos_951 $MYSQLD_DATADIR/master-bin.000001
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -84,11 +88,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_pos_760 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=134 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --stop-position=$binlog_pos_203 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -111,15 +115,15 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_pos_760 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--exec $MYSQL_BINLOG --short-form --stop-position=$binlog_pos_760 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- start and stop positions ---" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_pos_760 --stop-position=$binlog_pos_951 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -142,11 +146,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=$binlog_pos_760 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=134 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
+--exec $MYSQL_BINLOG --short-form --stop-position=$binlog_pos_135 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
diff --git a/mysql-test/t/mysqlbinlog_base64.test b/mysql-test/t/mysqlbinlog_base64.test
index fb21e28fdcb..3d3444cea1c 100644
--- a/mysql-test/t/mysqlbinlog_base64.test
+++ b/mysql-test/t/mysqlbinlog_base64.test
@@ -71,3 +71,32 @@ select count(*) from t2;
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
drop table t1;
drop table t2;
+
+#
+# BUG#12354268
+#
+# This test verifies that using --start-position with DECODE-ROWS
+# does not make mysqlbinlog to output an error stating that it
+# does not contain any FD event.
+#
+
+RESET MASTER;
+USE test;
+SET @old_binlog_format= @@binlog_format;
+SET SESSION binlog_format=ROW;
+CREATE TABLE t1(c1 INT);
+--let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
+--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
+--let $MYSQLD_DATADIR= `SELECT @@datadir`
+
+INSERT INTO t1 VALUES (1);
+
+FLUSH LOGS;
+
+--disable_result_log
+--exec $MYSQL_BINLOG --base64-output=DECODE-ROWS --start-position=$master_pos -v $MYSQLD_DATADIR/$master_binlog
+--enable_result_log
+
+DROP TABLE t1;
+SET SESSION binlog_format= @old_binlog_format;
+RESET MASTER;
diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test
index 986b5aba385..8f93ac7b864 100644
--- a/mysql-test/t/mysqlcheck.test
+++ b/mysql-test/t/mysqlcheck.test
@@ -2,6 +2,8 @@
# Embedded server doesn't support external clients
--source include/not_embedded.inc
+--source include/have_innodb.inc
+
# check that CSV engine was compiled in, as the result of the test
# depends on the presence of the log tables (which are CSV-based).
--source include/have_csv.inc
@@ -23,28 +25,33 @@ drop database if exists client_test_db;
# Bug #13783 mysqlcheck tries to optimize and analyze information_schema
#
--replace_result 'Table is already up to date' OK
---exec $MYSQL_CHECK --all-databases --analyze --optimize
+--exec $MYSQL_CHECK --all-databases --analyze
+--exec $MYSQL_CHECK --all-databases --optimize
--replace_result 'Table is already up to date' OK
---exec $MYSQL_CHECK --analyze --optimize --databases test information_schema mysql
---exec $MYSQL_CHECK --analyze --optimize information_schema schemata
+--exec $MYSQL_CHECK --analyze --databases test information_schema mysql
+--exec $MYSQL_CHECK --optimize --databases test information_schema mysql
+--exec $MYSQL_CHECK --analyze information_schema schemata
+--exec $MYSQL_CHECK --optimize information_schema schemata
#
# Bug #16502: mysqlcheck tries to check views
#
-create table t1 (a int);
+create table t1 (a int) engine=myisam;
create view v1 as select * from t1;
--replace_result 'Table is already up to date' OK
---exec $MYSQL_CHECK --analyze --optimize --databases test
+--exec $MYSQL_CHECK --analyze --databases test
+--exec $MYSQL_CHECK --optimize --databases test
--replace_result 'Table is already up to date' OK
---exec $MYSQL_CHECK --all-in-1 --analyze --optimize --databases test
+--exec $MYSQL_CHECK --all-in-1 --analyze --databases test
+--exec $MYSQL_CHECK --all-in-1 --optimize --databases test
drop view v1;
drop table t1;
#
# Bug #30654: mysqlcheck fails during upgrade of tables whose names include backticks
#
-create table `t``1`(a int);
-create table `t 1`(a int);
+create table `t``1`(a int) engine=myisam;
+create table `t 1`(a int) engine=myisam;
--replace_result 'Table is already up to date' OK
--exec $MYSQL_CHECK --databases test
drop table `t``1`, `t 1`;
@@ -54,7 +61,7 @@ drop table `t``1`, `t 1`;
#
create database d_bug25347;
use d_bug25347;
-create table t_bug25347 (a int);
+create table t_bug25347 (a int) engine=myisam;
create view v_bug25347 as select * from t_bug25347;
insert into t_bug25347 values (1),(2),(3);
flush tables;
@@ -86,8 +93,8 @@ drop view v1;
# Bug#37527: mysqlcheck fails to report entire database
# when frm file corruption
#
-CREATE TABLE t1(a INT);
-CREATE TABLE t2(a INT);
+CREATE TABLE t1(a INT) engine=myisam;
+CREATE TABLE t2(a INT) engine=myisam;
# backup then null t1.frm
--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t1.frm.bak
--remove_file $MYSQLD_DATADIR/test/t1.frm
@@ -107,13 +114,14 @@ DROP TABLE t1, t2;
#
# Bug #30679: 5.1 name encoding not performed for views during upgrade
#
-create table t1(a int);
+create table t1(a int) engine=myisam;
create view v1 as select * from t1;
show tables;
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm
show tables;
---exec $MYSQL_CHECK --check-upgrade --fix-table-names --databases test
+--exec $MYSQL_CHECK --check-upgrade --databases test
+--exec $MYSQL_CHECK --fix-table-names --databases test
show tables;
drop view v1, `v-1`;
drop table t1;
@@ -125,7 +133,7 @@ drop table t1;
# triggers
#
SET NAMES utf8;
-CREATE TABLE `#mysql50#@` (a INT);
+CREATE TABLE `#mysql50#@` (a INT) engine=myisam;
SHOW TABLES;
SET NAMES DEFAULT;
--echo mysqlcheck --fix-table-names --databases test
@@ -134,7 +142,7 @@ SET NAMES utf8;
SHOW TABLES;
DROP TABLE `@`;
-CREATE TABLE `Ñ` (a INT);
+CREATE TABLE `Ñ` (a INT) engine=myisam;
SET NAMES DEFAULT;
--echo mysqlcheck --default-character-set="latin1" --databases test
# Error returned depends on platform, replace it with "Table doesn't exist"
@@ -148,8 +156,8 @@ SET NAMES DEFAULT;
CREATE DATABASE `#mysql50#a@b`;
USE `#mysql50#a@b`;
-CREATE TABLE `#mysql50#c@d` (a INT);
-CREATE TABLE t1 (a INT);
+CREATE TABLE `#mysql50#c@d` (a INT) engine=myisam;
+CREATE TABLE t1 (a INT) engine=myisam;
# Create 5.0 like triggers
let $MYSQLTEST_VARDIR= `select @@datadir`;
@@ -178,7 +186,7 @@ SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name;
--echo mysqlcheck --fix-db-names --fix-table-names --all-databases
---exec $MYSQL_CHECK --fix-db-names --fix-table-names --all-databases
+--exec $MYSQL_CHECK --default-character-set=utf8 --fix-db-names --fix-table-names --all-databases
USE `a@b`;
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
@@ -201,14 +209,105 @@ USE test;
drop table if exists `#mysql50#t1-1`;
--enable_warnings
-create table `#mysql50#t1-1` (a int);
+create table `#mysql50#t1-1` (a int) engine=myisam;
--exec $MYSQL_CHECK --all-in-1 --fix-table-names --databases test
show tables like 't1-1';
drop table `t1-1`;
-create table `#mysql50#t1-1` (a int);
+create table `#mysql50#t1-1` (a int) engine=myisam;
--exec $MYSQL_CHECK --all-in-1 --fix-table-names test "#mysql50#t1-1"
show tables like 't1-1';
drop table `t1-1`;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug #35269: mysqlcheck behaves different depending on order of parameters
+--echo #
+
+--error 13
+--exec $MYSQL_CHECK -a --fix-table-names test "#mysql50#t1-1"
+--error 1
+--exec $MYSQL_CHECK -aoc test "#mysql50#t1-1"
+
+
+--echo #
+--echo # Bug#11755431 47205: MAP 'REPAIR TABLE' TO RECREATE +ANALYZE FOR
+--echo # ENGINES NOT SUPPORTING NATIVE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS bug47205;
+--enable_warnings
+
+--echo #
+--echo # Test 1: Check that ALTER TABLE ... rebuilds the table
+
+CREATE TABLE bug47205(a VARCHAR(20) PRIMARY KEY)
+ DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci engine=innodb;
+
+INSERT INTO bug47205 VALUES ("foobar");
+FLUSH TABLE bug47205;
+
+--echo # Replace the FRM with a 5.0 FRM that will require upgrade
+let $MYSQLD_DATADIR= `select @@datadir`;
+--remove_file $MYSQLD_DATADIR/test/bug47205.frm
+--copy_file std_data/bug47205.frm $MYSQLD_DATADIR/test/bug47205.frm
+
+--echo # Should indicate that ALTER TABLE ... FORCE is needed
+CHECK TABLE bug47205 FOR UPGRADE;
+
+--echo # ALTER TABLE ... FORCE should rebuild the table
+--echo # and therefore output "affected rows: 1"
+--enable_info
+ALTER TABLE bug47205 FORCE;
+--disable_info
+
+--echo # Table should now be ok
+CHECK TABLE bug47205 FOR UPGRADE;
+
+DROP TABLE bug47205;
+
+--echo #
+--echo # Test 2: InnoDB - REPAIR not supported
+
+CREATE TABLE bug47205(a VARCHAR(20) PRIMARY KEY)
+ DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci engine=innodb;
+
+FLUSH TABLE bug47205;
+
+--echo # Replace the FRM with a 5.0 FRM that will require upgrade
+let $MYSQLD_DATADIR= `select @@datadir`;
+--remove_file $MYSQLD_DATADIR/test/bug47205.frm
+--copy_file std_data/bug47205.frm $MYSQLD_DATADIR/test/bug47205.frm
+
+--echo # Should indicate that ALTER TABLE .. FORCE is needed
+CHECK TABLE bug47205 FOR UPGRADE;
+
+--echo # Running mysqlcheck to check and upgrade
+--exec $MYSQL_CHECK --check-upgrade --auto-repair test
+
+--echo # Table should now be ok
+CHECK TABLE bug47205 FOR UPGRADE;
+
+DROP TABLE bug47205;
+
+--echo #
+--echo # Test 3: MyISAM - REPAIR supported
+
+--echo # Use an old FRM that will require upgrade
+--copy_file std_data/bug36055.frm $MYSQLD_DATADIR/test/bug47205.frm
+--copy_file std_data/bug36055.MYD $MYSQLD_DATADIR/test/bug47205.MYD
+--copy_file std_data/bug36055.MYI $MYSQLD_DATADIR/test/bug47205.MYI
+
+--echo # Should indicate that REPAIR TABLE is needed
+CHECK TABLE bug47205 FOR UPGRADE;
+
+--echo # Running mysqlcheck to check and upgrade
+--exec $MYSQL_CHECK --check-upgrade --auto-repair test
+
+--echo # Table should now be ok
+CHECK TABLE bug47205 FOR UPGRADE;
+
+DROP TABLE bug47205;
diff --git a/mysql-test/t/mysqld--defaults-file.test b/mysql-test/t/mysqld--defaults-file.test
new file mode 100644
index 00000000000..065436c38aa
--- /dev/null
+++ b/mysql-test/t/mysqld--defaults-file.test
@@ -0,0 +1,47 @@
+# BUG#58455
+# Starting mysqld with defaults file without extension cause
+# segmentation fault
+
+source include/not_embedded.inc;
+source include/not_windows.inc;
+
+# We need to use a plain "mysqld" without any other options to trigger
+# the bug. In particular, it seems that passing --bootstrap does not
+# trigger the bug. To do that, we extract the "command name" from the
+# MYSQLD_BOOTSTRAP_CMD variable and store that in a file, which we
+# then load into the test case.
+
+perl;
+ my ($mysqld)= split " ", $ENV{MYSQLD_BOOTSTRAP_CMD};
+ open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die;
+ print FILE "let \$MYSQLD= $mysqld;\n";
+ close FILE;
+EOF
+
+source $MYSQL_TMP_DIR/mysqld.inc;
+
+# All these tests refer to configuration files that do not exist
+
+--error 1
+exec $MYSQLD --defaults-file=/path/with/no/extension --print-defaults 2>&1;
+
+--error 1
+exec $MYSQLD --defaults-file=/path/with.ext --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=relative/path/with.ext --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=relative/path/without/extension --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1;
+
+remove_file $MYSQL_TMP_DIR/mysqld.inc;
diff --git a/mysql-test/t/mysqld--help-notwin.test b/mysql-test/t/mysqld--help-notwin.test
new file mode 100644
index 00000000000..e3d1ca97128
--- /dev/null
+++ b/mysql-test/t/mysqld--help-notwin.test
@@ -0,0 +1,24 @@
+# Copyright (C) 2009-2010 Sun Microsystems, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# mysqld --help
+#
+--source include/not_embedded.inc
+--source include/not_windows.inc
+--source include/have_perfschema.inc
+
+--source include/mysqld--help.inc
+
diff --git a/mysql-test/t/mysqld--help-win.test b/mysql-test/t/mysqld--help-win.test
new file mode 100644
index 00000000000..56cfec8999b
--- /dev/null
+++ b/mysql-test/t/mysqld--help-win.test
@@ -0,0 +1,24 @@
+# Copyright (C) 2009-2010 Sun Microsystems, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# mysqld --help
+#
+--source include/not_embedded.inc
+--source include/windows.inc
+--source include/have_perfschema.inc
+
+--source include/mysqld--help.inc
+
diff --git a/mysql-test/t/mysqldump-max-master.opt b/mysql-test/t/mysqldump-max-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/mysqldump-max-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index fe0b05dbb42..e224bf6afe3 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -7,6 +7,9 @@
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
+disable_query_log;
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+enable_query_log;
--echo # Bug#37938 Test "mysqldump" lacks various insert statements
--echo # Turn off concurrent inserts to avoid random errors
@@ -46,9 +49,6 @@ DROP TABLE t1;
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999');
-# The following replaces is here because some systems replaces the above
-# double with '-inf' and others with MAX_DOUBLE
---replace_result (-1.79769313486232e+308) (RES) (NULL) (RES)
--exec $MYSQL_DUMP --compact test t1
DROP TABLE t1;
@@ -168,7 +168,7 @@ drop database mysqldump_test_db;
CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments test t1
--echo #
--echo # Bug#8063 make test mysqldump [ fail ]
@@ -178,10 +178,10 @@ INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
--echo # checking that "mysqldump" is compiled with "latin1"
--echo #
-#--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --compatible=mysql323 test t1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --compatible=mysql323 --default-character-set=cp850 test t1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=cp850 --compatible=mysql323 test t1
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 test t1
+#--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --compatible=mysql323 test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --compatible=mysql323 --default-character-set=cp850 test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=cp850 --compatible=mysql323 test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=utf8 --compatible=mysql323 test t1
DROP TABLE t1;
--echo #
@@ -875,8 +875,13 @@ select * from t1;
create view v1 as
select * from v3 where b in (1, 2, 3, 4, 5, 6, 7);
+# Disable warnings since LIMIT warning for unsafe statement if
+# binlog_format = STATEMENT. Note: after BUG#45832, the warning should
+# not be issued.
+--disable_warnings
create view v2 as
select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1;
+--enable_warnings
--exec $MYSQL_DUMP --skip-comments test
@@ -1673,14 +1678,14 @@ drop database db42635;
SET NAMES utf8;
CREATE TABLE `straße` ( f1 INT );
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 test
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=latin1 --compatible=mysql323 test
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=utf8 --compatible=mysql323 test
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=latin1 --compatible=mysql323 test
DROP TABLE `straße`;
CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ( f1 INT );
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 test
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=utf8 --compatible=mysql323 test
--error 2
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=latin1 --compatible=mysql323 test
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=latin1 --compatible=mysql323 test
DROP TABLE `כדשגכחךלדגכחשךדגחכךלדגכ`;
SET NAMES latin1;
@@ -1837,7 +1842,7 @@ set names latin1;
--echo
--echo # Dump mysqldump_test_db to bug30027.sql.
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30027.sql
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=latin1 --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30027.sql
--echo
--echo # Drop mysqldump_test_db.
@@ -1923,7 +1928,7 @@ WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1';
--echo
--echo ---> Dumping mysqldump_test_db to bug30217.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30217.sql
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30217.sql
--echo
@@ -2080,7 +2085,7 @@ INSERT INTO t1 VALUES (1, 'ABC-ÐБВ', 'DEF-ÂÃÄ'), (2, NULL, NULL);
--echo # default '--default-charset' (binary):
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --tab=$MYSQLTEST_VARDIR/tmp/ test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1
--echo ##################################################
--cat_file $file
--echo ##################################################
@@ -2093,7 +2098,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
--echo # utf8:
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=utf8 --tab=$MYSQLTEST_VARDIR/tmp/ test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=utf8 --tab=$MYSQLTEST_VARDIR/tmp/ test t1
--echo ##################################################
--cat_file $file
--echo ##################################################
@@ -2106,7 +2111,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
--echo # latin1 (data corruption is expected):
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=latin1 --tab=$MYSQLTEST_VARDIR/tmp/ test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=latin1 --tab=$MYSQLTEST_VARDIR/tmp/ test t1
--echo ##################################################
--cat_file $file
--echo ##################################################
@@ -2119,7 +2124,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
--echo # koi8r (data corruption is expected):
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --default-character-set=koi8r --tab=$MYSQLTEST_VARDIR/tmp/ test t1
+--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --default-character-set=koi8r --tab=$MYSQLTEST_VARDIR/tmp/ test t1
--echo ##################################################
--cat_file $file
--echo ##################################################
@@ -2174,8 +2179,41 @@ CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE CO
DROP TABLE `comment_table`;
--echo #
+--echo # BUG#11766310 : 59398: MYSQLDUMP 5.1 CAN'T HANDLE A DASH ("-") IN
+--echo # DATABASE NAMES IN ALTER DATABASE
+--echo #
+
+CREATE DATABASE `test-database`;
+USE `test-database`;
+CREATE TABLE `test` (`c1` VARCHAR(10)) ENGINE=MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DELIMITER |;
+CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
+END |
+DELIMITER ;|
+
+ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci;
+ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+
+--exec $MYSQL_DUMP --quote-names --compact test-database
+
+DROP DATABASE `test-database`;
+# Switching back to test database.
+USE test;
+
+--echo #
--echo # End of 5.1 tests
--echo #
+--echo #
+--echo # Verify that two modes can be given in --compatible;
+--echo # and are reflected in SET SQL_MODE in the mysqldump output.
+--echo # Also verify that a prefix of the mode's name is enough.
+--echo #
+CREATE TABLE t1 (a INT);
+# no_t = no_table_options; no_f = no_field_options
+--exec $MYSQL_DUMP --compatible=no_t,no_f --skip-comments test
+DROP TABLE t1;
+
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/mysqlshow.test b/mysql-test/t/mysqlshow.test
index 9ed93079f57..515e2bcf325 100644
--- a/mysql-test/t/mysqlshow.test
+++ b/mysql-test/t/mysqlshow.test
@@ -1,5 +1,9 @@
# Can't run test of external client with embedded server
-- source include/not_embedded.inc
+# Test lists tables in Information_schema, and InnoDB adds some
+-- source include/have_innodb.inc
+# Don't test when thread_pool active
+--source include/not_threadpool.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,test1,test2;
diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test
index 28042f62fe6..757d2813483 100644
--- a/mysql-test/t/mysqlslap.test
+++ b/mysql-test/t/mysqlslap.test
@@ -53,3 +53,18 @@ CREATE PROCEDURE p1() SELECT 1;
--exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1
DROP PROCEDURE p1;
+
+
+--echo #
+--echo # Bug #11765157 - 58090: mysqlslap drops schema specified in
+--echo # create_schema if auto-generate-sql also set.
+--echo #
+
+--exec $MYSQL_SLAP --silent --create-schema=bug58090 --concurrency=5 --iterations=20 --auto-generate-sql
+--echo # 'bug58090' database should not be present.
+SHOW DATABASES;
+--exec $MYSQL_SLAP --silent --create-schema=bug58090 --no-drop --auto-generate-sql
+--echo # 'bug58090' database should be present.
+SHOW DATABASES;
+DROP DATABASE bug58090;
+
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 52dfd8e86d3..9ff92496653 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -1019,16 +1019,13 @@ EOF
# ----------------------------------------------------------------------------
# Test inc
# ----------------------------------------------------------------------------
-inc $i;
-echo $i;
+let $i= 0;
inc $i;
echo $i;
let $i=100;
inc $i;
echo $i;
-
-let $i=hej;
-echo $i;
+let $i= -100;
inc $i;
echo $i;
@@ -1037,7 +1034,13 @@ echo $i;
--error 1
--exec echo "inc i;" | $MYSQL_TEST 2>&1
--error 1
+--exec echo "inc \$i;" | $MYSQL_TEST 2>&1
+--error 1
--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=text; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=10cc; inc \$i; echo \$i;" | $MYSQL_TEST 2>&1
inc $i; inc $i; inc $i; --echo $i
echo $i;
@@ -1047,25 +1050,25 @@ echo $i;
# Test dec
# ----------------------------------------------------------------------------
-dec $d;
-echo $d;
+let $d= 0;
dec $d;
echo $d;
let $d=100;
dec $d;
echo $d;
-let $d=hej;
-echo $d;
-dec $d;
-echo $d;
-
--error 1
--exec echo "dec;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "dec i;" | $MYSQL_TEST 2>&1
--error 1
+--exec echo "dec \$i;" | $MYSQL_TEST 2>&1
+--error 1
--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=text; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "let \$i=10cc; dec \$i; echo \$i;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
@@ -1182,10 +1185,11 @@ if ($counter)
{
echo oops, -0 is true;
}
-if (beta)
-{
- echo Beta is true;
-}
+# This is no longer allowed, as a precaution against mistyped conditionals
+# if (beta)
+# {
+# echo Beta is true;
+# }
let $counter=gamma;
while ($counter)
{
@@ -1194,6 +1198,196 @@ while ($counter)
}
# ----------------------------------------------------------------------------
+# Test if with compare conditions
+# ----------------------------------------------------------------------------
+
+let $ifvar= 5;
+let $ifvar2= 6;
+
+if ($ifvar < 7)
+{
+ echo 5<7;
+}
+if ($ifvar< 7)
+{
+ echo 5<7 again;
+}
+if ($ifvar<7)
+{
+ echo 5<7 still;
+}
+if ($ifvar < $ifvar2)
+{
+ echo 5<6;
+}
+if ($ifvar <= 4)
+{
+ echo 5<=4;
+}
+if ($ifvar >= 5)
+{
+ echo 5>=5;
+}
+if ($ifvar>=5)
+{
+ echo 5>=5 again;
+}
+if ($ifvar > 3)
+{
+ echo 5>3;
+}
+if ($ifvar == 4)
+{
+ echo 5==4;
+}
+if ($ifvar == 5)
+{
+ echo 5==5;
+}
+if ($ifvar != 8)
+{
+ echo 5!=8;
+}
+# Any number should compare unequal to any string
+if ($ifvar != five)
+{
+ echo 5!=five;
+}
+if ($ifvar == `SELECT 3+2`)
+{
+ echo 5==3+2;
+}
+if ($ifvar == 5)
+{
+ echo 5 == 5;
+}
+let $ifvar= hello;
+if ($ifvar == hello there)
+{
+ echo hello == hello there;
+}
+if ($ifvar == hello)
+{
+ echo hello == hello;
+}
+if ($ifvar == hell)
+{
+ echo hello == hell;
+}
+if ($ifvar == hello)
+{
+ echo hello == hello;
+}
+if ($ifvar != goodbye)
+{
+ echo hello != goodbye;
+}
+let $ifvar= 'quoted';
+if ($ifvar == ''quoted'')
+{
+ echo 'quoted' == ''quoted'';
+}
+let $ifvar= two words;
+if ($ifvar == two words)
+{
+ echo two words;
+}
+if ($ifvar == 'two words')
+{
+ echo 'two words';
+}
+if ($ifvar == "two words")
+{
+ echo "two words";
+}
+if ($ifvar == `SELECT 'two words'`)
+{
+ echo two words are two words;
+}
+if (42)
+{
+ echo right answer;
+}
+if (0)
+{
+ echo wrong answer;
+}
+# Non-empty string treated as 'true'
+if (`SELECT 'something'`)
+{
+ echo anything goes;
+}
+# Make sure 0 and string compare right
+let $ifvar= 0;
+if ($ifvar == string)
+{
+ echo 0 == string;
+}
+if ($ifvar != string)
+{
+ echo 0 != string;
+}
+--write_file $MYSQL_TMP_DIR/mysqltest.sql
+let $var= 5;
+if ($var >= four)
+{
+ echo 5>=four;
+}
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
+remove_file $MYSQL_TMP_DIR/mysqltest.sql;
+
+--write_file $MYSQL_TMP_DIR/mysqltest.sql
+let $var= 5;
+if ($var ~= 6)
+{
+ echo 5~=6;
+}
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
+remove_file $MYSQL_TMP_DIR/mysqltest.sql;
+
+--write_file $MYSQL_TMP_DIR/mysqltest.sql
+let $var= text;
+if (var == text)
+{
+ echo Oops I forgot the $;
+}
+EOF
+--error 1
+--exec $MYSQL_TEST < $MYSQL_TMP_DIR/mysqltest.sql 2>&1
+remove_file $MYSQL_TMP_DIR/mysqltest.sql;
+
+--error 1
+--exec echo "if (\$var ==) {" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "if (\$var > ) {" | $MYSQL_TEST 2>&1
+
+# ----------------------------------------------------------------------------
+# Test while with compare conditions
+# ----------------------------------------------------------------------------
+
+let $counter= 2;
+
+while ($counter < 5)
+{
+ echo counter is $counter;
+ inc $counter;
+}
+let $ifvar=;
+while ($ifvar != stop)
+{
+ if ($counter >= 7)
+ {
+ let $ifvar= stop;
+ }
+ echo counter is $counter;
+ inc $counter;
+}
+
+# ----------------------------------------------------------------------------
# Test while, { and }
# ----------------------------------------------------------------------------
@@ -2458,15 +2652,15 @@ let $count= 0;
while ($run)
{
let $Field= query_get_value($show_statement, Field, $rowno);
- if (`SELECT '$Field' = 'No such row'`)
+ if ($Field == No such row)
{
let $run= 0;
}
- if (`SELECT '$Field' <> 'No such row'`)
+ if ($Field != No such row)
{
let $Type= query_get_value($show_statement, Type, $rowno);
let $Null= query_get_value($show_statement, Null, $rowno);
- if (`SELECT '$Null' = 'YES'`)
+ if ($Null == YES)
{
inc $count;
}
@@ -2551,26 +2745,6 @@ rmdir $MYSQLTEST_VARDIR/tmp/testdir;
--replace_result c:\\a.txt z
SELECT 'c:\\a.txt' AS col;
-#
-# Bug#32307 mysqltest - does not detect illegal if syntax
-#
-
-let $test= 1;
-if ($test){
- echo hej;
-}
-
---write_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql
-if ($mysql_errno != 1436)
-{
- echo ^ Should not be allowed!
-}
-EOF
---error 1
---exec $MYSQL_TEST < $MYSQLTEST_VARDIR/tmp/mysqltest.sql 2>&1
-remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
-
-
# ----------------------------------------------------------------------------
# Test that -- is not allowed as comment, only as mysqltest builtin command
# ----------------------------------------------------------------------------
diff --git a/mysql-test/t/named_pipe.test b/mysql-test/t/named_pipe.test
index e88fd8e1ef8..23a11d61222 100644
--- a/mysql-test/t/named_pipe.test
+++ b/mysql-test/t/named_pipe.test
@@ -3,9 +3,12 @@
# other platforms
--source include/windows.inc
+# thread pool causes different results
+-- source include/not_threadpool.inc
+
# Only run this test if named pipe is avaliable
let $nmp= query_get_value("SHOW VARIABLES LIKE 'named_pipe'", Value, 1);
-if (`SELECT '$nmp' != 'ON'`){
+if ($nmp != ON){
skip No named pipe support;
}
diff --git a/mysql-test/t/no-threads.test b/mysql-test/t/no-threads.test
index fd8365e5678..c2b326897f8 100644
--- a/mysql-test/t/no-threads.test
+++ b/mysql-test/t/no-threads.test
@@ -1,3 +1,4 @@
+--source include/not_threadpool.inc
#
# Test the --thread-handler=no-threads option
#
diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test
index 43cdb977386..5b99c37ee29 100644
--- a/mysql-test/t/not_embedded_server.test
+++ b/mysql-test/t/not_embedded_server.test
@@ -4,37 +4,9 @@
-- source include/not_embedded.inc
-#
-# Produce output
-#
+# End of 4.1 tests
-select 1;
-
-# The following fails sporadically because 'check-testcase' runs
-# queries before this test and there is no way to guarantee that any
-# previous process finishes. The purpose of the test is not clearly
-# stated, there is no reference to any bug report, and "select from
-# I_S from prepared statement" doesn't look like something that's
-# really imporant to test. I'm commenting out this for now. If
-# anyone wants to keep this, please fix the race and motivate why we
-# need to test this. If you see this comment and it is after mid-2009
-# or so, feel free to remove this test from the file. /Sven
-#
-#
-## Show full process list with prepare
-## To not show other connections, this must be the first test and we must
-## have a server restart before this one
-##
-## We don't have any 4.1 tests as we use I_S to query the PROCESSLIST to
-## exclude system threads that may/may not be active in the server
-## (namely the ndb injector thread)
-##
-## End of 4.1 tests
-#
-#prepare stmt1 from ' SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND!=\'Daemon\' ';
-#--replace_column 1 number 6 time 3 localhost
-#execute stmt1;
-#deallocate prepare stmt1;
+call mtr.add_suppression("Can't open and lock privilege tables: Table 'host' was not locked with LOCK TABLES");
#
# Bug#43835: SHOW VARIABLES does not include 0 for slave_skip_errors
@@ -53,3 +25,82 @@ SELECT '1' RLIKE RPAD('1', 10000, '(');
# End of 5.1 tests
+
+--echo #
+--echo # WL#4284: Transactional DDL locking
+--echo #
+--echo # FLUSH PRIVILEGES should not implicitly unlock locked tables.
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (c1 INT);
+LOCK TABLES t1 READ;
+--error ER_TABLE_NOT_LOCKED
+FLUSH PRIVILEGES;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#54812: assert in Diagnostics_area::set_ok_status during EXPLAIN
+--echo #
+
+CREATE USER nopriv_user@localhost;
+
+connection default;
+--echo connection: default
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+DROP FUNCTION IF EXISTS f;
+--enable_warnings
+
+CREATE TABLE t1 (key1 INT PRIMARY KEY);
+CREATE TABLE t2 (key2 INT);
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE FUNCTION f() RETURNS INT RETURN 1;
+
+GRANT FILE ON *.* TO 'nopriv_user'@'localhost';
+
+FLUSH PRIVILEGES;
+
+connect (con1,localhost,nopriv_user,,);
+connection con1;
+--echo connection: con1
+
+let outfile=$MYSQLTEST_VARDIR/tmp/mytest;
+--error 0,1
+--remove_file $outfile
+--replace_result $outfile <outfile>
+--error ER_PROCACCESS_DENIED_ERROR
+eval SELECT MAX(key1) FROM t1 WHERE f() < 1 INTO OUTFILE '$outfile';
+# A removal of the outfile is necessary, at least today (2010-12-07), because
+# the outfile is created even if the SELECT statement fails.
+# If the server is improved in the future this may not happen.
+# ==> Do not fail if the outfile does not exist.
+--error 0,1
+--remove_file $outfile
+
+--error ER_PROCACCESS_DENIED_ERROR
+INSERT INTO t2 SELECT MAX(key1) FROM t1 WHERE f() < 1;
+
+--error ER_PROCACCESS_DENIED_ERROR
+SELECT MAX(key1) INTO @dummy FROM t1 WHERE f() < 1;
+
+--error ER_PROCACCESS_DENIED_ERROR
+CREATE TABLE t3 (i INT) AS SELECT MAX(key1) FROM t1 WHERE f() < 1;
+
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+connection default;
+--echo connection: default
+
+DROP TABLE t1,t2;
+DROP FUNCTION f;
+DROP USER nopriv_user@localhost;
+
+--echo #
+--echo # End Bug#54812
+--echo #
diff --git a/mysql-test/t/not_partition.test b/mysql-test/t/not_partition.test
index 78ca44acf18..38b88c00ba3 100644
--- a/mysql-test/t/not_partition.test
+++ b/mysql-test/t/not_partition.test
@@ -27,6 +27,7 @@ ALTER TABLE t1 CHECK PARTITION ALL;
ALTER TABLE t1 OPTIMIZE PARTITION ALL;
ALTER TABLE t1 ANALYZE PARTITION ALL;
ALTER TABLE t1 REBUILD PARTITION ALL;
+ALTER TABLE t1 TRUNCATE PARTITION ALL;
ALTER TABLE t1 ENGINE Memory;
ALTER TABLE t1 ADD (new INT);
DROP TABLE t1;
diff --git a/mysql-test/t/odbc.test b/mysql-test/t/odbc.test
index 6a754bb32a7..f1d60e15bc8 100644
--- a/mysql-test/t/odbc.test
+++ b/mysql-test/t/odbc.test
@@ -3,6 +3,8 @@
drop table if exists t1;
--enable_warnings
+set @@session.sql_auto_is_null=1;
+
#
# Test some ODBC compatibility
#
@@ -32,3 +34,5 @@ SELECT sql_no_cache a, last_insert_id() FROM t1;
DROP TABLE t1;
# End of 4.1 tests
+
+set @@session.sql_auto_is_null=default;
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index 8ca70258bc0..4b16f9ba699 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -1,7 +1,7 @@
# Tests for SSL connections, only run if mysqld is compiled
# with support for SSL.
---source include/have_ssl.inc
+-- source include/have_ssl_communication.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown1-master.opt b/mysql-test/t/optimizer_switch_eng_cond_pushdown1-master.opt
new file mode 100644
index 00000000000..89aa07976ac
--- /dev/null
+++ b/mysql-test/t/optimizer_switch_eng_cond_pushdown1-master.opt
@@ -0,0 +1 @@
+--optimizer-switch=engine_condition_pushdown=off --engine-condition-pushdown=1
diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown1.test b/mysql-test/t/optimizer_switch_eng_cond_pushdown1.test
new file mode 100644
index 00000000000..187aa145408
--- /dev/null
+++ b/mysql-test/t/optimizer_switch_eng_cond_pushdown1.test
@@ -0,0 +1,5 @@
+# check how --engine-condition-pushdown and --optimizer-switch
+# influence each other when used together (last wins).
+select @@session.engine_condition_pushdown,
+@@global.engine_condition_pushdown,
+@@session.optimizer_switch, @@global.optimizer_switch;
diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown2-master.opt b/mysql-test/t/optimizer_switch_eng_cond_pushdown2-master.opt
new file mode 100644
index 00000000000..f48ab5b963b
--- /dev/null
+++ b/mysql-test/t/optimizer_switch_eng_cond_pushdown2-master.opt
@@ -0,0 +1 @@
+--engine-condition-pushdown=1 --optimizer-switch=engine_condition_pushdown=off
diff --git a/mysql-test/t/optimizer_switch_eng_cond_pushdown2.test b/mysql-test/t/optimizer_switch_eng_cond_pushdown2.test
new file mode 100644
index 00000000000..187aa145408
--- /dev/null
+++ b/mysql-test/t/optimizer_switch_eng_cond_pushdown2.test
@@ -0,0 +1,5 @@
+# check how --engine-condition-pushdown and --optimizer-switch
+# influence each other when used together (last wins).
+select @@session.engine_condition_pushdown,
+@@global.engine_condition_pushdown,
+@@session.optimizer_switch, @@global.optimizer_switch;
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index a8a6ad00648..726dfa154b8 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -843,11 +843,11 @@ create table t1(a int, b tinytext);
insert into t1 values (1,2),(3,2);
set session sort_buffer_size= 30000;
set session max_sort_length= 2180;
---error 1038
+CALL mtr.add_suppression("Out of sort memory");
+--error ER_OUT_OF_SORTMEMORY
select * from t1 order by b;
drop table t1;
-
-
+call mtr.add_suppression("Out of sort memory; increase server sort buffer size");
--echo #
--echo # Bug #39844: Query Crash Mysql Server 5.0.67
--echo #
@@ -1492,4 +1492,45 @@ LIMIT 2;
DROP TABLE t1, t2;
+--echo #
+--echo # Bug #59110: Memory leak of QUICK_SELECT_I allocated memory
+--echo # and
+--echo # Bug #59308: Incorrect result for
+--echo SELECT DISTINCT <col>... ORDER BY <col> DESC
+--echo
+--echo # Use Valgrind to detect #59110!
+--echo #
+
+CREATE TABLE t1 (a INT,KEY (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+EXPLAIN SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+SELECT DISTINCT a,1 FROM t1 WHERE a <> 1 ORDER BY a DESC;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug #38745: MySQL 5.1 optimizer uses filesort for ORDER BY
+--echo # when it should use index
+--echo #
+
+CREATE TABLE t1 (i1 integer NOT NULL PRIMARY KEY);
+CREATE TABLE t2 (i2 integer NOT NULL PRIMARY KEY);
+CREATE TABLE t3 (i3 integer);
+
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12);
+INSERT INTO t2 SELECT * FROM t1;
+
+EXPLAIN EXTENDED
+SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2
+ LEFT JOIN t3 ON t2.i2 = t3.i3
+ ORDER BY t1.i1 LIMIT 5;
+
+SELECT t1.*, t2.* FROM t1 JOIN t2 ON t1.i1 = t2.i2
+ LEFT JOIN t3 ON t2.i2 = t3.i3
+ ORDER BY t1.i1 LIMIT 5;
+
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/t/order_fill_sortbuf-master.opt b/mysql-test/t/order_fill_sortbuf-master.opt
index 9aa3cc76221..7b6ade99226 100644
--- a/mysql-test/t/order_fill_sortbuf-master.opt
+++ b/mysql-test/t/order_fill_sortbuf-master.opt
@@ -1 +1 @@
---set-variable=sort_buffer=32804
+--sort_buffer=32804
diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test
index 45b13f141f7..9f2fc22da99 100644
--- a/mysql-test/t/outfile.test
+++ b/mysql-test/t/outfile.test
@@ -109,7 +109,7 @@ create user user_1@localhost;
grant all on mysqltest.* to user_1@localhost;
connect (con28181_1,localhost,user_1,,mysqltest);
---error ER_DBACCESS_DENIED_ERROR
+--error ER_ACCESS_DENIED_ERROR
eval select schema_name
into outfile "../../tmp/outfile-test.4"
fields terminated by ',' optionally enclosed by '"'
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index e579e371184..d477843b22b 100644
--- a/mysql-test/t/parser.test
+++ b/mysql-test/t/parser.test
@@ -646,6 +646,10 @@ select conv(255 AS p1, 10 AS p2, 16 AS p3);
# Native function with a variable number of arguments
+# Bug in libm.so on Solaris:
+# atan(10) from 32-bit version returns 1.4711276743037347
+# atan(10) from 64-bit version returns 1.4711276743037345
+--replace_result 1.4711276743037345 1.4711276743037347
select atan(10);
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS p1);
@@ -728,3 +732,4 @@ DROP TABLE t1, t2, t3;
--echo #
--echo # End of 5.1 tests
--echo #
+
diff --git a/mysql-test/t/parser_not_embedded.test b/mysql-test/t/parser_not_embedded.test
index 8ebeb9a8301..22e9ae5a140 100644
--- a/mysql-test/t/parser_not_embedded.test
+++ b/mysql-test/t/parser_not_embedded.test
@@ -24,3 +24,78 @@ EOF
--exec $MYSQL --comment --force --table test <$MYSQLTEST_VARDIR/tmp/bug39559.sql
--remove_file $MYSQLTEST_VARDIR/tmp/bug39559.sql
+--echo # Bug#46527 "COMMIT AND CHAIN RELEASE does not make sense"
+--echo #
+--error ER_PARSE_ERROR
+COMMIT AND CHAIN RELEASE;
+
+COMMIT AND NO CHAIN RELEASE;
+disconnect default;
+connect(default, localhost, root,,);
+
+COMMIT RELEASE;
+disconnect default;
+connect(default, localhost, root,,);
+
+--error ER_PARSE_ERROR
+COMMIT CHAIN RELEASE;
+
+--error ER_PARSE_ERROR
+COMMIT NO CHAIN RELEASE;
+
+--error ER_PARSE_ERROR
+COMMIT AND NO RELEASE;
+--error ER_PARSE_ERROR
+COMMIT AND RELEASE;
+
+COMMIT NO RELEASE;
+--error ER_PARSE_ERROR
+COMMIT CHAIN NO RELEASE;
+--error ER_PARSE_ERROR
+COMMIT NO CHAIN NO RELEASE;
+
+--error ER_PARSE_ERROR
+COMMIT AND RELEASE CHAIN;
+
+COMMIT AND NO CHAIN NO RELEASE;
+
+--error ER_PARSE_ERROR
+ROLLBACK AND CHAIN RELEASE;
+
+ROLLBACK AND NO CHAIN RELEASE;
+disconnect default;
+connect(default, localhost, root,,);
+
+ROLLBACK RELEASE;
+disconnect default;
+connect(default, localhost, root,,);
+
+--error ER_PARSE_ERROR
+ROLLBACK CHAIN RELEASE;
+
+--error ER_PARSE_ERROR
+ROLLBACK NO CHAIN RELEASE;
+disconnect default;
+connect(default, localhost, root,,);
+
+--error ER_PARSE_ERROR
+ROLLBACK AND NO RELEASE;
+
+--error ER_PARSE_ERROR
+ROLLBACK AND RELEASE;
+
+ROLLBACK NO RELEASE;
+
+--error ER_PARSE_ERROR
+ROLLBACK CHAIN NO RELEASE;
+
+--error ER_PARSE_ERROR
+ROLLBACK NO CHAIN NO RELEASE;
+--error ER_PARSE_ERROR
+ROLLBACK AND RELEASE CHAIN;
+
+ROLLBACK AND NO CHAIN NO RELEASE;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/parser_stack.test b/mysql-test/t/parser_stack.test
index 3330ef41833..bdcad5aa1b4 100644
--- a/mysql-test/t/parser_stack.test
+++ b/mysql-test/t/parser_stack.test
@@ -399,4 +399,12 @@ delimiter ;$$
drop procedure p_37228;
+#
+# Bug#27863 (excessive memory usage for many small queries in a multiquery
+# packet).
+#
+let $i=`select repeat("set @a=1;", 65535)`;
+--disable_query_log
+eval $i;
+--enable_query_log
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 0630dd31714..2a8ba15d3f1 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -15,6 +15,98 @@ drop table if exists t1, t2;
--enable_warnings
--echo #
+--echo # Bug#11765667: bug#58655: ASSERTION FAILED,
+--echo # SERVER CRASHES WITH MYSQLD GOT SIGNAL 6
+--echo #
+CREATE TABLE t1 (
+ id MEDIUMINT NOT NULL AUTO_INCREMENT,
+ dt DATE, st VARCHAR(255), uid INT,
+ id2nd LONGBLOB, filler VARCHAR(255), PRIMARY KEY(id, dt)
+);
+INSERT INTO t1 (dt, st, uid, id2nd, filler) VALUES
+ ('1991-03-14', 'Initial Insert', 200, 1234567, 'No Data'),
+ ('1991-02-26', 'Initial Insert', 201, 1234567, 'No Data'),
+ ('1992-03-16', 'Initial Insert', 234, 1234567, 'No Data'),
+ ('1992-07-02', 'Initial Insert', 287, 1234567, 'No Data'),
+ ('1991-05-26', 'Initial Insert', 256, 1234567, 'No Data'),
+ ('1991-04-25', 'Initial Insert', 222, 1234567, 'No Data'),
+ ('1993-03-12', 'Initial Insert', 267, 1234567, 'No Data'),
+ ('1993-03-14', 'Initial Insert', 291, 1234567, 'No Data'),
+ ('1991-12-20', 'Initial Insert', 298, 1234567, 'No Data'),
+ ('1994-10-31', 'Initial Insert', 220, 1234567, 'No Data');
+ALTER TABLE t1 PARTITION BY LIST (YEAR(dt)) (
+ PARTITION d1 VALUES IN (1991, 1994),
+ PARTITION d2 VALUES IN (1993),
+ PARTITION d3 VALUES IN (1992, 1995, 1996)
+);
+INSERT INTO t1 (dt, st, uid, id2nd, filler) VALUES
+ ('1991-07-14', 'After Partitioning Insert', 299, 1234567, 'Insert row');
+UPDATE t1 SET filler='Updating the row' WHERE uid=298;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#59297: Can't find record in 'tablename' on update inner join
+--echo #
+
+CREATE TABLE t1 (
+a char(2) NOT NULL,
+b char(2) NOT NULL,
+c int(10) unsigned NOT NULL,
+d varchar(255) DEFAULT NULL,
+e varchar(1000) DEFAULT NULL,
+PRIMARY KEY (a, b, c),
+KEY (a),
+KEY (a, b)
+)
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 20 */;
+
+INSERT INTO t1 (a, b, c, d, e) VALUES
+('07', '03', 343, '1', '07_03_343'),
+('01', '04', 343, '2', '01_04_343'),
+('01', '06', 343, '3', '01_06_343'),
+('01', '07', 343, '4', '01_07_343'),
+('01', '08', 343, '5', '01_08_343'),
+('01', '09', 343, '6', '01_09_343'),
+('03', '03', 343, '7', '03_03_343'),
+('03', '06', 343, '8', '03_06_343'),
+('03', '07', 343, '9', '03_07_343'),
+('04', '03', 343, '10', '04_03_343'),
+('04', '06', 343, '11', '04_06_343'),
+('05', '03', 343, '12', '05_03_343'),
+('11', '03', 343, '13', '11_03_343'),
+('11', '04', 343, '14', '11_04_343')
+;
+
+UPDATE t1 AS A,
+(SELECT '03' AS a, '06' AS b, 343 AS c, 'last' AS d) AS B
+SET A.e = B.d
+WHERE A.a = '03'
+AND A.b = '06'
+AND A.c = 343;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#57778: failed primary key add to partitioned innodb table
+--echo # inconsistent and crashes
+--echo #
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL)
+PARTITION BY KEY (a) PARTITIONS 2;
+INSERT INTO t1 VALUES (0,1), (0,2);
+--error ER_DUP_ENTRY
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+UPDATE t1 SET a = 1, b = 1 WHERE a = 0 AND b = 2;
+ALTER TABLE t1 ADD PRIMARY KEY (a);
+SELECT * FROM t1;
+ALTER TABLE t1 DROP PRIMARY KEY;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
--echo # Bug#57113: ha_partition::extra(ha_extra_function):
--echo # Assertion `m_extra_cache' failed
CREATE TABLE t1
@@ -63,6 +155,29 @@ INSERT INTO t2 VALUES (3,8601,'John S');
UPDATE t1, t2 SET t2.name = 'John Smith' WHERE t1.user_num = t2.user_num;
DROP TABLE t1, t2;
+
+--echo # Bug#39338: Fieldnames in
+--echo # INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION become unescaped
+--echo # NOTE: the partition expression is saved as a string, so changing from
+--echo # normal quotes to ansi quotes does not change the expression, only
+--echo # for partition by KEY.
+CREATE TABLE t1 (
+ ID int(11) NOT NULL,
+ `aaaa,aaaaa` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
+ ddddddddd int(11) NOT NULL DEFAULT '0',
+ new_field0 varchar(50),
+ PRIMARY KEY(ID, `aaaa,aaaaa`, ddddddddd))
+PARTITION BY RANGE(ID)
+PARTITIONS 3
+SUBPARTITION BY LINEAR KEY(ID,`aaaa,aaaaa`)
+SUBPARTITIONS 2 (
+ PARTITION p01 VALUES LESS THAN(100),
+ PARTITION p11 VALUES LESS THAN(200),
+ PARTITION p21 VALUES LESS THAN MAXVALUE);
+SELECT PARTITION_EXPRESSION, SUBPARTITION_EXPRESSION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
+show create table t1;
+drop table t1;
+
#
# Bug#48276: can't add column if subpartition exists
CREATE TABLE t1 (a INT, b INT)
@@ -150,6 +265,19 @@ show indexes from t1;
drop table t1;
#
+# Bug#40181: hang if create index
+#
+create table t1 (a int)
+partition by hash (a);
+create index i on t1 (a);
+insert into t1 values (1);
+insert into t1 select * from t1;
+--error ER_DUP_KEYNAME
+create index i on t1 (a);
+create index i2 on t1 (a);
+drop table t1;
+
+#
# Bug#36001: Partitions: spelling and using some error messages
#
--error ER_FOREIGN_KEY_ON_PARTITIONED
@@ -173,6 +301,29 @@ SELECT * FROM t1 WHERE pk < 0 ORDER BY pk;
DROP TABLE t1;
#
+# Bug#35765: ALTER TABLE produces wrong error when non-existent storage engine
+# used
+CREATE TABLE t1 (a INT)
+ENGINE=NonExistentEngine;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT)
+ENGINE=NonExistentEngine
+PARTITION BY HASH (a);
+DROP TABLE t1;
+CREATE TABLE t1 (a INT)
+ENGINE=Memory;
+ALTER TABLE t1 ENGINE=NonExistentEngine;
+# OK to only specify one partitions engine, since it is already assigned at
+# table level (after create, it is specified on all levels and all parts).
+ALTER TABLE t1
+PARTITION BY HASH (a)
+(PARTITION p0 ENGINE=Memory,
+ PARTITION p1 ENGINE=NonExistentEngine);
+ALTER TABLE t1 ENGINE=NonExistentEngine;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
# Bug#40494: Crash MYSQL server crashes on range access with partitioning
# and order by
#
@@ -427,12 +578,12 @@ drop table t1;
#
# BUG 16002: Handle unsigned integer functions properly
#
---error ER_PARSE_ERROR
+--error ER_VALUES_IS_NOT_INT_TYPE_ERROR
create table t1 (a bigint)
partition by range (a)
(partition p0 values less than (0xFFFFFFFFFFFFFFFF),
partition p1 values less than (10));
---error ER_PARSE_ERROR
+--error ER_VALUES_IS_NOT_INT_TYPE_ERROR
create table t1 (a bigint)
partition by list (a)
(partition p0 values in (0xFFFFFFFFFFFFFFFF),
@@ -1465,7 +1616,7 @@ PARTITION BY LIST (a)
SHOW CREATE TABLE t1;
DROP TABLE t1;
---error ER_PARSE_ERROR
+--error ER_NULL_IN_VALUES_LESS_THAN
CREATE TABLE t1 (a int)
PARTITION BY RANGE(a)
(PARTITION p0 VALUES LESS THAN (NULL));
@@ -2118,23 +2269,68 @@ SELECT COUNT(*) FROM t1;
DROP TABLE t1;
SET SESSION SQL_MODE=DEFAULT;
+# This testcase is commented due to the Bug #46853
+# Should be uncommented after fixing Bug #46853
+#--echo #
+#--echo # BUG#45816 - assertion failure with index containing double
+#--echo # column on partitioned table
+#--echo #
+#
+#CREATE TABLE t1 (
+# a INT DEFAULT NULL,
+# b DOUBLE DEFAULT NULL,
+# c INT DEFAULT NULL,
+# KEY idx2(b,a)
+#) PARTITION BY HASH(c) PARTITIONS 3;
+#
+#INSERT INTO t1 VALUES (6,8,9);
+#INSERT INTO t1 VALUES (6,8,10);
+#
+#SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
+#
+#DROP TABLE t1;
--echo #
---echo # BUG#45816 - assertion failure with index containing double
---echo # column on partitioned table
+--echo # Bug#46198: Hang after failed ALTER TABLE on partitioned table.
--echo #
-CREATE TABLE t1 (
- a INT DEFAULT NULL,
- b DOUBLE DEFAULT NULL,
- c INT DEFAULT NULL,
- KEY idx2(b,a)
-) PARTITION BY HASH(c) PARTITIONS 3;
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
-INSERT INTO t1 VALUES (6,8,9);
-INSERT INTO t1 VALUES (6,8,10);
+#
+# Case 1.
+#
+
+CREATE TABLE t1 (s1 INT PRIMARY KEY) PARTITION BY HASH(s1);
-SELECT 1 FROM t1 JOIN t1 AS t2 USING (a) FOR UPDATE;
+LOCK TABLES t1 WRITE, t1 b READ;
+
+UNLOCK TABLES;
+
+--error ER_ONLY_ON_RANGE_LIST_PARTITION
+ALTER TABLE t1 DROP PARTITION p1;
+
+# The SELECT below used to hang in tdc_wait_for_old_versions().
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+#
+# Case 2.
+#
+
+CREATE TABLE t1 (s1 VARCHAR(5) PRIMARY KEY) PARTITION BY KEY(s1);
+
+LOCK TABLES t1 WRITE, t1 b READ;
+
+UNLOCK TABLES;
+
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+ALTER TABLE t1 ADD COLUMN (s3 VARCHAR(5) UNIQUE);
+
+# The SELECT below used to hang in tdc_wait_for_old_versions().
+SELECT * FROM t1;
DROP TABLE t1;
@@ -2151,3 +2347,53 @@ DROP TABLE t1;
SET GLOBAL myisam_use_mmap=default;
--echo End of 5.1 tests
+
+--echo #
+--echo # BUG#55385: UPDATE statement throws an error, but still updates
+--echo # the table entries
+
+CREATE TABLE t1_part (
+ partkey int,
+ nokey int
+) PARTITION BY LINEAR HASH(partkey) PARTITIONS 3;
+
+INSERT INTO t1_part VALUES (1, 1) , (10, 10);
+CREATE VIEW v1 AS SELECT * FROM t1_part;
+
+--echo
+--echo # Should be (1,1),(10,10)
+SELECT * FROM t1_part;
+
+--echo
+--echo # Case 1
+--echo # Update is refused because partitioning key is updated
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.partkey = 2, B.nokey = 3;
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2, B.partkey = 3;
+
+--echo
+--echo # Case 2
+--echo # Like 1, but partition accessed through a view
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1_part AS A NATURAL JOIN v1 as B SET A.nokey = 2 , B.partkey = 3;
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE v1 AS A NATURAL JOIN t1_part as B SET A.nokey = 2 , B.partkey = 3;
+
+--echo
+--echo # Should be (1,1),(10,10)
+SELECT * FROM t1_part;
+
+--echo
+--echo # Case 3
+--echo # Update is accepted because partitioning key is not updated
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2 , B.nokey = 3;
+
+--echo
+--echo # Should be (1,3),(10,3)
+SELECT * FROM t1_part;
+
+--echo
+# Cleanup
+DROP VIEW v1;
+DROP TABLE t1_part;
diff --git a/mysql-test/t/partition_archive.test b/mysql-test/t/partition_archive.test
index fad57107b7d..39551991702 100644
--- a/mysql-test/t/partition_archive.test
+++ b/mysql-test/t/partition_archive.test
@@ -10,6 +10,27 @@
--source include/have_partition.inc
--source include/have_archive.inc
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+#
+# Bug#44622: Using PARTITIONs with ARCHIVE engine reports 0 bytes in i_s.TABLES
+#
+CREATE TABLE t1 (f1 DATE NOT NULL)
+ENGINE = ARCHIVE PARTITION BY RANGE (TO_DAYS(f1))
+(partition p1 values less than (733751),
+ partition p2 values less than MAXVALUE);
+
+INSERT INTO t1 VALUES(CURRENT_DATE);
+
+SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+DROP TABLE t1;
+CREATE TABLE t1 (f1 DATE NOT NULL)
+ENGINE = ARCHIVE;
+INSERT INTO t1 VALUES(CURRENT_DATE);
+SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+SELECT DATA_LENGTH, INDEX_LENGTH FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+DROP TABLE t1;
#
# Bug 17310 Partitions: Bugs with archived partitioned tables
diff --git a/mysql-test/t/partition_binlog.test b/mysql-test/t/partition_binlog.test
new file mode 100644
index 00000000000..c1f618b794f
--- /dev/null
+++ b/mysql-test/t/partition_binlog.test
@@ -0,0 +1,42 @@
+--source include/have_log_bin.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Bug#58147: ALTER TABLE w/ TRUNCATE PARTITION fails
+--echo # but the statement is written to binlog
+--echo #
+
+CREATE TABLE t1(id INT)
+PARTITION BY RANGE (id)
+(PARTITION p0 VALUES LESS THAN (100),
+ PARTITION pmax VALUES LESS THAN (MAXVALUE));
+
+INSERT INTO t1 VALUES (1), (10), (100), (1000);
+
+--let $binlog_file=query_get_value(SHOW MASTER STATUS, File, 1)
+--let $binlog_start=query_get_value(SHOW MASTER STATUS, Position, 1)
+
+--error ER_WRONG_PARTITION_NAME
+ALTER TABLE t1 TRUNCATE PARTITION p1;
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION p1;
+
+--echo # No error returned, output in table format instead:
+ALTER TABLE t1 ANALYZE PARTITION p1;
+ALTER TABLE t1 CHECK PARTITION p1;
+ALTER TABLE t1 OPTIMIZE PARTITION p1;
+ALTER TABLE t1 REPAIR PARTITION p1;
+
+ALTER TABLE t1 ANALYZE PARTITION p0;
+ALTER TABLE t1 CHECK PARTITION p0;
+ALTER TABLE t1 OPTIMIZE PARTITION p0;
+ALTER TABLE t1 REPAIR PARTITION p0;
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+ALTER TABLE t1 DROP PARTITION p0;
+
+--source include/show_binlog_events.inc
+
+DROP TABLE t1;
diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test
new file mode 100644
index 00000000000..95a2be36395
--- /dev/null
+++ b/mysql-test/t/partition_column.test
@@ -0,0 +1,510 @@
+#
+# Tests for the new column list partitioning introduced in second
+# version for partitioning.
+#
+--source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+--echo #
+--echo # Bug#52815: LIST COLUMNS doesn't insert rows in correct partition
+--echo # if muliple columns used
+CREATE TABLE t1 (
+id INT NOT NULL,
+name VARCHAR(255),
+department VARCHAR(10),
+country VARCHAR(255)
+) PARTITION BY LIST COLUMNS (department, country) (
+PARTITION first_office VALUES IN (('dep1', 'Russia'), ('dep1', 'Croatia')),
+PARTITION second_office VALUES IN (('dep2', 'Russia'))
+);
+
+INSERT INTO t1 VALUES(1, 'Ann', 'dep1', 'Russia');
+INSERT INTO t1 VALUES(2, 'Bob', 'dep1', 'Croatia');
+INSERT INTO t1 VALUES(3, 'Cecil', 'dep2', 'Russia');
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO t1 VALUES(3, 'Dan', 'dep2', 'Croatia');
+SELECT PARTITION_NAME,TABLE_ROWS
+FROM INFORMATION_SCHEMA.PARTITIONS
+WHERE TABLE_NAME = 't1';
+SHOW CREATE TABLE t1;
+SELECT * FROM t1 WHERE department = 'dep2' and country = 'Croatia';
+SELECT * FROM t1 WHERE department = 'dep1' and country = 'Croatia';
+DROP TABLE t1;
+
+#
+# Bug#51347: assertion with show create table + partition by columns
+# on decimal column
+#
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (a DECIMAL)
+PARTITION BY RANGE COLUMNS (a)
+(PARTITION p0 VALUES LESS THAN (0));
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+CREATE TABLE t1 (a BLOB)
+PARTITION BY RANGE COLUMNS (a)
+(PARTITION p0 VALUES LESS THAN ("X"));
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+CREATE TABLE t1 (a TEXT)
+PARTITION BY RANGE COLUMNS (a)
+(PARTITION p0 VALUES LESS THAN ("X"));
+
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (a FLOAT)
+PARTITION BY RANGE COLUMNS (a)
+(PARTITION p0 VALUES LESS THAN (0.0));
+
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (a DOUBLE)
+PARTITION BY RANGE COLUMNS (a)
+(PARTITION p0 VALUES LESS THAN (0.0));
+
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (d TIMESTAMP)
+PARTITION BY RANGE COLUMNS(d)
+(PARTITION p0 VALUES LESS THAN ('2000-01-01'),
+ PARTITION p1 VALUES LESS THAN ('2040-01-01'));
+
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (d BIT(1))
+PARTITION BY RANGE COLUMNS(d)
+(PARTITION p0 VALUES LESS THAN (0),
+ PARTITION p1 VALUES LESS THAN (1));
+
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (d ENUM("YES","NO"))
+PARTITION BY RANGE COLUMNS(d)
+(PARTITION p0 VALUES LESS THAN ("NO"),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (d SET("Car","MC"))
+PARTITION BY RANGE COLUMNS(d)
+(PARTITION p0 VALUES LESS THAN ("MC"),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+
+#
+# BUG#49180, Possible to define empty intervals for column list partitioning
+#
+--error ER_RANGE_NOT_INCREASING_ERROR
+create table t1 (a int, b int)
+partition by range columns (a,b)
+( partition p0 values less than (maxvalue, 10),
+ partition p1 values less than (maxvalue, maxvalue));
+
+--error ER_RANGE_NOT_INCREASING_ERROR
+create table t1 (a int, b int, c int)
+partition by range columns (a,b,c)
+( partition p0 values less than (1, maxvalue, 10),
+ partition p1 values less than (1, maxvalue, maxvalue));
+
+#
+# BUG#48737, Search fails with ucs2
+#
+create table t1 (a varchar(5) character set ucs2 collate ucs2_bin)
+partition by range columns (a)
+(partition p0 values less than (0x0041));
+insert into t1 values (0x00410000);
+select hex(a) from t1 where a like 'A_';
+explain partitions select hex(a) from t1 where a like 'A_';
+alter table t1 remove partitioning;
+select hex(a) from t1 where a like 'A_';
+create index a on t1 (a);
+select hex(a) from t1 where a like 'A_';
+insert into t1 values ('A_');
+select hex(a) from t1;
+drop table t1;
+
+#
+# BUG#48161, Delivering too few records using collate syntax with partitions
+#
+# Test case from BUG#48447 with some extension
+create table t1 (a varchar(1) character set latin1 collate latin1_general_ci)
+partition by range columns(a)
+( partition p0 values less than ('a'),
+ partition p1 values less than ('b'),
+ partition p2 values less than ('c'),
+ partition p3 values less than ('d'));
+insert into t1 values ('A'),('a'),('B'),('b'),('C'),('c');
+select * from t1 where a > 'B' collate latin1_bin;
+select * from t1 where a <> 'B' collate latin1_bin;
+alter table t1 remove partitioning;
+select * from t1 where a > 'B' collate latin1_bin;
+select * from t1 where a <> 'B' collate latin1_bin;
+drop table t1;
+
+# Test case from BUG#48161
+create table t1 (a varchar(2) character set latin1,
+ b varchar(2) character set latin1)
+partition by list columns(a,b)
+(partition p0 values in (('a','a')));
+insert into t1 values ('A','A');
+select * from t1 where b <> 'a' collate latin1_bin AND
+ a = 'A' collate latin1_bin;
+alter table t1 remove partitioning;
+select * from t1 where b <> 'a' collate latin1_bin AND
+ a = 'A' collate latin1_bin;
+drop table t1;
+
+create table t1 (a varchar(5))
+partition by list columns(a)
+( partition p0 values in ('\''),
+ partition p1 values in ('\\'),
+ partition p2 values in ('\0'));
+show create table t1;
+drop table t1;
+
+#
+# BUG#48165, sql_mode gives error
+#
+set @@sql_mode=allow_invalid_dates;
+--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
+create table t1 (a char, b char, c date)
+partition by range columns (a,b,c)
+( partition p0 values less than (0,0,to_days('3000-11-31')));
+
+--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
+create table t1 (a char, b char, c date)
+partition by range columns (a,b,c)
+( partition p0 values less than (0,0,'3000-11-31'));
+set @@sql_mode='';
+
+--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
+create table t1 (a int, b char(10), c varchar(25), d datetime)
+partition by range columns(a,b,c,d)
+subpartition by hash (to_seconds(d))
+subpartitions 4
+( partition p0 values less than (1, 0, MAXVALUE, '1900-01-01'),
+ partition p1 values less than (1, 'a', MAXVALUE, '1999-01-01'),
+ partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
+ partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
+
+create table t1 (a int, b char(10), c varchar(25), d datetime)
+partition by range columns(a,b,c,d)
+subpartition by hash (to_seconds(d))
+subpartitions 4
+( partition p0 values less than (1, '0', MAXVALUE, '1900-01-01'),
+ partition p1 values less than (1, 'a', MAXVALUE, '1999-01-01'),
+ partition p2 values less than (1, 'b', MAXVALUE, MAXVALUE),
+ partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
+show create table t1;
+drop table t1;
+
+--error ER_NULL_IN_VALUES_LESS_THAN
+create table t1 (a int, b int)
+partition by range columns (a,b)
+(partition p0 values less than (NULL, maxvalue));
+
+--error ER_MAXVALUE_IN_VALUES_IN, ER_PARSE_ERROR
+create table t1 (a int, b int)
+partition by list columns(a,b)
+( partition p0 values in ((maxvalue, 0)));
+
+create table t1 (a int, b int)
+partition by list columns (a,b)
+( partition p0 values in ((0,0)));
+--error ER_MAXVALUE_IN_VALUES_IN, ER_PARSE_ERROR
+alter table t1 add partition
+(partition p1 values in (maxvalue, maxvalue));
+drop table t1;
+#
+# BUG#47837, Crash when two same fields in column list processing
+#
+--error ER_SAME_NAME_PARTITION_FIELD
+create table t1 (a int, b int)
+partition by key (a,a);
+--error ER_SAME_NAME_PARTITION_FIELD
+create table t1 (a int, b int)
+partition by list columns(a,a)
+( partition p values in ((1,1)));
+
+#
+# BUG#47838, List partitioning have problems with <= and >=
+#
+create table t1 (a int signed)
+partition by list (a)
+( partition p0 values in (1, 3, 5, 7, 9, NULL),
+ partition p1 values in (2, 4, 6, 8, 0));
+insert into t1 values (NULL),(0),(1),(2),(2),(4),(4),(4),(8),(8);
+select * from t1 where NULL <= a;
+select * from t1 where a is null;
+explain partitions select * from t1 where a is null;
+select * from t1 where a <= 1;
+drop table t1;
+
+create table t1 (a int signed)
+partition by list columns(a)
+( partition p0 values in (1, 3, 5, 7, 9, NULL),
+ partition p1 values in (2, 4, 6, 8, 0));
+insert into t1 values (NULL),(0),(1),(2),(2),(4),(4),(4),(8),(8);
+select * from t1 where a <= NULL;
+select * from t1 where a is null;
+explain partitions select * from t1 where a is null;
+select * from t1 where a <= 1;
+drop table t1;
+
+create table t1 (a int, b int)
+partition by list columns(a,b)
+( partition p0 values in ((1, NULL), (2, NULL), (NULL, NULL)),
+ partition p1 values in ((1,1), (2,2)),
+ partition p2 values in ((3, NULL), (NULL, 1)));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
+show create table t1;
+#
+# BUG#47754 Crash when selecting using NOT BETWEEN for column list partitioning
+#
+insert into t1 values (3, NULL);
+insert into t1 values (NULL, 1);
+insert into t1 values (NULL, NULL);
+insert into t1 values (1, NULL);
+insert into t1 values (2, NULL);
+insert into t1 values (1,1);
+insert into t1 values (2,2);
+select * from t1 where a = 1;
+select * from t1 where a = 2;
+select * from t1 where a > 8;
+select * from t1 where a not between 8 and 8;
+show create table t1;
+drop table t1;
+
+--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
+create table t1 (a int)
+partition by list (a)
+( partition p0 values in (1),
+ partition p1 values in (1));
+
+create table t1 (a int)
+partition by list (a)
+( partition p0 values in (2, 1),
+ partition p1 values in (4, NULL, 3));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
+show create table t1;
+insert into t1 values (1);
+insert into t1 values (2);
+insert into t1 values (3);
+insert into t1 values (4);
+insert into t1 values (NULL);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (5);
+drop table t1;
+
+--error ER_PARSE_ERROR
+create table t1 (a int)
+partition by list columns(a)
+( partition p0 values in (2, 1),
+ partition p1 values in ((4), (NULL), (3)));
+
+create table t1 (a int)
+partition by list columns(a)
+( partition p0 values in (2, 1),
+ partition p1 values in (4, NULL, 3));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
+show create table t1;
+insert into t1 values (1);
+insert into t1 values (2);
+insert into t1 values (3);
+insert into t1 values (4);
+insert into t1 values (NULL);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (5);
+show create table t1;
+drop table t1;
+
+create table t1 (a int, b char(10), c varchar(5), d int)
+partition by range columns(a,b,c)
+subpartition by key (c,d)
+subpartitions 3
+( partition p0 values less than (1,'abc','abc'),
+ partition p1 values less than (2,'abc','abc'),
+ partition p2 values less than (3,'abc','abc'),
+ partition p3 values less than (4,'abc','abc'));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
+show create table t1;
+
+insert into t1 values (1,'a','b',1),(2,'a','b',2),(3,'a','b',3);
+insert into t1 values (1,'b','c',1),(2,'b','c',2),(3,'b','c',3);
+insert into t1 values (1,'c','d',1),(2,'c','d',2),(3,'c','d',3);
+insert into t1 values (1,'d','e',1),(2,'d','e',2),(3,'d','e',3);
+select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) OR
+ (a = 1 AND b >= 'a' AND (c = 'c' OR (c = 'd' AND d = 2))));
+drop table t1;
+
+create table t1 (a int, b varchar(2), c int)
+partition by range columns (a, b, c)
+(partition p0 values less than (1, 'A', 1),
+ partition p1 values less than (1, 'B', 1));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
+show create table t1;
+insert into t1 values (1, 'A', 1);
+explain partitions select * from t1 where a = 1 AND b <= 'A' and c = 1;
+select * from t1 where a = 1 AND b <= 'A' and c = 1;
+drop table t1;
+
+create table t1 (a char, b char, c char)
+partition by list columns(a)
+( partition p0 values in ('a'));
+insert into t1 (a) values ('a');
+select * from t1 where a = 'a';
+drop table t1;
+
+--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
+create table t1 (d time)
+partition by range columns(d)
+( partition p0 values less than ('2000-01-01'),
+ partition p1 values less than ('2040-01-01'));
+
+create table t1 (a int, b int)
+partition by range columns(a,b)
+(partition p0 values less than (maxvalue, 10));
+drop table t1;
+
+create table t1 (d date)
+partition by range columns(d)
+( partition p0 values less than ('2000-01-01'),
+ partition p1 values less than ('2009-01-01'));
+drop table t1;
+
+create table t1 (d date)
+partition by range columns(d)
+( partition p0 values less than ('1999-01-01'),
+ partition p1 values less than ('2000-01-01'));
+drop table t1;
+
+create table t1 (d date)
+partition by range columns(d)
+( partition p0 values less than ('2000-01-01'),
+ partition p1 values less than ('3000-01-01'));
+drop table t1;
+
+create table t1 (a int, b int)
+partition by range columns(a,b)
+(partition p2 values less than (99,99),
+ partition p1 values less than (99,999));
+
+insert into t1 values (99,998);
+select * from t1 where b = 998;
+drop table t1;
+
+create table t1 as select to_seconds(null) as to_seconds;
+select data_type from information_schema.columns
+where column_name='to_seconds';
+drop table t1;
+
+--error ER_PARSE_ERROR
+create table t1 (a int, b int)
+partition by list columns(a,b)
+(partition p0 values in ((maxvalue,maxvalue)));
+create table t1 (a int, b int)
+partition by range columns(a,b)
+(partition p0 values less than (maxvalue,maxvalue));
+drop table t1;
+
+create table t1 (a int)
+partition by list columns(a)
+(partition p0 values in (0));
+select partition_method from information_schema.partitions where table_name='t1';
+drop table t1;
+
+create table t1 (a char(6))
+partition by range columns(a)
+(partition p0 values less than ('H23456'),
+ partition p1 values less than ('M23456'));
+insert into t1 values ('F23456');
+select * from t1;
+drop table t1;
+
+-- error 1054
+create table t1 (a char(6))
+partition by range columns(a)
+(partition p0 values less than (H23456),
+ partition p1 values less than (M23456));
+
+-- error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
+create table t1 (a char(6))
+partition by range columns(a)
+(partition p0 values less than (23456),
+ partition p1 values less than (23456));
+
+-- error 1064
+create table t1 (a int, b int)
+partition by range columns(a,b)
+(partition p0 values less than (10));
+
+-- error ER_PARTITION_COLUMN_LIST_ERROR
+create table t1 (a int, b int)
+partition by range columns(a,b)
+(partition p0 values less than (1,1,1);
+
+create table t1 (a int, b int)
+partition by range columns(a,b)
+(partition p0 values less than (1, 0),
+ partition p1 values less than (2, maxvalue),
+ partition p2 values less than (3, 3),
+ partition p3 values less than (10, maxvalue));
+
+-- error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (11,0);
+insert into t1 values (0,1),(1,1),(2,1),(3,1),(3,4),(4,9),(9,1);
+select * from t1;
+
+alter table t1
+partition by range columns(b,a)
+(partition p0 values less than (1,2),
+ partition p1 values less than (3,3),
+ partition p2 values less than (9,5));
+explain partitions select * from t1 where b < 2;
+select * from t1 where b < 2;
+explain partitions select * from t1 where b < 4;
+select * from t1 where b < 4;
+
+alter table t1 reorganize partition p1 into
+(partition p11 values less than (2,2),
+ partition p12 values less than (3,3));
+
+-- error ER_REORG_OUTSIDE_RANGE
+alter table t1 reorganize partition p0 into
+(partition p01 values less than (0,3),
+ partition p02 values less than (1,1));
+
+-- error ER_PARTITION_COLUMN_LIST_ERROR
+alter table t1 reorganize partition p2 into
+(partition p2 values less than(9,6,1));
+
+-- error ER_PARTITION_COLUMN_LIST_ERROR
+alter table t1 reorganize partition p2 into
+(partition p2 values less than (10));
+
+alter table t1 reorganize partition p2 into
+(partition p21 values less than (4,7),
+ partition p22 values less than (9,5));
+explain partitions select * from t1 where b < 4;
+select * from t1 where b < 4;
+drop table t1;
+
+create table t1 (a int, b int)
+partition by list columns(a,b)
+subpartition by hash (b)
+subpartitions 2
+(partition p0 values in ((0,0), (1,1)),
+ partition p1 values in ((1000,1000)));
+insert into t1 values (1000,1000);
+#select * from t1 where a = 0 and b = 0;
+drop table t1;
+
+create table t1 (a char, b char, c char)
+partition by range columns(a,b,c)
+( partition p0 values less than ('a','b','c'));
+alter table t1 add partition
+(partition p1 values less than ('b','c','d'));
+drop table t1;
diff --git a/mysql-test/t/partition_column_prune.test b/mysql-test/t/partition_column_prune.test
new file mode 100644
index 00000000000..848825ba71b
--- /dev/null
+++ b/mysql-test/t/partition_column_prune.test
@@ -0,0 +1,71 @@
+#
+# Partition pruning tests for new COLUMN LIST feature
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+--enable_warnings
+
+create table t1 (a char, b char, c char)
+partition by range columns(a,b,c)
+( partition p0 values less than ('a','b','c'));
+insert into t1 values ('a', NULL, 'd');
+explain partitions select * from t1 where a = 'a' AND c = 'd';
+select * from t1 where a = 'a' AND c = 'd';
+drop table t1;
+
+## COLUMN_LIST partition pruning tests
+create table t1 (a int not null) partition by range columns(a) (
+ partition p0 values less than (10),
+ partition p1 values less than (20),
+ partition p2 values less than (30),
+ partition p3 values less than (40),
+ partition p4 values less than (50),
+ partition p5 values less than (60),
+ partition p6 values less than (70)
+);
+insert into t1 values (5),(15),(25),(35),(45),(55),(65);
+insert into t1 values (5),(15),(25),(35),(45),(55),(65);
+
+create table t2 (a int not null) partition by range(a) (
+ partition p0 values less than (10),
+ partition p1 values less than (20),
+ partition p2 values less than (30),
+ partition p3 values less than (40),
+ partition p4 values less than (50),
+ partition p5 values less than (60),
+ partition p6 values less than (70)
+);
+insert into t2 values (5),(15),(25),(35),(45),(55),(65);
+insert into t2 values (5),(15),(25),(35),(45),(55),(65);
+
+explain partitions select * from t1 where a > 35 and a < 45;
+explain partitions select * from t2 where a > 35 and a < 45;
+
+drop table t1, t2;
+
+create table t1 (a int not null, b int not null )
+partition by range columns(a,b) (
+ partition p01 values less than (2,10),
+ partition p02 values less than (2,20),
+ partition p03 values less than (2,30),
+
+ partition p11 values less than (4,10),
+ partition p12 values less than (4,20),
+ partition p13 values less than (4,30),
+
+ partition p21 values less than (6,10),
+ partition p22 values less than (6,20),
+ partition p23 values less than (6,30)
+);
+
+insert into t1 values (2,5), (2,15), (2,25),
+ (4,5), (4,15), (4,25), (6,5), (6,15), (6,25);
+insert into t1 select * from t1;
+
+explain partitions select * from t1 where a=2;
+explain partitions select * from t1 where a=4;
+explain partitions select * from t1 where a=2 and b < 22;
+
+drop table t1;
diff --git a/mysql-test/t/partition_datatype.test b/mysql-test/t/partition_datatype.test
index e5bde3edbef..967e1cddb4e 100644
--- a/mysql-test/t/partition_datatype.test
+++ b/mysql-test/t/partition_datatype.test
@@ -4,6 +4,7 @@
# as partition by key
# Created to verify the fix for Bug#31705
# Partitions: crash if varchar length > 65530
+# BUG#48164 limited size to 3072 bytes
#
-- source include/have_partition.inc
-- source include/have_innodb.inc
@@ -193,27 +194,29 @@ create table t1 (a set('y','n')) partition by key (a);
insert into t1 values ('y');
select * from t1 where a = 'y';
drop table t1;
-create table t1 (a varchar(65531)) partition by key (a);
+create table t1 (a varchar(3068)) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
select * from t1 where a like 'aaa%';
select * from t1 where a = 'bbbb';
drop table t1;
-create table t1 (a varchar(65532)) partition by key (a);
+create table t1 (a varchar(3069)) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
select * from t1 where a like 'aaa%';
select * from t1 where a = 'bbbb';
drop table t1;
-create table t1 (a varchar(65533) not null) partition by key (a);
+create table t1 (a varchar(3070) not null) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
select * from t1 where a like 'aaa%';
select * from t1 where a = 'bbbb';
drop table t1;
+-- error ER_PARTITION_FIELDS_TOO_LONG
+create table t1 (a varchar(3070)) partition by key (a);
-- error ER_TOO_BIG_ROWSIZE
create table t1 (a varchar(65533)) partition by key (a);
-- error ER_TOO_BIG_ROWSIZE
diff --git a/mysql-test/t/partition_debug_sync.test b/mysql-test/t/partition_debug_sync.test
index 69bc86a8bb7..448cec652d7 100644
--- a/mysql-test/t/partition_debug_sync.test
+++ b/mysql-test/t/partition_debug_sync.test
@@ -15,6 +15,8 @@ SET DEBUG_SYNC= 'RESET';
--echo # Bug#42438: Crash ha_partition::change_table_ptr
--echo # Test when remove partitioning is done while drop table is waiting
--echo # for the table.
+--echo # After MDL was introduced, there is no longer any race, so test is done
+--echo # by adding a small sleep to verify that the delete waits.
connect(con1, localhost, root,,);
--echo # Con 1
SET DEBUG_SYNC= 'RESET';
@@ -28,18 +30,20 @@ ENGINE = MYISAM
PARTITION p1 VALUES LESS THAN (20),
PARTITION p2 VALUES LESS THAN (100),
PARTITION p3 VALUES LESS THAN MAXVALUE ) */;
+SET SESSION debug= "+d,sleep_before_create_table_no_lock";
SET DEBUG_SYNC= 'alter_table_before_create_table_no_lock SIGNAL removing_partitioning WAIT_FOR waiting_for_alter';
SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL partitioning_removed';
--send ALTER TABLE t1 REMOVE PARTITIONING
connection default;
--echo # Con default
SET DEBUG_SYNC= 'now WAIT_FOR removing_partitioning';
-SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter';
-SET DEBUG_SYNC= 'rm_table_part2_before_delete_table WAIT_FOR partitioning_removed';
+SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL waiting_for_alter';
+SET DEBUG_SYNC= 'rm_table_no_locks_before_delete_table WAIT_FOR partitioning_removed';
DROP TABLE IF EXISTS t1;
--echo # Con 1
connection con1;
--reap
+SET SESSION debug= "-d,sleep_before_create_table_no_lock";
connection default;
SET DEBUG_SYNC= 'RESET';
connection con1;
@@ -49,6 +53,8 @@ SET DEBUG_SYNC= 'RESET';
--echo # Bug#42438: Crash ha_partition::change_table_ptr
--echo # Test when remove partitioning is failing due to drop table is already
--echo # in progress.
+--echo # After MDL was introduced, there is no longer any race, so test is done
+--echo # by adding a small sleep to verify that the alter waits.
CREATE TABLE t2
(a INTEGER,
b INTEGER NOT NULL,
@@ -59,15 +65,17 @@ ENGINE = MYISAM
PARTITION p1 VALUES LESS THAN (20),
PARTITION p2 VALUES LESS THAN (100),
PARTITION p3 VALUES LESS THAN MAXVALUE ) */;
-SET DEBUG_SYNC= 'before_lock_tables_takes_lock SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
+SET DEBUG_SYNC= 'alter_table_before_open_tables SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done';
--send ALTER TABLE t2 REMOVE PARTITIONING
connection default;
--echo # Con default
+SET SESSION debug= "+d,sleep_before_no_locks_delete_table";
SET DEBUG_SYNC= 'now WAIT_FOR removing_partitions';
-SET DEBUG_SYNC= 'waiting_for_table SIGNAL waiting_for_alter';
-SET DEBUG_SYNC= 'rm_table_part2_before_binlog SIGNAL delete_done';
+SET DEBUG_SYNC= 'rm_table_no_locks_before_delete_table SIGNAL waiting_for_alter';
+SET DEBUG_SYNC= 'rm_table_no_locks_before_binlog SIGNAL delete_done';
DROP TABLE IF EXISTS t2;
+SET SESSION debug= "-d,sleep_before_no_locks_delete_table";
--echo # Con 1
connection con1;
--error ER_NO_SUCH_TABLE
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index 7e574fd6a42..536935420a4 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -5,7 +5,7 @@
-- source include/have_partition.inc
--disable_warnings
-drop table if exists t1;
+drop table if exists t1, t2;
--enable_warnings
let $MYSQLD_DATADIR= `SELECT @@datadir`;
@@ -14,13 +14,13 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo # Bug#57924: crash when creating partitioned table with
--echo # multiple columns in the partition key
--echo #
---error ER_FIELD_NOT_FOUND_PART_ERROR
+--error ER_SAME_NAME_PARTITION_FIELD
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(a, b, a);
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(A, b);
DROP TABLE t1;
---error ER_FIELD_NOT_FOUND_PART_ERROR
+--error ER_SAME_NAME_PARTITION_FIELD
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a,b))
PARTITION BY KEY(a, b, A);
@@ -222,26 +222,23 @@ PARTITION BY HASH (WEEKDAY(a));
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
CREATE TABLE t1 (a INT)
PARTITION BY HASH (WEEKDAY(a));
---echo # TO_SECONDS() is added in 5.5.
---error ER_PARSE_ERROR
+--echo # TO_SECONDS() is added in 5.5.
+--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
CREATE TABLE t1 (a TIME)
PARTITION BY HASH (TO_SECONDS(a));
-#--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
-#CREATE TABLE t1 (a TIME)
-#PARTITION BY HASH (TO_SECONDS(a));
-#CREATE TABLE t1 (a DATE)
-#PARTITION BY HASH (TO_SECONDS(a));
-#DROP TABLE t1;
-#CREATE TABLE t1 (a DATETIME)
-#PARTITION BY HASH (TO_SECONDS(a));
-#DROP TABLE t1;
-#--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
-#CREATE TABLE t1 (a VARCHAR(10))
-#PARTITION BY HASH (TO_SECONDS(a));
-#--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
-#CREATE TABLE t1 (a INT)
-#PARTITION BY HASH (TO_SECONDS(a));
+CREATE TABLE t1 (a DATE)
+PARTITION BY HASH (TO_SECONDS(a));
+DROP TABLE t1;
+CREATE TABLE t1 (a DATETIME)
+PARTITION BY HASH (TO_SECONDS(a));
+DROP TABLE t1;
+--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
+CREATE TABLE t1 (a VARCHAR(10))
+PARTITION BY HASH (TO_SECONDS(a));
+--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
+CREATE TABLE t1 (a INT)
+PARTITION BY HASH (TO_SECONDS(a));
CREATE TABLE t1 (a TIME)
PARTITION BY HASH (TIME_TO_SEC(a));
@@ -689,22 +686,63 @@ CREATE TABLE t1 (a INT)
PARTITION BY HASH (TIME_TO_SEC(a));
--echo #
---echo # Bug#49161: Out of memory; restart server and try again (needed 2 bytes)
---echo #
-CREATE TABLE t1 (a INT) PARTITION BY HASH (a);
-FLUSH TABLES;
---remove_file $MYSQLD_DATADIR/test/t1.par
---replace_result $MYSQLD_DATADIR ./
-CHECK TABLE t1;
---error ER_UNKNOWN_ERROR
-SELECT * FROM t1;
---echo # Note that it is currently impossible to drop a partitioned table
---echo # without the .par file
---error ER_BAD_TABLE_ERROR
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.frm
---remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYI
---remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYD
+--echo # Bug#50036: Inconsistent errors when using TIMESTAMP
+--echo # columns/expressions
+
+--echo # 1. correct and appropriate errors in light of
+--echo # the fix for BUG#42849:
+--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
+CREATE TABLE t1 (c TIMESTAMP)
+PARTITION BY RANGE (TO_DAYS(c))
+(PARTITION p0 VALUES LESS THAN (10000),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+CREATE TABLE t2 (c TIMESTAMP);
+--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
+ALTER TABLE t2
+PARTITION BY RANGE (TO_DAYS(c))
+(PARTITION p0 VALUES LESS THAN (10000),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (c TIMESTAMP)
+PARTITION BY RANGE COLUMNS(c)
+(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+ALTER TABLE t2 PARTITION BY RANGE COLUMNS(c)
+(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+DROP TABLE t2;
+
+--echo # 2. These errors where questionable before the fix:
+
+--echo # VALUES clause are checked first, clearified the error message.
+--error ER_VALUES_IS_NOT_INT_TYPE_ERROR
+CREATE TABLE t1 (c TIMESTAMP)
+PARTITION BY RANGE (c)
+(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+
+--echo # TIMESTAMP is not INT (e.g. UNIX_TIMESTAMP).
+--error ER_VALUES_IS_NOT_INT_TYPE_ERROR
+CREATE TABLE t1 (c TIMESTAMP)
+PARTITION BY RANGE (UNIX_TIMESTAMP(c))
+(PARTITION p0 VALUES LESS THAN ('2000-01-01 00:00:00'),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+
+CREATE TABLE t1 (c TIMESTAMP)
+PARTITION BY RANGE (UNIX_TIMESTAMP(c))
+(PARTITION p0 VALUES LESS THAN (UNIX_TIMESTAMP('2000-01-01 00:00:00')),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+DROP TABLE t1;
+
+--echo # Changed error from ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
+CREATE TABLE t1 (c TIMESTAMP)
+PARTITION BY HASH (c) PARTITIONS 4;
+
+--echo # Moved to partition_myisam, since it was MyISAM specific
+--echo # Added test with existing TIMESTAMP partitioning (when it was allowed).
--echo #
--echo # Bug#49477: Assertion `0' failed in ha_partition.cc:5530
@@ -714,30 +752,41 @@ CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
--error ER_PARTITION_NO_TEMPORARY
CREATE TEMPORARY TABLE tmp_t1 LIKE t1;
DROP TABLE t1;
-
--echo #
---echo # Bug#50392: insert_id is not reset for partitioned tables
---echo # auto_increment on duplicate entry
-CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
-SET INSERT_ID= 13;
-INSERT INTO t1 VALUES (NULL);
-SET INSERT_ID= 12;
---error ER_DUP_ENTRY
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+--echo # Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with
+--echo # subpartitions
+SET @org_mode=@@sql_mode;
+SET @@sql_mode='NO_DIR_IN_CREATE';
+SELECT @@sql_mode;
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+SUBPARTITION BY HASH(TO_DAYS(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+ DATA DIRECTORY = '/tmp/not-existing'
+ INDEX DIRECTORY = '/tmp/not-existing');
+--replace_result MyISAM <curr_engine> InnoDB <curr_engine>
SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (NULL);
-SELECT * FROM t1;
DROP TABLE t1;
-CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY KEY(a);
-SET INSERT_ID= 13;
-INSERT INTO t1 VALUES (NULL);
-SET INSERT_ID= 12;
---error ER_DUP_ENTRY
-INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+SUBPARTITION BY HASH(TO_DAYS(purchased)) SUBPARTITIONS 2
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp0
+ DATA DIRECTORY = '/tmp/not-existing'
+ INDEX DIRECTORY = '/tmp/not-existing',
+ SUBPARTITION sp1));
+--replace_result MyISAM <curr_engine> InnoDB <curr_engine>
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+ DATA DIRECTORY = '/tmp/not-existing'
+ INDEX DIRECTORY = '/tmp/not-existing');
+--replace_result MyISAM <curr_engine> InnoDB <curr_engine>
SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (NULL);
-SELECT * FROM t1;
DROP TABLE t1;
+SET @@sql_mode= @org_mode;
#
# Bug#38719: Partitioning returns a different error code for a
@@ -753,24 +802,6 @@ INSERT INTO t1 VALUES (1),(1);
DROP TABLE t1;
#
-# Bug#31931: Mix of handlers error message
-#
---error ER_MIX_HANDLER_ERROR
-CREATE TABLE t1 (a INT)
-PARTITION BY HASH (a)
-( PARTITION p0 ENGINE=MyISAM,
- PARTITION p1);
---error ER_MIX_HANDLER_ERROR
-CREATE TABLE t1 (a INT)
-PARTITION BY LIST (a)
-SUBPARTITION BY HASH (a)
-( PARTITION p0 VALUES IN (0)
-( SUBPARTITION s0, SUBPARTITION s1 ENGINE=MyISAM, SUBPARTITION s2),
- PARTITION p1 VALUES IN (1)
-( SUBPARTITION s3 ENGINE=MyISAM, SUBPARTITION s4, SUBPARTITION s5 ENGINE=MyISAM));
-
-
-#
# Bug 29368:
# Incorrect error, 1467, for syntax error when creating partition
--error ER_PARTITION_REQUIRES_VALUES_ERROR
@@ -786,7 +817,7 @@ PARTITION BY RANGE (a)
#
# Partition by key stand-alone error
#
---error 1064
+--error ER_PARSE_ERROR
partition by list (a)
partitions 3
(partition x1 values in (1,2,9,4) tablespace ts1,
@@ -823,7 +854,7 @@ partitions 3
#
# Partition by key, partition function not allowed
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -838,7 +869,7 @@ partitions 3
#
# Partition by key, no partition name
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -869,7 +900,7 @@ select load_file('$MYSQLD_DATADIR/test/t1.par');
#
# Partition by hash, invalid field in function
#
---error 1054
+--error ER_BAD_FIELD_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -899,7 +930,7 @@ partitions 3
#
# Partition by key specified 3 partitions but only defined 2 => error
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -910,9 +941,9 @@ partitions 3
(partition x1, partition x2);
#
-# Partition by key specified 3 partitions but only defined 2 => error
+# Partition by hash, random function
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -923,9 +954,9 @@ partitions 2
(partition x1, partition x2);
#
-# Partition by key specified 3 partitions but only defined 2 => error
+# Partition by range, random function
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -936,9 +967,9 @@ partitions 2
(partition x1 values less than (0), partition x2 values less than (2));
#
-# Partition by key specified 3 partitions but only defined 2 => error
+# Partition by list, random function
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1074,7 +1105,7 @@ select load_file('$MYSQLD_DATADIR/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1101,7 +1132,7 @@ select load_file('$MYSQLD_DATADIR/test/t1.par');
#
# Subpartition by hash, no partitions defined, wrong subpartition function
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1142,7 +1173,7 @@ subpartition by hash (3+4);
#
# Subpartition by hash, no partitions defined, wrong subpartition function
#
---error 1054
+--error ER_BAD_FIELD_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1168,7 +1199,7 @@ select load_file('$MYSQLD_DATADIR/test/t1.par');
#
# Partition by range, invalid field in function
#
---error 1054
+--error ER_BAD_FIELD_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1182,7 +1213,7 @@ partitions 2
#
# Partition by range, inconsistent partition function and constants
#
---error 1064
+--error ER_VALUES_IS_NOT_INT_TYPE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1252,7 +1283,7 @@ partitions 2
#
# Partition by range, missing parenthesis
#
---error 1064
+--error ER_PARTITION_WRONG_VALUES_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1266,7 +1297,7 @@ partitions 2
#
# Partition by range, maxvalue in wrong place
#
---error 1064
+--error ER_PARTITION_MAXVALUE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1280,7 +1311,7 @@ partitions 2
#
# Partition by range, maxvalue in several places
#
---error 1064
+--error ER_PARTITION_MAXVALUE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1322,7 +1353,7 @@ partitions 2
#
# Subpartition by hash, wrong number of subpartitions
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1342,7 +1373,7 @@ subpartitions 3
#
# Subpartition by hash, wrong number of subpartitions
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1362,7 +1393,7 @@ subpartition by hash (a+b)
#
# Subpartition by list => error
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1381,7 +1412,7 @@ subpartition by list (a+b)
#
# Subpartition by list => error
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1425,7 +1456,7 @@ partitions 2
#
# Partition by list, invalid field in function
#
---error 1054
+--error ER_BAD_FIELD_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1495,7 +1526,7 @@ partitions 2
#
# Partition by list, wrong constant result type (not INT)
#
---error 1064
+--error ER_VALUES_IS_NOT_INT_TYPE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1509,7 +1540,7 @@ partitions 2
#
# Partition by list, missing parenthesis
#
---error 1064
+--error ER_PARSE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
@@ -1523,7 +1554,7 @@ partitions 2
#
# Bug #13439: Crash when LESS THAN (non-literal)
#
---error 1054
+--error ER_BAD_FIELD_ERROR
CREATE TABLE t1 (a int)
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (x1));
@@ -1550,13 +1581,13 @@ partition by range (ascii(v))
(partition p0 values less than (10));
#drop table t1;
--- error 1064
+-- error ER_PARSE_ERROR
create table t1 (a int)
partition by hash (rand(a));
--- error 1064
+-- error ER_PARSE_ERROR
create table t1 (a int)
partition by hash(CURTIME() + a);
--- error 1064
+-- error ER_PARSE_ERROR
create table t1 (a int)
partition by hash (NOW()+a);
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
@@ -1585,13 +1616,13 @@ PARTITION pmax VALUES LESS THAN MAXVALUE);
# Check that allowed arithmetic/math functions involving TIMESTAMP values result
# in ER_PARTITION_FUNC_NOT_ALLOWED_ERROR when used as a partitioning function
---error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE new (a TIMESTAMP NOT NULL PRIMARY KEY)
PARTITION BY RANGE (a) (
PARTITION p VALUES LESS THAN (20080819),
PARTITION pmax VALUES LESS THAN MAXVALUE);
---error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
+--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
ALTER TABLE old
PARTITION BY RANGE (a) (
PARTITION p VALUES LESS THAN (20080819),
diff --git a/mysql-test/t/partition_innodb-master.opt b/mysql-test/t/partition_innodb-master.opt
deleted file mode 100644
index 462f8fbe828..00000000000
--- a/mysql-test/t/partition_innodb-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---innodb_lock_wait_timeout=1
diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
index dc8bcbb4cb9..cd371a8f79a 100644
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@ -1,3 +1,4 @@
+--source include/not_embedded.inc
--source include/have_partition.inc
--source include/have_innodb.inc
@@ -10,6 +11,7 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
--echo # Bug#56287: crash when using Partition datetime in sub in query
--echo #
+
CREATE TABLE t1
(c1 bigint(20) unsigned NOT NULL AUTO_INCREMENT,
c2 varchar(40) not null default '',
@@ -31,6 +33,109 @@ SELECT count(*) FROM t1 p where c3 in
DROP TABLE t1;
+
+--echo #
+--echo # Bug#54747: Deadlock between REORGANIZE PARTITION and
+--echo # SELECT is not detected
+--echo #
+
+SET @old_innodb_thread_concurrency:= @@innodb_thread_concurrency;
+SET GLOBAL innodb_thread_concurrency = 1;
+
+CREATE TABLE t1
+(user_num BIGINT,
+ hours SMALLINT,
+ KEY user_num (user_num))
+ENGINE = InnoDB
+PARTITION BY RANGE COLUMNS (hours)
+(PARTITION hour_003 VALUES LESS THAN (3),
+ PARTITION hour_004 VALUES LESS THAN (4),
+ PARTITION hour_005 VALUES LESS THAN (5),
+ PARTITION hour_last VALUES LESS THAN (MAXVALUE));
+
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+
+BEGIN;
+SELECT COUNT(*) FROM t1;
+
+--echo # con1
+--connect (con1,localhost,root,,)
+--echo # SEND a ALTER PARTITION which waits on the ongoing transaction.
+--send
+ALTER TABLE t1
+REORGANIZE PARTITION hour_003, hour_004 INTO
+(PARTITION oldest VALUES LESS THAN (4));
+
+--echo # Connection default wait until the ALTER is in 'waiting for table...'
+--echo # state and then continue the transaction by trying a SELECT
+--connection default
+let $wait_condition =
+SELECT COUNT(*) = 1
+FROM information_schema.processlist
+WHERE INFO like 'ALTER TABLE t1%REORGANIZE PARTITION hour_003, hour_004%'
+AND STATE = 'Waiting for table metadata lock';
+--source include/wait_condition.inc
+SELECT COUNT(*) FROM t1;
+COMMIT;
+
+--echo # con1, reaping ALTER.
+--connection con1
+--reap
+
+--echo # Disconnecting con1 and switching to default. Cleaning up.
+--disconnect con1
+
+--connection default
+
+SET GLOBAL innodb_thread_concurrency = @old_innodb_thread_concurrency;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#50418: DROP PARTITION does not interact with transactions
+--echo #
+CREATE TABLE t1 (
+ id INT AUTO_INCREMENT NOT NULL,
+ name CHAR(50) NOT NULL,
+ myDate DATE NOT NULL,
+ PRIMARY KEY (id, myDate),
+ INDEX idx_date (myDate)
+ ) ENGINE=InnoDB
+PARTITION BY RANGE ( TO_DAYS(myDate) ) (
+ PARTITION p0 VALUES LESS THAN (734028),
+ PARTITION p1 VALUES LESS THAN (734029),
+ PARTITION p2 VALUES LESS THAN (734030),
+ PARTITION p3 VALUES LESS THAN MAXVALUE
+ ) ;
+INSERT INTO t1 VALUES
+(NULL, 'Lachlan', '2009-09-13'),
+ (NULL, 'Clint', '2009-09-13'),
+ (NULL, 'John', '2009-09-14'),
+ (NULL, 'Dave', '2009-09-14'),
+ (NULL, 'Jeremy', '2009-09-15'),
+ (NULL, 'Scott', '2009-09-15'),
+ (NULL, 'Jeff', '2009-09-16'),
+ (NULL, 'Joe', '2009-09-16');
+SET AUTOCOMMIT=0;
+SELECT * FROM t1 FOR UPDATE;
+UPDATE t1 SET name = 'Mattias' WHERE id = 7;
+SELECT * FROM t1 WHERE id = 7;
+--connect (con1, localhost, root,,)
+--echo # Connection con1
+SET lock_wait_timeout = 1;
+--echo # After the patch it will wait and fail on timeout.
+--error ER_LOCK_WAIT_TIMEOUT
+ALTER TABLE t1 DROP PARTITION p3;
+SHOW WARNINGS;
+--disconnect con1
+--connection default
+--echo # Connection default
+SELECT * FROM t1;
+--echo # No changes.
+COMMIT;
+DROP TABLE t1;
+
+
--echo #
--echo # Bug#51830: Incorrect partition pruning on range partition (regression)
--echo #
@@ -91,6 +196,51 @@ ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2
DROP TABLE t1, t2;
#
+# BUG#47774, Assertion failure in InnoDB using column list partitioning
+#
+create table t1 (a varchar(5), b int signed, c varchar(10), d datetime)
+partition by range columns(b,c)
+subpartition by hash(to_seconds(d))
+( partition p0 values less than (2, 'b'),
+ partition p1 values less than (4, 'd'),
+ partition p2 values less than (10, 'za'));
+insert into t1 values ('a', 3, 'w', '2001-10-27 04:34:00');
+insert into t1 values ('r', 7, 'w', '2001-10-27 05:34:00');
+insert into t1 values ('g', 10, 'w', '2001-10-27 06:34:00');
+update t1 set a = 'c' where a > 'f';
+drop table t1;
+
+#
+# BUG#47776, Failed to update for MEMORY engine, crash for InnoDB and success for MyISAM
+#
+create table t1 (a varchar(5))
+engine=memory
+partition by range columns(a)
+( partition p0 values less than ('m'),
+ partition p1 values less than ('za'));
+insert into t1 values ('j');
+update t1 set a = 'z' where (a >= 'j');
+drop table t1;
+
+create table t1 (a varchar(5))
+engine=myisam
+partition by range columns(a)
+( partition p0 values less than ('m'),
+ partition p1 values less than ('za'));
+insert into t1 values ('j');
+update t1 set a = 'z' where (a >= 'j');
+drop table t1;
+
+create table t1 (a varchar(5))
+engine=innodb
+partition by range columns(a)
+( partition p0 values less than ('m'),
+ partition p1 values less than ('za'));
+insert into t1 values ('j');
+update t1 set a = 'z' where (a >= 'j');
+drop table t1;
+
+#
# Bug#47029: Crash when reorganize partition with subpartition
#
create table t1 (a int not null,
@@ -127,17 +277,21 @@ SET autocommit = 0;
UPDATE t1 SET DATA = data*2 WHERE id = 3;
+# SHOW ENGINE InnoDB STATUS does not show transaction info in
+# PERFORMANCE-VERSION
# grouping/referencing in replace_regex is very slow on long strings,
# removing all before/after the interesting row before grouping/referencing
---replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
-SHOW ENGINE InnoDB STATUS;
+#--replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+) lock struct\(s\), heap size [0-9]+, ([0-9]+) row lock\(s\).*/\1 lock struct(s) \2 row lock(s)/
+#SHOW ENGINE InnoDB STATUS;
UPDATE t1 SET data = data*2 WHERE data = 2;
+# SHOW ENGINE InnoDB STATUS does not show transaction info in
+# PERFORMANCE-VERSION
# grouping/referencing in replace_regex is very slow on long strings,
# removing all before/after the interesting row before grouping/referencing
---replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
-SHOW ENGINE InnoDB STATUS;
+#--replace_regex /.*---TRANSACTION [0-9]+ [0-9]+, .*, OS thread id [0-9]+// /MySQL thread id [0-9]+, query id [0-9]+ .*// /.*([0-9]+ lock struct\(s\)), heap size [0-9]+, ([0-9]+ row lock\(s\)).*/\1 \2/
+#SHOW ENGINE InnoDB STATUS;
SET @@session.tx_isolation = @old_tx_isolation;
@@ -286,7 +440,6 @@ engine = innodb
partition by list (a)
(partition p0 values in (0));
--- error ER_MIX_HANDLER_ERROR
alter table t1 engine = x;
show create table t1;
drop table t1;
@@ -385,6 +538,7 @@ DROP TABLE t1;
# Before the fix it should show extra file like #sql-2405_2.par
--list_files $MYSQLD_DATADIR/test/ *
+--disable_parsing
--echo #
--echo # Bug#47343: InnoDB fails to clean-up after lock wait timeout on
--echo # REORGANIZE PARTITION
@@ -438,3 +592,42 @@ INSERT INTO t1 VALUES (1,1), (2,2);
SELECT * FROM t1 WHERE i1 = ( SELECT i1 FROM t1 WHERE f1=0 LIMIT 1 );
DROP TABLE t1;
+
+--enable_parsing
+
+--echo #
+--echo # Bug#54783: optimize table crashes with invalid timestamp default value and NO_ZERO_DATE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b TIMESTAMP DEFAULT '0000-00-00 00:00:00')
+ ENGINE=INNODB PARTITION BY LINEAR HASH (a) PARTITIONS 1;
+SET @old_mode = @@sql_mode;
+SET SESSION sql_mode = 'NO_ZERO_DATE';
+OPTIMIZE TABLE t1;
+SET SESSION sql_mode = @old_mode;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#57985 "ONLINE/FAST ALTER PARTITION can fail and leave the
+--echo # table unusable".
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a bigint not null, b int not null, PRIMARY KEY (a))
+ ENGINE = InnoDB PARTITION BY KEY(a) PARTITIONS 2;
+INSERT INTO t1 values (0,1), (1,2);
+--echo # The below ALTER should fail. It should leave the
+--echo # table in its original, non-corrupted, usable state.
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+ALTER TABLE t1 ADD UNIQUE KEY (b);
+--echo # The below statements should succeed, as ALTER should
+--echo # have left table intact.
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/partition_innodb_builtin.test b/mysql-test/t/partition_innodb_builtin.test
deleted file mode 100644
index a9be41c7455..00000000000
--- a/mysql-test/t/partition_innodb_builtin.test
+++ /dev/null
@@ -1,67 +0,0 @@
---source include/have_partition.inc
---source include/have_innodb.inc
---source include/have_not_innodb_plugin.inc
-
-#
-# Bug#32430 - show engine innodb status causes errors
-#
-SET NAMES utf8;
-CREATE TABLE `t``\""e` (a INT, PRIMARY KEY (a))
-ENGINE=InnoDB
-PARTITION BY RANGE (a)
-SUBPARTITION BY HASH (a)
-(PARTITION `p0``\""e` VALUES LESS THAN (100)
- (SUBPARTITION `sp0``\""e`,
- SUBPARTITION `sp1``\""e`),
- PARTITION `p1``\""e` VALUES LESS THAN (MAXVALUE)
- (SUBPARTITION `sp2``\""e`,
- SUBPARTITION `sp3``\""e`));
-INSERT INTO `t``\""e` VALUES (0), (2), (6), (10), (14), (18), (22);
-START TRANSACTION;
---echo # con1
-connect(con1,localhost,root,,);
-SET NAMES utf8;
-START TRANSACTION;
---echo # default connection
-connection default;
-UPDATE `t``\""e` SET a = 16 WHERE a = 0;
---echo # con1
-connection con1;
-UPDATE `t``\""e` SET a = 8 WHERE a = 22;
-let $id_1= `SELECT CONNECTION_ID()`;
-SEND;
-UPDATE `t``\""e` SET a = 12 WHERE a = 0;
---echo # default connection
-connection default;
-let $wait_timeout= 2;
-let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
-WHERE ID = $id_1 AND STATE = 'Searching rows for update';
---source include/wait_condition.inc
-#--echo # tested wait condition $wait_condition_reps times
---error ER_LOCK_DEADLOCK
-UPDATE `t``\""e` SET a = 4 WHERE a = 22;
---echo # First table reported in 'SHOW ENGINE InnoDB STATUS'
-# RECORD LOCKS space id 0 page no 50 n bits 80 index `PRIMARY` in \
-# Database `test`, Table `t1`, Partition `p0`, Subpartition `sp0` \
-# trx id 0 775
-# NOTE: replace_regex is very slow on match copy/past '(.*)' regex's
-# on big texts, removing a lot of text before + after makes it much faster.
-#/.*in (.*) trx.*/\1/
---replace_regex /.*RECORD LOCKS space id [0-9]* page no [0-9]* n bits [0-9]* // / trx id .*// /.*index .* in //
-SHOW ENGINE InnoDB STATUS;
-set @old_sql_mode = @@sql_mode;
-set sql_mode = 'ANSI_QUOTES';
-# INNODB_LOCKS only exists in innodb_plugin
-#SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS;
---replace_regex /.*RECORD LOCKS space id [0-9]* page no [0-9]* n bits [0-9]* // / trx id .*// /.*index .* in //
-SHOW ENGINE InnoDB STATUS;
-set @@sql_mode = @old_sql_mode;
---echo # con1
-connection con1;
-REAP;
-ROLLBACK;
-disconnect con1;
---echo # default connection
-connection default;
-DROP TABLE `t``\""e`;
-SET NAMES DEFAULT;
diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test
index 626e5d19b99..e8b73687177 100644
--- a/mysql-test/t/partition_innodb_plugin.test
+++ b/mysql-test/t/partition_innodb_plugin.test
@@ -1,7 +1,5 @@
--source include/have_partition.inc
---source include/have_innodb_plugin.inc
-# Remove the line below when bug#53307 is solved.
---source include/not_valgrind.inc
+--source include/have_innodb.inc
let $MYSQLD_DATADIR= `SELECT @@datadir`;
@@ -9,7 +7,7 @@ call mtr.add_suppression("nnoDB: Error: table `test`.`t1` .* Partition.* InnoDB
--echo #
--echo # Bug#55091: Server crashes on ADD PARTITION after a failed attempt
--echo #
-SET @old_innodb_file_format_check = @@global.innodb_file_format_check;
+SET @old_innodb_file_format_max = @@global.innodb_file_format_max;
SET @old_innodb_file_format = @@global.innodb_file_format;
SET @old_innodb_file_per_table = @@global.innodb_file_per_table;
SET @old_innodb_strict_mode = @@global.innodb_strict_mode;
@@ -68,7 +66,7 @@ DROP TABLE t1;
SET @@global.innodb_strict_mode = @old_innodb_strict_mode;
SET @@global.innodb_file_format = @old_innodb_file_format;
SET @@global.innodb_file_per_table = @old_innodb_file_per_table;
-SET @@global.innodb_file_format_check = @old_innodb_file_format_check;
+SET @@global.innodb_file_format_max = @old_innodb_file_format_max;
#
# Bug#32430 - show engine innodb status causes errors
diff --git a/mysql-test/t/partition_innodb_semi_consistent-master.opt b/mysql-test/t/partition_innodb_semi_consistent-master.opt
index e76299453d3..9655b180fbd 100644
--- a/mysql-test/t/partition_innodb_semi_consistent-master.opt
+++ b/mysql-test/t/partition_innodb_semi_consistent-master.opt
@@ -1 +1 @@
---innodb_lock_wait_timeout=2
+--innodb_lock_wait_timeout=2 --default-storage-engine=MyISAM
diff --git a/mysql-test/t/partition_innodb_semi_consistent.test b/mysql-test/t/partition_innodb_semi_consistent.test
index 2711d79f194..7f6b3d48c63 100644
--- a/mysql-test/t/partition_innodb_semi_consistent.test
+++ b/mysql-test/t/partition_innodb_semi_consistent.test
@@ -31,6 +31,7 @@ set session transaction isolation level repeatable read;
set autocommit=0;
-- error ER_LOCK_WAIT_TIMEOUT
update t1 set a=10 where a=5;
+commit;
connection a;
#DELETE FROM t1 WHERE a=5;
commit;
@@ -101,6 +102,7 @@ connection con2;
--error ER_LOCK_WAIT_TIMEOUT
UPDATE t1 SET b = 21 WHERE a = 1;
--disable_info
+ROLLBACK;
--echo # Switch to connection con1
connection con1;
@@ -150,6 +152,7 @@ SELECT * FROM t1;
connection con2;
--reap
SELECT * FROM t1;
+COMMIT;
--echo # Switch to connection con1
connection con1;
@@ -157,7 +160,7 @@ connection con1;
--echo # 3. test for updated key column:
TRUNCATE t1;
-TRUNCATE t2;
+DELETE FROM t2;
INSERT INTO t1 VALUES (1,'init');
diff --git a/mysql-test/t/partition_innodb_stmt.test b/mysql-test/t/partition_innodb_stmt.test
index d6181ce068e..c6f30f41969 100644
--- a/mysql-test/t/partition_innodb_stmt.test
+++ b/mysql-test/t/partition_innodb_stmt.test
@@ -50,7 +50,7 @@ connection con1;
--echo # connection con1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
---error ER_BINLOG_LOGGING_IMPOSSIBLE
+--error ER_BINLOG_STMT_MODE_AND_ROW_ENGINE
INSERT INTO t1 VALUES(9);
COMMIT;
diff --git a/mysql-test/t/partition_key_cache.test b/mysql-test/t/partition_key_cache.test
new file mode 100644
index 00000000000..4beb9506b05
--- /dev/null
+++ b/mysql-test/t/partition_key_cache.test
@@ -0,0 +1,251 @@
+# Test of key cache with partitions
+--source include/have_partition.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, v, x;
+--enable_warnings
+
+--echo # Actual test of key caches
+--echo # Verifing that reads/writes use the key cache correctly
+SELECT @org_key_cache_buffer_size:= @@global.default.key_buffer_size;
+--echo # Minimize default key cache (almost disabled).
+SET @@global.default.key_buffer_size = 4096;
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b))
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p0 VALUES LESS THAN (1167602410)
+ (SUBPARTITION sp0,
+ SUBPARTITION sp1),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp2,
+ SUBPARTITION sp3));
+CREATE TABLE t2 (
+ a INT,
+ b INT,
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b));
+FLUSH TABLES;
+FLUSH STATUS;
+
+# Genereate 4096 rows. Idea from:
+# http://datacharmer.blogspot.com/2007/12/data-from-nothing-solution-to-pop-quiz.html
+SET @a:=1167602400;
+CREATE VIEW v AS SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4;
+CREATE VIEW x AS SELECT 1 FROM v,v a,v b;
+# due to I_S performance, this was substituted with include files which
+# uses SHOW STATUS
+#DELIMITER |;
+#CREATE PROCEDURE was_zero_reads()
+#BEGIN
+# SELECT IF(VARIABLE_VALUE = 0,"Yes!","No!") as 'Was zero reads?'
+# FROM INFORMATION_SCHEMA.SESSION_STATUS
+# WHERE VARIABLE_NAME = 'KEY_READS';
+# FLUSH STATUS;
+#END|
+#DELIMITER ;|
+
+FLUSH STATUS;
+INSERT t1 SELECT @a, @a * (1 - ((@a % 2) * 2)) , 1167612400 - (@a:=@a+1) FROM x, x y;
+--source include/check_key_req.inc
+--echo # row distribution:
+SELECT PARTITION_NAME, SUBPARTITION_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA='test' and TABLE_NAME='t1';
+DROP VIEW x;
+DROP VIEW v;
+FLUSH TABLES;
+FLUSH STATUS;
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+INSERT t2 SELECT a,b,c FROM t1;
+--source include/check_key_req.inc
+FLUSH STATUS;
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+FLUSH TABLES;
+--echo # Setting the default key cache to 1M
+SET GLOBAL key_buffer_size = 1024*1024;
+FLUSH STATUS;
+--echo # All these have to read the indexes
+LOAD INDEX INTO CACHE t1 PARTITION (p1);
+--source include/check_key_reads.inc
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+--echo # All these should be able to use the key cache
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+FLUSH TABLES;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,p0);
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+LOAD INDEX INTO CACHE t2;
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+FLUSH TABLES;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,p0) IGNORE LEAVES;
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t1 WHERE b >= 0;
+--source include/check_key_reads.inc
+LOAD INDEX INTO CACHE t2 IGNORE LEAVES;
+--source include/check_key_reads.inc
+--echo # should not be zero
+SELECT COUNT(b) FROM t2 WHERE b >= 0;
+--source include/check_key_reads.inc
+TRUNCATE TABLE t2;
+INSERT t2 SELECT a,b,c FROM t1;
+--source include/check_key_req.inc
+DROP TABLE t1,t2;
+
+SET GLOBAL hot_cache.key_buffer_size = 1024*1024;
+SET GLOBAL warm_cache.key_buffer_size = 1024*1024;
+SET @@global.cold_cache.key_buffer_size = 1024*1024;
+SELECT @@global.default.key_buffer_size a, @@global.default.key_cache_block_size b, @@global.default.key_cache_age_threshold c, @@global.default.key_cache_division_limit d;
+SELECT @@global.hot_cache.key_buffer_size a, @@global.hot_cache.key_cache_block_size b, @@global.hot_cache.key_cache_age_threshold c, @@global.hot_cache.key_cache_division_limit d;
+SELECT @@global.warm_cache.key_buffer_size a, @@global.warm_cache.key_cache_block_size b, @@global.warm_cache.key_cache_age_threshold c, @@global.warm_cache.key_cache_division_limit d;
+SELECT @@global.cold_cache.key_buffer_size a, @@global.cold_cache.key_cache_block_size b, @@global.cold_cache.key_cache_age_threshold c, @@global.cold_cache.key_cache_division_limit d;
+CREATE TABLE t1 (
+ a INT,
+ b VARCHAR(257),
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b),
+ KEY `inx_c`(c))
+PARTITION BY RANGE (a)
+SUBPARTITION BY HASH (a)
+(PARTITION p0 VALUES LESS THAN (10)
+ (SUBPARTITION sp0,
+ SUBPARTITION sp1),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp2,
+ SUBPARTITION sp3));
+CREATE TABLE t2 (
+ a INT,
+ b VARCHAR(257),
+ c INT NOT NULL,
+ PRIMARY KEY (a),
+ KEY `inx_b` (b),
+ KEY `inx_c`(c));
+SET @a:=1167602400;
+# Genereate 4096 rows. Idea from:
+# http://datacharmer.blogspot.com/2007/12/data-from-nothing-solution-to-pop-quiz.html
+CREATE VIEW v AS SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4;
+CREATE VIEW x AS SELECT 1 FROM v,v a,v b;
+INSERT t1 SELECT @a, CONCAT('X_', @a, ' MySQL'), 1167612400 - (@a:=@a+1) FROM x, x a;
+DROP VIEW x;
+DROP VIEW v;
+INSERT t2 SELECT a, b, c FROM t1;
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t2;
+FLUSH TABLES;
+
+--echo # Restrict partitioned commands to partitioned tables only
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (p0,`p1`) INDEX (`PRIMARY`) IN hot_cache;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (`p1`) INDEX (`PRIMARY`,`inx_b`) IN hot_cache;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (ALL) KEY (`inx_b`,`PRIMARY`) IN hot_cache;
+--echo # Basic key cache testing
+--echo # The manual correctly says: "The syntax of CACHE INDEX enables you to
+--echo # specify that only particular indexes from a table should be assigned
+--echo # to the cache. The current implementation assigns all the table's
+--echo # indexes to the cache, so there is no reason to specify anything
+--echo # other than the table name."
+--echo # So the most of the test only tests the syntax
+CACHE INDEX t2 INDEX (`inx_b`) IN hot_cache;
+CACHE INDEX t2 KEY (`PRIMARY`) IN warm_cache;
+CACHE INDEX t2 KEY (`PRIMARY`,`inx_b`) IN cold_cache;
+CACHE INDEX t2 INDEX (inx_b,`PRIMARY`) IN default;
+CACHE INDEX t1 PARTITION (p0) KEY (`inx_b`) IN cold_cache;
+--error ER_PARSE_ERROR
+CACHE INDEX t1 PARTITIONS (p0) KEY (`inx_b`) IN cold_cache;
+--echo # only one table at a time if specifying partitions
+--error ER_PARSE_ERROR
+CACHE INDEX t1,t2 PARTITION (p0) KEY (`inx_b`) IN cold_cache;
+CACHE INDEX t1 PARTITION (`p0`,p1) INDEX (`PRIMARY`) IN warm_cache;
+CACHE INDEX t1 PARTITION (`p1`) INDEX (`PRIMARY`,inx_b) IN hot_cache;
+CACHE INDEX t1 PARTITION (ALL) KEY (`inx_b`,`PRIMARY`) IN default;
+CACHE INDEX t1 PARTITION (ALL) IN hot_cache;
+CACHE INDEX t1 INDEX (`inx_b`) IN default;
+CACHE INDEX t1 KEY (`PRIMARY`) IN hot_cache;
+CACHE INDEX t1 KEY (`PRIMARY`,`inx_b`) IN warm_cache;
+CACHE INDEX t1 INDEX (`inx_b`,`PRIMARY`) IN cold_cache;
+CACHE INDEX t1 IN hot_cache;
+--echo # Test of non existent key cache:
+--error ER_UNKNOWN_KEY_CACHE
+CACHE INDEX t1 IN non_existent_key_cache;
+--echo # Basic testing of LOAD INDEX
+LOAD INDEX INTO CACHE t2;
+--echo # PRIMARY and secondary keys have different block sizes
+LOAD INDEX INTO CACHE t2 ignore leaves;
+--echo # Must have INDEX or KEY before the index list
+--error ER_PARSE_ERROR
+LOAD INDEX INTO CACHE t2 (`PRIMARY`);
+
+--echo # Test of IGNORE LEAVES
+LOAD INDEX INTO CACHE t2 INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_b`) IGNORE LEAVES;
+CACHE INDEX t2 IN warm_cache;
+CACHE INDEX t1 IN cold_cache;
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`) IGNORE LEAVES;
+CACHE INDEX t2 INDEX (`inx_b`, `inx_c`) IN hot_cache;
+LOAD INDEX INTO CACHE t2 KEY (`inx_b`, `inx_c`) IGNORE LEAVES;
+CACHE INDEX t2 IN warm_cache;
+CACHE INDEX t2 INDEX (`PRIMARY`, `inx_c`) IN hot_cache;
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_c`) IGNORE LEAVES;
+CACHE INDEX t2 INDEX (`inx_b`,`PRIMARY`) IN default;
+LOAD INDEX INTO CACHE t2 KEY (`PRIMARY`,`inx_b`);
+CACHE INDEX t2 IN default;
+LOAD INDEX INTO CACHE t2 IGNORE LEAVES;
+
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+LOAD INDEX INTO CACHE t2 PARTITION (p1) INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t1, t2;
+--echo # only one table at a time if specifying partitions
+--error ER_PARSE_ERROR
+LOAD INDEX INTO CACHE t1 PARTITION (p0), t2;
+LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`,`inx_b`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`inx_b`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 INDEX (`PRIMARY`,`inx_b`);
+LOAD INDEX INTO CACHE t1 PARTITION (p1) INDEX (`PRIMARY`);
+LOAD INDEX INTO CACHE t1 PARTITION (`p1`,p0) KEY (`PRIMARY`) IGNORE LEAVES;
+LOAD INDEX INTO CACHE t1 PARTITION (ALL);
+--error ER_PARSE_ERROR
+LOAD INDEX INTO CACHE t1 PARTITIONS ALL;
+LOAD INDEX INTO CACHE t1 PARTITION (p1,`p0`) IGNORE LEAVES;
+DROP INDEX `inx_b` on t1;
+DROP INDEX `inx_b` on t2;
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+CACHE INDEX t2 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+CACHE INDEX t2 INDEX (`inx_b`) IN hot_cache;
+CACHE INDEX t1 PARTITION (p0) KEY (`inx_b`) IN hot_cache;
+CACHE INDEX t1 INDEX (`inx_b`) IN hot_cache;
+DROP TABLE t1,t2;
+SET GLOBAL hot_cache.key_buffer_size = 0;
+SET GLOBAL warm_cache.key_buffer_size = 0;
+SET @@global.cold_cache.key_buffer_size = 0;
+SELECT @@global.default.key_buffer_size a, @@global.default.key_cache_block_size b, @@global.default.key_cache_age_threshold c, @@global.default.key_cache_division_limit d;
+SELECT @@global.hot_cache.key_buffer_size a, @@global.hot_cache.key_cache_block_size b, @@global.hot_cache.key_cache_age_threshold c, @@global.hot_cache.key_cache_division_limit d;
+SELECT @@global.warm_cache.key_buffer_size a, @@global.warm_cache.key_cache_block_size b, @@global.warm_cache.key_cache_age_threshold c, @@global.warm_cache.key_cache_division_limit d;
+SELECT @@global.cold_cache.key_buffer_size a, @@global.cold_cache.key_cache_block_size b, @@global.cold_cache.key_cache_age_threshold c, @@global.cold_cache.key_cache_division_limit d;
+--disable_warnings
+SET @@global.default.key_buffer_size = @org_key_cache_buffer_size;
+--enable_warnings
diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test
index 1c76de9d55a..8d2ec88e0f4 100644
--- a/mysql-test/t/partition_list.test
+++ b/mysql-test/t/partition_list.test
@@ -40,6 +40,8 @@ subpartitions 2
partition p1 values in (1),
partition pnull values in (null, 2),
partition p3 values in (3));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1);
insert into t1 values (2,0),(2,1),(3,0),(3,1);
diff --git a/mysql-test/t/partition_mgm_err.test b/mysql-test/t/partition_mgm_err.test
index 0f8b8d3cd90..f921fa8ebca 100644
--- a/mysql-test/t/partition_mgm_err.test
+++ b/mysql-test/t/partition_mgm_err.test
@@ -61,7 +61,7 @@ ALTER TABLE t1 REORGANIZE PARTITION x0, x1, x1 INTO
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
(PARTITION x01 VALUES LESS THAN (5));
---error ER_REORG_OUTSIDE_RANGE
+--error ER_RANGE_NOT_INCREASING_ERROR
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
(PARTITION x01 VALUES LESS THAN (4),
PARTITION x11 VALUES LESS THAN (2));
diff --git a/mysql-test/t/partition_myisam.test b/mysql-test/t/partition_myisam.test
new file mode 100644
index 00000000000..c3766430275
--- /dev/null
+++ b/mysql-test/t/partition_myisam.test
@@ -0,0 +1,182 @@
+--source include/have_partition.inc
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+# These tests is only useful when running on MyISAM,
+# due to DATA/INDEX directory, non transactional behavior, tests with MyISAM
+# files etc.
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+
+--echo #
+--echo # Bug#50036: Inconsistent errors when using TIMESTAMP
+--echo # columns/expressions
+
+--echo # Added test with existing TIMESTAMP partitioning (when it was allowed).
+CREATE TABLE t1 (a TIMESTAMP)
+ENGINE = MyISAM
+PARTITION BY HASH (UNIX_TIMESTAMP(a));
+INSERT INTO t1 VALUES ('2000-01-02 03:04:05');
+--sorted_result
+SELECT * FROM t1;
+FLUSH TABLES;
+--echo # replacing t1.frm with TO_DAYS(a) which was allowed earlier.
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/parts/t1TIMESTAMP.frm $MYSQLD_DATADIR/test/t1.frm
+--echo # Disable warnings, since the result would differ when running with
+--echo # --ps-protocol (only for the 'SELECT * FROM t1' statement).
+--disable_warnings
+--sorted_result
+SELECT * FROM t1;
+--enable_warnings
+--replace_result MyISAM <curr_engine> InnoDB <curr_engine>
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('2001-02-03 04:05:06');
+--sorted_result
+SELECT * FROM t1;
+ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
+--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
+ALTER TABLE t1
+PARTITION BY RANGE (TO_DAYS(a))
+(PARTITION p0 VALUES LESS THAN (10000),
+ PARTITION p1 VALUES LESS THAN (MAXVALUE));
+SHOW CREATE TABLE t1;
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+CREATE TABLE t2 SELECT * FROM t1;
+DROP TABLE t2;
+ALTER TABLE t1 PARTITION BY HASH (UNIX_TIMESTAMP(a));
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
+SHOW CREATE TABLE t1;
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#31931: Mix of handlers error message
+--echo #
+--error ER_MIX_HANDLER_ERROR
+CREATE TABLE t1 (a INT)
+PARTITION BY HASH (a)
+( PARTITION p0 ENGINE=MyISAM,
+ PARTITION p1);
+--error ER_MIX_HANDLER_ERROR
+CREATE TABLE t1 (a INT)
+PARTITION BY LIST (a)
+SUBPARTITION BY HASH (a)
+( PARTITION p0 VALUES IN (0)
+( SUBPARTITION s0, SUBPARTITION s1 ENGINE=MyISAM, SUBPARTITION s2),
+ PARTITION p1 VALUES IN (1)
+( SUBPARTITION s3 ENGINE=MyISAM, SUBPARTITION s4, SUBPARTITION s5 ENGINE=MyISAM));
+
+--echo #
+--echo # Bug#49161: Out of memory; restart server and try again (needed 2 bytes)
+--echo #
+CREATE TABLE t1 (a INT)
+ENGINE = MyISAM
+PARTITION BY HASH (a);
+FLUSH TABLES;
+--remove_file $MYSQLD_DATADIR/test/t1.par
+--replace_result $MYSQLD_DATADIR ./
+CHECK TABLE t1;
+--error ER_FAILED_READ_FROM_PAR_FILE
+SELECT * FROM t1;
+--echo # Note that it is currently impossible to drop a partitioned table
+--echo # without the .par file
+--error ER_BAD_TABLE_ERROR
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+--remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYI
+--remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYD
+
+--echo #
+--echo # Bug#50392: insert_id is not reset for partitioned tables
+--echo # auto_increment on duplicate entry
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY)
+ENGINE = MyISAM;
+SET INSERT_ID= 13;
+INSERT INTO t1 VALUES (NULL);
+SET INSERT_ID= 12;
+--echo # For transactional engines, 12 will not be inserted, since the failing
+--echo # statement is rolled back.
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL);
+--echo # NOTE: 12 exists only in non transactional engines!
+SELECT * FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY)
+ENGINE = MyISAM
+PARTITION BY KEY(a);
+SET INSERT_ID= 13;
+INSERT INTO t1 VALUES (NULL);
+SET INSERT_ID= 12;
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (NULL);
+SELECT * FROM t1;
+DROP TABLE t1;
+#
+# Bug#30102: rename table does corrupt tables with partition files on failure
+#
+--echo # Bug#30102 test
+CREATE TABLE t1 (a INT)
+ENGINE = MyISAM
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (6),
+ PARTITION `p1....................` VALUES LESS THAN (9),
+ PARTITION p2 VALUES LESS THAN MAXVALUE);
+# partition p1 is 't1#P#p1' + @002e * 20 = 107 characters + file ending
+# total path lenght of './test/t1#P#p1@002e@002e<...>@002e.MY[ID]' is 118 chars
+--echo # List of files in database `test`, all original t1-files here
+--list_files $MYSQLD_DATADIR/test t1*
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+--echo # Renaming to a file name where the first partition is 250 chars
+--echo # and the second partition is 350 chars
+# 7,7 avoids the error message, which is not deterministic.
+--error 7,7
+RENAME TABLE t1 TO `t2_new..............................................end`;
+# 1234567890123456789012345678901234567890123456
+--echo # List of files in database `test`, should not be any t2-files here
+--list_files $MYSQLD_DATADIR/test t2*
+--echo # List of files in database `test`, should be all t1-files here
+--list_files $MYSQLD_DATADIR/test t1*
+--sorted_result
+SELECT * FROM t1;
+--echo # List of files in database `test`, should be all t1-files here
+--list_files $MYSQLD_DATADIR/test t1*
+--echo # Renaming to a file name where the first partition is 156 chars
+--echo # and the second partition is 256 chars
+# 7,7 avoids the error message, which is not deterministic.
+--error 7,7
+RENAME TABLE t1 TO `t2_............................_end`;
+# 1234567890123456789012345678
+# 7 + 4 + 5 + 28 * 5 = 16 + 140 = 156
+--echo # List of files in database `test`, should not be any t2-files here
+--list_files $MYSQLD_DATADIR/test t2*
+--echo # List of files in database `test`, should be all t1-files here
+--list_files $MYSQLD_DATADIR/test t1*
+--sorted_result
+SELECT * FROM t1;
+DROP TABLE t1;
+--echo # Should not be any files left here
+--list_files $MYSQLD_DATADIR/test t1*
+--list_files $MYSQLD_DATADIR/test t2*
+--echo # End of bug#30102 test.
+
+--echo # Test of post-push fix for bug#11766249/59316
+CREATE TABLE t1 (a INT, b VARCHAR(255), PRIMARY KEY (a))
+ENGINE = MyISAM
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (0) MAX_ROWS=100,
+ PARTITION p1 VALUES LESS THAN (100) MAX_ROWS=100,
+ PARTITION pMax VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (1, "Partition p1, first row");
+DROP TABLE t1;
diff --git a/mysql-test/t/partition_not_embedded.test b/mysql-test/t/partition_not_embedded.test
deleted file mode 100644
index 5c512085a9e..00000000000
--- a/mysql-test/t/partition_not_embedded.test
+++ /dev/null
@@ -1,53 +0,0 @@
--- source include/have_partition.inc
--- source include/not_embedded.inc
---disable_warnings
-DROP TABLE IF EXISTS t1, t2;
---enable_warnings
-let $MYSQLD_DATADIR= `SELECT @@datadir`;
-
-#
-# Bug#30102: rename table does corrupt tables with partition files on failure
-#
---echo # Bug#30102 test
-CREATE TABLE t1 (a INT)
-PARTITION BY RANGE (a)
-(PARTITION p0 VALUES LESS THAN (6),
- PARTITION `p1....................` VALUES LESS THAN (9),
- PARTITION p2 VALUES LESS THAN MAXVALUE);
-# partition p1 is 't1#P#p1' + @002e * 20 = 107 characters + file ending
-# total path lenght of './test/t1#P#p1@002e@002e<...>@002e.MY[ID]' is 118 chars
---echo # List of files in database `test`, all original t1-files here
---list_files $MYSQLD_DATADIR/test t1*
-INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
---echo # Renaming to a file name where the first partition is 250 chars
---echo # and the second partition is 350 chars
-# 7,7 avoids the error message, which is not deterministic.
---error 7,7
-RENAME TABLE t1 TO `t2_new..............................................end`;
-# 1234567890123456789012345678901234567890123456
---echo # List of files in database `test`, should not be any t2-files here
---list_files $MYSQLD_DATADIR/test t2*
---echo # List of files in database `test`, should be all t1-files here
---list_files $MYSQLD_DATADIR/test t1*
---sorted_result
-SELECT * FROM t1;
---echo # List of files in database `test`, should be all t1-files here
---list_files $MYSQLD_DATADIR/test t1*
---echo # Renaming to a file name where the first partition is 156 chars
---echo # and the second partition is 256 chars
-# 7,7 avoids the error message, which is not deterministic.
---error 7,7
-RENAME TABLE t1 TO `t2_............................_end`;
-# 1234567890123456789012345678
-# 7 + 4 + 5 + 28 * 5 = 16 + 140 = 156
---echo # List of files in database `test`, should not be any t2-files here
---list_files $MYSQLD_DATADIR/test t2*
---echo # List of files in database `test`, should be all t1-files here
---list_files $MYSQLD_DATADIR/test t1*
---sorted_result
-SELECT * FROM t1;
-DROP TABLE t1;
---echo # Should not be any files left here
---list_files $MYSQLD_DATADIR/test t1*
---list_files $MYSQLD_DATADIR/test t2*
---echo # End of bug#30102 test.
diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test
index db544d4643f..f2ca16b9259 100644
--- a/mysql-test/t/partition_pruning.test
+++ b/mysql-test/t/partition_pruning.test
@@ -235,6 +235,26 @@ INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'),
ALTER TABLE t1 DROP KEY a;
--source include/partition_date_range.inc
DROP TABLE t1;
+--echo # TO_SECONDS, test of LIST and index
+CREATE TABLE t1 (a DATE, KEY(a))
+PARTITION BY LIST (TO_SECONDS(a))
+(PARTITION `p0001-01-01` VALUES IN (TO_SECONDS('0001-01-01')),
+ PARTITION `p2001-01-01` VALUES IN (TO_SECONDS('2001-01-01')),
+ PARTITION `pNULL` VALUES IN (NULL),
+ PARTITION `p0000-01-02` VALUES IN (TO_SECONDS('0000-01-02')),
+ PARTITION `p1001-01-01` VALUES IN (TO_SECONDS('1001-01-01')));
+if ($verify_without_partitions)
+{
+ALTER TABLE t1 REMOVE PARTITIONING;
+}
+INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'),
+ ('1001-00-00'), ('1001-01-01'), ('1002-00-00'), ('2001-01-01');
+--source include/partition_date_range.inc
+--echo # test without index
+ALTER TABLE t1 DROP KEY a;
+--source include/partition_date_range.inc
+DROP TABLE t1;
+
#
# Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
@@ -1371,3 +1391,22 @@ INSERT INTO t1 VALUES ('2006-03-01 12:00:00');
-- echo must use p0 only:
explain partitions select * from t1 where recdate < '2006-01-01 00:00:00';
drop table t1;
+
+-- echo #
+-- echo # BUG#33730 Full table scan instead selected partitions for query more than 10 partitions
+-- echo #
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int)
+ partition by range(a+0) (
+ partition p0 values less than (64),
+ partition p1 values less than (128),
+ partition p2 values less than (255)
+);
+insert into t1 select A.a + 10*B.a from t0 A, t0 B;
+
+# this will use interval_via_walking
+explain partitions select * from t1 where a between 10 and 13;
+explain partitions select * from t1 where a between 10 and 10+33;
+
+drop table t0, t1;
diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test
index f386fac4998..3ff03248d88 100644
--- a/mysql-test/t/partition_range.test
+++ b/mysql-test/t/partition_range.test
@@ -28,6 +28,91 @@ EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a;
DROP TABLE t1;
#
+#BUG#49591, Add proper version number to SHOW CREATE TABLE
+#
+create table t1 (a DATETIME)
+partition by range (TO_DAYS(a))
+subpartition by hash(to_seconds(a))
+(partition p0 values less than (1));
+show create table t1;
+drop table t1;
+
+--error ER_NULL_IN_VALUES_LESS_THAN
+create table t1 (a int)
+partition by range (a)
+( partition p0 values less than (NULL),
+ partition p1 values less than (MAXVALUE));
+#
+# Merge fix of bug#27927 for TO_SECONDS function
+#
+create table t1 (a datetime not null)
+partition by range (TO_SECONDS(a))
+( partition p0 VALUES LESS THAN (TO_SECONDS('2007-03-08 00:00:00')),
+ partition p1 VALUES LESS THAN (TO_SECONDS('2007-04-01 00:00:00')));
+select partition_method, partition_expression, partition_description
+ from information_schema.partitions where table_name = "t1";
+INSERT INTO t1 VALUES ('2007-03-01 12:00:00'), ('2007-03-07 12:00:00');
+INSERT INTO t1 VALUES ('2007-03-08 12:00:00'), ('2007-03-15 12:00:00');
+explain partitions select * from t1 where a < '2007-03-08 00:00:00';
+explain partitions select * from t1 where a < '2007-03-08 00:00:01';
+explain partitions select * from t1 where a <= '2007-03-08 00:00:00';
+explain partitions select * from t1 where a <= '2007-03-07 23:59:59';
+explain partitions select * from t1 where a < '2007-03-07 23:59:59';
+show create table t1;
+drop table t1;
+#
+# New test cases for new function to_seconds
+#
+create table t1 (a date)
+partition by range(to_seconds(a))
+(partition p0 values less than (to_seconds('2004-01-01')),
+ partition p1 values less than (to_seconds('2005-01-01')));
+insert into t1 values ('2003-12-30'),('2004-12-31');
+select * from t1;
+explain partitions select * from t1 where a <= '2003-12-31';
+select * from t1 where a <= '2003-12-31';
+explain partitions select * from t1 where a <= '2005-01-01';
+select * from t1 where a <= '2005-01-01';
+show create table t1;
+drop table t1;
+
+create table t1 (a datetime)
+partition by range(to_seconds(a))
+(partition p0 values less than (to_seconds('2004-01-01 12:00:00')),
+ partition p1 values less than (to_seconds('2005-01-01 12:00:00')));
+insert into t1 values ('2004-01-01 11:59:29'),('2005-01-01 11:59:59');
+select * from t1;
+explain partitions select * from t1 where a <= '2004-01-01 11:59.59';
+select * from t1 where a <= '2004-01-01 11:59:59';
+explain partitions select * from t1 where a <= '2005-01-01';
+select * from t1 where a <= '2005-01-01';
+show create table t1;
+drop table t1;
+
+#
+# Adding new test cases for column list variant for partitioning
+#
+--error 1064
+create table t1 (a int, b char(20))
+partition by range columns(a,b)
+(partition p0 values less than (1));
+
+--error ER_TOO_MANY_VALUES_ERROR
+create table t1 (a int, b char(20))
+partition by range(a)
+(partition p0 values less than (1,"b"));
+
+--error ER_TOO_MANY_VALUES_ERROR
+create table t1 (a int, b char(20))
+partition by range(a)
+(partition p0 values less than (1,"b"));
+
+create table t1 (a int, b char(20))
+partition by range columns(b)
+(partition p0 values less than ("b"));
+drop table t1;
+
+#
# BUG 33429: Succeeds in adding partition when maxvalue on last partition
#
create table t1 (a int)
diff --git a/mysql-test/t/partition_symlink.test b/mysql-test/t/partition_symlink.test
index 4147d2c6e89..5fdde8e0abc 100644
--- a/mysql-test/t/partition_symlink.test
+++ b/mysql-test/t/partition_symlink.test
@@ -1,5 +1,6 @@
# Test that must have symlink. eg. using DATA/INDEX DIR
# (DATA/INDEX DIR requires symlinks)
+# This test is only useful for MyISAM, since no other engine supports DATA DIR
-- source include/have_partition.inc
-- source include/have_symlink.inc
# remove the not_windows line after fixing bug#33687
@@ -33,13 +34,14 @@ DROP DATABASE IF EXISTS mysqltest2;
CREATE USER mysqltest_1@localhost;
CREATE DATABASE mysqltest2;
USE mysqltest2;
- CREATE TABLE t1 (a INT);
+ CREATE TABLE t1 (a INT) ENGINE = MyISAM;
INSERT INTO t1 VALUES (0);
connect(con1,localhost,mysqltest_1,,);
-- echo # user mysqltest_1:
USE test;
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1 (a INT)
+ ENGINE = MyISAM
PARTITION BY LIST (a) (
PARTITION p0 VALUES IN (0)
DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp'
@@ -82,6 +84,7 @@ connection default;
USE mysqltest2;
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1 (a INT)
+ ENGINE = MyISAM
PARTITION BY LIST (a) (
PARTITION p0 VALUES IN (0)
DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp'
@@ -96,6 +99,7 @@ connection con1;
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-- error 1,1
eval CREATE TABLE t1 (a INT)
+ ENGINE = MyISAM
PARTITION BY LIST (a) (
PARTITION p0 VALUES IN (0)
DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp'
@@ -107,6 +111,7 @@ connection con1;
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-- error 1,1
eval CREATE TABLE t1 (a INT)
+ ENGINE = MyISAM
PARTITION BY LIST (a) (
PARTITION p0 VALUES IN (0)
DATA DIRECTORY '$MYSQLTEST_VARDIR/tmp'
@@ -128,6 +133,7 @@ connection default;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval create table t2 (i int )
+ENGINE = MyISAM
partition by range (i)
(
partition p01 values less than (1000)
@@ -139,6 +145,7 @@ set @org_mode=@@sql_mode;
set @@sql_mode='NO_DIR_IN_CREATE';
select @@sql_mode;
create table t1 (i int )
+ENGINE = MyISAM
partition by range (i)
(
partition p01 values less than (1000)
@@ -157,6 +164,7 @@ set @@sql_mode=@org_mode;
# Added ER_WRONG_TABLE_NAME and reported bug#39045
-- error ER_WRONG_ARGUMENTS, ER_WRONG_TABLE_NAME
create table t1 (a int)
+ENGINE = MyISAM
partition by key (a)
(partition p0 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data');
@@ -167,6 +175,7 @@ partition by key (a)
# Added ER_WRONG_TABLE_NAME and reported bug#39045
--error ER_WRONG_ARGUMENTS, ER_WRONG_TABLE_NAME
create table t1 (a int)
+ENGINE = MyISAM
partition by key (a)
(partition p0,
partition p1 DATA DIRECTORY 'part-data' INDEX DIRECTORY 'part-data');
diff --git a/mysql-test/t/partition_sync.test b/mysql-test/t/partition_sync.test
new file mode 100644
index 00000000000..85eb33ebb6b
--- /dev/null
+++ b/mysql-test/t/partition_sync.test
@@ -0,0 +1,93 @@
+--source include/have_partition.inc
+--source include/have_debug.inc
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+--echo #
+--echo # Bug #43867 ALTER TABLE on a partitioned table
+--echo # causes unnecessary deadlocks
+--echo #
+
+CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (1),
+ PARTITION p1 VALUES LESS THAN (2));
+
+INSERT INTO t1 VALUES (0),(1);
+
+connect(con1,localhost,root);
+
+--echo # Connection 2
+connection con1;
+BEGIN;
+SELECT * FROM t1;
+
+--echo # Connection 1
+connection default;
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION p3;
+
+--echo # Connection 2
+connection con1;
+--echo # This failed with deadlock and should not do so.
+SELECT * FROM t1;
+
+--echo # Connection 1
+connection default;
+disconnect con1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug #46654 False deadlock on concurrent DML/DDL
+--echo # with partitions, inconsistent behavior
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS tbl_with_partitions;
+--enable_warnings
+
+CREATE TABLE tbl_with_partitions ( i INT )
+ PARTITION BY HASH(i);
+INSERT INTO tbl_with_partitions VALUES (1);
+
+connect(con2,localhost,root);
+connect(con3,localhost,root);
+
+--echo # Connection 3
+connection con3;
+LOCK TABLE tbl_with_partitions READ;
+
+--echo # Connection 1
+--echo # Access table with disabled autocommit
+connection default;
+SET AUTOCOMMIT = 0;
+SELECT * FROM tbl_with_partitions;
+
+--echo # Connection 2
+--echo # Alter table, abort after prepare
+connection con2;
+set session debug="+d,abort_copy_table";
+--error ER_LOCK_WAIT_TIMEOUT
+ALTER TABLE tbl_with_partitions ADD COLUMN f INT;
+
+--echo # Connection 1
+--echo # Try accessing the table after Alter aborted.
+--echo # This used to give ER_LOCK_DEADLOCK.
+connection default;
+SELECT * FROM tbl_with_partitions;
+
+--echo # Connection 3
+connection con3;
+UNLOCK TABLES;
+
+--echo # Connection 1
+--echo # Cleanup
+connection default;
+disconnect con2;
+disconnect con3;
+DROP TABLE tbl_with_partitions;
+
+
+# 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
diff --git a/mysql-test/t/partition_truncate.test b/mysql-test/t/partition_truncate.test
new file mode 100644
index 00000000000..165213d204c
--- /dev/null
+++ b/mysql-test/t/partition_truncate.test
@@ -0,0 +1,33 @@
+#
+# Simple tests to verify truncate partition syntax
+#
+--source include/have_partition.inc
+--disable_warnings
+drop table if exists t1, t2, t3, t4;
+--enable_warnings
+
+create table t1 (a int)
+partition by list (a)
+(partition p1 values in (0));
+--error ER_WRONG_PARTITION_NAME
+alter table t1 truncate partition p1,p1;
+--error ER_WRONG_PARTITION_NAME
+alter table t1 truncate partition p0;
+drop table t1;
+
+create table t1 (a int)
+partition by list (a)
+subpartition by hash (a)
+subpartitions 1
+(partition p1 values in (1)
+ (subpartition sp1));
+--error ER_WRONG_PARTITION_NAME
+alter table t1 truncate partition sp1;
+drop table t1;
+
+create table t1 (a int);
+insert into t1 values (1), (3), (8);
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+alter table t1 truncate partition p0;
+select count(*) from t1;
+drop table t1;
diff --git a/mysql-test/t/partition_utf8.test b/mysql-test/t/partition_utf8.test
new file mode 100644
index 00000000000..d3ad7ba671e
--- /dev/null
+++ b/mysql-test/t/partition_utf8.test
@@ -0,0 +1,42 @@
+# Tests for Column list which requires utf8 output
+--source include/have_partition.inc
+set names utf8;
+create table t1 (a varchar(2) character set cp1250)
+partition by list columns (a)
+( partition p0 values in (0x81));
+show create table t1;
+drop table t1;
+create table t1 (a varchar(2) character set cp1250)
+partition by list columns (a)
+( partition p0 values in (0x80));
+show create table t1;
+drop table t1;
+
+#
+# BUG#48164, too long partition fields causes crash
+#
+--error ER_PARTITION_FIELDS_TOO_LONG
+create table t1 (a varchar(1500), b varchar(1570))
+partition by list columns(a,b)
+( partition p0 values in (('a','b')));
+
+create table t1 (a varchar(1023) character set utf8 collate utf8_spanish2_ci)
+partition by range columns(a)
+( partition p0 values less than ('CZ'),
+ partition p1 values less than ('CH'),
+ partition p2 values less than ('D'));
+insert into t1 values ('czz'),('chi'),('ci'),('cg');
+select * from t1 where a between 'cg' AND 'ci';
+drop table t1;
+
+#
+# BUG#48163, Dagger in UCS2 not working as partition value
+#
+create table t1 (a varchar(2) character set ucs2)
+partition by list columns (a)
+(partition p0 values in (0x2020),
+ partition p1 values in (''));
+show create table t1;
+insert into t1 values ('');
+insert into t1 values (_ucs2 0x2020);
+drop table t1;
diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test
index a4b99d8aa22..2b9907c0542 100644
--- a/mysql-test/t/perror.test
+++ b/mysql-test/t/perror.test
@@ -1,3 +1,4 @@
+--source include/not_windows.inc
#
# Check if the variable MY_PERROR is set
#
@@ -17,3 +18,17 @@ enable_query_log;
# As there is no error code defined for 10000, expect error
--error 1
--exec $MY_PERROR 10000 2>&1
+
+#
+# Bug#10143 (Perror not showing error description)
+#
+
+# test reported case
+--exec $MY_PERROR 1062 2>&1
+
+# test errors that contain characters to escape in the text.
+--exec $MY_PERROR 1076 2>&1
+--exec $MY_PERROR 1459 2>&1
+--exec $MY_PERROR 1461 2>&1
+
+
diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test
index 788a7b336ef..117eaf1e19b 100644
--- a/mysql-test/t/plugin.test
+++ b/mysql-test/t/plugin.test
@@ -5,15 +5,15 @@ CREATE TABLE t1(a int) ENGINE=EXAMPLE;
DROP TABLE t1;
--replace_regex /\.dll/.so/
-eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
--replace_regex /\.dll/.so/
--error 1125
-eval INSTALL PLUGIN EXAMPLE SONAME $HA_EXAMPLE_SO;
+eval INSTALL PLUGIN EXAMPLE SONAME '$EXAMPLE_PLUGIN';
UNINSTALL PLUGIN example;
--replace_regex /\.dll/.so/
-eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
CREATE TABLE t1(a int) ENGINE=EXAMPLE;
@@ -22,6 +22,12 @@ SELECT * FROM t1;
DROP TABLE t1;
+# a couple of tests for variables
+set global example_ulong_var=500;
+set global example_enum_var= e1;
+show status like 'example%';
+show variables like 'example%';
+
UNINSTALL PLUGIN example;
--error 1305
UNINSTALL PLUGIN EXAMPLE;
@@ -35,7 +41,7 @@ UNINSTALL PLUGIN non_exist;
--echo # to impossible int val
--echo #
--replace_regex /\.dll/.so/
-eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
SET GLOBAL example_enum_var= e1;
SET GLOBAL example_enum_var= e2;
@@ -50,7 +56,7 @@ UNINSTALL PLUGIN example;
# Bug #32757 hang with sql_mode set when setting some global variables
#
--replace_regex /\.dll/.so/
-eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
select @@session.sql_mode into @old_sql_mode;
diff --git a/mysql-test/t/plugin_auth-master.opt b/mysql-test/t/plugin_auth-master.opt
new file mode 100644
index 00000000000..3536d102387
--- /dev/null
+++ b/mysql-test/t/plugin_auth-master.opt
@@ -0,0 +1,2 @@
+$PLUGIN_AUTH_OPT
+$PLUGIN_AUTH_LOAD
diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test
new file mode 100644
index 00000000000..a81cf4e4783
--- /dev/null
+++ b/mysql-test/t/plugin_auth.test
@@ -0,0 +1,515 @@
+--source include/have_plugin_auth.inc
+--source include/not_embedded.inc
+--source include/mysql_upgrade_preparation.inc
+
+query_vertical SELECT PLUGIN_STATUS, PLUGIN_TYPE, PLUGIN_DESCRIPTION
+ FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='test_plugin_server';
+
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+
+SELECT plugin,authentication_string FROM mysql.user WHERE User='plug';
+
+--echo ## test plugin auth
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR : this should fail : no grant
+connect(plug_con,localhost,plug,plug_dest);
+--enable_query_log
+
+GRANT PROXY ON plug_dest TO plug;
+--echo test proxies_priv columns
+--replace_column 1 xx 7 xx
+SELECT * FROM mysql.proxies_priv;
+--echo test mysql.proxies_priv;
+SHOW CREATE TABLE mysql.proxies_priv;
+
+connect(plug_con,localhost,plug,plug_dest);
+
+connection plug_con;
+select USER(),CURRENT_USER();
+
+--echo ## test SET PASSWORD
+#--error ER_SET_PASSWORD_AUTH_PLUGIN
+SET PASSWORD = PASSWORD('plug_dest');
+
+connection default;
+disconnect plug_con;
+
+--echo ## test bad credentials
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect(plug_con,localhost,plug,bad_credentials);
+--enable_query_log
+
+--echo ## test bad default plugin : should get CR_AUTH_PLUGIN_CANNOT_LOAD
+--disable_result_log
+--disable_query_log
+--error 2059
+connect(plug_con_wrongp,localhost,plug,plug_dest,,,,,wrong_plugin_name);
+--enable_query_log
+--enable_result_log
+
+--echo ## test correct default plugin
+connect(plug_con_rightp,localhost,plug,plug_dest,,,,,auth_test_plugin);
+connection plug_con_rightp;
+select USER(),CURRENT_USER();
+connection default;
+disconnect plug_con_rightp;
+
+--echo ## test no_auto_create_user sql mode with plugin users
+SET @@sql_mode=no_auto_create_user;
+GRANT INSERT ON TEST.* TO grant_user IDENTIFIED WITH 'test_plugin_server';
+SET @@sql_mode=default;
+DROP USER grant_user;
+
+--echo ## test utf-8 user name
+CREATE USER `Ÿ` IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+
+GRANT PROXY ON plug_dest TO `Ÿ`;
+
+connect(non_ascii,localhost,Ÿ,plug_dest);
+connection non_ascii;
+select USER(),CURRENT_USER();
+
+connection default;
+disconnect non_ascii;
+DROP USER `Ÿ`;
+
+--echo ## test GRANT ... IDENTIFIED WITH/BY ...
+
+CREATE DATABASE test_grant_db;
+
+--echo # create new user via GRANT WITH
+GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user
+ IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+
+GRANT PROXY ON plug_dest TO new_grant_user;
+
+connect(plug_con_grant,localhost,new_grant_user,plug_dest);
+connection plug_con_grant;
+select USER(),CURRENT_USER();
+USE test_grant_db;
+CREATE TABLE t1 (a INT);
+DROP TABLE t1;
+connection default;
+disconnect plug_con_grant;
+REVOKE ALL PRIVILEGES ON test_grant_db.* FROM new_grant_user;
+
+--echo # try re-create existing user via GRANT IDENTIFIED BY
+GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user
+ IDENTIFIED BY 'unused_password';
+
+--echo # make sure password doesn't take precendence
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect(plug_con_grant_deny,localhost,new_grant_user,unused_password);
+--enable_query_log
+
+--echo #make sure plugin auth still available
+connect(plug_con_grant,localhost,new_grant_user,plug_dest);
+connection plug_con_grant;
+select USER(),CURRENT_USER();
+USE test_grant_db;
+CREATE TABLE t1 (a INT);
+DROP TABLE t1;
+connection default;
+disconnect plug_con_grant;
+
+DROP USER new_grant_user;
+
+--echo # try re-create existing user via GRANT IDENTIFIED WITH
+
+--error ER_GRANT_PLUGIN_USER_EXISTS
+GRANT ALL PRIVILEGES ON test_grant_db.* TO plug
+ IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+
+--error ER_GRANT_PLUGIN_USER_EXISTS
+GRANT ALL PRIVILEGES ON test_grant_db.* TO plug_dest
+ IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+
+--error ER_PARSE_ERROR
+REVOKE SELECT on test_grant_db.* FROM joro
+ INDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+
+--error ER_PARSE_ERROR
+REVOKE SELECT on test_grant_db.* FROM joro
+ INDENTIFIED BY 'plug_dest_passwd';
+
+--error ER_PARSE_ERROR
+REVOKE SELECT on test_grant_db.* FROM joro
+ INDENTIFIED BY PASSWORD 'plug_dest_passwd';
+
+DROP DATABASE test_grant_db;
+
+--echo ## GRANT PROXY tests
+
+CREATE USER grant_plug IDENTIFIED WITH 'test_plugin_server'
+ AS 'grant_plug_dest';
+CREATE USER grant_plug_dest IDENTIFIED BY 'grant_plug_dest_passwd';
+CREATE USER grant_plug_dest2 IDENTIFIED BY 'grant_plug_dest_passwd2';
+
+--echo # ALL PRIVILEGES doesn't include PROXY
+GRANT ALL PRIVILEGES ON *.* TO grant_plug;
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR : this should fail : no grant
+connect(grant_plug_con,localhost,grant_plug,grant_plug_dest);
+--enable_query_log
+
+--error ER_PARSE_ERROR : this should fail : can't combine PROXY
+GRANT ALL PRIVILEGES,PROXY ON grant_plug_dest TO grant_plug;
+
+--echo this should fail : can't combine PROXY
+--error ER_PARSE_ERROR
+GRANT ALL SELECT,PROXY ON grant_plug_dest TO grant_plug;
+
+--echo # this should fail : no such grant
+--error ER_NONEXISTING_GRANT
+REVOKE PROXY ON grant_plug_dest FROM grant_plug;
+
+connect(grant_plug_dest_con,localhost,grant_plug_dest,grant_plug_dest_passwd);
+connection grant_plug_dest_con;
+--echo in grant_plug_dest_con
+
+--echo ## testing what an ordinary user can grant
+--echo this should fail : no rights to grant all
+--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
+GRANT PROXY ON ''@'' TO grant_plug;
+
+--echo this should fail : not the same user
+--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
+GRANT PROXY ON grant_plug TO grant_plug_dest;
+
+--echo this should fail : same user, but on a different host
+--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
+GRANT PROXY ON grant_plug_dest TO grant_plug;
+
+--echo this should work : same user
+GRANT PROXY ON grant_plug_dest@localhost TO grant_plug_dest2;
+REVOKE PROXY ON grant_plug_dest@localhost FROM grant_plug_dest2;
+
+--echo this should work : same user
+GRANT PROXY ON grant_plug_dest@localhost TO grant_plug WITH GRANT OPTION;
+REVOKE PROXY ON grant_plug_dest@localhost FROM grant_plug;
+
+--echo this should fail : can't create users
+--error ER_CANT_CREATE_USER_WITH_GRANT
+GRANT PROXY ON grant_plug_dest@localhost TO grant_plug@localhost;
+
+connection default;
+--echo in default connection
+disconnect grant_plug_dest_con;
+
+--echo # test what root can grant
+
+--echo should work : root has PROXY to all users
+GRANT PROXY ON ''@'' TO grant_plug;
+REVOKE PROXY ON ''@'' FROM grant_plug;
+
+--echo should work : root has PROXY to all users
+GRANT PROXY ON ''@'' TO proxy_admin IDENTIFIED BY 'test'
+ WITH GRANT OPTION;
+
+--echo need USAGE : PROXY doesn't contain it.
+GRANT USAGE on *.* TO proxy_admin;
+
+connect (proxy_admin_con,localhost,proxy_admin,test);
+connection proxy_admin_con;
+--echo in proxy_admin_con;
+
+--echo should work : proxy_admin has proxy to ''@''
+GRANT PROXY ON future_user TO grant_plug;
+
+connection default;
+--echo in default connection
+disconnect proxy_admin_con;
+
+SHOW GRANTS FOR grant_plug;
+REVOKE PROXY ON future_user FROM grant_plug;
+SHOW GRANTS FOR grant_plug;
+
+--echo ## testing drop user
+CREATE USER test_drop@localhost;
+GRANT PROXY ON future_user TO test_drop@localhost;
+SHOW GRANTS FOR test_drop@localhost;
+DROP USER test_drop@localhost;
+SELECT * FROM mysql.proxies_priv WHERE Host = 'test_drop' AND User = 'localhost';
+
+DROP USER proxy_admin;
+
+DROP USER grant_plug,grant_plug_dest,grant_plug_dest2;
+
+--echo ## END GRANT PROXY tests
+
+--echo ## cleanup
+DROP USER plug;
+DROP USER plug_dest;
+
+--echo ## @@proxy_user tests
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug;
+
+SELECT USER(),CURRENT_USER(),@@LOCAL.proxy_user;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@GLOBAL.proxy_user;
+SELECT @@LOCAL.proxy_user;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET GLOBAL proxy_user = 'test';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET LOCAL proxy_user = 'test';
+SELECT @@LOCAL.proxy_user;
+
+connect(plug_con,localhost,plug,plug_dest);
+connection plug_con;
+--echo # in connection plug_con
+SELECT @@LOCAL.proxy_user;
+connection default;
+--echo # in connection default
+disconnect plug_con;
+
+--echo ## cleanup
+DROP USER plug;
+DROP USER plug_dest;
+--echo ## END @@proxy_user tests
+
+--echo ## @@external_user tests
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug;
+SELECT USER(),CURRENT_USER(),@@LOCAL.external_user;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@GLOBAL.external_user;
+SELECT @@LOCAL.external_user;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET GLOBAL external_user = 'test';
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SET LOCAL external_user = 'test';
+SELECT @@LOCAL.external_user;
+
+connect(plug_con,localhost,plug,plug_dest);
+connection plug_con;
+--echo # in connection plug_con
+SELECT @@LOCAL.external_user;
+connection default;
+--echo # in connection default
+disconnect plug_con;
+
+--echo ## cleanup
+DROP USER plug;
+DROP USER plug_dest;
+--echo ## END @@external_user tests
+
+--echo #
+--echo # Bug #56798 : Wrong credentials assigned when using a proxy user.
+--echo #
+
+GRANT ALL PRIVILEGES ON *.* TO power_user;
+GRANT USAGE ON anonymous_db.* TO ''@''
+ IDENTIFIED WITH 'test_plugin_server' AS 'power_user';
+GRANT PROXY ON power_user TO ''@'';
+CREATE DATABASE confidential_db;
+
+connect(plug_con,localhost, test_login_user, power_user, confidential_db);
+SELECT user(),current_user(),@@proxy_user;
+
+connection default;
+disconnect plug_con;
+
+DROP USER power_user;
+DROP USER ''@'';
+DROP DATABASE confidential_db;
+
+--echo # Test case #2 (crash with double grant proxy)
+
+CREATE USER ''@'' IDENTIFIED WITH 'test_plugin_server' AS 'standard_user';
+CREATE USER standard_user;
+CREATE DATABASE shared;
+GRANT ALL PRIVILEGES ON shared.* TO standard_user;
+GRANT PROXY ON standard_user TO ''@'';
+--echo #should not crash
+GRANT PROXY ON standard_user TO ''@'';
+
+DROP USER ''@'';
+DROP USER standard_user;
+DROP DATABASE shared;
+
+
+--echo #
+--echo # Bug #57551 : Live upgrade fails between 5.1.52 -> 5.5.7-rc
+--echo #
+
+CALL mtr.add_suppression("Missing system table mysql.proxies_priv.");
+
+DROP TABLE mysql.proxies_priv;
+
+--echo # Must come back with mysql.proxies_priv absent.
+--source include/restart_mysqld.inc
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM mysql.proxies_priv;
+
+CREATE USER u1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO u1@localhost;
+REVOKE ALL PRIVILEGES ON *.* FROM u1@localhost;
+GRANT ALL PRIVILEGES ON *.* TO u1@localhost;
+
+CREATE USER u2@localhost;
+GRANT ALL PRIVILEGES ON *.* TO u2@localhost;
+
+--echo # access denied because of no privileges to root
+--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
+GRANT PROXY ON u2@localhost TO u1@localhost;
+
+--echo # access denied because of no privileges to root
+--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
+REVOKE PROXY ON u2@localhost FROM u1@localhost;
+
+--echo # go try graning proxy on itself, so that it will need the table
+connect(proxy_granter_con,localhost,u2,);
+connection proxy_granter_con;
+
+--error ER_NO_SUCH_TABLE
+GRANT PROXY ON u2@localhost TO u1@localhost;
+--error ER_NO_SUCH_TABLE
+REVOKE PROXY ON u2@localhost FROM u1@localhost;
+
+connection default;
+disconnect proxy_granter_con;
+
+--echo # test if REVOKE works without the proxies_priv table
+REVOKE ALL PRIVILEGES ON *.* FROM u1@localhost, u2@localhost;
+
+--echo # test if DROP USER work without the proxies_priv table
+DROP USER u1@localhost,u2@localhost;
+
+--echo # test if FLUSH PRIVILEGES works without the proxies_priv table
+FLUSH PRIVILEGES;
+
+--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
+--query_vertical SELECT Host,User,Proxied_host,Proxied_user,With_grant FROM mysql.proxies_priv
+
+FLUSH PRIVILEGES;
+
+--echo #
+--echo # Bug#58139 : default-auth option not recognized in MySQL standard
+--echo # command line clients
+--echo #
+
+--echo # Executing 'mysql'
+--exec $MYSQL -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT -e "SELECT 1"
+
+--echo # Executing 'mysqladmin'
+--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT ping
+
+--echo # Executing 'mysqldump'
+--exec $MYSQL_DUMP -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --compact --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT test
+
+--echo # Executing 'mysql_upgrade'
+--exec $MYSQL_UPGRADE -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT --skip-verbose --force --upgrade-system-tables
+
+--echo #
+--echo # Bug #59657: Move the client authentication_pam plugin into the
+--echo # server repository
+--echo #
+
+CREATE USER uplain@localhost IDENTIFIED WITH 'cleartext_plugin_server'
+ AS 'cleartext_test';
+
+--echo ## test plugin auth
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR : this should fail : no grant
+connect(cleartext_fail_con,localhost,uplain,cleartext_test2);
+--enable_query_log
+
+connect(cleartext_con,localhost,uplain,cleartext_test);
+connection cleartext_con;
+select USER(),CURRENT_USER();
+
+connection default;
+disconnect cleartext_con;
+DROP USER uplain@localhost;
+
+--echo #
+--echo # Bug #59038 : mysql.user.authentication_string column
+--echo # causes configuration wizard to fail
+
+INSERT INTO mysql.user(
+ Host,
+ User,
+ Password,
+ Select_priv,
+ Insert_priv,
+ Update_priv,
+ Delete_priv,
+ Create_priv,
+ Drop_priv,
+ Reload_priv,
+ Shutdown_priv,
+ Process_priv,
+ File_priv,
+ Grant_priv,
+ References_priv,
+ Index_priv,
+ Alter_priv,
+ Show_db_priv,
+ Super_priv,
+ Create_tmp_table_priv,
+ Lock_tables_priv,
+ Execute_priv,
+ Repl_slave_priv,
+ Repl_client_priv,
+ /*!50001
+ Create_view_priv,
+ Show_view_priv,
+ Create_routine_priv,
+ Alter_routine_priv,
+ Create_user_priv,
+ */
+ ssl_type,
+ ssl_cipher,
+ x509_issuer,
+ x509_subject,
+ max_questions,
+ max_updates,
+ max_connections)
+VALUES (
+ 'localhost',
+ 'inserttest', '',
+ 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
+ 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
+ /*!50001 'Y', 'Y', 'Y', 'Y', 'Y', */'', '', '', '', '0', '0', '0');
+FLUSH PRIVILEGES;
+DROP USER inserttest@localhost;
+SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE
+ COLUMN_NAME IN ('authentication_string', 'plugin') AND
+ TABLE_NAME='user' AND
+ TABLE_SCHEMA='mysql'
+ORDER BY COLUMN_NAME;
+
+
+--echo #
+--echo # Bug #11936829: diff. between mysql.user (authentication_string)
+--echo # in fresh and upgraded 5.5.11
+--echo #
+
+SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_SCHEMA= 'mysql' AND TABLE_NAME= 'user' AND
+ COLUMN_NAME IN ('plugin', 'authentication_string')
+ ORDER BY COLUMN_NAME;
+ALTER TABLE mysql.user MODIFY plugin char(64) DEFAULT '' NOT NULL;
+ALTER TABLE mysql.user MODIFY authentication_string TEXT NOT NULL;
+
+--echo Run mysql_upgrade on a 5.5.10 external authentication column layout
+--exec $MYSQL_UPGRADE --skip-verbose --force 2>&1
+
+SELECT IS_NULLABLE, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_SCHEMA= 'mysql' AND TABLE_NAME= 'user' AND
+ COLUMN_NAME IN ('plugin', 'authentication_string')
+ ORDER BY COLUMN_NAME;
+
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/plugin_auth_qa-master.opt b/mysql-test/t/plugin_auth_qa-master.opt
new file mode 100644
index 00000000000..3536d102387
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa-master.opt
@@ -0,0 +1,2 @@
+$PLUGIN_AUTH_OPT
+$PLUGIN_AUTH_LOAD
diff --git a/mysql-test/t/plugin_auth_qa.test b/mysql-test/t/plugin_auth_qa.test
new file mode 100644
index 00000000000..0961c1dfef5
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa.test
@@ -0,0 +1,338 @@
+# The numbers represent test cases of the test plan.
+
+--source include/have_plugin_auth.inc
+--source include/not_embedded.inc
+
+CREATE DATABASE test_user_db;
+
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo ========== test 1.1 ======================================================
+# without '', without AS part
+CREATE USER plug IDENTIFIED WITH test_plugin_server;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+REVOKE ALL PRIVILEGES ON test_user_db.* FROM plug;
+DROP USER plug;
+# with '', without AS part
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+REVOKE ALL PRIVILEGES ON test_user_db.* FROM plug;
+DROP USER plug;
+# without '', AS part empty
+CREATE USER plug IDENTIFIED WITH test_plugin_server AS '';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS '';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+REVOKE ALL PRIVILEGES ON test_user_db.* FROM plug;
+DROP USER plug;
+# with '', AS part empty without ''
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS ;
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS;
+# without '', AS part without ''
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH test_plugin_server AS plug_dest;
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS plug_dest;
+--echo ========== test 1.1 syntax errors ========================================
+# without auth_name
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH AS plug_dest;
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH AS plug_dest;
+# without auth_name and AS part
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH;
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH;
+# without auth_name but AS part
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED AS '';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED AS '';
+# with 2 auth_name parts
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' IDENTIFIED WITH 'test_plugin_server';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug
+ IDENTIFIED WITH 'test_plugin_server' IDENTIFIED WITH 'test_plugin_server';
+# with 2 AS parts
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS '' AS 'plug_dest';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug AS '' AS 'plug_dest';
+# with 2 complete WITH parts
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS ''
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS ''
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+# with BY and WITH part
+--error ER_PARSE_ERROR
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd'
+ IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED BY 'plug_dest_passwd'
+ IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+# with WITH part and BY part
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+ USER plug_dest IDENTIFIED by 'plug_dest_pwd';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+ USER plug_dest IDENTIFIED by 'plug_dest_pwd';
+# with WITH part and BY part
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+ plug_dest IDENTIFIED by 'plug_dest_pwd';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+ plug_dest IDENTIFIED by 'plug_dest_pwd';
+# with WITH part and BY part
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+ IDENTIFIED by 'plug_dest_pwd';
+--error ER_PARSE_ERROR
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest'
+ IDENTIFIED by 'plug_dest_pwd';
+
+--echo ========== test 1.1 combinations ==========================
+# CREATE...WITH/CREATE...BY
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--echo ========== test 1.1.1.6/1.1.2.5 ============================
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug, plug_dest;
+#
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug_dest;
+# GRANT...WITH/CREATE...BY
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug, plug_dest;
+#
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug_dest;
+# CREATE...WITH/GRANT...BY
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug, plug_dest;
+#
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug_dest;
+#
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--error 1700
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--error 1700
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server';
+DROP USER plug;
+#
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--error ER_CANNOT_USER
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--error ER_CANNOT_USER
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server';
+DROP USER plug;
+#
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+#
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--error ER_CANNOT_USER
+CREATE USER plug IDENTIFIED BY 'plug_dest_passwd';
+DROP USER plug;
+#
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+DROP USER plug,plug_dest;
+#
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+DROP USER plug,plug_dest;
+#
+
+--echo ========== test 1.1.1.1/1.1.2.1/1.1.1.5 ====================
+
+SET NAMES utf8;
+#
+CREATE USER plüg IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plüg;
+CREATE USER plüg_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plüg_dest;
+
+SET NAMES ascii;
+#
+CREATE USER 'plüg' IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER 'plüg';
+CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER 'plüg_dest';
+
+SET NAMES latin1;
+#
+--echo ========== test 1.1.1.5 ====================================
+--error ER_PLUGIN_IS_NOT_LOADED
+CREATE USER 'plüg' IDENTIFIED WITH 'test_plügin_server' AS 'plüg_dest';
+CREATE USER 'plug' IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER 'plug';
+CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER 'plüg_dest';
+
+SET NAMES utf8;
+#
+--error ER_PLUGIN_IS_NOT_LOADED
+CREATE USER plüg IDENTIFIED WITH 'test_plügin_server' AS 'plüg_dest';
+CREATE USER 'plüg' IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER 'plüg';
+CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER 'plüg_dest';
+
+CREATE USER plüg IDENTIFIED WITH test_plugin_server AS 'plüg_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plüg;
+CREATE USER plüg_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plüg_dest;
+
+--echo ========== test 1.1.1.2/1.1.2.2=============================
+
+SET @auth_name= 'test_plugin_server';
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH @auth_name AS 'plug_dest';
+
+SET @auth_string= 'plug_dest';
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH test_plugin_server AS @auth_string;
+
+--echo ========== test 1.1.1.3/1.1.2.3=============================
+
+--error ER_PLUGIN_IS_NOT_LOADED
+CREATE USER plug IDENTIFIED WITH 'hh''s_test_plugin_server' AS 'plug_dest';
+
+CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'hh''s_plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug;
+CREATE USER 'hh''s_plug_dest' IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER 'hh''s_plug_dest';
+
+--echo ========== test 1.1.1.4 ====================================
+
+--error ER_PARSE_ERROR
+CREATE USER plug IDENTIFIED WITH hh''s_test_plugin_server AS 'plug_dest';
+
+--echo ========== test 1.1.3.1 ====================================
+
+GRANT INSERT ON test_user_db.* TO grant_user IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+CREATE USER plug_dest;
+DROP USER plug_dest;
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER grant_user,plug_dest;
+#
+set @save_sql_mode= @@sql_mode;
+SET @@sql_mode=no_auto_create_user;
+GRANT INSERT ON test_user_db.* TO grant_user IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+CREATE USER plug_dest;
+DROP USER plug_dest;
+--error ER_PASSWORD_NO_MATCH
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest;
+DROP USER grant_user;
+#
+GRANT INSERT ON test_user_db.* TO grant_user IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+DROP USER plug_dest;
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_user_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+DROP USER grant_user,plug_dest;
+set @@sql_mode= @save_sql_mode;
+#
+DROP DATABASE test_user_db;
+--exit
+
diff --git a/mysql-test/t/plugin_auth_qa_1-master.opt b/mysql-test/t/plugin_auth_qa_1-master.opt
new file mode 100644
index 00000000000..3536d102387
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa_1-master.opt
@@ -0,0 +1,2 @@
+$PLUGIN_AUTH_OPT
+$PLUGIN_AUTH_LOAD
diff --git a/mysql-test/t/plugin_auth_qa_1.test b/mysql-test/t/plugin_auth_qa_1.test
new file mode 100644
index 00000000000..06908935b01
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa_1.test
@@ -0,0 +1,340 @@
+# The numbers represent test cases of the test plan.
+
+--source include/have_plugin_auth.inc
+--source include/not_embedded.inc
+
+CREATE DATABASE test_user_db;
+
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+
+--echo ========== test 1.1.3.2 ====================================
+
+# CREATE...WITH/CREATE...BY/GRANT
+CREATE USER plug_user IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug_user;
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1
+REVOKE PROXY ON plug_dest FROM plug_user;
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1
+DROP USER plug_user,plug_dest;
+#
+# GRANT...WITH
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug_user;
+
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo 1)
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1
+REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_user'
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+--echo 2)
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1
+REVOKE PROXY ON plug_dest FROM plug_user;
+--echo 3)
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1
+DROP USER plug_user,plug_dest;
+#
+# GRANT...WITH/CREATE...BY
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--echo 1)
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1
+GRANT PROXY ON plug_dest TO plug_user;
+--echo 2)
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();USE test_user_db;CREATE TABLE t1(a int);SHOW TABLES;DROP TABLE t1;" 2>&1
+REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_user'
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+#REVOKE ALL PRIVILEGES ON test_user_db.* FROM 'plug_dest'
+# IDENTIFIED BY 'plug_dest_passwd';
+DROP USER plug_user,plug_dest;
+
+--echo ========== test 1.2 ========================================
+
+# GRANT...WITH/CREATE...BY
+GRANT ALL PRIVILEGES ON test_user_db.* TO plug_user
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug_user;
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1
+RENAME USER plug_dest TO new_dest;
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1
+GRANT PROXY ON new_dest TO plug_user;
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug_user,new_dest;
+
+# CREATE...WITH/CREATE...BY
+CREATE USER plug_user
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1
+GRANT PROXY ON plug_dest TO plug_user;
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK $PLUGIN_AUTH_OPT PLUGIN_AUTH_OPT
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1
+RENAME USER plug_dest TO new_dest;
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=plug_dest -e "SELECT current_user();SELECT user();" 2>&1
+GRANT PROXY ON new_dest TO plug_user;
+--error 1
+--exec $MYSQL -S $MASTER_MYSOCK -u plug_user $PLUGIN_AUTH_OPT --password=new_dest -e "SELECT current_user();SELECT user();" 2>&1
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug_user,new_dest;
+# CREATE...WITH
+CREATE USER plug_user
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug_user;
+--echo connect(plug_user,localhost,plug_user,plug_dest);
+connect(plug_user,localhost,plug_user,plug_dest);
+select USER(),CURRENT_USER();
+--echo connection default;
+connection default;
+--echo disconnect plug_user;
+disconnect plug_user;
+RENAME USER plug_user TO new_user;
+--echo connect(plug_user,localhost,new_user,plug_dest);
+connect(plug_user,localhost,new_user,plug_dest);
+select USER(),CURRENT_USER();
+--echo connection default;
+connection default;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo disconnect plug_user;
+disconnect plug_user;
+UPDATE mysql.user SET user='plug_user' WHERE user='new_user';
+FLUSH PRIVILEGES;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+DROP USER plug_dest,plug_user;
+--echo ========== test 1.3 ========================================
+
+#
+CREATE USER plug_user
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug_user;
+--echo connect(plug_user,localhost,plug_user,plug_dest);
+connect(plug_user,localhost,plug_user,plug_dest);
+select USER(),CURRENT_USER();
+--echo connection default;
+connection default;
+--echo disconnect plug_user;
+disconnect plug_user;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+UPDATE mysql.user SET user='new_user' WHERE user='plug_user';
+FLUSH PRIVILEGES;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+UPDATE mysql.user SET authentication_string='new_dest' WHERE user='new_user';
+FLUSH PRIVILEGES;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+UPDATE mysql.user SET plugin='new_plugin_server' WHERE user='new_user';
+FLUSH PRIVILEGES;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo connect(plug_user,localhost,new_user,new_dest);
+--disable_query_log
+--error ER_PLUGIN_IS_NOT_LOADED
+connect(plug_user,localhost,new_user,new_dest);
+--enable_query_log
+UPDATE mysql.user SET plugin='test_plugin_server' WHERE user='new_user';
+UPDATE mysql.user SET USER='new_dest' WHERE user='plug_dest';
+FLUSH PRIVILEGES;
+GRANT PROXY ON new_dest TO new_user;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo connect(plug_user,localhost,new_user,new_dest);
+connect(plug_user,localhost,new_user,new_dest);
+select USER(),CURRENT_USER();
+--echo connection default;
+connection default;
+--echo disconnect plug_user;
+disconnect plug_user;
+UPDATE mysql.user SET USER='plug_dest' WHERE user='new_dest';
+FLUSH PRIVILEGES;
+CREATE USER new_dest IDENTIFIED BY 'new_dest_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+GRANT ALL PRIVILEGES ON test.* TO new_user;
+--echo connect(plug_user,localhost,new_dest,new_dest_passwd);
+connect(plug_user,localhost,new_dest,new_dest_passwd);
+select USER(),CURRENT_USER();
+--echo connection default;
+connection default;
+--echo disconnect plug_user;
+disconnect plug_user;
+DROP USER new_user,new_dest,plug_dest;
+
+--echo ========== test 2, 2.1, 2.2 ================================
+
+CREATE USER ''@'' IDENTIFIED WITH test_plugin_server AS 'proxied_user';
+CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+SELECT USER(),CURRENT_USER();
+--echo ========== test 2.2.1 ======================================
+SELECT @@proxy_user;
+--echo connection default;
+connection default;
+--echo disconnect proxy_con;
+disconnect proxy_con;
+--echo connect(proxy_con,localhost,proxy_user,proxied_user);
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR : this should fail : no grant
+connect(proxy_con,localhost,proxy_user,proxied_user);
+--enable_query_log
+GRANT PROXY ON proxied_user TO ''@'';
+--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+SELECT USER(),CURRENT_USER();
+--echo connection default;
+connection default;
+--echo disconnect proxy_con;
+disconnect proxy_con;
+--echo connect(proxy_con,localhost,proxy_user,proxied_user);
+connect(proxy_con,localhost,proxy_user,proxied_user);
+SELECT USER(),CURRENT_USER();
+--echo ========== test 2.2.1 ======================================
+SELECT @@proxy_user;
+--echo connection default;
+connection default;
+--echo disconnect proxy_con;
+disconnect proxy_con;
+DROP USER ''@'',proxied_user;
+#
+GRANT ALL PRIVILEGES ON test_user_db.* TO ''@''
+ IDENTIFIED WITH test_plugin_server AS 'proxied_user';
+CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+SELECT USER(),CURRENT_USER();
+SELECT @@proxy_user;
+--echo connection default;
+connection default;
+--echo disconnect proxy_con;
+disconnect proxy_con;
+--echo connect(proxy_con,localhost,proxy_user,proxied_user);
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR : this should fail : no grant
+connect(proxy_con,localhost,proxy_user,proxied_user);
+--enable_query_log
+GRANT PROXY ON proxied_user TO ''@'';
+--echo connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+SELECT USER(),CURRENT_USER();
+--echo connection default;
+connection default;
+--echo disconnect proxy_con;
+disconnect proxy_con;
+--echo connect(proxy_con,localhost,proxy_user,proxied_user);
+connect(proxy_con,localhost,proxy_user,proxied_user);
+SELECT USER(),CURRENT_USER();
+SELECT @@proxy_user;
+--echo connection default;
+connection default;
+--echo disconnect proxy_con;
+disconnect proxy_con;
+DROP USER ''@'',proxied_user;
+#
+CREATE USER ''@'' IDENTIFIED WITH test_plugin_server AS 'proxied_user';
+CREATE USER proxied_user_1 IDENTIFIED BY 'proxied_user_1_pwd';
+CREATE USER proxied_user_2 IDENTIFIED BY 'proxied_user_2_pwd';
+CREATE USER proxied_user_3 IDENTIFIED BY 'proxied_user_3_pwd';
+CREATE USER proxied_user_4 IDENTIFIED BY 'proxied_user_4_pwd';
+CREATE USER proxied_user_5 IDENTIFIED BY 'proxied_user_5_pwd';
+GRANT PROXY ON proxied_user_1 TO ''@'';
+GRANT PROXY ON proxied_user_2 TO ''@'';
+GRANT PROXY ON proxied_user_3 TO ''@'';
+GRANT PROXY ON proxied_user_4 TO ''@'';
+GRANT PROXY ON proxied_user_5 TO ''@'';
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+--echo connect(proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd');
+connect(proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd');
+--echo connect(proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd);
+connect(proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd);
+--echo connect(proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd);
+connect(proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd);
+--echo connect(proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd);
+connect(proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd);
+--echo connect(proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd);
+connect(proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd);
+--echo connection proxy_con_1;
+connection proxy_con_1;
+SELECT USER(),CURRENT_USER();
+SELECT @@proxy_user;
+--echo connection proxy_con_2;
+connection proxy_con_2;
+SELECT USER(),CURRENT_USER();
+SELECT @@proxy_user;
+--echo connection proxy_con_3;
+connection proxy_con_3;
+SELECT USER(),CURRENT_USER();
+SELECT @@proxy_user;
+--echo connection proxy_con_4;
+connection proxy_con_4;
+SELECT USER(),CURRENT_USER();
+SELECT @@proxy_user;
+--echo connection proxy_con_5;
+connection proxy_con_5;
+SELECT USER(),CURRENT_USER();
+SELECT @@proxy_user;
+--echo connection default;
+connection default;
+--echo disconnect proxy_con_1;
+disconnect proxy_con_1;
+--echo disconnect proxy_con_2;
+disconnect proxy_con_2;
+--echo disconnect proxy_con_3;
+disconnect proxy_con_3;
+--echo disconnect proxy_con_4;
+disconnect proxy_con_4;
+--echo disconnect proxy_con_5;
+disconnect proxy_con_5;
+DROP USER ''@'',proxied_user_1,proxied_user_2,proxied_user_3,proxied_user_4,proxied_user_5;
+
+--echo ========== test 3 ==========================================
+
+GRANT ALL PRIVILEGES ON *.* TO plug_user
+ IDENTIFIED WITH test_plugin_server AS 'plug_dest';
+CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
+GRANT PROXY ON plug_dest TO plug_user;
+FLUSH PRIVILEGES;
+
+# Not working with the patch.
+
+#--replace_result $MYSQLADMIN MYSQLADMIN $MASTER_MYPORT MYPORT $MASTER_MYSOCK MYSOCK
+#--exec $MYSQLADMIN $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -S $MASTER_MYSOCK -u plug_user --password=plug_dest ping 2>&1
+#--replace_result $MYSQL_CHECK MYSQL_CHECK $MASTER_MYPORT MYPORT
+#--exec $MYSQL_CHECK $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u plug_user --password=plug_dest test
+#--replace_result $MYSQL_DUMP MYSQL_DUMP $MASTER_MYPORT MYPORT
+#--exec $MYSQL_DUMP -h localhost -P $MASTER_MYPORT $PLUGIN_AUTH_OPT -u plug_user --password=plug_dest test
+#--replace_result $MYSQL_SHOW MYSQL_SHOW $MASTER_MYPORT MYPORT
+#--exec $MYSQL_SHOW $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --plugin_dir=../plugin/auth -u plug_user --password=plug_dest 2>&1
+DROP USER plug_user, plug_dest;
+DROP DATABASE test_user_db;
+--exit
diff --git a/mysql-test/t/plugin_auth_qa_2-master.opt b/mysql-test/t/plugin_auth_qa_2-master.opt
new file mode 100644
index 00000000000..354907b9366
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa_2-master.opt
@@ -0,0 +1,2 @@
+$PLUGIN_AUTH_INTERFACE_OPT
+$PLUGIN_AUTH_INTERFACE_LOAD
diff --git a/mysql-test/t/plugin_auth_qa_2.test b/mysql-test/t/plugin_auth_qa_2.test
new file mode 100644
index 00000000000..e265690dc7d
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa_2.test
@@ -0,0 +1,153 @@
+# Horst Hunger
+# Created: 2010-10-06
+#
+# Test of the authentification interface. The plugin checks the expected values set
+# by this application and the application checks the values set the the plugin.
+--source include/have_plugin_interface.inc
+--source include/not_embedded.inc
+
+CREATE DATABASE test_user_db;
+
+--echo ========== test 1.1.3.2 ====================================
+--echo === check contens of components of info ====================
+
+CREATE USER qa_test_1_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_1_dest';
+CREATE USER qa_test_1_dest IDENTIFIED BY 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_1_dest identified by 'dest_passwd';
+GRANT PROXY ON qa_test_1_dest TO qa_test_1_user;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+SELECT @@proxy_user;
+SELECT @@external_user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_1_user --password=qa_test_1_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_1_user --password=qa_test_1_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+
+DROP USER qa_test_1_user;
+DROP USER qa_test_1_dest;
+
+--echo === Assign values to components of info ====================
+
+CREATE USER qa_test_2_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_2_dest';
+CREATE USER qa_test_2_dest IDENTIFIED BY 'dest_passwd';
+CREATE USER authenticated_as IDENTIFIED BY 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_2_dest identified by 'dest_passwd';
+GRANT PROXY ON qa_test_2_dest TO qa_test_2_user;
+GRANT PROXY ON authenticated_as TO qa_test_2_user;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+SELECT @@proxy_user;
+SELECT @@external_user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
+
+DROP USER qa_test_2_user;
+DROP USER qa_test_2_dest;
+DROP USER authenticated_as;
+
+--echo === Assign too high values for *length, which should have no effect ====
+
+CREATE USER qa_test_3_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_3_dest';
+CREATE USER qa_test_3_dest IDENTIFIED BY 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_3_dest identified by 'dest_passwd';
+GRANT PROXY ON qa_test_3_dest TO qa_test_3_user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_3_user --password=qa_test_3_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+DROP USER qa_test_3_user;
+DROP USER qa_test_3_dest;
+
+--echo === Assign too low values for *length, which should have no effect ====
+
+CREATE USER qa_test_4_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_4_dest';
+CREATE USER qa_test_4_dest IDENTIFIED BY 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_4_dest identified by 'dest_passwd';
+GRANT PROXY ON qa_test_4_dest TO qa_test_4_user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT -u qa_test_4_user --password=qa_test_4_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+DROP USER qa_test_4_user;
+DROP USER qa_test_4_dest;
+
+--echo === Assign empty string especially to authenticated_as (in plugin) ====
+
+CREATE USER qa_test_5_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_5_dest';
+CREATE USER qa_test_5_dest IDENTIFIED BY 'dest_passwd';
+CREATE USER ''@'localhost' IDENTIFIED BY 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_5_dest identified by 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO ''@'localhost' identified by 'dest_passwd';
+GRANT PROXY ON qa_test_5_dest TO qa_test_5_user;
+GRANT PROXY ON qa_test_5_dest TO ''@'localhost';
+
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--error 1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+DROP USER qa_test_5_user;
+DROP USER qa_test_5_dest;
+DROP USER ''@'localhost';
+
+--echo === Assign 'root' especially to authenticated_as (in plugin) ====
+
+CREATE USER qa_test_6_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_6_dest';
+CREATE USER qa_test_6_dest IDENTIFIED BY 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_6_dest identified by 'dest_passwd';
+GRANT PROXY ON qa_test_6_dest TO qa_test_6_user;
+
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--error 1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+GRANT PROXY ON qa_test_6_dest TO root IDENTIFIED WITH qa_auth_interface AS 'qa_test_6_dest';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--error 1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+REVOKE PROXY ON qa_test_6_dest FROM root;
+--sorted_result
+SELECT user,plugin,authentication_string FROM mysql.user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--error 1
+--exec $MYSQL $PLUGIN_AUTH_OPT -h localhost -P $MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+DROP USER qa_test_6_user;
+DROP USER qa_test_6_dest;
+DELETE FROM mysql.user WHERE user='root' AND plugin='qa_auth_interface';
+--sorted_result
+SELECT user,plugin,authentication_string,password FROM mysql.user;
+
+
+--echo === Test of the --default_auth option for clients ====
+
+CREATE USER qa_test_11_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_11_dest';
+CREATE USER qa_test_11_dest IDENTIFIED BY 'dest_passwd';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_11_dest identified by 'dest_passwd';
+GRANT PROXY ON qa_test_11_dest TO qa_test_11_user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--error 1
+--exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+DROP USER qa_test_11_user, qa_test_11_dest;
+DROP DATABASE test_user_db;
+
+--exit
diff --git a/mysql-test/t/plugin_auth_qa_3-master.opt b/mysql-test/t/plugin_auth_qa_3-master.opt
new file mode 100644
index 00000000000..e1754862a4d
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa_3-master.opt
@@ -0,0 +1,2 @@
+$PLUGIN_AUTH_SERVER_OPT
+$PLUGIN_AUTH_SERVER_LOAD
diff --git a/mysql-test/t/plugin_auth_qa_3.test b/mysql-test/t/plugin_auth_qa_3.test
new file mode 100644
index 00000000000..f7d90226332
--- /dev/null
+++ b/mysql-test/t/plugin_auth_qa_3.test
@@ -0,0 +1,25 @@
+# Horst Hunger
+# Created: 2010-10-06
+#
+# Test of the authentification interface. The plugin checks the expected values set
+# by this application and the application checks the values set the the plugin.
+--source include/have_plugin_server.inc
+--source include/not_embedded.inc
+
+CREATE DATABASE test_user_db;
+
+CREATE USER qa_test_11_user IDENTIFIED WITH qa_auth_server AS 'qa_test_11_dest';
+GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_11_dest identified by 'dest_passwd';
+GRANT PROXY ON qa_test_11_dest TO qa_test_11_user;
+
+--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_11_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+--echo exec MYSQL PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P MASTER_MYPORT -u qa_test_2_user --password=qa_test_11_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+--error 1
+--exec $MYSQL $PLUGIN_AUTH_OPT --default_auth=qa_auth_client -h localhost -P $MASTER_MYPORT -u qa_test_2_user --password=qa_test_2_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
+
+DROP USER qa_test_11_user, qa_test_11_dest;
+DROP DATABASE test_user_db;
+
+--exit
diff --git a/mysql-test/t/plugin_load_option-master.opt b/mysql-test/t/plugin_load_option-master.opt
new file mode 100644
index 00000000000..e22ecb4ff3a
--- /dev/null
+++ b/mysql-test/t/plugin_load_option-master.opt
@@ -0,0 +1,3 @@
+$EXAMPLE_PLUGIN_OPT
+$EXAMPLE_PLUGIN_LOAD
+--loose-plugin-example=FORCE_PLUS_PERMANENT
diff --git a/mysql-test/t/plugin_load_option.test b/mysql-test/t/plugin_load_option.test
new file mode 100644
index 00000000000..e49b693b5be
--- /dev/null
+++ b/mysql-test/t/plugin_load_option.test
@@ -0,0 +1,8 @@
+--source include/not_windows_embedded.inc
+--source include/have_example_plugin.inc
+
+--error ER_PLUGIN_IS_PERMANENT
+UNINSTALL PLUGIN example;
+
+SELECT PLUGIN_NAME, PLUGIN_STATUS, LOAD_OPTION FROM INFORMATION_SCHEMA.PLUGINS
+WHERE PLUGIN_NAME IN ('MyISAM', 'EXAMPLE');
diff --git a/mysql-test/t/plugin_not_embedded.test b/mysql-test/t/plugin_not_embedded.test
index 40024efcaad..a2b7b8a0fe4 100644
--- a/mysql-test/t/plugin_not_embedded.test
+++ b/mysql-test/t/plugin_not_embedded.test
@@ -8,7 +8,7 @@
GRANT INSERT ON mysql.plugin TO bug51770@localhost;
connect(con1,localhost,bug51770,,);
--replace_regex /\.dll/.so/
-eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
+eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN';
--error ER_TABLEACCESS_DENIED_ERROR
UNINSTALL PLUGIN example;
connection default;
@@ -25,7 +25,7 @@ DROP USER bug51770@localhost;
# The bug consisted of not recognizing / on Windows, so checking / on
# all platforms should cover this case.
-let $path = `select CONCAT_WS('/', '..', $HA_EXAMPLE_SO)`;
+let $path = `select CONCAT_WS('/', '..', '$EXAMPLE_PLUGIN')`;
--replace_regex /\.dll/.so/
--error ER_UDF_NO_PATHS
eval INSTALL PLUGIN example SONAME '$path';
diff --git a/mysql-test/t/profiling.test b/mysql-test/t/profiling.test
index 275c2d77c4a..1e1aada7c15 100644
--- a/mysql-test/t/profiling.test
+++ b/mysql-test/t/profiling.test
@@ -1,4 +1,4 @@
---source include/have_community_features.inc
+--source include/have_profiling.inc
# Verify that the protocol isn't violated if we ask for profiling info
# before profiling has recorded anything.
@@ -9,10 +9,6 @@ show profile all;
show session variables like 'profil%';
select @@profiling;
-# setting global variable is an error
---error ER_LOCAL_VARIABLE
-set global profiling = ON;
-
# But size is okay
set @start_value= @@global.profiling_history_size;
set global profiling_history_size=100;
diff --git a/mysql-test/t/ps-master.opt b/mysql-test/t/ps-master.opt
index 31c287d2bb5..1deeb6c9c63 100644
--- a/mysql-test/t/ps-master.opt
+++ b/mysql-test/t/ps-master.opt
@@ -1 +1 @@
---log-output=table,file --log-slow-queries --log-long-format --log-queries-not-using-indexes
+--log-output=table,file --log-slow-queries --log-queries-not-using-indexes
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 9b3f3e750e1..e00bd785789 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -3101,4 +3101,264 @@ EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
+--echo
--echo End of 5.1 tests.
+
+###########################################################################
+
+--echo
+--echo #
+--echo # WL#4435: Support OUT-parameters in prepared statements.
+--echo #
+--echo
+
+# The idea of this test case is to check that
+# - OUT-parameters of four allowed types (string, double, int, decimal) work
+# properly;
+# - INOUT and OUT parameters work properly;
+# - A mix of IN and OUT parameters work properly;
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p_string;
+DROP PROCEDURE IF EXISTS p_double;
+DROP PROCEDURE IF EXISTS p_int;
+DROP PROCEDURE IF EXISTS p_decimal;
+--enable_warnings
+
+delimiter |;
+
+--echo
+CREATE PROCEDURE p_string(
+ IN v0 INT,
+ OUT v1 CHAR(32),
+ IN v2 CHAR(32),
+ INOUT v3 CHAR(32))
+BEGIN
+ SET v0 = -1;
+ SET v1 = 'test_v1';
+ SET v2 = 'n/a';
+ SET v3 = 'test_v3';
+END|
+
+--echo
+CREATE PROCEDURE p_double(
+ IN v0 INT,
+ OUT v1 DOUBLE(4, 2),
+ IN v2 DOUBLE(4, 2),
+ INOUT v3 DOUBLE(4, 2))
+BEGIN
+ SET v0 = -1;
+ SET v1 = 12.34;
+ SET v2 = 98.67;
+ SET v3 = 56.78;
+END|
+
+--echo
+CREATE PROCEDURE p_int(
+ IN v0 CHAR(10),
+ OUT v1 INT,
+ IN v2 INT,
+ INOUT v3 INT)
+BEGIN
+ SET v0 = 'n/a';
+ SET v1 = 1234;
+ SET v2 = 9876;
+ SET v3 = 5678;
+END|
+
+--echo
+CREATE PROCEDURE p_decimal(
+ IN v0 INT,
+ OUT v1 DECIMAL(4, 2),
+ IN v2 DECIMAL(4, 2),
+ INOUT v3 DECIMAL(4, 2))
+BEGIN
+ SET v0 = -1;
+ SET v1 = 12.34;
+ SET v2 = 98.67;
+ SET v3 = 56.78;
+END|
+
+delimiter ;|
+
+--echo
+PREPARE stmt_str FROM 'CALL p_string(?, ?, ?, ?)';
+PREPARE stmt_dbl FROM 'CALL p_double(?, ?, ?, ?)';
+PREPARE stmt_int FROM 'CALL p_int(?, ?, ?, ?)';
+PREPARE stmt_dec FROM 'CALL p_decimal(?, ?, ?, ?)';
+
+--echo
+SET @x_str_1 = NULL;
+SET @x_str_2 = NULL;
+SET @x_str_3 = NULL;
+SET @x_dbl_1 = NULL;
+SET @x_dbl_2 = NULL;
+SET @x_dbl_3 = NULL;
+SET @x_int_1 = NULL;
+SET @x_int_2 = NULL;
+SET @x_int_3 = NULL;
+SET @x_dec_1 = NULL;
+SET @x_dec_2 = NULL;
+SET @x_dec_3 = NULL;
+
+--echo
+--echo -- Testing strings...
+
+--echo
+EXECUTE stmt_str USING @x_int_1, @x_str_1, @x_str_2, @x_str_3;
+SELECT @x_int_1, @x_str_1, @x_str_2, @x_str_3;
+
+--echo
+EXECUTE stmt_str USING @x_int_1, @x_str_1, @x_str_2, @x_str_3;
+SELECT @x_int_1, @x_str_1, @x_str_2, @x_str_3;
+
+--echo
+--echo -- Testing doubles...
+
+--echo
+EXECUTE stmt_dbl USING @x_int_1, @x_dbl_1, @x_dbl_2, @x_dbl_3;
+SELECT @x_int_1, @x_dbl_1, @x_dbl_2, @x_dbl_3;
+
+--echo
+EXECUTE stmt_dbl USING @x_int_1, @x_dbl_1, @x_dbl_2, @x_dbl_3;
+SELECT @x_int_1, @x_dbl_1, @x_dbl_2, @x_dbl_3;
+
+--echo
+--echo -- Testing ints...
+
+--echo
+EXECUTE stmt_int USING @x_str_1, @x_int_1, @x_int_2, @x_int_3;
+SELECT @x_str_1, @x_int_1, @x_int_2, @x_int_3;
+
+--echo
+EXECUTE stmt_int USING @x_str_1, @x_int_1, @x_int_2, @x_int_3;
+SELECT @x_str_1, @x_int_1, @x_int_2, @x_int_3;
+
+--echo
+--echo -- Testing decs...
+
+--echo
+EXECUTE stmt_dec USING @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3;
+SELECT @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3;
+
+--echo
+EXECUTE stmt_dec USING @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3;
+SELECT @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3;
+
+--echo
+DEALLOCATE PREPARE stmt_str;
+DEALLOCATE PREPARE stmt_dbl;
+DEALLOCATE PREPARE stmt_int;
+DEALLOCATE PREPARE stmt_dec;
+
+--echo
+DROP PROCEDURE p_string;
+DROP PROCEDURE p_double;
+DROP PROCEDURE p_int;
+DROP PROCEDURE p_decimal;
+
+#
+# Another test case for WL#4435: check out parameters in Dynamic SQL.
+#
+
+--echo
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+--enable_warnings
+
+--echo
+
+CREATE PROCEDURE p1(OUT v1 CHAR(10))
+ SET v1 = 'test1';
+
+--echo
+
+delimiter |;
+CREATE PROCEDURE p2(OUT v2 CHAR(10))
+BEGIN
+ SET @query = 'CALL p1(?)';
+ PREPARE stmt1 FROM @query;
+ EXECUTE stmt1 USING @u1;
+ DEALLOCATE PREPARE stmt1;
+
+ SET v2 = @u1;
+END|
+delimiter ;|
+
+--echo
+
+CALL p2(@a);
+SELECT @a;
+
+--echo
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+
+###########################################################################
+
+--source t/wl4435_generated.inc
+
+###########################################################################
+
+--echo
+--echo # End of WL#4435.
+
+###########################################################################
+
+
+--echo #
+--echo # WL#4284: Transactional DDL locking
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a INT);
+BEGIN;
+SELECT * FROM t1;
+--echo # Test that preparing a CREATE TABLE does not take a exclusive metdata lock.
+PREPARE stmt1 FROM "CREATE TABLE t1 AS SELECT 1";
+--error ER_TABLE_EXISTS_ERROR
+EXECUTE stmt1;
+DEALLOCATE PREPARE stmt1;
+DROP TABLE t1;
+
+--echo #
+--echo # WL#4284: Transactional DDL locking
+--echo #
+--echo # Test that metadata locks taken during prepare are released.
+--echo #
+
+connect(con1,localhost,root,,);
+connection default;
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a INT);
+connection con1;
+BEGIN;
+PREPARE stmt1 FROM "SELECT * FROM t1";
+connection default;
+DROP TABLE t1;
+disconnect con1;
+
+--echo
+--echo #
+--echo # Bug#56115: invalid memory reads when PS selecting from
+--echo # information_schema tables
+--echo # Bug#58701: crash in Field::make_field, cursor-protocol
+--echo #
+--echo # NOTE: MTR should be run both with --ps-protocol and --cursor-protocol.
+--echo #
+--echo
+
+SELECT *
+FROM (SELECT 1 UNION SELECT 2) t;
+
+
+--echo #
+--echo # End of 5.5 tests.
+
+###########################################################################
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index 387b3ebdd05..b9e84d8d7df 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -458,9 +458,6 @@ prepare stmt1 from ' analyze table t1 ' ;
prepare stmt1 from ' checksum table t1 ' ;
prepare stmt1 from ' repair table t1 ' ;
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_UNSUPPORTED_PS
-eval prepare stmt1 from ' restore table t1 from ''$datafile'' ' ;
--remove_file $datafile
## handler
diff --git a/mysql-test/t/ps_3innodb-master.opt b/mysql-test/t/ps_3innodb-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/ps_3innodb-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/ps_3innodb.test b/mysql-test/t/ps_3innodb.test
index e25a8b1f469..10d2e7a9ae5 100644
--- a/mysql-test/t/ps_3innodb.test
+++ b/mysql-test/t/ps_3innodb.test
@@ -8,6 +8,10 @@
# NOTE: PLEASE SEE ps_1general.test (bottom)
# BEFORE ADDING NEW TEST CASES HERE !!!
+# See Bug#38999 valgrind warnings for update statement in function
+# compare_record()
+-- source include/not_valgrind.inc
+
use test;
-- source include/have_innodb.inc
diff --git a/mysql-test/t/ps_ddl.test b/mysql-test/t/ps_ddl.test
index 1543c757908..3803a0daf52 100644
--- a/mysql-test/t/ps_ddl.test
+++ b/mysql-test/t/ps_ddl.test
@@ -278,8 +278,6 @@ deallocate prepare stmt;
--echo # Test 7-a: dependent PROCEDURE has changed
--echo #
---echo # Note, this scenario is not supported, subject of Bug#12093
---echo #
create table t1 (a int);
create trigger t1_ai after insert on t1 for each row
@@ -291,11 +289,10 @@ execute stmt using @var;
drop procedure p1;
create procedure p1 (a int) begin end;
set @var= 2;
---error ER_SP_DOES_NOT_EXIST
execute stmt using @var;
--echo # Cleanup
drop procedure p1;
-call p_verify_reprepare_count(0);
+call p_verify_reprepare_count(1);
--echo # Test 7-b: dependent FUNCTION has changed
--echo #
@@ -355,11 +352,13 @@ set @var=8;
--echo # XXX: bug, the SQL statement in the trigger is still
--echo # pointing at table 't3', since the view was expanded
--echo # at first statement execution.
+--echo # Since the view definition is inlined in the statement
+--echo # at prepare, changing the view definition does not cause
+--echo # repreparation.
--echo # Repreparation of the main statement doesn't cause repreparation
--echo # of trigger statements.
---error ER_NO_SUCH_TABLE
execute stmt using @var;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
--echo #
--echo # Sic: the insert went into t3, even though the view now
--echo # points at t2. This is because neither the merged view
@@ -642,6 +641,9 @@ deallocate prepare stmt;
--echo Part 16: VIEW -> TEMPORARY TABLE transitions
--echo =====================================================================
+--echo #
+--echo # Test 1: Merged view
+--echo #
create table t2 (a int);
insert into t2 (a) values (1);
create view t1 as select * from t2;
@@ -651,9 +653,39 @@ execute stmt;
call p_verify_reprepare_count(0);
create temporary table t1 (a int);
+# t1 still refers to the view - no reprepare has been done.
execute stmt;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
+
+drop view t1;
+# t1 still refers to the, now deleted, view - no reprepare has been done.
+--error ER_NO_SUCH_TABLE
+execute stmt;
+call p_verify_reprepare_count(0);
+
+drop table t2;
+drop temporary table t1;
+deallocate prepare stmt;
+
+--echo #
+--echo # Test 2: Materialized view
+--echo #
+create table t2 (a int);
+insert into t2 (a) values (1);
+create algorithm = temptable view t1 as select * from t2;
+
+prepare stmt from "select * from t1";
+execute stmt;
+call p_verify_reprepare_count(0);
+
+create temporary table t1 (a int);
+# t1 still refers to the view - no reprepare has been done.
+execute stmt;
+call p_verify_reprepare_count(0);
+
drop view t1;
+# t1 still refers to the, now deleted, view - no reprepare has been done.
+--error ER_NO_SUCH_TABLE
execute stmt;
call p_verify_reprepare_count(0);
@@ -661,6 +693,28 @@ drop table t2;
drop temporary table t1;
deallocate prepare stmt;
+--echo #
+--echo # Test 3: View referencing an Information schema table
+--echo #
+create view t1 as select table_name from information_schema.views;
+
+prepare stmt from "select * from t1";
+execute stmt;
+call p_verify_reprepare_count(0);
+
+create temporary table t1 (a int);
+# t1 has been substituted with a reference to the IS table
+execute stmt;
+call p_verify_reprepare_count(0);
+
+drop view t1;
+# Since the IS table has been substituted in, the statement still works
+execute stmt;
+call p_verify_reprepare_count(0);
+
+drop temporary table t1;
+deallocate prepare stmt;
+
--echo =====================================================================
--echo Part 17: VIEW -> VIEW (DDL) transitions
--echo =====================================================================
@@ -1447,7 +1501,7 @@ drop table t2;
create temporary table t2 (a int);
# Temporary table and base table are not in the same name space.
execute stmt;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
--error ER_TABLE_EXISTS_ERROR
execute stmt;
call p_verify_reprepare_count(1);
@@ -1457,7 +1511,7 @@ execute stmt;
call p_verify_reprepare_count(0);
drop table t2;
execute stmt;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
drop table t2;
# View with name of table to be created exists
# Attention:
@@ -1494,27 +1548,24 @@ execute stmt;
call p_verify_reprepare_count(0);
drop table t1;
deallocate prepare stmt;
---echo # XXX: no validation of the first table in case of
---echo # CREATE TEMPORARY TABLE. This is a shortcoming of the current code,
---echo # but since validation is not strictly necessary, nothing is done
---echo # about it.
---echo # Will be fixed as part of work on Bug#21431 "Incomplete support of
---echo # temporary tables"
create table t1 (a int);
insert into t1 (a) values (1);
prepare stmt from "create temporary table if not exists t2 as select * from t1";
execute stmt;
drop table t2;
execute stmt;
+call p_verify_reprepare_count(0);
execute stmt;
+call p_verify_reprepare_count(1);
select * from t2;
execute stmt;
+call p_verify_reprepare_count(0);
select * from t2;
drop table t2;
create temporary table t2 (a varchar(10));
execute stmt;
select * from t2;
-call p_verify_reprepare_count(0);
+call p_verify_reprepare_count(1);
drop table t1;
create table t1 (x int);
execute stmt;
diff --git a/mysql-test/t/ps_ddl1.test b/mysql-test/t/ps_ddl1.test
index 379ed576b5f..0145d445a14 100644
--- a/mysql-test/t/ps_ddl1.test
+++ b/mysql-test/t/ps_ddl1.test
@@ -363,7 +363,7 @@ end|
delimiter ;|
--error ER_SP_DOES_NOT_EXIST
execute stmt;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
--error ER_SP_DOES_NOT_EXIST
execute stmt;
call p_verify_reprepare_count(0);
diff --git a/mysql-test/t/ps_not_windows.test b/mysql-test/t/ps_not_windows.test
index 0ab08b59f1e..2003251dc55 100644
--- a/mysql-test/t/ps_not_windows.test
+++ b/mysql-test/t/ps_not_windows.test
@@ -3,7 +3,9 @@
# Non-windows specific ps tests.
--source include/not_windows.inc
# requires dynamic loading
---source include/have_dynamic_loading.inc
+if (`SELECT @@have_dynamic_loading != 'YES'`) {
+ --skip ps_not_windows requires dynamic loading
+}
#
# Bug #20665: All commands supported in Stored Procedures should work in
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 0edc9cca385..51e362d4916 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -94,10 +94,6 @@ select sql_cache * from t1 union select * from t1;
set query_cache_type=2;
select sql_cache * from t1 union select * from t1;
-# all sql_cache statements, except for the first select, are ignored.
-select * from t1 union select sql_cache * from t1;
-select * from t1 where a IN (select sql_cache a from t1);
-select * from t1 where a IN (select a from t1 union select sql_cache a from t1);
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
set query_cache_type=on;
@@ -110,15 +106,6 @@ show status like "Qcache_queries_in_cache";
# SELECT SQL_NO_CACHE
#
select sql_no_cache * from t1;
-# sql_no_cache can occur in any nested select to turn on cacheing for the whole
-# expression and it will always override a sql_cache statement.
-select * from t1 union select sql_no_cache * from t1;
-select * from t1 where a IN (select sql_no_cache a from t1);
-select * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
-select sql_cache sql_no_cache * from t1;
-select sql_cache * from t1 union select sql_no_cache * from t1;
-select sql_cache * from t1 where a IN (select sql_no_cache a from t1);
-select sql_cache * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
show status like "Qcache_queries_in_cache";
drop table t1;
#
@@ -511,12 +498,20 @@ drop table t1,t2,t3,t4;
set query_cache_wlock_invalidate=1;
create table t1 (a int not null);
create table t2 (a int not null);
+create view v1 as select * from t1;
select * from t1;
select * from t2;
show status like "Qcache_queries_in_cache";
lock table t1 write, t2 read;
show status like "Qcache_queries_in_cache";
unlock table;
+select * from t1;
+# Implicit locking of t1 does not invalidate QC
+show status like "Qcache_queries_in_cache";
+lock table v1 write;
+show status like "Qcache_queries_in_cache";
+unlock table;
+drop view v1;
drop table t1,t2;
set query_cache_wlock_invalidate=default;
@@ -953,9 +948,9 @@ set global query_cache_size=0;
create table t1 (a int);
insert into t1 values (1),(2),(3);
set GLOBAL query_cache_type=1;
-set GLOBAL query_cache_limit=10000;
+set GLOBAL query_cache_limit=10240;
set GLOBAL query_cache_min_res_unit=0;
-set GLOBAL query_cache_size= 100000;
+set GLOBAL query_cache_size= 102400;
# default_week_format
reset query cache;
@@ -1023,7 +1018,7 @@ set GLOBAL query_cache_size= default;
# Bug#28897 UUID() returns non-unique values when query cache is enabled
#
-set GLOBAL query_cache_size=1000000;
+set GLOBAL query_cache_size=1024000;
create table t1 (a char);
insert into t1 values ('c');
@@ -1044,22 +1039,25 @@ set GLOBAL query_cache_size= default;
# Bug #29053 SQL_CACHE in UNION causes non-deterministic functions to be cached
#
-set GLOBAL query_cache_size=1000000;
-
-create table t1 (a char);
-insert into t1 values ('c');
-
-let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`;
-let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`;
-
+# This syntax is no longer allowed, therefore the test case has been commented
+# out.
+# See test for Bug#35020 below.
+#set GLOBAL query_cache_size=1000000;
+#
+#create table t1 (a char);
+#insert into t1 values ('c');
+#
+#let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`;
+#let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`;
+#
# disabling the logging of the query because the times are different each run.
---disable_query_log
-eval select a from t1 where "$q1" = "$q2";
---enable_query_log
-
-drop table t1;
-
-set GLOBAL query_cache_size= default;
+#--disable_query_log
+#eval select a from t1 where "$q1" = "$q2";
+#--enable_query_log
+#
+#drop table t1;
+#
+#set GLOBAL query_cache_size= default;
#
# Bug#29856: Insufficient buffer space led to a server crash.
@@ -1189,7 +1187,7 @@ SET GLOBAL query_cache_size= default;
--echo #
--echo # Bug#25132 disabled query cache: Qcache_free_blocks = 1
--echo #
-set global query_cache_size=100000;
+set global query_cache_size=102400;
set global query_cache_size=0;
set global query_cache_type=0;
show status like 'Qcache_free_blocks';
@@ -1307,5 +1305,88 @@ SELECT 1 FROM t1 GROUP BY
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
+
+#
+# Bug#35020: illegal sql_cache select syntax
+#
+CREATE TABLE t1( a INT );
+
+--error ER_PARSE_ERROR
+SET @v = ( SELECT SQL_CACHE 1 );
+--error ER_PARSE_ERROR
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+
+#
+# Keywords 'SQL_CACHE' and 'SQL_NO_CACHE' are allowed as column names.
+# Hence the error messages are not intuitive.
+#
+--error ER_BAD_FIELD_ERROR
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+
+SELECT SQL_CACHE * FROM t1;
+SELECT SQL_NO_CACHE * FROM t1;
+
+# SQL_CACHE is only allowed once in first top-level select.
+--error ER_CANT_USE_OPTION_HERE
+SELECT * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN (SELECT SQL_CACHE a FROM t1);
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN (SELECT a FROM t1 UNION SELECT SQL_CACHE a FROM t1);
+
+--error ER_CANT_USE_OPTION_HERE
+SELECT * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN (SELECT SQL_NO_CACHE a FROM t1);
+--error ER_BAD_FIELD_ERROR
+SELECT * FROM t1 WHERE a IN
+ (SELECT a FROM t1 UNION SELECT SQL_NO_CACHE a FROM t1);
+--error ER_WRONG_USAGE
+SELECT SQL_CACHE SQL_NO_CACHE * FROM t1;
+--error ER_WRONG_USAGE
+SELECT SQL_NO_CACHE SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_CACHE * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_CACHE * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_NO_CACHE * FROM t1 UNION SELECT SQL_CACHE * FROM t1;
+--error ER_CANT_USE_OPTION_HERE
+SELECT SQL_NO_CACHE * FROM t1 UNION SELECT SQL_NO_CACHE * FROM t1;
+--error ER_BAD_FIELD_ERROR
+SELECT SQL_CACHE * FROM t1 WHERE a IN
+ (SELECT SQL_NO_CACHE a FROM t1);
+--error ER_BAD_FIELD_ERROR
+SELECT SQL_CACHE * FROM t1 WHERE a IN
+ (SELECT a FROM t1 UNION SELECT SQL_NO_CACHE a FROM t1);
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug#51336 Assert in reload_acl_and_cache during RESET QUERY CACHE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(id INT);
+
+START TRANSACTION;
+SELECT * FROM t1;
+# This caused an assert
+RESET QUERY CACHE;
+
+COMMIT;
+DROP TABLE t1;
diff --git a/mysql-test/t/query_cache_28249.test b/mysql-test/t/query_cache_28249.test
index 390a1ce6e3d..b1be7c57343 100644
--- a/mysql-test/t/query_cache_28249.test
+++ b/mysql-test/t/query_cache_28249.test
@@ -30,7 +30,7 @@ connection user1;
SET GLOBAL query_cache_type=1;
SET GLOBAL query_cache_limit=10000;
SET GLOBAL query_cache_min_res_unit=0;
-SET GLOBAL query_cache_size= 100000;
+SET GLOBAL query_cache_size= 102400;
FLUSH TABLES;
--disable_warnings
@@ -58,18 +58,18 @@ connection user3;
# Typical information_schema.processlist content after sufficient sleep time
# ID USER COMMAND TIME STATE INFO
# ....
-# 2 root Query 5 Locked SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
+# 2 root Query 5 Waiting for table metadata lock SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
# ....
# XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# The values marked with 'X' must be reached.
--echo # Poll till the select of connection user1 is blocked by the write lock on t1.
let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist
-WHERE state = 'Locked'
+WHERE state = 'Waiting for table metadata lock'
AND info = '$select_for_qc';
--source include/wait_condition.inc
eval
SELECT user,command,state,info FROM information_schema.processlist
-WHERE state = 'Locked'
+WHERE state = 'Waiting for table metadata lock'
AND info = '$select_for_qc';
INSERT INTO t1 VALUES (4);
diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test
index d30cd458e99..70b3c81168d 100644
--- a/mysql-test/t/query_cache_debug.test
+++ b/mysql-test/t/query_cache_debug.test
@@ -1,6 +1,6 @@
--source include/not_embedded.inc
--source include/have_query_cache.inc
---source include/have_debug.inc
+--source include/have_debug_sync.inc
#
# Bug #30887 Server crashes on SET GLOBAL query_cache_size=0
@@ -18,12 +18,11 @@ connect (bug30887con2, localhost, root, ,test);
connection bug30887con1;
--echo Activate debug hook and attempt to retrieve the statement from the cache.
-set session debug='+d,wait_in_query_cache_insert';
+set debug_sync="wait_in_query_cache_insert SIGNAL parked WAIT_FOR go";
--send select SQL_CACHE * from t1;
connection default;
-let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'wait_in_query_cache_insert';
---source include/wait_condition.inc
+set debug_sync="now WAIT_FOR parked";
connection bug30887con2;
--echo On a second connection; clear the query cache.
@@ -32,14 +31,18 @@ set global query_cache_size= 0;
connection default;
--echo Signal the debug hook to release the lock.
-select id from information_schema.processlist where state='wait_in_query_cache_insert' into @thread_id;
-kill query @thread_id;
+set debug_sync="now SIGNAL go";
--echo Show query cache status.
show status like 'Qcache_queries_in_cache';
+connection bug30887con1;
+--reap
+
disconnect bug30887con1;
disconnect bug30887con2;
+connection default;
+set debug_sync= 'RESET';
set global query_cache_size= 0;
use test;
drop table t1;
@@ -67,18 +70,14 @@ connect(con2,localhost,root,,test,,);
connection con1;
--echo # Switch to connection con1
-SET SESSION debug='+d,wait_after_query_cache_invalidate';
+SET DEBUG_SYNC = "wait_after_query_cache_invalidate SIGNAL parked WAIT_FOR go";
--echo # Send concurrent insert, will wait in the query cache table invalidate
--send INSERT INTO t1 VALUES (4)
connection default;
--echo # Switch to connection default
--echo # Wait for concurrent insert to reach the debug point
-let $wait_condition=
- SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
- WHERE STATE = "wait_after_query_cache_invalidate" AND
- INFO = "INSERT INTO t1 VALUES (4)";
---source include/wait_condition.inc
+SET DEBUG_SYNC = "now WAIT_FOR parked";
connection con2;
--echo # Switch to connection con2
@@ -88,9 +87,7 @@ SELECT * FROM t1;
connection default;
--echo # Switch to connection default
--echo # Notify the concurrent insert to proceed
-SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
- WHERE STATE = 'wait_after_query_cache_invalidate' INTO @thread_id;
-KILL QUERY @thread_id;
+SET DEBUG_SYNC = "now SIGNAL go";
connection con1;
--echo # Switch to connection con1
@@ -107,6 +104,7 @@ disconnect con2;
connection default;
--echo # Restore defaults
+SET DEBUG_SYNC= 'RESET';
RESET QUERY CACHE;
DROP TABLE t1,t2;
SET GLOBAL concurrent_insert= DEFAULT;
@@ -157,15 +155,14 @@ SELECT SQL_CACHE * FROM t1;
--echo ** before the mutex lock in invalidate_table_internal.
--echo ** This will allow new result sets to be written into the QC.
--echo **
-SET SESSION debug='+d,wait_in_query_cache_invalidate1';
-SET SESSION debug='+d,wait_in_query_cache_invalidate2';
+SET DEBUG_SYNC="wait_in_query_cache_invalidate1 SIGNAL parked1_1 WAIT_FOR go1_1";
+SET DEBUG_SYNC="wait_in_query_cache_invalidate2 SIGNAL parked1_2 WAIT_FOR go1_2";
--send DELETE FROM t1 WHERE a like '%a%';
connection default;
--echo =================================== Connection default
--echo ** Assert that the expect process status is obtained.
-LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state= 'wait_in_query_cache_invalidate1';
---source include/wait_condition.inc
+SET DEBUG_SYNC="now WAIT_FOR parked1_1";
-- echo **
connection thd2;
@@ -173,32 +170,36 @@ connection thd2;
--echo ** On THD2: Insert a result into the cache. This attempt will be blocked
--echo ** because of a debug hook placed just before the mutex lock after which
--echo ** the first part of the result set is written.
-SET SESSION debug='+d,wait_in_query_cache_insert';
+SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked2 WAIT_FOR go2 EXECUTE 1";
--send SELECT SQL_CACHE * FROM t2 UNION SELECT * FROM t3
+connection default;
+--echo =================================== Connection default
+--echo ** Assert that the SELECT-stmt thread reaches the sync point.
+SET DEBUG_SYNC="now WAIT_FOR parked2";
+--echo **
+--echo **
+
connection thd3;
--echo =================================== Connection thd3
--echo ** On THD3: Insert another result into the cache and block on the same
--echo ** debug hook.
-SET SESSION debug='+d,wait_in_query_cache_insert';
---send SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5;
+SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked3 WAIT_FOR go3 EXECUTE 1";
+--send SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5
connection default;
--echo =================================== Connection default
---echo ** Assert that the two SELECT-stmt threads to reach the hook.
-LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 2 FROM information_schema.processlist WHERE state='wait_in_query_cache_insert';
---source include/wait_condition.inc
+--echo ** Assert that the SELECT-stmt thread reaches the sync point.
+SET DEBUG_SYNC="now WAIT_FOR parked3";
--echo **
--echo **
--echo ** Signal the DELETE thread, THD1, to continue. It will enter the mutex
--echo ** lock and set query cache status to TABLE_FLUSH_IN_PROGRESS and then
--echo ** unlock the mutex before stopping on the next debug hook.
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate1' LIMIT 1 INTO @flush_thread_id;
-KILL QUERY @flush_thread_id;
+SET DEBUG_SYNC="now SIGNAL go1_1";
--echo ** Assert that we reach the next debug hook.
-LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2';
---source include/wait_condition.inc
+SET DEBUG_SYNC="now WAIT_FOR parked1_2";
--echo **
--echo ** Signal the remaining debug hooks blocking THD2 and THD3.
@@ -206,10 +207,18 @@ LET $wait_condition= SELECT SQL_NO_CACHE COUNT(*)= 1 FROM information_schema.pro
--echo ** and finally release the mutex. The threads will continue to wait
--echo ** until a broadcast signal reaches them causing both threads to
--echo ** come alive and check the condition.
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id ASC LIMIT 1 INTO @thread_id;
-KILL QUERY @thread_id;
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_insert' ORDER BY id DESC LIMIT 1 INTO @thread_id;
-KILL QUERY @thread_id;
+SET DEBUG_SYNC="now SIGNAL go2";
+--echo ** Wait for thd2 to receive the signal
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for query cache lock";
+--source include/wait_condition.inc
+SET DEBUG_SYNC="now SIGNAL go3";
+--echo ** Wait for thd3 to receive the signal
+let $wait_condition=
+ SELECT COUNT(*) = 2 FROM information_schema.processlist
+ WHERE state = "Waiting for query cache lock";
+--source include/wait_condition.inc
--echo **
--echo ** Finally signal the DELETE statement on THD1 one last time.
@@ -218,8 +227,7 @@ KILL QUERY @thread_id;
--echo ** One signal will be sent to the thread group waiting for executing
--echo ** invalidations and a broadcast signal will be sent to the thread
--echo ** group holding result set writers.
-SELECT SQL_NO_CACHE id FROM information_schema.processlist WHERE state='wait_in_query_cache_invalidate2' LIMIT 1 INTO @flush_thread_id;
-KILL QUERY @flush_thread_id;
+SET DEBUG_SYNC="now SIGNAL go1_2";
--echo **
--echo *************************************************************************
@@ -247,6 +255,7 @@ connection default;
disconnect thd1;
disconnect thd2;
disconnect thd3;
+SET DEBUG_SYNC= 'RESET';
SET GLOBAL query_cache_size= 0;
connection default;
@@ -256,4 +265,66 @@ FLUSH STATUS;
DROP TABLE t1,t2,t3,t4,t5;
SET GLOBAL query_cache_size= DEFAULT;
SET GLOBAL query_cache_type= DEFAULT;
-exit;
+
+--echo #
+--echo # Bug#56822: Add a thread state for sessions waiting on the query cache lock
+--echo #
+
+SET @old_query_cache_size= @@GLOBAL.query_cache_size;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+
+SET GLOBAL concurrent_insert= 1;
+SET GLOBAL query_cache_size= 1024*512;
+SET GLOBAL query_cache_type= ON;
+
+connect(con1,localhost,root,,test,,);
+connect(con2,localhost,root,,test,,);
+
+connection con1;
+--echo # Switch to connection con1
+SET DEBUG_SYNC = "wait_in_query_cache_invalidate2 SIGNAL parked WAIT_FOR go";
+--echo # Send INSERT, will wait in the query cache table invalidation
+--send INSERT INTO t1 VALUES (4);
+
+connection default;
+--echo # Switch to connection default
+--echo # Wait for insert to reach the debug point
+SET DEBUG_SYNC = "now WAIT_FOR parked";
+
+connection con2;
+--echo # Switch to connection con2
+--echo # Send a query that should wait on the query cache lock
+--send RESET QUERY CACHE
+
+connection default;
+--echo # Switch to connection default
+--echo # Wait for the state to be reflected in the processlist
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Waiting for query cache lock" AND info = "RESET QUERY CACHE";
+--source include/wait_condition.inc
+--echo # Signal that the query cache can be unlocked
+SET DEBUG_SYNC="now SIGNAL go";
+
+connection con1;
+--echo # Reap con1 and disconnect
+--reap
+disconnect con1;
+
+connection con2;
+--echo # Reap con2 and disconnect
+--reap
+disconnect con2;
+
+connection default;
+--echo # Restore defaults
+SET DEBUG_SYNC= 'RESET';
+RESET QUERY CACHE;
+DROP TABLE t1;
+SET GLOBAL query_cache_size= DEFAULT;
+SET GLOBAL query_cache_type= DEFAULT;
diff --git a/mysql-test/t/query_cache_disabled-master.opt b/mysql-test/t/query_cache_disabled-master.opt
new file mode 100644
index 00000000000..d7d47164883
--- /dev/null
+++ b/mysql-test/t/query_cache_disabled-master.opt
@@ -0,0 +1 @@
+--query_cache_type=0
diff --git a/mysql-test/t/query_cache_disabled.test b/mysql-test/t/query_cache_disabled.test
new file mode 100644
index 00000000000..cbc98bd94d6
--- /dev/null
+++ b/mysql-test/t/query_cache_disabled.test
@@ -0,0 +1,15 @@
+-- source include/have_query_cache.inc
+#
+# Bug#38551 query cache can still consume [very little] cpu time even when it is off.
+#
+SHOW GLOBAL VARIABLES LIKE 'query_cache_type';
+--error ER_QUERY_CACHE_DISABLED
+SET GLOBAL query_cache_type=ON;
+--error ER_QUERY_CACHE_DISABLED
+SET GLOBAL query_cache_type=DEMAND;
+--error ER_QUERY_CACHE_DISABLED
+SET GLOBAL query_cache_type=OFF;
+SET GLOBAL query_cache_size=1024*1024;
+SHOW GLOBAL VARIABLES LIKE 'query_cache_size';
+SET GLOBAL query_cache_size=0;
+
diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test
index 095d47f5bdf..77033ced564 100644
--- a/mysql-test/t/query_cache_notembedded.test
+++ b/mysql-test/t/query_cache_notembedded.test
@@ -99,6 +99,7 @@ connection root2;
SELECT * FROM t1;
connection root;
SELECT * FROM t1;
+UNLOCK TABLES;
drop table t1;
connection default;
disconnect root;
diff --git a/mysql-test/t/read_only_innodb.test b/mysql-test/t/read_only_innodb.test
index f8c25fdee1d..3bb626f2ca7 100644
--- a/mysql-test/t/read_only_innodb.test
+++ b/mysql-test/t/read_only_innodb.test
@@ -33,7 +33,7 @@ set global read_only=1;
connection con1;
select @@global.read_only;
select * from table_11733 ;
--- error ER_OPTION_PREVENTS_STATEMENT
+--error ER_OPTION_PREVENTS_STATEMENT
COMMIT;
connection default;
@@ -83,3 +83,149 @@ DROP USER test@localhost;
disconnect con1;
--echo echo End of 5.1 tests
+
+--echo #
+--echo # Bug#33669: Transactional temporary tables do not work under --read-only
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+--enable_warnings
+
+--echo # Setup user and tables
+CREATE USER bug33669@localhost;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT) ENGINE=INNODB;
+CREATE TABLE db1.t2 (a INT) ENGINE=INNODB;
+INSERT INTO db1.t1 VALUES (1);
+INSERT INTO db1.t2 VALUES (2);
+GRANT CREATE TEMPORARY TABLES, DROP, INSERT, DELETE, UPDATE,
+ SELECT, LOCK TABLES ON db1.* TO bug33669@localhost;
+SET GLOBAL READ_ONLY = ON;
+connect(con1,localhost,bug33669,,db1);
+--echo # Connection con1 (user bug33669):
+
+--echo
+--echo # Create, insert and drop temporary table:
+--echo
+CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB;
+INSERT INTO temp VALUES (1);
+DROP TABLE temp;
+
+--echo
+--echo # Lock base tables and use temporary table:
+--echo
+CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB;
+LOCK TABLES t1 READ, t2 READ;
+SELECT * FROM t1;
+INSERT INTO temp values (1);
+SELECT * FROM t2;
+UNLOCK TABLES;
+DROP TABLE temp;
+
+--echo
+--echo # Transaction
+--echo
+BEGIN;
+SELECT * FROM t1;
+CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB;
+--error ER_OPTION_PREVENTS_STATEMENT
+INSERT INTO t1 VALUES (1);
+INSERT INTO temp VALUES (1);
+SELECT * FROM t2;
+ROLLBACK;
+SELECT * FROM temp;
+DROP TABLE temp;
+
+--echo
+--echo # Lock base table as READ and temporary table as WRITE:
+--echo
+CREATE TEMPORARY TABLE temp (a INT) ENGINE=INNODB;
+LOCK TABLES t1 READ, temp WRITE;
+SELECT * FROM t1;
+SELECT * FROM temp;
+--error ER_OPTION_PREVENTS_STATEMENT
+INSERT INTO t1 VALUES (1);
+INSERT INTO temp VALUES (1);
+DROP TABLE temp;
+UNLOCK TABLES;
+
+--echo
+--echo # Lock temporary table that shadows a base table:
+--echo
+CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB;
+LOCK TABLES t1 WRITE;
+DROP TABLE t1;
+--error ER_TABLE_NOT_LOCKED
+SELECT * FROM t1;
+
+--echo
+--echo # INSERT SELECT from base table into temporary table:
+--echo
+
+CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB;
+CREATE TEMPORARY TABLE temp2 LIKE temp1;
+BEGIN;
+INSERT INTO temp1 VALUES (10);
+INSERT INTO temp2 VALUES (10);
+INSERT INTO temp1 SELECT * FROM t1;
+INSERT INTO temp2 SELECT * FROM t2;
+SELECT * FROM temp1 ORDER BY a;
+SELECT * FROM temp2 ORDER BY a;
+ROLLBACK;
+SELECT * FROM temp1,temp2;
+LOCK TABLES t1 READ, t2 READ;
+INSERT INTO temp1 VALUES (10);
+INSERT INTO temp2 VALUES (10);
+INSERT INTO temp1 SELECT * FROM t1;
+INSERT INTO temp2 SELECT * FROM t2;
+SELECT * FROM temp1 ORDER BY a;
+SELECT * FROM temp2 ORDER BY a;
+UNLOCK TABLES;
+DELETE temp1, temp2 FROM temp1, temp2;
+INSERT INTO temp1 VALUES (10);
+INSERT INTO temp2 VALUES (10);
+INSERT INTO temp1 SELECT * FROM t1;
+INSERT INTO temp2 SELECT * FROM t2;
+SELECT * FROM temp1 ORDER BY a;
+SELECT * FROM temp2 ORDER BY a;
+DROP TABLE temp1, temp2;
+
+--echo
+--echo # INSERT and INSERT SELECT that uses subqueries:
+CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB;
+CREATE TEMPORARY TABLE temp2 LIKE temp1;
+INSERT INTO temp1 (a) VALUES ((SELECT MAX(a) FROM t1));
+LOCK TABLES t2 READ;
+INSERT INTO temp2 (a) VALUES ((SELECT MAX(a) FROM t2));
+UNLOCK TABLES;
+LOCK TABLES t1 READ, t2 READ;
+INSERT INTO temp1 SELECT * FROM t1 WHERE a < (SELECT MAX(a) FROM t2);
+INSERT INTO temp2 SELECT * FROM t2 WHERE a > (SELECT MAX(a) FROM t1);
+UNLOCK TABLES;
+INSERT INTO temp1 SELECT * FROM t1 WHERE a < (SELECT MAX(a) FROM t2);
+INSERT INTO temp2 SELECT * FROM t2 WHERE a > (SELECT MAX(a) FROM t1);
+SELECT * FROM temp1 ORDER BY a;
+SELECT * FROM temp2 ORDER BY a;
+DROP TABLE temp1, temp2;
+
+--echo
+--echo # Multiple table update:
+--echo
+
+CREATE TEMPORARY TABLE temp1 (a INT) ENGINE=INNODB;
+CREATE TEMPORARY TABLE temp2 LIKE temp1;
+INSERT INTO temp1 VALUES (1),(2);
+INSERT INTO temp2 VALUES (3),(4);
+UPDATE temp1,temp2 SET temp1.a = 5, temp2.a = 10;
+SELECT * FROM temp1, temp2;
+DROP TABLE temp1, temp2;
+
+--echo
+--echo # Disconnect and cleanup
+--echo
+disconnect con1;
+connection default;
+SET GLOBAL READ_ONLY = OFF;
+DROP USER bug33669@localhost;
+DROP DATABASE db1;
diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test
index 5aa1a51a90f..bb90cbafd74 100644
--- a/mysql-test/t/rename.test
+++ b/mysql-test/t/rename.test
@@ -79,17 +79,15 @@ connection default;
--echo End of 4.1 tests
-#
-# Bug#14959: ALTER TABLE isn't able to rename a view
-#
+--echo #
+--echo # Bug#14959: "ALTER TABLE isn't able to rename a view"
+--echo # Bug#53976: "ALTER TABLE RENAME is allowed on views
+--echo # (not documented, broken)"
+--echo #
create table t1(f1 int);
create view v1 as select * from t1;
+--error ER_WRONG_OBJECT
alter table v1 rename to v2;
---error ER_NO_SUCH_TABLE
-alter table v1 rename to v2;
-rename table v2 to v1;
---error ER_TABLE_EXISTS_ERROR
-rename table v2 to v1;
drop view v1;
drop table t1;
diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test
index eb2ca7992a6..3c55f06ff4c 100644
--- a/mysql-test/t/repair.test
+++ b/mysql-test/t/repair.test
@@ -158,3 +158,33 @@ CREATE TEMPORARY TABLE tt1 (c1 INT);
REPAIR TABLE tt1 USE_FRM;
DROP TABLE tt1;
+
+--echo #
+--echo # Bug #48248 assert in MDL_ticket::upgrade_shared_lock_to_exclusive
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+LOCK TABLES t1 READ;
+REPAIR TABLE t1;
+
+UNLOCK TABLES;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test for bug #50784 "MDL: Assertion `m_tickets.is_empty() ||
+--echo # m_tickets.front() == m_trans_sentinel'"
+--echo #
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+create table t1 (i int);
+create table t2 (j int);
+set @@autocommit= 0;
+repair table t1, t2;
+set @@autocommit= default;
+drop tables t1, t2;
diff --git a/mysql-test/t/rpl_mysqldump_slave.test b/mysql-test/t/rpl_mysqldump_slave.test
new file mode 100644
index 00000000000..3f39fe19c0a
--- /dev/null
+++ b/mysql-test/t/rpl_mysqldump_slave.test
@@ -0,0 +1,30 @@
+--source include/master-slave.inc
+
+--echo #
+--echo # New --dump-slave, --apply-slave-statements functionality
+--echo #
+
+# There is a gap between when START SLAVE returns and when MASTER_LOG_FILE and
+# MASTER_LOG_POS are set. Ensure that we don't call SHOW SLAVE STATUS during
+# that gap.
+--sync_slave_with_master
+
+connection master;
+use test;
+
+connection slave;
+
+# Execute mysqldump with --dump-slave
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test
+
+# Execute mysqldump with --dump-slave and --apply-slave-statements
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements test
+
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+# Execute mysqldump with --dump-slave ,--apply-slave-statements and --include-master-host-port
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements --include-master-host-port test
+
+--source include/rpl_end.inc
diff --git a/mysql-test/t/schema.test b/mysql-test/t/schema.test
index a63402bbb83..6af7ee20b02 100644
--- a/mysql-test/t/schema.test
+++ b/mysql-test/t/schema.test
@@ -18,6 +18,93 @@ drop schema foo;
--echo #
+--echo # Bug #48940 MDL deadlocks against mysql_rm_db
+--echo #
+
+--disable_warnings
+DROP SCHEMA IF EXISTS schema1;
+--enable_warnings
+
+connect(con2, localhost, root);
+
+--echo # Connection default
+connection default;
+
+CREATE SCHEMA schema1;
+CREATE TABLE schema1.t1 (a INT);
+
+SET autocommit= FALSE;
+INSERT INTO schema1.t1 VALUES (1);
+
+--echo # Connection 2
+connection con2;
+--send DROP SCHEMA schema1
+
+--echo # Connection default
+connection default;
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for table metadata lock'
+ AND info='DROP SCHEMA schema1';
+--source include/wait_condition.inc
+# Error 1 is from ALTER DATABASE when the database does not exist.
+# Listing the error twice to prevent result diffences based on filename.
+--error 1,1
+ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8;
+SET autocommit= TRUE;
+
+--echo # Connection 2
+connection con2;
+--reap
+
+--echo # Connection default
+connection default;
+disconnect con2;
+
+
+--echo #
+--echo # Bug #49988 MDL deadlocks with mysql_create_db, reload_acl_and_cache
+--echo #
+
+--disable_warnings
+DROP SCHEMA IF EXISTS schema1;
+--enable_warnings
+
+connect (con2, localhost, root);
+
+--echo # Connection default
+connection default;
+CREATE SCHEMA schema1;
+CREATE TABLE schema1.t1 (id INT);
+LOCK TABLE schema1.t1 WRITE;
+
+--echo # Connection con2
+connection con2;
+--send DROP SCHEMA schema1
+
+--echo # Connection default
+connection default;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for schema metadata lock' and info='DROP SCHEMA schema1';
+--source include/wait_condition.inc
+
+--echo # CREATE SCHEMA used to give a deadlock.
+--echo # Now we prohibit CREATE SCHEMA in LOCK TABLES mode.
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+CREATE SCHEMA IF NOT EXISTS schema1;
+
+--echo # UNLOCK TABLES so DROP SCHEMA can continue.
+UNLOCK TABLES;
+
+--echo # Connection con2
+connection con2;
+--reap
+
+--echo # Connection default
+connection default;
+disconnect con2;
+
+
+--echo #
--echo # Bug#54360 Deadlock DROP/ALTER/CREATE DATABASE with open HANDLER
--echo #
@@ -36,9 +123,8 @@ connection default;
--echo # Connection con2
connect (con2, localhost, root);
---echo # Waiting for 'DROP DATABASE db1' to sync in.
let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
- WHERE state='Waiting for table' AND info='DROP DATABASE db1';
+ WHERE state='Waiting for table metadata lock' AND info='DROP DATABASE db1';
--source include/wait_condition.inc
--echo # Connection con1
@@ -47,6 +133,7 @@ connection con1;
CREATE DATABASE db2;
ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
DROP DATABASE db2;
+HANDLER t1 CLOSE;
--echo # Connection default
connection default;
@@ -56,6 +143,58 @@ disconnect con1;
disconnect con2;
+--echo #
+--echo # Tests for increased CREATE/ALTER/DROP DATABASE concurrency with
+--echo # database name locks.
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP DATABASE IF EXISTS db2;
+--enable_warnings
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (id INT);
+START TRANSACTION;
+INSERT INTO db1.t1 VALUES (1);
+
+--echo # Connection 2
+connection con2;
+--echo # DROP DATABASE should block due to the active transaction
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection 3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='Waiting for table metadata lock' and info='DROP DATABASE db1';
+--source include/wait_condition.inc
+--echo # But it should still be possible to CREATE/ALTER/DROP other databases.
+CREATE DATABASE db2;
+ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
+DROP DATABASE db2;
+
+--echo # Connection default
+connection default;
+--echo # End the transaction so DROP DATABASE db1 can continue
+COMMIT;
+
+--echo # Connection 2
+connection con2;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Connection default;
+connection default;
+disconnect con2;
+disconnect con3;
+
+
# 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
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index db08aad0df0..043b03e4686 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -1989,7 +1989,7 @@ DROP TABLE t1;
#
create table t1 (a int(11) unsigned, b int(11) unsigned);
-insert into t1 values (1,0), (1,1), (1,2);
+insert into t1 values (1,0), (1,1), (18446744073709551615,0);
select a-b from t1 order by 1;
select a-b , (a-b < 0) from t1 order by 1;
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
@@ -2910,6 +2910,7 @@ DROP TABLE t1,t2;
# cases to prevent fixing this accidently. It is intended behaviour)
#
+SET SQL_MODE='NO_UNSIGNED_SUBTRACTION';
CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL);
INSERT t1 SET i = 0;
UPDATE t1 SET i = -1;
@@ -2919,6 +2920,7 @@ SELECT * FROM t1;
UPDATE t1 SET i = i - 1;
SELECT * FROM t1;
DROP TABLE t1;
+SET SQL_MODE=default;
# BUG#17379
@@ -3767,7 +3769,7 @@ INSERT INTO t1 VALUES (2),(3);
--echo # Should not crash
--error ER_SUBQUERY_NO_1_ROW
SELECT 1 FROM t1 WHERE a <> 1 AND NOT
-ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1))
+ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1))
INTO @var0;
DROP TABLE t1;
@@ -4022,6 +4024,39 @@ SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON
drop table A,AA,B,BB;
--echo #end of test for bug#45266
+--echo #
+--echo # Bug#33546: Slowdown on re-evaluation of constant expressions.
+--echo #
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (2);
+SELECT * FROM t1 WHERE a = 1 + 1;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE a = 1 + 1;
+SELECT * FROM t1 HAVING a = 1 + 1;
+EXPLAIN EXTENDED SELECT * FROM t1 HAVING a = 1 + 1;
+SELECT * FROM t1, t2 WHERE a = b + (1 + 1);
+EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a = b + (1 + 1);
+SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1;
+EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00');
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
+BEGIN
+ SET @cnt := @cnt + 1;
+ RETURN 1;
+END;|
+delimiter ;|
+
+SET @cnt := 0;
+SELECT * FROM t1 WHERE a = f1();
+SELECT @cnt;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE a = f1();
+DROP TABLE t1, t2;
+DROP FUNCTION f1;
+--echo # End of bug#33546
+
--echo #
--echo # BUG#48052: Valgrind warning - uninitialized value in init_read_record()
--echo #
@@ -4088,4 +4123,116 @@ SELECT 1 FROM t1 ORDER BY a COLLATE latin1_german2_ci;
DROP TABLE t1;
+
+--echo #
+--echo # Bug #58422: Incorrect result when OUTER JOIN'ing
+--echo # with an empty table
+--echo #
+
+CREATE TABLE t_empty(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+CREATE TABLE t1(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+CREATE TABLE t2(pk INT PRIMARY KEY, i INT) ENGINE = MYISAM;
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+
+EXPLAIN
+SELECT *
+ FROM
+ t1
+ LEFT OUTER JOIN
+ (t2 INNER JOIN t_empty ON TRUE)
+ ON t1.pk=t2.pk
+ WHERE t2.pk <> 2;
+
+SELECT *
+ FROM
+ t1
+ LEFT OUTER JOIN
+ (t2 INNER JOIN t_empty ON TRUE)
+ ON t1.pk=t2.pk
+ WHERE t2.pk <> 2;
+
+
+EXPLAIN
+SELECT *
+ FROM
+ t1
+ LEFT OUTER JOIN
+ (t2 CROSS JOIN t_empty)
+ ON t1.pk=t2.pk
+ WHERE t2.pk <> 2;
+
+SELECT *
+ FROM
+ t1
+ LEFT OUTER JOIN
+ (t2 CROSS JOIN t_empty)
+ ON t1.pk=t2.pk
+ WHERE t2.pk <> 2;
+
+
+EXPLAIN
+SELECT *
+ FROM
+ t1
+ LEFT OUTER JOIN
+ (t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ ON t1.pk=t2.pk
+ WHERE t2.pk <> 2;
+
+SELECT *
+ FROM
+ t1
+ LEFT OUTER JOIN
+ (t2 INNER JOIN t_empty ON t_empty.i=t2.i)
+ ON t1.pk=t2.pk
+ WHERE t2.pk <> 2;
+
+
+
+DROP TABLE t1,t2,t_empty;
+
+
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug#54515: Crash in opt_range.cc::get_best_group_min_max on
+--echo # SELECT from VIEW with GROUP BY
+--echo #
+
+CREATE TABLE t1 (
+ col_int_key int DEFAULT NULL,
+ KEY int_key (col_int_key)
+) ;
+
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE VIEW view_t1 AS
+ SELECT t1.col_int_key AS col_int_key
+ FROM t1;
+
+SELECT col_int_key FROM view_t1 GROUP BY col_int_key;
+
+DROP VIEW view_t1;
+DROP TABLE t1;
+
+--echo # End of test BUG#54515
+
+--echo #
+--echo # Bug #57203 Assertion `field_length <= 255' failed.
+--echo #
+
+SELECT coalesce((avg(distinct (geomfromtext("point(25379 -22010)")))))
+UNION ALL
+SELECT coalesce((avg(distinct (geomfromtext("point(25379 -22010)")))))
+AS foo
+;
+
+CREATE table t1(a text);
+INSERT INTO t1 VALUES (''), ('');
+SELECT avg(distinct(t1.a)) FROM t1, t1 t2
+GROUP BY t2.a ORDER BY t1.a;
+
+DROP TABLE t1;
+
+--echo # End of test BUG#57203
diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test
index 481779e76d7..cca736d4c1d 100644
--- a/mysql-test/t/select_safe.test
+++ b/mysql-test/t/select_safe.test
@@ -6,7 +6,7 @@
drop table if exists t1;
--enable_warnings
-SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
+SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, MAX_JOIN_SIZE=9;
create table t1 (a int auto_increment primary key, b char(20));
insert into t1 values(1,"test");
SELECT SQL_BUFFER_RESULT * from t1;
@@ -85,6 +85,6 @@ set local max_join_size=1;
select * from (select 1 union select 2 union select 3) x;
drop table t1;
-SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
+SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, MAX_JOIN_SIZE=DEFAULT;
# End of 4.1 tests
diff --git a/mysql-test/t/shm.test b/mysql-test/t/shm.test
index 88e96ae7b45..4c765c43c1b 100644
--- a/mysql-test/t/shm.test
+++ b/mysql-test/t/shm.test
@@ -2,15 +2,25 @@
# to optimize things we skip this test on all other platforms
--source include/windows.inc
+# thread pool causes different results
+-- source include/not_threadpool.inc
+
# Only run this test if shared memory is avaliable
let $shm= query_get_value("SHOW VARIABLES LIKE 'shared_memory'", Value, 1);
-if (`SELECT '$shm' != 'ON'`){
+if ($shm != ON){
skip No shm support;
}
+let $shm_name= query_get_value("SHOW GLOBAL VARIABLES LIKE 'shared_memory_base_name'", Value, 1);
+
+# Connect using SHM for testing
+connect(shm_con,localhost,root,,,,$shm_name,SHM);
# Source select test case
-- source include/common-tests.inc
+connection default;
+disconnect shm_con;
+
#
# Bug #24924: shared-memory-base-name that is too long causes buffer overflow
#
@@ -20,7 +30,6 @@ if (`SELECT '$shm' != 'ON'`){
# Bug #33899: Deadlock in mysql_real_query with shared memory connections
#
-let $name= query_get_value("SHOW GLOBAL VARIABLES LIKE 'shared_memory_base_name'", Value, 1);
let $stmt= `SELECT REPEAT('a', 2048)`;
SET @max_allowed_packet= @@global.max_allowed_packet;
@@ -30,7 +39,7 @@ SET GLOBAL max_allowed_packet= 1024;
SET GLOBAL net_buffer_length= 1024;
--error 1
---exec echo SELECT '$stmt'| $MYSQL --protocol=memory --shared-memory-base-name=$name 2>&1
+--exec echo SELECT '$stmt'| $MYSQL --protocol=memory --shared-memory-base-name=$shm_name 2>&1
SET GLOBAL max_allowed_packet= @max_allowed_packet;
SET GLOBAL net_buffer_length= @net_buffer_length;
diff --git a/mysql-test/t/show_check-master.opt b/mysql-test/t/show_check-master.opt
index aab832e2848..108caf42203 100644
--- a/mysql-test/t/show_check-master.opt
+++ b/mysql-test/t/show_check-master.opt
@@ -1 +1 @@
---log-output=table,file --log-slow-queries --log-long-format --log-queries-not-using-indexes --myisam-recover=""
+--log-output=table,file --log-slow-queries --log-queries-not-using-indexes --myisam-recover=""
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index d46261f38d2..bc5ac8ac63f 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -1,3 +1,33 @@
+# Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2 of
+# the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+#
+
+################################################################################
+#
+# NOTICE:
+#
+# This file unfortunately contains characters in various different encodings.
+# Be careful when editing this file to ensure that you (or your editor) do
+# not change things (such as encodings) on lines that you did not mean to
+# modify.
+#
+################################################################################
+
+
# Uses GRANT commands that usually disabled in embedded server
-- source include/not_embedded.inc
@@ -5,9 +35,6 @@
# depends on the presence of the log tables (which are CSV-based).
--source include/have_csv.inc
-# Save the initial number of concurrent sessions
---source include/count_sessions.inc
-
#
# Test of some show commands
#
@@ -53,7 +80,7 @@ optimize table t1;
optimize table t1;
drop table t1;
-#show variables;
+# show variables;
--echo -- Here we enable metadata just to check that the collation of the
--echo -- resultset is non-binary for string type. This should be changed
@@ -173,7 +200,7 @@ type_long_blob longblob,
index(type_short)
) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" ENGINE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed CHARSET=latin1;
-# Not tested above: RAID_# UNION INSERT_METHOD DATA DIRECTORY INDEX DIRECTORY
+# Not tested above: UNION INSERT_METHOD DATA DIRECTORY INDEX DIRECTORY
show create table t1;
insert into t1 (type_timestamp) values ("2003-02-07 10:00:01");
select * from t1;
@@ -226,14 +253,6 @@ CREATE TABLE """a" (i INT);
SHOW CREATE TABLE """a";
DROP TABLE """a";
-# Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection
-#set names latin1;
-#create database `ä`;
-#create table `ä`.`ä` (a int) engine=heap;
-#--replace_column 7 # 8 # 9 #
-#show table status from `ä` LIKE 'ä';
-#drop database `ä`;
-
# to test quotes around keywords.. :
SET sql_mode= '';
@@ -332,6 +351,7 @@ drop table t1;
--error ER_DBACCESS_DENIED_ERROR
drop database mysqltest;
disconnect con1;
+--source include/wait_until_disconnected.inc
connect (con2,localhost,mysqltest_2,,test);
connection con2;
@@ -344,6 +364,7 @@ drop table mysqltest.t1;
--error ER_DBACCESS_DENIED_ERROR
drop database mysqltest;
disconnect con2;
+--source include/wait_until_disconnected.inc
connect (con3,localhost,mysqltest_3,,test);
connection con3;
@@ -353,6 +374,7 @@ show create database mysqltest;
drop table mysqltest.t1;
drop database mysqltest;
disconnect con3;
+--source include/wait_until_disconnected.inc
connection default;
set names binary;
@@ -362,15 +384,6 @@ delete from mysql.db
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
flush privileges;
-# This test fails on MAC OSX, so it is temporary disabled.
-# This needs WL#1324 to be done.
-#set names latin1;
-#create database `ä`;
-#create table `ä`.`ä` (a int) engine=heap;
-#--replace_column 7 # 8 # 9 #
-#show table status from `ä` LIKE 'ä';
-#drop database `ä`;
-
# Test that USING <keytype> is always shown in SHOW CREATE TABLE when it was
# specified during table creation, but not otherwise. (Bug#7235)
CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY;
@@ -550,18 +563,14 @@ CREATE VIEW v1 AS SELECT SQL_NO_CACHE NOW();
SHOW CREATE VIEW v1;
DROP VIEW v1;
-# Check that SQL_NO_CACHE always wins.
+--error ER_WRONG_USAGE
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE NOW();
-SHOW CREATE VIEW v1;
-DROP VIEW v1;
+--error ER_WRONG_USAGE
CREATE VIEW v1 AS SELECT SQL_NO_CACHE SQL_CACHE NOW();
-SHOW CREATE VIEW v1;
-DROP VIEW v1;
+--error ER_WRONG_USAGE
CREATE VIEW v1 AS SELECT SQL_CACHE SQL_NO_CACHE SQL_CACHE NOW();
-SHOW CREATE VIEW v1;
-DROP VIEW v1;
# Check CREATE VIEW in a prepared statement in a procedure.
delimiter |;
@@ -629,8 +638,6 @@ show plugins;
show columns in t1;
show slave hosts;
show keys in t1;
-show column types;
-show table types;
show storage engines;
show authors;
show contributors;
@@ -906,10 +913,12 @@ CREATE TABLE t1(ËÏÌÏÎËÁ1 INT);
--let $outfile1=$MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
+--source include/count_sessions.inc
--echo
--echo ---> Dumping mysqltest1 to outfile1
-
---exec $MYSQL_DUMP --default-character-set=latin1 --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $outfile1
+--exec $MYSQL_DUMP --default-character-set=latin1 --character-sets-dir=$MYSQL_SHAREDIR/charsets --databases mysqltest1 > $outfile1
+# Take care that the additional session caused by MYSQL_DUMP has disappeared.
+--source include/wait_until_count_sessions.inc
# - Clean mysqltest1;
@@ -923,9 +932,12 @@ DROP DATABASE mysqltest1;
--echo
--echo
+--source include/count_sessions.inc
--echo ---> Restoring mysqltest1...
--exec $MYSQL test < $outfile1
--remove_file $outfile1
+# Take care that the additional session caused by MYSQL has disappeared.
+--source include/wait_until_count_sessions.inc
# - Check definition of the table.
@@ -995,25 +1007,20 @@ grant select on `mysqltest`.`t1` to mysqltest_4@localhost;
connect (con4,localhost,mysqltest_4,,mysqltest);
connection con4;
show create database mysqltest;
+disconnect con4;
+--source include/wait_until_disconnected.inc
connection default;
delete from mysql.user where user='mysqltest_4';
delete from mysql.db where user='mysqltest_4';
delete from mysql.tables_priv where user='mysqltest_4';
flush privileges;
drop database mysqltest;
-connection default;
-disconnect con4;
#
# Ensure that show plugin code is tested
#
--disable_result_log
-show full plugin;
---enable_result_log
-show warnings;
---disable_result_log
-show plugin;
show plugins;
--enable_result_log
@@ -1059,11 +1066,23 @@ show full tables;
drop table `été`;
set names latin1;
+--echo #
+--echo # Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection
+--echo # Character set: Latin-1 (ISO-8859-1)
+--echo #
+SET NAMES latin1;
+CREATE DATABASE `ä`;
+CREATE TABLE `ä`.`ä` (a int) ENGINE=Memory;
+--replace_column 6 # 7 # 8 # 9 #
+SHOW TABLE STATUS FROM `ä` LIKE 'ä';
+DROP DATABASE `ä`;
+
#
# Bug#26402 Server crashes with old-style named table
#
--error ER_NO_SUCH_TABLE,ER_FILE_NOT_FOUND
show columns from `#mysql50#????????`;
+call mtr.add_suppression("Can.t find file: '.\\\\test\\\\\\?{8}.frm'");
#
# SHOW CREATE TRIGGER test.
@@ -1184,7 +1203,7 @@ DROP EVENT ev1;
# Bug#30036 SHOW TABLE TYPES causes the debug client to crash
#
--disable_result_log
-SHOW TABLE TYPES;
+SHOW STORAGE ENGINES;
--enable_result_log
@@ -1203,6 +1222,7 @@ SHOW ENGINE MYISAM STATUS;
--enable_result_log
disconnect conn1;
+--source include/wait_until_disconnected.inc
connection default;
DROP USER test_u@localhost;
@@ -1225,12 +1245,147 @@ CONNECTION con1;
--error ER_QUERY_INTERRUPTED
SHOW CREATE TABLE non_existent;
-CONNECTION default;
DISCONNECT con1;
+--source include/wait_until_disconnected.inc
+CONNECTION default;
--echo End of 5.1 tests
-# Wait till all disconnects are completed
---source include/wait_until_count_sessions.inc
+
+--echo #
+--echo # Bug#52593 SHOW CREATE TABLE is blocked if table is locked
+--echo # for write by another connection
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect(con1, localhost,root);
+connection default;
+
+CREATE TABLE t1 (i INT PRIMARY KEY);
+LOCK TABLE t1 WRITE;
+--echo # Switching to connection 'con1'.
+connection con1;
+--echo # This statement used to be blocked.
+SHOW CREATE TABLE t1;
+
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Switching to connection 'default'.
+connection default;
+UNLOCK TABLES;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#54905 Connection with WRITE lock cannot ALTER table due to
+--echo # concurrent SHOW CREATE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+
+--echo # Connection con1
+connect (con1,localhost,root);
+LOCK TABLE t1 WRITE;
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+SHOW CREATE TABLE t1;
+
+--echo # Connection con1
+connection con1;
+# Used to block
+ALTER TABLE t1 CHARACTER SET = utf8;
+UNLOCK TABLES;
+
+--echo # Connection default
+connection default;
+COMMIT;
+disconnect con1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#55498 SHOW CREATE TRIGGER takes wrong type of metadata lock.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1;
+
+--echo # Test 1: SHOW CREATE TRIGGER with WRITE locked table.
+
+--echo # Connection con1
+connect (con1, localhost, root);
+LOCK TABLE t1 WRITE;
+
+--echo # Connection default
+connection default;
+# Should not block.
+SHOW CREATE TRIGGER t1_bi;
+
+--echo # Connection con1
+connection con1;
+UNLOCK TABLES;
+
+--echo # Test 2: ALTER TABLE with SHOW CREATE TRIGGER in transaction
+
+--echo # Connection default
+connection default;
+START TRANSACTION;
+SHOW CREATE TRIGGER t1_bi;
+
+--echo # Connection con1
+connection con1;
+# Should not block.
+ALTER TABLE t1 CHARACTER SET = utf8;
+
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection default
+connection default;
+COMMIT;
+DROP TRIGGER t1_bi;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#57306 SHOW PROCESSLIST does not display string literals well.
+--echo #
+
+SET NAMES latin1;
+SELECT GET_LOCK('t', 1000);
+--connect (con1,localhost,root,,)
+--connection con1
+SET NAMES latin1;
+--send SELECT GET_LOCK('t',1000) AS 'óóóó';
+--connection default
+# Make sure con1 has switched from "SET NAMES" to "SELECT GET_LOCK"
+let $wait_timeout= 10;
+let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%GET_LOCK%' AND ID != CONNECTION_ID();
+--source include/wait_condition.inc
+--replace_column 1 ### 3 ### 6 ### 7 ###
+SHOW PROCESSLIST;
+SET NAMES utf8;
+--replace_column 1 ### 3 ### 6 ### 7 ###
+SHOW PROCESSLIST;
+SELECT RELEASE_LOCK('t');
+--connection con1
+--reap
+--disconnect con1
+--source include/wait_until_disconnected.inc
+--connection default
+SET NAMES latin1;
diff --git a/mysql-test/t/show_profile.test b/mysql-test/t/show_profile.test
new file mode 100644
index 00000000000..c20b29c40bf
--- /dev/null
+++ b/mysql-test/t/show_profile.test
@@ -0,0 +1,18 @@
+#
+# Test for show profiles
+# No meaningful check is possible.
+# So it only checks that SET profiling is possible and
+# that SHOW PROFILES, SHOW PROFILE FOR QUERY and SHOW PROFILE CPU FOR QUERY
+# do not cause syntax errors. It also increases code coverage for sql_profile.cc
+
+--source include/have_profiling.inc
+SET profiling = 1;
+SELECT 1;
+--replace_column 2 #
+SHOW PROFILES;
+--disable_result_log
+SHOW PROFILE FOR QUERY 1;
+SHOW PROFILE CPU FOR QUERY 1;
+--enable_result_log
+SET profiling = 0;
+
diff --git a/mysql-test/t/signal.test b/mysql-test/t/signal.test
new file mode 100644
index 00000000000..4c8e6159371
--- /dev/null
+++ b/mysql-test/t/signal.test
@@ -0,0 +1,2688 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for SIGNAL and RESIGNAL
+
+--echo #
+--echo # PART 1: syntax
+--echo #
+
+--echo #
+--echo # Test every new reserved and non reserved keywords
+--echo #
+
+--disable_warnings
+drop table if exists signal_non_reserved;
+--enable_warnings
+
+create table signal_non_reserved (
+ class_origin int,
+ subclass_origin int,
+ constraint_catalog int,
+ constraint_schema int,
+ constraint_name int,
+ catalog_name int,
+ schema_name int,
+ table_name int,
+ column_name int,
+ cursor_name int,
+ message_text int,
+ sqlcode int
+);
+
+drop table signal_non_reserved;
+
+--disable_warnings
+drop table if exists diag_non_reserved;
+--enable_warnings
+
+create table diag_non_reserved (
+ diagnostics int,
+ current int,
+ stacked int,
+ exception int
+);
+
+drop table diag_non_reserved;
+
+--disable_warnings
+drop table if exists diag_cond_non_reserved;
+--enable_warnings
+
+create table diag_cond_non_reserved (
+ condition_identifier int,
+ condition_number int,
+ condition_name int,
+ connection_name int,
+ message_length int,
+ message_octet_length int,
+ parameter_mode int,
+ parameter_name int,
+ parameter_ordinal_position int,
+ returned_sqlstate int,
+ routine_catalog int,
+ routine_name int,
+ routine_schema int,
+ server_name int,
+ specific_name int,
+ trigger_catalog int,
+ trigger_name int,
+ trigger_schema int
+);
+
+drop table diag_cond_non_reserved;
+
+--disable_warnings
+drop table if exists diag_stmt_non_reserved;
+--enable_warnings
+
+create table diag_stmt_non_reserved (
+ number int,
+ more int,
+ command_function int,
+ command_function_code int,
+ dynamic_function int,
+ dynamic_function_code int,
+ row_count int,
+ transactions_committed int,
+ transactions_rolled_back int,
+ transaction_active int
+);
+
+drop table diag_stmt_non_reserved;
+
+--disable_warnings
+drop table if exists test_reserved;
+--enable_warnings
+
+--error ER_PARSE_ERROR
+create table test_reserved (signal int);
+
+--error ER_PARSE_ERROR
+create table test_reserved (resignal int);
+
+--error ER_PARSE_ERROR
+create table test_reserved (condition int);
+
+--echo #
+--echo # Test the SIGNAL syntax
+--echo #
+
+--disable_warnings
+drop procedure if exists test_invalid;
+drop procedure if exists test_signal_syntax;
+drop function if exists test_signal_func;
+--enable_warnings
+
+delimiter $$;
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL;
+end $$
+
+--error ER_SP_COND_MISMATCH
+create procedure test_invalid()
+begin
+ SIGNAL foo;
+end $$
+
+--error ER_SIGNAL_BAD_CONDITION_TYPE
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR 1234;
+ SIGNAL foo;
+end $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo;
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ SIGNAL SQLSTATE '23000';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ SIGNAL SQLSTATE VALUE '23000';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET CLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET CONSTRAINT_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET CATALOG_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET SCHEMA_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET TABLE_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET COLUMN_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET CURSOR_NAME = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+--error ER_DUP_SIGNAL_SET
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET CLASS_ORIGIN = 'foo', CLASS_ORIGIN = 'bar';
+end $$
+
+--error ER_DUP_SIGNAL_SET
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
+end $$
+
+--error ER_DUP_SIGNAL_SET
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 'foo', MYSQL_ERRNO = 'bar';
+end $$
+
+create procedure test_signal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET
+ CLASS_ORIGIN = 'foo',
+ SUBCLASS_ORIGIN = 'foo',
+ CONSTRAINT_CATALOG = 'foo',
+ CONSTRAINT_SCHEMA = 'foo',
+ CONSTRAINT_NAME = 'foo',
+ CATALOG_NAME = 'foo',
+ SCHEMA_NAME = 'foo',
+ TABLE_NAME = 'foo',
+ COLUMN_NAME = 'foo',
+ CURSOR_NAME = 'foo',
+ MESSAGE_TEXT = 'foo',
+ MYSQL_ERRNO = 'foo';
+end $$
+drop procedure test_signal_syntax $$
+
+--error ER_SP_BAD_SQLSTATE
+SIGNAL SQLSTATE '00000' $$
+
+--error ER_SP_BAD_SQLSTATE
+SIGNAL SQLSTATE '00001' $$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '00000';
+end $$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '00001';
+end $$
+
+--echo #
+--echo # Test conditions information that SIGNAL can not set
+--echo #
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET bla_bla = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET CONDITION_IDENTIFIER = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET CONDITION_NUMBER = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET CONNECTION_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET MESSAGE_LENGTH = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET MESSAGE_OCTET_LENGTH = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET PARAMETER_MODE = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET PARAMETER_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET PARAMETER_ORDINAL_POSITION = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET RETURNED_SQLSTATE = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET ROUTINE_CATALOG = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET ROUTINE_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET ROUTINE_SCHEMA = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET SERVER_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET SPECIFIC_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET TRIGGER_CATALOG = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET TRIGGER_NAME = 'foo';
+end $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ SIGNAL SQLSTATE '12345' SET TRIGGER_SCHEMA = 'foo';
+end $$
+
+delimiter ;$$
+
+--echo #
+--echo # Test the RESIGNAL syntax
+--echo #
+
+--disable_warnings
+drop procedure if exists test_invalid;
+drop procedure if exists test_resignal_syntax;
+--enable_warnings
+
+delimiter $$;
+
+--error ER_SP_COND_MISMATCH
+create procedure test_invalid()
+begin
+ RESIGNAL foo;
+end $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL;
+end $$
+drop procedure test_resignal_syntax $$
+
+--error ER_SIGNAL_BAD_CONDITION_TYPE
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR 1234;
+ RESIGNAL foo;
+end $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo;
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SQLSTATE '23000';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SQLSTATE VALUE '23000';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET CLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET CLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET SUBCLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET SUBCLASS_ORIGIN = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET CONSTRAINT_CATALOG = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET CONSTRAINT_CATALOG = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET CONSTRAINT_SCHEMA = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET CONSTRAINT_SCHEMA = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET CONSTRAINT_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET CONSTRAINT_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET CATALOG_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET CATALOG_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET SCHEMA_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET SCHEMA_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET TABLE_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET TABLE_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET COLUMN_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET COLUMN_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET CURSOR_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET CURSOR_NAME = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ RESIGNAL SET MYSQL_ERRNO = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET MYSQL_ERRNO = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+--error ER_DUP_SIGNAL_SET
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET CLASS_ORIGIN = 'foo', CLASS_ORIGIN = 'bar';
+end $$
+
+--error ER_DUP_SIGNAL_SET
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET MESSAGE_TEXT = 'foo', MESSAGE_TEXT = 'bar';
+end $$
+
+--error ER_DUP_SIGNAL_SET
+create procedure test_invalid()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET MYSQL_ERRNO = 'foo', MYSQL_ERRNO = 'bar';
+end $$
+
+create procedure test_resignal_syntax()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ RESIGNAL foo SET
+ CLASS_ORIGIN = 'foo',
+ SUBCLASS_ORIGIN = 'foo',
+ CONSTRAINT_CATALOG = 'foo',
+ CONSTRAINT_SCHEMA = 'foo',
+ CONSTRAINT_NAME = 'foo',
+ CATALOG_NAME = 'foo',
+ SCHEMA_NAME = 'foo',
+ TABLE_NAME = 'foo',
+ COLUMN_NAME = 'foo',
+ CURSOR_NAME = 'foo',
+ MESSAGE_TEXT = 'foo';
+end $$
+drop procedure test_resignal_syntax $$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure test_invalid()
+begin
+ RESIGNAL SQLSTATE '00000';
+end $$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure test_invalid()
+begin
+ RESIGNAL SQLSTATE '00001';
+end $$
+
+delimiter ;$$
+
+--echo #
+--echo # PART 2: non preparable statements
+--echo #
+
+--error ER_UNSUPPORTED_PS
+prepare stmt from 'SIGNAL SQLSTATE \'23000\'';
+
+--error ER_UNSUPPORTED_PS
+prepare stmt from 'RESIGNAL SQLSTATE \'23000\'';
+
+--echo #
+--echo # PART 3: runtime execution
+--echo #
+
+--disable_warnings
+drop procedure if exists test_signal;
+drop procedure if exists test_resignal;
+drop table if exists t_warn;
+drop table if exists t_cursor;
+--enable_warnings
+
+# Helper tables
+create table t_warn(a integer(2));
+create table t_cursor(a integer);
+
+--echo #
+--echo # SIGNAL can also appear in a query
+--echo #
+
+--error ER_SP_COND_MISMATCH
+SIGNAL foo;
+
+SIGNAL SQLSTATE '01000';
+
+--error ER_SIGNAL_NOT_FOUND
+SIGNAL SQLSTATE '02000';
+
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '23000';
+
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE VALUE '23000';
+
+--error ER_WRONG_VALUE_FOR_VAR
+SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 65536;
+
+--error ER_WRONG_VALUE_FOR_VAR
+SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 99999;
+
+--error ER_WRONG_VALUE_FOR_VAR
+SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 4294967295;
+
+--error ER_WRONG_VALUE_FOR_VAR
+SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 0;
+
+--error ER_PARSE_ERROR
+SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = -1;
+
+--error 65535
+SIGNAL SQLSTATE 'HY000' SET MYSQL_ERRNO = 65535;
+
+--echo #
+--echo # RESIGNAL can also appear in a query
+--echo #
+
+--error ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER
+RESIGNAL;
+
+--error ER_SP_COND_MISMATCH
+RESIGNAL foo;
+
+--error ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER
+RESIGNAL SQLSTATE '12345';
+
+--error ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER
+RESIGNAL SQLSTATE VALUE '12345';
+
+--echo #
+--echo # Different kind of SIGNAL conditions
+--echo #
+
+delimiter $$;
+
+create procedure test_signal()
+begin
+ # max range
+ DECLARE foo CONDITION FOR SQLSTATE 'AABBB';
+ SIGNAL foo SET MYSQL_ERRNO = 65535;
+end $$
+
+--error 65535
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # max range
+ DECLARE foo CONDITION FOR SQLSTATE 'AABBB';
+ SIGNAL foo SET MYSQL_ERRNO = 65536;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Error
+ DECLARE foo CONDITION FOR SQLSTATE '99999';
+ SIGNAL foo SET MYSQL_ERRNO = 9999;
+end $$
+
+--error 9999
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # warning
+ DECLARE too_few_records CONDITION FOR SQLSTATE '01000';
+ SIGNAL too_few_records SET MYSQL_ERRNO = 1261;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Not found
+ DECLARE sp_fetch_no_data CONDITION FOR SQLSTATE '02000';
+ SIGNAL sp_fetch_no_data SET MYSQL_ERRNO = 1329;
+end $$
+
+--error ER_SP_FETCH_NO_DATA
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Error
+ DECLARE sp_cursor_already_open CONDITION FOR SQLSTATE '24000';
+ SIGNAL sp_cursor_already_open SET MYSQL_ERRNO = 1325;
+end $$
+
+--error ER_SP_CURSOR_ALREADY_OPEN
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Severe error
+ DECLARE lock_deadlock CONDITION FOR SQLSTATE '40001';
+ SIGNAL lock_deadlock SET MYSQL_ERRNO = 1213;
+end $$
+
+--error ER_LOCK_DEADLOCK
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Unknown -> error
+ DECLARE foo CONDITION FOR SQLSTATE "99999";
+ SIGNAL foo;
+end $$
+
+--error ER_SIGNAL_EXCEPTION
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # warning, no subclass
+ DECLARE warn CONDITION FOR SQLSTATE "01000";
+ SIGNAL warn;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # warning, with subclass
+ DECLARE warn CONDITION FOR SQLSTATE "01123";
+ SIGNAL warn;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Not found, no subclass
+ DECLARE not_found CONDITION FOR SQLSTATE "02000";
+ SIGNAL not_found;
+end $$
+
+--error ER_SIGNAL_NOT_FOUND
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Not found, with subclass
+ DECLARE not_found CONDITION FOR SQLSTATE "02XXX";
+ SIGNAL not_found;
+end $$
+
+--error ER_SIGNAL_NOT_FOUND
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Error, no subclass
+ DECLARE error CONDITION FOR SQLSTATE "12000";
+ SIGNAL error;
+end $$
+
+--error ER_SIGNAL_EXCEPTION
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Error, with subclass
+ DECLARE error CONDITION FOR SQLSTATE "12ABC";
+ SIGNAL error;
+end $$
+
+--error ER_SIGNAL_EXCEPTION
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Severe error, no subclass
+ DECLARE error CONDITION FOR SQLSTATE "40000";
+ SIGNAL error;
+end $$
+
+--error ER_SIGNAL_EXCEPTION
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ # Severe error, with subclass
+ DECLARE error CONDITION FOR SQLSTATE "40001";
+ SIGNAL error;
+end $$
+
+--error ER_SIGNAL_EXCEPTION
+call test_signal() $$
+drop procedure test_signal $$
+
+--echo #
+--echo # Test the scope of condition
+--echo #
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '99999';
+ begin
+ DECLARE foo CONDITION FOR 8888;
+ end;
+ SIGNAL foo SET MYSQL_ERRNO=9999; /* outer */
+end $$
+
+--error 9999
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR 9999;
+ begin
+ DECLARE foo CONDITION FOR SQLSTATE '88888';
+ SIGNAL foo SET MYSQL_ERRNO=8888; /* inner */
+ end;
+end $$
+
+--error 8888
+call test_signal() $$
+drop procedure test_signal $$
+
+--echo #
+--echo # Test SET MYSQL_ERRNO
+--echo #
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '99999';
+ SIGNAL foo SET MYSQL_ERRNO = 1111;
+end $$
+
+--error 1111
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01000";
+ SIGNAL warn SET MYSQL_ERRNO = 1111;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02000";
+ SIGNAL not_found SET MYSQL_ERRNO = 1111;
+end $$
+
+--error 1111
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "55000";
+ SIGNAL error SET MYSQL_ERRNO = 1111;
+end $$
+
+--error 1111
+call test_signal() $$
+drop procedure test_signal $$
+
+--echo #
+--echo # Test SET MESSAGE_TEXT
+--echo #
+
+--error ER_SIGNAL_EXCEPTION
+SIGNAL SQLSTATE '77777' SET MESSAGE_TEXT='' $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '77777';
+ SIGNAL foo SET
+ MESSAGE_TEXT = "",
+ MYSQL_ERRNO=5678;
+end $$
+
+--error 5678
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '99999';
+ SIGNAL foo SET
+ MESSAGE_TEXT = "Something bad happened",
+ MYSQL_ERRNO=9999;
+end $$
+
+--error 9999
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01000";
+ SIGNAL warn SET MESSAGE_TEXT = "Something bad happened";
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02000";
+ SIGNAL not_found SET MESSAGE_TEXT = "Something bad happened";
+end $$
+
+--error ER_SIGNAL_NOT_FOUND
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "55000";
+ SIGNAL error SET MESSAGE_TEXT = "Something bad happened";
+end $$
+
+--error ER_SIGNAL_EXCEPTION
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE something CONDITION FOR SQLSTATE "01000";
+ SIGNAL something SET MESSAGE_TEXT = _utf8 "This is a UTF8 text";
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE something CONDITION FOR SQLSTATE "01000";
+ SIGNAL something SET MESSAGE_TEXT = "";
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01111";
+ SIGNAL warn SET MESSAGE_TEXT = "á a";
+end $$
+
+call test_signal() $$
+show warnings $$
+drop procedure test_signal $$
+
+--echo #
+--echo # Test SET complex expressions
+--echo #
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ MYSQL_ERRNO = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ CLASS_ORIGIN = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ SUBCLASS_ORIGIN = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ CONSTRAINT_CATALOG = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ CONSTRAINT_SCHEMA = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ CONSTRAINT_NAME = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ CATALOG_NAME = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ SCHEMA_NAME = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ TABLE_NAME = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ COLUMN_NAME = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ CURSOR_NAME = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE '99999';
+ SIGNAL error SET
+ MESSAGE_TEXT = NULL;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE something CONDITION FOR SQLSTATE '99999';
+ DECLARE message_text VARCHAR(64) DEFAULT "Local string variable";
+ DECLARE sqlcode INTEGER DEFAULT 1234;
+
+ SIGNAL something SET
+ MESSAGE_TEXT = message_text,
+ MYSQL_ERRNO = sqlcode;
+end $$
+
+--error 1234
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal(message_text VARCHAR(64), sqlcode INTEGER)
+begin
+ DECLARE something CONDITION FOR SQLSTATE "12345";
+
+ SIGNAL something SET
+ MESSAGE_TEXT = message_text,
+ MYSQL_ERRNO = sqlcode;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal("Parameter string", NULL) $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal(NULL, 1234) $$
+
+--error 5678
+call test_signal("Parameter string", 5678) $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE something CONDITION FOR SQLSTATE "AABBB";
+
+ SIGNAL something SET
+ MESSAGE_TEXT = @message_text,
+ MYSQL_ERRNO = @sqlcode;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+
+set @sqlcode= 12 $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+
+set @message_text= "User variable" $$
+
+--error 12
+call test_signal() $$
+drop procedure test_signal $$
+
+--error ER_PARSE_ERROR
+create procedure test_invalid()
+begin
+ DECLARE something CONDITION FOR SQLSTATE "AABBB";
+
+ SIGNAL something SET
+ MESSAGE_TEXT = @message_text := 'illegal',
+ MYSQL_ERRNO = @sqlcode := 1234;
+end $$
+
+create procedure test_signal()
+begin
+ DECLARE aaa VARCHAR(64);
+ DECLARE bbb VARCHAR(64);
+ DECLARE ccc VARCHAR(64);
+ DECLARE ddd VARCHAR(64);
+ DECLARE eee VARCHAR(64);
+ DECLARE fff VARCHAR(64);
+ DECLARE ggg VARCHAR(64);
+ DECLARE hhh VARCHAR(64);
+ DECLARE iii VARCHAR(64);
+ DECLARE jjj VARCHAR(64);
+ DECLARE kkk VARCHAR(64);
+
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+
+ set aaa= repeat("A", 64);
+ set bbb= repeat("B", 64);
+ set ccc= repeat("C", 64);
+ set ddd= repeat("D", 64);
+ set eee= repeat("E", 64);
+ set fff= repeat("F", 64);
+ set ggg= repeat("G", 64);
+ set hhh= repeat("H", 64);
+ set iii= repeat("I", 64);
+ set jjj= repeat("J", 64);
+ set kkk= repeat("K", 64);
+
+ SIGNAL warn SET
+ CLASS_ORIGIN = aaa,
+ SUBCLASS_ORIGIN = bbb,
+ CONSTRAINT_CATALOG = ccc,
+ CONSTRAINT_SCHEMA = ddd,
+ CONSTRAINT_NAME = eee,
+ CATALOG_NAME = fff,
+ SCHEMA_NAME = ggg,
+ TABLE_NAME = hhh,
+ COLUMN_NAME = iii,
+ CURSOR_NAME = jjj,
+ MESSAGE_TEXT = kkk,
+ MYSQL_ERRNO = 65535;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+
+ SIGNAL warn SET
+ MYSQL_ERRNO = 999999999999999999999999999999999999999999999999999;
+end $$
+
+--error ER_WRONG_VALUE_FOR_VAR
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE aaax VARCHAR(65);
+ DECLARE bbbx VARCHAR(65);
+ DECLARE cccx VARCHAR(65);
+ DECLARE dddx VARCHAR(65);
+ DECLARE eeex VARCHAR(65);
+ DECLARE fffx VARCHAR(65);
+ DECLARE gggx VARCHAR(65);
+ DECLARE hhhx VARCHAR(65);
+ DECLARE iiix VARCHAR(65);
+ DECLARE jjjx VARCHAR(65);
+ DECLARE kkkx VARCHAR(65);
+ DECLARE lllx VARCHAR(129);
+
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+
+ set aaax= concat(repeat("A", 64), "X");
+ set bbbx= concat(repeat("B", 64), "X");
+ set cccx= concat(repeat("C", 64), "X");
+ set dddx= concat(repeat("D", 64), "X");
+ set eeex= concat(repeat("E", 64), "X");
+ set fffx= concat(repeat("F", 64), "X");
+ set gggx= concat(repeat("G", 64), "X");
+ set hhhx= concat(repeat("H", 64), "X");
+ set iiix= concat(repeat("I", 64), "X");
+ set jjjx= concat(repeat("J", 64), "X");
+ set kkkx= concat(repeat("K", 64), "X");
+ set lllx= concat(repeat("1", 100),
+ repeat("2", 20),
+ repeat("8", 8),
+ "X");
+
+ SIGNAL warn SET
+ CLASS_ORIGIN = aaax,
+ SUBCLASS_ORIGIN = bbbx,
+ CONSTRAINT_CATALOG = cccx,
+ CONSTRAINT_SCHEMA = dddx,
+ CONSTRAINT_NAME = eeex,
+ CATALOG_NAME = fffx,
+ SCHEMA_NAME = gggx,
+ TABLE_NAME = hhhx,
+ COLUMN_NAME = iiix,
+ CURSOR_NAME = jjjx,
+ MESSAGE_TEXT = lllx,
+ MYSQL_ERRNO = 10000;
+end $$
+
+#NOTE: the warning text for ER_TRUNCATED_WRONG_VALUE contains
+# value: '%-.128s', so the warning printed truncates the value too,
+# which affects MESSAGE_TEXT (the X is missing)
+
+call test_signal() $$
+drop procedure test_signal $$
+
+# Test that HANDLER can catch conditions raised by SIGNAL
+
+create procedure test_signal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER for SQLSTATE "01234"
+ begin
+ select "Caught by SQLSTATE";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "Caught by number";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER for SQLWARNING
+ begin
+ select "Caught by SQLWARNING";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+ DECLARE CONTINUE HANDLER for SQLSTATE "02ABC"
+ begin
+ select "Caught by SQLSTATE";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "Caught by number";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+ DECLARE CONTINUE HANDLER for NOT FOUND
+ begin
+ select "Caught by NOT FOUND";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "55555";
+ DECLARE CONTINUE HANDLER for SQLSTATE "55555"
+ begin
+ select "Caught by SQLSTATE";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "55555";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "Caught by number";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "55555";
+ DECLARE CONTINUE HANDLER for SQLEXCEPTION
+ begin
+ select "Caught by SQLEXCEPTION";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_signal() $$
+drop procedure test_signal $$
+
+--echo #
+--echo # Test where SIGNAL can be used
+--echo #
+
+create function test_signal_func() returns integer
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01XXX";
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "This function SIGNAL a warning",
+ MYSQL_ERRNO = 1012;
+
+ return 5;
+end $$
+
+select test_signal_func() $$
+drop function test_signal_func $$
+
+create function test_signal_func() returns integer
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02XXX";
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "This function SIGNAL not found",
+ MYSQL_ERRNO = 1012;
+
+ return 5;
+end $$
+
+--error 1012
+select test_signal_func() $$
+drop function test_signal_func $$
+
+create function test_signal_func() returns integer
+begin
+ DECLARE error CONDITION FOR SQLSTATE "50000";
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "This function SIGNAL an error",
+ MYSQL_ERRNO = 1012;
+
+ return 5;
+end $$
+
+--error 1012
+select test_signal_func() $$
+drop function test_signal_func $$
+
+--disable_warnings
+drop table if exists t1 $$
+--enable_warnings
+
+create table t1 (a integer) $$
+
+create trigger t1_ai after insert on t1 for each row
+begin
+ DECLARE msg VARCHAR(128);
+ DECLARE warn CONDITION FOR SQLSTATE "01XXX";
+
+ set msg= concat("This trigger SIGNAL a warning, a=", NEW.a);
+ SIGNAL warn SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 1012;
+end $$
+
+insert into t1 values (1), (2) $$
+
+drop trigger t1_ai $$
+
+create trigger t1_ai after insert on t1 for each row
+begin
+ DECLARE msg VARCHAR(128);
+ DECLARE not_found CONDITION FOR SQLSTATE "02XXX";
+
+ set msg= concat("This trigger SIGNAL a not found, a=", NEW.a);
+ SIGNAL not_found SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 1012
+insert into t1 values (3), (4) $$
+
+drop trigger t1_ai $$
+
+create trigger t1_ai after insert on t1 for each row
+begin
+ DECLARE msg VARCHAR(128);
+ DECLARE error CONDITION FOR SQLSTATE "03XXX";
+
+ set msg= concat("This trigger SIGNAL an error, a=", NEW.a);
+ SIGNAL error SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 1012
+insert into t1 values (5), (6) $$
+
+drop table t1 $$
+
+create table t1 (errno integer, msg varchar(128)) $$
+
+create trigger t1_ai after insert on t1 for each row
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01XXX";
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = NEW.msg,
+ MYSQL_ERRNO = NEW.errno;
+end $$
+
+insert into t1 set errno=1012, msg='Warning message 1 in trigger' $$
+insert into t1 set errno=1013, msg='Warning message 2 in trigger' $$
+
+drop table t1 $$
+
+--disable_warnings
+drop table if exists t1 $$
+drop procedure if exists p1 $$
+drop function if exists f1 $$
+--enable_warnings
+
+create table t1 (s1 int) $$
+insert into t1 values (1) $$
+
+create procedure p1()
+begin
+ declare a int;
+ declare c cursor for select f1() from t1;
+ declare continue handler for sqlstate '03000'
+ select "caught 03000";
+ declare continue handler for 1326
+ select "caught cursor is not open";
+
+ select "Before open";
+ open c;
+ select "Before fetch";
+ fetch c into a;
+ select "Before close";
+ close c;
+end $$
+
+create function f1() returns int
+begin
+ signal sqlstate '03000';
+ return 5;
+end $$
+
+## FIXME : MEMORY plugin warning, valgrind leak, bug#36518
+## call p1() $$
+
+drop table t1 $$
+drop procedure p1 $$
+drop function f1 $$
+
+--echo #
+--echo # Test the RESIGNAL runtime
+--echo #
+
+# 6 tests:
+# {Signaled warning, Signaled Not Found, Signaled Error,
+# warning, not found, error} --> RESIGNAL
+
+create procedure test_resignal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02222";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 1012
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "55555";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 1012
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlwarning
+ begin
+ select "before RESIGNAL";
+ RESIGNAL;
+ select "after RESIGNAL";
+ end;
+
+ insert into t_warn set a= 9999999999999999;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE x integer;
+ DECLARE c cursor for select * from t_cursor;
+ DECLARE CONTINUE HANDLER for not found
+ begin
+ select "before RESIGNAL";
+ RESIGNAL;
+ select "after RESIGNAL";
+ end;
+
+ open c;
+ fetch c into x;
+ close c;
+end $$
+
+--error ER_SP_FETCH_NO_DATA
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlexception
+ begin
+ select "before RESIGNAL";
+ RESIGNAL;
+ select "after RESIGNAL";
+ end;
+
+ drop table no_such_table;
+end $$
+
+--error ER_BAD_TABLE_ERROR
+call test_resignal() $$
+drop procedure test_resignal $$
+
+# 6 tests:
+# {Signaled warning, Signaled Not Found, Signaled Error,
+# warning, not found, error} --> RESIGNAL SET ...
+
+create procedure test_resignal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SET
+ MESSAGE_TEXT = "RESIGNAL of a warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02111";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SET
+ MESSAGE_TEXT = "RESIGNAL of a not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "33333";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SET
+ MESSAGE_TEXT = "RESIGNAL of an error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlwarning
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SET
+ MESSAGE_TEXT = "RESIGNAL of a warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ insert into t_warn set a= 9999999999999999;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE x integer;
+ DECLARE c cursor for select * from t_cursor;
+ DECLARE CONTINUE HANDLER for not found
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SET
+ MESSAGE_TEXT = "RESIGNAL of not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ open c;
+ fetch c into x;
+ close c;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlexception
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SET
+ MESSAGE_TEXT = "RESIGNAL of an error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ drop table no_such_table;
+end $$
+
+--error 5555
+call test_resignal() $$
+drop procedure test_resignal $$
+
+#########################################################
+
+# 3 tests:
+# {Signaled warning}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01111";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "01222" SET
+ MESSAGE_TEXT = "RESIGNAL to warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01111";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "02222" SET
+ MESSAGE_TEXT = "RESIGNAL to not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE warn CONDITION FOR SQLSTATE "01111";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "33333" SET
+ MESSAGE_TEXT = "RESIGNAL to error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL warn SET
+ MESSAGE_TEXT = "Raising a warning",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {Signaled not found}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "01222" SET
+ MESSAGE_TEXT = "RESIGNAL to warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "02222" SET
+ MESSAGE_TEXT = "RESIGNAL to not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE not_found CONDITION FOR SQLSTATE "02ABC";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "33333" SET
+ MESSAGE_TEXT = "RESIGNAL to error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL not_found SET
+ MESSAGE_TEXT = "Raising a not found",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {Signaled error}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "01222" SET
+ MESSAGE_TEXT = "RESIGNAL to warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "02222" SET
+ MESSAGE_TEXT = "RESIGNAL to not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE error CONDITION FOR SQLSTATE "AAAAA";
+ DECLARE CONTINUE HANDLER for 1012
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "33333" SET
+ MESSAGE_TEXT = "RESIGNAL to error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ SIGNAL error SET
+ MESSAGE_TEXT = "Raising an error",
+ MYSQL_ERRNO = 1012;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {warning}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlwarning
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "01111" SET
+ MESSAGE_TEXT = "RESIGNAL to a warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ insert into t_warn set a= 9999999999999999;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlwarning
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "02444" SET
+ MESSAGE_TEXT = "RESIGNAL to a not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ insert into t_warn set a= 9999999999999999;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlwarning
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "44444" SET
+ MESSAGE_TEXT = "RESIGNAL to an error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ insert into t_warn set a= 9999999999999999;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {not found}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+ DECLARE x integer;
+ DECLARE c cursor for select * from t_cursor;
+ DECLARE CONTINUE HANDLER for not found
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "01111" SET
+ MESSAGE_TEXT = "RESIGNAL to a warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ open c;
+ fetch c into x;
+ close c;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE x integer;
+ DECLARE c cursor for select * from t_cursor;
+ DECLARE CONTINUE HANDLER for not found
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "02444" SET
+ MESSAGE_TEXT = "RESIGNAL to a not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ open c;
+ fetch c into x;
+ close c;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE x integer;
+ DECLARE c cursor for select * from t_cursor;
+ DECLARE CONTINUE HANDLER for not found
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "44444" SET
+ MESSAGE_TEXT = "RESIGNAL to an error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ open c;
+ fetch c into x;
+ close c;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+# 3 tests:
+# {error}
+# --> RESIGNAL SQLSTATE {warning, not found, error} SET ...
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlexception
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "01111" SET
+ MESSAGE_TEXT = "RESIGNAL to a warning",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ drop table no_such_table;
+end $$
+
+call test_resignal() $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlexception
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "02444" SET
+ MESSAGE_TEXT = "RESIGNAL to a not found",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ drop table no_such_table;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+create procedure test_resignal()
+begin
+ DECLARE CONTINUE HANDLER for sqlexception
+ begin
+ select "before RESIGNAL";
+ RESIGNAL SQLSTATE "44444" SET
+ MESSAGE_TEXT = "RESIGNAL to an error",
+ MYSQL_ERRNO = 5555 ;
+ select "after RESIGNAL";
+ end;
+
+ drop table no_such_table;
+end $$
+
+--error 5555
+call test_resignal() $$
+show warnings $$
+drop procedure test_resignal $$
+
+--echo #
+--echo # More complex cases
+--echo #
+
+--disable_warnings
+drop procedure if exists peter_p1 $$
+drop procedure if exists peter_p2 $$
+--enable_warnings
+
+CREATE PROCEDURE peter_p1 ()
+BEGIN
+ DECLARE x CONDITION FOR 1231;
+ DECLARE EXIT HANDLER FOR x
+ BEGIN
+ SELECT '2';
+ RESIGNAL SET MYSQL_ERRNO = 9999;
+ END;
+
+ BEGIN
+ DECLARE EXIT HANDLER FOR x
+ BEGIN
+ SELECT '1';
+ RESIGNAL SET SCHEMA_NAME = 'test';
+ END;
+ SET @@sql_mode=NULL;
+ END;
+END
+$$
+
+CREATE PROCEDURE peter_p2 ()
+BEGIN
+ DECLARE x CONDITION for 9999;
+ DECLARE EXIT HANDLER FOR x
+ BEGIN
+ SELECT '3';
+ RESIGNAL SET MESSAGE_TEXT = 'Hi, I am a useless error message';
+ END;
+ CALL peter_p1();
+END
+$$
+
+#
+# Here, RESIGNAL only modifies the condition caught,
+# so there is only 1 condition at the end
+# The final SQLSTATE is 42000 (it comes from the error 1231),
+# since the condition attributes are preserved.
+#
+--error 9999
+CALL peter_p2() $$
+show warnings $$
+
+drop procedure peter_p1 $$
+drop procedure peter_p2 $$
+
+CREATE PROCEDURE peter_p1 ()
+BEGIN
+ DECLARE x CONDITION FOR SQLSTATE '42000';
+ DECLARE EXIT HANDLER FOR x
+ BEGIN
+ SELECT '2';
+ SHOW WARNINGS;
+ RESIGNAL x SET MYSQL_ERRNO = 9999;
+ END;
+
+ BEGIN
+ DECLARE EXIT HANDLER FOR x
+ BEGIN
+ SELECT '1';
+ SHOW WARNINGS;
+ RESIGNAL x SET
+ SCHEMA_NAME = 'test',
+ MYSQL_ERRNO= 1232;
+ END;
+ /* Raises ER_WRONG_VALUE_FOR_VAR : 1231, SQLSTATE 42000 */
+ SET @@sql_mode=NULL;
+ END;
+END
+$$
+
+CREATE PROCEDURE peter_p2 ()
+BEGIN
+ DECLARE x CONDITION for SQLSTATE '42000';
+ DECLARE EXIT HANDLER FOR x
+ BEGIN
+ SELECT '3';
+ SHOW WARNINGS;
+ RESIGNAL x SET
+ MESSAGE_TEXT = 'Hi, I am a useless error message',
+ MYSQL_ERRNO = 9999;
+ END;
+ CALL peter_p1();
+END
+$$
+
+#
+# Here, "RESIGNAL <condition>" create a new condition in the diagnostics
+# area, so that there are 4 conditions at the end.
+#
+--error 9999
+CALL peter_p2() $$
+show warnings $$
+
+drop procedure peter_p1 $$
+drop procedure peter_p2 $$
+
+#
+# Test the value of MESSAGE_TEXT in RESIGNAL when no SET MESSAGE_TEXT clause
+# is provided (the expected result is the text from the SIGNALed condition)
+#
+
+drop procedure if exists peter_p3 $$
+
+create procedure peter_p3()
+begin
+ declare continue handler for sqlexception
+ resignal sqlstate '99002' set mysql_errno = 2;
+
+ signal sqlstate '99001' set mysql_errno = 1, message_text = "Original";
+end $$
+
+--error 2
+call peter_p3() $$
+
+# Expecting 2 conditions, both with the text "Original"
+show warnings $$
+
+drop procedure peter_p3 $$
+
+delimiter ;$$
+
+drop table t_warn;
+drop table t_cursor;
+
+--echo #
+--echo # Miscelaneous test cases
+--echo #
+
+delimiter $$;
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 0x12; /* 18 */
+end $$
+
+-- error 18
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 0b00010010; /* 18 */
+end $$
+
+-- error 18
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = '65'; /* 65 */
+end $$
+
+-- error 65
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 'A'; /* illegal */
+end $$
+
+-- error ER_WRONG_VALUE_FOR_VAR
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = "65"; /* 65 */
+end $$
+
+-- error 65
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = "A"; /* illegal */
+end $$
+
+-- error ER_WRONG_VALUE_FOR_VAR
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = `65`; /* illegal */
+end $$
+
+-- error ER_BAD_FIELD_ERROR
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = `A`; /* illegal */
+end $$
+
+-- error ER_BAD_FIELD_ERROR
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 3.141592; /* 3 */
+end $$
+
+-- error 3
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 1000,
+ MESSAGE_TEXT= 0x41; /* A */
+end $$
+
+-- error 1000
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 1000,
+ MESSAGE_TEXT= 0b01000001; /* A */
+end $$
+
+-- error 1000
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 1000,
+ MESSAGE_TEXT = "Hello";
+end $$
+
+-- error 1000
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 1000,
+ MESSAGE_TEXT = 'Hello';
+end $$
+
+-- error 1000
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 1000,
+ MESSAGE_TEXT = `Hello`;
+end $$
+
+-- error ER_BAD_FIELD_ERROR
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL foo SET MYSQL_ERRNO = 1000,
+ MESSAGE_TEXT = 65.4321;
+end $$
+
+-- error 1000
+call test_signal $$
+drop procedure test_signal $$
+
+-- error ER_PARSE_ERROR
+create procedure test_signal()
+begin
+ DECLARE céèçà foo CONDITION FOR SQLSTATE '12345';
+ SIGNAL céèçà SET MYSQL_ERRNO = 1000;
+end $$
+
+-- error ER_PARSE_ERROR
+create procedure test_signal()
+begin
+ DECLARE "céèçà" CONDITION FOR SQLSTATE '12345';
+ SIGNAL "céèçà" SET MYSQL_ERRNO = 1000;
+end $$
+
+-- error ER_PARSE_ERROR
+create procedure test_signal()
+begin
+ DECLARE 'céèçà' CONDITION FOR SQLSTATE '12345';
+ SIGNAL 'céèçà' SET MYSQL_ERRNO = 1000;
+end $$
+
+create procedure test_signal()
+begin
+ DECLARE `céèçà` CONDITION FOR SQLSTATE '12345';
+ SIGNAL `céèçà` SET MYSQL_ERRNO = 1000;
+end $$
+
+-- error 1000
+call test_signal $$
+drop procedure test_signal $$
+
+create procedure test_signal()
+begin
+ SIGNAL SQLSTATE '77777' SET MYSQL_ERRNO = 1000, MESSAGE_TEXT='ÃÂÃÅÄ';
+end $$
+
+# Commented until WL#751 is implemented in this version
+# -- error 1000
+# call test_signal $$
+drop procedure test_signal $$
+
+delimiter ; $$
+
diff --git a/mysql-test/t/signal_code.test b/mysql-test/t/signal_code.test
new file mode 100644
index 00000000000..d2f65647c81
--- /dev/null
+++ b/mysql-test/t/signal_code.test
@@ -0,0 +1,57 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for SIGNAL and RESIGNAL
+
+-- source include/have_debug.inc
+
+use test;
+
+--disable_warnings
+drop procedure if exists signal_proc;
+drop function if exists signal_func;
+--enable_warnings
+
+delimiter $$;
+
+create procedure signal_proc()
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+
+ SIGNAL foo;
+ SIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+ RESIGNAL foo;
+ RESIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+end $$
+
+create function signal_func() returns int
+begin
+ DECLARE foo CONDITION FOR SQLSTATE '12345';
+
+ SIGNAL foo;
+ SIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+ RESIGNAL foo;
+ RESIGNAL foo SET MESSAGE_TEXT = "This is an error message";
+ return 0;
+end $$
+
+delimiter ;$$
+
+show procedure code signal_proc;
+drop procedure signal_proc;
+
+show function code signal_func;
+drop function signal_func;
+
diff --git a/mysql-test/t/signal_demo1.test b/mysql-test/t/signal_demo1.test
new file mode 100644
index 00000000000..5de847ba0ba
--- /dev/null
+++ b/mysql-test/t/signal_demo1.test
@@ -0,0 +1,345 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# Demonstrate how SIGNAL can be used to enforce integrity constraints.
+#
+
+# Naming:
+# - PO: Purchase Order
+# - AB: Address Book
+# - IN: Inventory
+
+# Simplified schema:
+#
+# Relation 1:
+# PO_ORDER (PK: po_id) 1:1 <---> 0:N (FK: po_id) PO_ORDER_LINE
+#
+# Relation 2:
+# IN_INVENTORY (PK: item_id) 1:1 <---> 0:N (FK: item_id) PO_ORDER_LINE
+#
+# Relation 3:
+# +--> 0:1 (PK: person_id) AB_PHYSICAL_PERSON
+# PO_ORDER (FK: cust_id) 1:1 <--|
+# +--> 0:1 (PK: company_id) AB_MORAL_PERSON
+# This is an 'arc' relationship :)
+#
+
+
+--disable_warnings
+drop database if exists demo;
+--enable_warnings
+
+create database demo;
+
+use demo;
+
+create table ab_physical_person (
+ person_id integer,
+ first_name VARCHAR(50),
+ middle_initial CHAR,
+ last_name VARCHAR(50),
+ primary key (person_id));
+
+create table ab_moral_person (
+ company_id integer,
+ name VARCHAR(100),
+ primary key (company_id));
+
+create table in_inventory (
+ item_id integer,
+ descr VARCHAR(50),
+ stock integer,
+ primary key (item_id));
+
+create table po_order (
+ po_id integer auto_increment,
+ cust_type char, /* arc relationship, see cust_id */
+ cust_id integer, /* FK to ab_physical_person *OR* ab_moral_person */
+ primary key (po_id));
+
+create table po_order_line (
+ po_id integer, /* FK to po_order.po_id */
+ line_no integer,
+ item_id integer, /* FK to in_inventory.item_id */
+ qty integer);
+
+delimiter $$;
+
+--echo #
+--echo # Schema integrity enforcement
+--echo #
+
+create procedure check_pk_person(in person_type char, in id integer)
+begin
+ declare x integer;
+ declare msg varchar(128);
+
+ /*
+ Test integrity constraints for an 'arc' relationship.
+ Based on 'person_type', 'id' points to either a
+ physical person, or a moral person.
+ */
+ case person_type
+ when 'P' then
+ begin
+ select count(person_id) from ab_physical_person
+ where ab_physical_person.person_id = id
+ into x;
+
+ if (x != 1)
+ then
+ set msg= concat('No such physical person, PK:', id);
+ SIGNAL SQLSTATE '45000' SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 10000;
+ end if;
+ end;
+
+ when 'M' then
+ begin
+ select count(company_id) from ab_moral_person
+ where ab_moral_person.company_id = id
+ into x;
+
+ if (x != 1)
+ then
+ set msg= concat('No such moral person, PK:', id);
+ SIGNAL SQLSTATE '45000' SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 10000;
+ end if;
+ end;
+
+ else
+ begin
+ set msg= concat('No such person type:', person_type);
+ SIGNAL SQLSTATE '45000' SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 20000;
+ end;
+ end case;
+end
+$$
+
+create procedure check_pk_inventory(in id integer)
+begin
+ declare x integer;
+ declare msg varchar(128);
+
+ select count(item_id) from in_inventory
+ where in_inventory.item_id = id
+ into x;
+
+ if (x != 1)
+ then
+ set msg= concat('Failed integrity constraint, table in_inventory, PK:',
+ id);
+ SIGNAL SQLSTATE '45000' SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 10000;
+ end if;
+end
+$$
+
+create procedure check_pk_order(in id integer)
+begin
+ declare x integer;
+ declare msg varchar(128);
+
+ select count(po_id) from po_order
+ where po_order.po_id = id
+ into x;
+
+ if (x != 1)
+ then
+ set msg= concat('Failed integrity constraint, table po_order, PK:', id);
+ SIGNAL SQLSTATE '45000' SET
+ MESSAGE_TEXT = msg,
+ MYSQL_ERRNO = 10000;
+ end if;
+end
+$$
+
+create trigger po_order_bi before insert on po_order
+for each row
+begin
+ call check_pk_person(NEW.cust_type, NEW.cust_id);
+end
+$$
+
+create trigger po_order_bu before update on po_order
+for each row
+begin
+ call check_pk_person(NEW.cust_type, NEW.cust_id);
+end
+$$
+
+create trigger po_order_line_bi before insert on po_order_line
+for each row
+begin
+ call check_pk_order(NEW.po_id);
+ call check_pk_inventory(NEW.item_id);
+end
+$$
+
+create trigger po_order_line_bu before update on po_order_line
+for each row
+begin
+ call check_pk_order(NEW.po_id);
+ call check_pk_inventory(NEW.item_id);
+end
+$$
+
+--echo #
+--echo # Application helpers
+--echo #
+
+create procedure po_create_order(
+ in p_cust_type char,
+ in p_cust_id integer,
+ out id integer)
+begin
+ insert into po_order set cust_type = p_cust_type, cust_id = p_cust_id;
+ set id = last_insert_id();
+end
+$$
+
+create procedure po_add_order_line(
+ in po integer,
+ in line integer,
+ in item integer,
+ in q integer)
+begin
+ insert into po_order_line set
+ po_id = po, line_no = line, item_id = item, qty = q;
+end
+$$
+
+delimiter ;$$
+
+--echo #
+--echo # Create sample data
+--echo #
+
+insert into ab_physical_person values
+ ( 1, "John", "A", "Doe"),
+ ( 2, "Marry", "B", "Smith")
+;
+
+insert into ab_moral_person values
+ ( 3, "ACME real estate, INC"),
+ ( 4, "Local school")
+;
+
+insert into in_inventory values
+ ( 100, "Table, dinner", 5),
+ ( 101, "Chair", 20),
+ ( 200, "Table, coffee", 3),
+ ( 300, "School table", 25),
+ ( 301, "School chairs", 50)
+;
+
+select * from ab_physical_person order by person_id;
+select * from ab_moral_person order by company_id;
+select * from in_inventory order by item_id;
+
+--echo #
+--echo # Entering an order
+--echo #
+
+set @my_po = 0;
+
+/* John Doe wants 1 table and 4 chairs */
+call po_create_order("P", 1, @my_po);
+
+call po_add_order_line (@my_po, 1, 100, 1);
+call po_add_order_line (@my_po, 2, 101, 4);
+
+/* Marry Smith wants a coffee table */
+call po_create_order("P", 2, @my_po);
+
+call po_add_order_line (@my_po, 1, 200, 1);
+
+--echo #
+--echo # Entering bad data in an order
+--echo #
+
+# There is no item 999 in in_inventory
+--error 10000
+call po_add_order_line (@my_po, 1, 999, 1);
+
+--echo #
+--echo # Entering bad data in an unknown order
+--echo #
+
+# There is no order 99 in po_order
+--error 10000
+call po_add_order_line (99, 1, 100, 1);
+
+--echo #
+--echo # Entering an order for an unknown company
+--echo #
+
+# There is no moral person of id 7
+--error 10000
+call po_create_order("M", 7, @my_po);
+
+--echo #
+--echo # Entering an order for an unknown person type
+--echo #
+
+# There is no person of type X
+--error 20000
+call po_create_order("X", 1, @my_po);
+
+/* The local school wants 10 class tables and 20 chairs */
+call po_create_order("M", 4, @my_po);
+
+call po_add_order_line (@my_po, 1, 300, 10);
+call po_add_order_line (@my_po, 2, 301, 20);
+
+# Raw data
+select * from po_order;
+select * from po_order_line;
+
+# Creative reporting ...
+
+select po_id as "PO#",
+ ( case cust_type
+ when "P" then concat (pp.first_name,
+ " ",
+ pp.middle_initial,
+ " ",
+ pp.last_name)
+ when "M" then mp.name
+ end ) as "Sold to"
+ from po_order po
+ left join ab_physical_person pp on po.cust_id = pp.person_id
+ left join ab_moral_person mp on po.cust_id = company_id
+;
+
+select po_id as "PO#",
+ ol.line_no as "Line",
+ ol.item_id as "Item",
+ inv.descr as "Description",
+ ol.qty as "Quantity"
+ from po_order_line ol, in_inventory inv
+ where inv.item_id = ol.item_id
+ order by ol.item_id, ol.line_no;
+
+drop database demo;
+
+
diff --git a/mysql-test/t/signal_demo2.test b/mysql-test/t/signal_demo2.test
new file mode 100644
index 00000000000..fc909cb926c
--- /dev/null
+++ b/mysql-test/t/signal_demo2.test
@@ -0,0 +1,207 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# Demonstrate how RESIGNAL can be used to 'catch' and 're-throw' an error
+#
+
+--disable_warnings
+drop database if exists demo;
+--enable_warnings
+
+create database demo;
+
+use demo;
+
+delimiter $$;
+
+create procedure proc_top_a(p1 integer)
+begin
+ ## DECLARE CONTINUE HANDLER for SQLEXCEPTION, NOT FOUND
+ begin
+ end;
+
+ select "Starting ...";
+ call proc_middle_a(p1);
+ select "The end";
+end
+$$
+
+create procedure proc_middle_a(p1 integer)
+begin
+ DECLARE l integer;
+ # without RESIGNAL:
+ # Should be: DECLARE EXIT HANDLER for SQLEXCEPTION, NOT FOUND
+ DECLARE EXIT HANDLER for 1 /* not sure how to handle exceptions */
+ begin
+ select "Oops ... now what ?";
+ end;
+
+ select "In prod_middle()";
+
+ create temporary table t1(a integer, b integer);
+ select GET_LOCK("user_mutex", 10) into l;
+
+ insert into t1 set a = p1, b = p1;
+
+ call proc_bottom_a(p1);
+
+ select RELEASE_LOCK("user_mutex") into l;
+ drop temporary table t1;
+end
+$$
+
+create procedure proc_bottom_a(p1 integer)
+begin
+ select "In proc_bottom()";
+
+ if (p1 = 1) then
+ begin
+ select "Doing something that works ...";
+ select * from t1;
+ end;
+ end if;
+
+ if (p1 = 2) then
+ begin
+ select "Doing something that fail (simulate an error) ...";
+ drop table no_such_table;
+ end;
+ end if;
+
+ if (p1 = 3) then
+ begin
+ select "Doing something that *SHOULD* works ...";
+ select * from t1;
+ end;
+ end if;
+
+end
+$$
+
+delimiter ;$$
+
+#
+# Code without RESIGNAL:
+# errors are apparent to the caller,
+# but there is no cleanup code,
+# so that the environment (get_lock(), temporary table) is polluted ...
+#
+call proc_top_a(1);
+
+# Expected
+--error ER_BAD_TABLE_ERROR
+call proc_top_a(2);
+
+# Dirty state
+--error ER_TABLE_EXISTS_ERROR
+call proc_top_a(3);
+
+# Dirty state
+--error ER_TABLE_EXISTS_ERROR
+call proc_top_a(1);
+
+drop temporary table if exists t1;
+
+delimiter $$;
+
+create procedure proc_top_b(p1 integer)
+begin
+ select "Starting ...";
+ call proc_middle_b(p1);
+ select "The end";
+end
+$$
+
+create procedure proc_middle_b(p1 integer)
+begin
+ DECLARE l integer;
+ DECLARE EXIT HANDLER for SQLEXCEPTION, NOT FOUND
+ begin
+ begin
+ DECLARE CONTINUE HANDLER for SQLEXCEPTION, NOT FOUND
+ begin
+ /* Ignore errors from the cleanup code */
+ end;
+
+ select "Doing cleanup !";
+ select RELEASE_LOCK("user_mutex") into l;
+ drop temporary table t1;
+ end;
+
+ RESIGNAL;
+ end;
+
+ select "In prod_middle()";
+
+ create temporary table t1(a integer, b integer);
+ select GET_LOCK("user_mutex", 10) into l;
+
+ insert into t1 set a = p1, b = p1;
+
+ call proc_bottom_b(p1);
+
+ select RELEASE_LOCK("user_mutex") into l;
+ drop temporary table t1;
+end
+$$
+
+create procedure proc_bottom_b(p1 integer)
+begin
+ select "In proc_bottom()";
+
+ if (p1 = 1) then
+ begin
+ select "Doing something that works ...";
+ select * from t1;
+ end;
+ end if;
+
+ if (p1 = 2) then
+ begin
+ select "Doing something that fail (simulate an error) ...";
+ drop table no_such_table;
+ end;
+ end if;
+
+ if (p1 = 3) then
+ begin
+ select "Doing something that *SHOULD* works ...";
+ select * from t1;
+ end;
+ end if;
+
+end
+$$
+
+delimiter ;$$
+
+#
+# Code with RESIGNAL:
+# errors are apparent to the caller,
+# the but cleanup code did get a chance to act ...
+#
+
+call proc_top_b(1);
+
+--error ER_BAD_TABLE_ERROR
+call proc_top_b(2);
+
+call proc_top_b(3);
+
+call proc_top_b(1);
+
+drop database demo;
+
diff --git a/mysql-test/t/signal_demo3.test b/mysql-test/t/signal_demo3.test
new file mode 100644
index 00000000000..347f1b75a79
--- /dev/null
+++ b/mysql-test/t/signal_demo3.test
@@ -0,0 +1,159 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# Demonstrate how RESIGNAL can be used to print a stack trace
+#
+
+# Save defaults
+
+SET @start_global_value = @@global.max_error_count;
+SELECT @start_global_value;
+SET @start_session_value = @@session.max_error_count;
+SELECT @start_session_value;
+
+--disable_warnings
+drop database if exists demo;
+--enable_warnings
+
+create database demo;
+
+use demo;
+
+delimiter $$;
+
+create procedure proc_1()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_1';
+
+ call proc_2();
+end
+$$
+
+create procedure proc_2()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_2';
+
+ call proc_3();
+end
+$$
+
+create procedure proc_3()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_3';
+
+ call proc_4();
+end
+$$
+
+create procedure proc_4()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_4';
+
+ call proc_5();
+end
+$$
+
+create procedure proc_5()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_5';
+
+ call proc_6();
+end
+$$
+
+create procedure proc_6()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_6';
+
+ call proc_7();
+end
+$$
+
+create procedure proc_7()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_7';
+
+ call proc_8();
+end
+$$
+
+create procedure proc_8()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_8';
+
+ call proc_9();
+end
+$$
+
+create procedure proc_9()
+begin
+ declare exit handler for sqlexception
+ resignal sqlstate '45000' set message_text='Oops in proc_9';
+
+ ## Do something that fails, to see how errors are reported
+ drop table oops_it_is_not_here;
+end
+$$
+
+delimiter ;$$
+
+-- error ER_SIGNAL_EXCEPTION
+call proc_1();
+
+# This is the interesting part:
+# the complete call stack from the origin of failure (proc_9)
+# to the top level caller (proc_1) is available ...
+
+show warnings;
+
+SET @@session.max_error_count = 5;
+SELECT @@session.max_error_count;
+
+-- error ER_SIGNAL_EXCEPTION
+call proc_1();
+show warnings;
+
+SET @@session.max_error_count = 7;
+SELECT @@session.max_error_count;
+
+-- error ER_SIGNAL_EXCEPTION
+call proc_1();
+show warnings;
+
+SET @@session.max_error_count = 9;
+SELECT @@session.max_error_count;
+
+-- error ER_SIGNAL_EXCEPTION
+call proc_1();
+show warnings;
+
+drop database demo;
+
+# Restore defaults
+
+SET @@global.max_error_count = @start_global_value;
+SELECT @@global.max_error_count;
+SET @@session.max_error_count = @start_session_value;
+SELECT @@session.max_error_count;
+
diff --git a/mysql-test/t/signal_sqlmode.test b/mysql-test/t/signal_sqlmode.test
new file mode 100644
index 00000000000..860c145a361
--- /dev/null
+++ b/mysql-test/t/signal_sqlmode.test
@@ -0,0 +1,123 @@
+# Copyright (C) 2008 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for SIGNAL, RESIGNAL and GET DIAGNOSTICS
+
+SET @save_sql_mode=@@sql_mode;
+
+SET sql_mode='';
+
+--disable_warnings
+drop procedure if exists p;
+drop procedure if exists p2;
+drop procedure if exists p3;
+--enable_warnings
+
+delimiter $$;
+
+create procedure p()
+begin
+ declare utf8_var VARCHAR(128) CHARACTER SET UTF8;
+ set utf8_var = concat(repeat('A', 128), 'X');
+ select length(utf8_var), utf8_var;
+end
+$$
+
+create procedure p2()
+begin
+ declare msg VARCHAR(129) CHARACTER SET UTF8;
+ set msg = concat(repeat('A', 128), 'X');
+ select length(msg), msg;
+
+ signal sqlstate '55555' set message_text = msg;
+end
+$$
+
+create procedure p3()
+begin
+ declare name VARCHAR(65) CHARACTER SET UTF8;
+ set name = concat(repeat('A', 64), 'X');
+ select length(name), name;
+
+ signal sqlstate '55555' set
+ message_text = 'Message',
+ table_name = name;
+end
+$$
+delimiter ;$$
+
+call p;
+
+--error ER_SIGNAL_EXCEPTION
+call p2;
+
+--error ER_SIGNAL_EXCEPTION
+call p3;
+
+drop procedure p;
+drop procedure p2;
+drop procedure p3;
+
+SET sql_mode='STRICT_ALL_TABLES';
+
+delimiter $$;
+
+create procedure p()
+begin
+ declare utf8_var VARCHAR(128) CHARACTER SET UTF8;
+ set utf8_var = concat(repeat('A', 128), 'X');
+ select length(utf8_var), utf8_var;
+end
+$$
+
+create procedure p2()
+begin
+ declare msg VARCHAR(129) CHARACTER SET UTF8;
+ set msg = concat(repeat('A', 128), 'X');
+ select length(msg), msg;
+
+ signal sqlstate '55555' set message_text = msg;
+end
+$$
+
+create procedure p3()
+begin
+ declare name VARCHAR(65) CHARACTER SET UTF8;
+ set name = concat(repeat('A', 64), 'X');
+ select length(name), name;
+
+ signal sqlstate '55555' set
+ message_text = 'Message',
+ table_name = name;
+end
+$$
+
+delimiter ;$$
+
+--error ER_DATA_TOO_LONG
+call p;
+
+--error ER_COND_ITEM_TOO_LONG
+call p2;
+
+--error ER_COND_ITEM_TOO_LONG
+call p3;
+
+drop procedure p;
+drop procedure p2;
+drop procedure p3;
+
+SET @@sql_mode=@save_sql_mode;
+
diff --git a/mysql-test/t/single_delete_update.test b/mysql-test/t/single_delete_update.test
new file mode 100644
index 00000000000..e3ee13f891c
--- /dev/null
+++ b/mysql-test/t/single_delete_update.test
@@ -0,0 +1,481 @@
+#
+# Single table specific update/delete tests (mysql_update and mysql_delete)
+#
+
+--echo #
+--echo # Bug #30584: delete with order by and limit clauses does not use
+--echo # limit efficiently
+--echo #
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25);
+
+CREATE TABLE t2(a INT, i INT PRIMARY KEY);
+INSERT INTO t2 (i) SELECT i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
+
+DROP TABLE t2;
+
+--echo #
+--echo # index on field prefix:
+--echo #
+
+CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1)));
+INSERT INTO t2 (i) SELECT i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
+
+DROP TABLE t2;
+
+--echo #
+--echo # constant inside ORDER BY list, should use filesort
+--echo # on a small table
+--echo #
+
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+let $cnt = `SELECT COUNT(*) FROM t2 WHERE b = 10`;
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+--echo ## should be 5 (previous LIMIT)
+eval SELECT $cnt - COUNT(*) FROM t2 WHERE b = 10;
+
+DROP TABLE t2;
+
+--echo #
+--echo # same test as above (constant inside ORDER BY list), but with
+--echo # a larger table - should not use filesort
+--echo #
+
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+
+INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+let $cnt = `SELECT COUNT(*) FROM t2 WHERE b = 10`;
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+--echo ## should be 5 (previous LIMIT)
+eval SELECT $cnt - COUNT(*) FROM t2 WHERE b = 10;
+
+DROP TABLE t2;
+
+--echo #
+--echo # as above + partial index, should use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c));
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
+
+DROP TABLE t2;
+
+--echo #
+--echo # as above but index is without HA_READ_ORDER flag, should use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) ENGINE=HEAP;
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
+
+DROP TABLE t2;
+
+--echo #
+--echo # quick select is Index Merge, should use filesort
+--echo #
+
+CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2));
+INSERT INTO t2 (key1, key2) SELECT i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+--replace_column 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+--replace_column 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+DROP TABLE t2;
+
+--echo #
+--echo # reverse quick select, should not use filesort
+--echo #
+
+CREATE TABLE t2(a INT, i INT PRIMARY KEY);
+INSERT INTO t2 (i) SELECT i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
+
+DROP TABLE t2;
+
+--echo #
+--echo # mixed sorting direction, should use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b));
+INSERT INTO t2 SELECT i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+DELETE FROM t2 ORDER BY a, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 ORDER BY a, b DESC;
+
+DROP TABLE t2;
+
+--echo #
+--echo # LIMIT with no WHERE and DESC direction, should not use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b));
+INSERT INTO t2 (a, b) SELECT i, i FROM t1;
+INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2;
+
+FLUSH STATUS;
+SELECT * FROM t2 ORDER BY a, b LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE c = 10 ORDER BY a DESC, b DESC;
+
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Bug #36569: UPDATE ... WHERE ... ORDER BY... always does a filesort
+--echo # even if not required
+--echo #
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25);
+
+CREATE TABLE t2(a INT, i INT PRIMARY KEY);
+INSERT INTO t2 (i) SELECT i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
+
+DROP TABLE t2;
+
+--echo #
+--echo # index on field prefix:
+--echo #
+
+CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1)));
+INSERT INTO t2 (i) SELECT i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
+
+DROP TABLE t2;
+
+--echo #
+--echo # constant inside ORDER BY list, should use filesort
+--echo # on a small table
+--echo #
+
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+let $cnt = `SELECT COUNT(*) FROM t2 WHERE b = 10`;
+
+FLUSH STATUS;
+UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+--echo ## should be 5 (previous LIMIT)
+SELECT COUNT(*) FROM t2 WHERE b = 10 AND d = 10 ORDER BY a, c;
+
+DROP TABLE t2;
+
+--echo #
+--echo # same test as above (constant inside ORDER BY list), but with
+--echo # a larger table - should not use filesort
+--echo #
+
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+
+INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+let $cnt = `SELECT COUNT(*) FROM t2 WHERE b = 10`;
+
+FLUSH STATUS;
+UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+--echo ## should be 5 (previous LIMIT)
+SELECT COUNT(*) FROM t2 WHERE b = 10 AND d = 10 ORDER BY a, c;
+
+DROP TABLE t2;
+
+--echo #
+--echo # as above + partial index, should use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c));
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
+
+DROP TABLE t2;
+
+--echo #
+--echo # as above but index is without HA_READ_ORDER flag, should use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c)) ENGINE=HEAP;
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE b = 10 ORDER BY a, c;
+
+DROP TABLE t2;
+
+--echo #
+--echo # quick select is Index Merge, should use filesort
+--echo #
+
+CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2));
+INSERT INTO t2 (key1, key2) SELECT i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+--replace_column 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+
+FLUSH STATUS;
+UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+--replace_column 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1;
+
+DROP TABLE t2;
+
+--echo #
+--echo # reverse quick select, should not use filesort
+--echo #
+
+CREATE TABLE t2(a INT, i INT PRIMARY KEY);
+INSERT INTO t2 (i) SELECT i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i;
+
+DROP TABLE t2;
+
+--echo #
+--echo # mixed sorting direction, should use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b));
+INSERT INTO t2 SELECT i, i, i FROM t1;
+
+FLUSH STATUS;
+SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE c = 10 ORDER BY a, b DESC;
+
+DROP TABLE t2;
+
+--echo #
+--echo # LIMIT with no WHERE and DESC direction, should not use filesort
+--echo #
+
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b));
+INSERT INTO t2 (a, b) SELECT i, i FROM t1;
+INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2;
+
+FLUSH STATUS;
+SELECT * FROM t2 ORDER BY a, b LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+
+FLUSH STATUS;
+UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5;
+SHOW SESSION STATUS LIKE 'Sort%';
+SHOW STATUS LIKE 'Handler_read_%';
+SELECT * FROM t2 WHERE c = 10 ORDER BY a DESC, b DESC;
+
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Bug #53742: UPDATEs have no effect after applying patch for bug 36569
+--echo #
+
+--disable_warnings
+CREATE TABLE t1 (
+ pk INT NOT NULL AUTO_INCREMENT,
+ c1_idx CHAR(1) DEFAULT 'y',
+ c2 INT,
+ PRIMARY KEY (pk),
+ INDEX c1_idx (c1_idx)
+) ENGINE=InnoDB;
+--enable_warnings
+
+INSERT INTO t1 VALUES (), (), (), ();
+
+SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;
+UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;
+SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;
+SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC;
+
+DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2;
+SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC;
+
+DROP TABLE t1;
+
diff --git a/mysql-test/t/skip_name_resolve.test b/mysql-test/t/skip_name_resolve.test
index 0edbdbcd22c..a14f3af5cd6 100644
--- a/mysql-test/t/skip_name_resolve.test
+++ b/mysql-test/t/skip_name_resolve.test
@@ -15,7 +15,7 @@ DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
# Bug#13407 Remote connecting crashes server
# Server crashed when one used USER() function in connection for which
# was impossible to obtain peer hostname.
-connect (con1, 127.0.0.1, root, , test, $MASTER_MYPORT, );
+connect (con1, localhost, root, , test, $MASTER_MYPORT, );
--replace_column 1 #
SELECT USER();
# We are only interested in the fact that statement below doesn't
diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test
index 247c84fda39..90b4c18895a 100644
--- a/mysql-test/t/sp-code.test
+++ b/mysql-test/t/sp-code.test
@@ -649,3 +649,56 @@ END//
DELIMITER ;//
SHOW PROCEDURE CODE p1;
DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
+--echo #
+
+--echo
+--echo # - Case 4: check that "No Data trumps Warning".
+--echo
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE c CURSOR FOR SELECT a FROM t1;
+
+ OPEN c;
+
+ BEGIN
+ DECLARE v INT;
+
+ DECLARE CONTINUE HANDLER FOR SQLWARNING
+ BEGIN
+ SELECT "Warning found!";
+ SHOW WARNINGS;
+ END;
+
+ DECLARE EXIT HANDLER FOR NOT FOUND
+ BEGIN
+ SELECT "End of Result Set found!";
+ SHOW WARNINGS;
+ END;
+
+ WHILE TRUE DO
+ FETCH c INTO v;
+ END WHILE;
+ END;
+
+ CLOSE c;
+
+ SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
+END|
+
+delimiter ;|
+
+SET SESSION debug="+d,bug23032_emit_warning";
+CALL p1();
+SET SESSION debug="-d,bug23032_emit_warning";
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test
index 720c24b2c24..6766b496db7 100644
--- a/mysql-test/t/sp-destruct.test
+++ b/mysql-test/t/sp-destruct.test
@@ -14,6 +14,7 @@
# Supress warnings written to the log file
call mtr.add_suppression("Column count of mysql.proc is wrong. Expected 20, found 19. The table is probably corrupted");
+call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value in column mysql.proc");
# Backup proc table
let $MYSQLD_DATADIR= `select @@datadir`;
@@ -197,3 +198,85 @@ SHOW PROCEDURE STATUS;
DROP TABLE mysql.proc;
RENAME TABLE proc_backup TO mysql.proc;
FLUSH TABLE mysql.proc;
+
+
+--echo #
+--echo # Bug#51376 Assert `! is_set()' failed in
+--echo # Diagnostics_area::set_ok_status on DROP FUNCTION
+--echo #
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE FUNCTION f1() RETURNS INT RETURN 1;
+
+--echo # Backup the procs_priv table
+RENAME TABLE mysql.procs_priv TO procs_priv_backup;
+FLUSH TABLE mysql.procs_priv;
+
+# DROP FUNCTION used to cause an assert.
+--error ER_NO_SUCH_TABLE
+DROP FUNCTION f1;
+SHOW WARNINGS;
+
+--echo # Restore the procs_priv table
+RENAME TABLE procs_priv_backup TO mysql.procs_priv;
+FLUSH TABLE mysql.procs_priv;
+
+
+--echo #
+--echo # Bug #56137 "Assertion `thd->lock == 0' failed on upgrading from
+--echo # 5.1.50 to 5.5.6".
+--echo #
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+--echo # Backup mysql.proc.
+flush table mysql.proc;
+let $MYSQLD_DATADIR= `select @@datadir`;
+--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm
+--copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD
+--copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI
+
+create database mysqltest;
+--echo # Corrupt mysql.proc to make it unusable by current version of server.
+alter table mysql.proc drop column type;
+--echo # The below statement should not cause assertion failure.
+drop database mysqltest;
+
+--echo # Restore mysql.proc.
+drop table mysql.proc;
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI
+
+
+--echo #
+--echo # Bug#58414 mysql_upgrade fails on dump upgrade between 5.1.53 -> 5.5.8
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS proc_backup;
+DROP DATABASE IF EXISTS db1;
+--enable_warnings
+
+--echo # Backup the proc table
+RENAME TABLE mysql.proc TO proc_backup;
+CREATE TABLE mysql.proc LIKE proc_backup;
+
+CREATE DATABASE db1;
+CREATE PROCEDURE db1.p1() SET @foo = 10;
+
+--echo # Modify a field of the table.
+ALTER TABLE mysql.proc MODIFY comment CHAR (32);
+
+# This should not fail even if mysql.proc is invalid.
+DROP DATABASE db1;
+
+--echo # Restore mysql.proc
+DROP TABLE mysql.proc;
+RENAME TABLE proc_backup TO mysql.proc;
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index 18a4a117939..6175fc53adf 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -723,7 +723,7 @@ lock table t1 read|
# This should fail since we forgot to lock mysql.proc for writing
# explicitly, and we can't open mysql.proc for _writing_ if there
# are locked tables.
---error 1100
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
alter procedure bug9566 comment 'Some comment'|
unlock tables|
# This should succeed
@@ -1325,11 +1325,6 @@ CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN DROP TRIGGER test1; EN
-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
CREATE FUNCTION bug_13627_f() returns int BEGIN DROP TRIGGER test1; return 1; END |
--- error ER_SP_BADSTATEMENT
-CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN load table t1 from master; END |
--- error ER_SP_BADSTATEMENT
-CREATE FUNCTION bug_13627_f() returns int BEGIN load table t1 from master; return 1; END |
-
-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW BEGIN create table t2 (a int); END |
-- error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
@@ -1580,18 +1575,6 @@ BEGIN
REPAIR TABLE t1;
RETURN 1;
END|
---error ER_SP_NO_RETSET
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
- BACKUP TABLE t1 TO '/tmp';
- RETURN 1;
-END|
---error ER_SP_NO_RETSET
-CREATE FUNCTION bug13012() RETURNS INT
-BEGIN
- RESTORE TABLE t1 FROM '/tmp';
- RETURN 1;
-END|
create table t1 (a int)|
CREATE PROCEDURE bug13012_1() REPAIR TABLE t1|
CREATE FUNCTION bug13012_2() RETURNS INT
@@ -2386,7 +2369,7 @@ drop procedure if exists p1;
delimiter |;
create procedure p1()
begin
- create table t1 (a int) type=MyISAM;
+ create table t1 (a int) engine=MyISAM;
drop table t1;
end|
delimiter ;|
@@ -2419,6 +2402,64 @@ end$$
delimiter ;$$
+#
+# Bug#36510 (Stored Procedures: mysql_error_code 0 should be illegal)
+#
+
+--disable_warnings
+drop procedure if exists proc_36510;
+--enable_warnings
+
+delimiter $$;
+
+--error ER_SP_BAD_SQLSTATE
+create procedure proc_36510()
+begin
+ declare should_be_illegal condition for sqlstate '00123';
+ declare continue handler for should_be_illegal set @x=0;
+end$$
+
+--error ER_SP_BAD_SQLSTATE
+create procedure proc_36510()
+begin
+ declare continue handler for sqlstate '00123' set @x=0;
+end$$
+
+--error ER_WRONG_VALUE
+create procedure proc_36510()
+begin
+ declare should_be_illegal condition for 0;
+ declare continue handler for should_be_illegal set @x=0;
+end$$
+
+--error ER_WRONG_VALUE
+create procedure proc_36510()
+begin
+ declare continue handler for 0 set @x=0;
+end$$
+delimiter ;$$
+
+#
+# Bug#15192: "fatal errors" are caught by handlers in stored procedures
+#
+
+--disable_warnings
+drop procedure if exists p1;
+--enable_warnings
+set @old_recursion_depth = @@max_sp_recursion_depth;
+set @@max_sp_recursion_depth = 255;
+delimiter |;
+create procedure p1(a int)
+begin
+ declare continue handler for 1436 -- ER_STACK_OVERRUN_NEED_MORE
+ select 'exception';
+ call p1(a+1);
+end|
+delimiter ;|
+--error 0,ER_STACK_OVERRUN_NEED_MORE,ER_SP_RECURSION_LIMIT
+call p1(1);
+set @@max_sp_recursion_depth = @old_recursion_depth;
+drop procedure p1;
#
# BUG#NNNN: New bug synopsis
@@ -2449,6 +2490,35 @@ SELECT AVG (a) FROM t1 WHERE b = 999999;
SELECT non_existent (a) FROM t1 WHERE b = 999999;
DROP TABLE t1;
+
+#
+# Bug #46374 crash, INSERT INTO t1 uses function, function modifies t1
+#
+CREATE TABLE t1 ( f2 INTEGER, f3 INTEGER );
+INSERT INTO t1 VALUES ( 1, 1 );
+
+delimiter |;
+
+CREATE FUNCTION func_1 () RETURNS INTEGER
+BEGIN
+ INSERT INTO t1 SELECT * FROM t1 ;
+ RETURN 1 ;
+END|
+
+delimiter ;|
+
+# The bug caused the following INSERT statement to trigger
+# an assertion. Error 1442 is the correct response
+#
+--error 1442
+INSERT INTO t1 SELECT * FROM (SELECT 2 AS f1, 2 AS f2) AS A WHERE func_1() = 5;
+
+# Cleanup
+DROP FUNCTION func_1;
+DROP TABLE t1;
+
+
+
--echo #
--echo # Bug #47788: Crash in TABLE_LIST::hide_view_error on UPDATE + VIEW +
--echo # SP + MERGE + ALTER
@@ -2472,3 +2542,320 @@ DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
+--echo #
+
+--echo
+--echo # - Case 1
+--echo
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+DROP PROCEDURE IF EXISTS p5;
+DROP PROCEDURE IF EXISTS p6;
+--enable_warnings
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ SELECT 1;
+ CALL p2();
+ END|
+
+CREATE PROCEDURE p2()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+
+--echo
+--echo # - Case 2
+--echo
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+ BEGIN
+ DECLARE c INT DEFAULT 0;
+ DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+ CALL p2();
+ CALL p3();
+ CALL p4();
+ SELECT c;
+ SELECT @@warning_count;
+ SHOW WARNINGS;
+ END|
+
+CREATE PROCEDURE p2()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ END|
+
+CREATE PROCEDURE p3()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ SELECT 1;
+ END|
+
+CREATE PROCEDURE p4()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ CALL p2();
+ END|
+
+CREATE PROCEDURE p5()
+ BEGIN
+ SELECT CAST('10 ' as unsigned integer);
+ SHOW WARNINGS;
+ END|
+
+CREATE PROCEDURE P6()
+ BEGIN
+ DECLARE c INT DEFAULT 0;
+ DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+ CALL p5();
+ SELECT c;
+ END|
+
+delimiter ;|
+
+CALL p1();
+CALL p6();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP PROCEDURE p5;
+DROP PROCEDURE p6;
+
+--echo
+--echo # - Case 3: check that "Exception trumps No Data".
+--echo
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE c CURSOR FOR SELECT a FROM t1;
+
+ OPEN c;
+
+ BEGIN
+ DECLARE v1 INT;
+ DECLARE v2 INT;
+
+ DECLARE EXIT HANDLER FOR SQLEXCEPTION
+ SELECT "Error caught (expected)";
+
+ DECLARE EXIT HANDLER FOR NOT FOUND
+ SELECT "End of Result Set found!";
+
+ WHILE TRUE DO
+ FETCH c INTO v1, v2;
+ END WHILE;
+ END;
+
+ CLOSE c;
+
+ SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack
+END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#36185: Incorrect precedence for warning and exception handlers
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception';
+ INSERT INTO t1 VALUES (CAST('10 ' AS SIGNED), NULL);
+END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP TABLE t1;
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
+--echo #
+
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1, 2);
+
+delimiter |;
+
+CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLWARNING
+ SET NEW.a = 10;
+
+ SET NEW.a = 99999999999;
+END|
+
+delimiter ;|
+
+UPDATE t1 SET b = 20;
+
+SHOW WARNINGS;
+
+SELECT * FROM t1;
+
+DROP TRIGGER t1_bu;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#9857: Stored procedures: handler for sqlwarning ignored
+--echo #
+
+SET @sql_mode_saved = @@sql_mode;
+SET sql_mode = traditional;
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLWARNING
+ SELECT 'warning caught (expected)';
+
+ SELECT 5 / 0;
+END|
+
+CREATE PROCEDURE p2()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
+ SELECT 'error caught (unexpected)';
+
+ SELECT 5 / 0;
+END|
+
+delimiter ;|
+
+CALL p1();
+SHOW WARNINGS;
+
+CALL p2();
+SHOW WARNINGS;
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+SET sql_mode = @sql_mode_saved;
+
+--echo #
+--echo # Bug#55850: Trigger warnings not cleared.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT,
+ d SMALLINT, e SMALLINT, f SMALLINT);
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+ INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999);
+
+CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
+ INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999);
+
+CREATE PROCEDURE p1()
+ INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+# What happened before the patch was:
+# - INSERT INTO t1 added 3 warnings about overflow in 'x', 'y' and 'z' columns;
+# - t1_bi run and added 3 warnings about overflow in 'a', 'b' and 'c' columns;
+# - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns;
+# => we had 9 warnings.
+#
+# Now what happens is:
+# - INSERT INTO t1 adds 3 warnings about overflow in 'x', 'y' and 'z' columns;
+# - t1_bi adds 3 warnings about overflow in 'a', 'b' and 'c' columns;
+# - The warnings added by triggers are cleared;
+# - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns;
+# - The warnings added by triggers are cleared;
+# => we have 3 warnings.
+
+--echo
+CALL p1();
+
+--echo
+SHOW WARNINGS;
+
+--echo
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;
+
+--echo # ----------------------------------------------------------------------
+
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL);
+
+delimiter |;
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ INSERT INTO t2 VALUES(
+ CAST('111111 ' AS SIGNED),
+ CAST('222222 ' AS SIGNED),
+ NULL);
+END|
+
+delimiter ;|
+
+CREATE PROCEDURE p1()
+ INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+--echo
+--error ER_BAD_NULL_ERROR
+CALL p1();
+
+--echo
+SHOW WARNINGS;
+
+--echo
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;
diff --git a/mysql-test/t/sp-lock.test b/mysql-test/t/sp-lock.test
new file mode 100644
index 00000000000..6284169eb9b
--- /dev/null
+++ b/mysql-test/t/sp-lock.test
@@ -0,0 +1,1141 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# Metadata lock handling for stored procedures and
+# functions.
+#
+--echo #
+--echo # Test coverage for changes performed by the fix
+--echo # for Bug#30977 "Concurrent statement using stored function
+--echo # and DROP FUNCTION breaks SBR.
+--echo #
+
+--echo #
+--echo # 1) Verify that the preceding transaction is
+--echo # (implicitly) committed before CREATE/ALTER/DROP
+--echo # PROCEDURE. Note, that this is already tested
+--echo # in implicit_commit.test, but here we use an alternative
+--echo # approach.
+--echo #
+
+--echo # Start a transaction, create a savepoint,
+--echo # then call a DDL operation on a procedure, and then check
+--echo # that the savepoint is no longer present.
+
+--disable_warnings
+drop table if exists t1;
+drop procedure if exists p1;
+drop procedure if exists p2;
+drop procedure if exists p3;
+drop procedure if exists p4;
+drop function if exists f1;
+--enable_warnings
+create table t1 (a int);
+--echo #
+--echo # Test 'CREATE PROCEDURE'.
+--echo #
+begin;
+savepoint sv;
+create procedure p1() begin end;
+--error ER_SP_DOES_NOT_EXIST
+rollback to savepoint sv;
+--echo #
+--echo # Test 'ALTER PROCEDURE'.
+--echo #
+begin;
+savepoint sv;
+alter procedure p1 comment 'changed comment';
+--error ER_SP_DOES_NOT_EXIST
+rollback to savepoint sv;
+--echo #
+--echo # Test 'DROP PROCEDURE'.
+--echo #
+begin;
+savepoint sv;
+drop procedure p1;
+--error ER_SP_DOES_NOT_EXIST
+rollback to savepoint sv;
+--echo #
+--echo # Test 'CREATE FUNCTION'.
+--echo #
+begin;
+savepoint sv;
+create function f1() returns int return 1;
+--error ER_SP_DOES_NOT_EXIST
+rollback to savepoint sv;
+--echo #
+--echo # Test 'ALTER FUNCTION'.
+--echo #
+begin;
+savepoint sv;
+alter function f1 comment 'new comment';
+--error ER_SP_DOES_NOT_EXIST
+rollback to savepoint sv;
+--echo #
+--echo # Test 'DROP FUNCTION'.
+--echo #
+begin;
+savepoint sv;
+drop function f1;
+--error ER_SP_DOES_NOT_EXIST
+rollback to savepoint sv;
+
+--echo #
+--echo # 2) Verify that procedure DDL operations fail
+--echo # under lock tables.
+--echo #
+--echo # Auxiliary routines to test ALTER.
+create procedure p1() begin end;
+create function f1() returns int return 1;
+
+lock table t1 write;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+create procedure p2() begin end;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+alter procedure p1 comment 'changed comment';
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+drop procedure p1;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+create function f2() returns int return 1;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+alter function f1 comment 'changed comment';
+lock table t1 read;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+create procedure p2() begin end;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+alter procedure p1 comment 'changed comment';
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+drop procedure p1;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+create function f2() returns int return 1;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+alter function f1 comment 'changed comment';
+unlock tables;
+--echo #
+--echo # Even if we locked a temporary table.
+--echo # Todo: this is a restriction we could possibly lift.
+--echo #
+drop table t1;
+create temporary table t1 (a int);
+lock table t1 read;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+create procedure p2() begin end;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+alter procedure p1 comment 'changed comment';
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+drop procedure p1;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+create function f2() returns int return 1;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+alter function f1 comment 'changed comment';
+unlock tables;
+
+drop function f1;
+drop procedure p1;
+drop temporary table t1;
+
+--echo #
+--echo # 3) Verify that CREATE/ALTER/DROP routine grab an
+--echo # exclusive lock.
+--echo #
+--echo # For that, start a transaction, use a routine. In a concurrent
+--echo # connection, try to drop or alter the routine. It should place
+--echo # a pending or exclusive lock and block. In another concurrnet
+--echo # connection, try to use the routine.
+--echo # That should block on the pending exclusive lock.
+--echo #
+--echo # Establish helper connections.
+connect(con1, localhost, root,,);
+connect(con2, localhost, root,,);
+connect(con3, localhost, root,,);
+
+--echo #
+--echo # Test DROP PROCEDURE.
+--echo #
+--echo # --> connection default
+connection default;
+create procedure p1() begin end;
+delimiter |;
+create function f1() returns int
+begin
+ call p1();
+ return 1;
+end|
+delimiter ;|
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'drop procedure p1'...
+send drop procedure p1;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'drop procedure t1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored procedure metadata lock' and
+info='drop procedure p1';
+--source include/wait_condition.inc
+--echo # Demonstrate that there is a pending exclusive lock.
+--echo # Sending 'select f1()'...
+send select f1();
+--echo # --> connection con3
+connection con3;
+--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored procedure metadata lock' and info='select f1()';
+--echo # --> connection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'drop procedure p1'...
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'select f1()'
+--error ER_SP_DOES_NOT_EXIST
+reap;
+--echo # --> connection default
+connection default;
+
+--echo #
+--echo # Test CREATE PROCEDURE.
+--echo #
+create procedure p1() begin end;
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'create procedure p1'...
+send create procedure p1() begin end;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'create procedure t1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored procedure metadata lock' and
+info='create procedure p1() begin end';
+--source include/wait_condition.inc
+--echo # Demonstrate that there is a pending exclusive lock.
+--echo # Sending 'select f1()'...
+send select f1();
+--echo # --> connection con3
+connection con3;
+--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored procedure metadata lock' and info='select f1()';
+--echo # --> connection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'create procedure p1'...
+--error ER_SP_ALREADY_EXISTS
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'select f1()'
+reap;
+connection default;
+
+--echo #
+--echo # Test ALTER PROCEDURE.
+--echo #
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'alter procedure p1'...
+send alter procedure p1 contains sql;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'alter procedure t1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored procedure metadata lock' and
+info='alter procedure p1 contains sql';
+--source include/wait_condition.inc
+--echo # Demonstrate that there is a pending exclusive lock.
+--echo # Sending 'select f1()'...
+send select f1();
+--echo # --> connection con3
+connection con3;
+--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored procedure metadata lock' and info='select f1()';
+--echo # --> connection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'alter procedure p1'...
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'select f1()'
+reap;
+--echo # --> connection default
+connection default;
+
+--echo #
+--echo # Test DROP FUNCTION.
+--echo #
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'drop function f1'...
+send drop function f1;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'drop function f1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='drop function f1';
+--source include/wait_condition.inc
+--echo # Demonstrate that there is a pending exclusive lock.
+--echo # Sending 'select f1()'...
+send select f1();
+--echo # --> connection con3
+connection con3;
+--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and info='select f1()';
+--echo # --> connection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'drop function f1'...
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'select f1()'
+--error ER_SP_DOES_NOT_EXIST
+reap;
+--echo # --> connection default
+connection default;
+
+--echo #
+--echo # Test CREATE FUNCTION.
+--echo #
+create function f1() returns int return 1;
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'create function f1'...
+send create function f1() returns int return 2;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'create function f1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='create function f1() returns int return 2';
+--source include/wait_condition.inc
+--echo # Demonstrate that there is a pending exclusive lock.
+--echo # Sending 'select f1()'...
+send select f1();
+--echo # --> connection con3
+connection con3;
+--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and info='select f1()';
+--echo # --> connection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'create function f1'...
+--error ER_SP_ALREADY_EXISTS
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'select f1()'
+reap;
+--echo # --> connection default
+connection default;
+
+--echo #
+--echo # Test ALTER FUNCTION.
+--echo #
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'alter function f1'...
+send alter function f1 contains sql;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'alter function f1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='alter function f1 contains sql';
+--source include/wait_condition.inc
+--echo # Demonstrate that there is a pending exclusive lock.
+--echo # Sending 'select f1()'...
+send select f1();
+--echo # --> connection con3
+connection con3;
+--echo # Waiting for 'select f1()' to get blocked by a pending MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and info='select f1()';
+--echo # --> connection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'alter function f1'...
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'select f1()'
+reap;
+--echo # --> connection default
+connection default;
+drop function f1;
+drop procedure p1;
+
+--echo #
+--echo # 4) MDL lock should not be taken for
+--echo # unrolled CALL statements.
+--echo # The primary goal of metadata locks is a consistent binary log.
+--echo # When a call statement is unrolled, it doesn't get to the
+--echo # binary log, instead the statements that are contained
+--echo # in the procedure body do. This can nest to any level.
+--echo #
+create procedure p1() begin end;
+create procedure p2() begin end;
+create table t1 (a int);
+delimiter |;
+create procedure p3()
+begin
+ call p1();
+ call p1();
+ call p2();
+end|
+create procedure p4()
+begin
+ call p1();
+ call p1();
+ call p2();
+ call p2();
+ call p3();
+end|
+delimiter ;|
+begin;
+select * from t1;
+savepoint sv;
+call p4();
+--echo # Prepared statement should not add any locks either.
+prepare stmt from "call p4()";
+execute stmt;
+execute stmt;
+--echo # --> connection con1
+connection con1;
+drop procedure p1;
+drop procedure p2;
+drop procedure p3;
+drop procedure p4;
+--echo # --> connection default
+connection default;
+--echo # This is to verify there was no implicit commit.
+rollback to savepoint sv;
+--error ER_SP_DOES_NOT_EXIST
+call p4();
+commit;
+drop table t1;
+
+--echo #
+--echo # 5) Locks should be taken on routines
+--echo # used indirectly by views or triggers.
+--echo #
+--echo #
+--echo # A function is used from a trigger.
+--echo #
+create function f1() returns int return 1;
+create table t1 (a int);
+create table t2 (a int, b int);
+create trigger t1_ai after insert on t1 for each row
+ insert into t2 (a, b) values (new.a, f1());
+begin;
+insert into t1 (a) values (1);
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'drop function f1'
+send drop function f1;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'drop function f1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='drop function f1';
+--source include/wait_condition.inc
+--echo # --> connnection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'drop function f1'...
+reap;
+--echo # --> connection default
+connection default;
+--echo #
+--echo # A function is used from a view.
+--echo #
+create function f1() returns int return 1;
+create view v1 as select f1() as a;
+begin;
+select * from v1;
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'drop function f1'
+send drop function f1;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'drop function f1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='drop function f1';
+--source include/wait_condition.inc
+--echo # --> connnection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'drop function f1'...
+reap;
+--echo # --> connection default
+connection default;
+--echo #
+--echo # A procedure is used from a function.
+--echo #
+delimiter |;
+create function f1() returns int
+begin
+ declare v_out int;
+ call p1(v_out);
+ return v_out;
+end|
+delimiter ;|
+create procedure p1(out v_out int) set v_out=3;
+begin;
+select * from v1;
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'drop procedure p1'
+send drop procedure p1;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'drop procedure p1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored procedure metadata lock' and
+info='drop procedure p1';
+--source include/wait_condition.inc
+--echo # --> connnection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'drop procedure p1'...
+reap;
+--echo # --> connection default
+connection default;
+
+--echo #
+--echo # Deep nesting: a function is used from a procedure used
+--echo # from a function used from a view used in a trigger.
+--echo #
+create function f2() returns int return 4;
+create procedure p1(out v_out int) set v_out=f2();
+drop trigger t1_ai;
+create trigger t1_ai after insert on t1 for each row
+ insert into t2 (a, b) values (new.a, (select max(a) from v1));
+begin;
+insert into t1 (a) values (3);
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'drop function f2'
+send drop function f2;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'drop function f2' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='drop function f2';
+--source include/wait_condition.inc
+--echo # --> connnection default
+connection default;
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'drop function f2'...
+reap;
+--echo # --> connection default
+connection default;
+
+drop view v1;
+drop function f1;
+drop procedure p1;
+drop table t1, t2;
+
+--echo #
+--echo # 6) Check that ER_LOCK_DEADLOCK is reported if
+--echo # acquisition of a shared lock fails during a transaction or
+--echo # we need to back off to flush the sp cache.
+--echo #
+--echo # Sic: now this situation does not require a back off since we
+--echo # flush the cache on the fly.
+--echo #
+create function f1() returns int return 7;
+create table t1 (a int);
+begin;
+select * from t1;
+# Used to have a back-off here, with optional ER_LOCK_DEADLOCK
+#--error ER_LOCK_DEADLOCK
+select f1();
+commit;
+drop table t1;
+drop function f1;
+
+--echo #
+--echo # 7) Demonstrate that under LOCK TABLES we accumulate locks
+--echo # on stored routines, and release metadata locks in
+--echo # ROLLBACK TO SAVEPOINT. That is done only for those stored
+--echo # routines that are not part of LOCK TABLES prelocking list.
+--echo # Those stored routines that are part of LOCK TABLES
+--echo # prelocking list are implicitly locked when entering
+--echo # LOCK TABLES, and ROLLBACK TO SAVEPOINT has no effect on
+--echo # them.
+--echo #
+create function f1() returns varchar(20) return "f1()";
+create function f2() returns varchar(20) return "f2()";
+create view v1 as select f1() as a;
+set @@session.autocommit=0;
+lock table v1 read;
+select * from v1;
+savepoint sv;
+select f2();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'drop function f1'...
+send drop function f1;
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'drop function f1' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='drop function f1';
+--source include/wait_condition.inc
+--echo # Sending 'drop function f2'...
+send drop function f2;
+--echo # --> connection default
+connection default;
+--echo # Waiting for 'drop function f2' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='drop function f2';
+--source include/wait_condition.inc
+rollback to savepoint sv;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'drop function f2'...
+reap;
+--echo # --> connection default
+connection default;
+unlock tables;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'drop function f1'...
+reap;
+--echo # --> connection default
+connection default;
+--error ER_SP_DOES_NOT_EXIST
+drop function f1;
+--error ER_SP_DOES_NOT_EXIST
+drop function f2;
+drop view v1;
+set @@session.autocommit=default;
+
+--echo #
+--echo # 8) Check the situation when we're preparing or executing a
+--echo # prepared statement, and as part of that try to flush the
+--echo # session sp cache. However, one of the procedures that
+--echo # needs a flush is in use. Verify that there is no infinite
+--echo # reprepare loop and no crash.
+--echo #
+create function f1() returns int return 1;
+delimiter |;
+--echo #
+--echo # We just mention p1() in the body of f2() to make
+--echo # sure that p1() metadata is validated when validating
+--echo # 'select f2()'.
+--echo # Recursion is not allowed in stored functions, so
+--echo # an attempt to just invoke p1() from f2() which is in turn
+--echo # called from p1() would have given a run-time error.
+--echo #
+create function f2() returns int
+begin
+ if @var is null then
+ call p1();
+ end if;
+ return 1;
+end|
+create procedure p1()
+begin
+ select f1() into @var;
+ execute stmt;
+end|
+delimiter ;|
+--echo # --> connection con2
+connection con2;
+prepare stmt from "select f2()";
+--echo # --> connection default
+connection default;
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'alter function f1 ...'...
+send alter function f1 comment "comment";
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'alter function f1 ...' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info like 'alter function f1 comment%';
+--source include/wait_condition.inc
+--echo # Sending 'call p1()'...
+send call p1();
+connection default;
+--echo # Waiting for 'call p1()' to get blocked on MDL lock on f1...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='select f1() into @var';
+--source include/wait_condition.inc
+--echo # Let 'alter function f1 ...' go through...
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'alter function f1 ...'
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'call p1()'...
+reap;
+deallocate prepare stmt;
+--echo # --> connection default
+connection default;
+drop function f1;
+drop function f2;
+drop procedure p1;
+
+--echo #
+--echo # 9) Check the situation when a stored function is invoked
+--echo # from a stored procedure, and recursively invokes the
+--echo # stored procedure that is in use. But for the second
+--echo # invocation, a cache flush is requested. We can't
+--echo # flush the procedure that's in use, and are forced
+--echo # to use an old version. It is not a violation of
+--echo # consistency, since we unroll top-level calls.
+--echo # Just verify the code works.
+--echo #
+create function f1() returns int return 1;
+begin;
+select f1();
+--echo # --> connection con1
+connection con1;
+--echo # Sending 'alter function f1 ...'...
+send alter function f1 comment "comment";
+--echo # --> connection con2
+connection con2;
+--echo # Waiting for 'alter function f1 ...' to get blocked on MDL lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info like 'alter function f1 comment%';
+--source include/wait_condition.inc
+delimiter |;
+--echo #
+--echo # We just mention p1() in the body of f2() to make
+--echo # sure that p1() is prelocked for f2().
+--echo # Recursion is not allowed in stored functions, so
+--echo # an attempt to just invoke p1() from f2() which is in turn
+--echo # called from p1() would have given a run-time error.
+--echo #
+create function f2() returns int
+begin
+ if @var is null then
+ call p1();
+ end if;
+ return 1;
+end|
+create procedure p1()
+begin
+ select f1() into @var;
+ select f2() into @var;
+end|
+delimiter ;|
+--echo # Sending 'call p1()'...
+send call p1();
+connection default;
+--echo # Waiting for 'call p1()' to get blocked on MDL lock on f1...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='Waiting for stored function metadata lock' and
+info='select f1() into @var';
+--source include/wait_condition.inc
+--echo # Let 'alter function f1 ...' go through...
+commit;
+--echo # --> connection con1
+connection con1;
+--echo # Reaping 'alter function f1 ...'
+reap;
+--echo # --> connection con2
+connection con2;
+--echo # Reaping 'call p1()'...
+reap;
+--echo # --> connection default
+connection default;
+drop function f1;
+drop function f2;
+drop procedure p1;
+
+--echo #
+--echo # 10) A select from information_schema.routines now
+--echo # flushes the stored routines caches. Test that this
+--echo # does not remove from the cache a stored routine
+--echo # that is already prelocked.
+--echo #
+create function f1() returns int return get_lock("30977", 100000);
+create function f2() returns int return 2;
+delimiter |;
+create function f3() returns varchar(255)
+begin
+ declare res varchar(255);
+ declare c cursor for select routine_name from
+ information_schema.routines where routine_name='f1';
+ select f1() into @var;
+ open c;
+ fetch c into res;
+ close c;
+ select f2() into @var;
+ return res;
+end|
+delimiter ;|
+--echo # --> connection con1
+connection con1;
+select get_lock("30977", 0);
+--echo # --> connection default
+connection default;
+--echo # Sending 'select f3()'...
+send select f3();
+--echo # --> connection con1
+connection con1;
+--echo # Waiting for 'select f3()' to get blocked on the user level lock...
+let $wait_condition=select count(*)=1 from information_schema.processlist
+where state='User lock' and info='select f1() into @var';
+--source include/wait_condition.inc
+--echo # Do something to change the cache version.
+create function f4() returns int return 4;
+drop function f4;
+select release_lock("30977");
+--echo # --> connection default
+connection default;
+--echo # Reaping 'select f3()'...
+--echo # Routine 'f2()' should exist and get executed successfully.
+reap;
+select @var;
+drop function f1;
+drop function f2;
+drop function f3;
+
+
+--echo # 11) Check the situation when the connection is flushing the
+--echo # SP cache which contains a procedure that is being executed.
+--echo #
+--echo # Function f1() calls p1(). Procedure p1() has a DROP
+--echo # VIEW statement, which, we know, invalidates the routines cache.
+--echo # During cache flush p1() must not be flushed since it's in
+--echo # use.
+--echo #
+delimiter |;
+create function f1() returns int
+begin
+ call p1();
+ return 1;
+end|
+create procedure p1()
+begin
+ create view v1 as select 1;
+ drop view v1;
+ select f1() into @var;
+ set @exec_count=@exec_count+1;
+end|
+delimiter ;|
+set @exec_count=0;
+--error ER_SP_RECURSION_LIMIT
+call p1();
+select @exec_count;
+set @@session.max_sp_recursion_depth=5;
+set @exec_count=0;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+call p1();
+select @exec_count;
+drop procedure p1;
+drop function f1;
+set @@session.max_sp_recursion_depth=default;
+
+--echo # --> connection con1
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+--echo # --> connection con2
+connection con2;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+--echo # --> connection con3
+connection con3;
+disconnect con3;
+--source include/wait_until_disconnected.inc
+--echo # --> connection default
+connection default;
+
+
+--echo #
+--echo # SHOW CREATE PROCEDURE p1 called from p1, after p1 was altered
+--echo #
+--echo # We are just covering the existing behaviour with tests. The
+--echo # results are not necessarily correct."
+--echo #
+
+delimiter |;
+CREATE PROCEDURE p1()
+BEGIN
+ SELECT get_lock("test", 10);
+ SHOW CREATE PROCEDURE p1;
+END|
+delimiter ;|
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Connection default
+connection default;
+SELECT get_lock("test", 10);
+
+--echo # Connection 2
+connection con2;
+--echo # Will halt before executing SHOW CREATE PROCEDURE p1
+--echo # Sending:
+--send CALL p1()
+
+--echo # Connection 3
+connection con3;
+let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state='User lock' and info='SELECT get_lock("test", 10)';
+--source include/wait_condition.inc
+--echo # Alter p1
+DROP PROCEDURE p1;
+CREATE PROCEDURE p1() BEGIN END;
+
+--echo # Connection default
+connection default;
+--echo # Resume CALL p1, now with new p1
+SELECT release_lock("test");
+
+--echo # Connection 2
+connection con2;
+--echo # Reaping: CALL p1()
+--reap
+
+--echo # Connection 3
+connection con3;
+disconnect con3;
+--source include/wait_until_disconnected.inc
+--echo # Connection 2
+connection con2;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+--echo # Connection default;
+connection default;
+DROP PROCEDURE p1;
+
+
+--echo #
+--echo # Bug#57663 Concurrent statement using stored function and DROP DATABASE
+--echo # breaks SBR
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+connect(con1, localhost, root);
+connect(con2, localhost, root);
+
+--echo # Test 1: Check that DROP DATABASE block if a function is used
+--echo # by an active transaction.
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE FUNCTION db1.f1() RETURNS INTEGER RETURN 1;
+START TRANSACTION;
+SELECT db1.f1();
+
+--echo # Connection con1
+connection con1;
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection default
+connection default;
+--echo # Waiting for DROP DATABASE to be blocked by the lock on f1()
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for stored function metadata lock'
+ AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+COMMIT;
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Test 2: Check that DROP DATABASE blocks if a procedure is
+--echo # used by an active transaction.
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE PROCEDURE db1.p1() BEGIN END;
+delimiter |;
+CREATE FUNCTION f1() RETURNS INTEGER
+BEGIN
+ CALL db1.p1();
+ RETURN 1;
+END|
+delimiter ;|
+START TRANSACTION;
+SELECT f1();
+
+--echo # Connection con1
+connection con1;
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection default
+connection default;
+--echo # Waiting for DROP DATABASE to be blocked by the lock on p1()
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for stored procedure metadata lock'
+ AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+COMMIT;
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Test 3: Check that DROP DATABASE is not selected as a victim if a
+--echo # deadlock is discovered with DML statements.
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+CREATE FUNCTION db1.f1() RETURNS INTEGER RETURN 1;
+START TRANSACTION;
+# DROP DATABASE will lock tables (t1) before functions (f1)
+SELECT db1.f1();
+
+--echo # Connection con1
+connection con1;
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection default
+connection default;
+--echo # Waiting for DROP DATABASE to be blocked by the lock on f1()
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for stored function metadata lock'
+ AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+--error ER_LOCK_DEADLOCK
+SELECT * FROM db1.t1;
+COMMIT;
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: DROP DATABASE db1
+--reap
+
+--echo # Test 4: Check that active DROP DATABASE blocks stored routine DDL.
+
+--echo # Connection default
+connection default;
+CREATE DATABASE db1;
+CREATE FUNCTION db1.f1() RETURNS INTEGER RETURN 1;
+CREATE FUNCTION db1.f2() RETURNS INTEGER RETURN 2;
+START TRANSACTION;
+SELECT db1.f2();
+
+--echo # Connection con1
+connection con1;
+--echo # Sending:
+--send DROP DATABASE db1
+
+--echo # Connection con2
+connection con2;
+--echo # Waiting for DROP DATABASE to be blocked by the lock on f2()
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for stored function metadata lock'
+ AND info='DROP DATABASE db1';
+--source include/wait_condition.inc
+--echo # Sending:
+--send ALTER FUNCTION db1.f1 COMMENT "test"
+
+--echo # Connection default
+connection default;
+--echo # Waiting for ALTER FUNCTION to be blocked by the schema lock on db1
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for schema metadata lock'
+ AND info='ALTER FUNCTION db1.f1 COMMENT "test"';
+--source include/wait_condition.inc
+COMMIT;
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: DROP DATABASE db1
+--reap
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: ALTER FUNCTION f1 COMMENT 'test'
+--error ER_SP_DOES_NOT_EXIST
+--reap
+disconnect con2;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection default
+connection default;
+DROP FUNCTION f1;
+
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/sp-no-code.test b/mysql-test/t/sp-no-code.test
new file mode 100644
index 00000000000..ce16c32a270
--- /dev/null
+++ b/mysql-test/t/sp-no-code.test
@@ -0,0 +1,12 @@
+#
+# Test the debugging feature "show procedure/function code <name>"
+#
+
+-- source include/have_nodebug.inc
+
+--error ER_FEATURE_DISABLED
+show procedure code foo;
+
+--error ER_FEATURE_DISABLED
+show function code foo;
+
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index 96f82c92248..d7ea829bf50 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -82,7 +82,7 @@ select * from db1_secret.t1;
# ...and not this
--error ER_DBACCESS_DENIED_ERROR
create procedure db1_secret.dummy() begin end;
---error ER_SP_DOES_NOT_EXIST
+--error ER_PROCACCESS_DENIED_ERROR
drop procedure db1_secret.dummy;
--error ER_PROCACCESS_DENIED_ERROR
drop procedure db1_secret.stamp;
@@ -106,7 +106,7 @@ select * from db1_secret.t1;
# ...and not this
--error ER_DBACCESS_DENIED_ERROR
create procedure db1_secret.dummy() begin end;
---error ER_SP_DOES_NOT_EXIST
+--error ER_PROCACCESS_DENIED_ERROR
drop procedure db1_secret.dummy;
--error ER_PROCACCESS_DENIED_ERROR
drop procedure db1_secret.stamp;
@@ -926,6 +926,39 @@ DROP DATABASE B48872;
--echo End of 5.0 tests.
+
+--echo #
+--echo # Test for bug#57061 "User without privilege on routine can discover
+--echo # its existence."
+--echo #
+--disable_warnings
+drop database if exists mysqltest_db;
+--enable_warnings
+create database mysqltest_db;
+--echo # Create user with no privileges on mysqltest_db database.
+create user bug57061_user@localhost;
+create function mysqltest_db.f1() returns int return 0;
+create procedure mysqltest_db.p1() begin end;
+--echo # Connect as user 'bug57061_user@localhost'
+connect (conn1, localhost, bug57061_user,,);
+--echo # Attempt to drop routine on which user doesn't have privileges
+--echo # should result in the same 'access denied' type of error whether
+--echo # routine exists or not.
+--error ER_PROCACCESS_DENIED_ERROR
+drop function if exists mysqltest_db.f_does_not_exist;
+--error ER_PROCACCESS_DENIED_ERROR
+drop procedure if exists mysqltest_db.p_does_not_exist;
+--error ER_PROCACCESS_DENIED_ERROR
+drop function if exists mysqltest_db.f1;
+--error ER_PROCACCESS_DENIED_ERROR
+drop procedure if exists mysqltest_db.p1;
+--echo # Connection 'default'.
+connection default;
+disconnect conn1;
+drop user bug57061_user@localhost;
+drop database mysqltest_db;
+
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/sp-ucs2.test b/mysql-test/t/sp-ucs2.test
index 7d6b62dfea0..f6f70c3c103 100644
--- a/mysql-test/t/sp-ucs2.test
+++ b/mysql-test/t/sp-ucs2.test
@@ -25,6 +25,126 @@ drop function bug17615|
drop table t3|
+#
+# Testing COLLATE clause in
+# - IN parameter
+# - RETURNS
+# - DELCARE
+#
+
+CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_unicode_ci)
+ RETURNS VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_danish_ci
+BEGIN
+ DECLARE f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_swedish_ci;
+ DECLARE f3 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_bin;
+ SET f1= concat(collation(f1), ' ', collation(f2), ' ', collation(f3));
+ RETURN f1;
+END|
+SELECT f('a')|
+SELECT collation(f('a'))|
+DROP FUNCTION f|
+
+#
+# Testing keywords UNICODE + BINARY
+#
+CREATE FUNCTION f()
+ RETURNS VARCHAR(64) UNICODE BINARY
+BEGIN
+ RETURN '';
+END|
+SHOW CREATE FUNCTION f;
+DROP FUNCTION f;
+
+CREATE FUNCTION f()
+ RETURNS VARCHAR(64) BINARY UNICODE
+BEGIN
+ RETURN '';
+END|
+SHOW CREATE FUNCTION f;
+DROP FUNCTION f;
+
+
+#
+# Testing keywords ASCII + BINARY
+#
+CREATE FUNCTION f()
+ RETURNS VARCHAR(64) ASCII BINARY
+BEGIN
+ RETURN '';
+END|
+SHOW CREATE FUNCTION f;
+DROP FUNCTION f;
+
+CREATE FUNCTION f()
+ RETURNS VARCHAR(64) BINARY ASCII
+BEGIN
+ RETURN '';
+END|
+SHOW CREATE FUNCTION f;
+DROP FUNCTION f;
+
+#
+# Testing COLLATE in OUT parameter
+#
+
+CREATE PROCEDURE p1(IN f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_czech_ci,
+ OUT f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_polish_ci)
+BEGIN
+ SET f2= f1;
+ SET f2= concat(collation(f1), ' ', collation(f2));
+END|
+
+
+CREATE FUNCTION f1()
+ RETURNS VARCHAR(64) CHARACTER SET ucs2
+BEGIN
+ DECLARE f1 VARCHAR(64) CHARACTER SET ucs2;
+ DECLARE f2 VARCHAR(64) CHARACTER SET ucs2;
+ SET f1='str';
+ CALL p1(f1, f2);
+ RETURN f2;
+END|
+
+
+SELECT f1()|
+DROP PROCEDURE p1|
+DROP FUNCTION f1|
+
+
+#
+# COLLATE with no CHARACTER SET in IN param
+#
+--error ER_NOT_SUPPORTED_YET
+CREATE FUNCTION f(f1 VARCHAR(64) COLLATE ucs2_unicode_ci)
+ RETURNS VARCHAR(64) CHARACTER SET ucs2
+BEGIN
+ RETURN 'str';
+END|
+
+
+#
+# COLLATE with no CHARACTER SET in RETURNS
+#
+--error ER_NOT_SUPPORTED_YET
+CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2)
+ RETURNS VARCHAR(64) COLLATE ucs2_unicode_ci
+BEGIN
+ RETURN 'str';
+END|
+
+
+#
+# COLLATE with no CHARACTER SET in DECLARE
+#
+--error ER_NOT_SUPPORTED_YET
+CREATE FUNCTION f(f1 VARCHAR(64) CHARACTER SET ucs2)
+ RETURNS VARCHAR(64) CHARACTER SET ucs2
+BEGIN
+ DECLARE f2 VARCHAR(64) COLLATE ucs2_unicode_ci;
+ RETURN 'str';
+END|
+
+
delimiter ;|
#
diff --git a/mysql-test/t/sp-vars.test b/mysql-test/t/sp-vars.test
index fe063889f81..2e7257cbcea 100644
--- a/mysql-test/t/sp-vars.test
+++ b/mysql-test/t/sp-vars.test
@@ -1448,3 +1448,42 @@ drop function f1;
drop table t1;
# End of 5.1 tests.
+
+###########################################################################
+#
+# Test case for BUG#28299: To-number conversion warnings work
+# differenly with CHAR and VARCHAR sp variables
+#
+###########################################################################
+
+--echo
+--echo ---------------------------------------------------------------
+--echo BUG#28299
+--echo ---------------------------------------------------------------
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE ctest()
+BEGIN
+ DECLARE i CHAR(16);
+ DECLARE j INT;
+ SET i= 'string';
+ SET j= 1 + i;
+END|
+DELIMITER ;|
+
+CALL ctest();
+DROP PROCEDURE ctest;
+
+DELIMITER |;
+CREATE PROCEDURE vctest()
+BEGIN
+ DECLARE i VARCHAR(16);
+ DECLARE j INT;
+ SET i= 'string';
+ SET j= 1 + i;
+END|
+DELIMITER ;|
+
+CALL vctest();
+DROP PROCEDURE vctest;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 5cf050146dd..b052b181d70 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1308,9 +1308,11 @@ select f3()|
select id, f3() from t1 as t11 order by id|
# Degenerate cases work too :)
select f0()|
+# But these should not (particularly views should be locked explicitly).
+--error ER_TABLE_NOT_LOCKED
select * from v0|
+--error ER_TABLE_NOT_LOCKED
select *, f0() from v0, (select 123) as d1|
-# But these should not !
--error ER_TABLE_NOT_LOCKED
select id, f3() from t1|
--error ER_TABLE_NOT_LOCKED
@@ -2882,7 +2884,6 @@ create procedure bug4902()
begin
show charset like 'foo';
show collation like 'foo';
- show column types;
show create table t1;
show create database test;
show databases like 'foo';
@@ -3749,7 +3750,7 @@ begin
end|
set @qcs1 = @@query_cache_size|
-set global query_cache_size = 100000|
+set global query_cache_size = 102400|
set @x = 1|
insert into t1 values ("qc", 42)|
select bug9902() from t1|
@@ -4062,34 +4063,41 @@ drop procedure bug11529|
# BUG#6063: Stored procedure labels are subject to restrictions (partial)
# BUG#7088: Stored procedures: labels won't work if character set is utf8
#
+
+set character set utf8|
+
--disable_warnings
drop procedure if exists bug6063|
drop procedure if exists bug7088_1|
drop procedure if exists bug7088_2|
--enable_warnings
---disable_parsing # temporarily disabled until Bar fixes BUG#11986
create procedure bug6063()
- lâbel: begin end|
-call bug6063()|
-# QQ Known bug: this will not show the label correctly.
-show create procedure bug6063|
+begin
+ lâbel: begin end;
+ label: begin end;
+ label1: begin end;
+end|
-set character set utf8|
create procedure bug7088_1()
label1: begin end label1|
+
create procedure bug7088_2()
läbel1: begin end|
+
+call bug6063()|
call bug7088_1()|
call bug7088_2()|
+
set character set default|
+
+show create procedure bug6063|
show create procedure bug7088_1|
show create procedure bug7088_2|
drop procedure bug6063|
drop procedure bug7088_1|
drop procedure bug7088_2|
---enable_parsing
#
# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure
@@ -5208,20 +5216,15 @@ drop procedure bug5967|
--disable_warnings
drop procedure if exists bug13012|
+--enable_warnings
# Disable warnings also for BACKUP/RESTORE: they are deprecated.
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
eval create procedure bug13012()
BEGIN
REPAIR TABLE t1;
- BACKUP TABLE t1 to '$backupdir';
- DROP TABLE t1;
- RESTORE TABLE t1 FROM '$backupdir';
END|
call bug13012()|
--enable_warnings
---remove_file $backupdir/t1.frm
---remove_file $backupdir/t1.MYD
drop procedure bug13012|
@@ -5429,6 +5432,8 @@ drop procedure if exists bug15231_1|
drop procedure if exists bug15231_2|
drop procedure if exists bug15231_3|
drop procedure if exists bug15231_4|
+drop procedure if exists bug15231_5|
+drop procedure if exists bug15231_6|
--enable_warnings
create table t3 (id int not null)|
@@ -5458,7 +5463,7 @@ end|
create procedure bug15231_3()
begin
declare exit handler for sqlwarning
- select 'Caught it (wrong)' as 'Result';
+ select 'Caught it (correct)' as 'Result';
call bug15231_4();
end|
@@ -5469,16 +5474,37 @@ begin
set x = 'zap';
select 'Missed it (correct)' as 'Result';
+ show warnings;
+end|
+
+create procedure bug15231_5()
+begin
+ declare exit handler for sqlwarning
+ select 'Caught it (wrong)' as 'Result';
+
+ call bug15231_6();
+end|
+
+create procedure bug15231_6()
+begin
+ declare x decimal(2,1);
+
+ set x = 'zap';
+ select 'Missed it (correct)' as 'Result';
+ select id from t3;
end|
call bug15231_1()|
call bug15231_3()|
+call bug15231_5()|
-drop table if exists t3|
-drop procedure if exists bug15231_1|
-drop procedure if exists bug15231_2|
-drop procedure if exists bug15231_3|
-drop procedure if exists bug15231_4|
+drop table t3|
+drop procedure bug15231_1|
+drop procedure bug15231_2|
+drop procedure bug15231_3|
+drop procedure bug15231_4|
+drop procedure bug15231_5|
+drop procedure bug15231_6|
#
@@ -7073,11 +7099,14 @@ select bug20777(9223372036854775807) as '9223372036854775807 2**63-1';
select bug20777(9223372036854775808) as '9223372036854775808 2**63+0';
select bug20777(9223372036854775809) as '9223372036854775809 2**63+1';
select bug20777(9223372036854775810) as '9223372036854775810 2**63+2';
+--error ER_DATA_OUT_OF_RANGE
select bug20777(-9223372036854775808) as 'lower bounds signed bigint';
select bug20777(9223372036854775807) as 'upper bounds signed bigint';
+--error ER_DATA_OUT_OF_RANGE
select bug20777(0) as 'lower bounds unsigned bigint';
select bug20777(18446744073709551615) as 'upper bounds unsigned bigint';
select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1';
+--error ER_DATA_OUT_OF_RANGE
select bug20777(-1) as 'lower bounds unsigned bigint - 1';
create table examplebug20777 as select
@@ -7088,10 +7117,8 @@ create table examplebug20777 as select
bug20777(9223372036854775809) as '2**63+1',
bug20777(18446744073709551614) as '2**64-2',
bug20777(18446744073709551615) as '2**64-1',
- bug20777(18446744073709551616) as '2**64',
- bug20777(0) as '0',
- bug20777(-1) as '-1';
-insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1);
+ bug20777(18446744073709551616) as '2**64';
+insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616);
show create table examplebug20777;
select * from examplebug20777 order by i;
@@ -8203,14 +8230,13 @@ DROP FUNCTION f1;
drop procedure if exists p;
--enable_warnings
set @old_mode= @@sql_mode;
-set @@sql_mode= pow(2,32)-1;
+set @@sql_mode= cast(pow(2,32)-1 as unsigned integer);
select @@sql_mode into @full_mode;
create procedure p() begin end;
call p();
-select @@sql_mode;
set @@sql_mode= @old_mode;
# Rename SQL modes that differ in name between the server and the table definition.
-select replace(@full_mode, '?', 'NOT_USED') into @full_mode;
+select replace(@full_mode, ',,,', ',NOT_USED,') into @full_mode;
select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode;
select name from mysql.proc where name = 'p' and sql_mode = @full_mode;
drop procedure p;
@@ -8353,3 +8379,403 @@ DROP PROCEDURE p5;
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
+
+#
+# Bug#39255: Stored procedures: crash if function references nonexistent table
+#
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP TABLE IF EXISTS t_non_existing;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ DECLARE v INT;
+ SELECT a INTO v FROM t_non_existing;
+ RETURN 1;
+END|
+delimiter ;|
+
+CREATE TABLE t1 (a INT) ENGINE = myisam;
+INSERT INTO t1 VALUES (1);
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t1 WHERE a = f1();
+
+DROP FUNCTION f1;
+DROP TABLE t1;
+
+#
+# Bug#36649: Condition area is not properly cleaned up after stored routine invocation
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+delimiter |;
+CREATE PROCEDURE p1(a INT, b CHAR)
+BEGIN
+ IF a > 0 THEN
+ CALL p1(a-1, 'ab');
+ ELSE
+ SELECT 1;
+ END IF;
+END|
+delimiter ;|
+
+SET @save_max_sp_recursion= @@max_sp_recursion_depth;
+SET @@max_sp_recursion_depth= 5;
+CALL p1(4, 'a');
+SET @@max_sp_recursion_depth= @save_max_sp_recursion;
+
+DROP PROCEDURE p1;
+
+#
+# Ensure that rules for message list clean up are being respected.
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+delimiter |;
+CREATE PROCEDURE p1(a CHAR)
+BEGIN
+ SELECT 1;
+ SELECT CAST('10 ' as UNSIGNED INTEGER);
+ SELECT 1;
+END|
+delimiter ;|
+
+CALL p1('data truncated parameter');
+
+DROP PROCEDURE p1;
+
+#
+# Cascading stored procedure/function calls.
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+--enable_warnings
+
+delimiter |;
+CREATE PROCEDURE p1()
+ CALL p2()|
+CREATE PROCEDURE p2()
+ CALL p3()|
+CREATE PROCEDURE p3()
+ CALL p4()|
+CREATE PROCEDURE p4()
+BEGIN
+ SELECT 1;
+ SELECT CAST('10 ' as UNSIGNED INTEGER);
+ SELECT 2;
+END|
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP FUNCTION IF EXISTS f3;
+DROP FUNCTION IF EXISTS f4;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a CHAR(2));
+
+INSERT INTO t1 VALUES ('aa');
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS CHAR
+ RETURN (SELECT f2())|
+CREATE FUNCTION f2() RETURNS CHAR
+ RETURN (SELECT f3())|
+CREATE FUNCTION f3() RETURNS CHAR
+ RETURN (SELECT f4())|
+CREATE FUNCTION f4() RETURNS CHAR
+BEGIN
+ RETURN (SELECT a FROM t1);
+END|
+delimiter ;|
+
+SELECT f1();
+
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP FUNCTION f3;
+DROP FUNCTION f4;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#34197: CREATE PROCEDURE fails when COMMENT truncated in non
+--echo # strict SQL mode
+--echo #
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE PROCEDURE p1 ()
+COMMENT
+'12345678901234567890123456789012345678901234567890123456789012345678901234567890'
+BEGIN
+END;
+
+SELECT comment FROM mysql.proc WHERE name = "p1";
+
+SELECT routine_comment FROM information_schema.routines WHERE routine_name = "p1";
+
+DROP PROCEDURE p1;
+
+
+--echo #
+--echo # Bug #47313 assert in check_key_in_view during CALL procedure
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS t1, t2_unrelated;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x);
+CREATE VIEW t1 AS SELECT 10 AS f1;
+
+--echo # t1 refers to the view
+--error ER_NON_INSERTABLE_TABLE
+CALL p1(1);
+
+CREATE TEMPORARY TABLE t1 (f1 INT);
+
+--echo # t1 still refers to the view since it was inlined
+--error ER_NON_INSERTABLE_TABLE
+CALL p1(2);
+
+DROP VIEW t1;
+
+--echo # t1 now refers to the temporary table
+CALL p1(3);
+
+--echo # Check which values were inserted into the temp table.
+SELECT * FROM t1;
+
+DROP TEMPORARY TABLE t1;
+DROP PROCEDURE p1;
+
+--echo # Now test what happens if the sp cache is invalidated.
+
+CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x);
+CREATE VIEW t1 AS SELECT 10 AS f1;
+CREATE VIEW v2_unrelated AS SELECT 1 AS r1;
+
+--echo # Load the procedure into the sp cache
+--error ER_NON_INSERTABLE_TABLE
+CALL p1(4);
+
+CREATE TEMPORARY TABLE t1 (f1 int);
+
+ALTER VIEW v2_unrelated AS SELECT 2 AS r1;
+
+--echo # Alter view causes the sp cache to be invalidated.
+--echo # Now t1 refers to the temporary table, not the view.
+CALL p1(5);
+
+--echo # Check which values were inserted into the temp table.
+SELECT * FROM t1;
+
+DROP TEMPORARY TABLE t1;
+DROP VIEW t1, v2_unrelated;
+DROP PROCEDURE p1;
+
+CREATE PROCEDURE p1(IN x INT) INSERT INTO t1 VALUES (x);
+CREATE TEMPORARY TABLE t1 (f1 INT);
+
+--echo # t1 refers to the temporary table
+CALL p1(6);
+
+CREATE VIEW t1 AS SELECT 10 AS f1;
+
+--echo # Create view causes the sp cache to be invalidated.
+--echo # t1 still refers to the temporary table since it shadows the view.
+CALL p1(7);
+
+DROP VIEW t1;
+
+--echo # Check which values were inserted into the temp table.
+SELECT * FROM t1;
+
+DROP TEMPORARY TABLE t1;
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug #11918 Can't use a declared variable in LIMIT clause
+--echo #
+--disable_warnings
+drop table if exists t1;
+drop procedure if exists p1;
+--enable_warnings
+create table t1 (c1 int);
+insert into t1 (c1) values (1), (2), (3), (4), (5);
+
+delimiter |;
+create procedure p1()
+begin
+ declare a integer;
+ declare b integer;
+ select * from t1 limit a, b;
+end|
+delimiter ;|
+--echo # How do we handle NULL limit values?
+call p1();
+drop table t1;
+create table t1 (a int);
+insert into t1 (a) values (1), (2), (3), (4), (5);
+--echo #
+--echo # Do we correctly resolve identifiers in LIMIT?
+--echo # Since DROP and CREATE did not invalidate
+--echo # the SP cache, we can't test until
+--echo # we drop and re-create the procedure.
+--echo #
+--error ER_BAD_FIELD_ERROR
+call p1();
+--echo #
+--echo # Drop and recreate the procedure, then repeat
+--echo #
+drop procedure p1;
+delimiter |;
+create procedure p1()
+begin
+ declare a integer;
+ declare b integer;
+ select * from t1 limit a, b;
+end|
+delimiter ;|
+--echo # Stored procedure variables are resolved correctly in the LIMIT
+call p1();
+drop table t1;
+create table t1 (c1 int);
+insert into t1 (c1) values (1), (2), (3), (4), (5);
+drop procedure p1;
+--echo # Try to create a procedure that
+--echo # refers to non-existing variables.
+--error ER_SP_UNDECLARED_VAR
+create procedure p1(p1 integer, p2 integer)
+ select * from t1 limit a, b;
+--echo #
+--echo # Try to use data types not allowed in LIMIT
+--echo #
+--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
+create procedure p1(p1 date, p2 date) select * from t1 limit p1, p2;
+--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
+create procedure p1(p1 integer, p2 float) select * from t1 limit p1, p2;
+--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
+create procedure p1(p1 integer, p2 char(1)) select * from t1 limit p1, p2;
+--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
+create procedure p1(p1 varchar(5), p2 char(1)) select * from t1 limit p1, p2;
+--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
+create procedure p1(p1 decimal, p2 decimal) select * from t1 limit p1, p2;
+--error ER_WRONG_SPVAR_TYPE_IN_LIMIT
+create procedure p1(p1 double, p2 double) select * from t1 limit p1, p2;
+
+--echo #
+--echo # Finally, test the valid case.
+--echo #
+create procedure p1(p1 integer, p2 integer)
+ select * from t1 limit p1, p2;
+
+call p1(NULL, NULL);
+call p1(0, 0);
+call p1(0, -1);
+call p1(-1, 0);
+call p1(-1, -1);
+call p1(0, 1);
+call p1(1, 0);
+call p1(1, 5);
+call p1(3, 2);
+
+
+--echo # Cleanup
+drop table t1;
+drop procedure p1;
+
+
+--echo #
+--echo # BUG#11766234: 59299: ASSERT (TABLE_REF->TABLE || TABLE_REF->VIEW)
+--echo # FAILS IN SET_FIELD_ITERATOR
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+CREATE VIEW v1 AS SELECT a FROM t2;
+CREATE PROCEDURE proc() SELECT * FROM t1 NATURAL JOIN v1;
+ALTER TABLE t2 CHANGE COLUMN a b CHAR;
+
+--echo
+--error ER_VIEW_INVALID
+CALL proc();
+--error ER_VIEW_INVALID
+CALL proc();
+
+--echo
+DROP TABLE t1,t2;
+DROP VIEW v1;
+DROP PROCEDURE proc;
+
+
+--echo
+--echo # --
+--echo # -- Bug 11765684 - 58674: SP-cache does not detect changes in
+--echo # -- pre-locking list caused by triggers
+--echo # ---
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a INT);
+CREATE TABLE t3(a INT);
+
+CREATE PROCEDURE p1()
+ INSERT INTO t1(a) VALUES (1);
+
+--echo
+CREATE TRIGGER t1_ai AFTER INSERT ON t1
+ FOR EACH ROW
+ INSERT INTO t2(a) VALUES (new.a);
+
+--echo
+CALL p1();
+
+--echo
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1
+ FOR EACH ROW
+ INSERT INTO t3(a) VALUES (new.a);
+
+--echo
+CALL p1();
+
+--echo
+DROP TABLE t1, t2, t3;
+DROP PROCEDURE p1;
+--echo
+
+--echo # End of 5.5 test
diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test
index 326cc22f1cd..e86e4ef32be 100644
--- a/mysql-test/t/sp_notembedded.test
+++ b/mysql-test/t/sp_notembedded.test
@@ -322,7 +322,7 @@ set session low_priority_updates=on;
connection rl_wait;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Locked" and
+ where state = "Waiting for table level lock" and
info = "update t1 set value='updated' where value='old'";
--source include/wait_condition.inc
@@ -371,16 +371,6 @@ DELETE FROM mysql.user WHERE User='mysqltest_1';
FLUSH PRIVILEGES;
-#
-# Restore global concurrent_insert value. Keep in the end of the test file.
-#
-
-set @@global.concurrent_insert= @old_concurrent_insert;
-
-# Wait till all disconnects are completed
---source include/wait_until_count_sessions.inc
-
-
--echo #
--echo # Bug#44521 Prepared Statement: CALL p() - crashes: `! thd->main_da.is_sent' failed et.al.
--echo #
@@ -449,7 +439,47 @@ DROP FUNCTION f1;
--disconnect con1
--disconnect con2
-
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
+
+--echo #
+--echo # Test for bug#11763757 "56510: ERROR 42000: FUNCTION DOES NOT EXIST
+--echo # IF NOT-PRIV USER RECONNECTS ".
+--echo #
+--echo # The real problem was that server was unable handle properly stored
+--echo # functions in databases which names contained dot.
+--echo #
+
+connection default;
+
+--disable_warnings
+DROP DATABASE IF EXISTS `my.db`;
+--enable_warnings
+
+create database `my.db`;
+use `my.db`;
+
+CREATE FUNCTION f1(a int) RETURNS INT RETURN a;
+
+--echo # Create new connection.
+connect (addcon, localhost, root,,);
+connection addcon;
+USE `my.db`;
+SELECT f1(1);
+SELECT `my.db`.f1(2);
+
+--echo # Switching to default connection.
+connection default;
+disconnect addcon;
+DROP DATABASE `my.db`;
+
+#
+# Restore global concurrent_insert value. Keep in the end of the test file.
+#
+
+set @@global.concurrent_insert= @old_concurrent_insert;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/sp_sync.test b/mysql-test/t/sp_sync.test
index f9dae17b039..368a09eac8c 100644
--- a/mysql-test/t/sp_sync.test
+++ b/mysql-test/t/sp_sync.test
@@ -5,54 +5,153 @@
--source include/have_debug_sync.inc
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+# Clean up resources used in this test case.
+--disable_warnings
+SET DEBUG_SYNC= 'RESET';
+--enable_warnings
+
--echo #
---echo # Bug#48157: crash in Item_field::used_tables
+--echo # Bug #30977 Concurrent statement using stored function and
+--echo # DROP FUNCTION breaks SBR
+--echo #
+--echo # A stored routine could change after dispatch_command()
+--echo # but before a MDL lock is taken. This must be noticed and the
+--echo # sp cache flushed so the correct version can be loaded.
--echo #
-CREATE TABLE t1 AS SELECT 1 AS a, 1 AS b;
-CREATE TABLE t2 AS SELECT 1 AS a, 1 AS b;
+connect (con2, localhost, root);
-DELIMITER |;
+--echo # Connection default
+connection default;
+CREATE FUNCTION f1() RETURNS INT RETURN 1;
+--echo # Get f1 cached
+SELECT f1();
+--echo # Then start executing it again...
+SET DEBUG_SYNC= 'before_execute_sql_command SIGNAL before WAIT_FOR changed';
+--echo # Sending:
+--send SELECT f1()
+
+--echo # Connection 2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR before';
+--echo # ... but before f1 is locked, change it.
+DROP FUNCTION f1;
+CREATE FUNCTION f1() RETURNS INT RETURN 2;
+SET DEBUG_SYNC= 'now SIGNAL changed';
+
+--echo # Connection default
+--echo # We should now get '2' and not '1'.
+connection default;
+--echo # Reaping: SELECT f1()
+--reap
-CREATE PROCEDURE p1()
-BEGIN
- UPDATE t1 JOIN t2 USING( a, b ) SET t1.b = 1, t2.b = 1;
-END|
+disconnect con2;
+DROP FUNCTION f1;
+SET DEBUG_SYNC= 'RESET';
-DELIMITER ;|
+--echo #
+--echo # Field translation items must be cleared in case of back-offs
+--echo # for queries that use Information Schema tables. Otherwise
+--echo # memory allocated in fix_fields() for views may end up referring
+--echo # to freed memory.
+--echo #
-connect (con1,localhost,root,,);
-connect (con2,localhost,root,,);
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
-connection con1;
-LOCK TABLES t1 WRITE, t2 WRITE;
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Connection default
+connection default;
+CREATE FUNCTION f1() RETURNS INT RETURN 0;
+--echo # Connection con2
connection con2;
-LET $ID= `select connection_id()`;
-SET DEBUG_SYNC = 'multi_update_reopen_tables SIGNAL parked WAIT_FOR go';
---send CALL p1()
+SET DEBUG_SYNC= 'after_wait_locked_pname SIGNAL locked WAIT_FOR issued';
+--echo # con2 will now have an x-lock on f1
+--echo # Sending:
+--send ALTER FUNCTION f1 COMMENT 'comment'
-connection con1;
-let $wait_condition= SELECT 1 FROM information_schema.processlist WHERE ID = $ID AND
-state = "Locked";
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR locked';
+--disable_result_log
+--echo # This query will block due to the x-lock on f1 and back-off
+--send SHOW OPEN TABLES WHERE f1()=0
+
+--echo # Connection con3
+connection con3;
+let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
+ WHERE state= 'Waiting for stored function metadata lock'
+ AND info='SHOW OPEN TABLES WHERE f1()=0';
--source include/wait_condition.inc
-DROP TABLE t1, t2;
-SET DEBUG_SYNC = 'now WAIT_FOR parked';
-CREATE TABLE t1 AS SELECT 1 AS a, 1 AS b;
-CREATE TABLE t2 AS SELECT 1 AS a, 1 AS b;
-SET DEBUG_SYNC = 'now SIGNAL go';
+--echo # Check that the IS query is blocked before releasing the x-lock
+SET DEBUG_SYNC= 'now SIGNAL issued';
-connection con2;
+--echo # Connection default
+connection default;
+--echo # Reaping: ALTER FUNCTION f1 COMMENT 'comment'
--reap
-
-disconnect con1;
+--enable_result_log
+DROP FUNCTION f1;
+SET DEBUG_SYNC= 'RESET';
disconnect con2;
+disconnect con3;
+
+
+--echo #
+--echo # Bug #48246 assert in close_thread_table
+--echo #
+
+CREATE TABLE t0 (b INTEGER);
+CREATE TABLE t1 (a INTEGER);
+CREATE FUNCTION f1(b INTEGER) RETURNS INTEGER RETURN 1;
+CREATE PROCEDURE p1() SELECT COUNT(f1(a)) FROM t1, t0;
+
+INSERT INTO t0 VALUES(1);
+INSERT INTO t1 VALUES(1), (2);
+
+--echo # Connection 2
+connect (con2, localhost, root);
+CALL p1();
+
+SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked_t1 WAIT_FOR go_for_t0';
+--echo # This call used to cause an assertion. MDL deadlock with upcoming
+--echo # LOCK TABLES statement will cause back-off and retry.
+--echo # A variable indicating if a prelocking list exists, used to be not
+--echo # reset properly causing an eventual assert.
+--echo # Sending:
+--send CALL p1()
+
+--echo # Connection default
connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR locked_t1';
+--echo # Issue LOCK TABLES statement which will enter in MDL deadlock
+--echo # with CALL statement and as result will cause it to perform
+--echo # back-off and retry.
+SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL go_for_t0';
+LOCK TABLES t0 WRITE, t1 WRITE;
+UNLOCK TABLES;
+
+--echo # Connection 2
+connection con2;
+--echo # Reaping: CALL p1()
+--reap;
---echo # Without the DEBUG_SYNC supplied in the same patch as this test in the
---echo # code, this test statement will hang.
-DROP TABLE t1, t2;
+--echo # Connection default
+connection default;
+disconnect con2;
DROP PROCEDURE p1;
+DROP FUNCTION f1;
+DROP TABLES t0, t1;
+SET DEBUG_SYNC= 'RESET';
-SET DEBUG_SYNC = 'RESET';
+# 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
diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test
index 0b04b9d7668..c114d397e43 100644
--- a/mysql-test/t/sp_trans.test
+++ b/mysql-test/t/sp_trans.test
@@ -5,6 +5,10 @@
-- source include/have_log_bin.inc
-- source include/have_innodb.inc
+disable_query_log;
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+enable_query_log;
+
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings
@@ -527,7 +531,9 @@ begin
select count(*)*255 from t3 into table_size;
until table_size > max_table_size*2 end repeat;
end|
+--disable_warnings
call bug14210_fill_table()|
+--enable_warnings
drop procedure bug14210_fill_table|
create table t4 like t3|
@@ -565,7 +571,7 @@ use db_bug7787|
# Test.
CREATE PROCEDURE p1()
- SHOW INNODB STATUS; |
+ SHOW ENGINE INNODB STATUS; |
GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost|
@@ -592,6 +598,68 @@ select distinct f1, bug13575(f1) from t3 order by f1|
drop function bug13575|
drop table t3|
+--echo #
+--echo # End of 5.1 tests
+--echo #
+
+--echo #
+--echo # Bug #35877 Update .. WHERE with function, constraint violation, crash
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1_aux|
+DROP TABLE IF EXISTS t1_not_null|
+DROP FUNCTION IF EXISTS f1_two_inserts|
+--enable_warnings
+
+-- echo # MyISAM test
+CREATE TABLE t1_not_null (f1 BIGINT, f2 BIGINT NOT NULL)|
+CREATE TABLE t1_aux (f1 BIGINT, f2 BIGINT)|
+INSERT INTO t1_aux VALUES (1,1)|
+
+CREATE FUNCTION f1_two_inserts() returns INTEGER
+BEGIN
+ INSERT INTO t1_not_null SET f1 = 10, f2 = NULL;
+ RETURN 1;
+END|
+
+-- error ER_BAD_NULL_ERROR
+UPDATE t1_aux SET f2 = 2 WHERE f1 = f1_two_inserts()|
+
+-- echo # InnoDB test
+ALTER TABLE t1_not_null ENGINE = InnoDB|
+ALTER TABLE t1_aux ENGINE = InnoDB|
+
+-- error ER_BAD_NULL_ERROR
+UPDATE t1_aux SET f2 = 2 WHERE f1 = f1_two_inserts()|
+
+DROP TABLE t1_aux, t1_not_null|
+DROP FUNCTION f1_two_inserts|
+
+--echo #
+--echo # Bug#49938: Failing assertion: inode or deadlock in fsp/fsp0fsp.c
+--echo #
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1|
+DROP TABLE IF EXISTS t1|
+--enable_warnings
+
+CREATE TABLE t1 (a INT) ENGINE=INNODB|
+
+CREATE PROCEDURE p1()
+BEGIN
+ TRUNCATE TABLE t1;
+END|
+
+LOCK TABLES t1 WRITE|
+CALL p1()|
+FLUSH TABLES;
+UNLOCK TABLES|
+CALL p1()|
+
+DROP PROCEDURE p1|
+DROP TABLE t1|
#
# BUG#NNNN: New bug synopsis
diff --git a/mysql-test/t/sp_trans_log.test b/mysql-test/t/sp_trans_log.test
index 5eccbf81fef..972c3dd36eb 100644
--- a/mysql-test/t/sp_trans_log.test
+++ b/mysql-test/t/sp_trans_log.test
@@ -34,8 +34,11 @@ end|
reset master|
--error ER_DUP_ENTRY
insert into t2 values (bug23333(),1)|
-# with fixes for 23333 will show there is the query */|
---source include/show_binlog_events.inc
+# the following must show there are events after the query
+# the binlog_limit is used to hide the differences between the mixed
+# and row logging formats after BUG#53259
+let $binlog_limit= 0, 4|
+source include/show_binlog_events.inc|
select count(*),@a from t1 /* must be 1,1 */|
delimiter ;|
diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test
index 4a9f34443cb..27956bc8877 100644
--- a/mysql-test/t/sql_mode.test
+++ b/mysql-test/t/sql_mode.test
@@ -309,6 +309,21 @@ flush privileges;
--connection default
drop user mysqltest_32753@localhost;
+
+#
+# Bug#21099 MySQL 5.0.22 silently creates MyISAM tables even though
+# InnoDB specified.
+#
+
+SET @org_mode=@@sql_mode;
+SET @@sql_mode='traditional';
+
+# Agreed change was to add NO_ENGINE_SUBSTITUTION to TRADITIONAL sql mode.
+SELECT @@sql_mode LIKE '%NO_ENGINE_SUBSTITUTION%';
+
+SET sql_mode=@org_mode;
+
+
#
# Bug#45100: Incomplete DROP USER in case of SQL_MODE = 'PAD_CHAR_TO_FULL_LENGTH'
#
diff --git a/mysql-test/t/ssl-big.test b/mysql-test/t/ssl-big.test
index 91103f1d782..59825a148a4 100644
--- a/mysql-test/t/ssl-big.test
+++ b/mysql-test/t/ssl-big.test
@@ -1,7 +1,7 @@
# Turn on ssl between the client and server
# and run a number of tests
--- source include/have_ssl.inc
+-- source include/have_ssl_communication.inc
-- source include/big_test.inc
# Save the initial number of concurrent sessions
@@ -62,3 +62,5 @@ disconnect ssl_con;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
+## This test file is for testing encrypted communication only, not other
+## encryption routines that the SSL library happens to provide!
diff --git a/mysql-test/t/ssl.test b/mysql-test/t/ssl.test
index 936652eaa3d..2526a52bec6 100644
--- a/mysql-test/t/ssl.test
+++ b/mysql-test/t/ssl.test
@@ -1,7 +1,7 @@
# Turn on ssl between the client and server
# and run a number of tests
--- source include/have_ssl.inc
+-- source include/have_ssl_communication.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
@@ -23,3 +23,5 @@ disconnect ssl_con;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
+## This test file is for testing encrypted communication only, not other
+## encryption routines that the SSL library happens to provide!
diff --git a/mysql-test/t/ssl_8k_key.test b/mysql-test/t/ssl_8k_key.test
index b4203e68445..a07d0eb7d02 100644
--- a/mysql-test/t/ssl_8k_key.test
+++ b/mysql-test/t/ssl_8k_key.test
@@ -1,6 +1,8 @@
--- source include/have_ssl.inc
+-- source include/have_ssl_communication.inc
#
# Bug#29784 YaSSL assertion failure when reading 8k key.
#
--exec $MYSQL --ssl --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem -e "SHOW STATUS LIKE 'ssl_Cipher'" 2>&1
+## This test file is for testing encrypted communication only, not other
+## encryption routines that the SSL library happens to provide!
diff --git a/mysql-test/t/ssl_and_innodb.test b/mysql-test/t/ssl_and_innodb.test
new file mode 100644
index 00000000000..4966f05b37b
--- /dev/null
+++ b/mysql-test/t/ssl_and_innodb.test
@@ -0,0 +1,11 @@
+-- source include/have_innodb.inc
+-- source include/have_ssl_crypto_functs.inc
+
+CREATE TABLE t1(a int) engine=innodb;
+INSERT INTO t1 VALUES (1);
+
+SELECT DISTINCT
+convert((SELECT des_decrypt(2,1) AS a FROM t1 WHERE @a:=1), signed) as d
+FROM t1 ;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/ssl_cipher-master.opt b/mysql-test/t/ssl_cipher-master.opt
new file mode 100644
index 00000000000..9525c238c40
--- /dev/null
+++ b/mysql-test/t/ssl_cipher-master.opt
@@ -0,0 +1 @@
+--ssl-cipher=AES128-SHA
diff --git a/mysql-test/t/ssl_cipher.test b/mysql-test/t/ssl_cipher.test
new file mode 100644
index 00000000000..5346968175c
--- /dev/null
+++ b/mysql-test/t/ssl_cipher.test
@@ -0,0 +1,23 @@
+# Turn on ssl between the client and server
+# and run a number of tests
+
+--echo #
+--echo # BUG#11760210 - SSL_CIPHER_LIST NOT SET OR RETURNED FOR "SHOW STATUS LIKE 'SSL_CIPHER_LIST'"
+--echo #
+
+-- source include/have_ssl.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+connect (ssl_con,localhost,root,,,,,SSL);
+
+# Check Cipher Name and Cipher List
+SHOW STATUS LIKE 'Ssl_cipher';
+SHOW STATUS LIKE 'Ssl_cipher_list';
+
+connection default;
+disconnect ssl_con;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/ssl_compress.test b/mysql-test/t/ssl_compress.test
index b6e11621bf6..e8aff942b9f 100644
--- a/mysql-test/t/ssl_compress.test
+++ b/mysql-test/t/ssl_compress.test
@@ -1,7 +1,7 @@
# Turn on compression between the client and server
# and run a number of tests
--- source include/have_ssl.inc
+-- source include/have_ssl_communication.inc
-- source include/have_compress.inc
# Save the initial number of concurrent sessions
@@ -30,3 +30,5 @@ disconnect ssl_compress_con;
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
+## This test file is for testing encrypted communication only, not other
+## encryption routines that the SSL library happens to provide!
diff --git a/mysql-test/t/ssl_connect.test b/mysql-test/t/ssl_connect.test
index 31e581c9342..05d6dc45c74 100644
--- a/mysql-test/t/ssl_connect.test
+++ b/mysql-test/t/ssl_connect.test
@@ -1,5 +1,5 @@
--- source include/have_ssl.inc
+-- source include/have_ssl_communication.inc
# Repeat connect/disconnect
@@ -11,3 +11,6 @@ while ($i)
dec $i;
}
echo completed;
+
+## This test file is for testing encrypted communication only, not other
+## encryption routines that the SSL library happens to provide!
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index 5da210f5a69..26c7a89bf5c 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -58,7 +58,8 @@ let $ID= `select connection_id()`;
connection con2;
--echo # Switched to connection: con2
# wait for the other query to start executing
-let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Locked";
+let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST
+ where ID = $ID and STATE = "Waiting for table level lock";
--source include/wait_condition.inc
unlock tables;
diff --git a/mysql-test/t/status_bug17954.test b/mysql-test/t/status_bug17954.test
new file mode 100644
index 00000000000..36430cceeff
--- /dev/null
+++ b/mysql-test/t/status_bug17954.test
@@ -0,0 +1,54 @@
+# This test requires that --log-output includes 'table', and the general
+# log is on
+
+# embedded server causes different stat
+-- source include/not_embedded.inc
+
+# thread pool causes different results
+-- source include/not_threadpool.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+# Disable concurrent inserts to avoid sporadic test failures as it might
+# affect the the value of variables used throughout the test case.
+set @old_concurrent_insert= @@global.concurrent_insert;
+set @@global.concurrent_insert= 0;
+
+# Disable logging to table, since this will also cause table locking and unlocking, which will
+# show up in SHOW STATUS and may cause sporadic failures
+
+SET @old_log_output = @@global.log_output;
+SET GLOBAL LOG_OUTPUT = 'FILE';
+
+# PS causes different statistics
+--disable_ps_protocol
+
+flush status;
+
+#
+# Bug#17954 Threads_connected > Threads_created
+#
+
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+CREATE VIEW v1 AS SELECT VARIABLE_NAME AS NAME, CONVERT(VARIABLE_VALUE, UNSIGNED) AS VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS;
+
+SELECT VALUE INTO @tc FROM v1 WHERE NAME = 'Threads_connected';
+SELECT NAME FROM v1 WHERE NAME = 'Threads_created' AND VALUE < @tc;
+#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS where variable_name like '%thread%';
+#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS;
+#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES;
+
+DROP VIEW v1;
+
+# Restore global concurrent_insert value. Keep in the end of the test file.
+--connection default
+set @@global.concurrent_insert= @old_concurrent_insert;
+SET GLOBAL log_output = @old_log_output;
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/strict-master.opt b/mysql-test/t/strict-master.opt
new file mode 100644
index 00000000000..96f0ce3f36c
--- /dev/null
+++ b/mysql-test/t/strict-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=MyISAM
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 5779ea97bc2..fc522a69a3c 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -192,11 +192,11 @@ INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-
---error 1292
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -206,18 +206,18 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
## Test INSERT with STR_TO_DATE into DATETIME
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-
---error 1292
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -227,18 +227,18 @@ INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
## Test INSERT with STR_TO_DATE into TIMESTAMP
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -248,7 +248,7 @@ INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
drop table t1;
@@ -822,6 +822,7 @@ INSERT INTO t1 (col2) VALUES (-1.1E-3);
INSERT INTO t1 (col1) VALUES ('+1.8E+309');
--error 1264
INSERT INTO t1 (col2) VALUES ('-1.2E-3');
+--error ER_DATA_OUT_OF_RANGE
UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0;
--error 1365
UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0;
@@ -1166,6 +1167,40 @@ set @@sql_mode='traditional';
--error ER_TOO_LONG_TABLE_COMMENT
create table t1 (i int)
comment '123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*123456789*';
--error ER_TOO_LONG_FIELD_COMMENT
create table t1 (
@@ -1176,6 +1211,26 @@ i int comment
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*');
set @@sql_mode= @org_mode;
create table t1
@@ -1186,6 +1241,26 @@ create table t1
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
+ 123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*');
select column_name, column_comment from information_schema.columns where
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 1f471b46c4e..e910ea09fb2 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -2513,8 +2513,6 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (i INT);
(SELECT i FROM t1) UNION (SELECT i FROM t1);
-#TODO:not supported
---error ER_PARSE_ERROR
SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
(
(SELECT i FROM t1) UNION
@@ -2531,8 +2529,6 @@ WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
from t1;
-#TODO:not supported
---error ER_PARSE_ERROR
explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
@@ -3203,8 +3199,6 @@ EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
-#TODO:not supported
---error ER_PARSE_ERROR
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
@@ -3570,6 +3564,232 @@ where v in(select v
where t1.g=t2.g) is unknown;
drop table t1, t2;
+-- echo #
+-- echo # Bug#33204: INTO is allowed in subselect, causing inconsistent results
+-- echo #
+CREATE TABLE t1( a INT );
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2( a INT, b INT );
+
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO @var FROM t1 WHERE a = 2) t1a;
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2) t1a;
+--error ER_PARSE_ERROR
+SELECT *
+FROM (SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO @var FROM t1 WHERE a = 2
+) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO OUTFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a INTO DUMPFILE 'file' FROM t1 WHERE a = 2
+) t1a;
+
+SELECT * FROM (SELECT a FROM t1 WHERE a = 2) t1a;
+
+SELECT * FROM (
+ SELECT a FROM t1 WHERE a = 2
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+) t1a;
+
+SELECT * FROM (
+ SELECT 1 a
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+ UNION
+ SELECT a FROM t1 WHERE a = 2
+) t1a;
+
+# This was not allowed previously. Possibly, it should be allowed on the future.
+# For now, the intent is to keep the fix as non-intrusive as possible.
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a) UNION SELECT 1 a);
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a)) alias;
+SELECT * FROM (SELECT 1 UNION SELECT 1) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO @a)) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO OUTFILE 'file' )) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM ((SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO @a)) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO DUMPFILE 'file' )) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION (SELECT 1 a INTO OUTFILE 'file' )) t1a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO @a))) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO DUMPFILE 'file' ))) t1a;
+--error ER_PARSE_ERROR
+SELECT * FROM (SELECT 1 a UNION ((SELECT 1 a INTO OUTFILE 'file' ))) t1a;
+
+SELECT * FROM (SELECT 1 a ORDER BY a) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a LIMIT 1) t1a;
+SELECT * FROM (SELECT 1 a UNION SELECT 1 a ORDER BY a LIMIT 1) t1a;
+
+# Test of rule
+# table_factor: '(' get_select_lex query_expression_body ')' opt_table_alias
+# UNION should not be allowed inside the parentheses, nor should
+# aliases after.
+#
+SELECT * FROM t1 JOIN (SELECT 1 UNION SELECT 1) alias ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((SELECT 1 UNION SELECT 1)) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN (t1 t1a UNION SELECT 1) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((t1 t1a UNION SELECT 1)) ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN (t1 t1a) t1a ON 1;
+--error ER_PARSE_ERROR
+SELECT * FROM t1 JOIN ((t1 t1a)) t1a ON 1;
+
+SELECT * FROM t1 JOIN (t1 t1a) ON 1;
+SELECT * FROM t1 JOIN ((t1 t1a)) ON 1;
+
+SELECT * FROM (t1 t1a);
+SELECT * FROM ((t1 t1a));
+
+SELECT * FROM t1 JOIN (SELECT 1 t1a) alias ON 1;
+SELECT * FROM t1 JOIN ((SELECT 1 t1a)) alias ON 1;
+
+SELECT * FROM t1 JOIN (SELECT 1 a) a ON 1;
+SELECT * FROM t1 JOIN ((SELECT 1 a)) a ON 1;
+
+# For the join, TABLE_LIST::select_lex == NULL
+# Check that we handle this.
+--error ER_PARSE_ERROR
+SELECT * FROM (t1 JOIN (SELECT 1) t1a1 ON 1) t1a2;
+
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 );
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ANY ( SELECT 3 UNION SELECT 1 );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+SELECT * FROM t1 WHERE a = ( SELECT 1 );
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO @a);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 INTO DUMPFILE 'file' );
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO OUTFILE 'file' );
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION SELECT 1 INTO DUMPFILE 'file' );
+
+# Make sure context is popped when we leave the nested select
+SELECT ( SELECT a FROM t1 WHERE a = 1 ), a FROM t1;
+SELECT ( SELECT a FROM t1 WHERE a = 1 UNION SELECT 1 ), a FROM t1;
+
+# Make sure we have feature F561 (see .yy file)
+SELECT * FROM t2 WHERE (a, b) IN (SELECT a, b FROM t2);
+
+# Make sure the parser does not allow nested UNIONs anywhere
+
+--error ER_PARSE_ERROR
+SELECT 1 UNION ( SELECT 1 UNION SELECT 1 );
+--error ER_PARSE_ERROR
+( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+
+--error ER_PARSE_ERROR
+SELECT ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1;
+SELECT ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT ((SELECT 1 UNION SELECT 1 UNION SELECT 1));
+
+--error ER_PARSE_ERROR
+SELECT * FROM ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+SELECT * FROM ( SELECT 1 UNION SELECT 1 UNION SELECT 1 ) a;
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION ( SELECT 1 UNION SELECT 1 ) );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ALL ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a = ANY ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( ( SELECT 1 UNION SELECT 1 ) UNION SELECT 1 );
+
+SELECT * FROM t1 WHERE a = ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ALL ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a = ANY ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 UNION SELECT 1 );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 UNION SELECT 1 INTO @v );
+SELECT EXISTS(SELECT 1+1);
+--error ER_PARSE_ERROR
+SELECT EXISTS(SELECT 1+1 INTO @test);
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 UNION SELECT 1 INTO @v );
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE EXISTS ( SELECT 1 INTO @v );
+--error ER_PARSE_ERROR
+SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
+
+DROP TABLE t1, t2;
#
# Bug #31157: Crash when select+order by the avg of some field within the
# group by
@@ -3725,4 +3945,93 @@ SELECT * FROM t2 UNION SELECT * FROM t2
DROP TABLE t1,t2;
--enable_result_log
+--echo #
+--echo # Bug #58818: Incorrect result for IN/ANY subquery
+--echo # with HAVING condition
+--echo #
+
+CREATE TABLE t1(i INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t1s(i INT);
+INSERT INTO t1s VALUES (10), (20), (30);
+CREATE TABLE t2s(i INT);
+INSERT INTO t2s VALUES (100), (200), (300);
+
+SELECT * FROM t1
+WHERE t1.i NOT IN
+(
+ SELECT STRAIGHT_JOIN t2s.i
+ FROM
+ t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
+ HAVING t2s.i = 999
+);
+
+SELECT * FROM t1
+WHERE t1.I IN
+(
+ SELECT STRAIGHT_JOIN t2s.i
+ FROM
+ t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
+ HAVING t2s.i = 999
+) IS UNKNOWN;
+
+SELECT * FROM t1
+WHERE NOT t1.I = ANY
+(
+ SELECT STRAIGHT_JOIN t2s.i
+ FROM
+ t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
+ HAVING t2s.i = 999
+);
+
+SELECT * FROM t1
+ WHERE t1.i = ANY (
+ SELECT STRAIGHT_JOIN t2s.i
+ FROM
+ t1s LEFT OUTER JOIN t2s ON t2s.i = t1s.i
+ HAVING t2s.i = 999
+ ) IS UNKNOWN;
+
+DROP TABLE t1,t1s,t2s;
+
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug #11765713 58705:
+--echo # OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES
+--echo # CREATED BY OPT_SUM_QUERY
+--echo #
+
+CREATE TABLE t1(a INT NOT NULL, KEY (a));
+INSERT INTO t1 VALUES (0), (1);
+
+--error ER_SUBQUERY_NO_1_ROW
+SELECT 1 as foo FROM t1 WHERE a < SOME
+ (SELECT a FROM t1 WHERE a <=>
+ (SELECT a FROM t1)
+ );
+
+SELECT 1 as foo FROM t1 WHERE a < SOME
+ (SELECT a FROM t1 WHERE a <=>
+ (SELECT a FROM t1 where a is null)
+ );
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #57704: Cleanup code dies with void TABLE::set_keyread(bool):
+--echo # Assertion `file' failed.
+--echo #
+
+CREATE TABLE t1 (a INT);
+
+--error ER_OPERAND_COLUMNS
+SELECT 1 FROM
+ (SELECT ROW(
+ (SELECT 1 FROM t1 RIGHT JOIN
+ (SELECT 1 FROM t1, t1 t2) AS d ON 1),
+ 1) FROM t1) AS e;
+
+DROP TABLE t1;
+
+
diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test
index fab0a462157..39c97941031 100644
--- a/mysql-test/t/subselect3.test
+++ b/mysql-test/t/subselect3.test
@@ -794,3 +794,50 @@ SHOW STATUS LIKE '%Handler_read_rnd_next';
DROP TABLE t1,t2;
--echo End of 5.1 tests
+
+--echo #
+--echo # BUG#48920: COUNT DISTINCT returns 1 for NULL values when in a subquery
+--echo # in the select list
+--echo #
+
+--echo
+CREATE TABLE t1 (
+ i int(11) DEFAULT NULL,
+ v varchar(1) DEFAULT NULL
+);
+
+--echo
+INSERT INTO t1 VALUES (8,'v');
+INSERT INTO t1 VALUES (9,'r');
+INSERT INTO t1 VALUES (NULL,'y');
+
+--echo
+CREATE TABLE t2 (
+ i int(11) DEFAULT NULL,
+ v varchar(1) DEFAULT NULL,
+ KEY i_key (i)
+);
+
+--echo
+INSERT INTO t2 VALUES (NULL,'r');
+INSERT INTO t2 VALUES (0,'c');
+INSERT INTO t2 VALUES (0,'o');
+INSERT INTO t2 VALUES (2,'v');
+INSERT INTO t2 VALUES (7,'c');
+
+--echo
+SELECT i, v, (SELECT COUNT(DISTINCT i)
+ FROM t1
+ WHERE v = t2.v) as subsel
+FROM t2;
+
+--echo
+EXPLAIN EXTENDED
+SELECT i, v, (SELECT COUNT(DISTINCT i)
+ FROM t1
+ WHERE v = t2.v) as subsel
+FROM t2;
+
+DROP TABLE t1,t2;
+
+--echo End of 5.6 tests
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index b8ab655da42..f024dd2567f 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -150,3 +150,32 @@ DROP TABLE t;
--echo #
--echo # End of 5.1 tests.
--echo #
+
+--echo #
+--echo # Bug#53236 Segfault in DTCollation::set(DTCollation&)
+--echo #
+
+CREATE TABLE t1 (
+ pk INTEGER AUTO_INCREMENT,
+ col_varchar VARCHAR(1),
+ PRIMARY KEY (pk)
+)
+;
+
+INSERT INTO t1 (col_varchar)
+VALUES
+('w'),
+('m')
+;
+
+SELECT table1.pk
+FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar =
+ table2.col_varchar) )
+WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1,
+ SUBQUERY1_t1.pk AS SUBQUERY1_field2
+ FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2
+ ON (SUBQUERY1_t2.col_varchar =
+ SUBQUERY1_t1.col_varchar) ) )
+;
+
+drop table t1;
diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test
index 573fe0c1810..73491417e0c 100644
--- a/mysql-test/t/subselect_innodb.test
+++ b/mysql-test/t/subselect_innodb.test
@@ -238,3 +238,12 @@ call p1();
call p1();
drop procedure p1;
drop tables t1,t2,t3;
+
+--echo #
+--echo # Bug#60085 crash in Item::save_in_field() with time data type
+--echo #
+
+CREATE TABLE t1(a date, b int, unique(b), unique(a), key(b)) engine=innodb;
+INSERT INTO t1 VALUES ('2011-05-13', 0);
+SELECT * FROM t1 WHERE b < (SELECT CAST(a as date) FROM t1 GROUP BY a);
+DROP TABLE t1;
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index 073fcd28246..5109137e564 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -39,7 +39,8 @@ drop table t2;
#
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" index directory="$MYSQLTEST_VARDIR/run";
+eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a))
+engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" index directory="$MYSQLTEST_VARDIR/run";
insert into t9 select * from t1;
check table t9;
@@ -71,21 +72,25 @@ SHOW CREATE TABLE t9;
create database mysqltest;
--error 1,1
-create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="/this-dir-does-not-exist";
+create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a))
+engine=myisam index directory="/this-dir-does-not-exist";
# temporarily disabled as it returns different result in the embedded server
-# --error ER_WRONG_ARGUMENTS, ER_WRONG_ARGUMENTS
-# create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="not-hard-path";
+--error ER_WRONG_TABLE_NAME
+create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a))
+engine=myisam index directory="not-hard-path";
# Should fail becasue the file t9.MYI already exist in 'run'
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1,1,ER_UNKNOWN_ERROR
-eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="$MYSQLTEST_VARDIR/run";
+eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a))
+engine=myisam index directory="$MYSQLTEST_VARDIR/run";
# Should fail becasue the file t9.MYD already exist in 'tmp'
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--error 1,1
-eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp";
+eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a))
+engine=myisam data directory="$MYSQLTEST_VARDIR/tmp";
# Check moving table t9 from default database to mysqltest;
# In this case the symlinks should be removed.
@@ -272,3 +277,24 @@ SELECT * FROM mysql.user;
--remove_file $MYSQL_TMP_DIR/mysql
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Test for bug #11759990 - "52354: 'CREATE TABLE .. LIKE ... '
+--echo # STATEMENTS FAIL".
+--echo #
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval create table t1 (a int primary key) engine=myisam
+ data directory="$MYSQLTEST_VARDIR/tmp"
+ index directory="$MYSQLTEST_VARDIR/run";
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+show create table t1;
+--echo # CREATE TABLE LIKE statement on table with INDEX/DATA DIRECTORY
+--echo # options should not fail. Per documentation newly created table
+--echo # should not inherit value of these options from the original table.
+create table t2 like t1;
+show create table t2;
+drop tables t1, t2;
diff --git a/mysql-test/t/system_mysql_db_fix30020.test b/mysql-test/t/system_mysql_db_fix30020.test
deleted file mode 100644
index 0a7d9dad7c9..00000000000
--- a/mysql-test/t/system_mysql_db_fix30020.test
+++ /dev/null
@@ -1,108 +0,0 @@
-# Embedded server doesn't support external clients
---source include/not_embedded.inc
-
-# Don't run this test if $MYSQL_FIX_SYSTEM_TABLES isn't set
-# to the location of mysql_fix_privilege_tables.sql
-if (`SELECT LENGTH("$MYSQL_FIX_SYSTEM_TABLES") <= 0`)
-{
- skip Test need MYSQL_FIX_SYSTEM_TABLES;
-}
-# check that CSV engine was compiled in, as the test relies on the presence
-# of the log tables (which are CSV-based)
---source include/have_csv.inc
-
-#
-# This is the test for mysql_fix_privilege_tables
-# It checks that a system tables from mysql 3.20
-# can be upgraded to current system table format
-#
-# Note: If this test fails, don't be confused about the errors reported
-# by mysql-test-run This shows warnings generated by
-# mysql_fix_system_tables which should be ignored.
-# Instead, concentrate on the errors in r/system_mysql_db.reject
-
--- disable_result_log
--- disable_query_log
-
-use test;
-
-# create system tables as in mysql-3.20
-
---disable_warnings
-CREATE TABLE db (
- Host char(60) binary DEFAULT '' NOT NULL,
- Db char(32) binary DEFAULT '' NOT NULL,
- User char(16) binary DEFAULT '' NOT NULL,
- Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- PRIMARY KEY Host (Host,Db,User),
- KEY User (User)
-)
-engine=MyISAM;
---enable_warnings
-
-INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y');
-INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y');
-
---disable_warnings
-CREATE TABLE host (
- Host char(60) binary DEFAULT '' NOT NULL,
- Db char(32) binary DEFAULT '' NOT NULL,
- Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- PRIMARY KEY Host (Host,Db)
-)
-engine=MyISAM;
---enable_warnings
-
---disable_warnings
-CREATE TABLE user (
- Host char(60) binary DEFAULT '' NOT NULL,
- User char(16) binary DEFAULT '' NOT NULL,
- Password char(16),
- Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,
- PRIMARY KEY Host (Host,User)
-)
-engine=MyISAM;
---enable_warnings
-
-INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y');
-INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N');
-
-# Call the "shell script" $MYSQL_FIX_SYSTEM_TABLES using system
--- system $MYSQL_FIX_SYSTEM_TABLES --database=test > $MYSQLTEST_VARDIR/log/system_mysql_db_fix30020.log 2>&1
--- enable_query_log
--- enable_result_log
-
--- source include/system_db_struct.inc
-
--- disable_query_log
-
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv,
-procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc,
-time_zone, time_zone_leap_second, time_zone_name, time_zone_transition,
-time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index;
-
--- enable_query_log
-
-# check that we dropped all system tables
-show tables;
-
-exit;
-# End of 4.1 tests
diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test
index 440fcc8aa8a..7a96f22e0d1 100644
--- a/mysql-test/t/system_mysql_db_fix40123.test
+++ b/mysql-test/t/system_mysql_db_fix40123.test
@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
-if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
+if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test need MYSQL_FIX_PRIVILEGE_TABLES;
}
@@ -26,7 +26,7 @@ use test;
# create system tables as in mysql-4.1.23
# created by executing "./mysql_create_system_tables real ."
-set table_type=myisam;
+set storage_engine=myisam;
CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
@@ -41,8 +41,8 @@ INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
-CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name varchar(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url varchar(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name varchar(64) not null, parent_category_id smallint unsigned null, url varchar(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
@@ -72,7 +72,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL,
-- disable_query_log
# Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
-- enable_query_log
diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test
index 4924c625d57..8adf0a09b22 100644
--- a/mysql-test/t/system_mysql_db_fix50030.test
+++ b/mysql-test/t/system_mysql_db_fix50030.test
@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
-if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
+if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test needs MYSQL_FIX_PRIVILEGE_TABLES;
}
@@ -26,7 +26,7 @@ use test;
# create system tables as in mysql-5.0.30
# created by executing "./mysql_create_system_tables real ."
-set table_type=myisam;
+set storage_engine=myisam;
CREATE TABLE db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges';
INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N');
@@ -39,9 +39,9 @@ INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','
CREATE TABLE func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions';
-CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
CREATE TABLE help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories';
@@ -60,7 +60,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL,
CREATE TABLE proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob DEFAULT '' NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob DEFAULT '' NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
CREATE TABLE servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
@@ -78,7 +78,7 @@ INSERT INTO servers VALUES ('test','localhost','test','root','', 0,'','mysql','r
-- disable_query_log
# Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
-- enable_query_log
diff --git a/mysql-test/t/system_mysql_db_fix50117.test b/mysql-test/t/system_mysql_db_fix50117.test
index d88c4edba93..9aeb654716c 100644
--- a/mysql-test/t/system_mysql_db_fix50117.test
+++ b/mysql-test/t/system_mysql_db_fix50117.test
@@ -3,7 +3,7 @@
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
-if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
+if (!$MYSQL_FIX_PRIVILEGE_TABLES)
{
skip Test needs MYSQL_FIX_PRIVILEGE_TABLES;
}
@@ -44,9 +44,9 @@ CREATE TABLE IF NOT EXISTS plugin ( name char(64) binary DEFAULT '' NOT NULL, dl
CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table';
-CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
+CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges';
-CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
+CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges';
CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(128) not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics';
@@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint sign
CREATE TABLE IF NOT EXISTS proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures';
-CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
+CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
@@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL,
-- disable_query_log
# Drop all tables created by this test
-DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, ndb_binlog_index, proxies_priv;
-- enable_query_log
diff --git a/mysql-test/t/tablespace.test b/mysql-test/t/tablespace.test
new file mode 100644
index 00000000000..9f3cf6255ac
--- /dev/null
+++ b/mysql-test/t/tablespace.test
@@ -0,0 +1,122 @@
+#
+# BUG#60111 storage type for table not saved in .frm
+#
+
+#
+# Check that the table options for TABLESPACE and STORAGE
+# are printed in SHOW CREATE TABLE
+#
+
+# TABLESPACE only
+CREATE TABLE t1(a int) TABLESPACE ts ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# TABLESPACE + STORAGE DISK
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE DISK ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# TABLESPACE + STORAGE MEMORY
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE MEMORY ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# STORAGE MEMORY only
+CREATE TABLE t1(a int) STORAGE MEMORY ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# STORAGE DISK only
+CREATE TABLE t1(a int) STORAGE DISK ENGINE=MyISAM;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+# Check that the table options for TABLESPACE and STORAGE
+# are kept in an ALTER
+#
+
+# TABLESPACE only
+CREATE TABLE t1(a int) TABLESPACE ts ENGINE=MyISAM;
+ALTER TABLE t1 ADD COLUMN b int;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# TABLESPACE and STORAGE DISK
+CREATE TABLE t1(a int) TABLESPACE ts STORAGE DISK ENGINE=MyISAM;
+ALTER TABLE t1 ADD COLUMN b int;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+# Check that the table options for TABLESPACE and STORAGE
+# can be changed with an ALTER
+#
+
+# TABLESPACE only
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+
+ALTER TABLE t1 TABLESPACE ts;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 TABLESPACE ts2;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+# STORAGE only
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+
+ALTER TABLE t1 STORAGE MEMORY;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 STORAGE DISK;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+# TABLESPACE and STORAGE
+CREATE TABLE t1(a int) ENGINE=MyISAM;
+
+ALTER TABLE t1 STORAGE MEMORY TABLESPACE ts;
+SHOW CREATE TABLE t1;
+
+ALTER TABLE t1 STORAGE DISK TABLESPACE ts2;
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+#
+# Check that it's possible to read a .frm fle created
+# by MySQL Cluster 7.0(which introduced the new "format
+# section) with this statement:
+#
+# CREATE TABLE cluster_7022_table
+# (
+# a int primary key,
+# b int,
+# c int STORAGE DISK,
+# d int STORAGE MEMORY NOT NULL,
+# e int COLUMN_FORMAT DYNAMIC,
+# f int COLUMN_FORMAT FIXED,
+# g int COLUMN_FORMAT DEFAULT,
+# h int STORAGE DISK COLUMN_FORMAT DYNAMIC NOT NULL,
+# i int STORAGE MEMORY COLUMN_FORMAT DYNAMIC,
+# j int STORAGE DISK COLUMN_FORMAT FIXED,
+# k int STORAGE MEMORY COLUMN_FORMAT FIXED
+# ) STORAGE DISK TABLESPACE the_tablespacename ENGINE=MyISAM;
+#
+# NOTE! The column level properties will not yet show up
+# in SHOW CREATE TABLE of MySQL Server(although they are
+# visible in .trace file)
+#
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/cluster_7022_table.frm $MYSQLD_DATADIR/test/t1.frm;
+copy_file std_data/cluster_7022_table.MYD $MYSQLD_DATADIR/test/t1.MYD;
+copy_file std_data/cluster_7022_table.MYI $MYSQLD_DATADIR/test/t1.MYI;
+
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 2bfa4936c91..92c22242cdb 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -235,4 +235,19 @@ INSERT INTO t2 SELECT f1();
DROP TABLE t1,t2,t3;
DROP FUNCTION f1;
+--echo #
+--echo # Bug #48067: A temp table with the same name as an existing table,
+--echo # makes drop database fail.
+--echo #
+--disable_warnings
+DROP TEMPORARY TABLE IF EXISTS bug48067.t1;
+DROP DATABASE IF EXISTS bug48067;
+--enable_warnings
+CREATE DATABASE bug48067;
+CREATE TABLE bug48067.t1 (c1 int);
+INSERT INTO bug48067.t1 values (1);
+CREATE TEMPORARY TABLE bug48067.t1 (c1 int);
+DROP DATABASE bug48067;
+DROP TEMPORARY table bug48067.t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/trigger-compat.test b/mysql-test/t/trigger-compat.test
index 2cc86692d0d..8b360d16b98 100644
--- a/mysql-test/t/trigger-compat.test
+++ b/mysql-test/t/trigger-compat.test
@@ -106,4 +106,184 @@ DROP TABLE t2;
DROP USER mysqltest_dfn@localhost;
DROP USER mysqltest_inv@localhost;
DROP DATABASE mysqltest_db1;
+USE test;
+
+--echo #
+--echo # Bug#45235: 5.1 does not support 5.0-only syntax triggers in any way
+--echo #
+let $MYSQLD_DATADIR=`SELECT @@datadir`;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+CREATE TABLE t1 ( a INT );
+CREATE TABLE t2 ( a INT );
+CREATE TABLE t3 ( a INT );
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t2 VALUES (1), (2), (3);
+INSERT INTO t3 VALUES (1), (2), (3);
+
+--echo # We simulate importing a trigger from 5.0 by writing a .TRN file for
+--echo # each trigger plus a .TRG file the way MySQL 5.0 would have done it,
+--echo # with syntax allowed in 5.0 only.
+--echo #
+--echo # Note that in 5.0 the following lines are missing from t1.TRG:
+--echo #
+--echo # client_cs_names='latin1'
+--echo # connection_cl_names='latin1_swedish_ci'
+--echo # db_cl_names='latin1_swedish_ci'
+
+--write_file $MYSQLD_DATADIR/test/tr11.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr12.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr13.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr14.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr15.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/t1.TRG
+TYPE=TRIGGERS
+triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr11 BEFORE INSERT ON t1 FOR EACH ROW DELETE FROM t3' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr12 AFTER INSERT ON t1 FOR EACH ROW DELETE FROM t3' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr13 BEFORE DELETE ON t1 FOR EACH ROW DELETE FROM t1 a USING t1 a' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr14 AFTER DELETE ON t1 FOR EACH ROW DELETE FROM non_existing_table' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr15 BEFORE UPDATE ON t1 FOR EACH ROW DELETE FROM non_existing_table a USING non_existing_table a'
+sql_modes=0 0 0 0 0
+definers='root@localhost' 'root@localhost' 'root@localhost' 'root@localhost' 'root@localhost'
+EOF
+
+--write_file $MYSQLD_DATADIR/test/t2.TRG
+TYPE=TRIGGERS
+triggers='Not allowed syntax here, and trigger name cant be extracted either.'
+sql_modes=0
+definers='root@localhost'
+EOF
+
+FLUSH TABLE t1;
+FLUSH TABLE t2;
+
+--echo # We will get parse errors for most DDL and DML statements when the table
+--echo # has broken triggers. The parse error refers to the first broken
+--echo # trigger.
+--error ER_PARSE_ERROR
+CREATE TRIGGER tr16 AFTER UPDATE ON t1 FOR EACH ROW INSERT INTO t1 VALUES (1);
+--error ER_PARSE_ERROR
+CREATE TRIGGER tr22 BEFORE INSERT ON t2 FOR EACH ROW DELETE FROM non_existing_table;
+SHOW TRIGGERS;
+--error ER_PARSE_ERROR
+INSERT INTO t1 VALUES (1);
+--error ER_PARSE_ERROR
+INSERT INTO t2 VALUES (1);
+--error ER_PARSE_ERROR
+DELETE FROM t1;
+--error ER_PARSE_ERROR
+UPDATE t1 SET a = 1 WHERE a = 1;
+SELECT * FROM t1;
+--error ER_PARSE_ERROR
+RENAME TABLE t1 TO t1_2;
+SHOW TRIGGERS;
+
+DROP TRIGGER tr11;
+DROP TRIGGER tr12;
+DROP TRIGGER tr13;
+DROP TRIGGER tr14;
+DROP TRIGGER tr15;
+
+SHOW TRIGGERS;
+
+--echo # Make sure there is no trigger file left.
+--list_files $MYSQLD_DATADIR/test/ tr*
+
+--echo # We write the same trigger files one more time to test DROP TABLE.
+--write_file $MYSQLD_DATADIR/test/tr11.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr12.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr13.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr14.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr15.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/t1.TRG
+TYPE=TRIGGERS
+triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr11 BEFORE INSERT ON t1 FOR EACH ROW DELETE FROM t3' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr12 AFTER INSERT ON t1 FOR EACH ROW DELETE FROM t3' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr13 BEFORE DELETE ON t1 FOR EACH ROW DELETE FROM t1 a USING t1 a' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr14 AFTER DELETE ON t1 FOR EACH ROW DELETE FROM non_existing_table' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr15 BEFORE UPDATE ON t1 FOR EACH ROW DELETE FROM non_existing_table a USING non_existing_table a'
+sql_modes=0 0 0 0 0
+definers='root@localhost' 'root@localhost' 'root@localhost' 'root@localhost' 'root@localhost'
+EOF
+
+FLUSH TABLE t1;
+FLUSH TABLE t2;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+--echo # Make sure there is no trigger file left.
+
+--list_files $MYSQLD_DATADIR/test/ tr*
+
+CREATE TABLE t1 ( a INT );
+CREATE TABLE t2 ( a INT );
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t2 VALUES (1), (2), (3);
+
+--echo # We write three trigger files. First trigger is syntaxically incorrect, next trigger is correct
+--echo # and last trigger is broken.
+--echo # Next we try to execute SHOW CREATE TRGGIR command for broken trigger and then try to drop one.
+--write_file $MYSQLD_DATADIR/test/tr11.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/tr12.TRN
+TYPE=TRIGGERNAME
+trigger_table=t1
+EOF
+
+--write_file $MYSQLD_DATADIR/test/t1.TRG
+TYPE=TRIGGERS
+triggers='CREATE the wrongest trigger_in_the_world' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr11 BEFORE DELETE ON t1 FOR EACH ROW DELETE FROM t1 a USING t1 a' 'CREATE DEFINER=`root`@`localhost` TRIGGER tr12 BEFORE INSERT ON t1 FOR EACH ROW DELETE FROM t2'
+sql_modes=0 0 0
+definers='root@localhost' 'root@localhost' 'root@localhost'
+EOF
+
+FLUSH TABLE t1;
+
+SHOW CREATE TRIGGER tr12;
+SHOW CREATE TRIGGER tr11;
+DROP TRIGGER tr12;
+DROP TRIGGER tr11;
+
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/t/trigger-trans.test b/mysql-test/t/trigger-trans.test
index 4d6e82dedcb..82bee7aa224 100644
--- a/mysql-test/t/trigger-trans.test
+++ b/mysql-test/t/trigger-trans.test
@@ -148,10 +148,15 @@ CREATE TRIGGER t1_ad AFTER DELETE ON t1 FOR EACH ROW SET @b = 1;
SET @a = 0;
SET @b = 0;
+--error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE t1;
SELECT @a, @b;
+DELETE FROM t1;
+
+SELECT @a, @b;
+
INSERT INTO t1 VALUES (1);
DELETE FROM t1;
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index bcbca4d2139..80dbcceb448 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -998,10 +998,6 @@ call p1();
drop trigger t1_bi;
create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id);
execute stmt1;
-# Until we implement proper mechanism for invalidation of SP statements
-# invoked whenever a table used in SP changes, this statement will fail with
-# 'Table ... does not exist' error.
---error ER_NO_SUCH_TABLE
call p1();
deallocate prepare stmt1;
drop procedure p1;
@@ -1751,7 +1747,7 @@ create trigger t1_ai after insert on t1 for each row set @a := 7;
create table t2 (j int);
insert into t2 values (1), (2);
set @a:="";
-create table if not exists t1 select * from t2;
+insert into t1 select * from t2;
select * from t1;
select @a;
# Let us check that trigger that involves table also works ok.
@@ -1759,7 +1755,7 @@ drop trigger t1_bi;
drop trigger t1_ai;
create table t3 (isave int);
create trigger t1_bi before insert on t1 for each row insert into t3 values (new.i);
-create table if not exists t1 select * from t2;
+insert into t1 select * from t2;
select * from t1;
select * from t3;
drop table t1, t2, t3;
@@ -1975,7 +1971,7 @@ select * from t1_op_log;
truncate t1;
truncate t1_op_log;
-create table if not exists t1
+insert into t1
select NULL, "CREATE TABLE ... SELECT, inserting a new key";
set @id=last_insert_id();
@@ -1984,7 +1980,7 @@ select * from t1;
select * from t1_op_log;
truncate t1_op_log;
-create table if not exists t1 replace
+replace into t1
select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
select * from t1;
@@ -2114,7 +2110,7 @@ select * from t1_op_log;
truncate t1;
truncate t1_op_log;
-create table if not exists v1
+insert into v1
select NULL, "CREATE TABLE ... SELECT, inserting a new key";
set @id=last_insert_id();
@@ -2123,7 +2119,7 @@ select * from t1;
select * from t1_op_log;
truncate t1_op_log;
-create table if not exists v1 replace
+replace into v1
select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
select * from t1;
@@ -2471,3 +2467,148 @@ DROP DATABASE db1;
USE test;
--echo End of 5.1 tests.
+
+
+--echo #
+--echo # Bug#34453 Can't change size of file (Errcode: 1224)
+--echo #
+
+--disable_warnings
+DROP TRIGGER IF EXISTS t1_bi;
+DROP TRIGGER IF EXISTS t1_bd;
+DROP TABLE IF EXISTS t1;
+DROP TEMPORARY TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (s1 INT);
+CREATE TEMPORARY TABLE t2 (s1 INT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES (0);
+CREATE TRIGGER t1_bd BEFORE DELETE ON t1 FOR EACH ROW DELETE FROM t2;
+INSERT INTO t1 VALUES (0);
+INSERT INTO t1 VALUES (0);
+SELECT * FROM t1;
+SELECT * FROM t2;
+-- echo # Reported to give ERROR 14 (HY000):
+-- echo # Can't change size of file (Errcode: 1224)
+-- echo # on Windows
+DELETE FROM t1;
+
+DROP TABLE t1;
+DROP TEMPORARY TABLE t2;
+
+#
+# Bug#36649: Condition area is not properly cleaned up after stored routine invocation
+#
+
+--disable_warnings
+DROP TRIGGER IF EXISTS trg1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+
+delimiter |;
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE a CHAR;
+ SELECT 'ab' INTO a;
+ SELECT 'ab' INTO a;
+ SELECT 'a' INTO a;
+END|
+delimiter ;|
+
+INSERT INTO t1 VALUES (1);
+
+DROP TRIGGER trg1;
+DROP TABLE t1;
+
+#
+# Successive trigger actuations
+#
+
+--disable_warnings
+DROP TRIGGER IF EXISTS trg1;
+DROP TRIGGER IF EXISTS trg2;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+
+delimiter |;
+
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE trg1 CHAR;
+ SELECT 'ab' INTO trg1;
+END|
+
+CREATE TRIGGER trg2 AFTER INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE trg2 CHAR;
+ SELECT 'ab' INTO trg2;
+END|
+
+delimiter ;|
+
+INSERT INTO t1 VALUES (0);
+SELECT * FROM t1;
+SHOW WARNINGS;
+INSERT INTO t1 VALUES (1),(2);
+
+DROP TRIGGER trg1;
+DROP TRIGGER trg2;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug #46747 "Crash in MDL_ticket::upgrade_shared_lock_to_exclusive
+--echo # on TRIGGER + TEMP table".
+--echo #
+
+--disable_warnings
+drop trigger if exists t1_bi;
+drop temporary table if exists t1;
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (i int);
+create trigger t1_bi before insert on t1 for each row set @a:=1;
+--echo # Create temporary table which shadows base table with trigger.
+create temporary table t1 (j int);
+--echo # Dropping of trigger should succeed.
+drop trigger t1_bi;
+select trigger_name from information_schema.triggers
+ where event_object_schema = 'test' and event_object_table = 't1';
+--echo # Clean-up.
+drop temporary table t1;
+drop table t1;
+
+
+--echo
+--echo #
+--echo # Bug #12362125: SP INOUT HANDLING IS BROKEN FOR TEXT TYPE.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(c TEXT);
+
+delimiter |;
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE v TEXT;
+ SET v = 'aaa';
+ SET NEW.c = v;
+END|
+delimiter ;|
+
+INSERT INTO t1 VALUES('qazwsxedc');
+
+SELECT c FROM t1;
+
+DROP TABLE t1;
+
+--echo
+--echo End of 5.5 tests.
diff --git a/mysql-test/t/trigger_notembedded.test b/mysql-test/t/trigger_notembedded.test
index 387944ffb47..536b00308ab 100644
--- a/mysql-test/t/trigger_notembedded.test
+++ b/mysql-test/t/trigger_notembedded.test
@@ -896,7 +896,7 @@ connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
- where state = "Flushing tables";
+ where state = "Waiting for global read lock";
--source include/wait_condition.inc
create trigger t1_bi before insert on t1 for each row begin end;
unlock tables;
diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test
index ba5364bd324..c7a066cc203 100644
--- a/mysql-test/t/truncate.test
+++ b/mysql-test/t/truncate.test
@@ -2,7 +2,7 @@
# Test of truncate
#
--disable_warnings
-drop table if exists t1;
+drop table if exists t1, t2;
--enable_warnings
create table t1 (a integer, b integer,c1 CHAR(10));
@@ -69,3 +69,97 @@ drop table t1;
# End of 5.0 tests
+--echo #
+--echo # Bug#20667 - Truncate table fails for a write locked table
+--echo #
+CREATE TABLE t1 (c1 INT);
+LOCK TABLE t1 WRITE;
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1;
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+UNLOCK TABLES;
+#
+LOCK TABLE t1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+TRUNCATE TABLE t1;
+UNLOCK TABLES;
+#
+CREATE TABLE t2 (c1 INT);
+LOCK TABLE t2 WRITE;
+--error ER_TABLE_NOT_LOCKED
+TRUNCATE TABLE t1;
+UNLOCK TABLES;
+#
+CREATE VIEW v1 AS SELECT t1.c1 FROM t1,t2 WHERE t1.c1 = t2.c1;
+INSERT INTO t1 VALUES (1), (2), (3);
+INSERT INTO t2 VALUES (1), (3), (4);
+SELECT * FROM v1;
+--error ER_NO_SUCH_TABLE
+TRUNCATE v1;
+SELECT * FROM v1;
+#
+LOCK TABLE t1 WRITE;
+--error ER_TABLE_NOT_LOCKED
+SELECT * FROM v1;
+--error ER_TABLE_NOT_LOCKED
+TRUNCATE v1;
+--error ER_TABLE_NOT_LOCKED
+SELECT * FROM v1;
+UNLOCK TABLES;
+#
+LOCK TABLE t1 WRITE, t2 WRITE;
+--error ER_TABLE_NOT_LOCKED
+SELECT * FROM v1;
+--error ER_TABLE_NOT_LOCKED
+TRUNCATE v1;
+--error ER_TABLE_NOT_LOCKED
+SELECT * FROM v1;
+UNLOCK TABLES;
+#
+LOCK TABLE v1 WRITE;
+SELECT * FROM v1;
+--error ER_TABLE_NOT_LOCKED
+TRUNCATE v1;
+SELECT * FROM v1;
+UNLOCK TABLES;
+#
+LOCK TABLE t1 WRITE, t2 WRITE, v1 WRITE;
+SELECT * FROM v1;
+--error ER_TABLE_NOT_LOCKED
+TRUNCATE v1;
+SELECT * FROM v1;
+UNLOCK TABLES;
+#
+DROP VIEW v1;
+DROP TABLE t1, t2;
+#
+CREATE PROCEDURE p1() SET @a = 5;
+--error ER_NO_SUCH_TABLE
+TRUNCATE p1;
+SHOW CREATE PROCEDURE p1;
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug#46452 Crash in MDL, HANDLER OPEN + TRUNCATE TABLE
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 AS SELECT 1 AS f1;
+
+HANDLER t1 OPEN;
+--echo # Here comes the crash.
+TRUNCATE t1;
+
+--echo # Currently TRUNCATE, just like other DDL, implicitly closes
+--echo # open HANDLER table.
+--error ER_UNKNOWN_TABLE
+HANDLER t1 READ FIRST;
+
+# Cleanup
+DROP TABLE t1;
+
+--echo # End of 6.0 tests
+
diff --git a/mysql-test/t/truncate_coverage.test b/mysql-test/t/truncate_coverage.test
new file mode 100644
index 00000000000..135935b53b3
--- /dev/null
+++ b/mysql-test/t/truncate_coverage.test
@@ -0,0 +1,228 @@
+#
+# Code coverage testing of TRUNCATE TABLE.
+#
+# Ingo Struewing, 2009-07-20
+#
+
+--source include/have_debug_sync.inc
+SET DEBUG_SYNC='RESET';
+
+--let $MYSQLD_DATADIR= `SELECT @@datadir`
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #
+--echo # Bug#20667 - Truncate table fails for a write locked table
+--echo #
+########
+# Attack wait_while_table_is_used(). Kill query while trying to
+# upgrade MDL.
+#
+CREATE TABLE t1 (c1 INT);
+INSERT INTO t1 VALUES (1);
+#
+# Acquire a shared metadata lock on table by opening HANDLER for it and wait.
+# TRUNCATE shall block on this metadata lock.
+# We can't use normal DML as such statements would also block LOCK TABLES.
+#
+--echo #
+--echo # connection con1
+--connect (con1, localhost, root,,)
+HANDLER t1 OPEN;
+#
+# Get connection id of default connection.
+# Lock the table and start TRUNCATE, which will block on MDL upgrade.
+#
+--echo #
+--echo # connection default
+--connection default
+let $ID= `SELECT @id := CONNECTION_ID()`;
+LOCK TABLE t1 WRITE;
+SET DEBUG_SYNC='mdl_upgrade_shared_lock_to_exclusive SIGNAL waiting';
+send TRUNCATE TABLE t1;
+#
+# Get the default connection ID into a variable in an invisible statement.
+# Kill the TRUNCATE query. This shall result in an error return
+# from wait_while_table_is_used().
+#
+--echo #
+--echo # connection con2
+--connect (con2, localhost, root,,)
+SET DEBUG_SYNC='now WAIT_FOR waiting';
+let $invisible_assignment_in_select = `SELECT @id := $ID`;
+KILL QUERY @id;
+--disconnect con2
+--echo #
+--echo # connection default
+--connection default
+--error ER_QUERY_INTERRUPTED
+reap;
+UNLOCK TABLES;
+--echo #
+--echo # connection con1
+--connection con1
+--echo # Release shared metadata lock by closing HANDLER.
+HANDLER t1 CLOSE;
+--disconnect con1
+--echo #
+--echo # connection default
+--connection default
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
+########
+# Attack reopen_tables(). Remove form file.
+#
+CREATE TABLE t1 (c1 INT);
+INSERT INTO t1 VALUES (1);
+#
+# Acquire a shared metadata lock on table by opening HANDLER for it and wait.
+# TRUNCATE shall block on this metadata lock.
+# We can't use normal DML as such statements would also block LOCK TABLES.
+#
+--echo #
+--echo # connection con1
+--connect (con1, localhost, root,,)
+HANDLER t1 OPEN;
+#
+# Lock the table and start TRUNCATE, which will block on MDL upgrade.
+#
+--echo #
+--echo # connection default
+--connection default
+LOCK TABLE t1 WRITE;
+SET DEBUG_SYNC='mdl_upgrade_shared_lock_to_exclusive SIGNAL waiting';
+send TRUNCATE TABLE t1;
+#
+# Remove datafile.
+# Commit to let TRUNCATE continue.
+#
+--echo #
+--echo # connection con2
+--connect (con2, localhost, root,,)
+SET DEBUG_SYNC='now WAIT_FOR waiting';
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+--disconnect con2
+--echo #
+--echo # connection con1
+--connection con1
+HANDLER t1 CLOSE;
+--disconnect con1
+--echo #
+--echo # connection default
+--connection default
+--error ER_NO_SUCH_TABLE
+reap;
+UNLOCK TABLES;
+--error ER_BAD_TABLE_ERROR
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
+########
+# Attack acquire_exclusive_locks(). Hold a global read lock.
+# Non-LOCK TABLE case.
+#
+CREATE TABLE t1 (c1 INT);
+INSERT INTO t1 VALUES (1);
+#
+# Start a transaction and execute a DML in it. Since 5.4.4 this leaves
+# a shared meta data lock (MDL) behind. TRUNCATE shall block on it.
+#
+--echo #
+--echo # connection con1
+--connect (con1, localhost, root,,)
+START TRANSACTION;
+INSERT INTO t1 VALUES (2);
+#
+# Get connection id of default connection.
+# Start TRUNCATE, which will block on acquire_exclusive_locks().
+#
+--echo #
+--echo # connection default
+--connection default
+let $ID= `SELECT @id := CONNECTION_ID()`;
+SET DEBUG_SYNC='mdl_acquire_lock_wait SIGNAL waiting';
+send TRUNCATE TABLE t1;
+#
+# Get the default connection ID into a variable in an invisible statement.
+# Kill the TRUNCATE query. This shall result in an error return
+# from wait_while_table_is_used().
+#
+--echo #
+--echo # connection con1
+--connection con1
+SET DEBUG_SYNC='now WAIT_FOR waiting';
+let $invisible_assignment_in_select = `SELECT @id := $ID`;
+KILL QUERY @id;
+--echo #
+--echo # connection default
+--connection default
+--error ER_QUERY_INTERRUPTED
+reap;
+--echo #
+--echo # connection con1
+--connection con1
+--echo # Release SW lock by committing transaction.
+COMMIT;
+--disconnect con1
+--echo #
+--echo # connection default
+--connection default
+UNLOCK TABLES;
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
+
+--echo #
+--echo # Bug#57659 Segfault in Query_cache::invalidate_data for TRUNCATE TABLE
+--echo #
+
+--echo # Note that this test case only reproduces the problem
+--echo # when it is run with valgrind.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, m1;
+--enable_warnings
+
+CREATE TABLE t1(a INT) engine=memory;
+CREATE TABLE m1(a INT) engine=merge UNION(t1);
+connect(con2, localhost, root);
+
+--echo # Connection con1
+connect(con1, localhost, root);
+SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped';
+--echo # Sending:
+--send TRUNCATE TABLE m1
+
+--echo # Connection con2
+connection con2;
+SET DEBUG_SYNC= 'now WAIT_FOR opened';
+--echo # Sending:
+--send FLUSH TABLES
+
+--echo # Connection default
+connection default;
+--echo # Waiting for FLUSH TABLES to be blocked.
+let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist
+ WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES';
+--source include/wait_condition.inc
+SET DEBUG_SYNC= 'now SIGNAL dropped';
+
+--echo # Connection con1
+connection con1;
+--echo # Reaping: TRUNCATE TABLE m1
+--error ER_WRONG_MRG_TABLE
+--reap
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection con2
+connection con2;
+--echo # Reaping: FLUSH TABLES
+--reap
+disconnect con2;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection default
+connection default;
+SET DEBUG_SYNC= 'RESET';
+DROP TABLE m1, t1;
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index 4e097edf73d..fa67afa48e8 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -534,18 +534,6 @@ DROP TABLE b15776;
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a year(-2));
-## For timestamp, we silently rewrite widths to 14 or 19.
-CREATE TABLE b15776 (a timestamp(4294967294));
-DROP TABLE b15776;
-CREATE TABLE b15776 (a timestamp(4294967295));
-DROP TABLE b15776;
---error ER_TOO_BIG_DISPLAYWIDTH
-CREATE TABLE b15776 (a timestamp(4294967296));
---error ER_PARSE_ERROR
-CREATE TABLE b15776 (a timestamp(-1));
---error ER_PARSE_ERROR
-CREATE TABLE b15776 (a timestamp(-2));
-
# We've already tested the case, but this should visually show that
# widths that are too large to be interpreted cause DISPLAYWIDTH errors.
@@ -555,8 +543,6 @@ CREATE TABLE b15776 (a int(99999999999999999999999999999999999999999999999999999
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
---error ER_TOO_BIG_DISPLAYWIDTH
-CREATE TABLE b15776 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
## Do not select, too much memory needed.
CREATE TABLE b15776 select cast(null as char(4294967295));
@@ -613,6 +599,24 @@ explain select convert(1, binary(99999999999999999999999999999999999999999999999
--echo End of 5.0 tests
+#
+# Bug #33969: Updating a text field via a left join
+#
+
+CREATE TABLE t1(id INT NOT NULL);
+CREATE TABLE t2(id INT NOT NULL, c TEXT NOT NULL);
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1, '');
+
+UPDATE t2 SET c = REPEAT('1', 70000);
+SELECT LENGTH(c) FROM t2;
+
+UPDATE t1 LEFT JOIN t2 USING(id) SET t2.c = REPEAT('1', 70000) WHERE t1.id = 1;
+SELECT LENGTH(c) FROM t2;
+
+DROP TABLE t1, t2;
+
--echo # Bug #52160: crash and inconsistent results when grouping
--echo # by a function and column
@@ -627,4 +631,3 @@ DROP FUNCTION f1;
DROP TABLE t1;
--echo End of 5.1 tests
-
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 899f912a5a5..9a21d8b370d 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -266,4 +266,42 @@ SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) =
DROP TABLE t1;
DROP VIEW v1;
+--echo #
+--echo # Bug#59685 crash in String::length with date types
+--echo #
+
+CREATE TABLE t1(a DATE, b YEAR, KEY(a));
+INSERT INTO t1 VALUES ('2011-01-01',2011);
+
+SELECT b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a) FROM t1;
+SELECT b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE) FROM t1;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug #33629: last_day function can return null, but has 'not null'
+--echo # flag set for result
+--echo #
+
+SELECT 1 FROM (SELECT LAST_DAY('0')) a;
+SELECT 1 FROM (SELECT MAKEDATE(2011,0)) a;
+
+CREATE TABLE t1 AS
+ SELECT LAST_DAY('1970-01-01') AS f1,
+ MAKEDATE(1970, 1) AS f2;
+DESCRIBE t1;
+DROP TABLE t1;
+
+--echo #
+
+--echo #
+--echo # Bug#57278: Crash on min/max + with date out of range.
+--echo #
+set @a=(select min(makedate('111','1'))) ;
+select @a;
+--echo #
+
+
+--echo End of 6.0 tests
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 43dafc371dc..81e032751ca 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -457,3 +457,84 @@ SELECT * FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Bug#52849 datetime index not work
+--echo #
+CREATE TABLE t1 (Id INT, AtTime DATETIME, KEY AtTime (AtTime));
+SET NAMES CP850;
+INSERT INTO t1 VALUES (1,'2010-04-12 22:30:12'), (2,'2010-04-12 22:30:12'), (3,'2010-04-12 22:30:12');
+EXPLAIN EXTENDED SELECT * FROM t1 FORCE INDEX(attime) WHERE AtTime = '2010-02-22 18:40:07';
+DROP TABLE t1;
+SET NAMES latin1;
+
+--echo #
+--echo # Bug#56271: Wrong comparison result with STR_TO_DATE function
+--echo #
+CREATE TABLE t1 (
+ `year` int(4) NOT NULL,
+ `month` int(2) NOT NULL
+);
+
+INSERT INTO t1 VALUES (2010,3),(2010,4),(2009,8),(2008,9);
+
+SELECT *
+FROM t1
+WHERE STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') >=
+STR_TO_DATE('1/1/2010', '%m/%d/%Y');
+
+create table t2(f1 datetime primary key);
+insert into t2 select STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') from t1;
+select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+--echo t2 should be const
+explain select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug#57095: Wrongly chosen expression cache type led to a wrong
+--echo # result.
+--echo #
+CREATE TABLE t1 (`b` datetime );
+INSERT INTO t1 VALUES ('2010-01-01 00:00:00'), ('2010-01-01 00:00:00');
+SELECT * FROM t1 WHERE b <= coalesce(NULL, now());
+DROP TABLE t1;
+--echo #
+
+--echo #
+--echo # BUG#12561818: RERUN OF STORED FUNCTION GIVES ERROR 1172:
+--echo # RESULT CONSISTED OF MORE THAN ONE ROW
+--echo #
+
+CREATE TABLE t1 (a DATE NOT NULL, b INT);
+INSERT INTO t1 VALUES ('0000-00-00',1), ('1999-05-10',2);
+
+CREATE TABLE t2 (a DATETIME NOT NULL, b INT);
+INSERT INTO t2 VALUES ('0000-00-00 00:00:00',1), ('1999-05-10 00:00:00',2);
+
+--echo
+SELECT * FROM t1 WHERE a IS NULL;
+SELECT * FROM t2 WHERE a IS NULL;
+SELECT * FROM t1 LEFT JOIN t1 AS t1_2 ON 1 WHERE t1_2.a IS NULL;
+SELECT * FROM t2 LEFT JOIN t2 AS t2_2 ON 1 WHERE t2_2.a IS NULL;
+SELECT * FROM t1 JOIN t1 AS t1_2 ON 1 WHERE t1_2.a IS NULL;
+SELECT * FROM t2 JOIN t2 AS t2_2 ON 1 WHERE t2_2.a IS NULL;
+
+--echo
+PREPARE stmt1 FROM
+ 'SELECT *
+ FROM t1 LEFT JOIN t1 AS t1_2 ON 1
+ WHERE t1_2.a IS NULL AND t1_2.b < 2';
+EXECUTE stmt1;
+EXECUTE stmt1;
+
+DEALLOCATE PREPARE stmt1;
+DROP TABLE t1,t2;
+
+--echo #
+--echo # End of 5.5 tests
+--echo #
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 8a81908296f..1d4ef345747 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -8,13 +8,13 @@ SET SQL_WARNINGS=1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
datatype_id int(11) DEFAULT '0' NOT NULL,
- minvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
- maxvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
+ min_value decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
+ max_value decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
valuename varchar(20),
forecolor int(11),
backcolor int(11),
PRIMARY KEY (id),
- UNIQUE datatype_id (datatype_id, minvalue, maxvalue)
+ UNIQUE datatype_id (datatype_id, min_value, max_value)
);
INSERT INTO t1 VALUES ( '1', '4', '0.0000000000', '0.0000000000', 'Ei saja', '0', '16776960');
INSERT INTO t1 VALUES ( '2', '4', '1.0000000000', '1.0000000000', 'Sajab', '16777215', '255');
@@ -148,8 +148,8 @@ INSERT INTO t1 VALUES ( '139', '21', '326.0000000000', '326.0000000000', 'Lumine
INSERT INTO t1 VALUES ( '143', '16', '-4.9000000000', '-0.1000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '145', '15', '0.0000000000', '1.9000000000', '', '0', '16769024');
INSERT INTO t1 VALUES ( '146', '16', '0.0000000000', '1.9000000000', '', '0', '16769024');
-select * from t1 where minvalue<=1 and maxvalue>=-1 and datatype_id=16;
-select * from t1 where minvalue<=-1 and maxvalue>=-1 and datatype_id=16;
+select * from t1 where min_value<=1 and max_value>=-1 and datatype_id=16;
+select * from t1 where min_value<=-1 and max_value>=-1 and datatype_id=16;
drop table t1;
#
@@ -410,6 +410,18 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
DROP TABLE t1;
#
+# Bug #24541: "Data truncated..." on decimal type columns without any good reason
+#
+
+create table t1 (c1 decimal(10,6));
+insert into t1 (c1) values (9.99e-4);
+insert into t1 (c1) values (9.98e-4);
+insert into t1 (c1) values (0.000999);
+insert into t1 (c1) values (cast(9.99e-4 as decimal(10,6)));
+select * from t1;
+drop table t1;
+
+#
# Bug#31019: MOD() function and operator crashes MySQL when
# divisor is very long and < 1
#
@@ -530,3 +542,44 @@ select max(case 1 when 1 then c else null end) from t1 group by c;
drop table t1;
--echo End of 5.0 tests
+
+#
+# Bug#52168 decimal casting catastrophes:
+# crashes and valgrind errors on simple casts
+#
+
+# Uninitialized read when calling Item_cache_decimal::val_int()
+CREATE TABLE t1 (a INTEGER);
+INSERT INTO t1 VALUES (NULL);
+CREATE TABLE t2 (b INTEGER);
+INSERT INTO t2 VALUES (NULL), (NULL);
+SELECT b FROM t1 JOIN t2 WHERE CONVERT(a, DECIMAL)|CONVERT(b, DECIMAL);
+DROP TABLE t1, t2;
+
+#
+# Bug#52122 crash when converting derived table column to decimal
+#
+CREATE TABLE t1 (col0 INTEGER, col1 REAL);
+CREATE TABLE t2 (col0 INTEGER);
+INSERT INTO t1 VALUES (0, 0.0), (NULL, NULL);
+INSERT INTO t2 VALUES (1);
+
+# Uninitialized read when calling Item_cache_decimal::val_real()
+SELECT 1 FROM t1
+JOIN
+(
+ SELECT t2.col0 FROM t2 RIGHT JOIN t1 USING(col0)
+ GROUP BY t2.col0
+) AS subq
+WHERE t1.col1 + CAST(subq.col0 AS DECIMAL);
+
+# Uninitialized read when calling Item_cache_decimal::val_str()
+SELECT 1 FROM t1
+JOIN
+(
+ SELECT t2.col0 FROM t2 RIGHT JOIN t1 USING(col0)
+ GROUP BY t2.col0
+) AS subq
+WHERE CONCAT(t1.col1, CAST(subq.col0 AS DECIMAL));
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 3b7b30db6f8..45cf80aab5c 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -7,7 +7,7 @@ drop table if exists t1,t2;
--enable_warnings
SELECT 10,10.0,10.,.1e+2,100.0e-1;
-SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
+SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000;
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0;
@@ -252,6 +252,37 @@ insert into t1 values (2e30), (-2e30);
select f1 + 0e0 from t1;
drop table t1;
+#
+# Bug #12860 "Difference in zero padding of exponent between Unix and Windows"
+#
+
+create table t1 (c char(6));
+insert into t1 values (2e6),(2e-5);
+select * from t1;
+drop table t1;
+
+#
+# Bug #21497 "DOUBLE truncated to unusable value"
+#
+
+CREATE TABLE d1 (d DOUBLE);
+INSERT INTO d1 VALUES (1.7976931348623157E+308);
+SELECT * FROM d1;
+--error ER_ILLEGAL_VALUE_FOR_TYPE
+INSERT INTO d1 VALUES (1.79769313486232e+308);
+SELECT * FROM d1;
+DROP TABLE d1;
+
+#
+# Bug #26788 "mysqld (debug) aborts when inserting specific numbers into char
+# fields"
+#
+
+create table t1 (a char(20));
+insert into t1 values (1.225e-05);
+select a+0 from t1;
+drop table t1;
+
#
# Bug #27483: Casting 'scientific notation type' to 'unsigned bigint' fails on
# windows.
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 2cf7ab8fbdf..f1eeabbd924 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1054,10 +1054,8 @@ while ($max_power)
}
SELECT my_float, my_double, my_varchar FROM t1;
-# Expected result 0.000000000011754943372854760000
-# On windows we get 0.000000000011754943372854770000
-# use replace_result to correct it
---replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000
+# The following statement produces results with garbage past
+# the significant digits. Improving it is a part of the WL#3977.
SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1;
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1;
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
@@ -1092,6 +1090,7 @@ create table t1 (c1 decimal(64));
--disable_ps_protocol
insert into t1 values(
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
+--error ER_DATA_OUT_OF_RANGE
insert into t1 values(
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
@@ -1510,5 +1509,29 @@ group by PAY.id + 1;
DROP TABLE currencies, payments, sub_tasks;
+--echo #
+--echo # BUG#52171: distinct aggregates on unsigned decimal fields trigger assertions
+--echo #
+
+CREATE TABLE t1 (a DECIMAL(4,4) UNSIGNED);
+INSERT INTO t1 VALUES (0);
+SELECT AVG(DISTINCT a) FROM t1;
+SELECT SUM(DISTINCT a) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#55436: buffer overflow in debug binary of dbug_buff in
+--echo # Field_new_decimal::store_value
+--echo #
+
+# this threw memory warnings on Windows. Also make sure future changes
+# don't change these results, as per usual.
+SET SQL_MODE='';
+CREATE TABLE t1(f1 DECIMAL(44,24)) ENGINE=MYISAM;
+INSERT INTO t1 SET f1 = -64878E-85;
+SELECT f1 FROM t1;
+DROP TABLE IF EXISTS t1;
+
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index 34331b72688..84d6f58dea1 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -39,7 +39,7 @@ drop table t1;
# SELECT CAST(0.2359591234567e+30 AS TIME);
# ##########################################################
-# End of 4.1 tests
+--echo End of 4.1 tests
#
# Bug#29555: Comparing time values as strings may lead to a wrong result.
@@ -100,3 +100,21 @@ SELECT TIMESTAMP(f1,'1') FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
+
+#
+# Bug#42664 - Sign ignored for TIME types when not comparing as longlong
+#
+
+CREATE TABLE t1 (f1 TIME);
+INSERT INTO t1 VALUES ('24:00:00');
+SELECT '24:00:00' = (SELECT f1 FROM t1);
+SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1);
+SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1);
+TRUNCATE t1;
+INSERT INTO t1 VALUES ('-24:00:00');
+SELECT CAST('24:00:00' AS TIME) = (SELECT f1 FROM t1);
+SELECT CAST('-24:00:00' AS TIME) = (SELECT f1 FROM t1);
+SELECT '-24:00:00' = (SELECT f1 FROM t1);
+DROP TABLE t1;
+
+--echo End of 6.0 tests
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index 602f6f089c2..cd4ba18455b 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -67,17 +67,6 @@ INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
SELECT * FROM t1;
drop table t1;
-create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
- t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
- t14 timestamp(14));
-insert t1 values (0,0,0,0,0,0,0),
-("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
-"1997-12-31 23:47:59");
-select * from t1;
-select * from t1;
-drop table t1;
-
#
# Let us check if we properly treat wrong datetimes and produce proper warnings
# (for both strings and numbers)
@@ -298,7 +287,7 @@ drop table t1;
# mode regardless of whether a display width is given.
#
set sql_mode='maxdb';
-create table t1 (a timestamp, b timestamp(19));
+create table t1 (a timestamp, b timestamp);
show create table t1;
# restore default mode
set sql_mode='';
@@ -373,4 +362,83 @@ SELECT a FROM t1 WHERE a >= '20000101000000';
DROP TABLE t1;
+--echo #
+--echo # Bug#50774: failed to get the correct resultset when timestamp values
+--echo # are appended with .0
+--echo #
+CREATE TABLE t1 ( a TIMESTAMP, KEY ( a ) );
+
+INSERT INTO t1 VALUES( '2010-02-01 09:31:01' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:02' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:03' );
+INSERT INTO t1 VALUES( '2010-02-01 09:31:04' );
+
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' <= a;
+SELECT * FROM t1 WHERE a <= '2010-02-01 09:31:02.0';
+SELECT * FROM t1 WHERE '2010-02-01 09:31:02.0' >= a;
+
+--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+SELECT * FROM t1 WHERE a >= '2010-02-01 09:31:02.0';
+
+CREATE TABLE t2 ( a TIMESTAMP, KEY ( a DESC ) );
+
+INSERT INTO t2 VALUES( '2010-02-01 09:31:01' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:02' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:03' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:04' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:05' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:06' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:07' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:08' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:09' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:10' );
+INSERT INTO t2 VALUES( '2010-02-01 09:31:11' );
+
+--echo # The bug would cause the range optimizer's comparison to use an open
+--echo # interval here. This reveals itself only in the number of reads
+--echo # performed.
+FLUSH STATUS;
+--replace_column 1 x 2 x 3 x 5 x 6 x 7 x 8 x 9 x 10 x
+EXPLAIN
+SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
+SELECT * FROM t2 WHERE a < '2010-02-01 09:31:02.0';
+SHOW STATUS LIKE 'Handler_read_next';
+
+DROP TABLE t1, t2;
+
--echo End of 5.1 tests
+
+--echo
+--echo Bug#50888 valgrind warnings in Field_timestamp::val_str
+--echo
+
+SET TIMESTAMP=0;
+CREATE TABLE t1(a timestamp);
+INSERT INTO t1 VALUES ('2008-02-23 09:23:45'), ('2010-03-05 11:08:02');
+FLUSH TABLES t1;
+SELECT MAX(a) FROM t1;
+SELECT a FROM t1;
+DROP TABLE t1;
+
+--echo End of Bug#50888
+
+--echo #
+--echo # Bug59330: Incorrect result when comparing an aggregate
+--echo # function with TIMESTAMP
+--echo #
+CREATE TABLE t1 (dt DATETIME, ts TIMESTAMP);
+INSERT INTO t1 VALUES('2011-01-06 12:34:30', '2011-01-06 12:34:30');
+SELECT MAX(dt), MAX(ts) FROM t1;
+SELECT MAX(ts) < '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(dt) < '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(ts) > '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(dt) > '2010-01-01 00:00:00' FROM t1;
+SELECT MAX(ts) = '2011-01-06 12:34:30' FROM t1;
+SELECT MAX(dt) = '2011-01-06 12:34:30' FROM t1;
+DROP TABLE t1;
+
+--echo End of 5.5 tests
+
diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test
index 9098881e379..33b84266118 100644
--- a/mysql-test/t/type_varchar.test
+++ b/mysql-test/t/type_varchar.test
@@ -199,3 +199,21 @@ SELECT a,(a + 0) FROM t1 ORDER BY a;
SELECT a,(a DIV 2) FROM t1 ORDER BY a;
SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
DROP TABLE t1;
+
+#
+# Bug #28299: To-number conversion warnings work differenly with CHAR
+# and VARCHAR sp variables
+#
+# * Verify that 'Truncated incorrect DOUBLE value' is shown for 's'
+# when using both CHAR and VARCHAR.
+#
+
+CREATE TABLE t1 (a VARCHAR(16));
+INSERT INTO t1 VALUES ('5'), ('s'), ('');
+SELECT 5 = a FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(16));
+INSERT INTO t1 VALUES ('5'), ('s'), ('');
+SELECT 5 = a FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test
index d8da4ccc82c..1a9e66478e1 100644
--- a/mysql-test/t/type_year.test
+++ b/mysql-test/t/type_year.test
@@ -150,5 +150,15 @@ SELECT ta.y AS ta_y, ta.s, tb.y AS tb_y, tb.s FROM t1 ta, t1 tb HAVING ta_y = tb
DROP TABLE t1;
--echo #
+--echo # Bug #59211: Select Returns Different Value for min(year) Function
+--echo #
+
+CREATE TABLE t1(c1 YEAR(4));
+INSERT INTO t1 VALUES (1901),(2155),(0000);
+SELECT * FROM t1;
+SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1;
+DROP TABLE t1;
+
+--echo #
--echo End of 5.1 tests
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
index 9295969c05f..f0b1835371c 100644
--- a/mysql-test/t/udf.test
+++ b/mysql-test/t/udf.test
@@ -439,6 +439,75 @@ SELECT * FROM t2 WHERE a = sequence();
DROP FUNCTION sequence;
DROP TABLE t1,t2;
+#
+# Bug#31767 (DROP FUNCTION name resolution)
+#
+
+--disable_warnings
+drop function if exists test.metaphon;
+drop function if exists metaphon;
+--enable_warnings
+
+--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
+eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
+
+select metaphon("Hello");
+
+# The UDF should not be dropped
+drop function if exists test.metaphon;
+
+select metaphon("Hello");
+
+drop function metaphon;
+
+CREATE FUNCTION test.metaphon(a TEXT) RETURNS TEXT return "This is a SF";
+
+create database db_31767;
+use db_31767;
+
+--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
+eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB";
+
+use test;
+
+# Uses the UDF
+select metaphon("Hello");
+
+# Uses the SF
+select test.metaphon("Hello");
+
+# Should drop the UDF, resolving the name the same way select does.
+drop function metaphon;
+
+# Should call the SF
+select metaphon("Hello");
+
+# Drop the SF
+drop function metaphon;
+
+# Change the current database to none.
+use db_31767;
+drop database db_31767;
+
+drop function if exists no_such_func;
+
+--error ER_SP_DOES_NOT_EXIST
+drop function no_such_func;
+
+drop function if exists test.no_such_func;
+
+--error ER_SP_DOES_NOT_EXIST
+drop function test.no_such_func;
+
+--error ER_NO_DB_ERROR
+drop procedure if exists no_such_proc;
+
+--error ER_NO_DB_ERROR
+drop procedure no_such_proc;
+
+use test;
+
+
--echo #
--echo # Bug#46259: 5.0.83 -> 5.1.36, query doesn't work
--echo #
@@ -452,3 +521,17 @@ SELECT IF( a = 1, a, a ) AS `b` FROM t1 ORDER BY field( `b`, 1 );
DROP TABLE t1;
--echo End of 5.0 tests.
+
+--echo #
+--echo # Bug#33546: Slowdown on re-evaluation of constant expressions.
+--echo #
+CREATE TABLE t1 (f1 INT);
+INSERT INTO t1 VALUES(1),(50);
+--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB
+eval CREATE FUNCTION myfunc_double RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB";
+EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE f1=1 + myfunc_double(1);
+DROP FUNCTION myfunc_double;
+DROP TABLE t1;
+--echo #
+--echo End of 5.1 tests.
+
diff --git a/mysql-test/t/union-master.opt b/mysql-test/t/union-master.opt
index 3eb98fc3d6b..c852f488260 100644
--- a/mysql-test/t/union-master.opt
+++ b/mysql-test/t/union-master.opt
@@ -1 +1 @@
---log-slow-queries --log-long-format --log-queries-not-using-indexes
+--log-slow-queries --log-queries-not-using-indexes
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index c8d5ea0f8e5..c6599517e90 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -91,88 +91,6 @@ SELECT @a:=1 UNION SELECT @a:=@a+1;
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
-
-#
-# Bug#32858: Erro: "Incorrect usage of UNION and INTO" does not take subselects
-# into account
-#
-CREATE TABLE t1 (a INT);
-INSERT INTO t1 VALUES (1);
-
-SELECT a INTO @v FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1
-) alias;
-
---let $outfile = $MYSQLTEST_VARDIR/tmp/union.out.file
---error 0,1
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a INTO OUTFILE '$outfile' FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1 WHERE 0
-) alias;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a INTO DUMPFILE '$outfile' FROM (
- SELECT a FROM t1
- UNION
- SELECT a FROM t1 WHERE 0
-) alias;
---remove_file $outfile
-
-#
-# INTO will not be allowed in subqueries in version 5.1 and above.
-#
-SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO @v FROM t1
-) alias;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO OUTFILE '$outfile' FROM t1
-) alias;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM (
- SELECT a FROM t1
- UNION
- SELECT a INTO DUMPFILE '$outfile' FROM t1
-) alias;
---remove_file $outfile
-
-SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM t1 UNION SELECT a INTO OUTFILE '$outfile' FROM t1;
---remove_file $outfile
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
-eval SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '$outfile' FROM t1;
---remove_file $outfile
-
---error ER_WRONG_USAGE
-SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_WRONG_USAGE
-eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
-
---replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
---error ER_WRONG_USAGE
-eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
-
-DROP TABLE t1;
-
#
# Test bug reported by joc@presence-pc.com
#
@@ -335,7 +253,7 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
create temporary table t1 select a from t1 union select a from t2;
drop temporary table t1;
---error 1093
+--error ER_TABLE_EXISTS_ERROR
create table t1 select a from t1 union select a from t2;
--error 1054
select a from t1 union select a from t2 order by t2.a;
@@ -1102,7 +1020,49 @@ DROP TABLE t1;
--echo End of 5.0 tests
+-- echo #
+-- echo # Bug#32858: Error: "Incorrect usage of UNION and INTO" does not take
+-- echo # subselects into account
+-- echo #
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+
+-- echo # Tests fix in parser rule select_derived_union.
+SELECT a INTO @v FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1
+) alias;
+
+SELECT a INTO OUTFILE 'union.out.file' FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1 WHERE 0
+) alias;
+
+SELECT a INTO DUMPFILE 'union.out.file2' FROM (
+ SELECT a FROM t1
+ UNION
+ SELECT a FROM t1 WHERE 0
+) alias;
+
+SELECT a FROM t1 UNION SELECT a INTO @v FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
+--error ER_WRONG_USAGE
+SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
+
+-- echo # Tests fix in parser rule query_expression_body.
+SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1;
+SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1;
+DROP TABLE t1;
+remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.1/data/test union.out.fil*;
--echo #
--echo # Bug #49734: Crash on EXPLAIN EXTENDED UNION ... ORDER BY
@@ -1157,3 +1117,70 @@ DROP TABLE t1,t2;
--echo End of 5.1 tests
+
+--echo #
+--echo # Bug#57986 ORDER BY clause is not used after a UNION,
+--echo # if embedded in a SELECT
+--echo #
+
+CREATE TABLE t1 (c1 VARCHAR(10) NOT NULL, c2 INT NOT NULL);
+CREATE TABLE t2 (c1 VARCHAR(10) NOT NULL, c2 INT NOT NULL);
+
+
+INSERT INTO t1 (c1, c2) VALUES ('t1a', 1), ('t1a', 2), ('t1a', 3), ('t1b', 2), ('t1b', 1);
+INSERT INTO t2 (c1, c2) VALUES ('t2a', 1), ('t2a', 2), ('t2a', 3), ('t2b', 2), ('t2b', 1);
+
+SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY c2, c1;
+SELECT * FROM t1 UNION (SELECT * FROM t2) ORDER BY c2, c1;
+SELECT * FROM t1 UNION (SELECT * FROM t2 ORDER BY c2, c1);
+
+SELECT c1, c2 FROM (
+ SELECT c1, c2 FROM t1
+ UNION
+ (SELECT c1, c2 FROM t2)
+ ORDER BY c2, c1
+) AS res;
+
+SELECT c1, c2 FROM (
+ SELECT c1, c2 FROM t1
+ UNION
+ (SELECT c1, c2 FROM t2)
+ ORDER BY c2 DESC, c1 LIMIT 1
+) AS res;
+
+SELECT c1, c2 FROM (
+ SELECT c1, c2 FROM t1
+ UNION
+ (SELECT c1, c2 FROM t2 ORDER BY c2 DESC, c1 LIMIT 1)
+) AS res;
+
+SELECT c1, c2 FROM (
+ SELECT c1, c2 FROM t1
+ UNION
+ SELECT c1, c2 FROM t2
+ ORDER BY c2 DESC, c1 DESC LIMIT 1
+) AS res;
+
+SELECT c1, c2 FROM (
+ (
+ (SELECT c1, c2 FROM t1)
+ UNION
+ (SELECT c1, c2 FROM t2)
+ )
+ ORDER BY c2 DESC, c1 ASC LIMIT 1
+) AS res;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug #58970 Problem Subquery (without referencing a table)
+--echo # and Order By
+--echo #
+
+SELECT(SELECT 0 AS a UNION SELECT 1 AS a ORDER BY a ASC LIMIT 1) AS dev;
+SELECT(SELECT 0 AS a UNION SELECT 1 AS a ORDER BY a DESC LIMIT 1) AS dev;
+SELECT(SELECT 0 AS a FROM dual UNION SELECT 1 AS a FROM dual ORDER BY a ASC LIMIT 1) AS dev;
+SELECT(SELECT 0 AS a FROM dual UNION SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev;
+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;
diff --git a/mysql-test/t/user_limits.test b/mysql-test/t/user_limits.test
index 41af032b97e..1bf3f9a3103 100644
--- a/mysql-test/t/user_limits.test
+++ b/mysql-test/t/user_limits.test
@@ -132,7 +132,7 @@ drop user mysqltest_1@localhost;
select @@session.max_user_connections, @@global.max_user_connections;
# Local max_user_connections variable can't be set directly
# since this limit is per-account
---error ER_GLOBAL_VARIABLE
+--error ER_VARIABLE_IS_READONLY
set session max_user_connections= 2;
# But it is ok to set global max_user_connections
set global max_user_connections= 2;
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index 56217fe67d5..6a64343b609 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -122,8 +122,6 @@ select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
#
--error 1064
set session @honk=99;
---error 1382
-set one_shot @honk=99;
#
# Bug #10724 @@local not preserved in column name of select
@@ -353,4 +351,57 @@ DROP TABLE t1;
select @v:=@v:=sum(1) from dual;
+#
+# Bug #57187: more user variable fun with multiple assignments and
+# comparison in query
+#
+
+CREATE TABLE t1(a DECIMAL(31,21));
+INSERT INTO t1 VALUES (0);
+
+SELECT (@v:=a) <> (@v:=1) FROM t1;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
+
+#
+# Bug#50511: Sometimes wrong handling of user variables containing NULL.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(f1 INT AUTO_INCREMENT, PRIMARY KEY(f1));
+
+INSERT INTO t1 SET f1 = NULL ;
+
+SET @aux = NULL ;
+INSERT INTO t1 SET f1 = @aux ;
+
+SET @aux1 = 0.123E-1;
+SET @aux1 = NULL;
+INSERT INTO t1 SET f1 = @aux1 ;
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1(f1 VARCHAR(257) , f2 INT, PRIMARY KEY(f2));
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @aux = 1;
+
+SET @aux = 1; # INT
+SET @aux = NULL;
+INSERT INTO test.t1 (f1, f2) VALUES (1, 1), (@aux, 2);
+
+SET @aux = 'text'; # STRING
+SET @aux = NULL;
+INSERT INTO t1(f1, f2) VALUES (1, 3), (@aux, 4);
+
+SELECT f1, f2 FROM t1 ORDER BY f2;
+
+DROP TRIGGER trg1;
+DROP TABLE t1;
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/variables-big.test b/mysql-test/t/variables-big.test
index 6c357bb6e54..53f426757b6 100644
--- a/mysql-test/t/variables-big.test
+++ b/mysql-test/t/variables-big.test
@@ -34,6 +34,7 @@
# There is a significant probablitity that this tests fails with testcase
# timeout if the testing box is not powerful enough.
#
+SET @def_var= @@session.transaction_prealloc_size;
--disable_warnings
SET SESSION transaction_prealloc_size=1024*1024*1024*1;
@@ -53,3 +54,5 @@ SET SESSION transaction_prealloc_size=1024*1024*1024*5;
SHOW PROCESSLIST;
--enable_warnings
+SET @@session.transaction_prealloc_size= @def_var;
+
diff --git a/mysql-test/t/variables-notembedded.test b/mysql-test/t/variables-notembedded.test
index 7cc068c68c7..b440cfa47b0 100644
--- a/mysql-test/t/variables-notembedded.test
+++ b/mysql-test/t/variables-notembedded.test
@@ -109,3 +109,30 @@ SET @@session.slave_skip_errors= 7;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@global.slave_skip_errors= 7;
#
+
+--echo #
+--echo # Bug #11766769 : 59959: SMALL VALUES OF --MAX-ALLOWED-PACKET
+--echo # ARE NOT BEING HONORED
+--echo #
+
+CREATE TABLE t1 (a MEDIUMTEXT);
+
+SET GLOBAL max_allowed_packet=2048;
+SET GLOBAL net_buffer_length=4096;
+CONNECT (con1,localhost,root,,test);
+SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
+SHOW SESSION VARIABLES LIKE 'net_buffer_length';
+--disable_query_log
+--error ER_NET_PACKET_TOO_LARGE
+INSERT INTO t1 VALUES ('123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+--enable_query_log
+
+CONNECTION default;
+DISCONNECT con1;
+SELECT LENGTH(a) FROM t1;
+
+SET GLOBAL max_allowed_packet=default;
+SET GLOBAL net_buffer_length=default;
+DROP TABLE t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 2513f4fbcc8..ddf1170de93 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -33,7 +33,7 @@ set @my_query_cache_type =@@global.query_cache_type;
set @my_rpl_recovery_rank =@@global.rpl_recovery_rank;
set @my_server_id =@@global.server_id;
set @my_slow_launch_time =@@global.slow_launch_time;
-set @my_storage_engine =@@global.storage_engine;
+set @my_storage_engine =@@global.default_storage_engine;
set @my_thread_cache_size =@@global.thread_cache_size;
set @my_max_allowed_packet =@@global.max_allowed_packet;
set @my_join_buffer_size =@@global.join_buffer_size;
@@ -132,12 +132,12 @@ set global timed_mutexes=0;
show variables like 'timed_mutexes';
select * from information_schema.session_variables where variable_name like 'timed_mutexes';
-set storage_engine=MYISAM, storage_engine="HEAP", global storage_engine="MERGE";
-show local variables like 'storage_engine';
-select * from information_schema.session_variables where variable_name like 'storage_engine';
-show global variables like 'storage_engine';
-select * from information_schema.global_variables where variable_name like 'storage_engine';
-set GLOBAL query_cache_size=100000;
+set default_storage_engine=MYISAM, default_storage_engine="HEAP", global default_storage_engine="MERGE";
+show local variables like 'default_storage_engine';
+select * from information_schema.session_variables where variable_name like 'default_storage_engine';
+show global variables like 'default_storage_engine';
+select * from information_schema.global_variables where variable_name like 'default_storage_engine';
+set GLOBAL query_cache_size=102400;
set GLOBAL myisam_max_sort_file_size=2000000;
show global variables like 'myisam_max_sort_file_size';
@@ -213,7 +213,6 @@ set @@query_alloc_block_size=1024*17+2;
set @@query_prealloc_size=1024*18-1023;
set @@transaction_alloc_block_size=1024*20-1;
set @@transaction_prealloc_size=1024*21-1;
-select @@query_alloc_block_size;
--echo ==+ Check manipulated values ==+
SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
'query_alloc_block_size', 'query_prealloc_size',
@@ -250,14 +249,12 @@ set unknown_variable=1;
--error ER_WRONG_TYPE_FOR_VAR
set max_join_size="hello";
--error ER_UNKNOWN_STORAGE_ENGINE
-set storage_engine=UNKNOWN_TABLE_TYPE;
+set default_storage_engine=UNKNOWN_TABLE_TYPE;
--error ER_WRONG_VALUE_FOR_VAR
-set storage_engine=MERGE, big_tables=2;
-show local variables like 'storage_engine';
+set default_storage_engine=MERGE, big_tables=2;
+show local variables like 'default_storage_engine';
--error ER_GLOBAL_VARIABLE
set SESSION query_cache_size=10000;
---error ER_NO_DEFAULT
-set GLOBAL storage_engine=DEFAULT;
--error ER_UNKNOWN_CHARACTER_SET
set character_set_client=UNKNOWN_CHARACTER_SET;
--error ER_UNKNOWN_COLLATION
@@ -266,18 +263,12 @@ set collation_connection=UNKNOWN_COLLATION;
set character_set_client=NULL;
--error ER_WRONG_VALUE_FOR_VAR
set collation_connection=NULL;
---error ER_LOCAL_VARIABLE
-set global autocommit=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@global.timestamp;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set @@version='';
--error ER_GLOBAL_VARIABLE
set @@concurrent_insert=1;
---error ER_LOCAL_VARIABLE
-set @@global.sql_auto_is_null=1;
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
-select @@global.sql_auto_is_null;
--error ER_GLOBAL_VARIABLE
set myisam_max_sort_file_size=100;
--error ER_WRONG_VALUE_FOR_VAR
@@ -355,10 +346,7 @@ set sql_big_tables=1;
set sql_buffer_result=1;
set sql_log_bin=1;
set sql_log_off=1;
-set sql_log_update=1;
set sql_low_priority_updates=1;
-set sql_max_join_size=200;
-select @@sql_max_join_size,@@max_join_size;
set sql_quote_show_create=1;
set sql_safe_updates=1;
set sql_select_limit=1;
@@ -366,7 +354,7 @@ set sql_select_limit=1;
set sql_select_limit=default;
set sql_warnings=1;
set global table_open_cache=100;
-set storage_engine=myisam;
+set default_storage_engine=myisam;
set global thread_cache_size=100;
set timestamp=1, timestamp=default;
set tmp_table_size=100;
@@ -559,7 +547,7 @@ select @@lc_time_names;
--echo *** LC_TIME_NAMES: testing with string expressions
set lc_time_names=concat('de','_','DE');
select @@lc_time_names;
---error ER_UNKNOWN_ERROR
+--error ER_UNKNOWN_LOCALE
set lc_time_names=concat('de','+','DE');
select @@lc_time_names;
--echo LC_TIME_NAMES: testing with numeric expressions
@@ -572,15 +560,15 @@ set lc_time_names=en_US;
--echo LC_TIME_NAMES: testing NULL and a negative number:
--error ER_WRONG_VALUE_FOR_VAR
set lc_time_names=NULL;
---error ER_UNKNOWN_ERROR
+--error ER_UNKNOWN_LOCALE
set lc_time_names=-1;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing locale with the last ID:
-set lc_time_names=108;
+set lc_time_names=109;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing a number beyond the valid ID range:
---error ER_UNKNOWN_ERROR
-set lc_time_names=109;
+--error ER_UNKNOWN_LOCALE
+set lc_time_names=110;
select @@lc_time_names;
--echo LC_TIME_NAMES: testing that 0 is en_US:
set lc_time_names=0;
@@ -847,7 +835,7 @@ set global query_cache_type =@my_query_cache_type;
set global rpl_recovery_rank =@my_rpl_recovery_rank;
set global server_id =@my_server_id;
set global slow_launch_time =@my_slow_launch_time;
-set global storage_engine =@my_storage_engine;
+set global default_storage_engine =@my_storage_engine;
set global thread_cache_size =@my_thread_cache_size;
set global max_allowed_packet =@my_max_allowed_packet;
set global join_buffer_size =@my_join_buffer_size;
@@ -856,8 +844,8 @@ set global join_buffer_size =@my_join_buffer_size;
# Bug#28580 Repeatation of status variables
#
--replace_column 2 #
-show global variables where Variable_name='table_definition_cache' or
-Variable_name='table_lock_wait_timeout';
+show global variables where Variable_name='table_definition_cache';
+# Note: table_lock_wait_timeout no longer exists. See bug#45225.
###########################################################################
@@ -969,15 +957,15 @@ SET @@global.init_file= 'x';
#
--echo #
--replace_column 2 #
-SHOW VARIABLES like 'language';
+SHOW VARIABLES like 'lc_messages_dir';
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
-SELECT @@session.language;
+SELECT @@session.lc_messages_dir;
--replace_column 1 #
-SELECT @@global.language;
+SELECT @@global.lc_messages_dir;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
-SET @@session.language= 'x';
+SET @@session.lc_messages_dir= 'x';
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
-SET @@global.language= 'x';
+SET @@global.lc_messages_dir= 'x';
#
--echo #
--replace_column 2 #
@@ -1202,7 +1190,7 @@ SET GLOBAL auto_increment_offset=0;
#
--enable_metadata
-select @@storage_engine;
+select @@default_storage_engine;
--disable_metadata
#
@@ -1293,10 +1281,243 @@ SET @@global.max_join_size=0;
SET @@global.key_buffer_size=0;
SET @@global.key_cache_block_size=0;
+#
+# Bug#56976: added new start-up parameter
+#
+select @@max_long_data_size;
+
+--echo #
+--echo # Bug#11766424 59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
+--echo #
+
+CREATE TABLE t1(f1 DECIMAL(1,1) UNSIGNED);
+INSERT INTO t1 VALUES (0.2),(0.1);
+SELECT 1 FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1);
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT @a:= CAST(1 AS UNSIGNED) AS a;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
# cleanup
SET @@global.max_binlog_cache_size=DEFAULT;
SET @@global.max_join_size=DEFAULT;
SET @@global.key_buffer_size=@kbs;
SET @@global.key_cache_block_size=@kcbs;
+
--echo End of 5.1 tests
+
+###########################################################################
+
+--echo
+--echo #
+--echo # Bug#34828: OF is taken as OFF and a value of 0 is set for variable SQL_notes.
+--echo #
+--echo
+
+--echo # Checking sql_notes...
+SET @sql_notes_saved = @@sql_notes;
+
+--echo
+SET @@sql_notes = ON;
+SELECT @@sql_notes;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@sql_notes = OF;
+SELECT @@sql_notes;
+
+--echo
+SET @@sql_notes = OFF;
+SELECT @@sql_notes;
+
+--echo
+SET @@sql_notes = @sql_notes_saved;
+
+--echo
+--echo # Checking delay_key_write...
+SET @delay_key_write_saved = @@delay_key_write;
+
+--echo
+SET GLOBAL delay_key_write = ON;
+SELECT @@delay_key_write;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL delay_key_write = OF;
+SELECT @@delay_key_write;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL delay_key_write = AL;
+SELECT @@delay_key_write;
+
+--echo
+SET GLOBAL delay_key_write = OFF;
+SELECT @@delay_key_write;
+
+--echo
+SET GLOBAL delay_key_write = ALL;
+SELECT @@delay_key_write;
+
+--echo
+SET GLOBAL delay_key_write = @delay_key_write_saved;
+
+--echo
+--echo # Checking sql_safe_updates...
+SET @sql_safe_updates_saved = @@sql_safe_updates;
+
+--echo
+SET @@sql_safe_updates = ON;
+SELECT @@sql_safe_updates;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@sql_safe_updates = OF;
+SELECT @@sql_safe_updates;
+
+--echo
+SET @@sql_safe_updates = OFF;
+SELECT @@sql_safe_updates;
+
+--echo
+SET @@sql_safe_updates = @sql_safe_updates_saved;
+
+--echo
+--echo # Checking foreign_key_checks...
+SET @foreign_key_checks_saved = @@foreign_key_checks;
+
+--echo
+SET @@foreign_key_checks = ON;
+SELECT @@foreign_key_checks;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@foreign_key_checks = OF;
+SELECT @@foreign_key_checks;
+
+--echo
+SET @@foreign_key_checks = OFF;
+SELECT @@foreign_key_checks;
+
+--echo
+SET @@foreign_key_checks = @foreign_key_checks_saved;
+
+--echo
+--echo # Checking unique_checks...
+SET @unique_checks_saved = @@unique_checks;
+
+--echo
+SET @@unique_checks = ON;
+SELECT @@unique_checks;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@unique_checks = OF;
+SELECT @@unique_checks;
+
+--echo
+SET @@unique_checks = OFF;
+SELECT @@unique_checks;
+
+--echo
+SET @@unique_checks = @unique_checks_saved;
+
+--echo
+--echo # Checking sql_buffer_result...
+SET @sql_buffer_result_saved = @@sql_buffer_result;
+
+--echo
+SET @@sql_buffer_result = ON;
+SELECT @@sql_buffer_result;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@sql_buffer_result = OF;
+SELECT @@sql_buffer_result;
+
+--echo
+SET @@sql_buffer_result = OFF;
+SELECT @@sql_buffer_result;
+
+--echo
+SET @@sql_buffer_result = @sql_buffer_result_saved;
+
+--echo
+--echo # Checking sql_quote_show_create...
+SET @sql_quote_show_create_saved = @@sql_quote_show_create;
+
+--echo
+SET @@sql_quote_show_create = ON;
+SELECT @@sql_quote_show_create;
+
+--echo
+--error ER_WRONG_VALUE_FOR_VAR
+SET @@sql_quote_show_create = OF;
+SELECT @@sql_quote_show_create;
+
+--echo
+SET @@sql_quote_show_create = OFF;
+SELECT @@sql_quote_show_create;
+
+--echo
+SET @@sql_quote_show_create = @sql_quote_show_create_saved;
+
+--echo
+--echo # End of Bug#34828.
+--echo
+
+--echo # Make sure we can manipulate with autocommit in the
+--echo # along with other variables.
+
+
+--disable_warnings
+drop table if exists t1;
+drop function if exists t1_max;
+drop function if exists t1_min;
+--enable_warnings
+
+create table t1 (a int) engine=innodb;
+insert into t1(a) values (0), (1);
+create function t1_max() returns int return (select max(a) from t1);
+create function t1_min() returns int return (select min(a) from t1);
+select t1_min();
+select t1_max();
+set @@session.autocommit=t1_min(), @@session.autocommit=t1_max(),
+ @@session.autocommit=t1_min(), @@session.autocommit=t1_max(),
+ @@session.autocommit=t1_min(), @@session.autocommit=t1_max();
+
+--echo # Cleanup.
+drop table t1;
+drop function t1_min;
+drop function t1_max;
+
+
+###########################################################################
+
+
+--echo #
+--echo # Bug #59884: setting charset to 2048 crashes
+--echo #
+
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_results = 2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_client=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_connection=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_server=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_server=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_filesystem=2048;
+--error ER_UNKNOWN_CHARACTER_SET
+set session character_set_database=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_connection=2048;
+--error ER_UNKNOWN_COLLATION
+set session collation_database=2048;
+
+--echo End of 5.5 tests
diff --git a/mysql-test/t/variables_community.test b/mysql-test/t/variables_community.test
index 0092d34133d..aa4bc6c631c 100644
--- a/mysql-test/t/variables_community.test
+++ b/mysql-test/t/variables_community.test
@@ -1,4 +1,4 @@
---source include/have_community_features.inc
+--source include/have_profiling.inc
#
# Bug#24822: Patch: uptime_since_flush_status
diff --git a/mysql-test/t/variables_debug.test b/mysql-test/t/variables_debug.test
index e6f1bbddc2a..6a3bc749b2a 100644
--- a/mysql-test/t/variables_debug.test
+++ b/mysql-test/t/variables_debug.test
@@ -13,6 +13,16 @@ select @@debug;
set debug= '-P';
select @@debug;
+#
+# Bug#38054: "SET SESSION debug" modifies @@global.debug variable
+#
+
+SELECT @@session.debug, @@global.debug;
+
+SET SESSION debug = '';
+
+SELECT @@session.debug, @@global.debug;
+
--echo #
--echo # Bug #52629: memory leak from sys_var_thd_dbug in
--echo # binlog.binlog_write_error
@@ -39,3 +49,78 @@ SELECT @@debug;
SET @@debug = @old_local_debug;
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Bug#46165 server crash in dbug
+--echo #
+
+SET @old_globaldebug = @@global.debug;
+SET @old_sessiondebug= @@session.debug;
+
+--echo # Test 1 - Bug test case, single connection
+SET GLOBAL debug= '+O,../../log/bug46165.1.trace';
+SET SESSION debug= '-d:-t:-i';
+
+SET GLOBAL debug= '';
+SET SESSION debug= '';
+
+--echo # Test 2 - Bug test case, two connections
+--echo # Connection default
+connection default;
+SET GLOBAL debug= '+O,../../log/bug46165.2.trace';
+SET SESSION debug= '-d:-t:-i';
+
+--echo # Connection con1
+connect (con1, localhost, root);
+SET GLOBAL debug= '';
+
+--echo # Connection default
+connection default;
+SET SESSION debug= '';
+--echo # Connection con1
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+--echo # Connection default
+connection default;
+SET GLOBAL debug= '';
+
+--echo # Test 3 - Active session trace file on disconnect
+--echo # Connection con1
+connect (con1, localhost, root);
+SET GLOBAL debug= '+O,../../log/bug46165.3.trace';
+SET SESSION debug= '-d:-t:-i';
+SET GLOBAL debug= '';
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Test 4 - Active session trace file on two connections
+--echo # Connection default
+connection default;
+SET GLOBAL debug= '+O,../../log/bug46165.4.trace';
+SET SESSION debug= '-d:-t:-i';
+
+--echo # Connection con1
+connect (con1, localhost, root);
+SET SESSION debug= '-d:-t:-i';
+SET GLOBAL debug= '';
+SET SESSION debug= '';
+
+--echo # Connection default
+connection default;
+SET SESSION debug= '';
+--echo # Connection con1
+connection con1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+--echo # Connection default
+connection default;
+
+--echo # Test 5 - Different trace files
+SET SESSION debug= '+O,../../log/bug46165.5.trace';
+SET SESSION debug= '+O,../../log/bug46165.6.trace';
+SET SESSION debug= '-O';
+
+SET GLOBAL debug= @old_globaldebug;
+SET SESSION debug= @old_sessiondebug;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index b1b3b5f2a83..39985bec339 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -1,3 +1,4 @@
+
--disable_warnings
drop table if exists t1,t2,t3,t4,t9,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6;
@@ -5,6 +6,9 @@ drop database if exists mysqltest;
--enable_warnings
use test;
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
#
# some basic test of views and its functionality
#
@@ -1016,6 +1020,7 @@ lock tables t1 read, v1 read;
select * from v1;
-- error ER_TABLE_NOT_LOCKED
select * from t2;
+unlock tables;
drop view v1;
drop table t1, t2;
@@ -3680,6 +3685,38 @@ SELECT * FROM v1 IGNORE INDEX (c2) WHERE c2=2;
DROP VIEW v1;
DROP TABLE t1;
+--echo #
+--echo # Bug #45806 crash when replacing into a view with a join!
+--echo #
+CREATE TABLE t1(a INT UNIQUE);
+CREATE VIEW v1 AS SELECT t1.a FROM t1, t1 AS a;
+INSERT INTO t1 VALUES (1), (2);
+
+REPLACE INTO v1(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v1;
+REPLACE INTO v1(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v1;
+DELETE FROM t1 WHERE a=3;
+INSERT INTO v1(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v1`.`a`= 1;
+SELECT * FROM v1;
+
+CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a;
+
+REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c;
+SELECT * FROM v2;
+REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c;
+SELECT * FROM v2;
+INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c
+ON DUPLICATE KEY UPDATE `v2`.`a`= 1;
+SELECT * FROM v2;
+
+DROP VIEW v1;
+DROP VIEW v2;
+DROP TABLE t1;
+
+--echo # -- End of test case for Bug#45806
+
--echo # -----------------------------------------------------------------
--echo # -- Bug#40825: Error 1356 while selecting from a view
--echo # -- with a "HAVING" clause though query works
@@ -3865,6 +3902,7 @@ drop procedure p;
--echo #
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT a FROM t1;
+--error ER_WRONG_OBJECT
ALTER TABLE v1;
DROP VIEW v1;
DROP TABLE t1;
@@ -3941,6 +3979,163 @@ DROP TABLE t1;
CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
DROP VIEW v1;
+--echo #
+--echo # Bug 11829681 - 60295: ERROR 1356 ON VIEW THAT EXECUTES FINE AS A QUERY
+--echo #
+
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT s.* FROM t1 s, t1 b HAVING a;
+
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------
+
+#
+# Bug#9801 (Views: imperfect error message)
+#
+
+--disable_warnings
+drop table if exists t_9801;
+drop view if exists v_9801;
+--enable_warnings
+
+create table t_9801 (s1 int);
+
+--error ER_VIEW_NONUPD_CHECK
+create view v_9801 as
+ select sum(s1) from t_9801 with check option;
+
+--error ER_VIEW_NONUPD_CHECK
+create view v_9801 as
+ select sum(s1) from t_9801 group by s1 with check option;
+
+ --error ER_VIEW_NONUPD_CHECK
+create view v_9801 as
+ select sum(s1) from t_9801 group by s1 with rollup with check option;
+
+drop table t_9801;
+
+--echo #
+--echo # Bug #47335 assert in get_table_share
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+CREATE TEMPORARY TABLE t1 (id INT);
+--error ER_NO_SUCH_TABLE
+ALTER VIEW t1 AS SELECT 1 AS f1;
+DROP TABLE t1;
+
+CREATE VIEW v1 AS SELECT 1 AS f1;
+CREATE TEMPORARY TABLE v1 (id INT);
+ALTER VIEW v1 AS SELECT 2 AS f1;
+DROP TABLE v1;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+
+--echo #
+--echo # Bug #47635 assert in start_waiting_global_read_lock
+--echo # during CREATE VIEW
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP VIEW IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (f1 integer);
+CREATE TEMPORARY TABLE IF NOT EXISTS t1 (f1 integer);
+CREATE TEMPORARY TABLE t2 (f1 integer);
+DROP TABLE t1;
+FLUSH TABLES WITH READ LOCK;
+--error ER_CANT_UPDATE_WITH_READLOCK
+CREATE VIEW t2 AS SELECT * FROM t1;
+
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Bug#48315 Metadata lock is not taken for merged views that
+--echo # use an INFORMATION_SCHEMA table
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+connect (con2, localhost, root);
+connect (con3, localhost, root);
+
+--echo # Connection default
+connection default;
+
+CREATE VIEW v1 AS SELECT schema_name FROM information_schema.schemata;
+CREATE TABLE t1 (str VARCHAR(50));
+CREATE PROCEDURE p1() INSERT INTO t1 SELECT * FROM v1;
+
+--echo # CALL p1() so the view is merged.
+CALL p1();
+
+--echo # Connection 3
+connection con3;
+LOCK TABLE t1 READ;
+
+--echo # Connection default
+connection default;
+--echo # Try to CALL p1() again, this time it should block for t1.
+--echo # Sending:
+--send CALL p1()
+
+--echo # Connection 2
+connection con2;
+let $wait_condition=
+ SELECT COUNT(*) = 1 from information_schema.processlist
+ WHERE state = "Waiting for table level lock" AND
+ info = "INSERT INTO t1 SELECT * FROM v1";
+--source include/wait_condition.inc
+--echo # ... then try to drop the view. This should block.
+--echo # Sending:
+--send DROP VIEW v1
+
+--echo # Connection 3
+connection con3;
+let $wait_condition=
+ SELECT COUNT(*) = 1 from information_schema.processlist
+ WHERE state = "Waiting for table metadata lock" AND info = "DROP VIEW v1";
+--source include/wait_condition.inc
+--echo # Now allow CALL p1() to complete
+UNLOCK TABLES;
+
+--echo # Connection default
+connection default;
+--echo # Reaping: CALL p1()
+--reap
+
+--echo # Connection 2
+connection con2;
+--echo # Reaping: DROP VIEW v1
+--reap
+
+--echo # Connection default
+connection default;
+DROP PROCEDURE p1;
+DROP TABLE t1;
+disconnect con2;
+disconnect con3;
+
+
+# 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
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index 21c6f376f8a..5896e25feda 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -1047,9 +1047,9 @@ GRANT SELECT ON db26813.t1 TO u26813@localhost;
connect (u1,localhost,u26813,,db26813);
connection u1;
---error ER_SPECIFIC_ACCESS_DENIED_ERROR
+--error ER_TABLEACCESS_DENIED_ERROR
ALTER VIEW v1 AS SELECT f2 FROM t1;
---error ER_SPECIFIC_ACCESS_DENIED_ERROR
+--error ER_TABLEACCESS_DENIED_ERROR
ALTER VIEW v2 AS SELECT f2 FROM t1;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
ALTER VIEW v3 AS SELECT f2 FROM t1;
@@ -1072,12 +1072,12 @@ CREATE USER u29908_1@localhost;
CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1;
CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS
SELECT f1 FROM t1;
-GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost;
-GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost;
+GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost;
+GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost;
GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost;
CREATE USER u29908_2@localhost;
-GRANT DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost;
-GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost;
+GRANT SELECT, DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost;
+GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost;
GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost;
connect (u2,localhost,u29908_2,,mysqltest_29908);
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 176f320e390..5569776904f 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -112,11 +112,6 @@ show variables like 'max_error_count';
drop table t1;
#
-# Test for deprecated table_type variable
-#
-set table_type=MYISAM;
-
-#
# Tests for show warnings limit a, b
#
create table t1 (a int);
@@ -233,3 +228,43 @@ DROP TABLE t1;
SHOW ERRORS;
--echo End of 5.0 tests
+
+#
+# Bug#55847: SHOW WARNINGS returns empty result set when SQLEXCEPTION is active
+#
+
+--echo
+--echo -- Bug#55847
+--echo
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TABLE t1(a INT UNIQUE);
+
+delimiter |;
+
+CREATE FUNCTION f1(x INT) RETURNS INT
+BEGIN
+ INSERT INTO t1 VALUES(x);
+ INSERT INTO t1 VALUES(x);
+ RETURN x;
+END|
+
+delimiter ;|
+
+--echo
+
+--error ER_DUP_ENTRY
+SHOW TABLES WHERE f1(11) = 11;
+
+--echo
+
+SHOW WARNINGS;
+
+--echo
+
+DROP TABLE t1;
+DROP FUNCTION f1;
diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test
index b7d31948d23..b7d31948d23 100755..100644
--- a/mysql-test/t/windows.test
+++ b/mysql-test/t/windows.test
diff --git a/mysql-test/t/wl4435_generated.inc b/mysql-test/t/wl4435_generated.inc
new file mode 100644
index 00000000000..5ea05a89402
--- /dev/null
+++ b/mysql-test/t/wl4435_generated.inc
@@ -0,0 +1,588 @@
+
+###########################################################################
+
+--echo
+--echo TINYINT
+--echo
+
+CREATE PROCEDURE p1(OUT v TINYINT)
+ SET v = 127;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 127;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo SMALLINT
+--echo
+
+CREATE PROCEDURE p1(OUT v SMALLINT)
+ SET v = 32767;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 32767;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo MEDIUMINT
+--echo
+
+CREATE PROCEDURE p1(OUT v MEDIUMINT)
+ SET v = 8388607;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 8388607;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo INT
+--echo
+
+CREATE PROCEDURE p1(OUT v INT)
+ SET v = 2147483647;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 2147483647;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo BIGINT
+--echo
+
+CREATE PROCEDURE p1(OUT v BIGINT)
+ SET v = 9223372036854775807;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 9223372036854775807;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo BIT(11)
+--echo
+
+CREATE PROCEDURE p1(OUT v BIT(11))
+ SET v = b'10100100101';
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = b'10100100101';
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo TIMESTAMP
+--echo
+
+CREATE PROCEDURE p1(OUT v TIMESTAMP)
+ SET v = '2007-11-18 15:01:02';
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = '2007-11-18 15:01:02';
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo DATETIME
+--echo
+
+CREATE PROCEDURE p1(OUT v DATETIME)
+ SET v = '1234-11-12 12:34:59';
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = '1234-11-12 12:34:59';
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo TIME
+--echo
+
+CREATE PROCEDURE p1(OUT v TIME)
+ SET v = '123:45:01';
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = '123:45:01';
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo DATE
+--echo
+
+CREATE PROCEDURE p1(OUT v DATE)
+ SET v = '1234-11-12';
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = '1234-11-12';
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo YEAR
+--echo
+
+CREATE PROCEDURE p1(OUT v YEAR)
+ SET v = 2010;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 2010;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo FLOAT(7, 4)
+--echo
+
+CREATE PROCEDURE p1(OUT v FLOAT(7, 4))
+ SET v = 123.4567;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a - 123.4567 < 0.00001;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo DOUBLE(8, 5)
+--echo
+
+CREATE PROCEDURE p1(OUT v DOUBLE(8, 5))
+ SET v = 123.45678;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a - 123.45678 < 0.000001;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo DECIMAL(9, 6)
+--echo
+
+CREATE PROCEDURE p1(OUT v DECIMAL(9, 6))
+ SET v = 123.456789;
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 123.456789;
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo CHAR(32)
+--echo
+
+CREATE PROCEDURE p1(OUT v CHAR(32))
+ SET v = REPEAT('a', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('a', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo VARCHAR(32)
+--echo
+
+CREATE PROCEDURE p1(OUT v VARCHAR(32))
+ SET v = REPEAT('b', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('b', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo TINYTEXT
+--echo
+
+CREATE PROCEDURE p1(OUT v TINYTEXT)
+ SET v = REPEAT('c', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('c', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo TEXT
+--echo
+
+CREATE PROCEDURE p1(OUT v TEXT)
+ SET v = REPEAT('d', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('d', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo MEDIUMTEXT
+--echo
+
+CREATE PROCEDURE p1(OUT v MEDIUMTEXT)
+ SET v = REPEAT('e', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('e', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo LONGTEXT
+--echo
+
+CREATE PROCEDURE p1(OUT v LONGTEXT)
+ SET v = REPEAT('f', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('f', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo BINARY(32)
+--echo
+
+CREATE PROCEDURE p1(OUT v BINARY(32))
+ SET v = REPEAT('g', 32);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('g', 32);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo VARBINARY(32)
+--echo
+
+CREATE PROCEDURE p1(OUT v VARBINARY(32))
+ SET v = REPEAT('h', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('h', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo TINYBLOB
+--echo
+
+CREATE PROCEDURE p1(OUT v TINYBLOB)
+ SET v = REPEAT('i', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('i', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo BLOB
+--echo
+
+CREATE PROCEDURE p1(OUT v BLOB)
+ SET v = REPEAT('j', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('j', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo MEDIUMBLOB
+--echo
+
+CREATE PROCEDURE p1(OUT v MEDIUMBLOB)
+ SET v = REPEAT('k', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('k', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo LONGBLOB
+--echo
+
+CREATE PROCEDURE p1(OUT v LONGBLOB)
+ SET v = REPEAT('l', 16);
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = REPEAT('l', 16);
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo SET('aaa', 'bbb')
+--echo
+
+CREATE PROCEDURE p1(OUT v SET('aaa', 'bbb'))
+ SET v = 'aaa';
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 'aaa';
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
+
+###########################################################################
+
+--echo
+--echo ENUM('aaa', 'bbb')
+--echo
+
+CREATE PROCEDURE p1(OUT v ENUM('aaa', 'bbb'))
+ SET v = 'aaa';
+
+PREPARE stmt1 FROM 'CALL p1(?)';
+EXECUTE stmt1 USING @a;
+
+CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1;
+
+SHOW CREATE TABLE tmp1;
+
+SELECT @a, @a = 'aaa';
+
+DROP TEMPORARY TABLE tmp1;
+DROP PROCEDURE p1;
diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test
index 9db8842f068..8ce9ce52960 100644
--- a/mysql-test/t/xa.test
+++ b/mysql-test/t/xa.test
@@ -3,6 +3,8 @@
#
-- source include/have_innodb.inc
+--source include/not_embedded.inc
+
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
@@ -76,9 +78,10 @@ xa rollback 'testa','testb';
xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
select * from t1;
-drop table t1;
disconnect con1;
+connection default;
+drop table t1;
#
# Bug#28323: Server crashed in xid cache operations
@@ -227,6 +230,157 @@ XA ROLLBACK 'xid1';
disconnect con1;
DROP TABLE t1;
+
+--echo #
+--echo # Bug#56448 Assertion failed: ! is_set() with second xa end
+--echo #
+
+XA START 'x';
+XA END 'x';
+# Second XA END caused an assertion.
+--error ER_XAER_RMFAIL
+XA END 'x';
+XA PREPARE 'x';
+# Second XA PREPARE also caused an assertion.
+--error ER_XAER_RMFAIL
+XA PREPARE 'x';
+XA ROLLBACK 'x';
+
+
+--echo #
+--echo # Bug#59986 Assert in Diagnostics_area::set_ok_status() for XA COMMIT
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a)) engine=InnoDB;
+INSERT INTO t1 VALUES (1, 1), (2, 2);
+
+--echo # Connection con1
+connect (con1, localhost, root);
+XA START 'a';
+UPDATE t1 SET b= 3 WHERE a=1;
+
+--echo # Connection default
+connection default;
+XA START 'b';
+UPDATE t1 SET b=4 WHERE a=2;
+--echo # Sending:
+--send UPDATE t1 SET b=5 WHERE a=1
+
+--echo # Connection con1
+connection con1;
+--sleep 1
+--error ER_LOCK_DEADLOCK
+UPDATE t1 SET b=6 WHERE a=2;
+# This used to trigger the assert
+--error ER_XA_RBDEADLOCK
+XA COMMIT 'a';
+
+--echo # Connection default
+connection default;
+--echo # Reaping: UPDATE t1 SET b=5 WHERE a=1
+--reap
+XA END 'b';
+XA ROLLBACK 'b';
+DROP TABLE t1;
+disconnect con1;
+
+
+--echo #
+--echo # Bug#11766752 59936: multiple xa assertions - transactional
+--echo # statement fuzzer
+--echo #
+
+CREATE TABLE t1 (a INT) engine=InnoDB;
+XA START 'a';
+INSERT INTO t1 VALUES (1);
+
+--error ER_XAER_RMFAIL
+SAVEPOINT savep;
+
+XA END 'a';
+--error ER_XAER_RMFAIL
+SELECT * FROM t1;
+--error ER_XAER_RMFAIL
+INSERT INTO t1 VALUES (2);
+--error ER_XAER_RMFAIL
+SAVEPOINT savep;
+--error ER_XAER_RMFAIL
+SET @a=(SELECT * FROM t1);
+
+XA PREPARE 'a';
+--error ER_XAER_RMFAIL
+SELECT * FROM t1; # used to cause InnoDB assert
+--error ER_XAER_RMFAIL
+INSERT INTO t1 VALUES (2); # used to cause InnoDB assert
+--error ER_XAER_RMFAIL
+SAVEPOINT savep;
+--error ER_XAER_RMFAIL
+SET @a=(SELECT * FROM t1); # used to cause InnoDB assert
+--error ER_XAER_RMFAIL
+UPDATE t1 SET a=1 WHERE a=2;
+
+XA COMMIT 'a';
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#12352846 - TRANS_XA_START(THD*):
+--echo # ASSERTION THD->TRANSACTION.XID_STATE.XID.IS_NULL()
+--echo # FAILED
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+
+--echo # Connection con2
+--connect (con2,localhost,root)
+XA START 'xid1';
+--echo # Sending:
+--send INSERT INTO t2 SELECT a FROM t1
+
+--echo # Connection default
+--connection default
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = "Sending data"
+ AND info = "INSERT INTO t2 SELECT a FROM t1";
+--echo # Waiting until INSERT ... is blocked
+--source include/wait_condition.inc
+DELETE FROM t1;
+COMMIT;
+
+--echo # Connection con2
+--connection con2
+--echo # Reaping: INSERT INTO t2 SELECT a FROM t1
+--error ER_LOCK_DEADLOCK
+--reap
+--error ER_XA_RBDEADLOCK
+XA COMMIT 'xid1';
+# This caused the assert to be triggered
+XA START 'xid1';
+
+XA END 'xid1';
+XA PREPARE 'xid1';
+XA ROLLBACK 'xid1';
+
+--echo # Connection default
+connection default;
+DROP TABLE t1, t2;
+disconnect con2;
+
+
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index 148c5701e61..89c0b8992b1 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -646,4 +646,24 @@ SELECT EXTRACTVALUE('', LPAD(0.1111E-15, '2011', 1));
SELECT UPDATEXML(CONVERT(_latin1'<' USING utf8),'1','1');
SELECT UPDATEXML(CONVERT(_latin1'<!--' USING utf8),'1','1');
+--echo #
+--echo # Bug#11766725 (bug#59901): EXTRACTVALUE STILL BROKEN AFTER FIX FOR BUG #44332
+--echo #
+SELECT ExtractValue(CONVERT('<\"', BINARY(10)), 1);
+
--echo End of 5.1 tests
+
+
+--echo #
+--echo # Start of 5.5 tests
+--echo #
+
+--echo #
+--echo # Bug#58175 xml functions read initialized bytes when conversions happen
+--echo #
+SET NAMES latin1;
+SELECT UPDATEXML(CONVERT('' USING swe7), TRUNCATE('',1), 0);
+
+--echo #
+--echo # End of 5.5 tests
+--echo #