summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Ronstrom <mikael@mysql.com>2009-06-11 12:07:59 +0200
committerMikael Ronstrom <mikael@mysql.com>2009-06-11 12:07:59 +0200
commit506c7fd47dd28e5726852e47d117bfbb37677005 (patch)
tree796cc97d1d103e18e0672d9b57dee4c54857073c
parent4557f4ee9e9975966be6fa7c4fa553b30992ca6d (diff)
parentfbb96b339ae5fcce19446fd27a2fb75e49b960f8 (diff)
downloadmariadb-git-506c7fd47dd28e5726852e47d117bfbb37677005.tar.gz
Merge MySQL 5.1.35 into MySQL 5.4
-rw-r--r--.bzrignore2
-rwxr-xr-xCMakeLists.txt8
-rw-r--r--README10
-rw-r--r--client/my_readline.h2
-rw-r--r--client/mysql.cc77
-rw-r--r--client/mysqladmin.cc2
-rw-r--r--client/mysqlbinlog.cc18
-rw-r--r--client/mysqlcheck.c9
-rw-r--r--client/mysqldump.c18
-rw-r--r--client/mysqlslap.c2
-rw-r--r--client/mysqltest.cc54
-rw-r--r--client/readline.cc46
-rw-r--r--client/sql_string.cc21
-rw-r--r--cmd-line-utils/libedit/term.c2
-rw-r--r--config/ac-macros/ha_ndbcluster.m440
-rw-r--r--config/ac-macros/misc.m413
-rw-r--r--config/ac-macros/plugins.m485
-rw-r--r--configure.in41
-rw-r--r--extra/comp_err.c2
-rw-r--r--extra/yassl/src/buffer.cpp4
-rw-r--r--extra/yassl/taocrypt/include/block.hpp2
-rw-r--r--extra/yassl/taocrypt/src/algebra.cpp2
-rw-r--r--extra/yassl/taocrypt/src/asn.cpp2
-rw-r--r--include/config-win.h9
-rw-r--r--include/my_getopt.h2
-rw-r--r--include/my_global.h58
-rw-r--r--include/my_md5.h90
-rw-r--r--include/my_sys.h8
-rw-r--r--include/thr_lock.h4
-rw-r--r--libmysql/libmysql.c10
-rw-r--r--libmysqld/CMakeLists.txt2
-rw-r--r--libmysqld/examples/CMakeLists.txt6
-rw-r--r--libmysqld/lib_sql.cc9
-rw-r--r--mysql-test/Makefile.am8
-rw-r--r--mysql-test/collections/README30
-rw-r--r--mysql-test/collections/README.experimental25
-rw-r--r--mysql-test/collections/default.daily1
-rw-r--r--mysql-test/collections/default.experimental1
-rw-r--r--mysql-test/collections/default.push5
-rw-r--r--mysql-test/collections/default.weekly0
-rw-r--r--mysql-test/extra/binlog_tests/binlog.test40
-rw-r--r--mysql-test/extra/rpl_tests/rpl_deadlock.test197
-rw-r--r--mysql-test/extra/rpl_tests/rpl_loadfile.test36
-rw-r--r--mysql-test/include/check-warnings.test2
-rw-r--r--mysql-test/include/concurrent.inc55
-rw-r--r--mysql-test/include/diff_master_slave.inc21
-rw-r--r--mysql-test/include/handler.inc36
-rw-r--r--mysql-test/include/kill_query.inc68
-rw-r--r--mysql-test/include/kill_query_and_diff_master_slave.inc43
-rw-r--r--mysql-test/include/mix1.inc60
-rw-r--r--mysql-test/include/ndb_backup.inc42
-rw-r--r--mysql-test/include/setup_fake_relay_log.inc4
-rw-r--r--mysql-test/include/wait_for_query_to_succeed.inc (renamed from mysql-test/include/wait_for_query_to_suceed.inc)4
-rw-r--r--mysql-test/include/wait_for_status_var.inc68
-rw-r--r--mysql-test/include/wait_show_condition.inc78
-rw-r--r--mysql-test/include/wait_until_count_sessions.inc46
-rw-r--r--mysql-test/lib/My/ConfigFactory.pm8
-rw-r--r--mysql-test/lib/My/CoreDump.pm127
-rw-r--r--mysql-test/lib/My/Platform.pm10
-rw-r--r--mysql-test/lib/My/SafeProcess.pm2
-rw-r--r--mysql-test/lib/My/SafeProcess/safe_process.cc17
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_process_win.cc19
-rw-r--r--mysql-test/lib/mtr_gcov.pl58
-rw-r--r--mysql-test/lib/mtr_report.pm40
-rw-r--r--mysql-test/lib/mtr_unique.pm2
-rwxr-xr-xmysql-test/mysql-test-run.pl192
-rw-r--r--mysql-test/r/archive_gis.result6
-rw-r--r--mysql-test/r/backup.result26
-rw-r--r--mysql-test/r/concurrent_innodb_safelog.result28
-rw-r--r--mysql-test/r/concurrent_innodb_unsafelog.result28
-rw-r--r--mysql-test/r/connect.result2
-rw-r--r--mysql-test/r/consistent_snapshot.result32
-rw-r--r--mysql-test/r/count_distinct3.result5
-rw-r--r--mysql-test/r/create.result4
-rw-r--r--mysql-test/r/ctype_collate.result19
-rw-r--r--mysql-test/r/ddl_i18n_koi8r.result24
-rw-r--r--mysql-test/r/ddl_i18n_utf8.result24
-rw-r--r--mysql-test/r/dirty_close.result10
-rw-r--r--mysql-test/r/events_bugs.result11
-rw-r--r--mysql-test/r/explain.result5
-rw-r--r--mysql-test/r/flush_block_commit.result74
-rw-r--r--mysql-test/r/flush_block_commit_notembedded.result30
-rw-r--r--mysql-test/r/flush_read_lock_kill.result20
-rw-r--r--mysql-test/r/fulltext.result12
-rw-r--r--mysql-test/r/func_des_encrypt.result34
-rw-r--r--mysql-test/r/func_encrypt.result7
-rw-r--r--mysql-test/r/func_group.result8
-rw-r--r--mysql-test/r/func_math.result40
-rw-r--r--mysql-test/r/func_misc.result3
-rw-r--r--mysql-test/r/func_set.result43
-rw-r--r--mysql-test/r/func_str.result24
-rw-r--r--mysql-test/r/gis-rtree.result668
-rw-r--r--mysql-test/r/gis.result22
-rw-r--r--mysql-test/r/grant.result36
-rw-r--r--mysql-test/r/group_by.result12
-rw-r--r--mysql-test/r/group_min_max.result15
-rw-r--r--mysql-test/r/handler_innodb.result13
-rw-r--r--mysql-test/r/handler_myisam.result13
-rw-r--r--mysql-test/r/index_merge_myisam.result171
-rw-r--r--mysql-test/r/information_schema.result29
-rw-r--r--mysql-test/r/information_schema_db.result2
-rw-r--r--mysql-test/r/innodb-autoinc.result288
-rw-r--r--mysql-test/r/innodb-semi-consistent.result7
-rw-r--r--mysql-test/r/innodb.result60
-rw-r--r--mysql-test/r/innodb_bug42419.result17
-rw-r--r--mysql-test/r/innodb_gis.result6
-rw-r--r--mysql-test/r/innodb_mysql.result194
-rw-r--r--mysql-test/r/insert.result5
-rw-r--r--mysql-test/r/key_cache.result2
-rw-r--r--mysql-test/r/lock.result27
-rw-r--r--mysql-test/r/lock_multi.result99
-rw-r--r--mysql-test/r/lock_multi_bug38499.result19
-rw-r--r--mysql-test/r/lock_multi_bug38691.result17
-rw-r--r--mysql-test/r/log_tables.result20
-rw-r--r--mysql-test/r/lowercase_table3.result16
-rw-r--r--mysql-test/r/lowercase_utf8.result9
-rw-r--r--mysql-test/r/merge.result88
-rw-r--r--mysql-test/r/multi_update.result10
-rw-r--r--mysql-test/r/myisam.result26
-rw-r--r--mysql-test/r/myisam_crash_before_flush_keys.result45
-rw-r--r--mysql-test/r/myisam_debug.result39
-rw-r--r--mysql-test/r/myisampack.result33
-rw-r--r--mysql-test/r/mysql-bug41486.result13
-rw-r--r--mysql-test/r/mysql.result4
-rw-r--r--mysql-test/r/mysqlbinlog.result73
-rw-r--r--mysql-test/r/mysqlbinlog_row_big.result48
-rw-r--r--mysql-test/r/mysqlcheck.result2
-rw-r--r--mysql-test/r/mysqldump-max.result72
-rw-r--r--mysql-test/r/mysqldump.result506
-rw-r--r--mysql-test/r/mysqltest.result8
-rw-r--r--mysql-test/r/not_embedded_server.result3
-rw-r--r--mysql-test/r/openssl_1.result18
-rw-r--r--mysql-test/r/packet.result4
-rw-r--r--mysql-test/r/parser.result7
-rw-r--r--mysql-test/r/parser_not_embedded.result49
-rw-r--r--mysql-test/r/partition.result17
-rw-r--r--mysql-test/r/partition_error.result9
-rw-r--r--mysql-test/r/partition_mgm.result9
-rw-r--r--mysql-test/r/partition_mgm_err.result4
-rw-r--r--mysql-test/r/preload.result4
-rw-r--r--mysql-test/r/ps.result16
-rw-r--r--mysql-test/r/ps_1general.result8
-rw-r--r--mysql-test/r/query_cache_debug.result49
-rw-r--r--mysql-test/r/query_cache_notembedded.result1
-rw-r--r--mysql-test/r/read_only.result38
-rw-r--r--mysql-test/r/repair.result4
-rw-r--r--mysql-test/r/row.result14
-rw-r--r--mysql-test/r/select.result55
-rw-r--r--mysql-test/r/shm.result7
-rw-r--r--mysql-test/r/show_check.result14
-rw-r--r--mysql-test/r/skip_name_resolve.result9
-rw-r--r--mysql-test/r/sp-error.result2
-rw-r--r--mysql-test/r/sp-security.result14
-rw-r--r--mysql-test/r/sp.result31
-rw-r--r--mysql-test/r/sp_trans.result2
-rw-r--r--mysql-test/r/strict.result6
-rw-r--r--mysql-test/r/subselect.result252
-rw-r--r--mysql-test/r/synchronization.result44
-rw-r--r--mysql-test/r/system_mysql_db.result6
-rw-r--r--mysql-test/r/trigger-compat.result4
-rw-r--r--mysql-test/r/trigger.result20
-rw-r--r--mysql-test/r/type_blob.result4
-rw-r--r--mysql-test/r/type_datetime.result19
-rw-r--r--mysql-test/r/type_float.result18
-rw-r--r--mysql-test/r/type_timestamp.result14
-rw-r--r--mysql-test/r/union.result28
-rw-r--r--mysql-test/r/upgrade.result32
-rw-r--r--mysql-test/r/varbinary.result2
-rw-r--r--mysql-test/r/variables-big.result30
-rw-r--r--mysql-test/r/variables-notembedded.result6
-rw-r--r--mysql-test/r/variables.result161
-rw-r--r--mysql-test/r/view.result70
-rw-r--r--mysql-test/r/view_grant.result56
-rw-r--r--mysql-test/r/warnings.result2
-rw-r--r--mysql-test/r/windows.result18
-rw-r--r--mysql-test/r/xml.result29
-rw-r--r--mysql-test/std_data/bug37631.MYD0
-rw-r--r--mysql-test/std_data/bug37631.MYIbin0 -> 1024 bytes
-rw-r--r--mysql-test/std_data/bug37631.frmbin0 -> 8590 bytes
-rw-r--r--mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result1
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_binlog.result32
-rw-r--r--mysql-test/suite/binlog/r/binlog_sql_mode.result46
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_binlog.result32
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_ps.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_unsafe.result205
-rw-r--r--mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test5
-rw-r--r--mysql-test/suite/binlog/t/binlog_sql_mode.test76
-rw-r--r--mysql-test/suite/binlog/t/binlog_unsafe.test122
-rw-r--r--mysql-test/suite/bugs/r/rpl_bug38205.result56
-rw-r--r--mysql-test/suite/bugs/t/rpl_bug38205.test166
-rw-r--r--mysql-test/suite/federated/federated.result20
-rw-r--r--mysql-test/suite/federated/federated.test22
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_func_view.result4
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_storedproc_08.result213
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_trig_0102.result6
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_trig_0407.result14
-rw-r--r--mysql-test/suite/funcs_1/r/innodb_views.result8
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_innodb.result256
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is.result5
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_memory.result256
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_myisam.result256
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_mysql.result12
-rw-r--r--mysql-test/suite/funcs_1/r/memory_func_view.result4
-rw-r--r--mysql-test/suite/funcs_1/r/memory_storedproc_08.result213
-rw-r--r--mysql-test/suite/funcs_1/r/memory_trig_0102.result6
-rw-r--r--mysql-test/suite/funcs_1/r/memory_trig_0407.result14
-rw-r--r--mysql-test/suite/funcs_1/r/memory_views.result8
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_func_view.result4
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_storedproc_08.result213
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_trig_0102.result6
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_trig_0407.result14
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_views.result8
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_func_view.result4
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_storedproc_08.result213
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_trig_0102.result6
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_trig_0407.result14
-rw-r--r--mysql-test/suite/funcs_1/r/ndb_views.result8
-rw-r--r--mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result4
-rw-r--r--mysql-test/suite/funcs_1/r/processlist_priv_ps.result4
-rw-r--r--mysql-test/suite/funcs_1/r/processlist_val_no_prot.result2
-rw-r--r--mysql-test/suite/funcs_1/r/processlist_val_ps.result2
-rw-r--r--mysql-test/suite/funcs_1/r/storedproc.result42
-rw-r--r--mysql-test/suite/funcs_1/storedproc/storedproc_08_show.inc9
-rw-r--r--mysql-test/suite/funcs_1/t/disabled.def5
-rw-r--r--mysql-test/suite/funcs_1/t/storedproc.test18
-rw-r--r--mysql-test/suite/funcs_1/triggers/triggers_0102.inc4
-rw-r--r--mysql-test/suite/funcs_1/triggers/triggers_0407.inc6
-rw-r--r--mysql-test/suite/funcs_2/charset/charset_master.test9
-rw-r--r--mysql-test/suite/ibmdb2i/include/have_i61.inc20
-rw-r--r--mysql-test/suite/ibmdb2i/include/have_ibmdb2i.inc6
-rw-r--r--mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44020.result11
-rw-r--r--mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44025.result4
-rw-r--r--mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44020.test9
-rw-r--r--mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44025.test9
-rw-r--r--mysql-test/suite/ndb/r/ndb_gis.result12
-rw-r--r--mysql-test/suite/ndb/r/ndb_restore.result15
-rw-r--r--mysql-test/suite/ndb/r/ndb_restore_partition.result15
-rw-r--r--mysql-test/suite/ndb/r/ndb_restore_print.result15
-rw-r--r--mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result15
-rw-r--r--mysql-test/suite/ndb_team/t/ndb_autodiscover.test6
-rw-r--r--mysql-test/suite/parts/inc/partition_auto_increment.inc39
-rw-r--r--mysql-test/suite/parts/r/ndb_dd_backuprestore.result15
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result112
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result32
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_innodb.result64
-rw-r--r--mysql-test/suite/parts/r/partition_alter1_1_myisam.result32
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_1_innodb.result192
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_1_myisam.result96
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_2_innodb.result192
-rw-r--r--mysql-test/suite/parts/r/partition_alter2_2_myisam.result96
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_blackhole.result7
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_ndb.result1
-rw-r--r--mysql-test/suite/parts/r/partition_basic_innodb.result96
-rw-r--r--mysql-test/suite/parts/r/partition_basic_myisam.result32
-rw-r--r--mysql-test/suite/parts/r/partition_basic_symlink_myisam.result46
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_archive.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_memory.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result4
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_archive.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_memory.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result4
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_archive.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_memory.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result12
-rw-r--r--mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result4
-rw-r--r--mysql-test/suite/rpl/include/rpl_mixed_ddl.inc2
-rw-r--r--mysql-test/suite/rpl/r/rpl_bug33931.result10
-rw-r--r--mysql-test/suite/rpl/r/rpl_bug38694.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_deadlock_innodb.result148
-rw-r--r--mysql-test/suite/rpl/r/rpl_do_grant.result78
-rw-r--r--mysql-test/suite/rpl/r/rpl_drop_if_exists.result98
-rw-r--r--mysql-test/suite/rpl/r/rpl_failed_optimize.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_idempotency.result20
-rw-r--r--mysql-test/suite/rpl/r/rpl_init_slave_errors.result18
-rw-r--r--mysql-test/suite/rpl/r/rpl_killed_ddl.result169
-rw-r--r--mysql-test/suite/rpl/r/rpl_loaddatalocal.result25
-rw-r--r--mysql-test/suite/rpl/r/rpl_loadfile.result18
-rw-r--r--mysql-test/suite/rpl/r/rpl_mixed_bit_pk.result32
-rw-r--r--mysql-test/suite/rpl/r/rpl_name_const.result28
-rw-r--r--mysql-test/suite/rpl/r/rpl_rotate_logs.result4
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_until.result77
-rw-r--r--mysql-test/suite/rpl/r/rpl_row_wide_table.result318
-rw-r--r--mysql-test/suite/rpl/r/rpl_skip_error.result74
-rw-r--r--mysql-test/suite/rpl/r/rpl_slave_load_in.result19
-rw-r--r--mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result53
-rw-r--r--mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result6
-rw-r--r--mysql-test/suite/rpl/r/rpl_sp.result22
-rw-r--r--mysql-test/suite/rpl/r/rpl_start_stop_slave.result28
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_loadfile.result231
-rw-r--r--mysql-test/suite/rpl/r/rpl_stm_log.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result26
-rw-r--r--mysql-test/suite/rpl/r/rpl_temporary.result13
-rw-r--r--mysql-test/suite/rpl/r/rpl_timezone.result19
-rw-r--r--mysql-test/suite/rpl/r/rpl_udf.result8
-rw-r--r--mysql-test/suite/rpl/t/disabled.def2
-rwxr-xr-xmysql-test/suite/rpl/t/rpl_000015-slave.sh1
-rw-r--r--mysql-test/suite/rpl/t/rpl_binlog_corruption.test1
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug33931.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug38694-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_bug38694.test10
-rw-r--r--mysql-test/suite/rpl/t/rpl_cross_version.test5
-rw-r--r--mysql-test/suite/rpl/t/rpl_do_grant.test97
-rw-r--r--mysql-test/suite/rpl/t/rpl_drop_if_exists.test115
-rw-r--r--mysql-test/suite/rpl/t/rpl_idempotency.test16
-rw-r--r--mysql-test/suite/rpl/t/rpl_init_slave_errors.test86
-rw-r--r--mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_killed_ddl.test352
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddatalocal.test34
-rw-r--r--mysql-test/suite/rpl/t/rpl_loadfile.test126
-rw-r--r--mysql-test/suite/rpl/t/rpl_mixed_bit_pk.test78
-rw-r--r--mysql-test/suite/rpl/t/rpl_name_const.test47
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs.test24
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_until.test121
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_wide_table.test339
-rw-r--r--mysql-test/suite/rpl/t/rpl_skip_error.test105
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_load_in.test50
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test49
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test24
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_stop_slave-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_stop_slave.test87
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_loadfile.test20
-rw-r--r--mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test53
-rw-r--r--mysql-test/suite/rpl/t/rpl_temporary.test38
-rw-r--r--mysql-test/suite/rpl/t/rpl_timezone.test27
-rw-r--r--mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result5
-rw-r--r--mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc1
-rw-r--r--mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc1
-rw-r--r--mysql-test/suite/sys_vars/r/auto_increment_increment_basic.result10
-rw-r--r--mysql-test/suite/sys_vars/r/auto_increment_increment_func.result2
-rw-r--r--mysql-test/suite/sys_vars/r/auto_increment_offset_basic.result10
-rw-r--r--mysql-test/suite/sys_vars/r/auto_increment_offset_func.result2
-rw-r--r--mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result2
-rw-r--r--mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/completion_type_func.result155
-rw-r--r--mysql-test/suite/sys_vars/r/concurrent_insert_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/connect_timeout_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/default_week_format_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result2
-rw-r--r--mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result202
-rw-r--r--mysql-test/suite/sys_vars/r/delayed_insert_timeout_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result2
-rw-r--r--mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/r/div_precision_increment_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/event_scheduler_func.result44
-rw-r--r--mysql-test/suite/sys_vars/r/expire_logs_days_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result4
-rw-r--r--mysql-test/suite/sys_vars/r/group_concat_max_len_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/interactive_timeout_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/interactive_timeout_func.result17
-rw-r--r--mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result10
-rw-r--r--mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result8
-rw-r--r--mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result6
-rw-r--r--mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result26
-rw-r--r--mysql-test/suite/sys_vars/r/log_warnings_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/log_warnings_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result6
-rw-r--r--mysql-test/suite/sys_vars/r/max_binlog_size_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_connections_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_delayed_threads_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_error_count_basic.result8
-rw-r--r--mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result20
-rw-r--r--mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result6
-rw-r--r--mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_length_for_sort_data_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_relay_log_size_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_sort_length_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_sp_recursion_depth_basic.result8
-rw-r--r--mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result8
-rw-r--r--mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result8
-rw-r--r--mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/myisam_data_pointer_size_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result6
-rw-r--r--mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result8
-rw-r--r--mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/net_buffer_length_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/net_read_timeout_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/net_write_timeout_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/optimizer_search_depth_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/preload_buffer_size_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result13
-rw-r--r--mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result34
-rw-r--r--mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result4
-rw-r--r--mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/read_buffer_size_basic.result10
-rw-r--r--mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result10
-rw-r--r--mysql-test/suite/sys_vars/r/rpl_init_slave_func.result2
-rw-r--r--mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result5
-rw-r--r--mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result12
-rw-r--r--mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result6
-rw-r--r--mysql-test/suite/sys_vars/r/server_id_basic_32.result6
-rw-r--r--mysql-test/suite/sys_vars/r/server_id_basic_64.result8
-rw-r--r--mysql-test/suite/sys_vars/r/slave_net_timeout_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result2
-rw-r--r--mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/r/slow_launch_time_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/slow_query_log_func.result4
-rw-r--r--mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result2
-rw-r--r--mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result26
-rw-r--r--mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result4
-rw-r--r--mysql-test/suite/sys_vars/r/table_definition_cache_basic.result2
-rw-r--r--mysql-test/suite/sys_vars/r/table_lock_wait_timeout_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/table_open_cache_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/tmp_table_size_basic.result4
-rw-r--r--mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result2
-rw-r--r--mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result2
-rw-r--r--mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result2
-rw-r--r--mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result2
-rw-r--r--mysql-test/suite/sys_vars/t/completion_type_func-master.opt1
-rw-r--r--mysql-test/suite/sys_vars/t/completion_type_func.test136
-rw-r--r--mysql-test/suite/sys_vars/t/concurrent_insert_func.test8
-rw-r--r--mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test233
-rw-r--r--mysql-test/suite/sys_vars/t/event_scheduler_func.test91
-rw-r--r--mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test2
-rw-r--r--mysql-test/suite/sys_vars/t/interactive_timeout_func.test76
-rw-r--r--mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test21
-rw-r--r--mysql-test/suite/sys_vars/t/rpl_init_slave_func.test2
-rw-r--r--mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test6
-rw-r--r--mysql-test/suite/sys_vars/t/slow_query_log_func.test6
-rw-r--r--mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test56
-rw-r--r--mysql-test/suite/sys_vars/t/timestamp_func.test2
-rw-r--r--mysql-test/suite/sys_vars/t/wait_timeout_func.test2
-rw-r--r--mysql-test/t/alter_table-big.test9
-rw-r--r--mysql-test/t/backup.test16
-rw-r--r--mysql-test/t/check.test21
-rw-r--r--mysql-test/t/compress.test11
-rw-r--r--mysql-test/t/connect.test84
-rw-r--r--mysql-test/t/consistent_snapshot.test44
-rw-r--r--mysql-test/t/count_distinct3.test39
-rw-r--r--mysql-test/t/ctype_collate.test14
-rw-r--r--mysql-test/t/ddl_i18n_koi8r.test50
-rw-r--r--mysql-test/t/ddl_i18n_utf8.test50
-rw-r--r--mysql-test/t/dirty_close.test21
-rw-r--r--mysql-test/t/disabled.def5
-rw-r--r--mysql-test/t/drop.test25
-rw-r--r--mysql-test/t/events_bugs.test12
-rw-r--r--mysql-test/t/explain.test17
-rw-r--r--mysql-test/t/flush_block_commit.test96
-rw-r--r--mysql-test/t/flush_block_commit_notembedded.test47
-rw-r--r--mysql-test/t/flush_read_lock_kill.test33
-rw-r--r--mysql-test/t/fulltext.test17
-rw-r--r--mysql-test/t/func_des_encrypt.test28
-rw-r--r--mysql-test/t/func_encrypt.test15
-rw-r--r--mysql-test/t/func_group.test2
-rw-r--r--mysql-test/t/func_math.test21
-rw-r--r--mysql-test/t/func_misc.test5
-rw-r--r--mysql-test/t/func_set.test12
-rw-r--r--mysql-test/t/func_str.test21
-rw-r--r--mysql-test/t/gis-rtree.test72
-rw-r--r--mysql-test/t/gis.test15
-rw-r--r--mysql-test/t/grant.test214
-rw-r--r--mysql-test/t/group_by.test18
-rw-r--r--mysql-test/t/group_min_max.test22
-rw-r--r--mysql-test/t/index_merge_myisam.test167
-rw-r--r--mysql-test/t/information_schema.test183
-rw-r--r--mysql-test/t/init_connect.test10
-rw-r--r--mysql-test/t/innodb-autoinc.test88
-rw-r--r--mysql-test/t/innodb-semi-consistent.test13
-rw-r--r--mysql-test/t/innodb.test57
-rw-r--r--mysql-test/t/innodb_bug42419.test78
-rw-r--r--mysql-test/t/innodb_mysql.test148
-rw-r--r--mysql-test/t/insert.test9
-rw-r--r--mysql-test/t/lock.test30
-rw-r--r--mysql-test/t/lock_multi.test510
-rw-r--r--mysql-test/t/lock_multi_bug38499.test221
-rw-r--r--mysql-test/t/lock_multi_bug38691.test141
-rw-r--r--mysql-test/t/log_tables.test4
-rw-r--r--mysql-test/t/lowercase_table3.test19
-rw-r--r--mysql-test/t/lowercase_utf8-master.opt4
-rw-r--r--mysql-test/t/lowercase_utf8.test9
-rw-r--r--mysql-test/t/merge.test104
-rw-r--r--mysql-test/t/multi_update.test74
-rw-r--r--mysql-test/t/myisam.test25
-rw-r--r--mysql-test/t/myisam_crash_before_flush_keys-master.opt1
-rw-r--r--mysql-test/t/myisam_crash_before_flush_keys.test49
-rw-r--r--mysql-test/t/myisam_debug.test57
-rw-r--r--mysql-test/t/myisampack.test46
-rw-r--r--mysql-test/t/mysql-bug41486.test50
-rw-r--r--mysql-test/t/mysql.test73
-rw-r--r--mysql-test/t/mysqlbinlog.test101
-rw-r--r--mysql-test/t/mysqlbinlog_row_big.test56
-rw-r--r--mysql-test/t/mysqldump-compat.test8
-rw-r--r--mysql-test/t/mysqldump.test31
-rw-r--r--mysql-test/t/mysqltest.test163
-rw-r--r--mysql-test/t/not_embedded_server.test6
-rw-r--r--mysql-test/t/overflow.test10
-rw-r--r--mysql-test/t/packet.test20
-rw-r--r--mysql-test/t/parser.test4
-rw-r--r--mysql-test/t/parser_not_embedded.test26
-rw-r--r--mysql-test/t/partition.test21
-rw-r--r--mysql-test/t/partition_error.test15
-rw-r--r--mysql-test/t/partition_mgm.test3
-rw-r--r--mysql-test/t/ps.test31
-rw-r--r--mysql-test/t/ps_1general.test83
-rw-r--r--mysql-test/t/query_cache_28249.test1
-rw-r--r--mysql-test/t/query_cache_debug.test68
-rw-r--r--mysql-test/t/query_cache_notembedded.test18
-rw-r--r--mysql-test/t/read_only.test80
-rw-r--r--mysql-test/t/rename.test22
-rw-r--r--mysql-test/t/row.test18
-rw-r--r--mysql-test/t/select.test30
-rw-r--r--mysql-test/t/shm.test19
-rw-r--r--mysql-test/t/show_check.test101
-rw-r--r--mysql-test/t/skip_name_resolve.test23
-rw-r--r--mysql-test/t/sp-security.test52
-rw-r--r--mysql-test/t/sp-threads.test29
-rw-r--r--mysql-test/t/sp.test63
-rw-r--r--mysql-test/t/sp_notembedded.test35
-rw-r--r--mysql-test/t/sp_trans_log.test12
-rw-r--r--mysql-test/t/ssl-big.test28
-rw-r--r--mysql-test/t/ssl.test8
-rw-r--r--mysql-test/t/ssl_compress.test10
-rw-r--r--mysql-test/t/status.test10
-rw-r--r--mysql-test/t/strict.test4
-rw-r--r--mysql-test/t/subselect.test598
-rw-r--r--mysql-test/t/synchronization.test22
-rw-r--r--mysql-test/t/timezone_grant.test41
-rw-r--r--mysql-test/t/trigger-compat.test25
-rw-r--r--mysql-test/t/trigger.test33
-rw-r--r--mysql-test/t/type_bit_innodb.test2
-rw-r--r--mysql-test/t/type_datetime.test19
-rw-r--r--mysql-test/t/type_float.test9
-rw-r--r--mysql-test/t/union.test58
-rw-r--r--mysql-test/t/upgrade.test50
-rw-r--r--mysql-test/t/user_limits.test41
-rw-r--r--mysql-test/t/variables-big.test57
-rw-r--r--mysql-test/t/variables-notembedded-master.opt2
-rw-r--r--mysql-test/t/variables.test139
-rw-r--r--mysql-test/t/view.test823
-rw-r--r--mysql-test/t/view_grant.test277
-rw-r--r--mysql-test/t/wait_timeout.test13
-rwxr-xr-xmysql-test/t/windows.test31
-rw-r--r--mysql-test/t/xa.test28
-rw-r--r--mysql-test/t/xml.test27
-rw-r--r--mysys/array.c2
-rw-r--r--mysys/base64.c2
-rw-r--r--mysys/charset.c43
-rw-r--r--mysys/checksum.c2
-rw-r--r--mysys/default.c89
-rw-r--r--mysys/default_modify.c4
-rw-r--r--mysys/errors.c16
-rw-r--r--mysys/hash.c13
-rw-r--r--mysys/md5.c567
-rw-r--r--mysys/mf_keycache.c8
-rw-r--r--mysys/mf_tempdir.c2
-rw-r--r--mysys/my_append.c2
-rw-r--r--mysys/my_compress.c4
-rw-r--r--mysys/my_conio.c2
-rw-r--r--mysys/my_copy.c2
-rw-r--r--mysys/my_error.c13
-rw-r--r--mysys/my_fstream.c6
-rw-r--r--mysys/my_getopt.c20
-rw-r--r--mysys/my_getwd.c2
-rw-r--r--mysys/my_init.c4
-rw-r--r--mysys/my_new.cc5
-rw-r--r--mysys/my_pread.c10
-rw-r--r--mysys/my_quick.c4
-rw-r--r--mysys/my_read.c2
-rw-r--r--mysys/my_write.c6
-rw-r--r--mysys/safemalloc.c2
-rw-r--r--mysys/string.c8
-rw-r--r--plugin/Makefile.am2
-rw-r--r--scripts/make_binary_distribution.sh9
-rwxr-xr-xscripts/make_win_bin_dist2
-rw-r--r--scripts/mysql_setpermission.sh2
-rw-r--r--scripts/mysql_system_tables.sql6
-rw-r--r--scripts/mysql_system_tables_fix.sql19
-rw-r--r--scripts/mysqld_multi.sh5
-rw-r--r--scripts/mysqld_safe.sh48
-rw-r--r--scripts/mysqldumpslow.sh4
-rw-r--r--scripts/mysqlhotcopy.sh60
-rw-r--r--server-tools/instance-manager/buffer.cc2
-rw-r--r--server-tools/instance-manager/instance.cc2
-rw-r--r--server-tools/instance-manager/instance_map.cc3
-rw-r--r--server-tools/instance-manager/options.cc6
-rw-r--r--server-tools/instance-manager/options.h3
-rw-r--r--server-tools/instance-manager/parse.h2
-rw-r--r--sql-bench/TODO21
-rw-r--r--sql-bench/test-create.sh2
-rw-r--r--sql-common/client.c4
-rw-r--r--sql-common/my_time.c13
-rw-r--r--sql-common/my_user.c4
-rw-r--r--sql/event_data_objects.cc4
-rw-r--r--sql/event_parse_data.cc4
-rw-r--r--sql/events.cc14
-rw-r--r--sql/field.cc12
-rw-r--r--sql/gen_lex_hash.cc6
-rw-r--r--sql/ha_partition.cc5
-rw-r--r--sql/handler.cc53
-rw-r--r--sql/item.cc139
-rw-r--r--sql/item.h4
-rw-r--r--sql/item_cmpfunc.cc13
-rw-r--r--sql/item_create.cc1
-rw-r--r--sql/item_func.cc21
-rw-r--r--sql/item_geofunc.cc27
-rw-r--r--sql/item_strfunc.cc39
-rw-r--r--sql/item_strfunc.h15
-rw-r--r--sql/item_sum.cc3
-rw-r--r--sql/item_timefunc.cc64
-rw-r--r--sql/item_xmlfunc.cc2
-rw-r--r--sql/lock.cc4
-rw-r--r--sql/log.cc12
-rw-r--r--sql/log_event.cc251
-rw-r--r--sql/log_event.h6
-rw-r--r--sql/log_event_old.cc4
-rw-r--r--sql/mysql_priv.h45
-rw-r--r--sql/mysqld.cc299
-rw-r--r--sql/net_serv.cc6
-rw-r--r--sql/opt_range.cc122
-rw-r--r--sql/parse_file.cc5
-rw-r--r--sql/parse_file.h2
-rw-r--r--sql/protocol.cc23
-rw-r--r--sql/rpl_filter.cc3
-rw-r--r--sql/rpl_record.cc34
-rw-r--r--sql/rpl_rli.cc5
-rw-r--r--sql/rpl_rli.h7
-rw-r--r--sql/rpl_utility.h6
-rw-r--r--sql/set_var.cc329
-rw-r--r--sql/set_var.h16
-rw-r--r--sql/share/errmsg.txt41
-rw-r--r--sql/slave.cc134
-rw-r--r--sql/sp.cc7
-rw-r--r--sql/sp_head.cc33
-rw-r--r--sql/sp_head.h10
-rw-r--r--sql/sp_pcontext.cc23
-rw-r--r--sql/sp_pcontext.h4
-rw-r--r--sql/spatial.h2
-rw-r--r--sql/sql_acl.cc3
-rw-r--r--sql/sql_base.cc89
-rw-r--r--sql/sql_cache.cc54
-rw-r--r--sql/sql_class.cc26
-rw-r--r--sql/sql_class.h10
-rw-r--r--sql/sql_connect.cc2
-rw-r--r--sql/sql_crypt.cc4
-rw-r--r--sql/sql_crypt.h2
-rw-r--r--sql/sql_db.cc11
-rw-r--r--sql/sql_delete.cc42
-rw-r--r--sql/sql_error.cc2
-rw-r--r--sql/sql_handler.cc27
-rw-r--r--sql/sql_insert.cc43
-rw-r--r--sql/sql_lex.cc103
-rw-r--r--sql/sql_lex.h41
-rw-r--r--sql/sql_load.cc33
-rw-r--r--sql/sql_parse.cc148
-rw-r--r--sql/sql_partition.cc3
-rw-r--r--sql/sql_plugin.cc35
-rw-r--r--sql/sql_prepare.cc8
-rw-r--r--sql/sql_profile.cc2
-rw-r--r--sql/sql_rename.cc11
-rw-r--r--sql/sql_repl.cc11
-rw-r--r--sql/sql_select.cc99
-rw-r--r--sql/sql_select.h6
-rw-r--r--sql/sql_servers.cc12
-rw-r--r--sql/sql_show.cc62
-rw-r--r--sql/sql_string.cc23
-rw-r--r--sql/sql_table.cc52
-rw-r--r--sql/sql_test.cc28
-rw-r--r--sql/sql_trigger.cc2
-rw-r--r--sql/sql_udf.cc2
-rw-r--r--sql/sql_view.cc71
-rw-r--r--sql/sql_view.h3
-rw-r--r--sql/sql_yacc.yy212
-rw-r--r--sql/strfunc.cc202
-rw-r--r--sql/table.cc6
-rw-r--r--sql/tztime.cc78
-rw-r--r--sql/udf_example.c4
-rw-r--r--sql/uniques.cc2
-rw-r--r--sql/unireg.cc17
-rw-r--r--storage/Makefile.am1
-rw-r--r--storage/archive/azio.c2
-rw-r--r--storage/archive/azlib.h2
-rw-r--r--storage/archive/ha_archive.cc12
-rw-r--r--storage/csv/ha_tina.cc33
-rw-r--r--storage/csv/ha_tina.h16
-rw-r--r--storage/csv/transparent_file.cc16
-rw-r--r--storage/csv/transparent_file.h12
-rw-r--r--storage/federated/ha_federated.cc20
-rw-r--r--storage/federated/ha_federated.h4
-rw-r--r--storage/heap/hp_write.c2
-rw-r--r--storage/ibmdb2i/CMakeLists.txt25
-rw-r--r--storage/ibmdb2i/Makefile.am54
-rw-r--r--storage/ibmdb2i/db2i_blobCollection.cc107
-rw-r--r--storage/ibmdb2i/db2i_blobCollection.h151
-rw-r--r--storage/ibmdb2i/db2i_charsetSupport.cc793
-rw-r--r--storage/ibmdb2i/db2i_charsetSupport.h65
-rw-r--r--storage/ibmdb2i/db2i_collationSupport.cc359
-rw-r--r--storage/ibmdb2i/db2i_collationSupport.h48
-rw-r--r--storage/ibmdb2i/db2i_constraints.cc698
-rw-r--r--storage/ibmdb2i/db2i_conversion.cc1446
-rw-r--r--storage/ibmdb2i/db2i_errors.cc297
-rw-r--r--storage/ibmdb2i/db2i_errors.h93
-rw-r--r--storage/ibmdb2i/db2i_file.cc556
-rw-r--r--storage/ibmdb2i/db2i_file.h446
-rw-r--r--storage/ibmdb2i/db2i_global.h138
-rw-r--r--storage/ibmdb2i/db2i_iconv.h51
-rw-r--r--storage/ibmdb2i/db2i_ileBridge.cc1342
-rw-r--r--storage/ibmdb2i/db2i_ileBridge.h499
-rw-r--r--storage/ibmdb2i/db2i_ioBuffers.cc332
-rw-r--r--storage/ibmdb2i/db2i_ioBuffers.h416
-rw-r--r--storage/ibmdb2i/db2i_misc.h113
-rw-r--r--storage/ibmdb2i/db2i_myconv.cc1498
-rw-r--r--storage/ibmdb2i/db2i_myconv.h3200
-rw-r--r--storage/ibmdb2i/db2i_rir.cc465
-rw-r--r--storage/ibmdb2i/db2i_safeString.h98
-rw-r--r--storage/ibmdb2i/db2i_sqlStatementStream.cc86
-rw-r--r--storage/ibmdb2i/db2i_sqlStatementStream.h151
-rw-r--r--storage/ibmdb2i/db2i_validatedPointer.h162
-rw-r--r--storage/ibmdb2i/ha_ibmdb2i.cc3291
-rw-r--r--storage/ibmdb2i/ha_ibmdb2i.h750
-rw-r--r--storage/ibmdb2i/plug.in12
-rw-r--r--storage/innobase/btr/btr0sea.c12
-rw-r--r--storage/innobase/dict/dict0load.c8
-rw-r--r--storage/innobase/handler/ha_innodb.cc64
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.c17
-rw-r--r--storage/innobase/include/pars0pars.h2
-rw-r--r--storage/innobase/include/rem0rec.h11
-rw-r--r--storage/innobase/include/rem0rec.ic19
-rw-r--r--storage/innobase/include/row0mysql.h15
-rw-r--r--storage/innobase/include/srv0srv.h6
-rw-r--r--storage/innobase/include/trx0roll.h14
-rw-r--r--storage/innobase/include/trx0trx.h42
-rw-r--r--storage/innobase/include/trx0trx.ic58
-rw-r--r--storage/innobase/lock/lock0lock.c36
-rw-r--r--storage/innobase/page/page0cur.c75
-rw-r--r--storage/innobase/row/row0mysql.c73
-rw-r--r--storage/innobase/row/row0sel.c43
-rw-r--r--storage/innobase/srv/srv0srv.c6
-rw-r--r--storage/innobase/trx/trx0roll.c51
-rw-r--r--storage/innobase/trx/trx0trx.c6
-rwxr-xr-xstorage/myisam/CMakeLists.txt2
-rw-r--r--storage/myisam/ft_boolean_search.c21
-rw-r--r--storage/myisam/ha_myisam.cc91
-rw-r--r--storage/myisam/mi_check.c6
-rw-r--r--storage/myisam/mi_close.c7
-rw-r--r--storage/myisam/mi_delete.c6
-rw-r--r--storage/myisam/mi_dynrec.c6
-rw-r--r--storage/myisam/mi_locking.c2
-rw-r--r--storage/myisam/mi_open.c3
-rw-r--r--storage/myisam/mi_packrec.c18
-rw-r--r--storage/myisam/mi_search.c2
-rw-r--r--storage/myisam/mi_write.c9
-rw-r--r--storage/myisam/myisamchk.c3
-rw-r--r--storage/myisam/myisamdef.h1
-rw-r--r--storage/myisam/rt_index.c10
-rw-r--r--storage/myisammrg/ha_myisammrg.cc102
-rw-r--r--storage/myisammrg/ha_myisammrg.h2
-rw-r--r--storage/myisammrg/myrg_open.c5
-rw-r--r--storage/ndb/tools/restore/consumer_restore.cpp4
-rw-r--r--storage/ndb/tools/restore/consumer_restorem.cpp4
-rw-r--r--strings/Makefile.am3
-rw-r--r--strings/ctype.c4
-rw-r--r--strings/my_vsnprintf.c4
-rw-r--r--support-files/Makefile.am1
-rw-r--r--support-files/my-huge.cnf.sh16
-rw-r--r--support-files/my-innodb-heavy-4G.cnf.sh28
-rw-r--r--support-files/my-large.cnf.sh16
-rw-r--r--support-files/my-medium.cnf.sh16
-rw-r--r--support-files/my-small.cnf.sh11
-rw-r--r--support-files/mysql.spec.sh12
-rw-r--r--tests/bug25714.c4
-rw-r--r--tests/mysql_client_test.c139
-rw-r--r--vio/viosocket.c22
-rw-r--r--win/Makefile.am5
805 files changed, 37083 insertions, 8745 deletions
diff --git a/.bzrignore b/.bzrignore
index 01ef6f2ffef..fad758b54b8 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -1295,6 +1295,8 @@ mysql-test/linux_sys_vars.inc
mysql-test/load_sysvars.inc
mysql-test/mtr
mysql-test/mysql-test-run
+mysql-test/mysql-test-gcov.err
+mysql-test/mysql-test-gcov.msg
mysql-test/mysql-test-run-shell
mysql-test/mysql-test-run.log
mysql-test/mysql_test_run_new
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1bb50cbade3..6a41496f120 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,7 +144,13 @@ IF(MSVC)
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
-
+
+ # Mark 32 bit executables large address aware so they can
+ # use > 2GB address space
+ IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
+ ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 4)
+
# Disable automatic manifest generation.
STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
${CMAKE_EXE_LINKER_FLAGS})
diff --git a/README b/README
index 56bd912d3d6..1a96d708a7e 100644
--- a/README
+++ b/README
@@ -1,11 +1,19 @@
This is a release of MySQL, a dual-license SQL database server.
-MySQL is brought to you by the MySQL team at MySQL AB.
+MySQL is brought to you by the MySQL team at Sun Microsystems, Inc.
License information can be found in these files:
- For GPL (free) distributions, see the COPYING file and
the EXCEPTIONS-CLIENT file.
- For commercial distributions, see the LICENSE.mysql file.
+GPLv2 Disclaimer
+For the avoidance of doubt, except that if any license choice
+other than GPL or LGPL is available it will apply instead, Sun
+elects to use only the General Public License version 2 (GPLv2)
+at this time for any software where a choice of GPL license versions
+is made available with the language indicating that GPLv2 or any
+later version may be used, or where a choice of which version of
+the GPL is applied is otherwise unspecified.
For further information about MySQL or additional documentation, see:
- The latest information about MySQL: http://www.mysql.com
diff --git a/client/my_readline.h b/client/my_readline.h
index 3ebe24b75b8..62ad19bece9 100644
--- a/client/my_readline.h
+++ b/client/my_readline.h
@@ -29,5 +29,5 @@ typedef struct st_line_buffer
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
-extern char *batch_readline(LINE_BUFFER *buffer);
+extern char *batch_readline(LINE_BUFFER *buffer, bool *truncated);
extern void batch_readline_end(LINE_BUFFER *buffer);
diff --git a/client/mysql.cc b/client/mysql.cc
index 65512e695b8..46141cd975f 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -49,7 +49,7 @@ const char *VER= "14.14";
#define MAX_COLUMN_LENGTH 1024
/* Buffer to hold 'version' and 'version_comment' */
-#define MAX_SERVER_VERSION_LENGTH 128
+static char *server_version= NULL;
/* Array of options to pass to libemysqld */
#define MAX_SERVER_ARGS 64
@@ -115,6 +115,8 @@ extern "C" {
#define PROMPT_CHAR '\\'
#define DEFAULT_DELIMITER ";"
+#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L)
+
typedef struct st_status
{
int exit_status;
@@ -246,11 +248,11 @@ typedef struct {
static COMMANDS commands[] = {
{ "?", '?', com_help, 1, "Synonym for `help'." },
- { "clear", 'c', com_clear, 0, "Clear command."},
+ { "clear", 'c', com_clear, 0, "Clear the current input statement."},
{ "connect",'r', com_connect,1,
"Reconnect to the server. Optional arguments are db and host." },
{ "delimiter", 'd', com_delimiter, 1,
- "Set statement delimiter. NOTE: Takes the rest of the line as new delimiter." },
+ "Set statement delimiter." },
#ifdef USE_POPEN
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
#endif
@@ -1045,7 +1047,7 @@ static void fix_history(String *final_command);
static COMMANDS *find_command(char *name,char cmd_name);
static bool add_line(String &buffer,char *line,char *in_string,
- bool *ml_comment);
+ bool *ml_comment, bool truncated);
static void remove_cntrl(String &buffer);
static void print_table_data(MYSQL_RES *result);
static void print_table_data_html(MYSQL_RES *result);
@@ -1117,7 +1119,7 @@ int main(int argc,char *argv[])
exit(1);
}
if (status.batch && !status.line_buff &&
- !(status.line_buff=batch_readline_init(opt_max_allowed_packet+512,stdin)))
+ !(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
{
free_defaults(defaults_argv);
my_end(0);
@@ -1198,7 +1200,7 @@ int main(int argc,char *argv[])
#endif
sprintf(buff, "%s",
#ifndef NOT_YET
- "Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n");
+ "Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n");
#else
"Type 'help [[%]function name[%]]' to get help on usage of function.\n");
#endif
@@ -1234,6 +1236,7 @@ sig_handler mysql_end(int sig)
glob_buffer.free();
old_buffer.free();
processed_prompt.free();
+ my_free(server_version,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
my_free(opt_mysql_unix_port,MYF(MY_ALLOW_ZERO_PTR));
my_free(histfile,MYF(MY_ALLOW_ZERO_PTR));
@@ -1810,13 +1813,14 @@ static int read_and_execute(bool interactive)
ulong line_number=0;
bool ml_comment= 0;
COMMANDS *com;
+ bool truncated= 0;
status.exit_status=1;
for (;;)
{
if (!interactive)
{
- line=batch_readline(status.line_buff);
+ line=batch_readline(status.line_buff, &truncated);
/*
Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
Editors like "notepad" put this marker in
@@ -1913,7 +1917,7 @@ static int read_and_execute(bool interactive)
#endif
continue;
}
- if (add_line(glob_buffer,line,&in_string,&ml_comment))
+ if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated))
break;
}
/* if in batch mode, send last query even if it doesn't end with \g or go */
@@ -1999,7 +2003,7 @@ static COMMANDS *find_command(char *name,char cmd_char)
static bool add_line(String &buffer,char *line,char *in_string,
- bool *ml_comment)
+ bool *ml_comment, bool truncated)
{
uchar inchar;
char buff[80], *pos, *out;
@@ -2245,8 +2249,23 @@ static bool add_line(String &buffer,char *line,char *in_string,
}
if (out != line || !buffer.is_empty())
{
- *out++='\n';
uint length=(uint) (out-line);
+
+ if (!truncated &&
+ (length < 9 ||
+ my_strnncoll (charset_info,
+ (uchar *)line, 9, (const uchar *) "delimiter", 9)))
+ {
+ /*
+ Don't add a new line in case there's a DELIMITER command to be
+ added to the glob buffer (e.g. on processing a line like
+ "<command>;DELIMITER <non-eof>") : similar to how a new line is
+ not added in the case when the DELIMITER is the first command
+ entered with an empty glob buffer.
+ */
+ *out++='\n';
+ length++;
+ }
if (buffer.length() + length >= buffer.alloced_length())
buffer.realloc(buffer.length()+length+IO_SIZE);
if ((!*ml_comment || preserve_comments) && buffer.append(line, length))
@@ -2648,7 +2667,7 @@ static void get_current_db()
(res= mysql_use_result(&mysql)))
{
MYSQL_ROW row= mysql_fetch_row(res);
- if (row[0])
+ if (row && row[0])
current_db= my_strdup(row[0], MYF(MY_WME));
mysql_free_result(res);
}
@@ -2855,7 +2874,7 @@ com_charset(String *buffer __attribute__((unused)), char *line)
param= get_arg(buff, 0);
if (!param || !*param)
{
- return put_info("Usage: \\C char_setname | charset charset_name",
+ return put_info("Usage: \\C charset_name | charset charset_name",
INFO_ERROR, 0);
}
new_cs= get_charset_by_csname(param, MY_CS_PRIMARY, MYF(MY_WME));
@@ -3907,7 +3926,7 @@ static int com_source(String *buffer, char *line)
return put_info(buff, INFO_ERROR, 0);
}
- if (!(line_buff=batch_readline_init(opt_max_allowed_packet+512,sql_file)))
+ if (!(line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, sql_file)))
{
my_fclose(sql_file,MYF(0));
return put_info("Can't initialize batch_readline", INFO_ERROR, 0);
@@ -4347,16 +4366,11 @@ select_limit, max_join_size);
static const char *
server_version_string(MYSQL *con)
{
- static char buf[MAX_SERVER_VERSION_LENGTH] = "";
-
/* Only one thread calls this, so no synchronization is needed */
- if (buf[0] == '\0')
+ if (server_version == NULL)
{
- char *bufp = buf;
MYSQL_RES *result;
- bufp= strnmov(buf, mysql_get_server_info(con), sizeof buf);
-
/* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
if (!mysql_query(con, "select @@version_comment limit 1") &&
(result = mysql_use_result(con)))
@@ -4364,17 +4378,32 @@ server_version_string(MYSQL *con)
MYSQL_ROW cur = mysql_fetch_row(result);
if (cur && cur[0])
{
- bufp = strxnmov(bufp, sizeof buf - (bufp - buf), " ", cur[0], NullS);
+ /* version, space, comment, \0 */
+ size_t len= strlen(mysql_get_server_info(con)) + strlen(cur[0]) + 2;
+
+ if ((server_version= (char *) my_malloc(len, MYF(MY_WME))))
+ {
+ char *bufp;
+ bufp = strmov(server_version, mysql_get_server_info(con));
+ bufp = strmov(bufp, " ");
+ (void) strmov(bufp, cur[0]);
+ }
}
mysql_free_result(result);
}
- /* str*nmov doesn't guarantee NUL-termination */
- if (bufp == buf + sizeof buf)
- buf[sizeof buf - 1] = '\0';
+ /*
+ If for some reason we didn't get a version_comment, we'll
+ keep things simple.
+ */
+
+ if (server_version == NULL)
+ {
+ server_version= strdup(mysql_get_server_info(con));
+ }
}
- return buf;
+ return server_version ? server_version : "";
}
static int
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 1e3249dd92a..df0dc1e7049 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -837,7 +837,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
bool old= (find_type(argv[0], &command_typelib, 2) ==
ADMIN_OLD_PASSWORD);
#ifdef __WIN__
- uint pw_len= strlen(pw);
+ uint pw_len= (uint) strlen(pw);
if (pw_len > 1 && pw[0] == '\'' && pw[pw_len-1] == '\'')
printf("Warning: single quotes were not trimmed from the password by"
" your command\nline client, as you might have expected.\n");
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 0b8e843887d..1621db5ded8 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -128,7 +128,7 @@ static Exit_status safe_connect();
class Load_log_processor
{
char target_dir_name[FN_REFLEN];
- int target_dir_name_len;
+ size_t target_dir_name_len;
/*
When we see first event corresponding to some LOAD DATA statement in
@@ -285,9 +285,9 @@ public:
File prepare_new_file_for_old_format(Load_log_event *le, char *filename);
Exit_status load_old_format_file(NET* net, const char *server_fname,
uint server_fname_len, File file);
- Exit_status process_first_event(const char *bname, uint blen,
+ Exit_status process_first_event(const char *bname, size_t blen,
const uchar *block,
- uint block_len, uint file_id,
+ size_t block_len, uint file_id,
Create_file_log_event *ce);
};
@@ -305,7 +305,7 @@ public:
File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le,
char *filename)
{
- uint len;
+ size_t len;
char *tail;
File file;
@@ -319,7 +319,7 @@ File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le,
return -1;
}
- le->set_fname_outside_temp_buf(filename,len+strlen(tail));
+ le->set_fname_outside_temp_buf(filename,len+(uint) strlen(tail));
return file;
}
@@ -411,9 +411,9 @@ Exit_status Load_log_processor::load_old_format_file(NET* net,
@retval OK_CONTINUE No error, the program should continue.
*/
Exit_status Load_log_processor::process_first_event(const char *bname,
- uint blen,
+ size_t blen,
const uchar *block,
- uint block_len,
+ size_t block_len,
uint file_id,
Create_file_log_event *ce)
{
@@ -456,7 +456,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
}
if (ce)
- ce->set_fname_outside_temp_buf(fname, strlen(fname));
+ ce->set_fname_outside_temp_buf(fname, (uint) strlen(fname));
if (my_write(file, (uchar*)block, block_len, MYF(MY_WME|MY_NABP)))
{
@@ -1189,7 +1189,7 @@ static my_time_t convert_str_to_timestamp(const char* str)
long dummy_my_timezone;
my_bool dummy_in_dst_time_gap;
/* We require a total specification (date AND time) */
- if (str_to_datetime(str, strlen(str), &l_time, 0, &was_cut) !=
+ if (str_to_datetime(str, (uint) strlen(str), &l_time, 0, &was_cut) !=
MYSQL_TIMESTAMP_DATETIME || was_cut)
{
error("Incorrect date and time argument: %s", str);
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 86e1b3352b4..d2edd084c57 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -349,7 +349,7 @@ static int get_options(int *argc, char ***argv)
if (!what_to_do)
{
- int pnlen = strlen(my_progname);
+ size_t pnlen= strlen(my_progname);
if (pnlen < 6) /* name too short */
what_to_do = DO_CHECK;
@@ -448,7 +448,8 @@ static int process_selected_tables(char *db, char **table_names, int tables)
space is for more readable output in logs and in case of error
*/
char *table_names_comma_sep, *end;
- int i, tot_length = 0;
+ size_t tot_length= 0;
+ int i= 0;
for (i = 0; i < tables; i++)
tot_length+= fixed_name_length(*(table_names + i)) + 2;
@@ -464,7 +465,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
*end++= ',';
}
*--end = 0;
- handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1);
+ handle_request_for_tables(table_names_comma_sep + 1, (uint) (tot_length - 1));
my_free(table_names_comma_sep, MYF(0));
}
else
@@ -486,7 +487,7 @@ static uint fixed_name_length(const char *name)
else if (*p == '.')
extra_length+= 2;
}
- return (p - name) + extra_length;
+ return (uint) ((p - name) + extra_length);
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 44c53a0e4c2..5a1fa3cc090 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -802,7 +802,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_set_charset= 0;
opt_compatible_mode_str= argument;
opt_compatible_mode= find_set(&compatible_mode_typelib,
- argument, strlen(argument),
+ argument, (uint) strlen(argument),
&err_ptr, &err_len);
if (err_len)
{
@@ -1475,7 +1475,8 @@ static int connect_to_db(char *host, char *user,char *passwd)
DB_error(&mysql_connection, "when trying to connect");
DBUG_RETURN(1);
}
- if (mysql_get_server_version(&mysql_connection) < 40100)
+ if ((mysql_get_server_version(&mysql_connection) < 40100) ||
+ (opt_compatible_mode & 3))
{
/* Don't dump SET NAMES with a pre-4.1 server (bug#7997). */
opt_set_charset= 0;
@@ -2421,11 +2422,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
row= mysql_fetch_row(result);
- fprintf(sql_file,
- "SET @saved_cs_client = @@character_set_client;\n"
- "SET character_set_client = utf8;\n"
+ fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" :
+ "/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
+ "/*!40101 SET character_set_client = utf8 */;\n"
"%s;\n"
- "SET character_set_client = @saved_cs_client;\n",
+ "/*!40101 SET character_set_client = @saved_cs_client */;\n",
row[1]);
check_io(sql_file);
@@ -4587,7 +4588,8 @@ char check_if_ignore_table(const char *table_name, char *table_type)
*/
if (!opt_no_data &&
(!my_strcasecmp(&my_charset_latin1, table_type, "MRG_MyISAM") ||
- !strcmp(table_type,"MRG_ISAM")))
+ !strcmp(table_type,"MRG_ISAM") ||
+ !strcmp(table_type,"FEDERATED")))
result= IGNORE_DATA;
}
mysql_free_result(res);
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 9ba912d646c..b8515289df5 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -1929,7 +1929,7 @@ parse_option(const char *origin, option_string **stmt, char delm)
char *ptr= (char *)origin;
option_string **sptr= stmt;
option_string *tmp;
- uint length= strlen(origin);
+ size_t length= strlen(origin);
uint count= 0; /* We know that there is always one */
for (tmp= *sptr= (option_string *)my_malloc(sizeof(option_string),
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 89b9c78a049..fdd4ff141bc 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -1316,7 +1316,7 @@ void log_msg(const char *fmt, ...)
void cat_file(DYNAMIC_STRING* ds, const char* filename)
{
int fd;
- uint len;
+ size_t len;
char buff[512];
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
@@ -1445,6 +1445,7 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...)
Test if diff is present. This is needed on Windows systems
as the OS returns 1 whether diff is successful or if it is
not present.
+ Takes name of diff program as argument
We run diff -v and look for output in stdout.
We don't redirect stderr to stdout to make for a simplified check
@@ -1452,11 +1453,12 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...)
not present.
*/
-int diff_check()
+int diff_check (const char *diff_name)
{
char buf[512]= {0};
FILE *res_file;
- const char *cmd = "diff -v";
+ char cmd[128];
+ my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name);
int have_diff = 0;
if (!(res_file= popen(cmd, "r")))
@@ -1488,7 +1490,7 @@ void show_diff(DYNAMIC_STRING* ds,
const char* filename1, const char* filename2)
{
DYNAMIC_STRING ds_tmp;
- int have_diff = 0;
+ const char *diff_name = 0;
if (init_dynamic_string(&ds_tmp, "", 256, 256))
die("Out of memory");
@@ -1501,15 +1503,20 @@ void show_diff(DYNAMIC_STRING* ds,
the way it's implemented does not work with default 'diff' on Solaris.
*/
#ifdef __WIN__
- have_diff = diff_check();
+ if (diff_check("diff"))
+ diff_name = "diff";
+ else if (diff_check("mtrdiff"))
+ diff_name = "mtrdiff";
+ else
+ diff_name = 0;
#else
- have_diff = 1;
+ diff_name = "diff"; // Otherwise always assume it's called diff
#endif
- if (have_diff)
+ if (diff_name)
{
/* First try with unified diff */
- if (run_tool("diff",
+ if (run_tool(diff_name,
&ds_tmp, /* Get output from diff in ds_tmp */
"-u",
filename1,
@@ -1520,7 +1527,7 @@ void show_diff(DYNAMIC_STRING* ds,
dynstr_set(&ds_tmp, "");
/* Fallback to context diff with "diff -c" */
- if (run_tool("diff",
+ if (run_tool(diff_name,
&ds_tmp, /* Get output from diff in ds_tmp */
"-c",
filename1,
@@ -1531,20 +1538,20 @@ void show_diff(DYNAMIC_STRING* ds,
dynstr_set(&ds_tmp, "");
/* Fallback to simple diff with "diff" */
- if (run_tool("diff",
+ if (run_tool(diff_name,
&ds_tmp, /* Get output from diff in ds_tmp */
filename1,
filename2,
"2>&1",
NULL) > 1) /* Most "diff" tools return >1 if error */
{
- have_diff= 0;
+ diff_name= 0;
}
}
}
}
- if (! have_diff)
+ if (! diff_name)
{
/*
Fallback to dump both files to result file and inform
@@ -1614,7 +1621,7 @@ int compare_files2(File fd, const char* filename2)
{
int error= RESULT_OK;
File fd2;
- uint len, len2;
+ size_t len, len2;
char buff[512], buff2[512];
if ((fd2= my_open(filename2, O_RDONLY, MYF(0))) < 0)
@@ -2653,7 +2660,8 @@ void do_exec(struct st_command *command)
log_msg("exec of '%s' failed, error: %d, status: %d, errno: %d",
ds_cmd.str, error, status, errno);
dynstr_free(&ds_cmd);
- die("command \"%s\" failed", command->first_argument);
+ die("command \"%s\" failed\n\nOutput from before failure:\n%s\n",
+ command->first_argument, ds_res.str);
}
DBUG_PRINT("info",
@@ -4647,6 +4655,10 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host,
int failed_attempts= 0;
DBUG_ENTER("safe_connect");
+
+ verbose_msg("Connecting to server %s:%d (socket %s) as '%s'"
+ ", connection '%s', attempt %d ...",
+ host, port, sock, user, name, failed_attempts);
while(!mysql_real_connect(mysql, host,user, pass, db, port, sock,
CLIENT_MULTI_STATEMENTS | CLIENT_REMEMBER_OPTIONS))
{
@@ -4678,6 +4690,7 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host,
}
failed_attempts++;
}
+ verbose_msg("... Connected.");
DBUG_VOID_RETURN;
}
@@ -7156,7 +7169,7 @@ void init_re_comp(my_regex_t *re, const char* str)
char erbuf[100];
int len= my_regerror(err, re, erbuf, sizeof(erbuf));
die("error %s, %d/%d `%s'\n",
- re_eprint(err), len, (int)sizeof(erbuf), erbuf);
+ re_eprint(err), (int)len, (int)sizeof(erbuf), erbuf);
}
}
@@ -7212,7 +7225,7 @@ int match_re(my_regex_t *re, char *str)
char erbuf[100];
int len= my_regerror(err, re, erbuf, sizeof(erbuf));
die("error %s, %d/%d `%s'\n",
- re_eprint(err), len, (int)sizeof(erbuf), erbuf);
+ re_eprint(err), (int)len, (int)sizeof(erbuf), erbuf);
}
return 0;
}
@@ -7511,8 +7524,12 @@ int main(int argc, char **argv)
parse_args(argc, argv);
log_file.open(opt_logdir, result_file_name, ".log");
+ verbose_msg("Logging to '%s'.", log_file.file_name());
if (opt_mark_progress)
+ {
progress_file.open(opt_logdir, result_file_name, ".progress");
+ verbose_msg("Tracing progress in '%s'.", progress_file.file_name());
+ }
var_set_int("$PS_PROTOCOL", ps_protocol);
var_set_int("$SP_PROTOCOL", sp_protocol);
@@ -7521,6 +7538,8 @@ int main(int argc, char **argv)
DBUG_PRINT("info",("result_file: '%s'",
result_file_name ? result_file_name : ""));
+ verbose_msg("Results saved in '%s'.",
+ result_file_name ? result_file_name : "");
if (mysql_server_init(embedded_server_arg_count,
embedded_server_args,
(char**) embedded_server_groups))
@@ -7591,6 +7610,7 @@ int main(int argc, char **argv)
open_file(opt_include);
}
+ verbose_msg("Start processing test commands from '%s' ...", cur_file->file_name);
while (!read_command(&command) && !abort_flag)
{
int current_line_inc = 1, processed = 0;
@@ -7908,6 +7928,7 @@ int main(int argc, char **argv)
log_file.close();
start_lineno= 0;
+ verbose_msg("... Done processing test commands.");
if (parsing_disabled)
die("Test ended with parsing disabled");
@@ -7958,6 +7979,7 @@ int main(int argc, char **argv)
if (!command_executed && result_file_name)
die("No queries executed but result file found!");
+ verbose_msg("Test has succeeded!");
timer_output();
/* Yes, if we got this far the test has suceeded! Sakila smiles */
cleanup_and_exit(0);
diff --git a/client/readline.cc b/client/readline.cc
index 7afdbc9531e..b32cb71b0de 100644
--- a/client/readline.cc
+++ b/client/readline.cc
@@ -24,7 +24,7 @@ static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,
ulong max_size);
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str);
static size_t fill_buffer(LINE_BUFFER *buffer);
-static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length);
+static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated);
LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
@@ -42,12 +42,13 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
}
-char *batch_readline(LINE_BUFFER *line_buff)
+char *batch_readline(LINE_BUFFER *line_buff, bool *truncated)
{
char *pos;
ulong out_length;
+ DBUG_ASSERT(truncated != NULL);
- if (!(pos=intern_read_line(line_buff,&out_length)))
+ if (!(pos=intern_read_line(line_buff,&out_length, truncated)))
return 0;
if (out_length && pos[out_length-1] == '\n')
if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */
@@ -149,6 +150,14 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
read_count=(buffer->bufread - bufbytes)/IO_SIZE;
if ((read_count*=IO_SIZE))
break;
+ if (buffer->bufread * 2 > buffer->max_size)
+ {
+ /*
+ So we must grow the buffer but we cannot due to the max_size limit.
+ Return 0 w/o setting buffer->eof to signal this condition.
+ */
+ return 0;
+ }
buffer->bufread *= 2;
if (!(buffer->buffer = (char*) my_realloc(buffer->buffer,
buffer->bufread+1,
@@ -172,11 +181,15 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count));
- /* Kludge to pretend every nonempty file ends with a newline. */
- if (!read_count && bufbytes && buffer->end[-1] != '\n')
+ if (!read_count)
{
- buffer->eof = read_count = 1;
- *buffer->end = '\n';
+ buffer->eof = 1;
+ /* Kludge to pretend every nonempty file ends with a newline. */
+ if (bufbytes && buffer->end[-1] != '\n')
+ {
+ read_count = 1;
+ *buffer->end = '\n';
+ }
}
buffer->end_of_line=(buffer->start_of_line=buffer->buffer)+bufbytes;
buffer->end+=read_count;
@@ -186,7 +199,7 @@ static size_t fill_buffer(LINE_BUFFER *buffer)
-char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length)
+char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length, bool *truncated)
{
char *pos;
size_t length;
@@ -200,14 +213,23 @@ char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length)
pos++;
if (pos == buffer->end)
{
- if ((uint) (pos - buffer->start_of_line) < buffer->max_size)
+ /*
+ fill_buffer() can return 0 either on EOF in which case we abort
+ or when the internal buffer has hit the size limit. In the latter case
+ return what we have read so far and signal string truncation.
+ */
+ if (!(length=fill_buffer(buffer)) || length == (uint) -1)
{
- if (!(length=fill_buffer(buffer)) || length == (size_t) -1)
- DBUG_RETURN(0);
- continue;
+ if (buffer->eof)
+ DBUG_RETURN(0);
}
+ else
+ continue;
pos--; /* break line here */
+ *truncated= 1;
}
+ else
+ *truncated= 0;
buffer->end_of_line=pos+1;
*out_length=(ulong) (pos + 1 - buffer->eof - buffer->start_of_line);
DBUG_RETURN(buffer->start_of_line);
diff --git a/client/sql_string.cc b/client/sql_string.cc
index c41463999aa..dc6147b563f 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -71,25 +71,22 @@ bool String::realloc(uint32 alloc_length)
char *new_ptr;
if (alloced)
{
- if ((new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
- {
- Ptr=new_ptr;
- Alloced_length=len;
- }
- else
- return TRUE; // Signal error
+ if (!(new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
+ return TRUE; // Signal error
}
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
{
+ if (str_length > len - 1)
+ str_length= 0;
if (str_length) // Avoid bugs in memcpy on AIX
memcpy(new_ptr,Ptr,str_length);
new_ptr[str_length]=0;
- Ptr=new_ptr;
- Alloced_length=len;
alloced=1;
}
else
return TRUE; // Signal error
+ Ptr= new_ptr;
+ Alloced_length= len;
}
Ptr[alloc_length]=0; // This make other funcs shorter
return FALSE;
@@ -125,7 +122,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
- uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
+ uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
}
#ifdef HAVE_FCONVERT
@@ -468,7 +465,7 @@ bool String::append(const char *s,uint32 arg_length)
bool String::append(const char *s)
{
- return append(s, strlen(s));
+ return append(s, (uint) strlen(s));
}
@@ -677,7 +674,7 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_sprintf(buff, (buff, "%.14g", d));
+ str_length+= my_sprintf(buff, (buff, "%.15g", d));
}
void String::qs_append(double *d)
diff --git a/cmd-line-utils/libedit/term.c b/cmd-line-utils/libedit/term.c
index 488c760da14..2f1aefa7117 100644
--- a/cmd-line-utils/libedit/term.c
+++ b/cmd-line-utils/libedit/term.c
@@ -61,7 +61,7 @@ static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#endif
-/* Solaris's term.h does horrid things. */
+/* Don't use Solaris's term.h. */
#if (defined(HAVE_TERM_H) && !defined(__SunOS))
#include <term.h>
#endif
diff --git a/config/ac-macros/ha_ndbcluster.m4 b/config/ac-macros/ha_ndbcluster.m4
index 5ee136f2266..3718b64f688 100644
--- a/config/ac-macros/ha_ndbcluster.m4
+++ b/config/ac-macros/ha_ndbcluster.m4
@@ -330,41 +330,11 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
AC_SUBST([NDB_SIZEOF_LONG])
AC_SUBST([NDB_SIZEOF_LONG_LONG])
- AC_CONFIG_FILES(storage/ndb/include/Makefile dnl
- storage/ndb/src/Makefile storage/ndb/src/common/Makefile dnl
- storage/ndb/docs/Makefile dnl
- storage/ndb/tools/Makefile dnl
- storage/ndb/src/common/debugger/Makefile dnl
- storage/ndb/src/common/debugger/signaldata/Makefile dnl
- storage/ndb/src/common/portlib/Makefile dnl
- storage/ndb/src/common/util/Makefile dnl
- storage/ndb/src/common/logger/Makefile dnl
- storage/ndb/src/common/transporter/Makefile dnl
- storage/ndb/src/common/mgmcommon/Makefile dnl
- storage/ndb/src/kernel/Makefile dnl
- storage/ndb/src/kernel/error/Makefile dnl
- storage/ndb/src/kernel/blocks/Makefile dnl
- storage/ndb/src/kernel/blocks/dbdict/Makefile dnl
- storage/ndb/src/kernel/blocks/dbdih/Makefile dnl
- storage/ndb/src/kernel/blocks/dblqh/Makefile dnl
- storage/ndb/src/kernel/blocks/dbtup/Makefile dnl
- storage/ndb/src/kernel/blocks/backup/Makefile dnl
- storage/ndb/src/kernel/vm/Makefile dnl
- storage/ndb/src/mgmapi/Makefile dnl
- storage/ndb/src/ndbapi/Makefile dnl
- storage/ndb/src/mgmsrv/Makefile dnl
- storage/ndb/src/mgmclient/Makefile dnl
- storage/ndb/src/cw/Makefile dnl
- storage/ndb/src/cw/cpcd/Makefile dnl
- storage/ndb/test/Makefile dnl
- storage/ndb/test/src/Makefile dnl
- storage/ndb/test/ndbapi/Makefile dnl
- storage/ndb/test/ndbapi/bank/Makefile dnl
- storage/ndb/test/tools/Makefile dnl
- storage/ndb/test/run-test/Makefile dnl
- storage/ndb/include/ndb_version.h storage/ndb/include/ndb_global.h dnl
- storage/ndb/include/ndb_types.h dnl
- )
+ AC_CONFIG_FILES([
+ storage/ndb/include/ndb_version.h
+ storage/ndb/include/ndb_global.h
+ storage/ndb/include/ndb_types.h
+ ])
])
AC_SUBST(TEST_NDBCLUSTER)
diff --git a/config/ac-macros/misc.m4 b/config/ac-macros/misc.m4
index 2fbb30383bd..2e62a4b3c88 100644
--- a/config/ac-macros/misc.m4
+++ b/config/ac-macros/misc.m4
@@ -231,16 +231,19 @@ esac
AC_DEFUN([MYSQL_CHECK_LIB_TERMCAP],
[
AC_CACHE_VAL(mysql_cv_termcap_lib,
-[AC_CHECK_LIB(ncurses, tgetent, mysql_cv_termcap_lib=libncurses,
- [AC_CHECK_LIB(curses, tgetent, mysql_cv_termcap_lib=libcurses,
- [AC_CHECK_LIB(termcap, tgetent, mysql_cv_termcap_lib=libtermcap,
- [AC_CHECK_LIB(tinfo, tgetent, mysql_cv_termcap_lib=libtinfo,
- mysql_cv_termcap_lib=NOT_FOUND)])])])])
+ [AC_CHECK_LIB(ncursesw, tgetent, mysql_cv_termcap_lib=libncursesw,
+ [AC_CHECK_LIB(ncurses, tgetent, mysql_cv_termcap_lib=libncurses,
+ [AC_CHECK_LIB(curses, tgetent, mysql_cv_termcap_lib=libcurses,
+ [AC_CHECK_LIB(termcap, tgetent, mysql_cv_termcap_lib=libtermcap,
+ [AC_CHECK_LIB(tinfo, tgetent, mysql_cv_termcap_lib=libtinfo,
+ mysql_cv_termcap_lib=NOT_FOUND)])])])])])
AC_MSG_CHECKING(for termcap functions library)
if test "$mysql_cv_termcap_lib" = "NOT_FOUND"; then
AC_MSG_ERROR([No curses/termcap library found])
elif test "$mysql_cv_termcap_lib" = "libtermcap"; then
TERMCAP_LIB=-ltermcap
+elif test "$mysql_cv_termcap_lib" = "libncursesw"; then
+TERMCAP_LIB=-lncursesw
elif test "$mysql_cv_termcap_lib" = "libncurses"; then
TERMCAP_LIB=-lncurses
elif test "$mysql_cv_termcap_lib" = "libtinfo"; then
diff --git a/config/ac-macros/plugins.m4 b/config/ac-macros/plugins.m4
index 8dfb698709f..5d15afeda99 100644
--- a/config/ac-macros/plugins.m4
+++ b/config/ac-macros/plugins.m4
@@ -302,7 +302,9 @@ AC_DEFUN([MYSQL_CONFIGURE_PLUGINS],[
_MYSQL_CONFIGURE_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
_MYSQL_EMIT_PLUGIN_ACTIONS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
AC_SUBST([mysql_se_dirs])
+ AC_SUBST([mysql_se_distdirs])
AC_SUBST([mysql_pg_dirs])
+ AC_SUBST([mysql_pg_distdirs])
AC_SUBST([mysql_se_unittest_dirs])
AC_SUBST([mysql_pg_unittest_dirs])
AC_SUBST([condition_dependent_plugin_modules])
@@ -354,6 +356,24 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
fi
AC_MSG_RESULT([no])
],[
+
+ # Plugin is not disabled, determine if it should be built,
+ # or only distributed
+
+ m4_ifdef([$6], [
+ if test ! -d "$srcdir/$6"; then
+ # Plugin directory was removed after autoconf was run; treat
+ # this as a disabled plugin
+ if test "X[$with_plugin_]$2" = Xyes; then
+ AC_MSG_RESULT([error])
+ AC_MSG_ERROR([disabled])
+ fi
+
+ # The result message will be printed below
+ [with_plugin_]$2=no
+ fi
+ ])
+
m4_ifdef([$9],[
if test "X[$with_plugin_]$2" = Xno; then
AC_MSG_RESULT([error])
@@ -372,6 +392,8 @@ AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
;;
esac
])
+
+
if test "X[$with_plugin_]$2" = Xno; then
AC_MSG_RESULT([no])
else
@@ -448,28 +470,49 @@ dnl Although this is "pretty", it breaks libmysqld build
condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp($11, [^.+[/$]], [\&])"
])
fi
- m4_ifdef([$6],[
- if test -n "$mysql_use_plugin_dir" ; then
- mysql_plugin_dirs="$mysql_plugin_dirs $6"
- m4_syscmd(test -f "$6/configure")
- ifelse(m4_sysval, 0,
- [AC_CONFIG_SUBDIRS($6)],
- [AC_CONFIG_FILES($6/Makefile)]
- )
- ifelse(m4_substr($6, 0, 8), [storage/],
- [
- [mysql_se_dirs="$mysql_se_dirs ]m4_substr($6, 8)"
- mysql_se_unittest_dirs="$mysql_se_unittest_dirs ../$6"
- ],
- m4_substr($6, 0, 7), [plugin/],
- [
- [mysql_pg_dirs="$mysql_pg_dirs ]m4_substr($6, 7)"
- mysql_pg_unittest_dirs="$mysql_pg_unittest_dirs ../$6"
- ],
- [AC_FATAL([don't know how to handle plugin dir ]$6)])
- fi
- ])
fi
+
+ m4_ifdef([$6], [
+ if test -d "$srcdir/$6"; then
+ # Even if we don't build a plugin, we bundle its source into the dist
+ # file. So its Makefile (and Makefiles for any subdirs) must be
+ # generated for 'make dist' to work.
+ m4_syscmd([test -f "]$6[/configure"])
+ ifelse(m4_sysval, 0,
+ [AC_CONFIG_SUBDIRS($6)],
+ [
+ # autoconf doesn't provide an automatic way to configure DIST_SUBDIRS of
+ # a subdir; for our purposes, it's enough to just check for existing
+ # Makefile.am files and add them in here
+dnl
+dnl Warning, don't try to quote the m4_esyscmd() macro, it doesn't
+dnl work. Quoting here is tricky.
+dnl
+dnl The $FIND or $SED variable can be set by the user when calling autoconf itself
+dnl to if they need to pass a specific path. This is *NOT* used when calling
+dnl running configure!
+dnl
+ AC_CONFIG_FILES(m4_esyscmd([${FIND-find} "]$6[" -name Makefile.am -print | ${SED-sed} 's,\.am$,,']))
+ ]
+ )
+
+ ifelse(
+ m4_substr($6, 0, 8), [storage/], [
+ mysql_se_distdirs="$mysql_se_distdirs m4_substr($6, 8)"
+ if test -n "$mysql_use_plugin_dir" ; then
+ mysql_se_dirs="$mysql_se_dirs m4_substr($6, 8)"
+ mysql_se_unittest_dirs="$mysql_se_unittest_dirs ../$6"
+ fi],
+
+ m4_substr($6, 0, 7), [plugin/], [
+ mysql_pg_distdirs="$mysql_pg_distdirs m4_substr($6, 7)"
+ if test -n "$mysql_use_plugin_dir" ; then
+ mysql_pg_dirs="$mysql_pg_dirs m4_substr($6, 7)"
+ mysql_pg_unittest_dirs="$mysql_pg_unittest_dirs ../$6"
+ fi],
+ [AC_FATAL([don't know how to handle plugin dir ]$6)])
+ fi
+ ])
])
])
diff --git a/configure.in b/configure.in
index 0266d43a1f4..0dffffda66e 100644
--- a/configure.in
+++ b/configure.in
@@ -9,7 +9,7 @@ AC_CANONICAL_SYSTEM
# remember to also update version.c in ndb
#
# When changing major version number please also check switch statement
-# in client/mysqlbinlog.cc:check_master_version().
+# in mysqlbinlog::check_master_version().
AM_INIT_AUTOMAKE(mysql, 5.4.1-beta)
AM_CONFIG_HEADER([include/config.h:config.h.in])
@@ -36,6 +36,7 @@ MYSQL_NUMERIC_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|[[a-z]][[a-z0-9]]
MYSQL_BASE_VERSION=`echo $MYSQL_NUMERIC_VERSION | sed -e "s|\.[[^.]]*$||"`
MYSQL_VERSION_ID=`echo $MYSQL_NUMERIC_VERSION | \
awk -F. '{printf "%d%0.2d%0.2d", $1, $2, $3}'`
+MYSQL_COPYRIGHT_YEAR=`date '+%Y'`
# Add previous major version for debian package upgrade path
MYSQL_PREVIOUS_BASE_VERSION=5.0
@@ -71,6 +72,7 @@ AC_SUBST(MYSQL_NO_DASH_VERSION)
AC_SUBST(MYSQL_BASE_VERSION)
AC_SUBST(MYSQL_VERSION_ID)
AC_SUBST(MYSQL_PREVIOUS_BASE_VERSION)
+AC_SUBST(MYSQL_COPYRIGHT_YEAR)
AC_SUBST(PROTOCOL_VERSION)
AC_DEFINE_UNQUOTED([PROTOCOL_VERSION], [$PROTOCOL_VERSION],
[mysql client protocol version])
@@ -816,7 +818,7 @@ AC_TYPE_SIZE_T
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \
+AC_CHECK_HEADERS(fcntl.h fenv.h float.h floatingpoint.h ieeefp.h limits.h \
memory.h pwd.h select.h \
stdlib.h stddef.h \
strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
@@ -839,19 +841,17 @@ AC_CHECK_LIB(nsl_r, gethostbyname_r, [],
AC_CHECK_LIB(nsl, gethostbyname_r))
AC_CHECK_FUNC(gethostbyname_r)
-AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
-AC_CHECK_FUNC(yp_get_default_domain, ,
- AC_CHECK_LIB(nsl, yp_get_default_domain))
-AC_CHECK_FUNC(p2open, , AC_CHECK_LIB(gen, p2open))
+AC_SEARCH_LIBS(setsockopt, socket)
# This may get things to compile even if bind-8 is installed
-AC_CHECK_FUNC(bind, , AC_CHECK_LIB(bind, bind))
+AC_SEARCH_LIBS(bind, bind)
# Check if crypt() exists in libc or libcrypt, sets LIBS if needed
AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT, 1, [crypt]))
# See if we need a library for address lookup.
AC_SEARCH_LIBS(inet_aton, [socket nsl resolv])
# For the sched_yield() function on Solaris
-AC_CHECK_FUNC(sched_yield, , AC_CHECK_LIB(posix4, sched_yield))
+AC_SEARCH_LIBS(sched_yield, posix4,
+ AC_DEFINE(HAVE_SCHED_YIELD, 1, [sched_yield]))
MYSQL_CHECK_ZLIB_WITH_COMPRESS
@@ -973,7 +973,7 @@ AC_MSG_RESULT([$USE_PSTACK])
# Check for gtty if termio.h doesn't exists
if test "$ac_cv_header_termio_h" = "no" -a "$ac_cv_header_termios_h" = "no"
then
- AC_CHECK_FUNC(gtty, , AC_CHECK_LIB(compat, gtty))
+ AC_SEARCH_LIBS(gtty, compat)
fi
# We make a special variable for non-threaded version of LIBS to avoid
@@ -2083,7 +2083,7 @@ AC_FUNC_VPRINTF
AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
chsize cuserid fchmod fcntl \
- fconvert fdatasync finite fpresetsticky fpsetmask fsync ftruncate \
+ fconvert fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
getpwuid getrlimit getrusage getwd index initgroups isnan \
localtime_r gethrtime gmtime_r \
@@ -2128,6 +2128,27 @@ esac
AC_MSG_CHECKING(for isinf in <math.h>)
AC_TRY_LINK([#include <math.h>], [float f = 0.0; int r = isinf(f); return r],
AC_MSG_RESULT(yes)
+ AC_MSG_CHECKING(whether isinf() is safe to use in C code)
+ AC_TRY_RUN([
+#include <math.h>
+int main()
+{
+ double a= 10.0;
+ double b= 1e308;
+
+ return !isinf(a * b);
+}
+],
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)
+ AC_DEFINE([HAVE_BROKEN_ISINF], [1],
+ [Define to 1 if isinf() uses 80-bit register for intermediate values])
+ ],
+ [
+# Let's be optimistic when cross-compiling, since the only compiler known
+# to be affected by this isinf() bug is GCC 4.3 on 32-bit x86.
+ AC_MSG_RESULT([[cross-compiling, assuming 'yes']])
+ ])
AC_MSG_CHECKING(whether isinf() can be used in C++ code)
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
diff --git a/extra/comp_err.c b/extra/comp_err.c
index f2d486487ff..e36e85f6f0c 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -660,7 +660,7 @@ static ha_checksum checksum_format_specifier(const char* msg)
case 'u':
case 'x':
case 's':
- chksum= my_checksum(chksum, start, p-start);
+ chksum= my_checksum(chksum, start, (uint) (p - start));
start= 0; /* Not in format specifier anymore */
break;
diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp
index 0c3f23b0cb8..66107dbe0a9 100644
--- a/extra/yassl/src/buffer.cpp
+++ b/extra/yassl/src/buffer.cpp
@@ -106,7 +106,7 @@ void input_buffer::add_size(uint i)
uint input_buffer::get_capacity() const
{
- return end_ - buffer_;
+ return (uint) (end_ - buffer_);
}
@@ -223,7 +223,7 @@ uint output_buffer::get_size() const
uint output_buffer::get_capacity() const
{
- return end_ - buffer_;
+ return (uint) (end_ - buffer_);
}
diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp
index 529a91eee08..bb34db5e07f 100644
--- a/extra/yassl/taocrypt/include/block.hpp
+++ b/extra/yassl/taocrypt/include/block.hpp
@@ -78,7 +78,7 @@ typename A::pointer StdReallocate(A& a, T* p, typename A::size_type oldSize,
if (preserve) {
A b = A();
typename A::pointer newPointer = b.allocate(newSize, 0);
- memcpy(newPointer, p, sizeof(T) * min(oldSize, newSize));
+ memcpy(newPointer, p, sizeof(T) * min((word32) oldSize, (word32) newSize));
a.deallocate(p, oldSize);
STL::swap(a, b);
return newPointer;
diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp
index cb597c41552..c221ce3d6cb 100644
--- a/extra/yassl/taocrypt/src/algebra.cpp
+++ b/extra/yassl/taocrypt/src/algebra.cpp
@@ -288,7 +288,7 @@ void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base,
r = buckets[i][buckets[i].size()-1];
if (buckets[i].size() > 1)
{
- for (int j = buckets[i].size()-2; j >= 1; j--)
+ for (int j= (unsigned int) (buckets[i].size()) - 2; j >= 1; j--)
{
Accumulate(buckets[i][j], buckets[i][j+1]);
Accumulate(r, buckets[i][j]);
diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp
index a06ab658c7b..3b1c1c2136a 100644
--- a/extra/yassl/taocrypt/src/asn.cpp
+++ b/extra/yassl/taocrypt/src/asn.cpp
@@ -213,7 +213,7 @@ void PublicKey::AddToEnd(const byte* data, word32 len)
Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h)
: key_(k, kSz)
{
- int sz = strlen(n);
+ size_t sz = strlen(n);
memcpy(name_, n, sz);
name_[sz] = 0;
diff --git a/include/config-win.h b/include/config-win.h
index ab0926af864..3a21551ebbb 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -33,7 +33,6 @@ functions */
#include <sys/locking.h>
#include <winsock2.h>
-#include <math.h> /* Because of rint() */
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
@@ -223,13 +222,6 @@ typedef uint rf_SetTimer;
#define inline __inline
#endif /* __cplusplus */
-inline double rint(double nr)
-{
- double f = floor(nr);
- double c = ceil(nr);
- return (((c-nr) >= (nr-f)) ? f :c);
-}
-
#ifdef _WIN64
#define ulonglong2double(A) ((double) (ulonglong) (A))
#define my_off_t2double(A) ((double) (my_off_t) (A))
@@ -284,7 +276,6 @@ inline ulonglong double2ulonglong(double d)
#define HAVE_FLOAT_H
#define HAVE_LIMITS_H
#define HAVE_STDDEF_H
-#define HAVE_RINT /* defined in this file */
#define NO_FCNTL_NONBLOCK /* No FCNTL */
#define HAVE_ALLOCA
#define HAVE_STRPBRK
diff --git a/include/my_getopt.h b/include/my_getopt.h
index 50ebe9190d8..7cbad607aac 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -72,7 +72,7 @@ extern void my_cleanup_options(const struct my_option *options);
extern void my_print_help(const struct my_option *options);
extern void my_print_variables(const struct my_option *options);
extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint,
- const struct my_option *));
+ const struct my_option *, int *));
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
my_bool *fix);
diff --git a/include/my_global.h b/include/my_global.h
index 4581dd6785c..9e8c9bdfc70 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -424,6 +424,9 @@ C_MODE_END
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
+#ifdef HAVE_FENV_H
+#include <fenv.h> /* For fesetround() */
+#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -577,9 +580,6 @@ typedef unsigned short ushort;
#define test_all_bits(a,b) (((a) & (b)) == (b))
#define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
-#ifndef HAVE_RINT
-#define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
-#endif
/* Define some general constants */
#ifndef TRUE
@@ -621,7 +621,6 @@ C_MODE_END
*/
#define _VARARGS(X) X
#define _STATIC_VARARGS(X) X
-#define _PC(X) X
/* The DBUG_ON flag always takes precedence over default DBUG_OFF */
#if defined(DBUG_ON) && defined(DBUG_OFF)
@@ -872,10 +871,20 @@ typedef SOCKET_SIZE_TYPE size_socket;
#endif
#ifdef HAVE_ISINF
-/* isinf() can be used in both C and C++ code */
-#define my_isinf(X) isinf(X)
+/* Check if C compiler is affected by GCC bug #39228 */
+#if !defined(__cplusplus) && defined(HAVE_BROKEN_ISINF)
+/* Force store/reload of the argument to/from a 64-bit double */
+static inline double my_isinf(double x)
+{
+ volatile double t= x;
+ return isinf(t);
+}
#else
-#define my_isinf(X) (!isfinite(X) && !isnan(X))
+/* System-provided isinf() is available and safe to use */
+#define my_isinf(X) isinf(X)
+#endif
+#else /* !HAVE_ISINF */
+#define my_isinf(X) (!finite(X) && !isnan(X))
#endif
/* Define missing math constants. */
@@ -1529,4 +1538,39 @@ inline void operator delete[](void*, void*) { /* Do nothing */ }
#define bool In_C_you_should_use_my_bool_instead()
#endif
+#ifndef HAVE_RINT
+/**
+ All integers up to this number can be represented exactly as double precision
+ values (DBL_MANT_DIG == 53 for IEEE 754 hardware).
+*/
+#define MAX_EXACT_INTEGER ((1LL << DBL_MANT_DIG) - 1)
+
+/**
+ rint(3) implementation for platforms that do not have it.
+ Always rounds to the nearest integer with ties being rounded to the nearest
+ even integer to mimic glibc's rint() behavior in the "round-to-nearest"
+ FPU mode. Hardware-specific optimizations are possible (frndint on x86).
+ Unlike this implementation, hardware will also honor the FPU rounding mode.
+*/
+
+static inline double rint(double x)
+{
+ double f, i;
+ f = modf(x, &i);
+ /*
+ All doubles with absolute values > MAX_EXACT_INTEGER are even anyway,
+ no need to check it.
+ */
+ if (x > 0.0)
+ i += (double) ((f > 0.5) || (f == 0.5 &&
+ i <= (double) MAX_EXACT_INTEGER &&
+ (longlong) i % 2));
+ else
+ i -= (double) ((f < -0.5) || (f == -0.5 &&
+ i >= (double) -MAX_EXACT_INTEGER &&
+ (longlong) i % 2));
+ return i;
+}
+#endif /* HAVE_RINT */
+
#endif /* my_global_h */
diff --git a/include/my_md5.h b/include/my_md5.h
index f92976b3beb..6458f27c5cc 100644
--- a/include/my_md5.h
+++ b/include/my_md5.h
@@ -13,80 +13,42 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/* See md5.c for explanation and copyright information. */
-/* MD5.H - header file for MD5C.C
+/*
+ * $FreeBSD: src/contrib/cvs/lib/md5.h,v 1.2 1999/12/11 15:10:02 peter Exp $
*/
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
+/* Unlike previous versions of this code, uint32 need not be exactly
+ 32 bits, merely 32 bits or more. Choosing a data type which is 32
+ bits instead of 64 is not important; speed is considerably more
+ important. ANSI guarantees that "unsigned long" will be big enough,
+ and always using it seems to have few disadvantages. */
+typedef uint32 cvs_uint32;
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
- */
-
-/* GLOBAL.H - RSAREF types and constants
- */
-
-/* PROTOTYPES should be set to one if and only if the compiler supports
- function argument prototyping.
-The following makes PROTOTYPES default to 0 if it has not already
- been defined with C compiler flags.
- */
-
-/* egcs 1.1.2 under linux didn't defined it.... :( */
-
-#ifndef PROTOTYPES
-#define PROTOTYPES 1 /* Assume prototypes */
-#endif
-
-/* POINTER defines a generic pointer type */
-typedef unsigned char *POINTER;
-
-/* UINT2 defines a two byte word */
-typedef uint16 UINT2; /* Fix for MySQL / Alpha */
-
-/* UINT4 defines a four byte word */
-typedef uint32 UINT4; /* Fix for MySQL / Alpha */
-
-/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
-If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
- returns an empty list.
- */
-#if PROTOTYPES
-#define PROTO_LIST(list) list
-#else
-#define PROTO_LIST(list) ()
-#endif
-/* MD5 context. */
typedef struct {
- UINT4 state[4]; /* state (ABCD) */
- UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
- unsigned char buffer[64]; /* input buffer */
-} my_MD5_CTX;
+ cvs_uint32 buf[4];
+ cvs_uint32 bits[2];
+ unsigned char in[64];
+} my_MD5Context;
#ifdef __cplusplus
extern "C" {
#endif
- void my_MD5Init PROTO_LIST ((my_MD5_CTX *));
- void my_MD5Update PROTO_LIST
- ((my_MD5_CTX *, unsigned char *, unsigned int));
- void my_MD5Final PROTO_LIST ((unsigned char [16], my_MD5_CTX *));
+void my_MD5Init (my_MD5Context *context);
+void my_MD5Update (my_MD5Context *context,
+ unsigned char const *buf, unsigned len);
+void my_MD5Final (unsigned char digest[16],
+ my_MD5Context *context);
#ifdef __cplusplus
}
#endif
+
+#define MY_MD5_HASH(digest,buf,len) \
+do { \
+ my_MD5Context ctx; \
+ my_MD5Init (&ctx); \
+ my_MD5Update (&ctx, buf, len); \
+ my_MD5Final (digest, &ctx); \
+} while (0)
diff --git a/include/my_sys.h b/include/my_sys.h
index 5335b65822f..01804cd089f 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -637,6 +637,7 @@ extern int nt_share_delete(const char *name,myf MyFlags);
extern void TERMINATE(FILE *file, uint flag);
#endif
extern void init_glob_errs(void);
+extern void wait_for_free_space(const char *filename, int errors);
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
extern int my_fclose(FILE *fd,myf MyFlags);
@@ -842,14 +843,17 @@ extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
extern int get_defaults_options(int argc, char **argv,
char **defaults, char **extra_defaults,
char **group_suffix);
+extern int my_load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv, const char ***);
extern int load_defaults(const char *conf_file, const char **groups,
- int *argc, char ***argv);
+ int *argc, char ***argv);
extern int modify_defaults_file(const char *file_location, const char *option,
const char *option_value,
const char *section_name, int remove_option);
extern int my_search_option_files(const char *conf_file, int *argc,
char ***argv, uint *args_used,
- Process_option_func func, void *func_ctx);
+ Process_option_func func, void *func_ctx,
+ const char **default_directories);
extern void free_defaults(char **argv);
extern void my_print_default_files(const char *conf_file);
extern void print_defaults(const char *conf_file, const char **groups);
diff --git a/include/thr_lock.h b/include/thr_lock.h
index e409df30972..fb70c57c0e7 100644
--- a/include/thr_lock.h
+++ b/include/thr_lock.h
@@ -27,6 +27,10 @@ extern "C" {
struct st_thr_lock;
extern ulong locks_immediate,locks_waited ;
+/*
+ Important: if a new lock type is added, a matching lock description
+ must be added to sql_test.cc's lock_descriptions array.
+*/
enum thr_lock_type { TL_IGNORE=-1,
TL_UNLOCK, /* UNLOCK ANY LOCK */
/*
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index ca329eadf0f..50995601d1f 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1617,7 +1617,7 @@ mysql_hex_string(char *to, const char *from, ulong length)
ulong STDCALL
mysql_escape_string(char *to,const char *from,ulong length)
{
- return escape_string_for_mysql(default_charset_info, to, 0, from, length);
+ return (uint) escape_string_for_mysql(default_charset_info, to, 0, from, length);
}
ulong STDCALL
@@ -1625,8 +1625,8 @@ mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
ulong length)
{
if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
- return escape_quotes_for_mysql(mysql->charset, to, 0, from, length);
- return escape_string_for_mysql(mysql->charset, to, 0, from, length);
+ return (uint) escape_quotes_for_mysql(mysql->charset, to, 0, from, length);
+ return (uint) escape_string_for_mysql(mysql->charset, to, 0, from, length);
}
void STDCALL
@@ -3833,13 +3833,13 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field,
#undef NOT_FIXED_DEC
{
/*
- The 14 below is to ensure that the server and client has the same
+ DBL_DIG below is to ensure that the server and client has the same
precisions. This will ensure that on the same machine you get the
same value as a string independent of the protocol you use.
*/
sprintf(buff, "%-*.*g", (int) min(sizeof(buff)-1,
param->buffer_length),
- min(14,width), value);
+ min(DBL_DIG, width), value);
end= strcend(buff, ' ');
*end= 0;
}
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 1582f0898d8..1c8f80768d4 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -201,6 +201,6 @@ ADD_LIBRARY(mysqlserver STATIC ${LIBMYSQLD_SOURCES})
ADD_DEPENDENCIES(mysqlserver GenServerSource GenError)
TARGET_LINK_LIBRARIES(mysqlserver)
-ADD_LIBRARY(libmysqld MODULE cmake_dummy.c libmysqld.def)
+ADD_LIBRARY(libmysqld SHARED cmake_dummy.c libmysqld.def)
ADD_DEPENDENCIES(libmysqld mysqlserver)
TARGET_LINK_LIBRARIES(libmysqld mysqlserver wsock32)
diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt
index fa9711b54da..5194836a728 100644
--- a/libmysqld/examples/CMakeLists.txt
+++ b/libmysqld/examples/CMakeLists.txt
@@ -30,12 +30,12 @@ ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
../../client/mysql.cc ../../client/readline.cc
../../client/sql_string.cc)
TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
-ADD_DEPENDENCIES(mysql_embedded libmysqld)
+TARGET_LINK_LIBRARIES(mysql_embedded libmysqld)
ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc)
TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
-ADD_DEPENDENCIES(mysqltest_embedded libmysqld)
+TARGET_LINK_LIBRARIES(mysqltest_embedded libmysqld)
ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c)
TARGET_LINK_LIBRARIES(mysql_client_test_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
-ADD_DEPENDENCIES(mysql_client_test_embedded libmysqld)
+TARGET_LINK_LIBRARIES(mysql_client_test_embedded libmysqld)
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 23572ad4929..d644c45a66a 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -43,6 +43,15 @@ extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
static my_bool emb_read_query_result(MYSQL *mysql);
+extern "C" void unireg_clear(int exit_code)
+{
+ DBUG_ENTER("unireg_clear");
+ clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
+ my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
+ DBUG_VOID_RETURN;
+}
+
+
/*
Reads error information from the MYSQL_DATA and puts
it into proper MYSQL members
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index dc9fbbd9aa5..5e3582d5e16 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -71,17 +71,17 @@ SUBDIRS = lib/My/SafeProcess
EXTRA_DIST = README \
valgrind.supp \
$(test_SCRIPTS) \
- $(nobase_test_DATA)
+ $(nobase_test_DATA)
# List of directories containing test + result files and the
# related test data files that should be copied
-TEST_DIRS = t r include std_data std_data/parts \
+TEST_DIRS = t r include std_data std_data/parts collections \
std_data/ndb_backup50 std_data/ndb_backup51 \
std_data/ndb_backup51_data_be std_data/ndb_backup51_data_le \
std_data/funcs_1 \
extra/binlog_tests/ extra/rpl_tests \
suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
- suite/bugs/data suite/bugs/t suite/bugs/r \
+ suite/bugs suite/bugs/data suite/bugs/t suite/bugs/r \
suite/federated \
suite/funcs_1 suite/funcs_1/bitdata \
suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
@@ -90,7 +90,7 @@ TEST_DIRS = t r include std_data std_data/parts \
suite/funcs_2 suite/funcs_2/charset suite/funcs_2/data \
suite/funcs_2/include suite/funcs_2/lib suite/funcs_2/r \
suite/funcs_2/t \
- suite/jp suite/jp/t suite/jp/r suite/jp/std_data \
+ suite/jp suite/jp/t suite/jp/r suite/jp/std_data suite/jp/include \
suite/manual/t suite/manual/r \
suite/ndb_team suite/ndb_team/t suite/ndb_team/r \
suite/rpl suite/rpl/data suite/rpl/include suite/rpl/r \
diff --git a/mysql-test/collections/README b/mysql-test/collections/README
new file mode 100644
index 00000000000..9af84646a40
--- /dev/null
+++ b/mysql-test/collections/README
@@ -0,0 +1,30 @@
+This directory contains collections of test runs that we run during our
+integration and release testing. Each file contains zero or more lines,
+with one invocation of mysql-test-run.pl on each. These invocations are
+written so that, with the assumption that perl is in your search path,
+any collection can run as a shell script or a batch file, with the parent
+mysql-test directory being the current working directory.
+
+During integration testing, we choose the collection to run by following
+these steps:
+
+1) We choose the extension to look for, based on these rules:
+ - If we're running a per-push test, we choose ".push" as the extension.
+ - If we're running a daily test, we choose ".daily" as the extension.
+ - If we're running a weekly test, we choose ".weekly" as the extension.
+
+2) If there is a collection that has the same name as the branch we're
+ testing plus the extension as determined in step 1, we choose that
+ collection.
+
+3) If the branch is unknown or we have removed all characters from it
+ and still not found a matching collection, we choose the name "default"
+ plus the extension determined in step 1. If there is no such file,
+ we give up and don't test anything at all.
+
+4) If we haven't found a collection yet, we remove the last character from
+ the branch name and go back to step 2.
+
+5) The commands from the collection are run line by line via execv() or
+ similar system calls. They are not run as a shell script. Shell
+ expansions are not guaranteed to work and most likely won't.
diff --git a/mysql-test/collections/README.experimental b/mysql-test/collections/README.experimental
new file mode 100644
index 00000000000..9eee2394423
--- /dev/null
+++ b/mysql-test/collections/README.experimental
@@ -0,0 +1,25 @@
+The .experimental files in this directory contain names of test cases that
+are still in development and whose failures should be considered expected,
+instead of regressions.
+
+These files are to be used with the --experimental option of
+mysql-test-run.pl. Please look at its help screen for usage information.
+
+The syntax is as follows:
+
+1) One line per test case.
+
+2) Empty lines and lines starting with a hash (#) are ignored.
+
+3) If any other line contains a blank followed by a hash (#), the hash
+ and any subsequent characters are ignored.
+
+4) The full test case name including the suite and execution mode
+ must be specified, for example:
+ main.alias 'row' # bug#00000
+
+5) As an exception to item 4, the last character of the test case
+ specification may be an asterisk (*). In that case, all test cases that
+ start with the same characters up to the last letter before the asterisk
+ are considered experimental:
+ main.a* # get rid of main.alias, main.alibaba and main.agliolio
diff --git a/mysql-test/collections/default.daily b/mysql-test/collections/default.daily
new file mode 100644
index 00000000000..194cc2aad59
--- /dev/null
+++ b/mysql-test/collections/default.daily
@@ -0,0 +1 @@
+perl mysql-test-run.pl --timer --force --comment=rpl_ndb_row --suite=rpl_ndb,ndb --mysqld=--binlog-format=row --experimental=collections/default.experimental
diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental
new file mode 100644
index 00000000000..103069f79cf
--- /dev/null
+++ b/mysql-test/collections/default.experimental
@@ -0,0 +1 @@
+funcs_1.charset_collation_1 # depends on compile-time decisions
diff --git a/mysql-test/collections/default.push b/mysql-test/collections/default.push
new file mode 100644
index 00000000000..0879b6fde2c
--- /dev/null
+++ b/mysql-test/collections/default.push
@@ -0,0 +1,5 @@
+perl mysql-test-run.pl --timer --force --comment=n_mix --mysqld=--binlog-format=mixed --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=ps_row --ps-protocol --mysqld=--binlog-format=row --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=embedded --embedded --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=rpl_binlog_row --suite=rpl,binlog --mysqld=--binlog-format=row --experimental=collections/default.experimental
+perl mysql-test-run.pl --timer --force --comment=funcs_1 --suite=funcs_1 --experimental=collections/default.experimental
diff --git a/mysql-test/collections/default.weekly b/mysql-test/collections/default.weekly
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mysql-test/collections/default.weekly
diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test
index 98bd116ba29..d72dc693cee 100644
--- a/mysql-test/extra/binlog_tests/binlog.test
+++ b/mysql-test/extra/binlog_tests/binlog.test
@@ -164,6 +164,46 @@ DROP TABLE t1;
DROP DATABASE bug39182;
USE test;
+#
+# Bug#35383: binlog playback and replication breaks due to
+# name_const substitution
+#
+DELIMITER //;
+CREATE PROCEDURE p1(IN v1 INT)
+BEGIN
+ CREATE TABLE t1 SELECT v1;
+ DROP TABLE t1;
+END//
+CREATE PROCEDURE p2()
+BEGIN
+ DECLARE v1 INT;
+ CREATE TABLE t1 SELECT v1+1;
+ DROP TABLE t1;
+END//
+CREATE PROCEDURE p3(IN v1 INT)
+BEGIN
+ CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0;
+ DROP TABLE t1;
+END//
+CREATE PROCEDURE p4(IN v1 INT)
+BEGIN
+ DECLARE v2 INT;
+ CREATE TABLE t1 SELECT 1, v1, v2;
+ DROP TABLE t1;
+ CREATE TABLE t1 SELECT 1, v1+1, v2;
+ DROP TABLE t1;
+END//
+DELIMITER ;//
+
+CALL p1(1);
+CALL p2();
+CALL p3(0);
+CALL p4(0);
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+
--echo End of 5.0 tests
# Test of a too big SET INSERT_ID: see if the truncated value goes
diff --git a/mysql-test/extra/rpl_tests/rpl_deadlock.test b/mysql-test/extra/rpl_tests/rpl_deadlock.test
index 62fe9b2223a..1b331cc948b 100644
--- a/mysql-test/extra/rpl_tests/rpl_deadlock.test
+++ b/mysql-test/extra/rpl_tests/rpl_deadlock.test
@@ -7,125 +7,126 @@
# (Guilhem) have seen the test manage to provoke lock wait timeout
# error but not deadlock error; that is ok as code deals with the two
# errors in exactly the same way.
-# We don't 'show status like 'slave_retried_transactions'' because this
-# is not repeatable (depends on sleeps).
--- source include/master-slave.inc
+--source include/master-slave.inc
+
+# 0) Prepare tables and data
+--echo *** Prepare tables and data ***
connection master;
eval CREATE TABLE t1 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type;
-eval CREATE TABLE t2 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type;
-# requiring 'unique' for the timeout part of the test
-eval CREATE TABLE t3 (a INT UNIQUE) ENGINE=$engine_type;
-eval CREATE TABLE t4 (a INT) ENGINE=$engine_type;
-show variables like 'slave_transaction_retries';
+eval CREATE TABLE t2 (a INT) ENGINE=$engine_type;
+eval CREATE TABLE t3 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type;
sync_slave_with_master;
-show create table t1;
-show create table t2;
-show variables like 'slave_transaction_retries';
-stop slave;
-
-# 1) Test deadlock
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SHOW CREATE TABLE t3;
+SHOW VARIABLES LIKE 'slave_transaction_retries';
+--source include/stop_slave.inc
connection master;
-begin;
-# Let's keep BEGIN and the locked statement in two different relay logs.
-insert into t2 values (0); # t2,t1 actors of deadlock in repl-ed ta
-#insert into t3 select * from t2 for update;
-let $1=10;
-disable_query_log;
-while ($1)
-{
- eval insert into t3 values( $1 );
- dec $1;
-}
-enable_query_log;
-insert into t1 values(1);
-commit;
+BEGIN;
+INSERT INTO t1 VALUES (1);
+# We make a long transaction here
+INSERT INTO t2 VALUES (2), (2), (2), (2), (2), (2), (2), (2), (2), (2);
+INSERT INTO t3 VALUES (3);
+COMMIT;
save_master_pos;
+# Save BEGIN event into variable
+let $master_pos_begin= query_get_value(SHOW BINLOG EVENTS, Pos, 5);
+--echo
-connection slave;
-begin;
-# Let's make our transaction large so that it's repl-ed msta that's victim
-let $1=100;
-disable_query_log;
-while ($1)
-{
- eval insert into t4 values( $1 );
- dec $1;
-}
-enable_query_log;
-select * from t1 for update; # t1,t2 on local slave's
-start slave;
-
-# bad option, todo: replicate a non-transactional t_sync with the transaction
-# and use wait_until_rows_count macro below
---real_sleep 3 # hope that slave is blocked now
-#let $count=11;
-#let $table=t_sync;
-#--include wait_until_rows_count.inc
+# 1) Test deadlock
+# Block slave SQL thread, wait retries of transaction, unlock slave before lock timeout
+--echo *** Test deadlock ***
-select * from t2 for update /* dl */; # provoke deadlock, repl-ed should be victim
-commit;
+connection slave;
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
+# Save variable 'Slave_retried_transactions' before deadlock
+let $slave_retried_transactions= query_get_value(SHOW GLOBAL STATUS LIKE 'Slave_retried_transactions', Value, 1);
+START SLAVE;
+# Wait until SQL thread blocked: variable 'Slave_retried_transactions' will incremented
+let $status_var= Slave_retried_transactions;
+let $status_var_value= $slave_retried_transactions;
+let $status_type= GLOBAL;
+let $status_var_comparsion= >;
+--source include/wait_for_status_var.inc
+SELECT COUNT(*) FROM t2;
+COMMIT;
sync_with_master;
-select * from t1; # check that repl-ed succeeded finally
-select * from t2 /* must be 1 */;
-# check that no error is reported
---replace_column 1 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
---replace_result $MASTER_MYPORT MASTER_MYPORT
---vertical_results
-show slave status;
---horizontal_results
+
+# Check the data
+SELECT * FROM t1;
+SELECT * FROM t3;
+# Check that no error is reported
+--source include/show_slave_status2.inc
+--echo
# 2) Test lock wait timeout
+# Block slave and wait lock timeout error
+--echo *** Test lock wait timeout ***
-stop slave;
-delete from t3;
-change master to master_log_pos=548; # the BEGIN log event
-begin;
-select * from t2 for update; # hold lock
-start slave;
---real_sleep 10 # repl-ed should have blocked, and be retrying
-select count(*) from t3 /* must be zero */; # replaying begins after rollback
-commit;
+connection slave;
+--source include/stop_slave.inc
+DELETE FROM t2;
+# Set slave position to the BEGIN log event
+--replace_result $master_pos_begin MASTER_POS_BEGIN
+eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
+BEGIN;
+# Hold lock
+SELECT * FROM t1 FOR UPDATE;
+# Wait until slave stopped with error 'Lock wait timeout exceeded'
+START SLAVE;
+let $slave_sql_errno= 1205;
+--source include/wait_for_slave_sql_error.inc
+SELECT COUNT(*) FROM t2;
+COMMIT;
+--source include/start_slave.inc
sync_with_master;
-select * from t1; # check that repl-ed succeeded finally
-select * from t2;
-# check that no error is reported
---replace_column 1 # 7 # 8 # 9 # 11 # 16 # 22 # 23 # 33 #
---replace_result $MASTER_MYPORT MASTER_MYPORT
---vertical_results
-show slave status;
---horizontal_results
+# Check data from tables
+SELECT * FROM t1;
+SELECT * FROM t3;
+# Check that no error is reported
+--source include/show_slave_status2.inc
+--echo
-# Now we repeat 2), but with BEGIN in the same relay log as
-# COMMIT (to see if seeking into hot log is ok).
-set @my_max_relay_log_size= @@global.max_relay_log_size;
-set global max_relay_log_size=0;
+# 3) Test lock wait timeout and purged relay log
+# Set max_relay_log_size=0, block slave and wait lock timeout error.
+# Restart slave and check that no erros appear
+--echo *** Test lock wait timeout and purged relay logs ***
-# This is really copy-paste of 2) of above
-stop slave;
-delete from t3;
-change master to master_log_pos=548;
-begin;
-select * from t2 for update;
-start slave;
---real_sleep 10
-select count(*) from t3 /* must be zero */; # replaying begins after rollback
-commit;
+connection slave;
+SET @my_max_relay_log_size= @@global.max_relay_log_size;
+SET global max_relay_log_size=0;
+--source include/stop_slave.inc
+DELETE FROM t2;
+# Set slave position to the BEGIN log event
+eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
+BEGIN;
+# Hold lock
+SELECT * FROM t1 FOR UPDATE;
+# Wait until slave stopped with error 'Lock wait timeout exceeded'
+START SLAVE;
+let $slave_sql_errno= 1205;
+--source include/wait_for_slave_sql_error.inc
+SELECT COUNT(*) FROM t2;
+COMMIT;
+--source include/start_slave.inc
sync_with_master;
-select * from t1;
-select * from t2;
---replace_column 1 # 7 # 8 # 9 # 11 # 16 # 22 # 23 # 33 # 35 # 36 #
---replace_result $MASTER_MYPORT MASTER_MYPORT
---vertical_results
-show slave status;
---horizontal_results
+# Check data from tables
+SELECT * FROM t1;
+SELECT * FROM t3;
+# Check that no error is reported
+--source include/show_slave_status2.inc
+--echo
+# Clean up
+--echo *** Clean up ***
connection master;
-drop table t1,t2,t3,t4;
+DROP TABLE t1,t2,t3;
sync_slave_with_master;
-set global max_relay_log_size= @my_max_relay_log_size;
+SET global max_relay_log_size= @my_max_relay_log_size;
--echo End of 5.1 tests
diff --git a/mysql-test/extra/rpl_tests/rpl_loadfile.test b/mysql-test/extra/rpl_tests/rpl_loadfile.test
new file mode 100644
index 00000000000..85620b58a97
--- /dev/null
+++ b/mysql-test/extra/rpl_tests/rpl_loadfile.test
@@ -0,0 +1,36 @@
+# Begin clean up test section
+--disable_warnings
+connection master;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE IF EXISTS test.t1;
+--enable_warnings
+
+# Section 1 test
+
+CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
+INSERT INTO test.t1 VALUES(1,'test');
+UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1;
+delimiter |;
+create procedure test.p1()
+begin
+ INSERT INTO test.t1 VALUES(2,'test');
+ UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2;
+end|
+delimiter ;|
+
+CALL test.p1();
+SELECT * FROM test.t1 ORDER BY blob_column;
+save_master_pos;
+sync_slave_with_master;
+connection slave;
+# Need to allow some time when NDB engine is used for
+# the injector thread to have time to populate binlog
+let $wait_condition= SELECT INSTR(blob_column,'aberration') > 0 FROM test.t1 WHERE a = 2;
+--source include/wait_condition.inc
+SELECT * FROM test.t1 ORDER BY blob_column;
+
+# Cleanup
+connection master;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE test.t1;
+sync_slave_with_master;
diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test
index 2144957f742..5295dd51a85 100644
--- a/mysql-test/include/check-warnings.test
+++ b/mysql-test/include/check-warnings.test
@@ -26,7 +26,7 @@ create temporary table error_log (
) engine=myisam;
# Get the name of servers error log
-let $log_error= query_get_value(show variables like 'log_error', Value, 1);
+let $log_error= $MTR_LOG_ERROR;
let $log_warning= $log_error.warnings;
# Try tload the warnings into a temporary table,
diff --git a/mysql-test/include/concurrent.inc b/mysql-test/include/concurrent.inc
index 3b34a5b1ede..2180ec4cc9c 100644
--- a/mysql-test/include/concurrent.inc
+++ b/mysql-test/include/concurrent.inc
@@ -11,6 +11,11 @@
# $engine_type storage engine to be tested
#
# Last update:
+# 2009-02-13 HH "Release_lock("hello")" is now also successful when delivering NULL,
+# replaced two sleeps by wait_condition. The last two "sleep 1" have not been
+# replaced as all tried wait conditions leaded to nondeterministic results, especially
+# to succeeding concurrent updates. To replace the sleeps there should be some time
+# planned (or internal knowledge of the server may help).
# 2006-08-02 ML test refactored
# old name was t/innodb_concurrent.test
# main code went into include/concurrent.inc
@@ -20,8 +25,9 @@
# new wrapper t/concurrent_innodb_safelog.test
#
-connection default;
+--source include/not_embedded.inc
+connection default;
#
# Show prerequisites for this test.
#
@@ -50,8 +56,6 @@ GRANT USAGE ON test.* TO mysqltest@localhost;
#
# Preparatory cleanup.
#
-DO release_lock("hello");
-DO release_lock("hello2");
--disable_warnings
drop table if exists t1;
--enable_warnings
@@ -86,13 +90,14 @@ drop table if exists t1;
connection thread2;
--echo ** Start transaction for thread 2
begin;
- --echo ** Update will cause a table scan and a new ULL will
+ --echo ** Update will cause a table scan and a new ULL will
--echo ** be created and blocked on the first row where tipo=11.
send update t1 set eta=1+get_lock("hello",10)*0 where tipo=11;
- sleep 1;
--echo ** connection thread1
connection thread1;
+ let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'User lock';
+ --source include/wait_condition.inc
--echo ** Start new transaction for thread 1
begin;
--echo ** Update on t1 will cause a table scan which will be blocked because
@@ -111,7 +116,9 @@ drop table if exists t1;
}
--echo ** Release user level name lock from thread 1. This will cause the ULL
--echo ** on thread 2 to end its wait.
- select release_lock("hello");
+# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following
+# is also guaranteed for NULL. Replaced SELECT by DO (no result).
+ DO release_lock("hello");
--echo ** Table is now updated with a new eta on tipo=22 for thread 1.
select * from t1;
@@ -119,7 +126,9 @@ drop table if exists t1;
connection thread2;
--echo ** Release the lock and collect result from update on thread 2
reap;
- select release_lock("hello");
+# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following
+# is also guaranteed for NULL. Replaced SELECT by DO (no result).
+ DO release_lock("hello");
--echo ** Table should have eta updates where tipo=11 but updates made by
--echo ** thread 1 shouldn't be visible yet.
select * from t1;
@@ -183,10 +192,11 @@ drop table t1;
--echo ** This will cause a hang on the first row where tipo=1 until the
--echo ** blocking ULL is released.
send update t1 set eta=1+get_lock("hello",10)*0 where tipo=1;
- sleep 1;
- --echo ** connection thread1
+--echo ** connection thread1
connection thread1;
+ let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'User lock';
+ --source include/wait_condition.inc
--echo ** Start transaction on thread 1
begin;
--echo ** Update on t1 will cause a table scan which will be blocked because
@@ -204,7 +214,9 @@ drop table t1;
update t1 set tipo=1 where tipo=2;
}
--echo ** Release ULL. This will release the next waiting ULL on thread 2.
- select release_lock("hello");
+# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically)the success of the following
+# is also guaranteed for NULL. Replaced SELECT by DO (no result).
+ DO release_lock("hello");
--echo ** The table should still be updated with updates for thread 1 only:
select * from t1;
@@ -212,7 +224,9 @@ drop table t1;
connection thread2;
--echo ** Release the lock and collect result from thread 2:
reap;
- select release_lock("hello");
+# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following
+# is also guaranteed for NULL. Replaced SELECT by DO (no result).
+ DO release_lock("hello");
--echo ** Seen from thread 2 the table should have been updated on four
--echo ** places.
select * from t1;
@@ -264,15 +278,18 @@ drop table t1;
--echo ** Update will create a table scan which creates a ULL where a=2;
--echo ** this will hang waiting on thread 1.
send update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
- sleep 1;
--echo ** connection thread1
connection thread1;
+ let $wait_condition= select count(*)= 1 from information_schema.processlist where state= 'User lock';
+ --source include/wait_condition.inc
--echo ** Insert new values to t1 from thread 1; this created an implicit
--echo ** commit since there are no on-going transactions.
insert into t1 values (1,1);
--echo ** Release the ULL (thread 2 updates will finish).
- select release_lock("hello2");
+# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following
+# is also guaranteed for NULL. Replaced SELECT by DO (no result).
+ DO release_lock("hello2");
--echo ** ..but thread 1 will still see t1 as if nothing has happend:
select * from t1;
@@ -280,7 +297,9 @@ drop table t1;
connection thread2;
--echo ** Collect results from thread 2 and release the lock.
reap;
- select release_lock("hello2");
+# Due to Bug#32782 User lock hash fails to find lock, which probably also cause Bug#39484 (main.concurrent_innodb_safelog fails sporadically) the success of the following
+# is also guaranteed for NULL. Replaced SELECT by DO (no result).
+ DO release_lock("hello2");
--echo ** The table should look like the original+updates for thread 2,
--echo ** and consist of new rows:
select * from t1;
@@ -534,6 +553,9 @@ drop table t1;
connection thread2;
begin;
send delete from t1 where tipo=2;
+# The sleep has not been replaced as all tried wait conditions leaded to sporadically
+# succeding update in the following thread. Also the used status variables '%lock%' and
+# 'innodb_deleted_rows' and infos in processlist where not sucessful.
sleep 1;
--echo ** connection thread1
@@ -594,8 +616,11 @@ drop table t1;
connection thread2;
begin;
send delete from t1 where tipo=2;
+# The sleep has not been replaced as all tried wait conditions leaded to sporadically
+# succeding update in the following thread. Also the used status variables '%lock%' and
+# 'innodb_deleted_rows' and infos in processlist where not sucessful.
sleep 1;
-
+
--echo ** connection thread1
connection thread1;
begin;
diff --git a/mysql-test/include/diff_master_slave.inc b/mysql-test/include/diff_master_slave.inc
new file mode 100644
index 00000000000..b6d79190671
--- /dev/null
+++ b/mysql-test/include/diff_master_slave.inc
@@ -0,0 +1,21 @@
+# ==== Purpose ====
+#
+# Diff the output of a statement on master and slave
+#
+# ==== Usage =====
+#
+# let $diff_statement= SELECT * FROM t1 WHERE a < 100;
+# source include/diff_master_slave.inc;
+
+--echo source include/diff_master_slave.inc;
+disable_query_log;
+disable_result_log;
+
+exec $MYSQL test -e "$diff_statement" > $MYSQLTEST_VARDIR/tmp/diff_master.out;
+sync_slave_with_master;
+exec $MYSQL_SLAVE test -e "$diff_statement" > $MYSQLTEST_VARDIR/tmp/diff_slave.out;
+
+diff_files $MYSQLTEST_VARDIR/tmp/diff_master.out $MYSQLTEST_VARDIR/tmp/diff_slave.out;
+
+enable_result_log;
+enable_query_log;
diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc
index 485b2e881d3..96f90aba8e0 100644
--- a/mysql-test/include/handler.inc
+++ b/mysql-test/include/handler.inc
@@ -479,6 +479,7 @@ handler t1 open;
--echo --> client 1
connection default;
drop table t1;
+disconnect con2;
#
# Bug#30632 HANDLER read failure causes hang
@@ -692,3 +693,38 @@ unlock tables;
drop table t1;
--error ER_UNKNOWN_TABLE
handler t1 read a next;
+
+#
+# Bug#41110: crash with handler command when used concurrently with alter table
+# Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+insert into t1 values (1);
+handler t1 open;
+connect(con1,localhost,root,,);
+send alter table t1 engine=memory;
+connection default;
+let $wait_condition=
+ select count(*) = 1 from information_schema.processlist
+ where state = "rename result table" and info = "alter table t1 engine=memory";
+--source include/wait_condition.inc
+--error ER_ILLEGAL_HA
+handler t1 read a next;
+handler t1 close;
+connection con1;
+--reap
+drop table t1;
+disconnect con1;
+connection default;
+
+#
+# Bug#44151 using handler commands on information_schema tables crashes server
+#
+USE information_schema;
+--error ER_WRONG_USAGE
+HANDLER COLUMNS OPEN;
+USE test;
diff --git a/mysql-test/include/kill_query.inc b/mysql-test/include/kill_query.inc
new file mode 100644
index 00000000000..341c3b93535
--- /dev/null
+++ b/mysql-test/include/kill_query.inc
@@ -0,0 +1,68 @@
+# ==== Purpose ====
+#
+# Kill a query in the master connection, and then try to reap the
+# result of the killed query.
+#
+# ==== Usage ====
+#
+# The following variables should be set before sourcing this file.
+#
+# $debug_lock: name of the debug user lock, if set, will release/lock
+# the specified debug lock accordingly, and before
+# sourcing this, connection 'master' should get the user
+# lock and run a query in another thread, which will
+# block before creating statement event.
+#
+# $connection_name: name of the connection that is waiting for the
+# lock, this can not be 'master'
+#
+# $connection_id: id of the connection that is waiting for the lock
+#
+# Example:
+# let $debug_lock=;
+# connection master1;
+# let $connection_name= master1;
+# let $connection_id= `SELECT CONNECTION_ID()`;
+# send CREATE TABLE t1;
+# source kill_query.inc;
+#
+# let $debug_lock= "debug_lock.before_query_log_event";
+# connection master;
+# eval SELECT GET_LOCK($debug_lock, 10);
+# connection master1;
+# let $connection_name= master1;
+# let $connection_id= `SELECT CONNECTION_ID()`;
+# send CREATE TABLE t1;
+# source kill_query.inc;
+
+
+--echo source include/kill_query.inc;
+disable_query_log;
+disable_result_log;
+connection master;
+
+# kill the query that is waiting
+eval kill query $connection_id;
+
+if (`SELECT '$debug_lock' != ''`)
+{
+ # release the lock to allow binlog continue
+ eval SELECT RELEASE_LOCK($debug_lock);
+}
+
+# reap the result of the waiting query
+connection $connection_name;
+error 0, 1317, 1307, 1306, 1334, 1305;
+reap;
+
+connection master;
+
+if (`SELECT '$debug_lock' != ''`)
+{
+ # get lock again to make the next query wait
+ eval SELECT GET_LOCK($debug_lock, 10);
+}
+
+connection $connection_name;
+enable_query_log;
+enable_result_log;
diff --git a/mysql-test/include/kill_query_and_diff_master_slave.inc b/mysql-test/include/kill_query_and_diff_master_slave.inc
new file mode 100644
index 00000000000..611d6929c99
--- /dev/null
+++ b/mysql-test/include/kill_query_and_diff_master_slave.inc
@@ -0,0 +1,43 @@
+# ==== Purpose ====
+#
+# Kill a query, sync master with slave, and diff the output of a
+# statement on master and slave to check if statement is correctly
+# replicated.
+#
+# ==== Usage ====
+#
+# connection <CONNECTION>;
+# let $connection_name=<CONNECTION>
+# let $connection_id=`SELECT CONNECTION_ID()`;
+# let $diff_statement=<SQL COMMAND>;
+# send <SQL COMMAND>;
+# source include/kill_query_and_diff_master_slave.inc;
+#
+# Note: <CONNECTION> must not be 'master'.
+#
+# See also kill_query.inc and diff_master_slave.inc for more
+# information
+
+source include/kill_query.inc;
+
+# Release the debug lock if used, so that the statements in
+# diff_master_slave.inc will not be blocked.
+connection master;
+disable_query_log;
+disable_result_log;
+if (`SELECT '$debug_lock' != ''`)
+{
+ eval SELECT RELEASE_LOCK($debug_lock);
+}
+enable_result_log;
+enable_query_log;
+
+source include/diff_master_slave.inc;
+
+# Acquire the debug lock again if used
+connection master;
+disable_query_log; disable_result_log; if (`SELECT '$debug_lock' !=
+''`) { eval SELECT GET_LOCK($debug_lock, 10); } enable_result_log;
+enable_query_log;
+
+connection $connection_name;
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc
index cc9183205be..7c87949830f 100644
--- a/mysql-test/include/mix1.inc
+++ b/mysql-test/include/mix1.inc
@@ -1122,6 +1122,46 @@ SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5;
DROP TABLE t1;
+#
+# Bug#37284 Crash in Field_string::type()
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (a char(50)) ENGINE=InnoDB;
+CREATE INDEX i1 on t1 (a(3));
+SELECT * FROM t1 WHERE a = 'abcde';
+DROP TABLE t1;
+
+
+--echo #
+--echo # BUG #26288: savepoint are not deleted on comit, if the transaction
+--echo # was otherwise empty
+--echo #
+BEGIN;
+SAVEPOINT s1;
+COMMIT;
+--error 1305
+RELEASE SAVEPOINT s1;
+
+BEGIN;
+SAVEPOINT s2;
+COMMIT;
+--error 1305
+ROLLBACK TO SAVEPOINT s2;
+
+BEGIN;
+SAVEPOINT s3;
+ROLLBACK;
+--error 1305
+RELEASE SAVEPOINT s3;
+
+BEGIN;
+SAVEPOINT s4;
+ROLLBACK;
+--error 1305
+ROLLBACK TO SAVEPOINT s4;
+
--echo End of 5.0 tests
# Fix for BUG#19243 "wrong LAST_INSERT_ID() after ON DUPLICATE KEY
@@ -1368,6 +1408,7 @@ SELECT * FROM t1;
--echo # Switch to connection con2
connection con2;
+--reap
SELECT * FROM t1;
connection default;
@@ -1475,4 +1516,23 @@ DROP TABLE t1;
# DROP TABLE t1;
#
+--echo #
+--echo # Bug #44290: explain crashes for subquery with distinct in
+--echo # SQL_SELECT::test_quick_select
+--echo # (reproduced only with InnoDB tables)
+--echo #
+
+eval
+CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3))
+ ENGINE=$engine_type;
+INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
+
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
+ FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+EXPLAIN
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
+ FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/include/ndb_backup.inc b/mysql-test/include/ndb_backup.inc
index e6780788fe9..5262f1231a2 100644
--- a/mysql-test/include/ndb_backup.inc
+++ b/mysql-test/include/ndb_backup.inc
@@ -2,21 +2,45 @@
# By JBM 2006-02-16 So that the code is not repeated #
# in test cases and can be reused. #
######################################################
+
--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "start backup" >> $NDB_TOOLS_OUTPUT
-# there is no neat way to find the backupid, this is a hack to find it...
-let $dump_file= $MYSQLTEST_VARDIR/tmp/tmp.dat;
---exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="$NDB_CONNECTSTRING" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $dump_file
+# To find the backupid, we must dump this data to a table, and SELECT
+# what we want into an outfile. This could be accomplished with grep, but
+# grep isn't Windows-portable
+
+--disable_query_log
+# create a table to help us out
+--disable_warnings # leave this on until done with the entire process
+# cleanup
+DROP TABLE IF EXISTS helper1;
+CREATE TABLE helper1(c1 VARCHAR(20));
+# dump raw data to file
+let $ndb_backup_file1= $MYSQLTEST_VARDIR/ndb_backup_tmp.dat;
+let $ndb_backup_file2= $MYSQLTEST_VARDIR/tmp.dat;
+--error 0,1
+--remove_file $ndb_backup_file1
+--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="$NDB_CONNECTSTRING" -d sys --delimiter=',' SYSTAB_0 > $ndb_backup_file1
+# load the table from the raw data file
+eval LOAD DATA INFILE '$ndb_backup_file1' INTO TABLE helper1;
+--remove_file $ndb_backup_file1
+# output what we need
+eval SELECT * FROM helper1 WHERE c1 LIKE '%520093696%'
+INTO OUTFILE '$ndb_backup_file2';
+# cleanup
+DROP TABLE helper1;
+--enable_warnings
+--enable_query_log
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
---replace_result $dump_file DUMP_FILE
-eval LOAD DATA INFILE '$dump_file' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval LOAD DATA INFILE '$ndb_backup_file2' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+--remove_file $ndb_backup_file2
# Load backup id into environment variable
let the_backup_id=`SELECT backup_id from test.backup_info`;
-DROP TABLE test.backup_info;
-
-remove_file $dump_file;
+DROP TABLE test.backup_info;
diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc
index 79ff7429466..f88806e1079 100644
--- a/mysql-test/include/setup_fake_relay_log.inc
+++ b/mysql-test/include/setup_fake_relay_log.inc
@@ -69,9 +69,9 @@ let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
# Create relay log file.
copy_file $fake_relay_log $_fake_relay_log;
# Create relay log index.
---exec echo $_fake_relay_log > $_fake_relay_index
+--exec echo $_fake_filename-fake.000001 > $_fake_relay_index
# Setup replication from existing relay log.
-eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_relay_log', RELAY_LOG_POS=4;
+eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_filename-fake.000001', RELAY_LOG_POS=4;
--enable_query_log
diff --git a/mysql-test/include/wait_for_query_to_suceed.inc b/mysql-test/include/wait_for_query_to_succeed.inc
index 6ac1144620e..12ba5c4d9b8 100644
--- a/mysql-test/include/wait_for_query_to_suceed.inc
+++ b/mysql-test/include/wait_for_query_to_succeed.inc
@@ -1,5 +1,5 @@
#
-# Run a query over and over until it suceeds ot timeout occurs
+# Run a query over and over until it succeeds ot timeout occurs
#
@@ -17,7 +17,7 @@ while ($mysql_errno)
if (!$counter)
{
- die("Waited too long for query to suceed");
+ --die "Waited too long for query to succeed";
}
}
enable_abort_on_error;
diff --git a/mysql-test/include/wait_for_status_var.inc b/mysql-test/include/wait_for_status_var.inc
new file mode 100644
index 00000000000..4c168da7f1a
--- /dev/null
+++ b/mysql-test/include/wait_for_status_var.inc
@@ -0,0 +1,68 @@
+# ==== Purpose ====
+#
+# Waits until a variable from SHOW STATUS has returned a specified
+# value, or until a timeout is reached.
+#
+# ==== Usage ====
+#
+# let $status_var= Threads_connected;
+# let $status_var_value= 1;
+# --source include/wait_for_status_var.inc
+#
+# Parameters:
+#
+# $status_var, $status_var_value
+# This macro will wait until the variable of SHOW STATUS
+# named $status_var gets the value $status_var_value. See
+# the example above.
+#
+# $status_type= GLOBAL|SESSION
+# To specify the type (attribute) of status variable and
+# run either SHOW GLOBAL STATUS or SHOW SESSION STATUS.
+#
+# $status_var_comparsion
+# By default, this file waits until $status_var becomes equal to
+# $status_var_value. If you want to wait until $status_var
+# becomes *unequal* to $status_var_value, set this parameter to the
+# string '!=', like this:
+# let $status_var_comparsion= !=;
+#
+# $status_timeout
+# The default timeout is 1 minute. You can change the timeout by
+# setting $status_timeout. The unit is tenths of seconds.
+#
+
+if (`SELECT STRCMP('$status_type', '') * STRCMP(UPPER('$status_type'), 'SESSION') * STRCMP(UPPER('$status_type'), 'GLOBAL')`)
+{
+ --echo **** ERROR: Unknown type of variable status_type: allowed values are: SESSION or GLOBAL ****
+ exit;
+}
+
+let $_status_timeout_counter= $status_timeout;
+if (!$_status_timeout_counter)
+{
+ let $_status_timeout_counter= 600;
+}
+
+let $_status_var_comparsion= $status_var_comparsion;
+if (`SELECT '$_status_var_comparsion' = ''`)
+{
+ let $_status_var_comparsion= =;
+}
+
+let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
+while (`SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_value')`)
+{
+ if (!$_status_timeout_counter)
+ {
+ --echo **** ERROR: failed while waiting for $status_type $status_var $_status_var_comparison $status_var_value ****
+ --echo Note: the following output may have changed since the failure was detected
+ --echo **** Showing STATUS, PROCESSLIST ****
+ eval SHOW $status_type STATUS LIKE '$status_var';
+ SHOW PROCESSLIST;
+ exit;
+ }
+ dec $_status_timeout_counter;
+ sleep 0.1;
+ let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
+}
diff --git a/mysql-test/include/wait_show_condition.inc b/mysql-test/include/wait_show_condition.inc
new file mode 100644
index 00000000000..253101d1e07
--- /dev/null
+++ b/mysql-test/include/wait_show_condition.inc
@@ -0,0 +1,78 @@
+# include/wait_show_condition.inc
+#
+# SUMMARY
+#
+# Waits until the show statement ($show_statement) has at least within one of
+# the rows of the result set for the field ($field) a value which fulfils
+# a condition ($condition), or the operation times out.
+#
+#
+# USAGE
+#
+# let $show_statement= SHOW PROCESSLIST;
+# let $field= State;
+# let $condition= = 'Updating';
+# --source include/wait_show_condition.inc
+#
+# OR
+#
+# let $wait_timeout= 60; # Override default of 30 seconds with 60.
+# let $show_statement= SHOW PROCESSLIST;
+# let $field= State;
+# let $condition= = 'Updating';
+# --source include/wait_show_condition.inc
+#
+# Please do not use this use routine if you can replace the SHOW statement
+# with a select. In such a case include/wait_condition.inc is recommended.
+#
+# Created: 2009-02-18 mleich
+#
+
+let $max_run_time= 30;
+if ($wait_timeout)
+{
+ let $max_run_time= $wait_timeout;
+}
+# Reset $wait_timeout so that its value won't be used on subsequent
+# calls, and default will be used instead.
+let $wait_timeout= 0;
+
+# The smallest timespan till UNIX_TIMESTAMP() gets incremented is ~0 seconds.
+# We add one second to avoid the case that somebody measures timespans on a
+# real clock with fractions of seconds, detects that n seconds are sufficient,
+# assigns n to this routine and suffers because he sometimes gets n - 1
+# seconds in reality.
+inc $max_run_time;
+
+let $found= 0;
+let $max_end_time= `SELECT UNIX_TIMESTAMP() + $max_run_time`;
+while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`)
+{
+ # Sleep a bit to avoid too heavy load.
+ real_sleep 0.2;
+ let $rowno= 1;
+ let $process_result= 1;
+ while (`SELECT $process_result = 1 AND $found = 0`)
+ {
+ let $field_value= query_get_value($show_statement, $field, $rowno);
+ if (`SELECT '$field_value' $condition`)
+ {
+ let $found= 1;
+ }
+ if (`SELECT '$field_value' = 'No such row'`)
+ {
+ # We are behind the last row of the result set.
+ let $process_result= 0;
+ }
+ inc $rowno;
+ }
+}
+if (!$found)
+{
+ echo # Timeout in include/wait_show_condition.inc for $wait_condition;
+ echo # show_statement : $show_statement;
+ echo # field : $field;
+ echo # condition : $condition;
+ echo # max_run_time : $max_run_time;
+}
+
diff --git a/mysql-test/include/wait_until_count_sessions.inc b/mysql-test/include/wait_until_count_sessions.inc
index 36fa9accafe..de4f0eeb652 100644
--- a/mysql-test/include/wait_until_count_sessions.inc
+++ b/mysql-test/include/wait_until_count_sessions.inc
@@ -2,14 +2,23 @@
#
# SUMMARY
#
-# Waits until the passed number ($count_sessions) of concurrent sessions was
-# observed via
+# Waits until the passed number ($count_sessions) of concurrent sessions or
+# a smaller number was observed via
# SHOW STATUS LIKE 'Threads_connected'
# or the operation times out.
-# Note: Starting with 5.1 we could also use
-# SELECT COUNT(*) FROM information_schema.processlist
-# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
-# runs in all versions 5.0+
+# Note:
+# 1. We wait for $current_sessions <= $count_sessions because in the use case
+# with count_sessions.inc before and wait_until_count_sessions.inc after
+# the core of the test it could happen that the disconnects of sessions
+# belonging to the preceeding test are not finished.
+# sessions at test begin($count_sessions) = m + n
+# sessions of the previous test which will be soon disconnected = n (n >= 0)
+# sessions at test end ($current sessions, assuming the test disconnects
+# all additional sessions) = m
+# 2. Starting with 5.1 we could also use
+# SELECT COUNT(*) FROM information_schema.processlist
+# I stay with "SHOW STATUS LIKE 'Threads_connected'" because this
+# runs in all versions 5.0+
#
#
# USAGE
@@ -19,20 +28,20 @@
#
# OR typical example of a test which uses more than one session
# Such a test could harm successing tests if there is no server shutdown
-# and start between.cw
+# and start between.
#
# If the testing box is slow than the disconnect of sessions belonging to
# the current test might happen when the successing test gets executed.
# This means the successing test might see activities like unexpected
# rows within the general log or the PROCESSLIST.
# Example from bug http://bugs.mysql.com/bug.php?id=40377
-# --- bzr_mysql-6.0-rpl/.../r/log_state.result
+# --- bzr_mysql-6.0-rpl/.../r/log_state.result
# +++ bzr_mysql-6.0-rpl/.../r/log_state.reject
# @@ -25,6 +25,7 @@
-# event_time user_host ... command_type argument
-# TIMESTAMP USER_HOST ... Query create table t1(f1 int)
-# TIMESTAMP USER_HOST ... Query select * from mysql.general_log
-# +TIMESTAMP USER_HOST ... Quit
+# event_time user_host ... command_type argument
+# TIMESTAMP USER_HOST ... Query create table t1(f1 int)
+# TIMESTAMP USER_HOST ... Query select * from mysql.general_log
+# +TIMESTAMP USER_HOST ... Quit
# ....
#
# What to do?
@@ -79,10 +88,14 @@
# backup.test, grant3.test
#
#
-# Created: 2009-01-14 mleich
+# Created:
+# 2009-01-14 mleich
+# Modified:
+# 2009-02-24 mleich Fix Bug#43114 wait_until_count_sessions too restrictive,
+# random PB failures
#
-let $wait_counter= 50;
+let $wait_counter= 100;
if ($wait_timeout)
{
let $wait_counter= `SELECT $wait_timeout * 10`;
@@ -93,7 +106,7 @@ let $wait_timeout= 0;
while ($wait_counter)
{
let $current_sessions= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1);
- let $success= `SELECT $current_sessions = $count_sessions`;
+ let $success= `SELECT $current_sessions <= $count_sessions`;
if ($success)
{
let $wait_counter= 0;
@@ -107,6 +120,7 @@ while ($wait_counter)
if (!$success)
{
--echo # Timeout in wait_until_count_sessions.inc
- --echo # Number of sessions expected: $count_sessions found: $current_sessions
+ --echo # Number of sessions expected: <= $count_sessions found: $current_sessions
+ SHOW PROCESSLIST;
}
diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm
index 567a05ac7a1..852f706c858 100644
--- a/mysql-test/lib/My/ConfigFactory.pm
+++ b/mysql-test/lib/My/ConfigFactory.pm
@@ -116,8 +116,8 @@ sub fix_tmpdir {
sub fix_log_error {
my ($self, $config, $group_name, $group)= @_;
- my $dir= dirname($group->value('datadir'));
- return "$dir/mysqld.err";
+ my $dir= $self->{ARGS}->{vardir};
+ return "$dir/log/$group_name.err";
}
sub fix_log {
@@ -203,7 +203,7 @@ my @mysqld_rules=
{ '#host' => \&fix_host },
{ 'port' => \&fix_port },
{ 'socket' => \&fix_socket },
- { 'log-error' => \&fix_log_error },
+ { '#log-error' => \&fix_log_error },
{ 'log' => \&fix_log },
{ 'log-slow-queries' => \&fix_log_slow_queries },
{ '#user' => sub { return shift->{ARGS}->{user} || ""; } },
@@ -389,7 +389,7 @@ sub post_check_embedded_group {
my @no_copy =
(
- 'log-error', # Embedded server writes stderr to mysqltest's log file
+ '#log-error', # Embedded server writes stderr to mysqltest's log file
'slave-net-timeout', # Embedded server are not build with replication
);
diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm
index 599f9ccbfca..f3e9f521384 100644
--- a/mysql-test/lib/My/CoreDump.pm
+++ b/mysql-test/lib/My/CoreDump.pm
@@ -104,9 +104,136 @@ EOF
}
+# Check that Debugging tools for Windows are installed
+sub cdb_check {
+ `cdb -? 2>&1`;
+ if ($? >> 8)
+ {
+ print "Cannot find cdb. Please Install Debugging tools for Windows\n";
+ print "from http://www.microsoft.com/whdc/devtools/debugging/";
+ if($ENV{'ProgramW6432'})
+ {
+ print "install64bit.mspx (native x64 version)\n";
+ }
+ else
+ {
+ print "installx86.mspx\n";
+ }
+ }
+}
+
+
+sub _cdb {
+ my ($core_name)= @_;
+ print "\nTrying 'cdb' to get a backtrace\n";
+ return unless -f $core_name;
+
+ # Try to set environment for debugging tools for Windows
+ if ($ENV{'PATH'} !~ /Debugging Tools/)
+ {
+ if ($ENV{'ProgramW6432'})
+ {
+ # On x64 computer
+ $ENV{'PATH'}.= ";".$ENV{'ProgramW6432'}."\\Debugging Tools For Windows (x64)";
+ }
+ else
+ {
+ # On x86 computer. Newest versions of Debugging tools are installed in the
+ # directory with (x86) suffix, older versions did not have this suffix.
+ $ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows (x86)";
+ $ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows";
+ }
+ }
+
+
+ # Read module list, find out the name of executable and
+ # build symbol path (required by cdb if executable was built on
+ # different machine)
+ my $tmp_name= $core_name.".cdb_lmv";
+ `cdb -z $core_name -c \"lmv;q\" > $tmp_name 2>&1`;
+ if ($? >> 8)
+ {
+ unlink($tmp_name);
+ # check if cdb is installed and complain if not
+ cdb_check();
+ return;
+ }
+
+ open(temp,"< $tmp_name");
+ my %dirhash=();
+ while(<temp>)
+ {
+ if($_ =~ /Image path\: (.*)/)
+ {
+ if (rindex($1,'\\') != -1)
+ {
+ my $dir= substr($1, 0, rindex($1,'\\'));
+ $dirhash{$dir}++;
+ }
+ }
+ }
+ close(temp);
+ unlink($tmp_name);
+
+ my $image_path= join(";", (keys %dirhash),".");
+
+ # For better callstacks, setup _NT_SYMBOL_PATH to include
+ # OS symbols. Note : Dowloading symbols for the first time
+ # can take some minutes
+ if (!$ENV{'_NT_SYMBOL_PATH'})
+ {
+ my $windir= $ENV{'windir'};
+ my $symbol_cache= substr($windir ,0, index($windir,'\\'))."\\cdb_symbols";
+
+ print "OS debug symbols will be downloaded and stored in $symbol_cache.\n";
+ print "You can control the location of symbol cache with _NT_SYMBOL_PATH\n";
+ print "environment variable. Please refer to Microsoft KB article\n";
+ print "http://support.microsoft.com/kb/311503 for details about _NT_SYMBOL_PATH\n";
+ print "-------------------------------------------------------------------------\n";
+
+ $ENV{'_NT_SYMBOL_PATH'}.=
+ "srv*".$symbol_cache."*http://msdl.microsoft.com/download/symbols";
+ }
+
+ my $symbol_path= $image_path.";".$ENV{'_NT_SYMBOL_PATH'};
+
+
+ # Run cdb. Use "analyze" extension to print crashing thread stacktrace
+ # and "uniqstack" to print other threads
+
+ my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;!uniqstack -p;q";
+ my $cdb_output=
+ `cdb -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines -c "$cdb_cmd" 2>&1`;
+ return if $? >> 8;
+ return unless $cdb_output;
+
+ # Remove comments (lines starting with *), stack pointer and frame
+ # pointer adresses and offsets to function to make output better readable
+ $cdb_output=~ s/^\*.*\n//gm;
+ $cdb_output=~ s/^([\:0-9a-fA-F\`]+ )+//gm;
+ $cdb_output=~ s/^ChildEBP RetAddr//gm;
+ $cdb_output=~ s/^Child\-SP RetAddr Call Site//gm;
+ $cdb_output=~ s/\+0x([0-9a-fA-F]+)//gm;
+
+ print <<EOF, $cdb_output, "\n";
+Output from cdb follows. Faulting thread is printed twice,with and without function parameters
+Search for STACK_TEXT to see the stack trace of
+the faulting thread. Callstacks of other threads are printed after it.
+EOF
+ return 1;
+}
+
+
sub show {
my ($class, $core_name)= @_;
+ # On Windows, rely on cdb to be there...
+ if (IS_WINDOWS)
+ {
+ _cdb($core_name);
+ return;
+ }
+
# We try dbx first; gdb itself may coredump if run on a Sun Studio
# compiled binary on Solaris.
diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm
index 3dd5c552b10..69ffdfbb4ce 100644
--- a/mysql-test/lib/My/Platform.pm
+++ b/mysql-test/lib/My/Platform.pm
@@ -113,8 +113,8 @@ sub check_socket_path_length {
# Create a tempfile name with same length as "path"
my $tmpdir = tempdir( CLEANUP => 0);
- my $len = length($path) - length($tmpdir);
- my $testfile = $tmpdir . "x" x ($len > 0 ? $len : 1);
+ my $len = length($path) - length($tmpdir) - 1;
+ my $testfile = $tmpdir . "/" . "x" x ($len > 0 ? $len : 1);
my $sock;
eval {
$sock= new IO::Socket::UNIX
@@ -126,17 +126,15 @@ sub check_socket_path_length {
die "Could not create UNIX domain socket: $!"
unless defined $sock;
- die "UNIX domain socket patch was truncated"
+ die "UNIX domain socket path was truncated"
unless ($testfile eq $sock->hostpath());
$truncated= 0; # Yes, it worked!
};
- #print "check_socket_path_length, failed: ", $@, '\n' if ($@);
$sock= undef; # Close socket
- unlink($testfile); # Remove the physical file
- rmdir($tmpdir); # Remove the tempdir
+ rmtree($tmpdir); # Remove the tempdir and any socket file created
return $truncated;
}
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm
index 0e3aa968052..5ef3286ad8e 100644
--- a/mysql-test/lib/My/SafeProcess.pm
+++ b/mysql-test/lib/My/SafeProcess.pm
@@ -117,6 +117,7 @@ sub new {
my $output = delete($opts{'output'});
my $error = delete($opts{'error'});
my $verbose = delete($opts{'verbose'});
+ my $nocore = delete($opts{'nocore'});
my $host = delete($opts{'host'});
my $shutdown = delete($opts{'shutdown'});
my $user_data= delete($opts{'user_data'});
@@ -137,6 +138,7 @@ sub new {
push(@safe_args, $safe_script) if defined $safe_script;
push(@safe_args, "--verbose") if $verbose > 0;
+ push(@safe_args, "--nocore") if $nocore;
# Point the safe_process at the right parent if running on cygwin
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;
diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc
index 7932f3fd2d6..dc7b7da28c7 100644
--- a/mysql-test/lib/My/SafeProcess/safe_process.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process.cc
@@ -45,6 +45,8 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
@@ -149,7 +151,8 @@ int main(int argc, char* const argv[] )
char* const* child_argv= 0;
pid_t own_pid= getpid();
pid_t parent_pid= getppid();
-
+ bool nocore = false;
+
/* Install signal handlers */
signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal);
@@ -181,6 +184,9 @@ int main(int argc, char* const argv[] )
start++; /* Step past = */
if ((parent_pid= atoi(start)) == 0)
die("Invalid value '%s' passed to --parent-id", start);
+ } else if ( strcmp(arg, "--nocore") == 0 )
+ {
+ nocore = true; // Don't allow the process to dump core
}
else
die("Unknown option: %s", arg);
@@ -218,6 +224,15 @@ int main(int argc, char* const argv[] )
// it and any childs(that hasn't changed group themself)
setpgid(0, 0);
+ if (nocore)
+ {
+ struct rlimit corelim = { 0, 0 };
+ if (setrlimit (RLIMIT_CORE, &corelim) < 0)
+ {
+ message("setrlimit failed, errno=%d", errno);
+ }
+ }
+
// Signal that child is ready
buf= 37;
write(pfd[1], &buf, 1);
diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
index 640254875c9..4fb89f098ed 100755
--- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
@@ -77,14 +77,29 @@ static void message(const char* fmt, ...)
static void die(const char* fmt, ...)
{
+ DWORD last_err= GetLastError();
va_list args;
fprintf(stderr, "%s: FATAL ERROR, ", safe_process_name);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
- if (int last_err= GetLastError())
- fprintf(stderr, "error: %d, %s\n", last_err, strerror(last_err));
+ if (last_err)
+ {
+ char *message_text;
+ if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER
+ |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, last_err , 0, (LPSTR)&message_text,
+ 0, NULL))
+ {
+ fprintf(stderr,"error: %d, %s\n",last_err, message_text);
+ LocalFree(message_text);
+ }
+ else
+ {
+ /* FormatMessage failed, print error code only */
+ fprintf(stderr,"error:%d\n", last_err);
+ }
+ }
fflush(stderr);
exit(1);
}
diff --git a/mysql-test/lib/mtr_gcov.pl b/mysql-test/lib/mtr_gcov.pl
index 5049fdd6063..f531889b08d 100644
--- a/mysql-test/lib/mtr_gcov.pl
+++ b/mysql-test/lib/mtr_gcov.pl
@@ -22,40 +22,46 @@ use strict;
sub gcov_prepare ($) {
my ($dir)= @_;
+ print "Purging gcov information from '$dir'...\n";
- `find $dir -name \*.gcov \
- -or -name \*.da | xargs rm`;
+ system("find $dir -name \*.gcov -o -name \*.da"
+ . " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm");
}
-my @mysqld_src_dirs=
- (
- "strings",
- "mysys",
- "include",
- "extra",
- "regex",
- "isam",
- "merge",
- "myisam",
- "myisammrg",
- "heap",
- "sql",
- );
-
+#
+# Collect gcov statistics.
+# Arguments:
+# $dir basedir, normally source directory
+# $gcov gcov utility program [path] name
+# $gcov_msg message file name
+# $gcov_err error file name
+#
sub gcov_collect ($$$) {
my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
+ # Get current directory to return to later.
my $start_dir= cwd();
- print "Collecting source coverage info...\n";
- -f $gcov_msg and unlink($gcov_msg);
- -f $gcov_err and unlink($gcov_err);
- foreach my $d ( @mysqld_src_dirs )
- {
- chdir("$dir/$d");
- foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
- {
- `$gcov $f 2>>$gcov_err >>$gcov_msg`;
+ print "Collecting source coverage info using '$gcov'...\n";
+ -f "$start_dir/$gcov_msg" and unlink("$start_dir/$gcov_msg");
+ -f "$start_dir/$gcov_err" and unlink("$start_dir/$gcov_err");
+
+ my @dirs= `find "$dir" -type d -print | sort`;
+ #print "List of directories:\n@dirs\n";
+
+ foreach my $d ( @dirs ) {
+ my $dir_reported= 0;
+ chomp($d);
+ chdir($d) or next;
+
+ foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) ) {
+ $f =~ /(.*)\.[ch]c?/;
+ -f "$1.gcno" or next;
+ if (!$dir_reported) {
+ print "Collecting in '$d'...\n";
+ $dir_reported= 1;
+ }
+ system("$gcov $f 2>>$start_dir/$gcov_err >>$start_dir/$gcov_msg");
}
chdir($start_dir);
}
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index ce3fba87385..9c6ab35ee5e 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -69,6 +69,8 @@ sub _mtr_report_test_name ($) {
print _name(), _timestamp();
printf "%-40s ", $tname;
+
+ return $tname;
}
@@ -105,20 +107,48 @@ sub mtr_report_test_passed ($) {
sub mtr_report_test ($) {
my ($tinfo)= @_;
- _mtr_report_test_name($tinfo);
+ my $test_name = _mtr_report_test_name($tinfo);
my $comment= $tinfo->{'comment'};
my $logfile= $tinfo->{'logfile'};
my $warnings= $tinfo->{'warnings'};
my $result= $tinfo->{'result'};
+ my $retry= $tinfo->{'retries'} ? "retry-" : "";
if ($result eq 'MTR_RES_FAILED'){
my $timest = format_time();
+ my $fail = "fail";
+
+ if ( $::opt_experimental )
+ {
+ # Find out if this test case is an experimental one, so we can treat
+ # the failure as an expected failure instead of a regression.
+ for my $exp ( @$::experimental_test_cases ) {
+ if ( $exp ne $test_name ) {
+ # if the expression is not the name of this test case, but has
+ # an asterisk at the end, determine if the characters up to
+ # but excluding the asterisk are the same
+ if ( $exp ne "" && substr($exp, -1, 1) eq "*" ) {
+ $exp = substr($exp, 0, length($exp) - 1);
+ if ( substr($test_name, 0, length($exp)) ne $exp ) {
+ # no match, try next entry
+ next;
+ }
+ # if yes, fall through to set the exp-fail status
+ } else {
+ # no match, try next entry
+ next;
+ }
+ }
+ $fail = "exp-fail";
+ last;
+ }
+ }
if ( $warnings )
{
- mtr_report("[ fail ] Found warnings/errors in server log file!");
+ mtr_report("[ $retry$fail ] Found warnings/errors in server log file!");
mtr_report(" Test ended at $timest");
mtr_report($warnings);
return;
@@ -126,14 +156,14 @@ sub mtr_report_test ($) {
my $timeout= $tinfo->{'timeout'};
if ( $timeout )
{
- mtr_report("[ fail ] timeout after $timeout seconds");
+ mtr_report("[ $retry$fail ] timeout after $timeout seconds");
mtr_report(" Test ended at $timest");
mtr_report("\n$tinfo->{'comment'}");
return;
}
else
{
- mtr_report("[ fail ]\n Test ended at $timest");
+ mtr_report("[ $retry$fail ]\n Test ended at $timest");
}
if ( $logfile )
@@ -176,7 +206,7 @@ sub mtr_report_test ($) {
{
my $timer_str= $tinfo->{timer} || "";
$tot_real_time += ($timer_str/1000);
- mtr_report("[ pass ] ", sprintf("%5s", $timer_str));
+ mtr_report("[ ${retry}pass ] ", sprintf("%5s", $timer_str));
# Show any problems check-testcase found
if ( defined $tinfo->{'check'} )
diff --git a/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm
index 2ac172883a2..294a5d7b4d6 100644
--- a/mysql-test/lib/mtr_unique.pm
+++ b/mysql-test/lib/mtr_unique.pm
@@ -188,6 +188,8 @@ sub mtr_release_unique_id($) {
flock SEM, LOCK_UN or warn "can't unlock $file.sem";
close SEM;
+
+ delete $mtr_unique_ids{$$};
}
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index ba426446075..3949148ec49 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -107,6 +107,17 @@ our $default_vardir;
our $opt_vardir; # Path to use for var/ dir
my $path_vardir_trace; # unix formatted opt_vardir for trace files
my $opt_tmpdir; # Path to use for tmp/ dir
+my $opt_tmpdir_pid;
+
+END {
+ if ( defined $opt_tmpdir_pid and $opt_tmpdir_pid == $$ )
+ {
+ # Remove the tempdir this process has created
+ mtr_verbose("Removing tmpdir '$opt_tmpdir");
+ rmtree($opt_tmpdir);
+ }
+}
+
my $path_config_file; # The generated config file, var/my.cnf
# Visual Studio produces executables in different sub-directories based on the
@@ -152,8 +163,9 @@ our $opt_force;
our $opt_mem= $ENV{'MTR_MEM'};
our $opt_gcov;
-our $opt_gcov_err;
-our $opt_gcov_msg;
+our $opt_gcov_exe= "gcov";
+our $opt_gcov_err= "mysql-test-gcov.msg";
+our $opt_gcov_msg= "mysql-test-gcov.err";
our $glob_debugger= 0;
our $opt_gdb;
@@ -169,12 +181,18 @@ our $opt_client_debugger;
my $config; # The currently running config
my $current_config_name; # The currently running config file template
+our $opt_experimental;
+our $experimental_test_cases;
+
my $baseport;
my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto";
+my $build_thread= 0;
my $opt_record;
my $opt_report_features;
+my $opt_skip_core;
+
our $opt_check_testcases= 1;
my $opt_mark_progress;
@@ -385,7 +403,7 @@ sub main {
mtr_print_line();
if ( $opt_gcov ) {
- gcov_collect($basedir, $opt_gcov,
+ gcov_collect($basedir, $opt_gcov_exe,
$opt_gcov_msg, $opt_gcov_err);
}
@@ -665,14 +683,9 @@ sub run_worker ($) {
report_option('name',"worker[$thread_num]");
# --------------------------------------------------------------------------
- # Use auto build thread in all but first worker
+ # Set different ports per thread
# --------------------------------------------------------------------------
- set_build_thread_ports($thread_num > 1 ? 'auto' : $opt_build_thread);
-
- if (check_ports_free()){
- # Some port was not free(which one has already been printed)
- mtr_error("Some port(s) was not free")
- }
+ set_build_thread_ports($thread_num);
# --------------------------------------------------------------------------
# Turn off verbosity in workers, unless explicitly specified
@@ -792,7 +805,7 @@ sub command_line_setup {
'big-test' => \$opt_big_test,
'combination=s' => \@opt_combinations,
'skip-combinations' => \&collect_option,
-
+ 'experimental=s' => \$opt_experimental,
'skip-im' => \&ignore_option,
# Specify ports
@@ -932,12 +945,12 @@ sub command_line_setup {
}
# Look for language files and charsetsdir, use same share
- my $path_share= mtr_path_exists("$basedir/share/mysql",
- "$basedir/sql/share",
- "$basedir/share");
+ $path_language= mtr_path_exists("$basedir/share/mysql/english",
+ "$basedir/sql/share/english",
+ "$basedir/share/english");
+
-
- $path_language= mtr_path_exists("$path_share/english");
+ my $path_share= dirname($path_language);
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
if (using_extern())
@@ -959,6 +972,33 @@ sub command_line_setup {
mtr_print_thick_line('#');
}
+ if ( $opt_experimental )
+ {
+ # read the list of experimental test cases from the file specified on
+ # the command line
+ open(FILE, "<", $opt_experimental) or mtr_error("Can't read experimental file: $opt_experimental");
+ mtr_report("Using experimental file: $opt_experimental");
+ $experimental_test_cases = [];
+ while(<FILE>) {
+ chomp;
+ # remove comments (# foo) at the beginning of the line, or after a
+ # blank at the end of the line
+ s/( +|^)#.*$//;
+ # remove whitespace
+ s/^ +//;
+ s/ +$//;
+ # if nothing left, don't need to remember this line
+ if ( $_ eq "" ) {
+ next;
+ }
+ # remember what is left as the name of another test case that should be
+ # treated as experimental
+ print " - $_\n";
+ push @$experimental_test_cases, $_;
+ }
+ close FILE;
+ }
+
foreach my $arg ( @ARGV )
{
if ( $arg =~ /^--skip-/ )
@@ -1066,8 +1106,11 @@ sub command_line_setup {
" creating a shorter one...");
# Create temporary directory in standard location for temporary files
- $opt_tmpdir= tempdir( TMPDIR => 1, CLEANUP => 1 );
+ $opt_tmpdir= tempdir( TMPDIR => 1, CLEANUP => 0 );
mtr_report(" - using tmpdir: '$opt_tmpdir'\n");
+
+ # Remember pid that created dir so it's removed by correct process
+ $opt_tmpdir_pid= $$;
}
}
$opt_tmpdir =~ s,/+$,,; # Remove ending slash if any
@@ -1080,6 +1123,14 @@ sub command_line_setup {
}
# --------------------------------------------------------------------------
+ # Check parallel value
+ # --------------------------------------------------------------------------
+ if ($opt_parallel < 1)
+ {
+ mtr_error("0 or negative parallel value makes no sense, use positive number");
+ }
+
+ # --------------------------------------------------------------------------
# Record flag
# --------------------------------------------------------------------------
if ( $opt_record and ! @opt_cases )
@@ -1268,18 +1319,32 @@ sub command_line_setup {
# But a fairly safe range seems to be 5001 - 32767
#
sub set_build_thread_ports($) {
- my $build_thread= shift || 0;
+ my $thread= shift || 0;
- if ( lc($build_thread) eq 'auto' ) {
- #mtr_report("Requesting build thread... ");
- $build_thread= mtr_get_unique_id(250, 299);
- if ( !defined $build_thread ) {
- mtr_error("Could not get a unique build thread id");
+ if ( lc($opt_build_thread) eq 'auto' ) {
+ my $found_free = 0;
+ $build_thread = 250; # Start attempts from here
+ while (! $found_free)
+ {
+ $build_thread= mtr_get_unique_id($build_thread, 299);
+ if ( !defined $build_thread ) {
+ mtr_error("Could not get a unique build thread id");
+ }
+ $found_free= check_ports_free($build_thread);
+ # If not free, release and try from next number
+ mtr_release_unique_id($build_thread++) unless $found_free;
}
- #mtr_report(" - got $build_thread");
+ }
+ else
+ {
+ $build_thread = $opt_build_thread + $thread - 1;
}
$ENV{MTR_BUILD_THREAD}= $build_thread;
- $opt_build_thread= $build_thread;
+
+ if (! check_ports_free($build_thread)) {
+ # Some port was not free(which one has already been printed)
+ mtr_error("Some port(s) was not free")
+ }
# Calculate baseport
$baseport= $build_thread * 10 + 10000;
@@ -1535,14 +1600,22 @@ sub mysql_fix_arguments () {
}
-sub client_arguments ($) {
+sub client_arguments ($;$) {
my $client_name= shift;
+ my $group_suffix= shift;
my $client_exe= mtr_exe_exists("$path_client_bindir/$client_name");
my $args;
mtr_init_args(\$args);
mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
- client_debug_arg($args, $client_name);
+ if (defined($group_suffix)) {
+ mtr_add_arg($args, "--defaults-group-suffix=%s", $group_suffix);
+ client_debug_arg($args, "$client_name-$group_suffix");
+ }
+ else
+ {
+ client_debug_arg($args, $client_name);
+ }
return mtr_args2str($client_exe, @$args);
}
@@ -1793,6 +1866,7 @@ sub environment_setup {
$ENV{'MYSQL_SHOW'}= client_arguments("mysqlshow");
$ENV{'MYSQL_BINLOG'}= client_arguments("mysqlbinlog");
$ENV{'MYSQL'}= client_arguments("mysql");
+ $ENV{'MYSQL_SLAVE'}= client_arguments("mysql", ".2");
$ENV{'MYSQL_UPGRADE'}= client_arguments("mysql_upgrade");
$ENV{'MYSQLADMIN'}= native_path($exe_mysqladmin);
$ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments();
@@ -2433,22 +2507,18 @@ sub kill_leftovers ($) {
# Check that all the ports that are going to
# be used are free
#
-sub check_ports_free
+sub check_ports_free ($)
{
- my @ports_to_check;
- for ($baseport..$baseport+9){
- push(@ports_to_check, $_);
- }
- #mtr_report("Checking ports...");
- # print "@ports_to_check\n";
- foreach my $port (@ports_to_check){
- if (mtr_ping_port($port)){
- mtr_report(" - 'localhost:$port' was not free");
- return 1; # One port was not free
+ my $bthread= shift;
+ my $portbase = $bthread * 10 + 10000;
+ for ($portbase..$portbase+9){
+ if (mtr_ping_port($_)){
+ mtr_report(" - 'localhost:$_' was not free");
+ return 0; # One port was not free
}
}
- return 0; # All ports free
+ return 1; # All ports free
}
@@ -2860,9 +2930,6 @@ test case was executed:\n";
$result= 2;
}
- # Remove the .err file the check generated
- unlink($err_file);
-
# Remove the .result file the check generated
unlink("$base_file.result");
@@ -3470,7 +3537,10 @@ sub start_check_warnings ($$) {
my $name= "warnings-".$mysqld->name();
- extract_warning_lines($mysqld->value('log-error'));
+ my $log_error= $mysqld->value('#log-error');
+ # To be communicated to the test
+ $ENV{MTR_LOG_ERROR}= $log_error;
+ extract_warning_lines($log_error);
my $args;
mtr_init_args(\$args);
@@ -3480,6 +3550,7 @@ sub start_check_warnings ($$) {
mtr_add_arg($args, "--skip-safemalloc");
mtr_add_arg($args, "--test-file=%s", "include/check-warnings.test");
+ mtr_add_arg($args, "--verbose");
if ( $opt_embedded_server )
{
@@ -3569,10 +3640,9 @@ sub check_warnings ($) {
if ( $res == 62 ) {
# Test case was ok and called "skip"
- ;
+ # Remove the .err file the check generated
+ unlink($err_file);
}
- # Remove the .err file the check generated
- unlink($err_file);
if ( keys(%started) == 0){
# All checks completed
@@ -3594,8 +3664,6 @@ sub check_warnings ($) {
$result= 2;
}
- # Remove the .err file the check generated
- unlink($err_file);
}
elsif ( $proc eq $timeout_proc ) {
$tinfo->{comment}.= "Timeout $timeout_proc for ".
@@ -3947,6 +4015,7 @@ sub mysqld_arguments ($$$) {
mtr_add_arg($args, "%s", $arg);
}
}
+ $opt_skip_core = $found_skip_core;
if ( !$found_skip_core )
{
mtr_add_arg($args, "%s", "--core-file");
@@ -3986,6 +4055,12 @@ sub mysqld_start ($$) {
$path_vardir_trace, $mysqld->name());
}
+ if (IS_WINDOWS)
+ {
+ # Trick the server to send output to stderr, with --console
+ mtr_add_arg($args, "--console");
+ }
+
if ( $opt_gdb || $opt_manual_gdb )
{
gdb_arguments(\$args, \$exe, $mysqld->name());
@@ -4018,7 +4093,7 @@ sub mysqld_start ($$) {
# Remove the old pidfile if any
unlink($mysqld->value('pid-file'));
- my $output= $mysqld->value('log-error');
+ my $output= $mysqld->value('#log-error');
if ( $opt_valgrind and $opt_debug )
{
# When both --valgrind and --debug is selected, send
@@ -4038,6 +4113,7 @@ sub mysqld_start ($$) {
error => $output,
append => 1,
verbose => $opt_verbose,
+ nocore => $opt_skip_core,
host => undef,
shutdown => sub { mysqld_stop($mysqld) },
);
@@ -4090,12 +4166,6 @@ sub server_need_restart {
return 0;
}
- if ( $opt_embedded_server )
- {
- mtr_verbose_restart($server, "no start or restart for embedded server");
- return 0;
- }
-
if ( $tinfo->{'force_restart'} ) {
mtr_verbose_restart($server, "forced in .opt file");
return 1;
@@ -4325,7 +4395,7 @@ sub start_servers($) {
# Already started
# Write start of testcase to log file
- mark_log($mysqld->value('log-error'), $tinfo);
+ mark_log($mysqld->value('#log-error'), $tinfo);
next;
}
@@ -4384,7 +4454,7 @@ sub start_servers($) {
mkpath($tmpdir) unless -d $tmpdir;
# Write start of testcase to log file
- mark_log($mysqld->value('log-error'), $tinfo);
+ mark_log($mysqld->value('#log-error'), $tinfo);
# Run <tname>-master.sh
if ($mysqld->option('#!run-master-sh') and
@@ -4435,7 +4505,7 @@ sub start_servers($) {
$tinfo->{comment}=
"Failed to start ".$mysqld->name();
- my $logfile= $mysqld->value('log-error');
+ my $logfile= $mysqld->value('#log-error');
if ( defined $logfile and -f $logfile )
{
$tinfo->{logfile}= mtr_fromfile($logfile);
@@ -4479,6 +4549,7 @@ sub start_check_testcase ($$$) {
mtr_add_arg($args, "--result-file=%s", "$opt_vardir/tmp/$name.result");
mtr_add_arg($args, "--test-file=%s", "include/check-testcase.test");
+ mtr_add_arg($args, "--verbose");
if ( $mode eq "before" )
{
@@ -4648,8 +4719,7 @@ sub start_mysqltest ($) {
elsif ( $opt_client_debugger )
{
debugger_arguments(\$args, \$exe, "client");
- }
-
+ }
my $proc= My::SafeProcess->new
(
@@ -5048,6 +5118,8 @@ Misc options
to turn off.
sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time
+ gcov Collect coverage information after the test.
+ The result is a gcov file per source and header file.
HERE
exit(1);
diff --git a/mysql-test/r/archive_gis.result b/mysql-test/r/archive_gis.result
index 901f8a9acc2..178c5716911 100644
--- a/mysql-test/r/archive_gis.result
+++ b/mysql-test/r/archive_gis.result
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.416666666667 25.416666666667)
+109 POINT(25.4166666666667 25.4166666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.588527753042 17.426536064114)
-118 POINT(55.588527753042 17.426536064114)
+117 POINT(55.5885277530424 17.426536064114)
+118 POINT(55.5885277530424 17.426536064114)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result
index b657c620805..bab2c83448c 100644
--- a/mysql-test/r/backup.result
+++ b/mysql-test/r/backup.result
@@ -4,23 +4,23 @@ create table t4(n int);
backup table t4 to '../../bogus';
Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X)
-test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X)
test.t4 backup status Operation failed
backup table t4 to '../../tmp';
Table Op Msg_type Msg_text
-test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t4 backup status OK
backup table t4 to '../../tmp';
Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X)
-test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t4 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X)
test.t4 backup status Operation failed
drop table t4;
restore table t4 from '../../tmp';
Table Op Msg_type Msg_text
-test.t4 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t4 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t4 restore status OK
select count(*) from t4;
count(*)
@@ -29,18 +29,18 @@ create table t1(n int);
insert into t1 values (23),(45),(67);
backup table t1 to '../../tmp';
Table Op Msg_type Msg_text
-test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t1 backup status OK
drop table t1;
restore table t1 from '../../bogus';
Table Op Msg_type Msg_text
t1 restore error Failed copying .frm file
Warnings:
-Warning 1287 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+Warning 1287 The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
Error 29 File 'MYSQLTEST_VARDIR/bogus/t1.frm' not found (Errcode: X)
restore table t1 from '../../tmp';
Table Op Msg_type Msg_text
-test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t1 restore status OK
select n from t1;
n
@@ -53,13 +53,13 @@ insert into t2 values (123),(145),(167);
insert into t3 values (223),(245),(267);
backup table t2,t3 to '../../tmp';
Table Op Msg_type Msg_text
-test.t2 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t2 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t2 backup status OK
test.t3 backup status OK
drop table t1,t2,t3;
restore table t1,t2,t3 from '../../tmp';
Table Op Msg_type Msg_text
-test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t1 restore status OK
test.t2 restore status OK
test.t3 restore status OK
@@ -81,14 +81,14 @@ k
drop table t1,t2,t3,t4;
restore table t1 from '../../tmp';
Table Op Msg_type Msg_text
-test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t1 restore status OK
rename table t1 to t5;
lock tables t5 write;
backup table t5 to '../../tmp';
unlock tables;
Table Op Msg_type Msg_text
-test.t5 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t5 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t5 backup status OK
drop table t5;
DROP TABLE IF EXISTS `t+1`;
@@ -96,12 +96,12 @@ CREATE TABLE `t+1` (c1 INT);
INSERT INTO `t+1` VALUES (1), (2), (3);
BACKUP TABLE `t+1` TO '../../tmp';
Table Op Msg_type Msg_text
-test.t+1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t+1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t+1 backup status OK
DROP TABLE `t+1`;
RESTORE TABLE `t+1` FROM '../../tmp';
Table Op Msg_type Msg_text
-test.t+1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t+1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t+1 restore status OK
SELECT * FROM `t+1`;
c1
diff --git a/mysql-test/r/concurrent_innodb_safelog.result b/mysql-test/r/concurrent_innodb_safelog.result
index 92d274993d9..e6adaac1068 100644
--- a/mysql-test/r/concurrent_innodb_safelog.result
+++ b/mysql-test/r/concurrent_innodb_safelog.result
@@ -7,8 +7,6 @@ SELECT @@global.innodb_locks_unsafe_for_binlog;
0
# keep_locks == 1
GRANT USAGE ON test.* TO mysqltest@localhost;
-DO release_lock("hello");
-DO release_lock("hello2");
drop table if exists t1;
**
@@ -36,7 +34,7 @@ get_lock("hello",10)
** connection thread2
** Start transaction for thread 2
begin;
-** Update will cause a table scan and a new ULL will
+** Update will cause a table scan and a new ULL will
** be created and blocked on the first row where tipo=11.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=11;
** connection thread1
@@ -51,9 +49,7 @@ update t1 set eta=2 where tipo=22;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** Release user level name lock from thread 1. This will cause the ULL
** on thread 2 to end its wait.
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** Table is now updated with a new eta on tipo=22 for thread 1.
select * from t1;
eta tipo c
@@ -70,9 +66,7 @@ eta tipo c
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from update on thread 2
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** Table should have eta updates where tipo=11 but updates made by
** thread 1 shouldn't be visible yet.
select * from t1;
@@ -194,9 +188,7 @@ begin;
update t1 set tipo=1 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
** Release ULL. This will release the next waiting ULL on thread 2.
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** The table should still be updated with updates for thread 1 only:
select * from t1;
eta tipo c
@@ -213,9 +205,7 @@ eta tipo c
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from thread 2:
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** Seen from thread 2 the table should have been updated on four
** places.
select * from t1;
@@ -319,9 +309,7 @@ update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
** commit since there are no on-going transactions.
insert into t1 values (1,1);
** Release the ULL (thread 2 updates will finish).
-select release_lock("hello2");
-release_lock("hello2")
-1
+DO release_lock("hello2");
** ..but thread 1 will still see t1 as if nothing has happend:
select * from t1;
a b
@@ -332,9 +320,7 @@ a b
1 1
** connection thread2
** Collect results from thread 2 and release the lock.
-select release_lock("hello2");
-release_lock("hello2")
-1
+DO release_lock("hello2");
** The table should look like the original+updates for thread 2,
** and consist of new rows:
select * from t1;
diff --git a/mysql-test/r/concurrent_innodb_unsafelog.result b/mysql-test/r/concurrent_innodb_unsafelog.result
index 2a6c15d38c1..e9c53d4cfa0 100644
--- a/mysql-test/r/concurrent_innodb_unsafelog.result
+++ b/mysql-test/r/concurrent_innodb_unsafelog.result
@@ -7,8 +7,6 @@ SELECT @@global.innodb_locks_unsafe_for_binlog;
1
# keep_locks == 0
GRANT USAGE ON test.* TO mysqltest@localhost;
-DO release_lock("hello");
-DO release_lock("hello2");
drop table if exists t1;
**
@@ -36,7 +34,7 @@ get_lock("hello",10)
** connection thread2
** Start transaction for thread 2
begin;
-** Update will cause a table scan and a new ULL will
+** Update will cause a table scan and a new ULL will
** be created and blocked on the first row where tipo=11.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=11;
** connection thread1
@@ -50,9 +48,7 @@ begin;
update t1 set eta=2 where tipo=22;
** Release user level name lock from thread 1. This will cause the ULL
** on thread 2 to end its wait.
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** Table is now updated with a new eta on tipo=22 for thread 1.
select * from t1;
eta tipo c
@@ -69,9 +65,7 @@ eta tipo c
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from update on thread 2
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** Table should have eta updates where tipo=11 but updates made by
** thread 1 shouldn't be visible yet.
select * from t1;
@@ -192,9 +186,7 @@ begin;
** do not match the WHERE condition are released.
update t1 set tipo=1 where tipo=2;
** Release ULL. This will release the next waiting ULL on thread 2.
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** The table should still be updated with updates for thread 1 only:
select * from t1;
eta tipo c
@@ -211,9 +203,7 @@ eta tipo c
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** connection thread2
** Release the lock and collect result from thread 2:
-select release_lock("hello");
-release_lock("hello")
-1
+DO release_lock("hello");
** Seen from thread 2 the table should have been updated on four
** places.
select * from t1;
@@ -317,9 +307,7 @@ update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
** commit since there are no on-going transactions.
insert into t1 values (1,1);
** Release the ULL (thread 2 updates will finish).
-select release_lock("hello2");
-release_lock("hello2")
-1
+DO release_lock("hello2");
** ..but thread 1 will still see t1 as if nothing has happend:
select * from t1;
a b
@@ -330,9 +318,7 @@ a b
1 1
** connection thread2
** Collect results from thread 2 and release the lock.
-select release_lock("hello2");
-release_lock("hello2")
-1
+DO release_lock("hello2");
** The table should look like the original+updates for thread 2,
** and consist of new rows:
select * from t1;
diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result
index 727433d3032..5e6c013bb38 100644
--- a/mysql-test/r/connect.result
+++ b/mysql-test/r/connect.result
@@ -188,7 +188,7 @@ DROP USER mysqltest_u1@localhost;
# -- End of Bug#33507.
-# -- Bug#35074: max_used_connections is not correct.
+# -- Bug#35074: max_used_connections is not correct.
FLUSH STATUS;
diff --git a/mysql-test/r/consistent_snapshot.result b/mysql-test/r/consistent_snapshot.result
index 90606abbe4e..694c996a58e 100644
--- a/mysql-test/r/consistent_snapshot.result
+++ b/mysql-test/r/consistent_snapshot.result
@@ -1,15 +1,23 @@
-drop table if exists t1;
-create table t1 (a int) engine=innodb;
-start transaction with consistent snapshot;
-insert into t1 values(1);
-select * from t1;
+DROP TABLE IF EXISTS t1;
+# Establish connection con1 (user=root)
+# Establish connection con2 (user=root)
+# Switch to connection con1
+CREATE TABLE t1 (a INT) ENGINE=innodb;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+# Switch to connection con2
+INSERT INTO t1 VALUES(1);
+# Switch to connection con1
+SELECT * FROM t1;
a
-commit;
-delete from t1;
-start transaction;
-insert into t1 values(1);
-select * from t1;
+COMMIT;
+DELETE FROM t1;
+START TRANSACTION;
+# Switch to connection con2
+INSERT INTO t1 VALUES(1);
+# Switch to connection con1
+SELECT * FROM t1;
a
1
-commit;
-drop table t1;
+COMMIT;
+# Switch to connection default + close connections con1 and con2
+DROP TABLE t1;
diff --git a/mysql-test/r/count_distinct3.result b/mysql-test/r/count_distinct3.result
index 086e1360b0c..840c26669a1 100644
--- a/mysql-test/r/count_distinct3.result
+++ b/mysql-test/r/count_distinct3.result
@@ -2,7 +2,8 @@ DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
SELECT COUNT(*) FROM t1;
COUNT(*)
-4181000
+4201000
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
+# Begin cleanup
+SET session myisam_sort_buffer_size = @orig_myisam_sort_buffer_size;
DROP TABLE t1;
-set @@read_buffer_size=default;
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 057a8600ca2..bd11a8725ef 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -1731,7 +1731,7 @@ t1 CREATE TABLE `t1` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
@@ -1745,7 +1745,7 @@ t1 CREATE TEMPORARY TABLE `t1` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result
index 69b48ee2952..b42094550bd 100644
--- a/mysql-test/r/ctype_collate.result
+++ b/mysql-test/r/ctype_collate.result
@@ -611,3 +611,22 @@ check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
+least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci)
+a
+create table t1
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `f1` varchar(1) CHARACTER SET latin5 NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
+latin5_turkish_ci then 2 else 3 end;
+case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
+latin5_turkish_ci then 2 else 3 end
+3
+select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
+concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci)
+abc
diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result
index 34cea2a5a7d..af3a0899181 100644
--- a/mysql-test/r/ddl_i18n_koi8r.result
+++ b/mysql-test/r/ddl_i18n_koi8r.result
@@ -1729,18 +1729,18 @@ DELETE FROM mysqltest2.log|
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -1808,18 +1808,18 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result
index cf5dac3dc7c..10c2afcadc1 100644
--- a/mysql-test/r/ddl_i18n_utf8.result
+++ b/mysql-test/r/ddl_i18n_utf8.result
@@ -1729,18 +1729,18 @@ DELETE FROM mysqltest2.log|
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -1808,18 +1808,18 @@ ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
USE `mysqltest2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `log` (
`msg` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (1),(0),(1);
ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
diff --git a/mysql-test/r/dirty_close.result b/mysql-test/r/dirty_close.result
index c4fc19a35f8..b49b72f1b95 100644
--- a/mysql-test/r/dirty_close.result
+++ b/mysql-test/r/dirty_close.result
@@ -1,9 +1,9 @@
-drop table if exists t1;
-create table t1 (n int);
-insert into t1 values (1),(2),(3);
-select * from t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (n INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT * FROM t1;
n
1
2
3
-drop table t1;
+DROP TABLE t1;
diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result
index 83030a00179..50bfa97c59f 100644
--- a/mysql-test/r/events_bugs.result
+++ b/mysql-test/r/events_bugs.result
@@ -736,6 +736,17 @@ select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mo
select name from mysql.event where name = 'p' and sql_mode = @full_mode;
name
drop event e1;
+SET @old_server_id = @@GLOBAL.server_id;
+SET GLOBAL server_id = (1 << 32) - 1;
+SELECT @@GLOBAL.server_id;
+@@GLOBAL.server_id
+4294967295
+CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS;
+event_name originator
+ev1 4294967295
+DROP EVENT ev1;
+SET GLOBAL server_id = @old_server_id;
DROP DATABASE events_test;
SET GLOBAL event_scheduler= 'ON';
SET @@global.concurrent_insert= @concurrent_insert;
diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result
index 3de741b5efb..a81ff554ca2 100644
--- a/mysql-test/r/explain.result
+++ b/mysql-test/r/explain.result
@@ -155,6 +155,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1`
DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a);
+ERROR 42000: Key 'a' doesn't exist in table 't1'
+DROP TABLE t1;
#
# Bug#37870: Usage of uninitialized value caused failed assertion.
#
@@ -182,3 +186,4 @@ dt
2001-01-01 01:01:01
2001-01-01 01:01:01
drop tables t1, t2;
+End of 5.1 tests.
diff --git a/mysql-test/r/flush_block_commit.result b/mysql-test/r/flush_block_commit.result
index d5b10868358..d2197beaaab 100644
--- a/mysql-test/r/flush_block_commit.result
+++ b/mysql-test/r/flush_block_commit.result
@@ -1,39 +1,57 @@
-drop table if exists t1;
-create table t1 (a int) engine=innodb;
-begin;
-insert into t1 values(1);
-flush tables with read lock;
-select * from t1;
+# Establish connection con1 (user=root)
+# Establish connection con2 (user=root)
+# Establish connection con3 (user=root)
+# Switch to connection con1
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT) ENGINE=innodb;
+BEGIN;
+INSERT INTO t1 VALUES(1);
+# Switch to connection con2
+FLUSH TABLES WITH READ LOCK;
+SELECT * FROM t1;
a
-commit;
-select * from t1;
+# Switch to connection con1
+COMMIT;
+# Switch to connection con2
+SELECT * FROM t1;
a
-unlock tables;
-begin;
-select * from t1 for update;
+UNLOCK TABLES;
+# Switch to connection con1
+# Switch to connection con1
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
a
1
-begin;
-select * from t1 for update;
-flush tables with read lock;
-commit;
+# Switch to connection con2
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
+# Switch to connection con3
+FLUSH TABLES WITH READ LOCK;
+# Switch to connection con1
+COMMIT;
+# Switch to connection con2
a
1
-unlock tables;
-commit;
-begin;
-insert into t1 values(10);
-flush tables with read lock;
-commit;
-unlock tables;
-flush tables with read lock;
-unlock tables;
-begin;
-select * from t1;
+# Switch to connection con3
+UNLOCK TABLES;
+# Switch to connection con2
+COMMIT;
+# Switch to connection con1
+BEGIN;
+INSERT INTO t1 VALUES(10);
+FLUSH TABLES WITH READ LOCK;
+COMMIT;
+UNLOCK TABLES;
+# Switch to connection con2
+FLUSH TABLES WITH READ LOCK;
+UNLOCK TABLES;
+BEGIN;
+SELECT * FROM t1;
a
1
10
-show create database test;
+SHOW CREATE DATABASE test;
Database Create Database
test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
-drop table t1;
+DROP TABLE t1;
+# Switch to connection default and close connections con1, con2, con3
diff --git a/mysql-test/r/flush_block_commit_notembedded.result b/mysql-test/r/flush_block_commit_notembedded.result
index 16fb143ee4c..c7fd7a11877 100644
--- a/mysql-test/r/flush_block_commit_notembedded.result
+++ b/mysql-test/r/flush_block_commit_notembedded.result
@@ -1,15 +1,23 @@
-create table t1 (a int) engine=innodb;
-reset master;
-set autocommit=0;
-insert t1 values (1);
-flush tables with read lock;
-show master status;
+# Establish connection con1 (user=root)
+# Establish connection con2 (user=root)
+# Switch to connection con1
+CREATE TABLE t1 (a INT) ENGINE=innodb;
+RESET MASTER;
+SET AUTOCOMMIT=0;
+INSERT t1 VALUES (1);
+# Switch to connection con2
+FLUSH TABLES WITH READ LOCK;
+SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 106
-commit;
-show master status;
+# Switch to connection con1
+COMMIT;
+# Switch to connection con2
+SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 106
-unlock tables;
-drop table t1;
-set autocommit=1;
+UNLOCK TABLES;
+# Switch to connection con1
+DROP TABLE t1;
+SET AUTOCOMMIT=1;
+# Switch to connection default and close connections con1 and con2
diff --git a/mysql-test/r/flush_read_lock_kill.result b/mysql-test/r/flush_read_lock_kill.result
index 0b599f343f7..b16a8b114b3 100644
--- a/mysql-test/r/flush_read_lock_kill.result
+++ b/mysql-test/r/flush_read_lock_kill.result
@@ -1,12 +1,12 @@
-set @old_concurrent_insert= @@global.concurrent_insert;
-set @@global.concurrent_insert= 0;
-drop table if exists t1;
-create table t1 (kill_id int);
-insert into t1 values(connection_id());
-flush tables with read lock;
-select ((@id := kill_id) - kill_id) from t1;
+SET @old_concurrent_insert= @@global.concurrent_insert;
+SET @@global.concurrent_insert= 0;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (kill_id INT);
+INSERT INTO t1 VALUES(connection_id());
+FLUSH TABLES WITH READ LOCK;
+SELECT ((@id := kill_id) - kill_id) FROM t1;
((@id := kill_id) - kill_id)
0
-kill connection @id;
-drop table t1;
-set @@global.concurrent_insert= @old_concurrent_insert;
+KILL CONNECTION @id;
+DROP TABLE t1;
+SET @@global.concurrent_insert= @old_concurrent_insert;
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index 8633bd61681..d1edce12cce 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -531,3 +531,15 @@ SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) FROM t1;
MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE)
2
DROP TABLE t1;
+CREATE TABLE t1(a TEXT);
+SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE);
+ERROR HY000: Incorrect arguments to AGAINST
+DROP TABLE t1;
+CREATE TABLE t1(a VARCHAR(64), FULLTEXT(a));
+INSERT INTO t1 VALUES('awrd bwrd cwrd'),('awrd bwrd cwrd'),('awrd bwrd cwrd');
+SELECT * FROM t1 WHERE MATCH(a) AGAINST('+awrd bwrd* +cwrd*' IN BOOLEAN MODE);
+a
+awrd bwrd cwrd
+awrd bwrd cwrd
+awrd bwrd cwrd
+DROP TABLE t1;
diff --git a/mysql-test/r/func_des_encrypt.result b/mysql-test/r/func_des_encrypt.result
index 46b30bdab58..b81f96f6ef7 100644
--- a/mysql-test/r/func_des_encrypt.result
+++ b/mysql-test/r/func_des_encrypt.result
@@ -1,3 +1,37 @@
select des_encrypt('hello');
des_encrypt('hello')
€Ö2nV“Ø}
+#
+# Bug #11643: des_encrypt() causes server to die
+#
+CREATE TABLE t1 (des VARBINARY(200) NOT NULL DEFAULT '') ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('1234'), ('12345'), ('123456'), ('1234567');
+UPDATE t1 SET des=DES_ENCRYPT('1234');
+SELECT LENGTH(des) FROM t1;
+LENGTH(des)
+9
+9
+9
+9
+SELECT DES_DECRYPT(des) FROM t1;
+DES_DECRYPT(des)
+1234
+1234
+1234
+1234
+SELECT
+LENGTH(DES_ENCRYPT('1234')),
+LENGTH(DES_ENCRYPT('12345')),
+LENGTH(DES_ENCRYPT('123456')),
+LENGTH(DES_ENCRYPT('1234567'));
+LENGTH(DES_ENCRYPT('1234')) LENGTH(DES_ENCRYPT('12345')) LENGTH(DES_ENCRYPT('123456')) LENGTH(DES_ENCRYPT('1234567'))
+9 9 9 9
+SELECT
+DES_DECRYPT(DES_ENCRYPT('1234')),
+DES_DECRYPT(DES_ENCRYPT('12345')),
+DES_DECRYPT(DES_ENCRYPT('123456')),
+DES_DECRYPT(DES_ENCRYPT('1234567'));
+DES_DECRYPT(DES_ENCRYPT('1234')) DES_DECRYPT(DES_ENCRYPT('12345')) DES_DECRYPT(DES_ENCRYPT('123456')) DES_DECRYPT(DES_ENCRYPT('1234567'))
+1234 12345 123456 1234567
+DROP TABLE t1;
+End of 5.0 tests
diff --git a/mysql-test/r/func_encrypt.result b/mysql-test/r/func_encrypt.result
index 04af76429f8..8fbf36b45b9 100644
--- a/mysql-test/r/func_encrypt.result
+++ b/mysql-test/r/func_encrypt.result
@@ -183,3 +183,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select des_decrypt(des_encrypt('hello',4),'password2') AS `des_decrypt(des_encrypt("hello",4),'password2')`,des_decrypt(des_encrypt('hello','hidden')) AS `des_decrypt(des_encrypt("hello","hidden"))`
+drop table if exists t1;
+create table t1 (f1 smallint(6) default null, f2 mediumtext character set utf8)
+engine=myisam default charset=latin1;
+insert into t1 values (null,'contraction\'s');
+insert into t1 values (-15818,'requirement\'s');
+select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a;
+drop table t1;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index e0a6c44eb01..3d989ad1730 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -61,7 +61,7 @@ grp sum
NULL NULL
1 7
2 20.25
-3 45.483163247594
+3 45.4831632475944
create table t2 (grp int, a bigint unsigned, c char(10));
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
replace into t2 select grp, a, c from t1 limit 2,1;
@@ -1186,7 +1186,7 @@ std(s1/s2)
0.21325764
select std(o1/o2) from bug22555;
std(o1/o2)
-0.21325763586649
+0.213257635866493
select std(e1/e2) from bug22555;
std(e1/e2)
0.21325764
@@ -1212,7 +1212,7 @@ round(std(s1/s2), 17)
0.21325763586649341
select std(o1/o2) from bug22555;
std(o1/o2)
-0.21325763586649
+0.213257635866493
select round(std(e1/e2), 17) from bug22555;
round(std(e1/e2), 17)
0.21325763586649341
@@ -1237,7 +1237,7 @@ round(std(s1/s2), 17)
0.21325763586649341
select std(o1/o2) from bug22555;
std(o1/o2)
-0.21325763586649
+0.213257635866493
select round(std(e1/e2), 17) from bug22555;
round(std(e1/e2), 17)
0.21325763586649341
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index b4a07f18521..c3d2db2d553 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -60,7 +60,7 @@ Warnings:
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
-3 3.9068905956085 NULL NULL NULL
+3 3.90689059560852 NULL NULL NULL
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -68,7 +68,7 @@ Warnings:
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
-2 1.2552725051033 NULL NULL NULL
+2 1.25527250510331 NULL NULL NULL
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -85,7 +85,7 @@ Note 1003 select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand();
rand(999999) rand()
-0.014231365187309 0.028870999839968
+0.0142313651873091 0.028870999839968
explain extended select rand(999999),rand();
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
@@ -101,7 +101,7 @@ Warnings:
Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format((1 / tan(1)),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
select degrees(pi()),radians(360);
degrees(pi()) radians(360)
-180 6.2831853071796
+180 6.28318530717959
select format(atan(-2, 2), 6);
format(atan(-2, 2), 6)
-0.785398
@@ -368,7 +368,7 @@ mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
5 5 1
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
-2.1359870359209e+96 2.1359870359209e+96 -32
+2.13598703592091e+96 2.13598703592091e+96 -32
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
SELECT a DIV 900 y FROM t1 GROUP BY y;
@@ -407,6 +407,36 @@ SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
a DIV 2
0
DROP TABLE t1;
+CREATE TABLE t1 (a DOUBLE);
+INSERT INTO t1 VALUES (-1.1), (1.1),
+(-1.5), (1.5),
+(-1.9), (1.9),
+(-2.1), (2.1),
+(-2.5), (2.5),
+(-2.9), (2.9),
+# Check numbers with absolute values > 2^53 - 1
+# (see comments for MAX_EXACT_INTEGER)
+(-1e16 - 0.5), (1e16 + 0.5),
+(-1e16 - 1.5), (1e16 + 1.5);
+SELECT a, ROUND(a) FROM t1;
+a ROUND(a)
+-1.1 -1
+1.1 1
+-1.5 -2
+1.5 2
+-1.9 -2
+1.9 2
+-2.1 -2
+2.1 2
+-2.5 -2
+2.5 2
+-2.9 -3
+2.9 3
+-1e+16 -10000000000000000
+1e+16 10000000000000000
+-1e+16 -10000000000000002
+1e+16 10000000000000002
+DROP TABLE t1;
End of 5.0 tests
SELECT 1e308 + 1e308;
1e308 + 1e308
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index 3b864cd5804..81dddd0f648 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -329,6 +329,9 @@ SELECT * FROM t1 WHERE a = NAME_CONST('reportDate',
_binary'2009-01-09' COLLATE 'binary');
a
DROP TABLE t1;
+select NAME_CONST('_id',1234) as id;
+id
+1234
End of 5.0 tests
select connection_id() > 0;
connection_id() > 0
diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result
index 3f9f7b85731..ecdc35ac4cd 100644
--- a/mysql-test/r/func_set.result
+++ b/mysql-test/r/func_set.result
@@ -103,3 +103,46 @@ CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL))
8
End of 5.0 tests
+drop table if exists t1;
+create table t1 (f1 set('test1','test2','test3') character set utf8 default null)
+engine=myisam default charset=latin1;
+insert into t1 values (''),(null),(null),(''),(''),('');
+select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a;
+a
+0
+NULL
+NULL
+0
+0
+0
+0
+NULL
+NULL
+0
+0
+0
+0
+NULL
+NULL
+0
+0
+0
+0
+NULL
+NULL
+0
+0
+0
+0
+NULL
+NULL
+0
+0
+0
+0
+NULL
+NULL
+0
+0
+0
+drop table t1;
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 0824f13cafc..25cbf2470ed 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -1351,10 +1351,10 @@ cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2))
20.06
select conv("18383815659218730760",10,10) + 0;
conv("18383815659218730760",10,10) + 0
-1.8383815659219e+19
+1.83838156592187e+19
select "18383815659218730760" + 0;
"18383815659218730760" + 0
-1.8383815659219e+19
+1.83838156592187e+19
CREATE TABLE t1 (code varchar(10));
INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
SELECT ASCII(code), code FROM t1 WHERE code='A12';
@@ -2519,4 +2519,24 @@ def format(a, 2) 253 49 4 Y 0 31 8
format(a, 2)
1.33
drop table t1;
+CREATE TABLE t1 (c DATE, aa VARCHAR(30));
+INSERT INTO t1 VALUES ('2008-12-31','aaaaaa');
+SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i FROM t1;
+h i
+31.12.2008 AAAAAA, aaaaaa
+DROP TABLE t1;
End of 5.0 tests
+drop table if exists t1;
+create table t1(f1 tinyint default null)engine=myisam;
+insert into t1 values (-1),(null);
+explain select 1 as a from t1,(select decode(f1,f1) as b from t1) a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using join buffer
+2 DERIVED t1 ALL NULL NULL NULL NULL 2
+explain select 1 as a from t1,(select encode(f1,f1) as b from t1) a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using join buffer
+2 DERIVED t1 ALL NULL NULL NULL NULL 2
+drop table t1;
diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
index f8e0085bf59..b030139e40e 100644
--- a/mysql-test/r/gis-rtree.result
+++ b/mysql-test/r/gis-rtree.result
@@ -186,106 +186,106 @@ CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL
) ENGINE=MyISAM;
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)));
ALTER TABLE t2 ADD SPATIAL KEY(g);
SHOW CREATE TABLE t2;
Table Create Table
@@ -309,406 +309,406 @@ fid AsText(g)
56 LINESTRING(41 41,50 50)
45 LINESTRING(51 51,60 60)
55 LINESTRING(41 51,50 60)
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-99
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-98
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-97
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-96
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-95
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-94
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-93
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-92
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-91
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-90
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-89
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-88
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-87
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-86
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-85
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-84
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-83
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-82
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-81
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-80
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-79
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-78
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-77
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-76
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-75
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-74
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-73
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-72
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-71
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-70
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-69
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-68
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-67
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-66
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-65
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-64
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-63
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-62
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-61
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-60
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-59
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-58
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-57
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-56
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-55
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-54
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-53
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-52
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-51
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-50
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-49
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-48
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-47
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-46
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-45
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-44
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-43
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-42
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-41
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-40
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-39
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-38
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-37
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-36
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-35
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-34
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-33
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-32
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-31
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-30
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-29
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-28
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-27
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-26
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-25
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-24
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-23
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-22
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-21
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-20
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-19
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-18
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-17
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-16
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-15
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-14
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-13
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-12
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-11
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-10
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10))));
SELECT count(*) FROM t2;
count(*)
-9
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10))));
SELECT count(*) FROM t2;
count(*)
-8
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10))));
SELECT count(*) FROM t2;
count(*)
-7
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10))));
SELECT count(*) FROM t2;
count(*)
-6
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10))));
SELECT count(*) FROM t2;
count(*)
-5
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10))));
SELECT count(*) FROM t2;
count(*)
-4
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10))));
SELECT count(*) FROM t2;
count(*)
-3
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10))));
SELECT count(*) FROM t2;
count(*)
-2
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10))));
SELECT count(*) FROM t2;
count(*)
-1
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10))));
SELECT count(*) FROM t2;
count(*)
-0
+100
DROP TABLE t2;
drop table if exists t1;
Warnings:
@@ -863,11 +863,11 @@ Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
CREATE TABLE t1 (foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,0)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,0)));
-SELECT 1 FROM t1 WHERE foo != PointFromWKB(POINT(0,0));
+INSERT INTO t1 (foo) VALUES (POINT(1,1));
+INSERT INTO t1 (foo) VALUES (POINT(1,0));
+INSERT INTO t1 (foo) VALUES (POINT(0,1));
+INSERT INTO t1 (foo) VALUES (POINT(0,0));
+SELECT 1 FROM t1 WHERE foo != POINT(0,0);
1
1
1
@@ -1426,35 +1426,35 @@ Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
create table t1 (a geometry not null, spatial index(a));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
-insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
-insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
-insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
-insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
-insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
-insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
-insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
-insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
-insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
-insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
-insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
+insert into t1 values (POINT(1.1517219314031e+164, 131072));
+insert into t1 values (POINT(9.1248812352444e+192, 2.9740338169556e+284));
+insert into t1 values (POINT(4.7783097267365e-299, -0));
+insert into t1 values (POINT(1.49166814624e-154, 2.0880974297595e-53));
+insert into t1 values (POINT(4.0917382598702e+149, 1.2024538023802e+111));
+insert into t1 values (POINT(2.0349165139404e+236, 2.9993936277913e-241));
+insert into t1 values (POINT(2.5243548967072e-29, 1.2024538023802e+111));
+insert into t1 values (POINT(0, 6.9835074892995e-251));
+insert into t1 values (POINT(2.0880974297595e-53, 3.1050361846014e+231));
+insert into t1 values (POINT(2.8728483499323e-188, 2.4600631144627e+260));
+insert into t1 values (POINT(3.0517578125e-05, 2.0349165139404e+236));
+insert into t1 values (POINT(1.1517219314031e+164, 1.1818212630766e-125));
+insert into t1 values (POINT(2.481040258324e-265, 5.7766220027675e-275));
+insert into t1 values (POINT(2.0880974297595e-53, 2.5243548967072e-29));
+insert into t1 values (POINT(5.7766220027675e-275, 9.9464647281957e+86));
+insert into t1 values (POINT(2.2181357552967e+130, 3.7857669957337e-270));
+insert into t1 values (POINT(4.5767114681874e-246, 3.6893488147419e+19));
+insert into t1 values (POINT(4.5767114681874e-246, 3.7537584144024e+255));
+insert into t1 values (POINT(3.7857669957337e-270, 1.8033161362863e-130));
+insert into t1 values (POINT(0, 5.8774717541114e-39));
+insert into t1 values (POINT(1.1517219314031e+164, 2.2761049594727e-159));
+insert into t1 values (POINT(6.243497100632e+144, 3.7857669957337e-270));
+insert into t1 values (POINT(3.7857669957337e-270, 2.6355494858076e-82));
+insert into t1 values (POINT(2.0349165139404e+236, 3.8518598887745e-34));
+insert into t1 values (POINT(4.6566128730774e-10, 2.0880974297595e-53));
+insert into t1 values (POINT(2.0880974297595e-53, 1.8827498946116e-183));
+insert into t1 values (POINT(1.8033161362863e-130, 9.1248812352444e+192));
+insert into t1 values (POINT(4.7783097267365e-299, 2.2761049594727e-159));
+insert into t1 values (POINT(1.94906280228e+289, 1.2338789709327e-178));
drop table t1;
CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
INSERT INTO t1(foo) VALUES (NULL);
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index fdcde4e8739..494b7a36532 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -47,26 +47,26 @@ INSERT INTO gis_point VALUES
INSERT INTO gis_line VALUES
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
-(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
+(107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
INSERT INTO gis_polygon VALUES
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
-(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
+(110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
INSERT INTO gis_multi_point VALUES
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
-(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
+(113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
INSERT INTO gis_multi_line VALUES
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
-(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
+(116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
INSERT INTO gis_multi_polygon VALUES
(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
-(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
+(119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
INSERT INTO gis_geometrycollection VALUES
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
-(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
+(121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))));
INSERT into gis_geometry SELECT * FROM gis_point;
INSERT into gis_geometry SELECT * FROM gis_line;
INSERT into gis_geometry SELECT * FROM gis_polygon;
@@ -284,7 +284,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.416666666667 25.416666666667)
+109 POINT(25.4166666666667 25.4166666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon;
fid Area(g)
@@ -318,8 +318,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
fid AsText(Centroid(g))
-117 POINT(55.588527753042 17.426536064114)
-118 POINT(55.588527753042 17.426536064114)
+117 POINT(55.5885277530424 17.426536064114)
+118 POINT(55.5885277530424 17.426536064114)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon;
fid Area(g)
@@ -651,11 +651,11 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85998;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
-85998 MULTIPOLYGON 0 POINT(115.31877315203 -36.237472821022)
+85998 MULTIPOLYGON 0 POINT(115.318773152032 -36.2374728210215)
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85984;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
-85984 MULTIPOLYGON 0 POINT(-114.87787186923 36.33101763469)
+85984 MULTIPOLYGON 0 POINT(-114.877871869233 36.3310176346905)
drop table t1;
create table t1 (fl geometry not null);
insert into t1 values (1);
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 18f11ebcc71..de80a83d538 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -164,7 +164,7 @@ Warnings:
Warning 1364 Field 'ssl_cipher' doesn't have a default value
Warning 1364 Field 'x509_issuer' doesn't have a default value
Warning 1364 Field 'x509_subject' doesn't have a default value
-insert into mysql.db (host, db, user, select_priv) values
+insert into mysql.db (host, db, user, select_priv) values
('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y');
alter table mysql.db order by db asc;
flush privileges;
@@ -264,7 +264,7 @@ drop user mysqltest_1@localhost;
SET NAMES koi8r;
CREATE DATABASE ÂÄ;
USE ÂÄ;
-CREATE TABLE ÔÁÂ (ËÏÌ int);
+CREATE TABLE ÔÁÂ (ËÏÌ INT);
GRANT SELECT ON ÂÄ.* TO ÀÚÅÒ@localhost;
SHOW GRANTS FOR ÀÚÅÒ@localhost;
Grants for ÀÚÅÒ@localhost
@@ -383,21 +383,21 @@ grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
-SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
-WHERE GRANTEE = '''mysqltest_3''@''localhost'''
-ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
+SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
+WHERE GRANTEE = '''mysqltest_3''@''localhost'''
+ ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_3'@'localhost' NULL mysqltest_1 t1 a UPDATE NO
'mysqltest_3'@'localhost' NULL mysqltest_2 t1 c SELECT NO
'mysqltest_3'@'localhost' NULL mysqltest_1 t2 b SELECT NO
'mysqltest_3'@'localhost' NULL mysqltest_2 t2 d UPDATE NO
SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
-WHERE GRANTEE = '''mysqltest_3''@''localhost'''
-ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
+WHERE GRANTEE = '''mysqltest_3''@''localhost'''
+ ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
-WHERE GRANTEE = '''mysqltest_3''@''localhost'''
-ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
+WHERE GRANTEE = '''mysqltest_3''@''localhost'''
+ ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE GRANTEE = '''mysqltest_3''@''localhost'''
@@ -459,7 +459,7 @@ Privilege Context Comment
Alter Tables To alter the table
Alter routine Functions,Procedures To alter or drop stored functions/procedures
Create Databases,Tables,Indexes To create new databases and tables
-Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
+Create routine Databases To use CREATE FUNCTION/PROCEDURE
Create temporary tables Databases To use CREATE TEMPORARY TABLE
Create view Tables To create new views
Create user Server Admin To create new users
@@ -884,11 +884,11 @@ flush privileges;
drop table t2;
drop table t1;
CREATE DATABASE mysqltest3;
-use mysqltest3;
+USE mysqltest3;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
CREATE DATABASE mysqltest2;
-use mysqltest2;
+USE mysqltest2;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
CREATE VIEW v_yn AS SELECT * FROM t_nn;
@@ -958,7 +958,7 @@ DROP TABLE mysqltest3.t_nn;
DROP DATABASE mysqltest3;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
DROP USER 'mysqltest_1'@'localhost';
-use test;
+USE test;
create user mysqltest1_thisisreallytoolong;
ERROR HY000: String 'mysqltest1_thisisreallytoolong' is too long for user name (should be no longer than 16)
CREATE DATABASE mysqltest1;
@@ -1196,16 +1196,16 @@ DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
DROP USER mysqltest_2@localhost;
-use test;
+USE test;
CREATE TABLE t1 (f1 int, f2 int);
INSERT INTO t1 VALUES(1,1), (2,2);
CREATE DATABASE db27878;
GRANT UPDATE(f1) ON t1 TO 'mysqltest_1'@'localhost';
GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost';
GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost';
-use db27878;
+USE db27878;
CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1;
-use db27878;
+USE db27878;
UPDATE v1 SET f2 = 4;
ERROR HY000: View 'db27878.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SELECT * FROM test.t1;
@@ -1217,7 +1217,7 @@ REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost';
REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost';
DROP USER mysqltest_1@localhost;
DROP DATABASE db27878;
-use test;
+USE test;
DROP TABLE t1;
#
# Bug#33275 Server crash when creating temporary table mysql.user
@@ -1355,6 +1355,6 @@ Warnings:
Warning 1403 There is no such grant defined for user 'userbug33464' on host 'localhost' on routine 'fn2'
DROP PROCEDURE sp3;
DROP USER 'userbug33464'@'localhost';
-use test;
+USE test;
DROP DATABASE dbbug33464;
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 48f97aeb428..742d4b90807 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1691,3 +1691,15 @@ FROM t1;
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
+SET @old_sql_mode = @@sql_mode;
+SET @@sql_mode='ONLY_FULL_GROUP_BY';
+CREATE TABLE t1(i INT);
+INSERT INTO t1 VALUES (1), (10);
+SELECT COUNT(i) FROM t1;
+COUNT(i)
+2
+SELECT COUNT(i) FROM t1 WHERE i > 1;
+COUNT(i)
+1
+DROP TABLE t1;
+SET @@sql_mode = @old_sql_mode;
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index adda0053687..b17884c4f7a 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -2448,3 +2448,18 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 select sql_buffer_result `test`.`t1`.`a` AS `a`,(max(`test`.`t1`.`b`) + 1) AS `max(b)+1` from `test`.`t1` where (`test`.`t1`.`a` = 0) group by `test`.`t1`.`a`
drop table t1;
+CREATE TABLE t1 (a int, b int, c int, d int,
+KEY foo (c,d,a,b), KEY bar (c,a,b,d));
+INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
+EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL foo 10 NULL 9 Using where; Using index for group-by
+SELECT DISTINCT c FROM t1 WHERE d=4;
+c
+1
+2
+DROP TABLE t1;
+End of 5.0 tests
diff --git a/mysql-test/r/handler_innodb.result b/mysql-test/r/handler_innodb.result
index 3e4cef99480..957fc30acef 100644
--- a/mysql-test/r/handler_innodb.result
+++ b/mysql-test/r/handler_innodb.result
@@ -730,3 +730,16 @@ unlock tables;
drop table t1;
handler t1 read a next;
ERROR 42S02: Unknown table 't1' in HANDLER
+drop table if exists t1;
+create table t1 (a int);
+insert into t1 values (1);
+handler t1 open;
+alter table t1 engine=memory;
+handler t1 read a next;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+handler t1 close;
+drop table t1;
+USE information_schema;
+HANDLER COLUMNS OPEN;
+ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
+USE test;
diff --git a/mysql-test/r/handler_myisam.result b/mysql-test/r/handler_myisam.result
index 0b27b07c4d2..dde6a4586bc 100644
--- a/mysql-test/r/handler_myisam.result
+++ b/mysql-test/r/handler_myisam.result
@@ -728,3 +728,16 @@ unlock tables;
drop table t1;
handler t1 read a next;
ERROR 42S02: Unknown table 't1' in HANDLER
+drop table if exists t1;
+create table t1 (a int);
+insert into t1 values (1);
+handler t1 open;
+alter table t1 engine=memory;
+handler t1 read a next;
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+handler t1 close;
+drop table t1;
+USE information_schema;
+HANDLER COLUMNS OPEN;
+ERROR HY000: Incorrect usage of HANDLER OPEN and information_schema
+USE test;
diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result
index 19826aca43a..8a935d87457 100644
--- a/mysql-test/r/index_merge_myisam.result
+++ b/mysql-test/r/index_merge_myisam.result
@@ -1391,3 +1391,174 @@ WHERE
`RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
`TESTID`='' AND `UCCHECK`='';
drop table t1;
+#
+# Generic @@optimizer_switch tests (move those into a separate file if
+# we get another @@optimizer_switch user)
+#
+select @@optimizer_switch;
+@@optimizer_switch
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
+set optimizer_switch='index_merge=off,index_merge_union=off';
+select @@optimizer_switch;
+@@optimizer_switch
+index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on
+set optimizer_switch='index_merge_union=on';
+select @@optimizer_switch;
+@@optimizer_switch
+index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
+set optimizer_switch='default,index_merge_sort_union=off';
+select @@optimizer_switch;
+@@optimizer_switch
+index_merge=on,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on
+set optimizer_switch=4;
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of '4'
+set optimizer_switch=NULL;
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'NULL'
+set optimizer_switch='default,index_merge';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge'
+set optimizer_switch='index_merge=index_merge';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=index_merge'
+set optimizer_switch='index_merge=on,but...';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'but...'
+set optimizer_switch='index_merge=';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge='
+set optimizer_switch='index_merge';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge'
+set optimizer_switch='on';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'on'
+set optimizer_switch='index_merge=on,index_merge=off';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=off'
+set optimizer_switch='index_merge_union=on,index_merge_union=default';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge_union=default'
+set optimizer_switch='default,index_merge=on,index_merge=off,default';
+ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=off,default'
+set optimizer_switch=default;
+set optimizer_switch='index_merge=off,index_merge_union=off,default';
+select @@optimizer_switch;
+@@optimizer_switch
+index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=on
+set optimizer_switch=default;
+select @@global.optimizer_switch;
+@@global.optimizer_switch
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
+set @@global.optimizer_switch=default;
+select @@global.optimizer_switch;
+@@global.optimizer_switch
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
+#
+# Check index_merge's @@optimizer_switch flags
+#
+select @@optimizer_switch;
+@@optimizer_switch
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int, b int, c int, filler char(100),
+key(a), key(b), key(c));
+insert into t1 select
+A.a * B.a*10 + C.a*100,
+A.a * B.a*10 + C.a*100,
+A.a,
+'filler'
+from t0 A, t0 B, t0 C;
+This should use union:
+explain select * from t1 where a=1 or b=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using union(a,b); Using where
+This should use ALL:
+set optimizer_switch='default,index_merge=off';
+explain select * from t1 where a=1 or b=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where
+This should use sort-union:
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a=1 or b=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 2 Using sort_union(a,b); Using where
+This will use sort-union:
+set optimizer_switch=default;
+explain select * from t1 where a<1 or b <1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where
+This should use ALL:
+set optimizer_switch='default,index_merge_sort_union=off';
+explain select * from t1 where a<1 or b <1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where
+This should use ALL:
+set optimizer_switch='default,index_merge=off';
+explain select * from t1 where a<1 or b <1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL a,b NULL NULL NULL 1000 Using where
+This will use sort-union:
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a<1 or b <1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 38 Using sort_union(a,b); Using where
+alter table t1 add d int, add key(d);
+update t1 set d=a;
+This will use sort_union:
+set optimizer_switch=default;
+explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b,c,d a,b 5,5 NULL 3 Using sort_union(a,b); Using where
+And if we disable sort_union, union:
+set optimizer_switch='default,index_merge_sort_union=off';
+explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b,c,d c,d 5,5 NULL 100 Using union(c,d); Using where
+drop table t1;
+create table t1 (
+a int, b int, c int,
+filler1 char(200), filler2 char(200),
+key(a),key(b),key(c)
+);
+insert into t1
+select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a, 'foo', 'bar'
+from t0 A, t0 B, t0 C, t0 D where D.a<5;
+This should be intersect:
+set optimizer_switch=default;
+explain select * from t1 where a=10 and b=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
+No intersect when index_merge is disabled:
+set optimizer_switch='default,index_merge=off';
+explain select * from t1 where a=10 and b=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 49 Using where
+No intersect if it is disabled:
+set optimizer_switch='default,index_merge_intersection=off';
+explain select * from t1 where a=10 and b=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 49 Using where
+Do intersect when union was disabled
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a=10 and b=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
+Do intersect when sort_union was disabled
+set optimizer_switch='default,index_merge_sort_union=off';
+explain select * from t1 where a=10 and b=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where
+This will use intersection inside a union:
+set optimizer_switch=default;
+explain select * from t1 where a=10 and b=10 or c=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b,c a,b,c 5,5,5 NULL 6 Using union(intersect(a,b),c); Using where
+Should be only union left:
+set optimizer_switch='default,index_merge_intersection=off';
+explain select * from t1 where a=10 and b=10 or c=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using union(a,c); Using where
+This will switch to sort-union (intersection will be gone, too,
+thats a known limitation:
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a=10 and b=10 or c=10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b,c a,c 5,5 NULL 54 Using sort_union(a,c); Using where
+set optimizer_switch=default;
+show variables like 'optimizer_switch';
+Variable_name Value
+optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on
+drop table t0, t1;
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index f8deef15819..9a75e478264 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -99,7 +99,7 @@ t2
t3
t5
v1
-select c,table_name from v1
+select c,table_name from v1
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
c table_name
@@ -118,7 +118,7 @@ t4 t4
t2 t2
t3 t3
t5 t5
-select c,table_name from v1
+select c,table_name from v1
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
c table_name
@@ -197,7 +197,7 @@ a int(11) YES NULL
create view mysqltest.v1 (c) as select a from mysqltest.t1;
grant select (a) on mysqltest.t1 to mysqltest_2@localhost;
grant select on mysqltest.v1 to mysqltest_3;
-select table_name, column_name, privileges from information_schema.columns
+select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 't1';
table_name column_name privileges
t1 a select
@@ -275,7 +275,7 @@ begin
select * from t1;
select * from t2;
end|
-select parameter_style, sql_data_access, dtd_identifier
+select parameter_style, sql_data_access, dtd_identifier
from information_schema.routines where routine_schema='test';
parameter_style sql_data_access dtd_identifier
SQL CONTAINS SQL NULL
@@ -560,7 +560,7 @@ drop view v1;
create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2),
d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3),
i DOUBLE);
-select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
+select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1';
COLUMN_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE
@@ -621,7 +621,7 @@ TABLE_NAME= "vo";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
drop view vo;
select TABLE_NAME,TABLE_TYPE,ENGINE
-from information_schema.tables
+from information_schema.tables
where table_schema='information_schema' limit 2;
TABLE_NAME TABLE_TYPE ENGINE
CHARACTER_SETS SYSTEM VIEW MEMORY
@@ -726,7 +726,7 @@ where table_schema="information_schema" and table_name="COLUMNS" and
column_type
varchar(32)
varchar(32)
-select TABLE_ROWS from information_schema.tables where
+select TABLE_ROWS from information_schema.tables where
table_schema="information_schema" and table_name="COLUMNS";
TABLE_ROWS
NULL
@@ -760,7 +760,7 @@ count(*)
drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
-information_schema.columns
+information_schema.columns
where data_type = 'longtext';
table_schema table_name column_name
information_schema COLUMNS COLUMN_DEFAULT
@@ -804,7 +804,7 @@ event last_executed datetime
event starts datetime
event ends datetime
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
-WHERE NOT EXISTS
+WHERE NOT EXISTS
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME);
@@ -833,7 +833,7 @@ x_float NULL NULL
x_double_precision NULL NULL
drop table t1;
grant select on test.* to mysqltest_4@localhost;
-SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
+SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME='TABLE_NAME';
TABLE_NAME COLUMN_NAME PRIVILEGES
COLUMNS TABLE_NAME select
@@ -1079,7 +1079,7 @@ BEGIN
SELECT 'foo' FROM DUAL;
END |
ERROR 42000: Unknown database 'information_schema'
-select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema';
+select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema';
ROUTINE_NAME
grant all on information_schema.* to 'user1'@'localhost';
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
@@ -1634,7 +1634,7 @@ show events where Db= 'information_schema';
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
use test;
#
-# Bug#34166: Server crash in SHOW OPEN TABLES and prelocking
+# Bug#34166 Server crash in SHOW OPEN TABLES and prelocking
#
drop table if exists t1;
drop function if exists f1;
@@ -1720,4 +1720,9 @@ SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
CREATE_OPTIONS
KEY_BLOCK_SIZE=1
DROP TABLE t1;
+SET TIMESTAMP=@@TIMESTAMP + 10000000;
+SELECT 'OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0;
+TEST_RESULT
+OK
+SET TIMESTAMP=DEFAULT;
End of 5.1 tests.
diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result
index 83b8217b570..475839569c7 100644
--- a/mysql-test/r/information_schema_db.result
+++ b/mysql-test/r/information_schema_db.result
@@ -200,7 +200,7 @@ Field Type Null Key Default Extra
f1 char(4) YES NULL
show create view v2;
View Create View character_set_client collation_connection
-v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1` latin1 latin1_swedish_ci
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1` latin1 latin1_swedish_ci
show create view testdb_1.v1;
ERROR 42000: SHOW VIEW command denied to user 'testdb_2'@'localhost' for table 'v1'
select table_name from information_schema.columns a
diff --git a/mysql-test/r/innodb-autoinc.result b/mysql-test/r/innodb-autoinc.result
index 1e4b088c6cd..ade4db35ce6 100644
--- a/mysql-test/r/innodb-autoinc.result
+++ b/mysql-test/r/innodb-autoinc.result
@@ -579,3 +579,291 @@ c1
18446744073709551610
18446744073709551615
DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "%auto_inc%";
+Variable_name Value
+auto_increment_increment 1
+auto_increment_offset 1
+CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+3 3
+4 4
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+c1 c2
+1 1
+2 2
+3 3
+4 4
+DROP TABLE t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note 1051 Unknown table 't1'
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note 1051 Unknown table 't2'
+CREATE TABLE t1 (
+a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+b INT(10) UNSIGNED NOT NULL,
+c ENUM('FALSE','TRUE') DEFAULT NULL,
+PRIMARY KEY (a)) ENGINE = InnoDB;
+CREATE TABLE t2 (
+m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+n INT(10) UNSIGNED NOT NULL,
+o enum('FALSE','TRUE') DEFAULT NULL,
+PRIMARY KEY (m)) ENGINE = InnoDB;
+INSERT INTO t2 (n,o) VALUES
+(1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
+(3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `m` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `n` int(10) unsigned NOT NULL,
+ `o` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`m`)
+) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+23 1 FALSE
+24 2 FALSE
+25 3 FALSE
+26 4 FALSE
+27 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+23 1 FALSE
+24 2 FALSE
+25 3 FALSE
+26 4 FALSE
+27 5 FALSE
+30 1 FALSE
+31 2 FALSE
+32 3 FALSE
+33 4 FALSE
+34 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=latin1
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+a b c
+1 1 TRUE
+2 1 FALSE
+3 2 TRUE
+4 2 FALSE
+5 3 TRUE
+6 3 FALSE
+7 4 TRUE
+8 4 FALSE
+9 5 TRUE
+10 5 FALSE
+13 1 TRUE
+14 1 FALSE
+15 2 TRUE
+16 2 FALSE
+17 3 TRUE
+18 3 FALSE
+19 4 TRUE
+20 4 FALSE
+21 5 TRUE
+22 5 FALSE
+23 1 FALSE
+24 2 FALSE
+25 3 FALSE
+26 4 FALSE
+27 5 FALSE
+30 1 FALSE
+31 2 FALSE
+32 3 FALSE
+33 4 FALSE
+34 5 FALSE
+37 1 FALSE
+38 2 FALSE
+39 3 FALSE
+40 4 FALSE
+41 5 FALSE
+44 1 FALSE
+45 2 FALSE
+46 3 FALSE
+47 4 FALSE
+48 5 FALSE
+51 1 FALSE
+52 2 FALSE
+53 3 FALSE
+54 4 FALSE
+55 5 FALSE
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `b` int(10) unsigned NOT NULL,
+ `c` enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=latin1
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE IF EXISTS t1;
+Warnings:
+Note 1051 Unknown table 't1'
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note 1051 Unknown table 't2'
+CREATE TABLE t1(
+c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
+PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+CREATE TABLE t2(
+c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
+PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t2 SELECT c1 FROM t1;
+Got one of the listed errors
+INSERT INTO t2 SELECT NULL FROM t1;
+Got one of the listed errors
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/r/innodb-semi-consistent.result b/mysql-test/r/innodb-semi-consistent.result
index 55e3cb5c7b4..ca0e362ef80 100644
--- a/mysql-test/r/innodb-semi-consistent.result
+++ b/mysql-test/r/innodb-semi-consistent.result
@@ -38,3 +38,10 @@ a
11
7
drop table t1;
+create table t1 (a int, b int) engine=myisam;
+create table t2 (c int, d int, key (c)) engine=innodb;
+insert into t1 values (1,1);
+insert into t2 values (1,2);
+set session transaction isolation level read committed;
+delete from t1 using t1 join t2 on t1.a = t2.c where t2.d in (1);
+drop table t1, t2;
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index a82c5225e54..7ff73826104 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -1736,36 +1736,36 @@ select count(*) from t1 where x = 18446744073709551601;
count(*)
1
drop table t1;
-show status like "Innodb_buffer_pool_pages_total";
-Variable_name Value
-Innodb_buffer_pool_pages_total 4096
-show status like "Innodb_page_size";
-Variable_name Value
-Innodb_page_size 16384
-show status like "Innodb_rows_deleted";
-Variable_name Value
-Innodb_rows_deleted 71
-show status like "Innodb_rows_inserted";
-Variable_name Value
-Innodb_rows_inserted 1084
-show status like "Innodb_rows_updated";
-Variable_name Value
-Innodb_rows_updated 885
-show status like "Innodb_row_lock_waits";
-Variable_name Value
-Innodb_row_lock_waits 0
-show status like "Innodb_row_lock_current_waits";
-Variable_name Value
-Innodb_row_lock_current_waits 0
-show status like "Innodb_row_lock_time";
-Variable_name Value
-Innodb_row_lock_time 0
-show status like "Innodb_row_lock_time_max";
-Variable_name Value
-Innodb_row_lock_time_max 0
-show status like "Innodb_row_lock_time_avg";
-Variable_name Value
-Innodb_row_lock_time_avg 0
+SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
+variable_value
+4096
+SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
+variable_value
+16384
+SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted';
+variable_value - @innodb_rows_deleted_orig
+71
+SELECT variable_value - @innodb_rows_inserted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted';
+variable_value - @innodb_rows_inserted_orig
+1084
+SELECT variable_value - @innodb_rows_updated_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated';
+variable_value - @innodb_rows_updated_orig
+885
+SELECT variable_value - @innodb_row_lock_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits';
+variable_value - @innodb_row_lock_waits_orig
+0
+SELECT variable_value - @innodb_row_lock_current_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits';
+variable_value - @innodb_row_lock_current_waits_orig
+0
+SELECT variable_value - @innodb_row_lock_time_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time';
+variable_value - @innodb_row_lock_time_orig
+0
+SELECT variable_value - @innodb_row_lock_time_max_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max';
+variable_value - @innodb_row_lock_time_max_orig
+0
+SELECT variable_value - @innodb_row_lock_time_avg_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg';
+variable_value - @innodb_row_lock_time_avg_orig
+0
show variables like "innodb_sync_spin_loops";
Variable_name Value
innodb_sync_spin_loops 20
diff --git a/mysql-test/r/innodb_bug42419.result b/mysql-test/r/innodb_bug42419.result
new file mode 100644
index 00000000000..f304bb634cb
--- /dev/null
+++ b/mysql-test/r/innodb_bug42419.result
@@ -0,0 +1,17 @@
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b INT) ENGINE = InnoDB;
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+COMMIT;
+SET AUTOCOMMIT = 0;
+CREATE TEMPORARY TABLE t1_tmp ( b INT );
+INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 3;
+INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 2;
+SET AUTOCOMMIT = 0;
+CREATE TEMPORARY TABLE t2_tmp ( a int, new_a int );
+INSERT INTO t2_tmp VALUES (1,51),(2,52),(3,53);
+UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 1;
+UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 2;
+INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 1;
+ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+Reap the server message for connection user2 UPDATE t1 ...
+UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 3;
+DROP TABLE t1;
diff --git a/mysql-test/r/innodb_gis.result b/mysql-test/r/innodb_gis.result
index ef8bdcc5f3e..c6c775afc9f 100644
--- a/mysql-test/r/innodb_gis.result
+++ b/mysql-test/r/innodb_gis.result
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.416666666667 25.416666666667)
+109 POINT(25.4166666666667 25.4166666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.588527753042 17.426536064114)
-118 POINT(55.588527753042 17.426536064114)
+117 POINT(55.5885277530424 17.426536064114)
+118 POINT(55.5885277530424 17.426536064114)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 6fcc9415d12..191a8578d4c 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -1378,6 +1378,36 @@ a b c
5 1 1
4 1 1
DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a char(50)) ENGINE=InnoDB;
+CREATE INDEX i1 on t1 (a(3));
+SELECT * FROM t1 WHERE a = 'abcde';
+a
+DROP TABLE t1;
+#
+# BUG #26288: savepoint are not deleted on comit, if the transaction
+# was otherwise empty
+#
+BEGIN;
+SAVEPOINT s1;
+COMMIT;
+RELEASE SAVEPOINT s1;
+ERROR 42000: SAVEPOINT s1 does not exist
+BEGIN;
+SAVEPOINT s2;
+COMMIT;
+ROLLBACK TO SAVEPOINT s2;
+ERROR 42000: SAVEPOINT s2 does not exist
+BEGIN;
+SAVEPOINT s3;
+ROLLBACK;
+RELEASE SAVEPOINT s3;
+ERROR 42000: SAVEPOINT s3 does not exist
+BEGIN;
+SAVEPOINT s4;
+ROLLBACK;
+ROLLBACK TO SAVEPOINT s4;
+ERROR 42000: SAVEPOINT s4 does not exist
End of 5.0 tests
CREATE TABLE `t2` (
`k` int(11) NOT NULL auto_increment,
@@ -1657,6 +1687,25 @@ vid tid idx name type
3 1 2 c1 NULL
3 1 1 pk NULL
DROP TABLE t1;
+#
+# Bug #44290: explain crashes for subquery with distinct in
+# SQL_SELECT::test_quick_select
+# (reproduced only with InnoDB tables)
+#
+CREATE TABLE t1 (c1 INT, c2 INT, c3 INT, KEY (c3), KEY (c2, c3))
+ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,1,1), (1,1,1), (1,1,2), (1,1,1), (1,1,2);
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
+FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+1
+1
+EXPLAIN
+SELECT 1 FROM (SELECT COUNT(DISTINCT c1)
+FROM t1 WHERE c2 IN (1, 1) AND c3 = 2 GROUP BY c2) x;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> system NULL NULL NULL NULL 1
+2 DERIVED t1 index c3,c2 c2 10 NULL 5
+DROP TABLE t1;
End of 5.1 tests
drop table if exists t1, t2, t3;
create table t1(a int);
@@ -1846,4 +1895,149 @@ id
TRUNCATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;
+#
+# Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0
+#
+CREATE TABLE t1 (
+id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE=InnoDB;
+CREATE TABLE t2 (
+id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+aid INT UNSIGNED NOT NULL,
+PRIMARY KEY (id),
+FOREIGN KEY (aid) REFERENCES t1 (id)
+) ENGINE=InnoDB;
+CREATE TABLE t3 (
+bid INT UNSIGNED NOT NULL,
+FOREIGN KEY (bid) REFERENCES t2 (id)
+) ENGINE=InnoDB;
+CREATE TABLE t4 (
+a INT
+) ENGINE=InnoDB;
+CREATE TABLE t5 (
+a INT
+) ENGINE=InnoDB;
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id, aid) VALUES (1, 1),(2,1),(3,1),(4,1);
+INSERT INTO t3 (bid) VALUES (1);
+INSERT INTO t4 VALUES (1),(2),(3),(4),(5);
+INSERT INTO t5 VALUES (1);
+DELETE t5 FROM t4 LEFT JOIN t5 ON t4.a= t5.a;
+DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`))
+DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`bid`) REFERENCES `t2` (`id`))
+DELETE IGNORE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
+DROP TABLE t3;
+DROP TABLE t2;
+DROP TABLE t1;
+DROP TABLES t4,t5;
+# Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0
+# Testing for any side effects of IGNORE on AFTER DELETE triggers used with
+# transactional tables.
+#
+CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (a VARCHAR(100)) ENGINE=InnoDB;
+CREATE TABLE t3 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t4 (i INT NOT NULL PRIMARY KEY, t1i INT,
+FOREIGN KEY (t1i) REFERENCES t1(i))
+ENGINE=InnoDB;
+CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+SET @b:='EXECUTED TRIGGER';
+INSERT INTO t2 VALUES (@b);
+SET @a:= error_happens_here;
+END||
+SET @b:="";
+SET @a:="";
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t3 SELECT * FROM t1;
+** An error in a trigger causes rollback of the statement.
+DELETE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+ERROR 42S22: Unknown column 'error_happens_here' in 'field list'
+SELECT @a,@b;
+@a @b
+ EXECUTED TRIGGER
+SELECT * FROM t2;
+a
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+i i
+1 1
+2 2
+3 3
+4 4
+** Same happens with the IGNORE option
+DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+ERROR 42S22: Unknown column 'error_happens_here' in 'field list'
+SELECT * FROM t2;
+a
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+i i
+1 1
+2 2
+3 3
+4 4
+**
+** The following is an attempt to demonstrate
+** error handling inside a row iteration.
+**
+DROP TRIGGER trg;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t3 VALUES (1),(2),(3),(4);
+INSERT INTO t4 VALUES (3,3),(4,4);
+CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+SET @b:= CONCAT('EXECUTED TRIGGER FOR ROW ',CAST(OLD.i AS CHAR));
+INSERT INTO t2 VALUES (@b);
+END||
+** DELETE is prevented by foreign key constrains but errors are silenced.
+** The AFTER trigger isn't fired.
+DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+** Tables are modified by best effort:
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+i i
+3 3
+4 4
+** The AFTER trigger was only executed on successful rows:
+SELECT * FROM t2;
+a
+EXECUTED TRIGGER FOR ROW 1
+EXECUTED TRIGGER FOR ROW 2
+DROP TRIGGER trg;
+**
+** Induce an error midway through an AFTER-trigger
+**
+TRUNCATE TABLE t4;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t3;
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t3 VALUES (1),(2),(3),(4);
+CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+SET @a:= @a+1;
+IF @a > 2 THEN
+INSERT INTO t4 VALUES (5,5);
+END IF;
+END||
+SET @a:=0;
+** Errors in the trigger causes the statement to abort.
+DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`t1i`) REFERENCES `t1` (`i`))
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+i i
+1 1
+2 2
+3 3
+4 4
+SELECT * FROM t4;
+i t1i
+DROP TRIGGER trg;
+DROP TABLE t4;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
End of 5.1 tests
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index 919aff4bfb7..3f91039d592 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -633,4 +633,9 @@ SELECT * FROM t2;
c1
15449237462
DROP TABLE t1, t2;
+CREATE TABLE t1(f1 FLOAT);
+INSERT INTO t1 VALUES (1.23);
+CREATE TABLE t2(f1 CHAR(1));
+INSERT INTO t2 SELECT f1 FROM t1;
+DROP TABLE t1, t2;
End of 5.0 tests.
diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result
index 9ada5dc0784..08d8059f61b 100644
--- a/mysql-test/r/key_cache.result
+++ b/mysql-test/r/key_cache.result
@@ -276,8 +276,6 @@ Variable_name Value
Key_blocks_unused KEY_BLOCKS_UNUSED
set global keycache2.key_buffer_size=0;
set global keycache3.key_buffer_size=100;
-Warnings:
-Warning 1292 Truncated incorrect key_buffer_size value: '100'
set global keycache3.key_buffer_size=0;
create table t1 (mytext text, FULLTEXT (mytext));
insert t1 values ('aaabbb');
diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result
index 6152e403637..7ec07fb5273 100644
--- a/mysql-test/r/lock.result
+++ b/mysql-test/r/lock.result
@@ -166,4 +166,31 @@ ERROR HY000: View's SELECT refers to a temporary table 't2'
Cleanup.
drop table t2, t3;
+#
+# Bug#39843 DELETE requires write access to table in subquery in where clause
+#
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (
+table1_rowid SMALLINT NOT NULL
+);
+CREATE TABLE t2 (
+table2_rowid SMALLINT NOT NULL
+);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+LOCK TABLES t1 WRITE, t2 READ;
+# Sub-select should not try to aquire a write lock.
+DELETE FROM t1
+WHERE EXISTS
+(
+SELECT 'x'
+FROM t2
+WHERE t1.table1_rowid = t2.table2_rowid
+) ;
+# While implementing the patch we didn't break old behavior;
+# The following sub-select should still requires a write lock:
+SELECT * FROM t1 WHERE 1 IN (SELECT * FROM t2 FOR UPDATE);
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
+UNLOCK TABLES;
+DROP TABLE t1,t2;
End of 5.1 tests.
diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result
index a0e3d9fad06..d8768e802ea 100644
--- a/mysql-test/r/lock_multi.result
+++ b/mysql-test/r/lock_multi.result
@@ -51,10 +51,10 @@ Field Type Null Key Default Extra
a int(11) YES NULL
unlock tables;
drop table t1;
-use mysql;
+USE mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES;
-use mysql;
+USE mysql;
SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
OPTIMIZE TABLES columns_priv, db, host, user;
Table Op Msg_type Msg_text
@@ -65,7 +65,7 @@ mysql.user optimize status OK
UNLOCK TABLES;
Select_priv
N
-use test;
+USE test;
use test;
CREATE TABLE t1 (c1 int);
LOCK TABLE t1 WRITE;
@@ -96,45 +96,66 @@ alter table t1 auto_increment=0;
alter table t1 auto_increment=0;
unlock tables;
drop table t1;
-CREATE TABLE t1 (
-a int(11) unsigned default NULL,
-b varchar(255) default NULL,
-UNIQUE KEY a (a),
-KEY b (b)
-);
-INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
-CREATE TABLE t2 SELECT * FROM t1;
-CREATE TABLE t3 SELECT * FROM t1;
-# test altering of columns that multiupdate doesn't use
-# normal mode
-# PS mode
-# test altering of columns that multiupdate uses
-# normal mode
-# PS mode
-DROP TABLE t1, t2, t3;
-CREATE TABLE t1( a INT, b INT );
-INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
-# 1. test regular tables
-# 1.1. test altering of columns that multiupdate doesn't use
-# 1.1.1. normal mode
-# 1.1.2. PS mode
-# 1.2. test altering of columns that multiupdate uses
-# 1.2.1. normal mode
-# 1.2.2. PS mode
-ALTER TABLE t1 ADD COLUMN a INT;
-# 2. test UNIONs
-# 2.1. test altering of columns that multiupdate doesn't use
-# 2.1.1. normal mode
-# 2.1.2. PS mode
-# 2.2. test altering of columns that multiupdate uses
-# 2.2.1. normal mode
-# 2.2.2. PS mode
-DROP TABLE t1;
+create table t1 (a int);
+create table t2 like t1;
+# con1
+lock tables t1 write;
+# con2
+flush tables with read lock;
+# con5
+# global read lock is taken
+# con3
+select * from t2 for update;
+# waiting for release of read lock
+# con4
+# would hang and later cause a deadlock
+flush tables t2;
+# clean up
+unlock tables;
+unlock tables;
+a
+drop table t1,t2;
+#
+# Lightweight version:
+# Ensure that the wait for a GRL is done before opening tables.
+#
+create table t1 (a int);
+create table t2 like t1;
+#
+# UPDATE
+#
+# default
+flush tables with read lock;
+# con1
+update t2 set a = 1;
+# default
+# statement is waiting for release of read lock
+# con2
+flush table t2;
+# default
+unlock tables;
+# con1
+#
+# LOCK TABLES .. WRITE
+#
+# default
+flush tables with read lock;
+# con1
+lock tables t2 write;
+# default
+# statement is waiting for release of read lock
+# con2
+flush table t2;
+# default
+unlock tables;
+# con1
+unlock tables;
+drop table t1,t2;
End of 5.0 tests
create table t1 (i int);
lock table t1 read;
-update t1 set i= 10;;
-select * from t1;;
+update t1 set i= 10;
+select * from t1;
kill query ID;
i
ERROR 70100: Query execution was interrupted
diff --git a/mysql-test/r/lock_multi_bug38499.result b/mysql-test/r/lock_multi_bug38499.result
new file mode 100644
index 00000000000..fd0f2138a8d
--- /dev/null
+++ b/mysql-test/r/lock_multi_bug38499.result
@@ -0,0 +1,19 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1( a INT, b INT );
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
+# 1. test regular tables
+# 1.1. test altering of columns that multiupdate doesn't use
+# 1.1.1. normal mode
+# 1.1.2. PS mode
+# 1.2. test altering of columns that multiupdate uses
+# 1.2.1. normal mode
+# 1.2.2. PS mode
+ALTER TABLE t1 ADD COLUMN a INT;
+# 2. test UNIONs
+# 2.1. test altering of columns that multiupdate doesn't use
+# 2.1.1. normal mode
+# 2.1.2. PS mode
+# 2.2. test altering of columns that multiupdate uses
+# 2.2.1. normal mode
+# 2.2.2. PS mode
+DROP TABLE t1;
diff --git a/mysql-test/r/lock_multi_bug38691.result b/mysql-test/r/lock_multi_bug38691.result
new file mode 100644
index 00000000000..74b9603d8e3
--- /dev/null
+++ b/mysql-test/r/lock_multi_bug38691.result
@@ -0,0 +1,17 @@
+DROP TABLE IF EXISTS t1,t2,t3;
+CREATE TABLE t1 (
+a int(11) unsigned default NULL,
+b varchar(255) default NULL,
+UNIQUE KEY a (a),
+KEY b (b)
+);
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+CREATE TABLE t2 SELECT * FROM t1;
+CREATE TABLE t3 SELECT * FROM t1;
+# test altering of columns that multiupdate doesn't use
+# normal mode
+# PS mode
+# test altering of columns that multiupdate uses
+# normal mode
+# PS mode
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result
index 376120abcda..f8321520880 100644
--- a/mysql-test/r/log_tables.result
+++ b/mysql-test/r/log_tables.result
@@ -56,7 +56,7 @@ general_log CREATE TABLE `general_log` (
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
@@ -65,7 +65,7 @@ Field Type Null Key Default Extra
event_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
user_host mediumtext NO NULL
thread_id int(11) NO NULL
-server_id int(11) NO NULL
+server_id int(10) unsigned NO NULL
command_type varchar(64) NO NULL
argument mediumtext NO NULL
show create table mysql.slow_log;
@@ -80,7 +80,7 @@ slow_log CREATE TABLE `slow_log` (
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show fields from mysql.slow_log;
@@ -94,7 +94,7 @@ rows_examined int(11) NO NULL
db varchar(512) NO NULL
last_insert_id int(11) NO NULL
insert_id int(11) NO NULL
-server_id int(11) NO NULL
+server_id int(10) unsigned NO NULL
sql_text mediumtext NO NULL
flush logs;
flush tables;
@@ -167,7 +167,7 @@ general_log CREATE TABLE `general_log` (
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
@@ -183,7 +183,7 @@ slow_log CREATE TABLE `slow_log` (
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
alter table mysql.general_log engine=myisam;
@@ -194,7 +194,7 @@ general_log CREATE TABLE `general_log` (
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='General log'
@@ -210,7 +210,7 @@ slow_log CREATE TABLE `slow_log` (
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Slow log'
set global general_log='ON';
@@ -268,7 +268,7 @@ CREATE TABLE `general_log` (
ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
-`server_id` int(11) NOT NULL,
+`server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
@@ -283,7 +283,7 @@ ON UPDATE CURRENT_TIMESTAMP,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
-`server_id` int(11) NOT NULL,
+`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
set global general_log='ON';
diff --git a/mysql-test/r/lowercase_table3.result b/mysql-test/r/lowercase_table3.result
index 880a203a15f..1ef7d04bb1d 100644
--- a/mysql-test/r/lowercase_table3.result
+++ b/mysql-test/r/lowercase_table3.result
@@ -1,11 +1,11 @@
-call mtr.add_suppression("Cannot find or open table test/BUG29839 from");
+call mtr.add_suppression("Cannot find or open table test/BUG29839 from .*");
DROP TABLE IF EXISTS t1,T1;
-CREATE TABLE t1 (a int);
-SELECT * from T1;
+CREATE TABLE t1 (a INT);
+SELECT * FROM T1;
a
-drop table t1;
-flush tables;
-CREATE TABLE bug29839 (a int) ENGINE=INNODB;
-SELECT * from BUG29839;
+FLUSH TABLES;
+DROP TABLE t1;
+CREATE TABLE bug29839 (a INT) ENGINE=INNODB;
+SELECT * FROM BUG29839;
ERROR 42S02: Table 'test.BUG29839' doesn't exist
-drop table bug29839;
+DROP TABLE bug29839;
diff --git a/mysql-test/r/lowercase_utf8.result b/mysql-test/r/lowercase_utf8.result
new file mode 100644
index 00000000000..043226e1f64
--- /dev/null
+++ b/mysql-test/r/lowercase_utf8.result
@@ -0,0 +1,9 @@
+set names utf8;
+create table `Ö` (id int);
+show tables from test like 'Ö';
+Tables_in_test (Ö)
+ö
+show tables from test like 'ö';
+Tables_in_test (ö)
+ö
+drop table `Ö`;
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 9ab982a6688..f53b328d14e 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -2025,7 +2025,6 @@ TABLE_SCHEMA = 'test' and TABLE_NAME='tm1';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT
NULL test tm1 BASE TABLE NULL NULL NULL # # # # # # # # # # NULL # # Unable to open underlying table which is differently defined or of non-MyISAM ty
DROP TABLE tm1;
-End of 5.1 tests
CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
CREATE TABLE t3(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
@@ -2041,4 +2040,91 @@ EXPLAIN SELECT COUNT(*) FROM t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
DROP TABLE t1, t2, t3, t4;
+CREATE TABLE t1(a INT, KEY(a));
+INSERT INTO t1 VALUES(0),(1),(2),(3),(4);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+CREATE TABLE m1(a INT, KEY(a)) ENGINE=MERGE UNION=(t1);
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+CARDINALITY
+5
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+CARDINALITY
+5
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+CARDINALITY
+5
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+CARDINALITY
+5
+DROP TABLE t1, m1;
+#
+# Bug #40675 MySQL 5.1 crash with index merge algorithm and Merge tables
+#
+# create MYISAM table t1 and insert values into it
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+# create MYISAM table t2 and insert values into it
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) 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),(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),(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),(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),(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),
+(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),
+(1,2);
+# Create the merge table t3
+CREATE TABLE t3(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b))
+ENGINE=MERGE UNION=(t2) INSERT_METHOD=FIRST;
+# Lock tables t1 and t3 for write
+LOCK TABLES t1 WRITE, t3 WRITE;
+# Insert values into the merge table t3
+INSERT INTO t3(a,b) VALUES(1,2);
+# select from the join of t2 and t3 (The merge table)
+SELECT t3.a FROM t1,t3 WHERE t3.b=2 AND t3.a=1;
+a
+1
+1
+# Unlock the tables
+UNLOCK TABLES;
+# drop the created tables
+DROP TABLE t1, t2, t3;
+# insert duplicate value in child table while merge table doesn't have key
+create table t1 (
+col1 int(10),
+primary key (col1)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+CREATE TABLE m1 (
+col1 int(10) NOT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(t1);
+insert into m1 (col1) values (1);
+insert into m1 (col1) values (1);
+ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
+drop table m1, t1;
+CREATE TABLE t1 (
+col1 INT(10)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+CREATE VIEW v1 as SELECT * FROM t1;
+CREATE TABLE m1 (
+col1 INT(10)
+)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1);
+#Select should detect that the child table is a view and fail.
+SELECT * FROM m1;
+ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+DROP VIEW v1;
+DROP TABLE m1, t1;
End of 5.1 tests
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index b8f6aa9e4d4..449333a4ae6 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -375,7 +375,7 @@ update t2, t1 set t2.field=t1.field
where t1.id1=t2.id2 and 0=1;
delete t1, t2 from t2 inner join t1 on t1.id1=t2.id2
where 0=1;
-delete t1, t2 from t2,t1
+delete t1, t2 from t2,t1
where t1.id1=t2.id2 and 0=1;
drop table t1,t2;
CREATE TABLE t1 ( a int );
@@ -443,12 +443,12 @@ delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2
ERROR HY000: You can't specify target table 't1' for update in FROM clause
drop table t1,t2;
create table t1 (
-aclid bigint not null primary key,
-status tinyint(1) not null
+aclid bigint not null primary key,
+status tinyint(1) not null
) engine = innodb;
create table t2 (
-refid bigint not null primary key,
-aclid bigint, index idx_acl(aclid)
+refid bigint not null primary key,
+aclid bigint, index idx_acl(aclid)
) engine = innodb;
insert into t2 values(1,null);
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 6f26135ce45..732b1b260f8 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -2226,4 +2226,30 @@ Key Start Len Index Type
1 2 30 multip. varchar
2 33 30 multip. char NULL
DROP TABLE t1;
+CREATE TABLE t1 (
+c INT,
+d bit(1),
+e INT,
+f VARCHAR(1),
+g BIT(1),
+h BIT(1),
+KEY (h, d, e, g)
+);
+INSERT INTO t1 VALUES
+( 3, 1, 1, 'a', 0, 0 ),
+( 3, 1, 5, 'a', 0, 0 ),
+( 10, 1, 2, 'a', 0, 1 ),
+( 10, 1, 3, 'a', 0, 1 ),
+( 10, 1, 4, 'a', 0, 1 );
+SELECT f FROM t1 WHERE d = 1 AND e = 2 AND g = 0 AND h = 1;
+f
+a
+SELECT h+0, d + 0, e, g + 0 FROM t1;
+h+0 d + 0 e g + 0
+0 1 1 0
+0 1 5 0
+1 1 2 0
+1 1 3 0
+1 1 4 0
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/myisam_crash_before_flush_keys.result b/mysql-test/r/myisam_crash_before_flush_keys.result
new file mode 100644
index 00000000000..372f2e41590
--- /dev/null
+++ b/mysql-test/r/myisam_crash_before_flush_keys.result
@@ -0,0 +1,45 @@
+#
+# BUG#41330 - Myisam table open count set to zero before index blocks are written.
+#
+# Don't test this under valgrind, memory leaks will occur
+# Binary must be compiled with debug for crash to occur
+SET GLOBAL delay_key_write=ALL;
+CREATE TABLE t1(a INT,
+b INT,
+PRIMARY KEY(a , b),
+KEY(b)) ENGINE=MyISAM DELAY_KEY_WRITE = 1;
+INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6);
+# Setup the mysqld to crash at certain point
+SET SESSION debug="d,crash_before_flush_keys";
+# Write file to make mysql-test-run.pl expect crash
+# Run the crashing query
+FLUSH TABLE t1;
+ERROR HY000: Lost connection to MySQL server during query
+# Run MYISAMCHK tool to check the table t1 and repair
+myisamchk: MyISAM file MYSQLD_DATADIR/test/t1
+myisamchk: warning: 1 client is using or hasn't closed the table properly
+myisamchk: error: Size of indexfile is: 1024 Should be: 3072
+MYISAMCHK: Unknown error 126
+myisamchk: error: Can't read indexpage from filepos: 1024
+MyISAM-table 'MYSQLD_DATADIR/test/t1' is corrupted
+Fix it using switch "-r" or "-o"
+# Write file to make mysql-test-run.pl start the server
+# Turn on reconnect
+# Call script that will poll the server waiting for
+# it to be back online again
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`a`,`b`),
+ KEY `b` (`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 DELAY_KEY_WRITE=1
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+a b
+1 2
+2 3
+3 4
+4 5
+5 6
+DROP TABLE t1;
diff --git a/mysql-test/r/myisam_debug.result b/mysql-test/r/myisam_debug.result
new file mode 100644
index 00000000000..c128bfffce9
--- /dev/null
+++ b/mysql-test/r/myisam_debug.result
@@ -0,0 +1,39 @@
+#
+# BUG#40827 - Killing insert-select to MyISAM can cause table corruption
+#
+CREATE TABLE `t1` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+KEY(id1), KEY(id)
+) ENGINE=MyISAM;
+CREATE TABLE `t2` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+KEY (id1), KEY(id)
+) ENGINE=MyISAM;
+INSERT INTO t2 (id) VALUES (123);
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+INSERT INTO t2 (id) SELECT id FROM t2;
+# Switch to insert Connection
+SET SESSION debug='+d,wait_in_enable_indexes';
+# Send insert data
+INSERT INTO t1(id) SELECT id FROM t2;
+# Switch to default Connection
+# Wait for insert data to reach the debug point
+SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE STATE = 'wait_in_enable_indexes' AND
+INFO = "INSERT INTO t1(id) SELECT id FROM t2"
+INTO @thread_id;
+KILL QUERY @thread_id;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/myisampack.result b/mysql-test/r/myisampack.result
index 50d700ab7a2..fbcd8aed17a 100644
--- a/mysql-test/r/myisampack.result
+++ b/mysql-test/r/myisampack.result
@@ -54,3 +54,36 @@ test.t1 repair error Table 'test.t1' is read only
Warnings:
Error 1036 Table 't1' is read only
drop table t1;
+#
+# BUG#41541 - Valgrind warnings on packed MyISAM table
+#
+CREATE TABLE t1(f1 VARCHAR(200), f2 TEXT);
+INSERT INTO t1 VALUES ('foo', 'foo1'), ('bar', 'bar1');
+FLUSH TABLE t1;
+# Compress the table using MYISAMPACK tool
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+1024
+DROP TABLE t1;
+#
+# Bug #43973 - backup_myisam.test fails on 6.0-bugteam
+#
+CREATE DATABASE mysql_db1;
+CREATE TABLE mysql_db1.t1 (c1 VARCHAR(5), c2 int);
+CREATE INDEX i1 ON mysql_db1.t1 (c1, c2);
+INSERT INTO mysql_db1.t1 VALUES ('A',1);
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+FLUSH TABLE mysql_db1.t1;
+# Compress the table using MYISAMPACK tool
+# Run MYISAMCHK tool on the compressed table
+SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5;
+COUNT(*)
+128
+DROP TABLE mysql_db1.t1;
+DROP DATABASE mysql_db1;
diff --git a/mysql-test/r/mysql-bug41486.result b/mysql-test/r/mysql-bug41486.result
new file mode 100644
index 00000000000..02777ab587f
--- /dev/null
+++ b/mysql-test/r/mysql-bug41486.result
@@ -0,0 +1,13 @@
+DROP TABLE IF EXISTS t1;
+SET @old_max_allowed_packet= @@global.max_allowed_packet;
+SET @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024;
+CREATE TABLE t1(data LONGBLOB);
+INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024);
+SET @old_general_log = @@global.general_log;
+SET @@global.general_log = 0;
+SET @@global.general_log = @old_general_log;
+SELECT LENGTH(data) FROM t1;
+LENGTH(data)
+2097152
+DROP TABLE t1;
+SET @@global.max_allowed_packet = @old_max_allowed_packet;
diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
index 25b66fe7fc6..5054c3aa76f 100644
--- a/mysql-test/r/mysql.result
+++ b/mysql-test/r/mysql.result
@@ -188,6 +188,10 @@ delimiter
2
@z:='1' @z=database()
1 NULL
+1
+1
+1
+1
End of 5.0 tests
WARNING: --server-arg option not supported in this configuration.
Warning (Code 1286): Unknown table engine 'nonexistent'
diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result
index 974b4952799..b55a96b6f30 100644
--- a/mysql-test/r/mysqlbinlog.result
+++ b/mysql-test/r/mysqlbinlog.result
@@ -44,16 +44,16 @@ SET TIMESTAMP=1000000000/*!*/;
insert into t2 values ()
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
DELIMITER ;
# End of log file
@@ -144,16 +144,16 @@ SET TIMESTAMP=1000000000/*!*/;
insert into t2 values ()
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
DELIMITER ;
# End of log file
@@ -359,29 +359,29 @@ SET @@session.collation_database=DEFAULT/*!*/;
create table t1 (a varchar(64) character set utf8)
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=7/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=7/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO table t1
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
-load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r
+load data LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO table t1 character set koi8r
/*!*/;
SET TIMESTAMP=1000000000/*!*/;
drop table t1
@@ -391,22 +391,28 @@ DELIMITER ;
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
CREATE TABLE t1 (c1 CHAR(10));
-flush logs;
+FLUSH LOGS;
INSERT INTO t1 VALUES ('0123456789');
-flush logs;
+FLUSH LOGS;
DROP TABLE t1;
-# Query thread_id=REMOVED exec_time=REMOVED error_code=REMOVED
-flush logs;
-create table t1(a int);
-insert into t1 values(connection_id());
-flush logs;
-drop table t1;
+We expect this value to be 1
+The bug being tested was that 'Query' lines were not preceded by '#'
+If the line is in the table, it had to have been preceded by a '#'
+
+SELECT COUNT(*) AS `BUG#28293_expect_1` FROM patch WHERE a LIKE '%Query%';
+BUG#28293_expect_1
1
-drop table t1;
+DROP TABLE patch;
+FLUSH LOGS;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(connection_id());
+FLUSH LOGS;
+DROP TABLE t1;
+1
+DROP TABLE t1;
shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql
-End of 5.0 tests
-flush logs;
-BUG#31611: Security risk with BINLOG statement
+FLUSH LOGS;
+Bug#31611 Security risk with BINLOG statement
SET BINLOG_FORMAT=ROW;
CREATE DATABASE mysqltest1;
CREATE USER untrusted@localhost;
@@ -429,7 +435,7 @@ a b
1 root@localhost
DROP DATABASE mysqltest1;
DROP USER untrusted@localhost;
-BUG#32580: mysqlbinlog cannot read binlog event with user variables
+Bug#32580 mysqlbinlog cannot read binlog event with user variables
USE test;
SET BINLOG_FORMAT = STATEMENT;
FLUSH LOGS;
@@ -454,4 +460,15 @@ an_int 1000
a_decimal 907.79
a_string Just a test
DROP TABLE t1;
+SET @@global.server_id= 4294967295;
+RESET MASTER;
+FLUSH LOGS;
+SELECT
+(@a:=LOAD_FILE("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
+IS NOT NULL;
+(@a:=LOAD_FILE("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog"))
+IS NOT NULL
+1
+*** Unsigned server_id 4294967295 is found: 1 ***
+SET @@global.server_id= 1;
End of 5.1 tests
diff --git a/mysql-test/r/mysqlbinlog_row_big.result b/mysql-test/r/mysqlbinlog_row_big.result
index f2ca72f9936..46fa0dc79cd 100644
--- a/mysql-test/r/mysqlbinlog_row_big.result
+++ b/mysql-test/r/mysqlbinlog_row_big.result
@@ -9,7 +9,17 @@ SET timestamp=1000000000;
#
# We need big packets.
#
+# Capture initial value to reset at the end of the test
+# Now adjust max_allowed_packet
SET @@global.max_allowed_packet= 1024*1024*1024;
+max_allowed_packet is a global variable.
+In order for the preceding change in max_allowed_packets' value
+to be seen and used, we must start a new connection.
+The change does not take effect with the current one.
+For simplicity, we just disconnect / reconnect connection default here.
+Disconnecting default connection...
+Reconnecting default connection...
+default connection established, continuing with the test
#
# Delete all existing binary logs.
#
@@ -21,40 +31,56 @@ CREATE TABLE t1 (
c1 LONGTEXT
) ENGINE=MyISAM DEFAULT CHARSET latin1;
#
-# Show how much rows are affected by each statement.
+# Show how many rows are affected by each statement.
#
#
-# Insert a big row.
+# Insert some big rows.
#
+256MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216));
+affected rows: 1
+32MB
INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152));
affected rows: 1
+4MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 262144));
+affected rows: 1
+512KB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 32768));
+affected rows: 1
#
# Show what we have in the table.
# Do not display the column value itself, just its length.
#
SELECT LENGTH(c1) FROM t1;
+LENGTH(c1) 268435456
LENGTH(c1) 33554432
-affected rows: 1
+LENGTH(c1) 4194304
+LENGTH(c1) 524288
+affected rows: 4
#
-# Grow the row by updating.
+# Grow the rows by updating.
#
UPDATE t1 SET c1 = CONCAT(c1, c1);
-affected rows: 1
-info: Rows matched: 1 Changed: 1 Warnings: 0
+affected rows: 4
+info: Rows matched: 4 Changed: 4 Warnings: 0
#
# Show what we have in the table.
# Do not display the column value itself, just its length.
#
SELECT LENGTH(c1) FROM t1;
+LENGTH(c1) 536870912
+LENGTH(c1) 1048576
LENGTH(c1) 67108864
-affected rows: 1
+LENGTH(c1) 8388608
+affected rows: 4
#
-# Delete the row.
+# Delete the rows.
#
DELETE FROM t1 WHERE c1 >= 'ManyMegaByteBlck';
-affected rows: 1
+affected rows: 4
#
-# Hide how much rows are affected by each statement.
+# Hide how many rows are affected by each statement.
#
#
# Flush all log buffers to the log file.
@@ -70,5 +96,7 @@ FLUSH LOGS;
#
# Cleanup.
#
+# reset variable value to pass testcase checks
+SET @@global.max_allowed_packet = 1048576;
DROP TABLE t1;
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out
diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result
index 6f7fcb7efde..704cd7ac3f4 100644
--- a/mysql-test/r/mysqlcheck.result
+++ b/mysql-test/r/mysqlcheck.result
@@ -149,7 +149,7 @@ SET NAMES DEFAULT;
mysqlcheck --default-character-set="latin1" --databases test
test.?
Error : Table doesn't exist
-error : Corrupt
+status : Operation failed
mysqlcheck --default-character-set="utf8" --databases test
test.Ñ OK
SET NAMES utf8;
diff --git a/mysql-test/r/mysqldump-max.result b/mysql-test/r/mysqldump-max.result
index c1c61cd7fe8..c300f3d7996 100644
--- a/mysql-test/r/mysqldump-max.result
+++ b/mysql-test/r/mysqldump-max.result
@@ -93,73 +93,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t3` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t4` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t5` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t6` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
@@ -190,73 +190,73 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
DROP TABLE IF EXISTS `t3`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t3` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
DROP TABLE IF EXISTS `t4`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t4` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
DROP TABLE IF EXISTS `t5`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t5` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
DROP TABLE IF EXISTS `t6`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t6` (
`id` int(8) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 4e97f5bc509..c97131563cb 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -34,12 +34,12 @@ DROP TABLE t1;
CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321");
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` decimal(64,20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('987654321098765432109876543210987654321.00000000000000000000');
DROP TABLE t1;
#
@@ -49,12 +49,12 @@ CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (RES);
DROP TABLE t1;
#
@@ -70,21 +70,21 @@ INSERT INTO t1 VALUES ('1.2345', 2.3456);
INSERT INTO t1 VALUES ("1.2345", 2.3456);
ERROR 42S22: Unknown column '1.2345' in 'field list'
SET SQL_MODE=@OLD_SQL_MODE;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` decimal(10,5) DEFAULT NULL,
`b` float DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456);
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` decimal(10,5) DEFAULT NULL,
`b` float DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
@@ -98,13 +98,13 @@ INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456)
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` decimal(10,5) DEFAULT NULL,
`b` float DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -127,13 +127,13 @@ UNLOCK TABLES;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` decimal(10,5) DEFAULT NULL,
`b` float DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456);
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -209,12 +209,12 @@ INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=koi8r;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -245,12 +245,9 @@ INSERT INTO t1 VALUES (1), (2);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL40' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) TYPE=MyISAM;
-SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -271,12 +268,9 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) TYPE=MyISAM;
-SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -295,12 +289,12 @@ DROP TABLE t1;
# Bug#2592 mysqldump doesn't quote "tricky" names correctly
#
create table ```a` (i int);
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE ```a` (
`i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
drop table ```a`;
#
# Bug#2591 mysqldump quotes names inconsistently
@@ -318,12 +312,12 @@ create table t1(a int);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -346,12 +340,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS "t1";
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "t1" (
"a" int(11) DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES "t1" WRITE;
/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
@@ -377,12 +371,12 @@ set global sql_mode='ANSI_QUOTES';
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -405,12 +399,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS "t1";
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "t1" (
"a" int(11) DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES "t1" WRITE;
/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
@@ -440,12 +434,12 @@ insert into t1 values (1),(2),(3);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -534,12 +528,12 @@ INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` char(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -570,12 +564,9 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
CREATE TABLE `t1` (
`a` char(10) DEFAULT NULL
) TYPE=MyISAM;
-SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -596,12 +587,9 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
CREATE TABLE `t1` (
`a` char(10) DEFAULT NULL
) TYPE=MyISAM;
-SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -622,12 +610,9 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
CREATE TABLE `t1` (
`a` char(10) DEFAULT NULL
) TYPE=MyISAM;
-SET character_set_client = @saved_cs_client;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -661,12 +646,12 @@ INSERT INTO t2 VALUES (4),(5),(6);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
@@ -702,12 +687,12 @@ INSERT INTO `t1` VALUES (0x602010000280100005E71A);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -743,12 +728,12 @@ INSERT INTO t1 VALUES (4),(5),(6);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -777,12 +762,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
@@ -1146,8 +1131,8 @@ insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`F_c4ca4238a0b923820dcc509a6f75849b` int(11) DEFAULT NULL,
`F_c81e728d9d4c2f636f067f89cc14862c` int(11) DEFAULT NULL,
@@ -1480,7 +1465,7 @@ CREATE TABLE `t1` (
`F_6faa8040da20ef399b63a72d0e4ab575` int(11) DEFAULT NULL,
`F_fe73f687e5bc5280214e0486b273a5f9` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -1521,12 +1506,12 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -1565,19 +1550,19 @@ INSERT INTO t2 VALUES (1), (2);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1600,19 +1585,19 @@ SET character_set_client = @saved_cs_client;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1812,26 +1797,26 @@ create table t3(a int);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t3`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t3` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1861,12 +1846,12 @@ mysqldump: Got error: 1064: You have an error in your SQL syntax; check the manu
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -1897,15 +1882,15 @@ insert into t1 values (0815, 4711, 2006);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS "t1";
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "t1" (
"a b" int(11) NOT NULL DEFAULT '0',
"c""d" int(11) NOT NULL DEFAULT '0',
"e`f" int(11) NOT NULL DEFAULT '0',
PRIMARY KEY ("a b","c""d","e`f")
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES "t1" WRITE;
/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
@@ -1931,15 +1916,15 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a b` int(11) NOT NULL DEFAULT '0',
`c"d` int(11) NOT NULL DEFAULT '0',
`e``f` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`a b`,`c"d`,`e``f`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -1985,13 +1970,13 @@ create view v2 as select * from t2 where a like 'a%' with check option;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` varchar(30) DEFAULT NULL,
KEY `a` (`a`(5))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
@@ -2081,12 +2066,12 @@ create view v1 as select * from t1;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2153,13 +2138,13 @@ create view v2 as select * from t2 where a like 'a%' with check option;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` varchar(30) DEFAULT NULL,
KEY `a` (`a`(5))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
@@ -2220,12 +2205,12 @@ INSERT INTO t1 VALUES ('\'');
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` char(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2266,14 +2251,14 @@ select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2425,13 +2410,13 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` bigint(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2497,12 +2482,12 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
@@ -2554,13 +2539,13 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` bigint(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2568,12 +2553,12 @@ INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
@@ -2699,12 +2684,12 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2850,13 +2835,13 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`d` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2887,13 +2872,13 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`d` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -2940,12 +2925,12 @@ a2
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS "t1 test";
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "t1 test" (
"a1" int(11) DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES "t1 test" WRITE;
/*!40000 ALTER TABLE "t1 test" DISABLE KEYS */;
@@ -2969,12 +2954,12 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
DROP TABLE IF EXISTS "t2 test";
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "t2 test" (
"a2" int(11) DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES "t2 test" WRITE;
/*!40000 ALTER TABLE "t2 test" DISABLE KEYS */;
@@ -3023,14 +3008,14 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` varchar(32) DEFAULT NULL,
`c` varchar(32) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -3154,12 +3139,12 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET l
USE `test`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -3213,13 +3198,13 @@ insert into t1 values ('','');
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL,
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -3248,13 +3233,13 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` binary(1) DEFAULT NULL,
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -3427,12 +3412,12 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CH
USE `mysqldump_test_db`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -3489,14 +3474,14 @@ create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_tables` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_tables`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `basetable` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`tag` varchar(64) DEFAULT NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_views` /*!40100 DEFAULT CHARACTER SET latin1 */;
@@ -3520,7 +3505,7 @@ USE `mysqldump_views`;
/*!50001 SET collation_connection = latin1_swedish_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
+/*!50001 VIEW `nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
@@ -3663,31 +3648,31 @@ CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t2`,`t3`);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t2`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t2` WRITE;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `t3`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t3` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t3` WRITE;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
@@ -3767,13 +3752,13 @@ drop database mysqldump_test_db;
#
CREATE TABLE t1 (c1 INT, c2 LONGBLOB);
INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` longblob
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
INSERT INTO `t1` VALUES (11,0x7171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171);
DROP TABLE t1;
#
@@ -3831,6 +3816,153 @@ DROP TABLE t1,t2;
-- Dump completed on DATE
#
+# Bug #42635: mysqldump includes views that were excluded using
+# the --ignore-table option
+#
+create database db42635;
+use db42635;
+create table t1 (id int);
+create view db42635.v1 (c) as select * from db42635.t1;
+create view db42635.v2 (c) as select * from db42635.t1;
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t1`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t1` (
+ `id` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
+DROP TABLE IF EXISTS `v2`;
+/*!50001 DROP VIEW IF EXISTS `v2`*/;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+/*!50001 CREATE TABLE `v2` (
+ `c` int(11)
+) ENGINE=MyISAM */;
+SET character_set_client = @saved_cs_client;
+/*!50001 DROP TABLE `v2`*/;
+/*!50001 DROP VIEW IF EXISTS `v2`*/;
+/*!50001 SET @saved_cs_client = @@character_set_client */;
+/*!50001 SET @saved_cs_results = @@character_set_results */;
+/*!50001 SET @saved_col_connection = @@collation_connection */;
+/*!50001 SET character_set_client = latin1 */;
+/*!50001 SET character_set_results = latin1 */;
+/*!50001 SET collation_connection = latin1_swedish_ci */;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v2` AS select `t1`.`id` AS `c` from `t1` */;
+/*!50001 SET character_set_client = @saved_cs_client */;
+/*!50001 SET character_set_results = @saved_cs_results */;
+/*!50001 SET collation_connection = @saved_col_connection */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+use test;
+drop database db42635;
+#
+# Bug#33550 mysqldump 4.0 compatibility broken
+#
+SET NAMES utf8;
+CREATE TABLE `straße` ( f1 INT );
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `straße`;
+CREATE TABLE `straße` (
+ `f1` int(11) DEFAULT NULL
+) TYPE=MyISAM;
+
+LOCK TABLES `straße` WRITE;
+/*!40000 ALTER TABLE `straße` DISABLE KEYS */;
+/*!40000 ALTER TABLE `straße` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `straße`;
+CREATE TABLE `straße` (
+ `f1` int(11) DEFAULT NULL
+) TYPE=MyISAM;
+
+LOCK TABLES `straße` WRITE;
+/*!40000 ALTER TABLE `straße` DISABLE KEYS */;
+/*!40000 ALTER TABLE `straße` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+DROP TABLE `straße`;
+CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ( f1 INT );
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `כדשגכחךלדגכחשךדגחכךלדגכ`;
+CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` (
+ `f1` int(11) DEFAULT NULL
+) TYPE=MyISAM;
+
+LOCK TABLES `כדשגכחךלדגכחשךדגחכךלדגכ` WRITE;
+/*!40000 ALTER TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` DISABLE KEYS */;
+/*!40000 ALTER TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,MYSQL323' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE `כדשגכחךלדגכחשךדגחכךלדגכ`;
+SET NAMES latin1;
+#
# End of 5.0 tests
#
drop table if exists t1;
@@ -3850,13 +3982,13 @@ INSERT INTO t1 VALUES (3,4), (4,5);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -3945,12 +4077,12 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_test_db` /*!40100 DEFAULT CH
USE `mysqldump_test_db`;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -4047,12 +4179,12 @@ create database `test-database`;
use `test-database`;
create table test (a int);
DROP TABLE IF EXISTS `test`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `test` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `test` WRITE;
/*!40000 ALTER TABLE `test` DISABLE KEYS */;
/*!40000 ALTER TABLE `test` ENABLE KEYS */;
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index 1a65f90bd65..a9c20e34517 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -215,7 +215,6 @@ source database
"MySQL: The world's most popular ;open source database"
echo message echo message
-mysqltest: At line 1: command "false" failed
mysqltest: At line 1: Missing argument in exec
MySQL
"MySQL"
@@ -383,7 +382,6 @@ mysqltest: At line 1: The argument to dec must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000"
mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: Missing arguments to system, nothing to do!
-mysqltest: At line 1: system command 'false' failed
system command 'NonExistsinfComamdn 2> /dev/null' failed
test
test2
@@ -745,10 +743,12 @@ select 1;
-- a comment for the server;
mysqltest: At line 1: Found line beginning with -- that didn't contain a valid mysqltest command, check your syntax or use # if you intended to write a comment
con1
+con2
default
con1
-default
-con1
+con2
con1
+con2
+con2
-closed_connection-
End of tests
diff --git a/mysql-test/r/not_embedded_server.result b/mysql-test/r/not_embedded_server.result
index 8f7c125196a..60c92bd0196 100644
--- a/mysql-test/r/not_embedded_server.result
+++ b/mysql-test/r/not_embedded_server.result
@@ -1,3 +1,6 @@
select 1;
1
1
+SHOW VARIABLES like 'slave_skip_errors';
+Variable_name Value
+slave_skip_errors OFF
diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result
index cab1f7a0755..c408c14b716 100644
--- a/mysql-test/r/openssl_1.result
+++ b/mysql-test/r/openssl_1.result
@@ -98,12 +98,12 @@ INSERT INTO t1 VALUES (1), (2);
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -132,12 +132,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
@@ -166,12 +166,12 @@ UNLOCK TABLES;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
-SET @saved_cs_client = @@character_set_client;
-SET character_set_client = utf8;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
);
-SET character_set_client = @saved_cs_client;
+/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
diff --git a/mysql-test/r/packet.result b/mysql-test/r/packet.result
index fa2fb33d278..ecbb47d4ee0 100644
--- a/mysql-test/r/packet.result
+++ b/mysql-test/r/packet.result
@@ -1,3 +1,5 @@
+set @max_allowed_packet=@@global.max_allowed_packet;
+set @net_buffer_length=@@global.net_buffer_length;
set global max_allowed_packet=100;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '100'
@@ -23,3 +25,5 @@ len
select length(repeat('a',2000));
length(repeat('a',2000))
2000
+set global max_allowed_packet=@max_allowed_packet;
+set global net_buffer_length=@net_buffer_length;
diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result
index 270c1ec5670..7e703de0876 100644
--- a/mysql-test/r/parser.result
+++ b/mysql-test/r/parser.result
@@ -522,7 +522,7 @@ select conv(255 AS p1, 10 AS p2, 16 AS p3);
ERROR 42000: Incorrect parameters in the call to native function 'conv'
select atan(10);
atan(10)
-1.4711276743037
+1.47112767430373
select atan(10 AS p1);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 p1);
@@ -533,7 +533,7 @@ select atan(10 "p1");
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10, 20);
atan(10, 20)
-0.46364760900081
+0.463647609000806
select atan(10 AS p1, 20);
ERROR 42000: Incorrect parameters in the call to native function 'atan'
select atan(10 p1, 20);
@@ -615,3 +615,6 @@ UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0;
SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')};
a1 a4
DROP TABLE t1, t2, t3;
+#
+# End of 5.1 tests
+#
diff --git a/mysql-test/r/parser_not_embedded.result b/mysql-test/r/parser_not_embedded.result
new file mode 100644
index 00000000000..871eb226cc4
--- /dev/null
+++ b/mysql-test/r/parser_not_embedded.result
@@ -0,0 +1,49 @@
+#
+# Bug#39559: dump of stored procedures / functions with C-style
+# comment can't be read back
+#
++----------+--------+
+| expected | result |
++----------+--------+
+| 2 | 2 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 1 | 1 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 3 | 3 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 2 | 2 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 7 | 7 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 8 | 8 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 7 | 7 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 4 | 4 |
++----------+--------+
++----------+--------+
+| expected | result |
++----------+--------+
+| 4 | 4 |
++----------+--------+
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index cec4e60d139..f69ba522a9c 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -1,5 +1,9 @@
SET @old_general_log= @@global.general_log;
drop table if exists t1, t2;
+CREATE TABLE t1 (a INT, FOREIGN KEY (a) REFERENCES t0 (a))
+ENGINE=MyISAM
+PARTITION BY HASH (a);
+ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning
CREATE TABLE t1 (
pk INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (pk)
@@ -1907,5 +1911,18 @@ select count(*) from t1;
count(*)
288
drop table t1;
+#
+# Bug#42944: partition not pruned correctly
+#
+CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN (200),
+PARTITION p2 VALUES LESS THAN (300),
+PARTITION p3 VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (10), (100), (200), (300), (400);
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a>=200;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p2,p3 ALL NULL NULL NULL NULL 3 Using where
+DROP TABLE t1;
End of 5.1 tests
SET @@global.general_log= @old_general_log;
diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result
index 547ce1ca316..511806d64bd 100644
--- a/mysql-test/r/partition_error.result
+++ b/mysql-test/r/partition_error.result
@@ -1,4 +1,13 @@
drop table if exists t1;
+CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (1),(1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+DROP TABLE t1;
+CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a))
+PARTITION BY KEY (a) PARTITIONS 2;
+INSERT INTO t1 VALUES (1),(1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+DROP TABLE t1;
CREATE TABLE t1 (a INT)
PARTITION BY HASH (a)
( PARTITION p0 ENGINE=MyISAM,
diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result
index a1f35756e21..2ff6e3f1923 100644
--- a/mysql-test/r/partition_mgm.result
+++ b/mysql-test/r/partition_mgm.result
@@ -53,7 +53,14 @@ CREATE TABLE t1 (a INT)
of multi-line
comment */
PARTITIONS 5 */;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*/' at line 6
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (a)
+PARTITIONS 5 */
+DROP TABLE t1;
CREATE TABLE t1 (a INT)
/*!50100 PARTITION BY HASH (a)
-- with a single line comment embedded
diff --git a/mysql-test/r/partition_mgm_err.result b/mysql-test/r/partition_mgm_err.result
index db89c6ef6e7..f8403988f47 100644
--- a/mysql-test/r/partition_mgm_err.result
+++ b/mysql-test/r/partition_mgm_err.result
@@ -25,13 +25,13 @@ ALTER TABLE t1 DROP PARTITION x10, x1, x2, x3;
ERROR HY000: Error in list of partitions to DROP
ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 INTO
(PARTITION x11 VALUES LESS THAN (22));
-ERROR HY000: More partitions to reorganise than there are partitions
+ERROR HY000: More partitions to reorganize than there are partitions
ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2 INTO
(PARTITION x3 VALUES LESS THAN (6));
ERROR HY000: Duplicate partition name x3
ALTER TABLE t1 REORGANIZE PARTITION x0, x2 INTO
(PARTITION x11 VALUES LESS THAN (2));
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE t1 REORGANIZE PARTITION x0, x1, x1 INTO
(PARTITION x11 VALUES LESS THAN (4));
ERROR HY000: Error in list of partitions to REORGANIZE
diff --git a/mysql-test/r/preload.result b/mysql-test/r/preload.result
index 24a6e594a14..7ed0c62f33a 100644
--- a/mysql-test/r/preload.result
+++ b/mysql-test/r/preload.result
@@ -144,7 +144,7 @@ Key_reads 0
load index into cache t3, t2 key (primary,b) ;
Table Op Msg_type Msg_text
test.t3 preload_keys Error Table 'test.t3' doesn't exist
-test.t3 preload_keys error Corrupt
+test.t3 preload_keys status Operation failed
test.t2 preload_keys status OK
show status like "key_read%";
Variable_name Value
@@ -159,7 +159,7 @@ Key_reads 0
load index into cache t3 key (b), t2 key (c) ;
Table Op Msg_type Msg_text
test.t3 preload_keys Error Table 'test.t3' doesn't exist
-test.t3 preload_keys error Corrupt
+test.t3 preload_keys status Operation failed
test.t2 preload_keys Error Key 'c' doesn't exist in table 't2'
test.t2 preload_keys status Operation failed
show status like "key_read%";
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 05b2d18889b..1f8a077af40 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -235,7 +235,7 @@ execute stmt1;
prepare stmt1 from "insert into t1 select i from t1";
execute stmt1;
execute stmt1;
-prepare stmt1 from "select * from t1 into outfile 'f1.txt'";
+prepare stmt1 from "select * from t1 into outfile '<MYSQLTEST_VARDIR>/tmp/f1.txt'";
execute stmt1;
deallocate prepare stmt1;
drop table t1;
@@ -803,6 +803,8 @@ select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
16382
set global max_prepared_stmt_count=-1;
+Warnings:
+Warning 1292 Truncated incorrect max_prepared_stmt_count value: '-1'
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
0
@@ -1394,13 +1396,13 @@ execute stmt;
Table Op Msg_type Msg_text
test.t1 repair status OK
test.t4 repair Error Table 'test.t4' doesn't exist
-test.t4 repair error Corrupt
+test.t4 repair status Operation failed
test.t3 repair status OK
execute stmt;
Table Op Msg_type Msg_text
test.t1 repair status OK
test.t4 repair Error Table 'test.t4' doesn't exist
-test.t4 repair error Corrupt
+test.t4 repair status Operation failed
test.t3 repair status OK
prepare stmt from "optimize table t1, t3, t4";
execute stmt;
@@ -1408,23 +1410,23 @@ Table Op Msg_type Msg_text
test.t1 optimize status OK
test.t3 optimize status OK
test.t4 optimize Error Table 'test.t4' doesn't exist
-test.t4 optimize error Corrupt
+test.t4 optimize status Operation failed
execute stmt;
Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date
test.t3 optimize status Table is already up to date
test.t4 optimize Error Table 'test.t4' doesn't exist
-test.t4 optimize error Corrupt
+test.t4 optimize status Operation failed
prepare stmt from "analyze table t4, t1";
execute stmt;
Table Op Msg_type Msg_text
test.t4 analyze Error Table 'test.t4' doesn't exist
-test.t4 analyze error Corrupt
+test.t4 analyze status Operation failed
test.t1 analyze status Table is already up to date
execute stmt;
Table Op Msg_type Msg_text
test.t4 analyze Error Table 'test.t4' doesn't exist
-test.t4 analyze error Corrupt
+test.t4 analyze status Operation failed
test.t1 analyze status Table is already up to date
deallocate prepare stmt;
drop table t1, t2, t3;
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index e2905ea0904..1b2a0cc50b2 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -400,16 +400,16 @@ prepare stmt3 from ' lock tables t1 read ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from ' unlock tables ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet
-prepare stmt1 from ' load data infile ''data.txt''
-into table t1 fields terminated by ''\t'' ';
+prepare stmt1 from ' load data infile ''<MYSQLTEST_VARDIR>/tmp/data.txt''
+ into table t1 fields terminated by ''\t'' ';
ERROR HY000: This command is not supported in the prepared statement protocol yet
-prepare stmt1 from ' select * into outfile ''data.txt'' from t1 ';
+prepare stmt1 from ' select * into outfile ''<MYSQLTEST_VARDIR>/tmp/data.txt'' from t1 ';
execute stmt1 ;
prepare stmt1 from ' optimize table t1 ' ;
prepare stmt1 from ' analyze table t1 ' ;
prepare stmt1 from ' checksum table t1 ' ;
prepare stmt1 from ' repair table t1 ' ;
-prepare stmt1 from ' restore table t1 from ''data.txt'' ' ;
+prepare stmt1 from ' restore table t1 from ''<MYSQLTEST_VARDIR>/tmp/data.txt'' ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' handler t1 open ';
ERROR HY000: This command is not supported in the prepared statement protocol yet
diff --git a/mysql-test/r/query_cache_debug.result b/mysql-test/r/query_cache_debug.result
index c90165368e3..b03a71d3fec 100644
--- a/mysql-test/r/query_cache_debug.result
+++ b/mysql-test/r/query_cache_debug.result
@@ -22,3 +22,52 @@ Qcache_queries_in_cache 0
set global query_cache_size= 0;
use test;
drop table t1;
+SET @old_concurrent_insert= @@GLOBAL.concurrent_insert;
+SET @old_query_cache_size= @@GLOBAL.query_cache_size;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (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;
+# Switch to connection con1
+SET SESSION debug='+d,wait_after_query_cache_invalidate';
+# Send concurrent insert, will wait in the query cache table invalidate
+INSERT INTO t1 VALUES (4);
+# Switch to connection default
+# Wait for concurrent insert to reach the debug point
+# Switch to connection con2
+# Send SELECT that shouldn't be cached
+SELECT * FROM t1;
+a
+1
+2
+3
+# Switch to connection default
+# 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;
+# Switch to connection con1
+# Gather insert result
+SHOW STATUS LIKE "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
+# Test that it's cacheable
+SELECT * FROM t1;
+a
+1
+2
+3
+4
+SHOW STATUS LIKE "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+# Disconnect
+# Restore defaults
+RESET QUERY CACHE;
+DROP TABLE t1,t2;
+SET GLOBAL concurrent_insert= DEFAULT;
+SET GLOBAL query_cache_size= DEFAULT;
+SET GLOBAL query_cache_type= DEFAULT;
diff --git a/mysql-test/r/query_cache_notembedded.result b/mysql-test/r/query_cache_notembedded.result
index 64bb40f1d17..d9bf7a6d814 100644
--- a/mysql-test/r/query_cache_notembedded.result
+++ b/mysql-test/r/query_cache_notembedded.result
@@ -375,6 +375,7 @@ id
show status like 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 1
+USE test;
DROP DATABASE bug30269;
DROP USER 'bug30269'@'localhost';
set GLOBAL query_cache_type=default;
diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result
index cf81566f4e5..7b28da5a577 100644
--- a/mysql-test/r/read_only.result
+++ b/mysql-test/r/read_only.result
@@ -1,12 +1,18 @@
+set @start_read_only= @@global.read_only;
DROP TABLE IF EXISTS t1,t2,t3;
grant CREATE, SELECT, DROP on *.* to test@localhost;
+connect (con1,localhost,test,,test);
+connection default;
set global read_only=0;
+connection con1;
create table t1 (a int);
insert into t1 values(1);
create table t2 select * from t1;
+connection default;
set global read_only=1;
create table t3 (a int);
drop table t3;
+connection con1;
select @@global.read_only;
@@global.read_only
1
@@ -39,13 +45,18 @@ delete t1 from t1,t3 where t1.a=t3.a;
drop table t1;
insert into t1 values(1);
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
+connection default;
set global read_only=0;
lock table t1 write;
+connection con1;
lock table t2 write;
+connection default;
set global read_only=1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables ;
+send set global read_only=1;
set global read_only=1;
+connection con1;
select @@global.read_only;
@@global.read_only
0
@@ -53,13 +64,20 @@ unlock tables ;
select @@global.read_only;
@@global.read_only
1
+connection default;
+reap;
+connection default;
set global read_only=0;
lock table t1 read;
+connection con1;
lock table t2 read;
+connection default;
set global read_only=1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
unlock tables ;
+send set global read_only=1;
set global read_only=1;
+connection con1;
select @@global.read_only;
@@global.read_only
0
@@ -67,24 +85,35 @@ unlock tables ;
select @@global.read_only;
@@global.read_only
1
+connection default;
+reap;
+connection default;
set global read_only=0;
BEGIN;
+connection con1;
BEGIN;
+connection default;
set global read_only=1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
ROLLBACK;
set global read_only=1;
+connection con1;
select @@global.read_only;
@@global.read_only
1
ROLLBACK;
+connection default;
set global read_only=0;
flush tables with read lock;
set global read_only=1;
unlock tables;
+connect (root2,localhost,root,,test);
+connection default;
set global read_only=0;
flush tables with read lock;
+connection root2;
set global read_only=1;
+connection default;
select @@global.read_only;
@@global.read_only
1
@@ -94,11 +123,12 @@ ERROR 42S02: Unknown table 'ttt'
drop temporary table if exists ttt;
Warnings:
Note 1051 Unknown table 'ttt'
+connection default;
set global read_only=0;
drop table t1,t2;
drop user test@localhost;
#
-# Bug #27440 read_only allows create and drop database
+# Bug#27440 read_only allows create and drop database
#
set global read_only= 1;
drop database if exists mysqltest_db1;
@@ -112,16 +142,20 @@ grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
create database mysqltest_db1;
grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
flush privileges;
+connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,MASTER_MYPORT,);
+connection con_bug27440;
create database mysqltest_db2;
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
show databases like '%mysqltest_db2%';
Database (%mysqltest_db2%)
drop database mysqltest_db1;
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
+disconnect con_bug27440;
+connection default;
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;
drop database mysqltest_db1;
-set global read_only=0;
+set global read_only= @start_read_only;
diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result
index 609733b2b02..5bb3dd76fed 100644
--- a/mysql-test/r/repair.result
+++ b/mysql-test/r/repair.result
@@ -27,7 +27,7 @@ drop table t1;
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair Error Table 'test.t1' doesn't exist
-test.t1 repair error Corrupt
+test.t1 repair status Operation failed
create table t1 engine=myisam SELECT 1,"table 1";
flush tables;
repair table t1;
@@ -126,7 +126,7 @@ id
# Run CHECK TABLE, it should indicate table need a REPAIR TABLE
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
-test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" to fix it!
+test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
# REPAIR old table USE_FRM should fail
REPAIR TABLE t1 USE_FRM;
Table Op Msg_type Msg_text
diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result
index 3feaa6255c1..2eaec67c547 100644
--- a/mysql-test/r/row.result
+++ b/mysql-test/r/row.result
@@ -443,3 +443,17 @@ SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a;
ROW(a, 1) IN (SELECT SUM(b), 3)
0
DROP TABLE t1;
+create table t1 (a varchar(200),
+b int unsigned not null primary key auto_increment)
+default character set 'utf8';
+create table t2 (c varchar(200),
+d int unsigned not null primary key auto_increment)
+default character set 'latin1';
+insert into t1 (a) values('abc');
+insert into t2 (c) values('abc');
+select * from t1,t2 where (a,b) = (c,d);
+a b c d
+abc 1 abc 1
+select host,user from mysql.user where (host,user) = ('localhost','test');
+host user
+drop table t1,t2;
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 0519489b715..09c7d1b329d 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2784,26 +2784,26 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select max(key1) from t1 where key1 <= 0.6158;
max(key1)
-0.61580002307892
+0.615800023078918
select max(key2) from t2 where key2 <= 1.6158;
max(key2)
-1.6158000230789
+1.61580002307892
select min(key1) from t1 where key1 >= 0.3762;
min(key1)
-0.37619999051094
+0.376199990510941
select min(key2) from t2 where key2 >= 1.3762;
min(key2)
-1.3761999607086
+1.37619996070862
select max(key1), min(key2) from t1, t2
where key1 <= 0.6158 and key2 >= 1.3762;
max(key1) min(key2)
-0.61580002307892 1.3761999607086
+0.615800023078918 1.37619996070862
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
max(key1)
-0.61580002307892
+0.615800023078918
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
min(key1)
-0.37619999051094
+0.376199990510941
DROP TABLE t1,t2;
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (10);
@@ -4373,6 +4373,19 @@ f3 f4 count
1 abc 1
1 def 2
drop table t1, t2, t3;
+CREATE TABLE t1 (a INT KEY, b INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2
+DROP TABLE t1;
End of 5.0 tests
create table t1(a INT, KEY (a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
@@ -4416,4 +4429,32 @@ date_nokey
Warnings:
Warning 1292 Incorrect date value: '10:41:7' for column 'date_nokey' at row 1
DROP TABLE A,C;
+CREATE TABLE t1 (a INT NOT NULL, b INT);
+INSERT INTO t1 VALUES (1, 1);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00
+Warnings:
+Note 1003 select '1' AS `a`,'1' AS `b` from `test`.`t1` where 1
+SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
+a b
+1 1
+DROP TABLE t1;
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
+Warnings:
+Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
+Warnings:
+Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 const row not found
+Warnings:
+Note 1003 select '0' AS `a`,'0' AS `b`,'0' AS `c` from `test`.`t1` where 1
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/r/shm.result b/mysql-test/r/shm.result
index 36ab17c1e4d..c504fe222ef 100644
--- a/mysql-test/r/shm.result
+++ b/mysql-test/r/shm.result
@@ -2152,4 +2152,11 @@ Warnings:
Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
mysqld is alive
+SET @max_allowed_packet= @@global.max_allowed_packet;
+SET @net_buffer_length= @@global.net_buffer_length;
+SET GLOBAL max_allowed_packet= 1024;
+SET GLOBAL net_buffer_length= 1024;
+ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes
+SET GLOBAL max_allowed_packet= @max_allowed_packet;
+SET GLOBAL net_buffer_length= @net_buffer_length;
End of 5.0 tests.
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 2051939e4b6..e6550bee954 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -545,9 +545,9 @@ mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
drop table mysqltest.t1;
drop database mysqltest;
set names binary;
-delete from mysql.user
+delete from mysql.user
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
-delete from mysql.db
+delete from mysql.db
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
flush privileges;
CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY;
@@ -664,7 +664,7 @@ show create table t1;
ERROR HY000: Incorrect information in file: './test/t1.frm'
drop table if exists t1;
-# Bug#12183: SHOW OPEN TABLES behavior doesn't match grammar.
+# Bug#12183 SHOW OPEN TABLES behavior doesn't match grammar.
DROP DATABASE IF EXISTS mysqltest1;
CREATE DATABASE mysqltest1;
@@ -784,7 +784,7 @@ show status like 'slow_queries';
Variable_name Value
Slow_queries 1
create table t1 (a int);
-create trigger tr1 before insert on t1 for each row
+create trigger tr1 before insert on t1 for each row
begin
end;
create view v1 as select a from t1;
@@ -1010,7 +1010,7 @@ def TRIGGERS DATABASE_COLLATION Database Collation 253 96 17 N 1 0 33
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
t1_bi INSERT t1 SET @a = 1 BEFORE NULL root@localhost binary binary latin1_swedish_ci
----------------------------------------------------------------
-SELECT
+SELECT
TRIGGER_CATALOG,
TRIGGER_SCHEMA,
TRIGGER_NAME,
@@ -1198,7 +1198,7 @@ CREATE DATABASE mysqltest1;
use mysqltest1;
CREATE TABLE t1(ËÏÌÏÎËÁ1 INT);
----> Dumping mysqltest1 to show_check.mysqltest1.sql
+---> Dumping mysqltest1 to outfile1
DROP DATABASE mysqltest1;
@@ -1295,7 +1295,7 @@ drop database mysqltest;
show full plugin;
show warnings;
Level Code Message
-Warning 1287 The syntax 'SHOW PLUGIN' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW PLUGINS' instead
+Warning 1287 The syntax 'SHOW PLUGIN' is deprecated and will be removed in MySQL 6.0. Please use 'SHOW PLUGINS' instead
show plugin;
show plugins;
create database `mysqlttest\1`;
diff --git a/mysql-test/r/skip_name_resolve.result b/mysql-test/r/skip_name_resolve.result
index 8ef52e75238..8aa9877a8e9 100644
--- a/mysql-test/r/skip_name_resolve.result
+++ b/mysql-test/r/skip_name_resolve.result
@@ -5,10 +5,7 @@ GRANT USAGE ON *.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255'
GRANT ALL PRIVILEGES ON `test`.* TO 'mysqltest_1'@'127.0.0.1/255.255.255.255'
REVOKE ALL ON test.* FROM mysqltest_1@'127.0.0.1/255.255.255.255';
DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
-select user();
-user()
+SELECT USER();
+USER()
#
-show processlist;
-Id User Host db Command Time State Info
-<id> root <host> test <command> <time> <state> <info>
-<id> root <host> test <command> <time> <state> <info>
+SHOW PROCESSLIST;
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 3def6536897..35d61ce757d 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -1643,7 +1643,7 @@ create table t1 (a int) type=MyISAM;
drop table t1;
end|
Warnings:
-Warning 1287 The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 5.2. Please use 'ENGINE=storage_engine' instead
+Warning 1287 The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 6.0. Please use 'ENGINE=storage_engine' instead
call p1();
call p1();
drop procedure p1;
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 66177395ac9..65c94577a57 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -342,12 +342,12 @@ GRANT SUPER ON *.* TO mysqltest_2@localhost;
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
---> connection: mysqltest_2_con
-use mysqltest;
+USE mysqltest;
CREATE PROCEDURE wl2897_p1() SELECT 1;
CREATE FUNCTION wl2897_f1() RETURNS INT RETURN 1;
---> connection: mysqltest_1_con
-use mysqltest;
+USE mysqltest;
CREATE DEFINER=root@localhost PROCEDURE wl2897_p2() SELECT 2;
ERROR 42000: Access denied; you need the SUPER privilege for this operation
CREATE DEFINER=root@localhost FUNCTION wl2897_f2() RETURNS INT RETURN 2;
@@ -363,7 +363,7 @@ Warnings:
Note 1449 The user specified as a definer ('a @ b @ c'@'localhost') does not exist
---> connection: con1root
-use mysqltest;
+USE mysqltest;
SHOW CREATE PROCEDURE wl2897_p1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
wl2897_p1 CREATE DEFINER=`mysqltest_2`@`localhost` PROCEDURE `wl2897_p1`()
@@ -393,7 +393,7 @@ CREATE USER mysqltest_2@localhost;
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
---> connection: mysqltest_1_con
-use mysqltest;
+USE mysqltest;
CREATE PROCEDURE bug13198_p1()
SELECT 1;
CREATE FUNCTION bug13198_f1() RETURNS INT
@@ -406,7 +406,7 @@ bug13198_f1()
1
---> connection: mysqltest_2_con
-use mysqltest;
+USE mysqltest;
CALL bug13198_p1();
1
1
@@ -418,7 +418,7 @@ bug13198_f1()
DROP USER mysqltest_1@localhost;
---> connection: mysqltest_2_con
-use mysqltest;
+USE mysqltest;
CALL bug13198_p1();
ERROR HY000: The user specified as a definer ('mysqltest_1'@'localhost') does not exist
SELECT bug13198_f1();
@@ -435,7 +435,7 @@ Host User Password
localhost user19857 *82DC221D557298F6CE9961037DB1C90604792F5C
---> connection: mysqltest_2_con
-use test;
+USE test;
CREATE PROCEDURE sp19857() DETERMINISTIC
BEGIN
DECLARE a INT;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 01ddde56450..9574841bc35 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -581,7 +581,7 @@ return 2.7182818284590452354|
set @e = e()|
select e(), @e|
e() @e
-2.718281828459 2.718281828459
+2.71828182845905 2.71828182845905
drop function if exists inc|
create function inc(i int) returns int
return i+1|
@@ -618,7 +618,7 @@ create function fun(d double, i int, u int unsigned) returns double
return mul(inc(i), fac(u)) / e()|
select fun(2.3, 3, 5)|
fun(2.3, 3, 5)
-176.58213176229
+176.582131762292
insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
select * from t2 where s = append("a", "b")|
@@ -4342,18 +4342,18 @@ drop procedure if exists bug13012|
create procedure bug13012()
BEGIN
REPAIR TABLE t1;
-BACKUP TABLE t1 to '../../tmp';
+BACKUP TABLE t1 to '<MYSQLTEST_VARDIR>/tmp/';
DROP TABLE t1;
-RESTORE TABLE t1 FROM '../../tmp';
+RESTORE TABLE t1 FROM '<MYSQLTEST_VARDIR>/tmp/';
END|
call bug13012()|
Table Op Msg_type Msg_text
test.t1 repair status OK
Table Op Msg_type Msg_text
-test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1 backup Warning The syntax 'BACKUP TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t1 backup status OK
Table Op Msg_type Msg_text
-test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 5.2. Please use MySQL Administrator (mysqldump, mysql) instead
+test.t1 restore Warning The syntax 'RESTORE TABLE' is deprecated and will be removed in MySQL 6.0. Please use MySQL Administrator (mysqldump, mysql) instead
test.t1 restore status OK
drop procedure bug13012|
create view v1 as select * from t1|
@@ -6018,9 +6018,9 @@ CREATE TABLE t3 (f1 INT, f2 FLOAT)|
INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
SUM(f2) bug25373(f1)
-6.3000000715256 1
+6.30000007152557 1
15 2
-21.300000071526 NULL
+21.3000000715256 NULL
DROP FUNCTION bug25373|
DROP TABLE t3|
DROP DATABASE IF EXISTS mysqltest1|
@@ -6994,6 +6994,21 @@ select name from mysql.proc where name = 'p' and sql_mode = @full_mode;
name
p
drop procedure p;
+CREATE DEFINER = 'root'@'localhost' PROCEDURE p1()
+NOT DETERMINISTIC
+CONTAINS SQL
+SQL SECURITY DEFINER
+COMMENT ''
+BEGIN
+SHOW TABLE STATUS like 't1';
+END;//
+CREATE TABLE t1 (f1 INT);
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+DROP PROCEDURE p1;
+DROP TABLE t1;
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------
diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result
index abd454ac907..3cc251bc0a6 100644
--- a/mysql-test/r/sp_trans.result
+++ b/mysql-test/r/sp_trans.result
@@ -535,7 +535,7 @@ use db_bug7787|
CREATE PROCEDURE p1()
SHOW INNODB STATUS; |
Warnings:
-Warning 1287 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed in MySQL 5.2. Please use 'SHOW ENGINE INNODB STATUS' instead
+Warning 1287 The syntax 'SHOW INNODB STATUS' is deprecated and will be removed in MySQL 6.0. Please use 'SHOW ENGINE INNODB STATUS' instead
GRANT EXECUTE ON PROCEDURE p1 TO user_bug7787@localhost|
DROP DATABASE db_bug7787|
drop user user_bug7787@localhost|
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 1255284f4fe..241f4198bf7 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -1305,7 +1305,7 @@ set @@sql_mode='traditional';
create table t1 (i int)
comment '123456789*123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*123456789*';
-ERROR HY000: Too long comment for table 't1'
+ERROR HY000: Comment for table 't1' is too long (max = 60)
create table t1 (
i int comment
'123456789*123456789*123456789*123456789*
@@ -1315,7 +1315,7 @@ i int comment
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*');
-ERROR HY000: Too long comment for field 'i'
+ERROR HY000: Comment for field 'i' is too long (max = 255)
set @@sql_mode= @org_mode;
create table t1
(i int comment
@@ -1327,7 +1327,7 @@ create table t1
123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*');
Warnings:
-Warning 1105 Unknown error
+Warning 1629 Comment for field 'i' is too long (max = 255)
select column_name, column_comment from information_schema.columns where
table_schema = 'test' and table_name = 't1';
column_name column_comment
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index aff26454b2d..7f6ebb14c3e 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -192,11 +192,11 @@ select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
(select a from t3 where a<t2.a*4 order by 1 desc limit 1) a
3 1
7 2
-select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
(select t3.a from t3 where a<8 order by 1 desc limit 1) a
7 2
-explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived3> system NULL NULL NULL NULL 1 100.00
@@ -2303,20 +2303,20 @@ drop table t1,t2;
CREATE TABLE t1 ( a int, b int );
CREATE TABLE t2 ( c int, d int );
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
-SELECT a AS abc, b FROM t1 outr WHERE b =
+SELECT a AS abc, b FROM t1 outr WHERE b =
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
abc b
1 2
2 3
3 4
-INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b =
+INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b =
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t2;
c d
1 2
2 3
3 4
-CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b =
+CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b =
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t3;
abc b
@@ -2517,8 +2517,8 @@ INSERT INTO t1 VALUES ('ASM','American Samoa','Oceania','Polynesia',199.00,0,680
INSERT INTO t1 VALUES ('ATF','French Southern territories','Antarctica','Antarctica',7780.00,0,0,NULL,0.00,NULL,'Terres australes françaises','Nonmetropolitan Territory of France','Jacques Chirac',NULL,'TF');
INSERT INTO t1 VALUES ('UMI','United States Minor Outlying Islands','Oceania','Micronesia/Caribbean',16.00,0,0,NULL,0.00,NULL,'United States Minor Outlying Islands','Dependent Territory of the US','George W. Bush',NULL,'UM');
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
-SELECT DISTINCT Continent AS c FROM t1 outr WHERE
-Code <> SOME ( SELECT Code FROM t1 WHERE Continent = outr.Continent AND
+SELECT DISTINCT Continent AS c FROM t1 outr WHERE
+Code <> SOME ( SELECT Code FROM t1 WHERE Continent = outr.Continent AND
Population < 200);
c
Oceania
@@ -2628,32 +2628,32 @@ select
count(distinct t2.userid) pass,
groupstuff.*,
count(t2.courseid) crse,
-t1.categoryid,
+t1.categoryid,
t2.courseid,
date_format(date, '%b%y') as colhead
-from t2
-join t1 on t2.courseid=t1.courseid
+from t2
+join t1 on t2.courseid=t1.courseid
join
(
-select
-t5.userid,
-parentid,
-parentgroup,
-childid,
-groupname,
-grouptypeid
-from t5
-join
+select
+t5.userid,
+parentid,
+parentgroup,
+childid,
+groupname,
+grouptypeid
+from t5
+join
(
-select t4.id as parentid,
-t4.name as parentgroup,
-t4.id as childid,
-t4.name as groupname,
-t4.grouptypeid
-from t4
-) as gin on t5.groupid=gin.childid
-) as groupstuff on t2.userid = groupstuff.userid
-group by
+select t4.id as parentid,
+t4.name as parentgroup,
+t4.id as childid,
+t4.name as groupname,
+t4.grouptypeid
+from t4
+) as gin on t5.groupid=gin.childid
+) as groupstuff on t2.userid = groupstuff.userid
+group by
groupstuff.groupname, colhead , t2.courseid;
pass userid parentid parentgroup childid groupname grouptypeid crse categoryid courseid colhead
1 5141 12 group2 12 group2 5 1 5 12 Aug04
@@ -2929,9 +2929,9 @@ INSERT INTO t1 VALUES("0037", "1", "2005-12-06 12:18:56");
INSERT INTO t1 VALUES("0037", "2", "2006-01-06 12:25:53");
INSERT INTO t1 VALUES("0048", "1", "2006-01-06 12:37:50");
INSERT INTO t1 VALUES("0059", "1", "2006-01-06 12:37:50");
-select * from t1 r1
-where (r1.retailerID,(r1.changed)) in
-(SELECT r2.retailerId,(max(changed)) from t1 r2
+select * from t1 r1
+where (r1.retailerID,(r1.changed)) in
+(SELECT r2.retailerId,(max(changed)) from t1 r2
group by r2.retailerId);
retailerID statusID changed
0026 2 2006-01-06 12:25:53
@@ -2943,41 +2943,41 @@ create table t1(a int, primary key (a));
insert into t1 values (10);
create table t2 (a int primary key, b varchar(32), c int, unique key b(c, b));
insert into t2(a, c, b) values (1,10,'359'), (2,10,'35988'), (3,10,'35989');
-explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
-ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
-ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
-SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
-ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
-ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
a a b
10 3 35989
-explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
-ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
-ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
-SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
-ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
-ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
a a b
10 1 359
drop table t1,t2;
-CREATE TABLE t1 (
-field1 int NOT NULL,
-field2 int NOT NULL,
-field3 int NOT NULL,
-PRIMARY KEY (field1,field2,field3)
+CREATE TABLE t1 (
+field1 int NOT NULL,
+field2 int NOT NULL,
+field3 int NOT NULL,
+PRIMARY KEY (field1,field2,field3)
);
-CREATE TABLE t2 (
-fieldA int NOT NULL,
-fieldB int NOT NULL,
-PRIMARY KEY (fieldA,fieldB)
+CREATE TABLE t2 (
+fieldA int NOT NULL,
+fieldB int NOT NULL,
+PRIMARY KEY (fieldA,fieldB)
);
INSERT INTO t1 VALUES
(1,1,1), (1,1,2), (1,2,1), (1,2,2), (1,2,3), (1,3,1);
@@ -2991,14 +2991,14 @@ field1 field2 COUNT(*)
SELECT field1, field2
FROM t1
GROUP BY field1, field2
-HAVING COUNT(*) >= ALL (SELECT fieldB
+HAVING COUNT(*) >= ALL (SELECT fieldB
FROM t2 WHERE fieldA = field1);
field1 field2
1 2
SELECT field1, field2
FROM t1
GROUP BY field1, field2
-HAVING COUNT(*) < ANY (SELECT fieldB
+HAVING COUNT(*) < ANY (SELECT fieldB
FROM t2 WHERE fieldA = field1);
field1 field2
1 1
@@ -3021,8 +3021,8 @@ a a IN (SELECT a FROM t1)
DROP TABLE t1,t2;
CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('1998-09-23'), ('2003-03-25');
-CREATE TABLE t2 AS SELECT
-(SELECT a FROM t1 WHERE a < '2000-01-01') AS sub_a
+CREATE TABLE t2 AS SELECT
+(SELECT a FROM t1 WHERE a < '2000-01-01') AS sub_a
FROM t1 WHERE a > '2000-01-01';
SHOW CREATE TABLE t2;
Table Create Table
@@ -3188,7 +3188,7 @@ INSERT INTO t2 VALUES ( 6 );
CREATE TABLE t3 ( c3 integer );
INSERT INTO t3 VALUES ( 7 );
INSERT INTO t3 VALUES ( 8 );
-SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2
+SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2
WHERE EXISTS (SELECT c3 FROM t3 WHERE c2 IS NULL );
c1 c2
2 NULL
@@ -3231,20 +3231,20 @@ E1
DROP TABLE t1,t2;
CREATE TABLE t1(select_id BIGINT, values_id BIGINT);
INSERT INTO t1 VALUES (1, 1);
-CREATE TABLE t2 (select_id BIGINT, values_id BIGINT,
+CREATE TABLE t2 (select_id BIGINT, values_id BIGINT,
PRIMARY KEY(select_id,values_id));
INSERT INTO t2 VALUES (0, 1), (0, 2), (0, 3), (1, 5);
-SELECT values_id FROM t1
+SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id IN (1, 0));
values_id
1
-SELECT values_id FROM t1
+SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id BETWEEN 0 AND 1);
values_id
1
-SELECT values_id FROM t1
+SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id = 0 OR select_id = 1);
values_id
@@ -3259,7 +3259,7 @@ drop table t1;
CREATE TABLE t1 (a int, b int);
CREATE TABLE t2 (c int, d int);
CREATE TABLE t3 (e int);
-INSERT INTO t1 VALUES
+INSERT INTO t1 VALUES
(1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40);
INSERT INTO t2 VALUES
(2,10), (2,20), (4,10), (5,10), (3,20), (2,40);
@@ -3322,7 +3322,7 @@ a
2
SELECT a FROM t1 GROUP BY a
HAVING a IN (SELECT c FROM t2
-WHERE MIN(b) < d AND
+WHERE MIN(b) < d AND
EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
a
2
@@ -3373,7 +3373,7 @@ a
4
SELECT t1.a FROM t1 GROUP BY t1.a
HAVING t1.a > ALL(SELECT t2.c FROM t2
-WHERE EXISTS(SELECT t3.e FROM t3
+WHERE EXISTS(SELECT t3.e FROM t3
WHERE SUM(t1.a+t2.c) < t3.e/4));
ERROR HY000: Invalid use of group function
SELECT t1.a from t1 GROUP BY t1.a HAVING AVG(SUM(t1.b)) > 20;
@@ -3486,7 +3486,7 @@ mid bigint(20) unsigned NOT NULL,
date date NOT NULL,
PRIMARY KEY (id)
);
-INSERT INTO t2 VALUES
+INSERT INTO t2 VALUES
(1, 1, '2006-03-30'), (2, 2, '2006-04-06'), (3, 3, '2006-04-13'),
(4, 2, '2006-04-20'), (5, 1, '2006-05-01');
SELECT *,
@@ -3524,7 +3524,7 @@ i2 int(11) NOT NULL default '0',
t datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (i1,i2,t)
);
-INSERT INTO t1 VALUES
+INSERT INTO t1 VALUES
(24,1,'2005-03-03 16:31:31'),(24,1,'2005-05-27 12:40:07'),
(24,1,'2005-05-27 12:40:08'),(24,1,'2005-05-27 12:40:10'),
(24,1,'2005-05-27 12:40:25'),(24,1,'2005-05-27 12:40:30'),
@@ -3540,7 +3540,7 @@ PRIMARY KEY (i1)
INSERT INTO t2 VALUES (24,1,'2006-06-20 12:29:40');
EXPLAIN
SELECT * FROM t1,t2
-WHERE t1.t = (SELECT t1.t FROM t1
+WHERE t1.t = (SELECT t1.t FROM t1
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
ORDER BY t1.t DESC LIMIT 1);
id select_type table type possible_keys key key_len ref rows Extra
@@ -3548,7 +3548,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index
2 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
SELECT * FROM t1,t2
-WHERE t1.t = (SELECT t1.t FROM t1
+WHERE t1.t = (SELECT t1.t FROM t1
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
ORDER BY t1.t DESC LIMIT 1);
i1 i2 t i1 i2 t
@@ -3557,22 +3557,22 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (i INT);
(SELECT i FROM t1) UNION (SELECT i FROM t1);
i
-SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
+SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
(
-(SELECT i FROM t1) UNION
+(SELECT i FROM t1) UNION
(SELECT i FROM t1)
);
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
(SELECT i FROM t1)
)' at line 3
-SELECT * FROM t1
+SELECT * FROM t1
WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (SELECT i FROM t1)))' at line 2
explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
from t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union (select t12.i from t1 t12))
from t1' at line 1
-explain select * from t1 where not exists
+explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union (select t12.i from t1 t12))' at line 2
DROP TABLE t1;
@@ -3591,9 +3591,9 @@ insert into t1 (a) select FLOOR(rand() * 100) from t1;
insert into t1 (a) select FLOOR(rand() * 100) from t1;
insert into t1 (a) select FLOOR(rand() * 100) from t1;
insert into t1 (a) select FLOOR(rand() * 100) from t1;
-SELECT a,
-(SELECT REPEAT(' ',250) FROM t1 i1
-WHERE i1.b=t1.a ORDER BY RAND() LIMIT 1) AS a
+SELECT a,
+(SELECT REPEAT(' ',250) FROM t1 i1
+WHERE i1.b=t1.a ORDER BY RAND() LIMIT 1) AS a
FROM t1 ORDER BY a LIMIT 5;
a a
0 NULL
@@ -3622,7 +3622,7 @@ COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b))
2 2
1 1
1 1
-SELECT COUNT(DISTINCT t1.b),
+SELECT COUNT(DISTINCT t1.b),
(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3)
FROM t1 GROUP BY t1.a;
COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3)
@@ -3633,7 +3633,7 @@ SELECT (
SELECT (
SELECT COUNT(DISTINCT t1.b)
)
-)
+)
FROM t1 GROUP BY t1.a;
(
SELECT (
@@ -3648,8 +3648,8 @@ SELECT (
SELECT (
SELECT COUNT(DISTINCT t1.b)
)
-)
-FROM t1 GROUP BY t1.a LIMIT 1)
+)
+FROM t1 GROUP BY t1.a LIMIT 1)
FROM t1 t2
GROUP BY t2.a;
(
@@ -3657,7 +3657,7 @@ SELECT (
SELECT (
SELECT COUNT(DISTINCT t1.b)
)
-)
+)
FROM t1 GROUP BY t1.a LIMIT 1)
2
2
@@ -3669,13 +3669,13 @@ PRIMARY KEY (x), FOREIGN KEY (y) REFERENCES t1 (b));
SET SESSION sort_buffer_size = 32 * 1024;
Warnings:
Warning 1292 Truncated incorrect sort_buffer_size value: '32768'
-SELECT SQL_NO_CACHE COUNT(*)
+SELECT SQL_NO_CACHE COUNT(*)
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
FROM t1) t;
COUNT(*)
3000
SET SESSION sort_buffer_size = 8 * 1024 * 1024;
-SELECT SQL_NO_CACHE COUNT(*)
+SELECT SQL_NO_CACHE COUNT(*)
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
FROM t1) t;
COUNT(*)
@@ -3736,7 +3736,7 @@ sq
2
4
DEALLOCATE PREPARE stmt1;
-SELECT f2, AVG(f21),
+SELECT f2, AVG(f21),
(SELECT t.f3 FROM t2 AS t WHERE t2.f2=t.f2 AND t.f3=MAX(t2.f3)) AS test
FROM t2 GROUP BY f2;
f2 AVG(f21) test
@@ -3744,12 +3744,12 @@ f2 AVG(f21) test
2 2.0000 2004-02-29 11:11:11
DROP TABLE t1,t2;
CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL);
-INSERT INTO t1 VALUES
-(1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),
-(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'), (3,3,'j'),
+INSERT INTO t1 VALUES
+(1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),
+(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'), (3,3,'j'),
(3,2,'k'), (3,1,'l'), (1,9,'m');
-SELECT a, MAX(b),
-(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) AS test
+SELECT a, MAX(b),
+(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) AS test
FROM t1 GROUP BY a;
a MAX(b) test
1 9 m
@@ -3900,7 +3900,7 @@ COUNT(*) a (SELECT MIN(m) FROM t2 WHERE m = count(*))
2 2 2
3 3 3
1 4 1
-SELECT COUNT(*), a
+SELECT COUNT(*), a
FROM t1 GROUP BY a
HAVING (SELECT MIN(m) FROM t2 WHERE m = count(*)) > 1;
COUNT(*) a
@@ -3931,7 +3931,7 @@ INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'),
(1,5,0,'e'), (2,1,0,'f'), (2,2,0,'g'), (2,3,0,'h'), (3,4,0,'i'), (3,3,0,'j'),
(3,2,0,'k'), (3,1,0,'l'), (1,9,0,'m'), (1,0,10,'n'), (2,0,5,'o'), (3,0,7,'p');
SELECT a, MAX(b),
-(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test
+(SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test
FROM t1 GROUP BY a;
a MAX(b) test
1 9 m
@@ -3953,7 +3953,7 @@ a AVG(b) test
3 2.5000 NULL
SELECT tt.a,
(SELECT (SELECT c FROM t1 as t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
-LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
FROM t1 as tt;
a test
1 n
@@ -3975,7 +3975,7 @@ a test
SELECT tt.a,
(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
LIMIT 1)
-FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
FROM t1 as tt GROUP BY tt.a;
a test
1 n
@@ -3984,7 +3984,7 @@ a test
SELECT tt.a, MAX(
(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
LIMIT 1)
-FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test
+FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test
FROM t1 as tt GROUP BY tt.a;
a test
1 n
@@ -4027,11 +4027,11 @@ COUNT(1)
1
SELECT SUM( (SELECT AVG( (SELECT t1.a FROM t2) ) FROM DUAL) ) FROM t1;
ERROR HY000: Invalid use of group function
-SELECT
+SELECT
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
FROM t1;
ERROR HY000: Invalid use of group function
-SELECT t1.a as XXA,
+SELECT t1.a as XXA,
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
FROM t1;
ERROR HY000: Invalid use of group function
@@ -4048,25 +4048,25 @@ INSERT INTO t1 VALUES
(3,'FL'), (2,'GA'), (4,'FL'), (1,'GA'), (5,'NY'), (7,'FL'), (6,'NY');
CREATE TABLE t2 (id int NOT NULL, INDEX idx(id));
INSERT INTO t2 VALUES (7), (5), (1), (3);
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
id st
3 FL
1 GA
7 FL
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
GROUP BY id;
id st
1 GA
3 FL
7 FL
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
id st
2 GA
4 FL
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
GROUP BY id;
id st
@@ -4237,7 +4237,7 @@ a b
DROP TABLE t1,t2;
CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 VALUES (1,1), (1,2), (2,3), (2,4);
-EXPLAIN
+EXPLAIN
SELECT a AS out_a, MIN(b) FROM t1
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
GROUP BY a;
@@ -4246,7 +4246,7 @@ SELECT a AS out_a, MIN(b) FROM t1
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
GROUP BY a;
ERROR 42S22: Unknown column 'out_a' in 'where clause'
-EXPLAIN
+EXPLAIN
SELECT a AS out_a, MIN(b) FROM t1 t1_outer
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
GROUP BY a;
@@ -4277,16 +4277,16 @@ Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select 2 AS `2` from `test`.`t1` where exists(select 1 AS `1` from `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`))
EXPLAIN EXTENDED
-SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
+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));
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a))' at line 2
DROP TABLE t1,t2;
create table t1(f11 int, f12 int);
create table t2(f21 int unsigned not null, f22 int, f23 varchar(10));
insert into t1 values(1,1),(2,2), (3, 3);
set session sort_buffer_size= 33*1024;
-select count(*) from t1 where f12 =
+select count(*) from t1 where f12 =
(select f22 from t2 where f22 = f12 order by f21 desc, f22, f23 limit 1);
count(*)
3
@@ -4327,12 +4327,12 @@ IF(
FROM t2 VPC, t4 a2, t2 a3
WHERE
VPC.f4 = a2.f10 AND a3.f2 = a4
-LIMIT 1) IS NULL,
-0,
+LIMIT 1) IS NULL,
+0,
t3.f5
)
) AS a6
-FROM
+FROM
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
GROUP BY a4;
a4 f3 a6
@@ -4341,7 +4341,7 @@ a4 f3 a6
DROP TABLE t1, t2, t3, t4;
create table t1 (a float(5,4) zerofill);
create table t2 (a float(5,4),b float(2,0));
-select t1.a from t1 where
+select t1.a from t1 where
t1.a= (select b from t2 limit 1) and not
t1.a= (select a from t2 limit 1) ;
a
@@ -4362,7 +4362,7 @@ Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` where <in_optimizer>(1,<exists>(select 1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having (<cache>(1) = <ref_null_helper>(1))))
DROP TABLE t1;
End of 5.0 tests.
-CREATE TABLE t1 (a int, b int);
+CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
a
@@ -4385,22 +4385,22 @@ WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
ERROR HY000: Invalid use of group function
SET @@sql_mode=default;
DROP TABLE t1;
-CREATE TABLE t1 (s1 char(1));
+CREATE TABLE t1 (s1 CHAR(1));
INSERT INTO t1 VALUES ('a');
SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1);
s1
a
DROP TABLE t1;
-CREATE TABLE t1(c int, KEY(c));
-CREATE TABLE t2(a int, b int);
+CREATE TABLE t1(c INT, KEY(c));
+CREATE TABLE t2(a INT, b INT);
INSERT INTO t2 VALUES (1, 10), (2, NULL);
INSERT INTO t1 VALUES (1), (3);
SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10);
a b
DROP TABLE t1,t2;
-CREATE TABLE t1(pk int PRIMARY KEY, a int, INDEX idx(a));
+CREATE TABLE t1(pk INT PRIMARY KEY, a INT, INDEX idx(a));
INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20);
-CREATE TABLE t2(pk int PRIMARY KEY, a int, b int, INDEX idxa(a));
+CREATE TABLE t2(pk INT PRIMARY KEY, a INT, b INT, INDEX idxa(a));
INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100);
SELECT * FROM t1
WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b);
@@ -4409,36 +4409,36 @@ pk a
3 30
2 20
DROP TABLE t1,t2;
-CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY b (b));
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), KEY b (b));
INSERT INTO t1 VALUES (1,NULL), (9,NULL);
CREATE TABLE t2 (
-a int,
-b int,
-c int,
-d int,
+a INT,
+b INT,
+c INT,
+d INT,
PRIMARY KEY (a),
UNIQUE KEY b (b,c,d),
KEY b_2 (b),
KEY c (c),
KEY d (d)
);
-INSERT INTO t2 VALUES
+INSERT INTO t2 VALUES
(43, 2, 11 ,30),
(44, 2, 12 ,30),
(45, 1, 1 ,10000),
(46, 1, 2 ,10000),
(556,1, 32 ,10000);
CREATE TABLE t3 (
-a int,
-b int,
-c int,
+a INT,
+b INT,
+c INT,
PRIMARY KEY (a),
UNIQUE KEY b (b,c),
KEY c (c),
KEY b_2 (b)
);
INSERT INTO t3 VALUES (1,1,1), (2,32,1);
-explain
+explain
SELECT t1.a, (SELECT 1 FROM t2 WHERE t2.b=t3.c AND t2.c=t1.a ORDER BY t2.d LIMIT 1) AS incorrect FROM t1, t3 WHERE t3.b=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 index b,b_2 b 10 NULL 2 Using index
@@ -4479,7 +4479,7 @@ DELETE FROM v3;
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
#
-# BUG#37822: Correlated subquery with IN and IS UNKNOWN provides wrong result
+# Bug#37822 Correlated subquery with IN and IS UNKNOWN provides wrong result
#
create table t1(id integer primary key, g integer, v integer, s char(1));
create table t2(id integer primary key, g integer, v integer, s char(1));
diff --git a/mysql-test/r/synchronization.result b/mysql-test/r/synchronization.result
index 5d8585f1f88..3f6d16178dd 100644
--- a/mysql-test/r/synchronization.result
+++ b/mysql-test/r/synchronization.result
@@ -1,6 +1,6 @@
-drop table if exists t1,t2;
-CREATE TABLE t1 (x1 int);
-ALTER TABLE t1 CHANGE x1 x2 int;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (x1 INT);
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -8,7 +8,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -16,7 +16,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -24,7 +24,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -32,7 +32,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -40,7 +40,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -48,7 +48,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -56,7 +56,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -64,7 +64,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -72,7 +72,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -80,7 +80,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -88,7 +88,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -96,7 +96,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -104,7 +104,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -112,7 +112,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -120,7 +120,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -128,7 +128,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -136,7 +136,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -144,7 +144,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x1 x2 int;
+ALTER TABLE t1 CHANGE x1 x2 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -152,7 +152,7 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
-ALTER TABLE t1 CHANGE x2 x1 int;
+ALTER TABLE t1 CHANGE x2 x1 INT;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
diff --git a/mysql-test/r/system_mysql_db.result b/mysql-test/r/system_mysql_db.result
index 0106c9459e7..e252331cd1a 100644
--- a/mysql-test/r/system_mysql_db.result
+++ b/mysql-test/r/system_mysql_db.result
@@ -227,7 +227,7 @@ event CREATE TABLE `event` (
`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') NOT NULL DEFAULT '',
`comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
- `originator` int(10) NOT NULL,
+ `originator` int(10) unsigned NOT NULL,
`time_zone` char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM',
`character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
@@ -241,7 +241,7 @@ general_log CREATE TABLE `general_log` (
`event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'
@@ -257,7 +257,7 @@ slow_log CREATE TABLE `slow_log` (
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
show tables;
diff --git a/mysql-test/r/trigger-compat.result b/mysql-test/r/trigger-compat.result
index 1609707fb09..2bcd919e0db 100644
--- a/mysql-test/r/trigger-compat.result
+++ b/mysql-test/r/trigger-compat.result
@@ -12,9 +12,7 @@ GRANT CREATE, TRIGGER ON mysqltest_db1.* TO mysqltest_dfn@localhost;
---> connection: wl2818_definer_con
CREATE TABLE t1(num_value INT);
CREATE TABLE t2(user_str TEXT);
-CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1
-FOR EACH ROW
-INSERT INTO t2 VALUES(CURRENT_USER());
+CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER());
---> patching t1.TRG...
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index 2290919f191..23f15f618f2 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -1960,6 +1960,26 @@ select * from t2;
s1
drop table t1;
drop temporary table t2;
+#------------------------------------------------------------------------
+# Bug#39953 Triggers are not working properly with multi table updates
+#------------------------------------------------------------------------
+DROP TABLE IF EXISTS t1;
+DROP TRIGGER IF EXISTS t_insert;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (a int, date_insert timestamp, PRIMARY KEY (a));
+INSERT INTO t1 (a) VALUES (2),(5);
+CREATE TABLE t2 (a int, b int, PRIMARY KEY (a));
+CREATE TRIGGER t_insert AFTER INSERT ON t2 FOR EACH ROW BEGIN UPDATE t1,t2 SET
+date_insert=NOW() WHERE t1.a=t2.b AND t2.a=NEW.a; END |
+INSERT INTO t2 (a,b) VALUES (1,2);
+DROP TRIGGER t_insert;
+CREATE TRIGGER t_insert AFTER INSERT ON t2 FOR EACH ROW BEGIN UPDATE t1,t2 SET
+date_insert=NOW(),b=b+1 WHERE t1.a=t2.b AND t2.a=NEW.a; END |
+INSERT INTO t2 (a,b) VALUES (3,5);
+ERROR HY000: Can't update table 't2' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
+DROP TABLE t1;
+DROP TRIGGER t_insert;
+DROP TABLE t2;
End of 5.0 tests
drop table if exists table_25411_a;
drop table if exists table_25411_b;
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index a80adab1f87..d11ab236c34 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -891,11 +891,11 @@ CREATE TABLE b15776 (a year(-2));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
CREATE TABLE b15776 (a timestamp(4294967294));
Warnings:
-Warning 1287 The syntax 'TIMESTAMP(4294967294)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(4294967294)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
DROP TABLE b15776;
CREATE TABLE b15776 (a timestamp(4294967295));
Warnings:
-Warning 1287 The syntax 'TIMESTAMP(4294967295)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(4294967295)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
DROP TABLE b15776;
CREATE TABLE b15776 (a timestamp(4294967296));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 6a692ed58e4..b6281443751 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -619,3 +619,22 @@ ERROR 42000: Invalid default value for 'da'
create table t1 (t time default '916:00:00 a');
ERROR 42000: Invalid default value for 't'
set @@sql_mode= @org_mode;
+SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7));
+CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7))
+20060810101112.0123450
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2006-08-10 10:11:12.0123450'
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7));
+CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7))
+20060810101112.0123450
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '00000002006-000008-0000010 000010:0000011:00000012.0123450'
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7));
+CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7))
+20060810101112.0123450
+SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7));
+CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7))
+20080729104251.1234560
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2008-07-29T10:42:51.1234567'
+End of 5.1 tests
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index d4cfd1c04ed..a3a13bb0435 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -385,12 +385,12 @@ Warning 1264 Out of range value for column 'f1' at row 1
Warning 1264 Out of range value for column 'f1' at row 2
select f1 + 0e0 from t1;
f1 + 0e0
-1.0000000150475e+29
--1.0000000150475e+29
-1.0000000150475e+30
--1.0000000150475e+30
-1.0000000150475e+30
--1.0000000150475e+30
+1.00000001504747e+29
+-1.00000001504747e+29
+1.00000001504747e+30
+-1.00000001504747e+30
+1.00000001504747e+30
+-1.00000001504747e+30
drop table t1;
create table t1(d double, u bigint unsigned);
insert into t1(d) values (9.22337203685479e18),
@@ -401,4 +401,10 @@ u
9223372036854790144
18400000000000000000
drop table t1;
+CREATE TABLE t1 (f1 DOUBLE);
+INSERT INTO t1 VALUES(-1.79769313486231e+308);
+SELECT f1 FROM t1;
+f1
+-1.79769313486231e+308
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result
index 91938771ee3..24cb725de9f 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -101,13 +101,13 @@ create table t1 (t2 timestamp(2), t4 timestamp(4), t6 timestamp(6),
t8 timestamp(8), t10 timestamp(10), t12 timestamp(12),
t14 timestamp(14));
Warnings:
-Warning 1287 The syntax 'TIMESTAMP(2)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(4)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(6)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(8)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(10)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(12)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
-Warning 1287 The syntax 'TIMESTAMP(14)' is deprecated and will be removed in MySQL 5.2. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(2)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(4)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(6)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(8)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(10)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(12)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
+Warning 1287 The syntax 'TIMESTAMP(14)' is deprecated and will be removed in MySQL 6.0. Please use 'TIMESTAMP' instead
insert t1 values (0,0,0,0,0,0,0),
("1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
"1997-12-31 23:47:59", "1997-12-31 23:47:59", "1997-12-31 23:47:59",
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 2a10f34d081..23a7724984c 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -160,12 +160,12 @@ SELECT a FROM t1
UNION
SELECT a FROM t1
) alias;
-SELECT a INTO OUTFILE 'union.out.file' FROM (
+SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/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 INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM (
SELECT a FROM t1
UNION
SELECT a FROM t1 WHERE 0
@@ -178,21 +178,21 @@ SELECT a INTO @v FROM t1
SELECT a FROM (
SELECT a FROM t1
UNION
-SELECT a INTO OUTFILE 'union.out.file3' FROM t1
+SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
) alias;
SELECT a FROM (
SELECT a FROM t1
UNION
-SELECT a INTO DUMPFILE 'union.out.file4' FROM t1
+SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1
) 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;
+SELECT a FROM t1 UNION SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
+SELECT a FROM t1 UNION SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1;
SELECT a INTO @v FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
-SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
+SELECT a INTO OUTFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
-SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
+SELECT a INTO DUMPFILE '<MYSQLTEST_VARDIR>/tmp/union.out.file' FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
DROP TABLE t1;
CREATE TABLE t1 (
@@ -1562,4 +1562,16 @@ DESC t6;
Field Type Null Key Default Extra
NULL int(11) YES NULL
DROP TABLE t1, t2, t3, t4, t5, t6;
+CREATE TABLE t1 (f FLOAT(9,6));
+CREATE TABLE t2 AS SELECT f FROM t1 UNION SELECT f FROM t1;
+SHOW FIELDS FROM t2;
+Field Type Null Key Default Extra
+f float(9,6) YES NULL
+DROP TABLE t1, t2;
+CREATE TABLE t1(d DOUBLE(9,6));
+CREATE TABLE t2 AS SELECT d FROM t1 UNION SELECT d FROM t1;
+SHOW FIELDS FROM t2;
+Field Type Null Key Default Extra
+d double(9,6) YES NULL
+DROP TABLE t1, t2;
End of 5.0 tests
diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result
index adf81efe8e3..da6201692a9 100644
--- a/mysql-test/r/upgrade.result
+++ b/mysql-test/r/upgrade.result
@@ -57,6 +57,18 @@ s1
1
drop table `txu@0023p@0023p1`;
drop table `txu#p#p1`;
+#
+# Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
+#
+# copy table created using mysql4.0 into the data dir
+# check the table created using mysql 4.0
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+# query the table created using mysql 4.0
+SELECT * FROM t1;
+c1 c2 c3
+DROP TABLE t1;
truncate t1;
drop table t1;
drop database if exists `tabc`;
@@ -84,3 +96,23 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin2
drop database `a-b-c`;
drop database `tabc`;
+use `#mysql50#a-b-c`;
+create table t1(f1 char(10));
+show databases like '%a-b-c%';
+Database (%a-b-c%)
+#mysql50#a-b-c
+ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
+show databases like '%a-b-c%';
+Database (%a-b-c%)
+a-b-c
+show create view `a-b-c`.v1;
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `a`.`f1` AS `f1` from (`a-b-c`.`t1` `a` join `information_schema`.`tables` `b`) where (convert(`a`.`f1` using utf8) = `b`.`TABLE_NAME`) utf8 utf8_general_ci
+Warnings:
+Note 1600 Creation context of view `a-b-c`.`v1' is invalid
+select * from `a-b-c`.v1;
+f1
+Warnings:
+Note 1600 Creation context of view `a-b-c`.`v1' is invalid
+drop database `a-b-c`;
+use test;
diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result
index 271d7a0fe8d..b623ea1d86e 100644
--- a/mysql-test/r/varbinary.result
+++ b/mysql-test/r/varbinary.result
@@ -38,7 +38,7 @@ length(a) length(b)
255 3
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
-test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" to fix it!
+test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
diff --git a/mysql-test/r/variables-big.result b/mysql-test/r/variables-big.result
index ae1e20109b9..960fc6d22f4 100644
--- a/mysql-test/r/variables-big.result
+++ b/mysql-test/r/variables-big.result
@@ -1,20 +1,20 @@
-set session transaction_prealloc_size=1024*1024*1024*1;
-show processlist;
+SET SESSION transaction_prealloc_size=1024*1024*1024*1;
+SHOW PROCESSLIST;
Id User Host db Command Time State Info
-1 root localhost test Query 0 NULL show processlist
-set session transaction_prealloc_size=1024*1024*1024*2;
-show processlist;
+<Id> root localhost test Query <Time> NULL SHOW PROCESSLIST
+SET SESSION transaction_prealloc_size=1024*1024*1024*2;
+SHOW PROCESSLIST;
Id User Host db Command Time State Info
-1 root localhost test Query 0 NULL show processlist
-set session transaction_prealloc_size=1024*1024*1024*3;
-show processlist;
+<Id> root localhost test Query <Time> NULL SHOW PROCESSLIST
+SET SESSION transaction_prealloc_size=1024*1024*1024*3;
+SHOW PROCESSLIST;
Id User Host db Command Time State Info
-1 root localhost test Query 0 NULL show processlist
-set session transaction_prealloc_size=1024*1024*1024*4;
-show processlist;
+<Id> root localhost test Query <Time> NULL SHOW PROCESSLIST
+SET SESSION transaction_prealloc_size=1024*1024*1024*4;
+SHOW PROCESSLIST;
Id User Host db Command Time State Info
-1 root localhost test Query 0 NULL show processlist
-set session transaction_prealloc_size=1024*1024*1024*5;
-show processlist;
+<Id> root localhost test Query <Time> NULL SHOW PROCESSLIST
+SET SESSION transaction_prealloc_size=1024*1024*1024*5;
+SHOW PROCESSLIST;
Id User Host db Command Time State Info
-1 root localhost test Query 0 NULL show processlist
+<Id> root localhost test Query <Time> NULL SHOW PROCESSLIST
diff --git a/mysql-test/r/variables-notembedded.result b/mysql-test/r/variables-notembedded.result
index c9125bcee90..8c6d54757ed 100644
--- a/mysql-test/r/variables-notembedded.result
+++ b/mysql-test/r/variables-notembedded.result
@@ -11,7 +11,7 @@ Variable_name Value
slave_load_tmpdir SLAVE_LOAD_TMPDIR
show variables like 'slave_skip_errors';
Variable_name Value
-slave_skip_errors 3,100,137,643,1752
+slave_skip_errors 0,3,100,137,643,1752
---- Clean Up ----
set global slave_net_timeout=default;
set global sql_slave_skip_counter= 0;
@@ -98,12 +98,12 @@ ERROR HY000: Variable 'slave_load_tmpdir' is a read only variable
#
SHOW VARIABLES like 'slave_skip_errors';
Variable_name Value
-slave_skip_errors 3,100,137,643,1752
+slave_skip_errors 0,3,100,137,643,1752
SELECT @@session.slave_skip_errors;
ERROR HY000: Variable 'slave_skip_errors' is a GLOBAL variable
SELECT @@global.slave_skip_errors;
@@global.slave_skip_errors
-3,100,137,643,1752
+0,3,100,137,643,1752
SET @@session.slave_skip_errors= 7;
ERROR HY000: Variable 'slave_skip_errors' is a read only variable
SET @@global.slave_skip_errors= 7;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index d3b3a6f2663..f27d0b9fdd5 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -27,6 +27,7 @@ set @my_slow_launch_time =@@global.slow_launch_time;
set @my_storage_engine =@@global.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;
set @`test`=1;
select @test, @`test`, @TEST, @`TEST`, @"teSt";
@test @`test` @TEST @`TEST` @"teSt"
@@ -299,59 +300,107 @@ set @@rand_seed1=10000000,@@rand_seed2=1000000;
select ROUND(RAND(),5);
ROUND(RAND(),5)
0.02887
-show variables like '%alloc%';
+
+==+ Testing %alloc% system variables +==
+==+ NOTE: These values *must* be a multiple of 1024 +==
+==+ Other values will be rounded down to nearest multiple +==
+
+==+ Show initial values +==
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
Variable_name Value
query_alloc_block_size 8192
query_prealloc_size 8192
range_alloc_block_size 4096
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
+==+ information_schema data +==
+SELECT * FROM information_schema.session_variables
+WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
VARIABLE_NAME VARIABLE_VALUE
QUERY_ALLOC_BLOCK_SIZE 8192
QUERY_PREALLOC_SIZE 8192
RANGE_ALLOC_BLOCK_SIZE 4096
TRANSACTION_ALLOC_BLOCK_SIZE 8192
TRANSACTION_PREALLOC_SIZE 4096
-set @@range_alloc_block_size=1024*16;
+Testing values that are multiples of 1024
+set @@range_alloc_block_size=1024*15+1024;
+set @@query_alloc_block_size=1024*15+1024*2;
+set @@query_prealloc_size=1024*18-1024;
+set @@transaction_alloc_block_size=1024*21-1024*1;
+set @@transaction_prealloc_size=1024*21-2048;
+==+ Check manipulated values ==+
+select @@query_alloc_block_size;
+@@query_alloc_block_size
+17408
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
+Variable_name Value
+query_alloc_block_size 17408
+query_prealloc_size 17408
+range_alloc_block_size 16384
+transaction_alloc_block_size 20480
+transaction_prealloc_size 19456
+==+ information_schema data +==
+SELECT * FROM information_schema.session_variables
+WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
+VARIABLE_NAME VARIABLE_VALUE
+QUERY_ALLOC_BLOCK_SIZE 17408
+QUERY_PREALLOC_SIZE 17408
+RANGE_ALLOC_BLOCK_SIZE 16384
+TRANSACTION_ALLOC_BLOCK_SIZE 20480
+TRANSACTION_PREALLOC_SIZE 19456
+==+ Manipulate variable values +==
+Testing values that are not 1024 multiples
+set @@range_alloc_block_size=1024*16+1023;
set @@query_alloc_block_size=1024*17+2;
-set @@query_prealloc_size=1024*18;
+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;
@@query_alloc_block_size
17408
-show variables like '%alloc%';
+==+ Check manipulated values ==+
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
Variable_name Value
query_alloc_block_size 17408
-query_prealloc_size 18432
+query_prealloc_size 17408
range_alloc_block_size 16384
transaction_alloc_block_size 19456
transaction_prealloc_size 20480
-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
+==+ information_schema data +==
+SELECT * FROM information_schema.session_variables
+WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
VARIABLE_NAME VARIABLE_VALUE
QUERY_ALLOC_BLOCK_SIZE 17408
-QUERY_PREALLOC_SIZE 18432
+QUERY_PREALLOC_SIZE 17408
RANGE_ALLOC_BLOCK_SIZE 16384
TRANSACTION_ALLOC_BLOCK_SIZE 19456
TRANSACTION_PREALLOC_SIZE 20480
+==+ Set values back to the default values +==
set @@range_alloc_block_size=default;
set @@query_alloc_block_size=default, @@query_prealloc_size=default;
set transaction_alloc_block_size=default, @@transaction_prealloc_size=default;
-show variables like '%alloc%';
+==+ Check the values now that they are reset +==
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
Variable_name Value
query_alloc_block_size 8192
query_prealloc_size 8192
range_alloc_block_size 4096
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
-VARIABLE_NAME VARIABLE_VALUE
-QUERY_ALLOC_BLOCK_SIZE 8192
-QUERY_PREALLOC_SIZE 8192
-RANGE_ALLOC_BLOCK_SIZE 4096
-TRANSACTION_ALLOC_BLOCK_SIZE 8192
-TRANSACTION_PREALLOC_SIZE 4096
SELECT @@version LIKE 'non-existent';
@@version LIKE 'non-existent'
0
@@ -705,7 +754,7 @@ VARIABLE_NAME VARIABLE_VALUE
MYISAM_DATA_POINTER_SIZE 7
SET GLOBAL table_open_cache=-1;
Warnings:
-Warning 1292 Truncated incorrect table_open_cache value: '0'
+Warning 1292 Truncated incorrect table_open_cache value: '-1'
SHOW VARIABLES LIKE 'table_open_cache';
Variable_name Value
table_open_cache 1
@@ -970,6 +1019,11 @@ show variables like 'hostname';
Variable_name Value
hostname #
End of 5.0 tests
+set join_buffer_size=1;
+Warnings:
+Warning 1292 Truncated incorrect join_buffer_size value: '1'
+set @save_join_buffer_size=@@join_buffer_size;
+set join_buffer_size=@save_join_buffer_size;
set global binlog_cache_size =@my_binlog_cache_size;
set global connect_timeout =@my_connect_timeout;
set global delayed_insert_timeout =@my_delayed_insert_timeout;
@@ -1000,6 +1054,7 @@ set global slow_launch_time =@my_slow_launch_time;
set global 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;
show global variables where Variable_name='table_definition_cache' or
Variable_name='table_lock_wait_timeout';
Variable_name Value
@@ -1341,3 +1396,75 @@ SET @@session.thread_stack= 7;
ERROR HY000: Variable 'thread_stack' is a read only variable
SET @@global.thread_stack= 7;
ERROR HY000: Variable 'thread_stack' is a read only variable
+SELECT @@global.expire_logs_days INTO @old_eld;
+SET GLOBAL expire_logs_days = -1;
+Warnings:
+Warning 1292 Truncated incorrect expire_logs_days value: '-1'
+needs to've been adjusted (0)
+SELECT @@global.expire_logs_days;
+@@global.expire_logs_days
+0
+SET GLOBAL expire_logs_days = 11;
+SET @old_mode=@@sql_mode;
+SET SESSION sql_mode = 'TRADITIONAL';
+SET GLOBAL expire_logs_days = 100;
+ERROR 42000: Variable 'expire_logs_days' can't be set to the value of '100'
+needs to be unchanged (11)
+SELECT @@global.expire_logs_days;
+@@global.expire_logs_days
+11
+SET SESSION sql_mode = @old_mode;
+SET GLOBAL expire_logs_days = 100;
+Warnings:
+Warning 1292 Truncated incorrect expire_logs_days value: '100'
+needs to've been adjusted (99)
+SELECT @@global.expire_logs_days;
+@@global.expire_logs_days
+99
+SET GLOBAL expire_logs_days = 11;
+SET GLOBAL expire_logs_days = 99;
+needs to pass with no warnings (99)
+SELECT @@global.expire_logs_days;
+@@global.expire_logs_days
+99
+SET GLOBAL expire_logs_days = @old_eld;
+SET GLOBAL auto_increment_offset=-1;
+Warnings:
+Warning 1292 Truncated incorrect auto_increment_offset value: '-1'
+SET GLOBAL auto_increment_offset=0;
+Warnings:
+Warning 1292 Truncated incorrect auto_increment_offset value: '0'
+select @@storage_engine;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def @@storage_engine 253 6 6 N 1 31 8
+@@storage_engine
+MyISAM
+SET @old_server_id = @@GLOBAL.server_id;
+SET GLOBAL server_id = (1 << 32) - 1;
+SELECT @@GLOBAL.server_id;
+@@GLOBAL.server_id
+4294967295
+SET GLOBAL server_id = (1 << 32);
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '4294967296'
+SELECT @@GLOBAL.server_id;
+@@GLOBAL.server_id
+4294967295
+SET GLOBAL server_id = (1 << 60);
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '1152921504606846976'
+SELECT @@GLOBAL.server_id;
+@@GLOBAL.server_id
+4294967295
+SET GLOBAL server_id = 0;
+SELECT @@GLOBAL.server_id;
+@@GLOBAL.server_id
+0
+SET GLOBAL server_id = -1;
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '-1'
+SELECT @@GLOBAL.server_id;
+@@GLOBAL.server_id
+0
+SET GLOBAL server_id = @old_server_id;
+End of 5.1 tests
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 38d05ae84fe..0905fc0109b 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -1673,9 +1673,9 @@ INSERT INTO t2 VALUES (4,3,'n');
INSERT INTO t2 VALUES (6,1,'n');
INSERT INTO t2 VALUES (8,1,'y');
CREATE VIEW v1 AS SELECT * FROM t1;
-SELECT a.col1,a.col2,b.col2,b.col3
+SELECT a.col1,a.col2,b.col2,b.col3
FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1
-WHERE b.col2 IS NULL OR
+WHERE b.col2 IS NULL OR
b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
col1 col2 col2 col3
1 trudy 2 y
@@ -1687,9 +1687,9 @@ col1 col2 col2 col3
7 carsten NULL NULL
8 ranger 1 y
10 matt NULL NULL
-SELECT a.col1,a.col2,b.col2,b.col3
+SELECT a.col1,a.col2,b.col2,b.col3
FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1
-WHERE b.col2 IS NULL OR
+WHERE b.col2 IS NULL OR
b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
col1 col2 col2 col3
1 trudy 2 y
@@ -1743,7 +1743,7 @@ A A
2 2
3 3
create table t3 as select a a,a b from t2;
-create view v2 as select * from t3 where
+create view v2 as select * from t3 where
a in (select * from t1) or b in (select * from t2);
select * from v2 A, v2 B where A.a = B.b;
a b a b
@@ -1999,7 +1999,7 @@ dkjhgd
drop view v1;
create table t1 (f59 int, f60 int, f61 int);
insert into t1 values (19,41,32);
-create view v1 as select f59, f60 from t1 where f59 in
+create view v1 as select f59, f60 from t1 where f59 in
(select f59 from t1);
update v1 set f60=2345;
ERROR HY000: The target table v1 of the UPDATE is not updatable
@@ -2115,7 +2115,7 @@ pid int NOT NULL
INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d');
INSERT INTO t2 values (1,1), (2,1), (2,2);
CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid;
-SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2
+SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2
WHERE t1.aid = t2.aid GROUP BY pid;
pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1)
1 a b,c d
@@ -2217,7 +2217,7 @@ group_name varchar(32) NOT NULL
) engine = InnoDB;
create table t2 (
r_object_id char(16) NOT NULL,
-i_position int(11) NOT NULL,
+i_position int(11) NOT NULL,
users_names varchar(32) default NULL
) Engine = InnoDB;
create view v1 as select r_object_id, group_name from t1;
@@ -2230,7 +2230,7 @@ insert into t1 values('120001a080000542','tstgroup1');
insert into t2 values('120001a080000542',-1, 'guser01');
insert into t2 values('120001a080000542',-2, 'guser02');
select v1.r_object_id, v2.users_names from v1, v2
-where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id
+where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id
order by users_names;
r_object_id users_names
120001a080000542 guser01
@@ -2380,8 +2380,8 @@ create table t4 (x int, y int, z int);
create view v1 as
select t1.x
from (
-(t1 join t2 on ((t1.y = t2.y)))
-join
+(t1 join t2 on ((t1.y = t2.y)))
+join
(t3 left join t4 on (t3.y = t4.y) and (t3.z = t4.z))
);
prepare stmt1 from "select count(*) from v1 where x = ?";
@@ -2557,12 +2557,12 @@ Warnings:
Warning 1052 Column 'x' in group statement is ambiguous
DROP VIEW v1;
DROP TABLE t1;
-drop table if exists t1;
-drop view if exists v1;
-create table t1 (id int);
-create view v1 as select * from t1;
-drop table t1;
-show create view v1;
+drop table if exists t1;
+drop view if exists v1;
+create table t1 (id int);
+create view v1 as select * from t1;
+drop table t1;
+show create view v1;
drop view v1;
//
View Create View character_set_client collation_connection
@@ -2609,7 +2609,7 @@ DROP VIEW v2;
DROP TABLE t1, t2;
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY,
td date DEFAULT NULL, KEY idx(td));
-INSERT INTO t1 VALUES
+INSERT INTO t1 VALUES
(1, '2005-01-01'), (2, '2005-01-02'), (3, '2005-01-02'),
(4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'),
(7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06');
@@ -2973,10 +2973,10 @@ drop view v1;
drop table t1;
CREATE TABLE t1(pk int PRIMARY KEY);
CREATE TABLE t2(pk int PRIMARY KEY, fk int, ver int, org int);
-CREATE ALGORITHM=MERGE VIEW v1 AS
+CREATE ALGORITHM=MERGE VIEW v1 AS
SELECT t1.*
-FROM t1 JOIN t2
-ON t2.fk = t1.pk AND
+FROM t1 JOIN t2
+ON t2.fk = t1.pk AND
t2.ver = (SELECT MAX(t.ver) FROM t2 t WHERE t.org = t2.org);
SHOW WARNINGS;
Level Code Message
@@ -3306,7 +3306,7 @@ name char(10) NOT NULL
INSERT INTO t1 (lid, name) VALUES
(1, 'YES'), (2, 'NO');
CREATE TABLE t2 (
-id int NOT NULL PRIMARY KEY,
+id int NOT NULL PRIMARY KEY,
gid int NOT NULL,
lid int NOT NULL,
dt date
@@ -3405,8 +3405,8 @@ CREATE TABLE t1 (id int);
CREATE TABLE t2 (id int, c int DEFAULT 0);
INSERT INTO t1 (id) VALUES (1);
INSERT INTO t2 (id) VALUES (1);
-CREATE VIEW v1 AS
-SELECT t2.c FROM t1, t2
+CREATE VIEW v1 AS
+SELECT t2.c FROM t1, t2
WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
UPDATE v1 SET c=1;
DROP VIEW v1;
@@ -3514,7 +3514,7 @@ role_name varchar(100) default NULL,
app_name varchar(40) NOT NULL,
INDEX idx_app_name(app_name)
);
-CREATE VIEW v1 AS
+CREATE VIEW v1 AS
SELECT profile.person_id AS person_id
FROM t1 profile, t2 userrole, t3 role
WHERE userrole.person_id = profile.person_id AND
@@ -3526,7 +3526,7 @@ INSERT INTO t1 VALUES
(-717462680,'ENTS Ta','0'), (-904346964,'ndard SQL\n','0');
INSERT INTO t2 VALUES
(1,3,6),(2,4,7),(3,5,8),(4,6,9),(5,1,6),(6,1,7),(7,1,8),(8,1,9),(9,1,10);
-INSERT INTO t3 VALUES
+INSERT INTO t3 VALUES
(1,'NUCANS_APP_USER','NUCANSAPP'),(2,'NUCANS_TRGAPP_USER','NUCANSAPP'),
(3,'IA_INTAKE_COORDINATOR','IACANS'),(4,'IA_SCREENER','IACANS'),
(5,'IA_SUPERVISOR','IACANS'),(6,'IA_READONLY','IACANS'),
@@ -3552,7 +3552,7 @@ i
2
3
4
-select table_name, is_updatable from information_schema.views
+select table_name, is_updatable from information_schema.views
where table_name = 'v1';
table_name is_updatable
v1 NO
@@ -3598,8 +3598,8 @@ DROP VIEW v2;
DROP VIEW v3;
DROP TABLE t1;
#
-# Bug#29477: Not all fields of the target table were checked to have
-# a default value when inserting into a view.
+# Bug#29477 Not all fields of the target table were checked to have
+# a default value when inserting into a view.
#
create table t1(f1 int, f2 int not null);
create view v1 as select f1 from t1;
@@ -3616,7 +3616,7 @@ drop table t1;
create table t1 (a int, key(a));
create table t2 (c int);
create view v1 as select a b from t1;
-create view v2 as select 1 a from t2, v1 where c in
+create view v2 as select 1 a from t2, v1 where c in
(select 1 from t1 where b = a);
insert into t1 values (1), (1);
insert into t2 values (1), (1);
@@ -3638,7 +3638,7 @@ MAX(a) COUNT(DISTINCT a)
DROP VIEW v1;
DROP TABLE t1;
# -----------------------------------------------------------------
-# -- Bug#34337: Server crash when Altering a view using a table name.
+# -- Bug#34337 Server crash when Altering a view using a table name.
# -----------------------------------------------------------------
DROP TABLE IF EXISTS t1;
@@ -3655,8 +3655,8 @@ DROP TABLE t1;
# -- End of test case for Bug#34337.
# -----------------------------------------------------------------
-# -- Bug#35193: VIEW query is rewritten without "FROM DUAL",
-# -- causing syntax error
+# -- Bug#35193 VIEW query is rewritten without "FROM DUAL",
+# -- causing syntax error
# -----------------------------------------------------------------
CREATE VIEW v1 AS SELECT 1 FROM DUAL WHERE 1;
@@ -3723,7 +3723,7 @@ DROP DATABASE `d-1`;
USE test;
#
-# Bug#26676: VIEW using old table schema in a session.
+# Bug#26676 VIEW using old table schema in a session.
#
DROP VIEW IF EXISTS v1;
@@ -3765,7 +3765,7 @@ DROP TABLE t1;
# End of test case for Bug#26676.
# -----------------------------------------------------------------
-# -- Bug#32538: View definition picks up character set, but not collation
+# -- Bug#32538 View definition picks up character set, but not collation
# -----------------------------------------------------------------
DROP VIEW IF EXISTS v1;
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index 1821e50e294..7e280fa2fe5 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -28,7 +28,7 @@ create view v2 as select * from mysqltest.t2;
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2'
show create view v1;
View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
grant create view,drop,select on test.* to mysqltest_1@localhost;
use test;
alter view v1 as select * from mysqltest.t1;
@@ -309,7 +309,7 @@ grant create view,select on test.* to mysqltest_1@localhost;
create view v1 as select * from mysqltest.t1;
show create view v1;
View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqltest_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `mysqltest`.`t1`.`a` AS `a`,`mysqltest`.`t1`.`b` AS `b` from `mysqltest`.`t1` latin1 latin1_swedish_ci
revoke select on mysqltest.t1 from mysqltest_1@localhost;
select * from v1;
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
@@ -646,7 +646,7 @@ CREATE DATABASE test2;
CREATE TABLE test1.t0 (a VARCHAR(20));
CREATE TABLE test2.t1 (a VARCHAR(20));
CREATE VIEW test2.t3 AS SELECT * FROM test1.t0;
-CREATE OR REPLACE VIEW test.v1 AS
+CREATE OR REPLACE VIEW test.v1 AS
SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb;
DROP VIEW test.v1;
DROP VIEW test2.t3;
@@ -790,7 +790,7 @@ v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI
DROP USER u26813@localhost;
DROP DATABASE db26813;
#
-# Bug#29908: A user can gain additional access through the ALTER VIEW.
+# Bug#29908 A user can gain additional access through the ALTER VIEW.
#
CREATE DATABASE mysqltest_29908;
USE mysqltest_29908;
@@ -921,6 +921,32 @@ c4
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_u1@localhost;
+CREATE DATABASE db1;
+USE db1;
+CREATE TABLE t1(f1 INT, f2 INT);
+CREATE VIEW v1 AS SELECT f1, f2 FROM t1;
+GRANT SELECT (f1) ON t1 TO foo;
+GRANT SELECT (f1) ON v1 TO foo;
+USE db1;
+SELECT f1 FROM t1;
+f1
+SELECT f2 FROM t1;
+ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 't1'
+SELECT * FROM t1;
+ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 't1'
+SELECT f1 FROM v1;
+f1
+SELECT f2 FROM v1;
+ERROR 42000: SELECT command denied to user 'foo'@'localhost' for column 'f2' in table 'v1'
+SELECT * FROM v1;
+ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 'v1'
+USE test;
+REVOKE SELECT (f1) ON db1.t1 FROM foo;
+REVOKE SELECT (f1) ON db1.v1 FROM foo;
+DROP USER foo;
+DROP VIEW db1.v1;
+DROP TABLE db1.t1;
+DROP DATABASE db1;
End of 5.0 tests.
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
@@ -956,6 +982,27 @@ Warnings:
Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
DROP VIEW v1;
DROP TABLE t1;
+CREATE USER mysqluser1@localhost;
+CREATE DATABASE mysqltest1;
+USE mysqltest1;
+CREATE TABLE t1 ( a INT );
+CREATE TABLE t2 ( b INT );
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1), (2);
+GRANT CREATE VIEW ON mysqltest1.* TO mysqluser1@localhost;
+GRANT SELECT ON t1 TO mysqluser1@localhost;
+GRANT INSERT ON t2 TO mysqluser1@localhost;
+This would lead to failed assertion.
+CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
+SELECT * FROM v1;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
+SELECT b FROM v1;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
+DROP TABLE t1, t2;
+DROP VIEW v1;
+DROP DATABASE mysqltest1;
+DROP USER mysqluser1@localhost;
+USE test;
End of 5.1 tests.
CREATE USER mysqluser1@localhost;
CREATE DATABASE mysqltest1;
@@ -996,3 +1043,4 @@ DROP VIEW v1, v2;
DROP DATABASE mysqltest1;
DROP VIEW test.v3;
DROP USER mysqluser1@localhost;
+USE test;
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index 19d95acd5c1..2e393aea9e4 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -168,7 +168,7 @@ max_error_count 10
drop table t1;
set table_type=MYISAM;
Warnings:
-Warning 1287 The syntax '@@table_type' is deprecated and will be removed in MySQL 5.2. Please use '@@storage_engine' instead
+Warning 1287 The syntax '@@table_type' is deprecated and will be removed in MySQL 6.0. Please use '@@storage_engine' instead
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
update t1 set a='abc';
diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result
index d056bde4dca..4e0d73ea0eb 100644
--- a/mysql-test/r/windows.result
+++ b/mysql-test/r/windows.result
@@ -19,6 +19,24 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
DROP TABLE t1;
+CREATE DATABASE `TESTDB`;
+USE `TESTDB`;
+CREATE FUNCTION test_fn() RETURNS INTEGER
+BEGIN
+DECLARE rId bigint;
+RETURN rId;
+END
+//
+CREATE FUNCTION test_fn2() RETURNS INTEGER
+BEGIN
+DECLARE rId bigint;
+RETURN rId;
+END
+//
+DROP FUNCTION `TESTDB`.`test_fn`;
+DROP FUNCTION `testdb`.`test_fn2`;
+USE test;
+DROP DATABASE `TESTDB`;
End of 5.0 tests.
drop procedure if exists proc_1;
create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll';
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index 404b0dc3789..fad2cab0e57 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -1064,4 +1064,33 @@ select extractvalue('<a></a>','"b"/a');
ERROR HY000: XPATH syntax error: '/a'
select extractvalue('<a></a>','(1)/a');
ERROR HY000: XPATH syntax error: '/a'
+CREATE TABLE IF NOT EXISTS t1 (
+id int(10) unsigned NOT NULL AUTO_INCREMENT,
+xml text,
+PRIMARY KEY (id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (id, xml) VALUES
+(15, '<?xml version="1.0"?><bla name="blubb"></bla>'),
+(14, '<xml version="kaputt">');
+SELECT
+extractvalue( xml, '/bla/@name' ),
+extractvalue( xml, '/bla/@name' )
+FROM t1 ORDER BY t1.id;
+extractvalue( xml, '/bla/@name' ) extractvalue( xml, '/bla/@name' )
+NULL NULL
+blubb blubb
+Warnings:
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+SELECT
+UpdateXML(xml, '/bla/@name', 'test'),
+UpdateXML(xml, '/bla/@name', 'test')
+FROM t1 ORDER BY t1.id;
+UpdateXML(xml, '/bla/@name', 'test') UpdateXML(xml, '/bla/@name', 'test')
+NULL NULL
+<?xml version="1.0"?><bla test></bla> <?xml version="1.0"?><bla test></bla>
+Warnings:
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/std_data/bug37631.MYD b/mysql-test/std_data/bug37631.MYD
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/mysql-test/std_data/bug37631.MYD
diff --git a/mysql-test/std_data/bug37631.MYI b/mysql-test/std_data/bug37631.MYI
new file mode 100644
index 00000000000..8bf14b46add
--- /dev/null
+++ b/mysql-test/std_data/bug37631.MYI
Binary files differ
diff --git a/mysql-test/std_data/bug37631.frm b/mysql-test/std_data/bug37631.frm
new file mode 100644
index 00000000000..2742a387c38
--- /dev/null
+++ b/mysql-test/std_data/bug37631.frm
Binary files differ
diff --git a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result
index 8df0568a755..8226469fcf7 100644
--- a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result
+++ b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result
@@ -38,4 +38,5 @@ DROP PROCEDURE IF EXISTS p2;
DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS tr1;
stop slave sql_thread;
+reset slave;
SET @@global.relay_log_purge= @old_relay_log_purge;
diff --git a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result
index 1a56e048b27..25cb7a4726f 100644
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result
@@ -1137,6 +1137,38 @@ DROP PROCEDURE p1;
DROP TABLE t1;
DROP DATABASE bug39182;
USE test;
+CREATE PROCEDURE p1(IN v1 INT)
+BEGIN
+CREATE TABLE t1 SELECT v1;
+DROP TABLE t1;
+END//
+CREATE PROCEDURE p2()
+BEGIN
+DECLARE v1 INT;
+CREATE TABLE t1 SELECT v1+1;
+DROP TABLE t1;
+END//
+CREATE PROCEDURE p3(IN v1 INT)
+BEGIN
+CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0;
+DROP TABLE t1;
+END//
+CREATE PROCEDURE p4(IN v1 INT)
+BEGIN
+DECLARE v2 INT;
+CREATE TABLE t1 SELECT 1, v1, v2;
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1, v1+1, v2;
+DROP TABLE t1;
+END//
+CALL p1(1);
+CALL p2();
+CALL p3(0);
+CALL p4(0);
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
End of 5.0 tests
reset master;
create table t1 (id tinyint auto_increment primary key);
diff --git a/mysql-test/suite/binlog/r/binlog_sql_mode.result b/mysql-test/suite/binlog/r/binlog_sql_mode.result
new file mode 100644
index 00000000000..e306040502d
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_sql_mode.result
@@ -0,0 +1,46 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+SET @old_sql_mode= @@global.sql_mode;
+SET @old_binlog_format=@@session.binlog_format;
+SET SESSION sql_mode=8;
+Initialization
+RESET MASTER;
+CREATE TABLE t1 (id INT);
+CREATE PROCEDURE testProc() SELECT * FROM t1;
+CREATE VIEW testView as SELECT * from t1;
+CREATE FUNCTION testFunc()
+RETURNS INT
+BEGIN
+return 1;
+END;|
+CREATE TRIGGER testTrig BEFORE INSERT ON t1
+FOR EACH ROW BEGIN
+UPDATE t1 SET id = id +1;
+END;|
+CREATE EVENT testEvent ON SCHEDULE
+EVERY 1 DAY
+DO
+BEGIN
+UPDATE t1 SET id = id +1;
+END;|
+Chceck Result
+select
+(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
+is not null;
+(@a:=load_file("MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
+is not null
+1
+*** String sql_mode=0 is found: 0 ***
+Clean Up
+DROP PROCEDURE testProc;
+DROP FUNCTION testFunc;
+DROP TRIGGER testTrig;
+DROP EVENT testEvent;
+DROP VIEW testView;
+DROP TABLE t1;
+SET @@global.sql_mode= @old_sql_mode;
+SET @@session.binlog_format=@old_binlog_format;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
index aadbf950b21..efdeb30a2af 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
@@ -644,6 +644,38 @@ DROP PROCEDURE p1;
DROP TABLE t1;
DROP DATABASE bug39182;
USE test;
+CREATE PROCEDURE p1(IN v1 INT)
+BEGIN
+CREATE TABLE t1 SELECT v1;
+DROP TABLE t1;
+END//
+CREATE PROCEDURE p2()
+BEGIN
+DECLARE v1 INT;
+CREATE TABLE t1 SELECT v1+1;
+DROP TABLE t1;
+END//
+CREATE PROCEDURE p3(IN v1 INT)
+BEGIN
+CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0;
+DROP TABLE t1;
+END//
+CREATE PROCEDURE p4(IN v1 INT)
+BEGIN
+DECLARE v2 INT;
+CREATE TABLE t1 SELECT 1, v1, v2;
+DROP TABLE t1;
+CREATE TABLE t1 SELECT 1, v1+1, v2;
+DROP TABLE t1;
+END//
+CALL p1(1);
+CALL p2();
+CALL p3(0);
+CALL p4(0);
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
End of 5.0 tests
reset master;
create table t1 (id tinyint auto_increment primary key);
diff --git a/mysql-test/suite/binlog/r/binlog_stm_ps.result b/mysql-test/suite/binlog/r/binlog_stm_ps.result
index 1cf7429987e..ea7cc6f16df 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_ps.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_ps.result
@@ -11,7 +11,7 @@ prepare s from "insert into t1 select 100 limit ?";
set @a=100;
execute s using @a;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; create table t1 (a int)
diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result
index 7c0980ba77c..675c327e9e7 100644
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result
@@ -10,25 +10,25 @@ INSERT DELAYED INTO t1 VALUES (5);
---- Insert directly ----
INSERT INTO t1 VALUES (@@global.sync_binlog);
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
INSERT INTO t1 VALUES (@@session.insert_id);
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
INSERT INTO t1 VALUES (@@global.auto_increment_increment);
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
INSERT INTO t2 SELECT UUID();
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
INSERT INTO t2 VALUES (@@session.sql_mode);
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
INSERT INTO t2 VALUES (@@global.init_slave);
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
INSERT INTO t2 VALUES (@@hostname);
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
---- Insert from stored procedure ----
CREATE PROCEDURE proc()
BEGIN
@@ -42,13 +42,13 @@ INSERT INTO t2 VALUES (@@hostname);
END|
CALL proc();
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
---- Insert from stored function ----
CREATE FUNCTION func()
RETURNS INT
@@ -66,13 +66,13 @@ SELECT func();
func()
0
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
---- Insert from trigger ----
CREATE TRIGGER trig
BEFORE INSERT ON trigger_table
@@ -88,14 +88,14 @@ INSERT INTO t2 VALUES (@@hostname);
END|
INSERT INTO trigger_table VALUES ('bye.');
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
---- Insert from prepared statement ----
PREPARE p1 FROM 'INSERT INTO t1 VALUES (@@global.sync_binlog)';
PREPARE p2 FROM 'INSERT INTO t1 VALUES (@@session.insert_id)';
@@ -106,25 +106,25 @@ PREPARE p6 FROM 'INSERT INTO t2 VALUES (@@global.init_slave)';
PREPARE p7 FROM 'INSERT INTO t2 VALUES (@@hostname)';
EXECUTE p1;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
EXECUTE p2;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
EXECUTE p3;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
EXECUTE p4;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
EXECUTE p5;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
EXECUTE p6;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
EXECUTE p7;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
---- Insert from nested call of triggers / functions / procedures ----
CREATE PROCEDURE proc1()
INSERT INTO trigger_table VALUES ('ha!')|
@@ -154,13 +154,13 @@ EXECUTE prep6;
func5()
0
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
==== Variables that should *not* be unsafe ====
INSERT INTO t1 VALUES (@@session.pseudo_thread_id);
INSERT INTO t1 VALUES (@@session.pseudo_thread_id);
@@ -195,16 +195,16 @@ DROP TABLE t1, t2, t3, trigger_table, trigger_table2;
CREATE TABLE t1(a INT, b INT, KEY(a), PRIMARY KEY(b));
INSERT INTO t1 SELECT * FROM t1 LIMIT 1;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
REPLACE INTO t1 SELECT * FROM t1 LIMIT 1;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
UPDATE t1 SET a=1 LIMIT 1;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
DELETE FROM t1 LIMIT 1;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
CREATE PROCEDURE p1()
BEGIN
INSERT INTO t1 SELECT * FROM t1 LIMIT 1;
@@ -214,10 +214,10 @@ DELETE FROM t1 LIMIT 1;
END|
CALL p1();
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
DROP PROCEDURE p1;
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
@@ -225,5 +225,106 @@ CREATE TABLE t1 (a VARCHAR(100), b VARCHAR(100));
INSERT INTO t1 VALUES ('a','b');
UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
DROP TABLE t1;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1(i INT PRIMARY KEY);
+CREATE TABLE t2(i INT PRIMARY KEY);
+CREATE TABLE t3(i INT, ch CHAR(50));
+"Should issue message Statement is not safe to log in statement format."
+INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+CREATE FUNCTION func6()
+RETURNS INT
+BEGIN
+INSERT INTO t1 VALUES (10);
+INSERT INTO t1 VALUES (11);
+INSERT INTO t1 VALUES (12);
+RETURN 0;
+END|
+"Should issue message Statement is not safe to log in statement format only once"
+INSERT INTO t3 VALUES(func6(), UUID());
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+"Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements"
+CREATE FUNCTION fun_check_log_bin() RETURNS INT
+BEGIN
+SET @@SQL_LOG_BIN = 0;
+INSERT INTO t1 VALUES(@@global.sync_binlog);
+RETURN 100;
+END|
+"One unsafe warning should be issued in the following statement"
+SELECT fun_check_log_bin();
+fun_check_log_bin()
+100
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+"SQL_LOG_BIN should be ON still"
+SHOW VARIABLES LIKE "SQL_LOG_BIN";
+Variable_name Value
+sql_log_bin ON
+set @save_log_bin = @@SESSION.SQL_LOG_BIN;
+set @@SESSION.SQL_LOG_BIN = 0;
+"Should NOT have any warning message issued in the following statements"
+INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
+DROP TABLE t1,t2;
+"Should NOT have any warning message issued in the following func7() and trig"
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a CHAR(40));
+CREATE TABLE trigger_table (a CHAR(7));
+CREATE FUNCTION func7()
+RETURNS INT
+BEGIN
+INSERT INTO t1 VALUES (@@global.sync_binlog);
+INSERT INTO t1 VALUES (@@session.insert_id);
+INSERT INTO t2 SELECT UUID();
+INSERT INTO t2 VALUES (@@session.sql_mode);
+INSERT INTO t2 VALUES (@@global.init_slave);
+RETURN 0;
+END|
+SHOW VARIABLES LIKE "SQL_LOG_BIN";
+Variable_name Value
+sql_log_bin OFF
+SELECT func7();
+func7()
+0
+---- Insert from trigger ----
+CREATE TRIGGER trig
+BEFORE INSERT ON trigger_table
+FOR EACH ROW
+BEGIN
+INSERT INTO t1 VALUES (@@global.sync_binlog);
+INSERT INTO t1 VALUES (@@session.insert_id);
+INSERT INTO t1 VALUES (@@global.auto_increment_increment);
+INSERT INTO t2 SELECT UUID();
+INSERT INTO t2 VALUES (@@session.sql_mode);
+INSERT INTO t2 VALUES (@@global.init_slave);
+INSERT INTO t2 VALUES (@@hostname);
+END|
+INSERT INTO trigger_table VALUES ('bye.');
+DROP FUNCTION fun_check_log_bin;
+DROP FUNCTION func6;
+DROP FUNCTION func7;
+DROP TRIGGER trig;
+DROP TABLE t1, t2, t3, trigger_table;
+set @@SESSION.SQL_LOG_BIN = @save_log_bin;
+SET @save_sql_mode = @@SESSION.SQL_MODE;
+SET @@SESSION.SQL_MODE = STRICT_ALL_TABLES;
+CREATE TABLE t1(i INT PRIMARY KEY);
+CREATE TABLE t2(i INT PRIMARY KEY);
+INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+INSERT INTO t1 VALUES(@@global.sync_binlog);
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+UPDATE t1 SET i = 999 LIMIT 1;
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+DELETE FROM t1 LIMIT 1;
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+DROP TABLE t1, t2;
+SET @@SESSION.SQL_MODE = @save_sql_mode;
+"End of tests"
diff --git a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test
index f20cc33f820..5297767675c 100644
--- a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test
+++ b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test
@@ -52,9 +52,10 @@ DROP FUNCTION IF EXISTS f1;
DROP TRIGGER IF EXISTS tr1;
enable_warnings;
-remove_file $MYSQLD_DATADIR/slave-relay-bin.000001;
-remove_file $MYSQLD_DATADIR/slave-relay-bin.index;
stop slave sql_thread;
+reset slave;
source include/wait_for_slave_sql_to_stop.inc;
+remove_file $MYSQLD_DATADIR/slave-relay-bin.000001;
+remove_file $MYSQLD_DATADIR/slave-relay-bin.index;
SET @@global.relay_log_purge= @old_relay_log_purge;
diff --git a/mysql-test/suite/binlog/t/binlog_sql_mode.test b/mysql-test/suite/binlog/t/binlog_sql_mode.test
new file mode 100644
index 00000000000..1777f8cb561
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_sql_mode.test
@@ -0,0 +1,76 @@
+# ==== Purpose ====
+#
+# Test that sql_mode can correct restore before generating the binlog event
+# when creating CREATEable objects.
+#
+# ==== Method ====
+#
+# Scan binlog file to check if the sql_mode is still set to 0 before generating binlog event
+#
+
+-- source include/master-slave.inc
+-- source include/have_log_bin.inc
+
+# BUG#39526 sql_mode not retained in binary log for CREATE PROCEDURE
+
+SET @old_sql_mode= @@global.sql_mode;
+SET @old_binlog_format=@@session.binlog_format;
+let $MYSQLD_DATADIR= `select @@datadir`;
+SET SESSION sql_mode=8;
+
+--echo Initialization
+
+RESET MASTER;
+CREATE TABLE t1 (id INT);
+
+CREATE PROCEDURE testProc() SELECT * FROM t1;
+CREATE VIEW testView as SELECT * from t1;
+
+DELIMITER |;
+CREATE FUNCTION testFunc()
+ RETURNS INT
+ BEGIN
+ return 1;
+ END;|
+DELIMITER ;|
+
+DELIMITER |;
+CREATE TRIGGER testTrig BEFORE INSERT ON t1
+ FOR EACH ROW BEGIN
+ UPDATE t1 SET id = id +1;
+ END;|
+DELIMITER ;|
+
+DELIMITER |;
+CREATE EVENT testEvent ON SCHEDULE
+ EVERY 1 DAY
+ DO
+ BEGIN
+ UPDATE t1 SET id = id +1;
+ END;|
+DELIMITER ;|
+
+--echo Chceck Result
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select
+(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog"))
+is not null;
+let $s_mode_unsigned= `select @a like "%@@session.sql_mode=0%" /* must return 0 */`;
+echo *** String sql_mode=0 is found: $s_mode_unsigned ***;
+
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug39526.binlog
+
+--echo Clean Up
+
+DROP PROCEDURE testProc;
+DROP FUNCTION testFunc;
+DROP TRIGGER testTrig;
+DROP EVENT testEvent;
+DROP VIEW testView;
+DROP TABLE t1;
+
+SET @@global.sql_mode= @old_sql_mode;
+SET @@session.binlog_format=@old_binlog_format;
diff --git a/mysql-test/suite/binlog/t/binlog_unsafe.test b/mysql-test/suite/binlog/t/binlog_unsafe.test
index f58233d4fef..1b0f0a6c30a 100644
--- a/mysql-test/suite/binlog/t/binlog_unsafe.test
+++ b/mysql-test/suite/binlog/t/binlog_unsafe.test
@@ -8,6 +8,7 @@
# executed cannot be determined (e.g., INSERT DELAYED). Such
# statements should be marked unsafe. All unsafe statements should
# give a warning.
+# Yet the warning/error message isn't issued when SQL_LOG_BIN is turned off.
#
# This test verifies that a warning is generated for statements that
# should be unsafe, when they are executed under statement mode
@@ -32,14 +33,20 @@
# We try to insert the variables that should not be unsafe into a
# table, and verify that *no* warning is issued.
#
-#
+# Execute a unsafe statement calling a trigger or stored function
+# or neither when SQL_LOG_BIN is turned ON, a warning/error should be issued
+# Execute a unsafe statement calling a trigger or stored function
+# or neither when @@SQL_LOG_BIN is turned OFF,
+# no warning/error is issued
+
# ==== Related bugs and worklogs ====
#
# WL#3339: Issue warnings when statement-based replication may fail
# BUG#31168: @@hostname does not replicate
# BUG#34732: mysqlbinlog does not print default values for auto_increment variables
# BUG#34768: nondeterministic INSERT using LIMIT logged in stmt mode if binlog_format=mixed
-#
+# BUG#41980, SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0
+# BUG#42640: mysqld crashes when unsafe statements are executed (STRICT_TRANS_TABLES mode)
#
# ==== Related test cases ====
#
@@ -271,3 +278,114 @@ INSERT INTO t1 VALUES ('a','b');
UPDATE t1 SET b = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s' WHERE a = 'a' LIMIT 1;
DROP TABLE t1;
+#
+#For bug#41980, SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+CREATE TABLE t1(i INT PRIMARY KEY);
+CREATE TABLE t2(i INT PRIMARY KEY);
+CREATE TABLE t3(i INT, ch CHAR(50));
+
+--echo "Should issue message Statement is not safe to log in statement format."
+INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
+
+DELIMITER |;
+CREATE FUNCTION func6()
+RETURNS INT
+BEGIN
+ INSERT INTO t1 VALUES (10);
+ INSERT INTO t1 VALUES (11);
+ INSERT INTO t1 VALUES (12);
+ RETURN 0;
+END|
+DELIMITER ;|
+--echo "Should issue message Statement is not safe to log in statement format only once"
+INSERT INTO t3 VALUES(func6(), UUID());
+
+--echo "Check whether SET @@SQL_LOG_BIN = 0/1 doesn't work in substatements"
+DELIMITER |;
+CREATE FUNCTION fun_check_log_bin() RETURNS INT
+BEGIN
+ SET @@SQL_LOG_BIN = 0;
+ INSERT INTO t1 VALUES(@@global.sync_binlog);
+ RETURN 100;
+END|
+DELIMITER ;|
+--echo "One unsafe warning should be issued in the following statement"
+SELECT fun_check_log_bin();
+--echo "SQL_LOG_BIN should be ON still"
+SHOW VARIABLES LIKE "SQL_LOG_BIN";
+
+set @save_log_bin = @@SESSION.SQL_LOG_BIN;
+set @@SESSION.SQL_LOG_BIN = 0;
+--echo "Should NOT have any warning message issued in the following statements"
+INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
+DROP TABLE t1,t2;
+
+--echo "Should NOT have any warning message issued in the following func7() and trig"
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a CHAR(40));
+CREATE TABLE trigger_table (a CHAR(7));
+DELIMITER |;
+CREATE FUNCTION func7()
+RETURNS INT
+BEGIN
+ INSERT INTO t1 VALUES (@@global.sync_binlog);
+ INSERT INTO t1 VALUES (@@session.insert_id);
+ INSERT INTO t2 SELECT UUID();
+ INSERT INTO t2 VALUES (@@session.sql_mode);
+ INSERT INTO t2 VALUES (@@global.init_slave);
+ RETURN 0;
+END|
+DELIMITER ;|
+SHOW VARIABLES LIKE "SQL_LOG_BIN";
+SELECT func7();
+
+--echo ---- Insert from trigger ----
+
+DELIMITER |;
+CREATE TRIGGER trig
+BEFORE INSERT ON trigger_table
+FOR EACH ROW
+BEGIN
+ INSERT INTO t1 VALUES (@@global.sync_binlog);
+ INSERT INTO t1 VALUES (@@session.insert_id);
+ INSERT INTO t1 VALUES (@@global.auto_increment_increment);
+ INSERT INTO t2 SELECT UUID();
+ INSERT INTO t2 VALUES (@@session.sql_mode);
+ INSERT INTO t2 VALUES (@@global.init_slave);
+ INSERT INTO t2 VALUES (@@hostname);
+END|
+DELIMITER ;|
+
+INSERT INTO trigger_table VALUES ('bye.');
+
+#clean up
+DROP FUNCTION fun_check_log_bin;
+DROP FUNCTION func6;
+DROP FUNCTION func7;
+DROP TRIGGER trig;
+DROP TABLE t1, t2, t3, trigger_table;
+set @@SESSION.SQL_LOG_BIN = @save_log_bin;
+
+#
+# For BUG#42640: mysqld crashes when unsafe statements are executed (STRICT_TRANS_TABLES mode)
+#
+SET @save_sql_mode = @@SESSION.SQL_MODE;
+SET @@SESSION.SQL_MODE = STRICT_ALL_TABLES;
+
+CREATE TABLE t1(i INT PRIMARY KEY);
+CREATE TABLE t2(i INT PRIMARY KEY);
+
+INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
+INSERT INTO t1 VALUES(@@global.sync_binlog);
+
+UPDATE t1 SET i = 999 LIMIT 1;
+DELETE FROM t1 LIMIT 1;
+
+DROP TABLE t1, t2;
+SET @@SESSION.SQL_MODE = @save_sql_mode;
+--echo "End of tests"
diff --git a/mysql-test/suite/bugs/r/rpl_bug38205.result b/mysql-test/suite/bugs/r/rpl_bug38205.result
new file mode 100644
index 00000000000..8f1dee344fa
--- /dev/null
+++ b/mysql-test/suite/bugs/r/rpl_bug38205.result
@@ -0,0 +1,56 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1i(n int primary key) engine=innodb;
+create table t2m(n int primary key) engine=myisam;
+begin;
+insert into t1i values (1);
+insert into t1i values (2);
+insert into t1i values (3);
+commit;
+begin;
+insert into t1i values (5);
+begin;
+insert into t1i values (4);
+insert into t2m values (1);
+update t1i set n = 5 where n = 4;
+commit;
+zero
+0
+*** kill sql thread ***
+rollback;
+*** sql thread is *not* running: No ***
+*** the prove: the killed slave has not finished the current transaction ***
+three
+3
+one
+1
+zero
+0
+delete from t2m;
+start slave sql_thread;
+delete from t1i;
+delete from t2m;
+begin;
+insert into t1i values (5);
+begin;
+insert into t1i values (4);
+update t1i set n = 5 where n = 4;
+commit;
+zero
+0
+stop slave sql_thread;
+rollback;
+*** sql thread is *not* running: No ***
+*** the prove: the stopped slave has rolled back the current transaction ***
+zero
+0
+zero
+0
+one
+1
+start slave sql_thread;
+drop table t1i, t2m;
diff --git a/mysql-test/suite/bugs/t/rpl_bug38205.test b/mysql-test/suite/bugs/t/rpl_bug38205.test
new file mode 100644
index 00000000000..52b36636e79
--- /dev/null
+++ b/mysql-test/suite/bugs/t/rpl_bug38205.test
@@ -0,0 +1,166 @@
+#
+# Bug #38205 Row-based Replication (RBR) causes inconsistencies: HA_ERR_FOUND_DUPP_KEY
+# Bug#319 if while a non-transactional slave is replicating a transaction possible problem
+#
+# Verifying the fact that STOP SLAVE in the middle of a group execution waits
+# for the end of the group before the slave sql thread will stop.
+# The patch refines STOP SLAVE to not interrupt a transaction or other type of
+# the replication events group (the part I).
+# Killing the sql thread continues to provide a "hard" stop (the part II).
+#
+# Non-deterministic tests
+#
+
+source include/master-slave.inc;
+source include/have_innodb.inc;
+
+
+#
+# Part II, killed sql slave leaves instantly
+#
+
+# A. multi-statement transaction as the replication group
+
+connection master;
+
+create table t1i(n int primary key) engine=innodb;
+create table t2m(n int primary key) engine=myisam;
+
+sync_slave_with_master;
+
+connection master;
+
+begin;
+insert into t1i values (1);
+insert into t1i values (2);
+insert into t1i values (3);
+commit;
+
+sync_slave_with_master;
+
+#
+# todo: first challenge is to find out the SQL thread id
+# the following is not fully reliable
+#
+
+let $id=`SELECT id from information_schema.processlist where user like 'system user' and state like '%Has read all relay log%' or user like 'system user' and state like '%Reading event from the relay log%'`;
+connection slave;
+begin;
+insert into t1i values (5);
+
+connection master;
+let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+begin;
+insert into t1i values (4);
+insert into t2m values (1); # non-ta update
+update t1i set n = 5 where n = 4; # to block at. can't be played with killed
+commit;
+let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+connection slave;
+# slave sql thread must be locked out by the conn `slave' explicit lock
+let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+--disable_query_log
+eval select $pos0_master - $pos0_slave as zero;
+--enable_query_log
+
+connection slave1;
+
+let $count= 1;
+let $table= t2m;
+source include/wait_until_rows_count.inc;
+#
+# todo: may fail as said above
+#
+--echo *** kill sql thread ***
+--disable_query_log
+eval kill connection $id;
+--enable_query_log
+
+connection slave;
+rollback; # release the sql thread
+
+connection slave1;
+
+source include/wait_for_slave_sql_to_stop.inc;
+let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
+--echo *** sql thread is *not* running: $sql_status ***
+let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+
+connection slave;
+--echo *** the prove: the killed slave has not finished the current transaction ***
+
+--disable_query_log
+select count(*) as three from t1i;
+eval select $pos1_master > $pos1_slave as one;
+eval select $pos1_slave - $pos0_slave as zero;
+--enable_query_log
+
+delete from t2m; # remove the row to be able to replay
+start slave sql_thread;
+
+#
+# Part I: B The homogenous transaction remains interuptable in between
+#
+
+connection master;
+delete from t1i;
+delete from t2m;
+
+sync_slave_with_master;
+begin;
+insert into t1i values (5);
+
+connection master;
+let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+begin;
+insert into t1i values (4);
+update t1i set n = 5 where n = 4; # to block at. not to be played
+commit;
+let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+
+connection slave1;
+# slave sql can't advance as must be locked by the conn `slave' trans
+let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+--disable_query_log
+eval select $pos0_master - $pos0_slave as zero;
+--enable_query_log
+
+#
+# the replicated trans is blocked by the slave's local.
+# However, it's not easy to catch the exact moment when it happens.
+# The test issues sleep which makes the test either non-deterministic or
+# wasting too much time.
+#
+--sleep 3
+
+send stop slave sql_thread;
+
+connection slave;
+rollback; # release the sql thread
+
+connection slave1;
+reap;
+source include/wait_for_slave_sql_to_stop.inc;
+let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
+--echo *** sql thread is *not* running: $sql_status ***
+
+let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+
+--echo *** the prove: the stopped slave has rolled back the current transaction ***
+
+--disable_query_log
+select count(*) as zero from t1i;
+eval select $pos0_master - $pos0_slave as zero;
+eval select $pos1_master > $pos0_slave as one;
+--enable_query_log
+
+start slave sql_thread;
+
+# clean-up
+
+connection master;
+drop table t1i, t2m;
+
+sync_slave_with_master;
diff --git a/mysql-test/suite/federated/federated.result b/mysql-test/suite/federated/federated.result
index e54aa63b2ac..57f665995a1 100644
--- a/mysql-test/suite/federated/federated.result
+++ b/mysql-test/suite/federated/federated.result
@@ -2130,6 +2130,26 @@ SELECT t1.a FROM t1, t1 as t2 WHERE t2.b NOT LIKE t1.b;
a
DROP TABLE t1;
DROP TABLE t1;
+#
+# BUG#21360 - mysqldump error on federated tables
+#
+#Switch to Connection Slave
+CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id));
+INSERT INTO t1 VALUES ('text1'),('text2'),('text3'),('text4');
+#Switch to Connection Master
+CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED
+CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
+# Dump table t1 using mysqldump tool
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t1` (
+ `id` varchar(20) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
+/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE t1;
+#Switch to Connection Slave
+DROP TABLE t1;
End of 5.0 tests
create server 's1' foreign data wrapper 'mysql' options (port 3306);
drop server 's1';
diff --git a/mysql-test/suite/federated/federated.test b/mysql-test/suite/federated/federated.test
index fa448e74a18..870bbcb8f71 100644
--- a/mysql-test/suite/federated/federated.test
+++ b/mysql-test/suite/federated/federated.test
@@ -1942,6 +1942,28 @@ DROP TABLE t1;
connection master;
DROP TABLE t1;
+--echo #
+--echo # BUG#21360 - mysqldump error on federated tables
+--echo #
+connection slave;
+--echo #Switch to Connection Slave
+CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id));
+INSERT INTO t1 VALUES ('text1'),('text2'),('text3'),('text4');
+
+connection master;
+--echo #Switch to Connection Master
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED
+ CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
+--echo # Dump table t1 using mysqldump tool
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+--exec $MYSQL_DUMP --compact test t1
+DROP TABLE t1;
+
+connection slave;
+--echo #Switch to Connection Slave
+DROP TABLE t1;
+
connection default;
--echo End of 5.0 tests
diff --git a/mysql-test/suite/funcs_1/r/innodb_func_view.result b/mysql-test/suite/funcs_1/r/innodb_func_view.result
index 1547c5461be..4beb0c8aaf2 100644
--- a/mysql-test/suite/funcs_1/r/innodb_func_view.result
+++ b/mysql-test/suite/funcs_1/r/innodb_func_view.result
@@ -5245,7 +5245,7 @@ WHERE select_id = 1 OR select_id IS NULL order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
@@ -5259,7 +5259,7 @@ WHERE select_id = 1 OR select_id IS NULL) order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
diff --git a/mysql-test/suite/funcs_1/r/innodb_storedproc_08.result b/mysql-test/suite/funcs_1/r/innodb_storedproc_08.result
index 7bffd77d9c6..2e504af6ed4 100644
--- a/mysql-test/suite/funcs_1/r/innodb_storedproc_08.result
+++ b/mysql-test/suite/funcs_1/r/innodb_storedproc_08.result
@@ -103,7 +103,7 @@ END//
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -208,75 +208,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode
@@ -390,7 +321,7 @@ ALTER FUNCTION fn_2 MODIFIES SQL DATA;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -495,75 +426,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode
@@ -670,7 +532,7 @@ ALTER FUNCTION fn_2 CONTAINS SQL;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -775,75 +637,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode
diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_0102.result b/mysql-test/suite/funcs_1/r/innodb_trig_0102.result
index 86c2d2521ac..5ca24acf0bf 100644
--- a/mysql-test/suite/funcs_1/r/innodb_trig_0102.result
+++ b/mysql-test/suite/funcs_1/r/innodb_trig_0102.result
@@ -348,13 +348,13 @@ for each row set @test_var2='trig1_a';
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema like 'trig_db%'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
trig_db1 trig1_a t1
trig_db1 trig1_b t1
trig_db2 trig2 t1
-mtr ts_insert test_suppressions
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
insert into trig_db2.t1 (f1,f2) values ('insert to db2 t1 from db1',352);
diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result
index 62c8e0d06db..33e58f50ec1 100644
--- a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result
+++ b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result
@@ -90,10 +90,10 @@ f1
Trigger 3.5.4.1
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema = 'db_drop'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
-mtr ts_insert test_suppressions
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1 order by f1;
f1
@@ -151,12 +151,8 @@ Select * from t1;
f1
Trigger 3.5.4.4
Drop database db_drop4;
-Show databases;
-Database
-information_schema
-mtr
-mysql
-test
+Show databases like 'db_drop4';
+Database (db_drop4)
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result
index bc0b101f90a..a335e135a4f 100644
--- a/mysql-test/suite/funcs_1/r/innodb_views.result
+++ b/mysql-test/suite/funcs_1/r/innodb_views.result
@@ -21367,7 +21367,7 @@ ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check Error Table 'test.v1' doesn't exist
-test.v1 check error Corrupt
+test.v1 check status Operation failed
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
@@ -22824,7 +22824,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.7320508075689
+ABC 1.73205080756888
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -22842,7 +22842,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
SELECT SQRT('DEF');
SQRT('DEF')
0
@@ -22862,7 +22862,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
CREATE TABLE t2 AS SELECT f1, SQRT(f2) my_sqrt FROM t1;
SELECT * FROM t2 order by 2;
f1 ABC
diff --git a/mysql-test/suite/funcs_1/r/is_columns_innodb.result b/mysql-test/suite/funcs_1/r/is_columns_innodb.result
index 27a00ebf10d..73a74e4d7a2 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_innodb.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_innodb.result
@@ -485,7 +485,7 @@ NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1
NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob select,insert,update,references
NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL test tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -510,32 +510,32 @@ NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) u
NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
NULL test tb3 f119 2  NO char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
NULL test tb3 f120 3  NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
@@ -609,33 +609,33 @@ NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000
NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f191 16 88.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f192 17 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f193 18 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f195 20 55.5 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f196 21 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f197 22 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f199 24 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f200 25 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f201 26 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f204 29 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f205 30 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f206 31 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f207 32 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f208 33 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f209 34 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f212 37 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f213 38 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f214 39 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f215 40 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f216 41 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -652,7 +652,7 @@ NULL test tb4 f238 55 NULL YES varchar 0 0 NULL NULL latin1 latin1_swedish_ci va
NULL test tb4 f239 56 NULL YES varchar 20000 20000 NULL NULL latin1 latin1_bin varchar(20000) select,insert,update,references
NULL test tb4 f240 57 NULL YES varchar 2000 2000 NULL NULL latin1 latin1_swedish_ci varchar(2000) select,insert,update,references
NULL test tb4 f241 58 NULL YES char 100 100 NULL NULL latin1 latin1_swedish_ci char(100) select,insert,update,references
-NULL test1 tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -677,32 +677,32 @@ NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30)
NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
@@ -762,11 +762,7 @@ NULL date NULL NULL
NULL datetime NULL NULL
NULL decimal NULL NULL
NULL double NULL NULL
-NULL double unsigned NULL NULL
-NULL double unsigned zerofill NULL NULL
NULL float NULL NULL
-NULL float unsigned NULL NULL
-NULL float unsigned zerofill NULL NULL
NULL int NULL NULL
NULL mediumint NULL NULL
NULL smallint NULL NULL
@@ -910,33 +906,33 @@ NULL test tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb2 f73 double NULL NULL NULL NULL double
-NULL test tb2 f74 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f74 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f75 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f76 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f77 double NULL NULL NULL NULL double
-NULL test tb2 f78 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f78 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f79 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f80 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f81 float NULL NULL NULL NULL float
-NULL test tb2 f82 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f82 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f83 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f84 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb2 f85 float NULL NULL NULL NULL float
NULL test tb2 f86 float NULL NULL NULL NULL float
-NULL test tb2 f87 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f88 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f87 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f88 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f89 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f90 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f91 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f92 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb2 f93 float NULL NULL NULL NULL float
NULL test tb2 f94 double NULL NULL NULL NULL double
-NULL test tb2 f95 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f96 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f95 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f96 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f97 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f98 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f99 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f100 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f101 date NULL NULL NULL NULL date
NULL test tb2 f102 time NULL NULL NULL NULL time
NULL test tb2 f103 datetime NULL NULL NULL NULL datetime
@@ -1019,33 +1015,33 @@ NULL test tb4 f187 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb4 f188 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test tb4 f189 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb4 f190 double NULL NULL NULL NULL double
-NULL test tb4 f191 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f192 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f193 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f191 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f192 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f193 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f194 double NULL NULL NULL NULL double
-NULL test tb4 f195 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f196 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f197 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f195 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f196 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f197 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f198 float NULL NULL NULL NULL float
-NULL test tb4 f199 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f200 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f201 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f199 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f200 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f201 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb4 f202 float NULL NULL NULL NULL float
NULL test tb4 f203 float NULL NULL NULL NULL float
-NULL test tb4 f204 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f205 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f206 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f207 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f208 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f209 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f204 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f205 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f206 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f207 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f208 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f209 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb4 f210 float NULL NULL NULL NULL float
NULL test tb4 f211 double NULL NULL NULL NULL double
-NULL test tb4 f212 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f213 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f214 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f215 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f216 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f217 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f212 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f213 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f214 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f215 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f216 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f217 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f218 date NULL NULL NULL NULL date
NULL test tb4 f219 time NULL NULL NULL NULL time
NULL test tb4 f220 datetime NULL NULL NULL NULL datetime
@@ -1077,33 +1073,33 @@ NULL test1 tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test1 tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test1 tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test1 tb2 f73 double NULL NULL NULL NULL double
-NULL test1 tb2 f74 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f74 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f75 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f76 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f77 double NULL NULL NULL NULL double
-NULL test1 tb2 f78 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f78 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f79 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f80 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f81 float NULL NULL NULL NULL float
-NULL test1 tb2 f82 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f82 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f83 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f84 float NULL NULL NULL NULL float unsigned zerofill
NULL test1 tb2 f85 float NULL NULL NULL NULL float
NULL test1 tb2 f86 float NULL NULL NULL NULL float
-NULL test1 tb2 f87 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f88 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f87 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f88 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f89 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f90 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f91 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f92 float NULL NULL NULL NULL float unsigned zerofill
NULL test1 tb2 f93 float NULL NULL NULL NULL float
NULL test1 tb2 f94 double NULL NULL NULL NULL double
-NULL test1 tb2 f95 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f96 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f95 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f96 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f97 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f98 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f99 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f100 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f101 date NULL NULL NULL NULL date
NULL test1 tb2 f102 time NULL NULL NULL NULL time
NULL test1 tb2 f103 datetime NULL NULL NULL NULL datetime
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result
index 94aa75c6db2..ccb94c63d46 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is.result
@@ -166,7 +166,7 @@ NULL information_schema PROCESSLIST HOST 3 NO varchar 64 192 NULL NULL utf8 utf
NULL information_schema PROCESSLIST ID 1 0 NO bigint NULL NULL 19 0 NULL NULL bigint(4) select
NULL information_schema PROCESSLIST INFO 8 NULL YES longtext 4294967295 4294967295 NULL NULL utf8 utf8_general_ci longtext select
NULL information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
-NULL information_schema PROCESSLIST TIME 6 0 NO bigint NULL NULL 19 0 NULL NULL bigint(7) select
+NULL information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL int(7) select
NULL information_schema PROCESSLIST USER 2 NO varchar 16 48 NULL NULL utf8 utf8_general_ci varchar(16) select
NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NULL YES varchar 512 1536 NULL NULL utf8 utf8_general_ci varchar(512) select
NULL information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select
@@ -340,6 +340,7 @@ ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML;
COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
NULL bigint NULL NULL
NULL datetime NULL NULL
+NULL int NULL NULL
--> CHAR(0) is allowed (see manual), and here both CHARACHTER_* values
--> are 0, which is intended behavior, and the result of 0 / 0 IS NULL
SELECT CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
@@ -519,7 +520,7 @@ NULL information_schema PROCESSLIST ID bigint NULL NULL NULL NULL bigint(4)
3.0000 information_schema PROCESSLIST HOST varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema PROCESSLIST DB varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema PROCESSLIST COMMAND varchar 16 48 utf8 utf8_general_ci varchar(16)
-NULL information_schema PROCESSLIST TIME bigint NULL NULL NULL NULL bigint(7)
+NULL information_schema PROCESSLIST TIME int NULL NULL NULL NULL int(7)
3.0000 information_schema PROCESSLIST STATE varchar 64 192 utf8 utf8_general_ci varchar(64)
1.0000 information_schema PROCESSLIST INFO longtext 4294967295 4294967295 utf8 utf8_general_ci longtext
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_memory.result b/mysql-test/suite/funcs_1/r/is_columns_memory.result
index 9bcf7887c16..513d7bdfac6 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_memory.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_memory.result
@@ -466,7 +466,7 @@ NULL test tb1 f55 47 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0
NULL test tb1 f56 48 0000000099 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test tb1 f57 49 99 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) select,insert,update,references
NULL test tb1 f58 50 99 NO decimal NULL NULL 64 0 NULL NULL decimal(64,0) select,insert,update,references
-NULL test tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -491,32 +491,32 @@ NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) u
NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
NULL test tb3 f119 2  NO char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
NULL test tb3 f120 3  NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
@@ -584,33 +584,33 @@ NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000
NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f191 16 88.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f192 17 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f193 18 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f195 20 55.5 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f196 21 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f197 22 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f199 24 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f200 25 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f201 26 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f204 29 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f205 30 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f206 31 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f207 32 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f208 33 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f209 34 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f212 37 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f213 38 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f214 39 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f215 40 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f216 41 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -626,7 +626,7 @@ NULL test tb4 f238 55 NULL YES varchar 25000 25000 NULL NULL latin1 latin1_bin v
NULL test tb4 f239 56 NULL YES varbinary 0 0 NULL NULL NULL NULL varbinary(0) select,insert,update,references
NULL test tb4 f240 57 NULL YES varchar 1200 1200 NULL NULL latin1 latin1_swedish_ci varchar(1200) select,insert,update,references
NULL test tb4 f241 53 NULL YES char 255 255 NULL NULL latin1 latin1_swedish_ci char(255) select,insert,update,references
-NULL test1 tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -651,32 +651,32 @@ NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30)
NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
@@ -728,11 +728,7 @@ NULL date NULL NULL
NULL datetime NULL NULL
NULL decimal NULL NULL
NULL double NULL NULL
-NULL double unsigned NULL NULL
-NULL double unsigned zerofill NULL NULL
NULL float NULL NULL
-NULL float unsigned NULL NULL
-NULL float unsigned zerofill NULL NULL
NULL int NULL NULL
NULL mediumint NULL NULL
NULL smallint NULL NULL
@@ -866,33 +862,33 @@ NULL test tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb2 f73 double NULL NULL NULL NULL double
-NULL test tb2 f74 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f74 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f75 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f76 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f77 double NULL NULL NULL NULL double
-NULL test tb2 f78 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f78 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f79 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f80 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f81 float NULL NULL NULL NULL float
-NULL test tb2 f82 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f82 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f83 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f84 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb2 f85 float NULL NULL NULL NULL float
NULL test tb2 f86 float NULL NULL NULL NULL float
-NULL test tb2 f87 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f88 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f87 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f88 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f89 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f90 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f91 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f92 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb2 f93 float NULL NULL NULL NULL float
NULL test tb2 f94 double NULL NULL NULL NULL double
-NULL test tb2 f95 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f96 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f95 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f96 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f97 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f98 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f99 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f100 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f101 date NULL NULL NULL NULL date
NULL test tb2 f102 time NULL NULL NULL NULL time
NULL test tb2 f103 datetime NULL NULL NULL NULL datetime
@@ -969,33 +965,33 @@ NULL test tb4 f187 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb4 f188 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test tb4 f189 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb4 f190 double NULL NULL NULL NULL double
-NULL test tb4 f191 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f192 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f193 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f191 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f192 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f193 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f194 double NULL NULL NULL NULL double
-NULL test tb4 f195 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f196 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f197 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f195 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f196 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f197 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f198 float NULL NULL NULL NULL float
-NULL test tb4 f199 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f200 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f201 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f199 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f200 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f201 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb4 f202 float NULL NULL NULL NULL float
NULL test tb4 f203 float NULL NULL NULL NULL float
-NULL test tb4 f204 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f205 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f206 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f207 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f208 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f209 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f204 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f205 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f206 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f207 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f208 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f209 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb4 f210 float NULL NULL NULL NULL float
NULL test tb4 f211 double NULL NULL NULL NULL double
-NULL test tb4 f212 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f213 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f214 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f215 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f216 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f217 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f212 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f213 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f214 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f215 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f216 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f217 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f218 date NULL NULL NULL NULL date
NULL test tb4 f219 time NULL NULL NULL NULL time
NULL test tb4 f220 datetime NULL NULL NULL NULL datetime
@@ -1026,33 +1022,33 @@ NULL test1 tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test1 tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test1 tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test1 tb2 f73 double NULL NULL NULL NULL double
-NULL test1 tb2 f74 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f74 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f75 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f76 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f77 double NULL NULL NULL NULL double
-NULL test1 tb2 f78 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f78 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f79 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f80 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f81 float NULL NULL NULL NULL float
-NULL test1 tb2 f82 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f82 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f83 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f84 float NULL NULL NULL NULL float unsigned zerofill
NULL test1 tb2 f85 float NULL NULL NULL NULL float
NULL test1 tb2 f86 float NULL NULL NULL NULL float
-NULL test1 tb2 f87 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f88 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f87 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f88 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f89 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f90 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f91 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f92 float NULL NULL NULL NULL float unsigned zerofill
NULL test1 tb2 f93 float NULL NULL NULL NULL float
NULL test1 tb2 f94 double NULL NULL NULL NULL double
-NULL test1 tb2 f95 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f96 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f95 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f96 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f97 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f98 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f99 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f100 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f101 date NULL NULL NULL NULL date
NULL test1 tb2 f102 time NULL NULL NULL NULL time
NULL test1 tb2 f103 datetime NULL NULL NULL NULL datetime
diff --git a/mysql-test/suite/funcs_1/r/is_columns_myisam.result b/mysql-test/suite/funcs_1/r/is_columns_myisam.result
index de047728826..a95ca4f0ebf 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_myisam.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_myisam.result
@@ -514,7 +514,7 @@ NULL test tb1 f6 6 NULL YES mediumtext 16777215 16777215 NULL NULL latin1 latin1
NULL test tb1 f7 7 NULL YES longtext 4294967295 4294967295 NULL NULL latin1 latin1_swedish_ci longtext select,insert,update,references
NULL test tb1 f8 8 NULL YES tinyblob 255 255 NULL NULL NULL NULL tinyblob select,insert,update,references
NULL test tb1 f9 9 NULL YES blob 65535 65535 NULL NULL NULL NULL blob select,insert,update,references
-NULL test tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -547,32 +547,32 @@ NULL test tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) u
NULL test tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb3 f118 1 a NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
NULL test tb3 f119 2  NO char 1 1 NULL NULL latin1 latin1_bin char(1) select,insert,update,references
NULL test tb3 f120 3  NO char 1 1 NULL NULL latin1 latin1_swedish_ci char(1) select,insert,update,references
@@ -646,33 +646,33 @@ NULL test tb4 f187 12 000000000000000000000000000000009.000000000000000000000000
NULL test tb4 f188 13 0000000009 NO decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test tb4 f189 14 000000000000000000000000000000009.000000000000000000000000000000 NO decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test tb4 f190 15 88.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f191 16 88.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f192 17 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f193 18 00000000000000000088.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f191 16 88.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f192 17 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f193 18 00000000000000000088.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f194 19 55.5 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f195 20 55.5 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f196 21 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f197 22 00000000000000000055.5 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f195 20 55.5 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f196 21 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f197 22 00000000000000000055.5 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f198 23 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f199 24 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f200 25 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f201 26 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f199 24 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f200 25 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f201 26 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb4 f202 27 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb4 f203 28 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test tb4 f204 29 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f205 30 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f206 31 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f207 32 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f208 33 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f209 34 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f204 29 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f205 30 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f206 31 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f207 32 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f208 33 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f209 34 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test tb4 f210 35 NULL YES float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test tb4 f211 36 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test tb4 f212 37 NULL YES float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test tb4 f213 38 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test tb4 f214 39 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f215 40 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test tb4 f216 41 NULL YES float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test tb4 f217 42 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f212 37 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test tb4 f213 38 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test tb4 f214 39 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f215 40 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test tb4 f216 41 NULL YES float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test tb4 f217 42 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test tb4 f218 43 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test tb4 f219 44 NULL YES time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test tb4 f220 45 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -698,7 +698,7 @@ NULL test tb4 f239 64 NULL YES varbinary 1000 1000 NULL NULL NULL NULL varbinary
NULL test tb4 f240 65 NULL YES varchar 120 120 NULL NULL latin1 latin1_swedish_ci varchar(120) select,insert,update,references
NULL test tb4 f241 66 NULL YES char 100 100 NULL NULL latin1 latin1_swedish_ci char(100) select,insert,update,references
NULL test tb4 f242 67 NULL YES bit NULL NULL 30 NULL NULL NULL bit(30) select,insert,update,references
-NULL test1 tb2 f100 42 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f100 42 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f101 43 2000-01-01 NO date NULL NULL NULL NULL NULL NULL date select,insert,update,references
NULL test1 tb2 f102 44 00:00:20 NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL test1 tb2 f103 45 0002-02-02 00:00:00 NO datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
@@ -731,32 +731,32 @@ NULL test1 tb2 f70 12 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30)
NULL test1 tb2 f71 13 NULL YES decimal NULL NULL 10 0 NULL NULL decimal(10,0) unsigned zerofill select,insert,update,references
NULL test1 tb2 f72 14 NULL YES decimal NULL NULL 63 30 NULL NULL decimal(63,30) unsigned zerofill select,insert,update,references
NULL test1 tb2 f73 15 NULL YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f74 16 NULL YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f75 17 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f76 18 NULL YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f74 16 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f75 17 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f76 18 NULL YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f77 19 7.7 YES double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f78 20 7.7 YES double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f79 21 00000000000000000007.7 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f80 22 00000000000000000008.8 YES double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f78 20 7.7 YES double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f79 21 00000000000000000007.7 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f80 22 00000000000000000008.8 YES double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
NULL test1 tb2 f81 23 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f82 24 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f83 25 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f84 26 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f82 24 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f83 25 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f84 26 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test1 tb2 f85 27 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test1 tb2 f86 28 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
-NULL test1 tb2 f87 29 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f88 30 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f89 31 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f90 32 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f91 33 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f92 34 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f87 29 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f88 30 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f89 31 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f90 32 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f91 33 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f92 34 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test1 tb2 f93 35 8.8 NO float NULL NULL 12 NULL NULL NULL float select,insert,update,references
NULL test1 tb2 f94 36 8.8 NO double NULL NULL 22 NULL NULL NULL double select,insert,update,references
-NULL test1 tb2 f95 37 8.8 NO float unsigned NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
-NULL test1 tb2 f96 38 8.8 NO double unsigned NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
-NULL test1 tb2 f97 39 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
-NULL test1 tb2 f98 40 00000000000000000008.8 NO double unsigned zerofill NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
-NULL test1 tb2 f99 41 0000000008.8 NO float unsigned zerofill NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f95 37 8.8 NO float NULL NULL 12 NULL NULL NULL float unsigned select,insert,update,references
+NULL test1 tb2 f96 38 8.8 NO double NULL NULL 22 NULL NULL NULL double unsigned select,insert,update,references
+NULL test1 tb2 f97 39 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
+NULL test1 tb2 f98 40 00000000000000000008.8 NO double NULL NULL 22 NULL NULL NULL double unsigned zerofill select,insert,update,references
+NULL test1 tb2 f99 41 0000000008.8 NO float NULL NULL 12 NULL NULL NULL float unsigned zerofill select,insert,update,references
NULL test4 t6 f1 1 NULL YES char 20 20 NULL NULL latin1 latin1_swedish_ci char(20) select,insert,update,references
NULL test4 t6 f2 2 NULL YES char 25 25 NULL NULL latin1 latin1_swedish_ci char(25) select,insert,update,references
NULL test4 t6 f3 3 NULL YES date NULL NULL NULL NULL NULL NULL date select,insert,update,references
@@ -817,11 +817,7 @@ NULL date NULL NULL
NULL datetime NULL NULL
NULL decimal NULL NULL
NULL double NULL NULL
-NULL double unsigned NULL NULL
-NULL double unsigned zerofill NULL NULL
NULL float NULL NULL
-NULL float unsigned NULL NULL
-NULL float unsigned zerofill NULL NULL
NULL int NULL NULL
NULL mediumint NULL NULL
NULL smallint NULL NULL
@@ -963,33 +959,33 @@ NULL test tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb2 f73 double NULL NULL NULL NULL double
-NULL test tb2 f74 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f74 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f75 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f76 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f77 double NULL NULL NULL NULL double
-NULL test tb2 f78 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f78 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f79 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f80 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f81 float NULL NULL NULL NULL float
-NULL test tb2 f82 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f82 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f83 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f84 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb2 f85 float NULL NULL NULL NULL float
NULL test tb2 f86 float NULL NULL NULL NULL float
-NULL test tb2 f87 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f88 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f87 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f88 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f89 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f90 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f91 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f92 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb2 f93 float NULL NULL NULL NULL float
NULL test tb2 f94 double NULL NULL NULL NULL double
-NULL test tb2 f95 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb2 f96 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f95 float NULL NULL NULL NULL float unsigned
+NULL test tb2 f96 double NULL NULL NULL NULL double unsigned
+NULL test tb2 f97 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f98 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb2 f99 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb2 f100 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb2 f101 date NULL NULL NULL NULL date
NULL test tb2 f102 time NULL NULL NULL NULL time
NULL test tb2 f103 datetime NULL NULL NULL NULL datetime
@@ -1080,33 +1076,33 @@ NULL test tb4 f187 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb4 f188 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test tb4 f189 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test tb4 f190 double NULL NULL NULL NULL double
-NULL test tb4 f191 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f192 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f193 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f191 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f192 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f193 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f194 double NULL NULL NULL NULL double
-NULL test tb4 f195 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f196 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f197 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f195 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f196 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f197 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f198 float NULL NULL NULL NULL float
-NULL test tb4 f199 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f200 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f201 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f199 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f200 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f201 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb4 f202 float NULL NULL NULL NULL float
NULL test tb4 f203 float NULL NULL NULL NULL float
-NULL test tb4 f204 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f205 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f206 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f207 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f208 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f209 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f204 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f205 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f206 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f207 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f208 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f209 float NULL NULL NULL NULL float unsigned zerofill
NULL test tb4 f210 float NULL NULL NULL NULL float
NULL test tb4 f211 double NULL NULL NULL NULL double
-NULL test tb4 f212 float unsigned NULL NULL NULL NULL float unsigned
-NULL test tb4 f213 double unsigned NULL NULL NULL NULL double unsigned
-NULL test tb4 f214 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f215 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test tb4 f216 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test tb4 f217 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f212 float NULL NULL NULL NULL float unsigned
+NULL test tb4 f213 double NULL NULL NULL NULL double unsigned
+NULL test tb4 f214 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f215 double NULL NULL NULL NULL double unsigned zerofill
+NULL test tb4 f216 float NULL NULL NULL NULL float unsigned zerofill
+NULL test tb4 f217 double NULL NULL NULL NULL double unsigned zerofill
NULL test tb4 f218 date NULL NULL NULL NULL date
NULL test tb4 f219 time NULL NULL NULL NULL time
NULL test tb4 f220 datetime NULL NULL NULL NULL datetime
@@ -1147,33 +1143,33 @@ NULL test1 tb2 f70 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test1 tb2 f71 decimal NULL NULL NULL NULL decimal(10,0) unsigned zerofill
NULL test1 tb2 f72 decimal NULL NULL NULL NULL decimal(63,30) unsigned zerofill
NULL test1 tb2 f73 double NULL NULL NULL NULL double
-NULL test1 tb2 f74 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f75 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f76 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f74 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f75 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f76 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f77 double NULL NULL NULL NULL double
-NULL test1 tb2 f78 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f79 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f80 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f78 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f79 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f80 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f81 float NULL NULL NULL NULL float
-NULL test1 tb2 f82 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f83 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f84 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f82 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f83 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f84 float NULL NULL NULL NULL float unsigned zerofill
NULL test1 tb2 f85 float NULL NULL NULL NULL float
NULL test1 tb2 f86 float NULL NULL NULL NULL float
-NULL test1 tb2 f87 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f88 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f89 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f90 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f91 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f92 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f87 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f88 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f89 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f90 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f91 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f92 float NULL NULL NULL NULL float unsigned zerofill
NULL test1 tb2 f93 float NULL NULL NULL NULL float
NULL test1 tb2 f94 double NULL NULL NULL NULL double
-NULL test1 tb2 f95 float unsigned NULL NULL NULL NULL float unsigned
-NULL test1 tb2 f96 double unsigned NULL NULL NULL NULL double unsigned
-NULL test1 tb2 f97 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f98 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
-NULL test1 tb2 f99 float unsigned zerofill NULL NULL NULL NULL float unsigned zerofill
-NULL test1 tb2 f100 double unsigned zerofill NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f95 float NULL NULL NULL NULL float unsigned
+NULL test1 tb2 f96 double NULL NULL NULL NULL double unsigned
+NULL test1 tb2 f97 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f98 double NULL NULL NULL NULL double unsigned zerofill
+NULL test1 tb2 f99 float NULL NULL NULL NULL float unsigned zerofill
+NULL test1 tb2 f100 double NULL NULL NULL NULL double unsigned zerofill
NULL test1 tb2 f101 date NULL NULL NULL NULL date
NULL test1 tb2 f102 time NULL NULL NULL NULL time
NULL test1 tb2 f103 datetime NULL NULL NULL NULL datetime
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
index 9d1f316a9bf..2f1f61c0525 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
@@ -48,7 +48,7 @@ NULL mysql event last_executed 10 NULL YES datetime NULL NULL NULL NULL NULL NUL
NULL mysql event modified 9 0000-00-00 00:00:00 NO timestamp NULL NULL NULL NULL NULL NULL timestamp select,insert,update,references
NULL mysql event name 2 NO char 64 192 NULL NULL utf8 utf8_general_ci char(64) PRI select,insert,update,references
NULL mysql event on_completion 14 DROP NO enum 8 24 NULL NULL utf8 utf8_general_ci enum('DROP','PRESERVE') select,insert,update,references
-NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) select,insert,update,references
+NULL mysql event originator 17 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
NULL mysql event sql_mode 15 NO set 478 1434 NULL NULL utf8 utf8_general_ci 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') select,insert,update,references
NULL mysql event starts 11 NULL YES datetime NULL NULL NULL NULL NULL NULL datetime select,insert,update,references
NULL mysql event status 13 ENABLED NO enum 18 54 NULL NULL utf8 utf8_general_ci enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') select,insert,update,references
@@ -60,7 +60,7 @@ NULL mysql func type 4 NULL NO enum 9 27 NULL NULL utf8 utf8_general_ci enum('fu
NULL mysql general_log argument 6 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
NULL mysql general_log command_type 5 NULL NO varchar 64 192 NULL NULL utf8 utf8_general_ci varchar(64) select,insert,update,references
NULL mysql general_log event_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
-NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
+NULL mysql general_log server_id 4 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
NULL mysql general_log thread_id 3 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
NULL mysql general_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
NULL mysql help_category help_category_id 1 NULL NO smallint NULL NULL 5 0 NULL NULL smallint(5) unsigned PRI select,insert,update,references
@@ -150,7 +150,7 @@ NULL mysql slow_log lock_time 4 NULL NO time NULL NULL NULL NULL NULL NULL time
NULL mysql slow_log query_time 3 NULL NO time NULL NULL NULL NULL NULL NULL time select,insert,update,references
NULL mysql slow_log rows_examined 6 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
NULL mysql slow_log rows_sent 5 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
-NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(11) select,insert,update,references
+NULL mysql slow_log server_id 10 NULL NO int NULL NULL 10 0 NULL NULL int(10) unsigned select,insert,update,references
NULL mysql slow_log sql_text 11 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
NULL mysql slow_log start_time 1 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
NULL mysql slow_log user_host 2 NULL NO mediumtext 16777215 16777215 NULL NULL utf8 utf8_general_ci mediumtext select,insert,update,references
@@ -329,7 +329,7 @@ NULL mysql event ends datetime NULL NULL NULL NULL datetime
3.0000 mysql event on_completion enum 8 24 utf8 utf8_general_ci enum('DROP','PRESERVE')
3.0000 mysql event sql_mode set 478 1434 utf8 utf8_general_ci 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')
3.0000 mysql event comment char 64 192 utf8 utf8_bin char(64)
-NULL mysql event originator int NULL NULL NULL NULL int(10)
+NULL mysql event originator int NULL NULL NULL NULL int(10) unsigned
1.0000 mysql event time_zone char 64 64 latin1 latin1_swedish_ci char(64)
3.0000 mysql event character_set_client char 32 96 utf8 utf8_bin char(32)
3.0000 mysql event collation_connection char 32 96 utf8 utf8_bin char(32)
@@ -342,7 +342,7 @@ NULL mysql func ret tinyint NULL NULL NULL NULL tinyint(1)
NULL mysql general_log event_time timestamp NULL NULL NULL NULL timestamp
1.0000 mysql general_log user_host mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext
NULL mysql general_log thread_id int NULL NULL NULL NULL int(11)
-NULL mysql general_log server_id int NULL NULL NULL NULL int(11)
+NULL mysql general_log server_id int NULL NULL NULL NULL int(10) unsigned
3.0000 mysql general_log command_type varchar 64 192 utf8 utf8_general_ci varchar(64)
1.0000 mysql general_log argument mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext
NULL mysql help_category help_category_id smallint NULL NULL NULL NULL smallint(5) unsigned
@@ -434,7 +434,7 @@ NULL mysql slow_log rows_examined int NULL NULL NULL NULL int(11)
3.0000 mysql slow_log db varchar 512 1536 utf8 utf8_general_ci varchar(512)
NULL mysql slow_log last_insert_id int NULL NULL NULL NULL int(11)
NULL mysql slow_log insert_id int NULL NULL NULL NULL int(11)
-NULL mysql slow_log server_id int NULL NULL NULL NULL int(11)
+NULL mysql slow_log server_id int NULL NULL NULL NULL int(10) unsigned
1.0000 mysql slow_log sql_text mediumtext 16777215 16777215 utf8 utf8_general_ci mediumtext
3.0000 mysql tables_priv Host char 60 180 utf8 utf8_bin char(60)
3.0000 mysql tables_priv Db char 64 192 utf8 utf8_bin char(64)
diff --git a/mysql-test/suite/funcs_1/r/memory_func_view.result b/mysql-test/suite/funcs_1/r/memory_func_view.result
index 9a2b0a6a293..4e48d9412d1 100644
--- a/mysql-test/suite/funcs_1/r/memory_func_view.result
+++ b/mysql-test/suite/funcs_1/r/memory_func_view.result
@@ -5246,7 +5246,7 @@ WHERE select_id = 1 OR select_id IS NULL order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
@@ -5260,7 +5260,7 @@ WHERE select_id = 1 OR select_id IS NULL) order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
diff --git a/mysql-test/suite/funcs_1/r/memory_storedproc_08.result b/mysql-test/suite/funcs_1/r/memory_storedproc_08.result
index 2740a2cafa8..7f08a77ef09 100644
--- a/mysql-test/suite/funcs_1/r/memory_storedproc_08.result
+++ b/mysql-test/suite/funcs_1/r/memory_storedproc_08.result
@@ -104,7 +104,7 @@ END//
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -209,75 +209,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode NO_ENGINE_SUBSTITUTION
@@ -391,7 +322,7 @@ ALTER FUNCTION fn_2 MODIFIES SQL DATA;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -496,75 +427,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode NO_ENGINE_SUBSTITUTION
@@ -671,7 +533,7 @@ ALTER FUNCTION fn_2 CONTAINS SQL;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -776,75 +638,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode NO_ENGINE_SUBSTITUTION
diff --git a/mysql-test/suite/funcs_1/r/memory_trig_0102.result b/mysql-test/suite/funcs_1/r/memory_trig_0102.result
index a95702debcd..c39370dde69 100644
--- a/mysql-test/suite/funcs_1/r/memory_trig_0102.result
+++ b/mysql-test/suite/funcs_1/r/memory_trig_0102.result
@@ -349,13 +349,13 @@ for each row set @test_var2='trig1_a';
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema like 'trig_db%'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
trig_db1 trig1_a t1
trig_db1 trig1_b t1
trig_db2 trig2 t1
-mtr ts_insert test_suppressions
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
insert into trig_db2.t1 (f1,f2) values ('insert to db2 t1 from db1',352);
diff --git a/mysql-test/suite/funcs_1/r/memory_trig_0407.result b/mysql-test/suite/funcs_1/r/memory_trig_0407.result
index feb0017b86b..2f76f5544b9 100644
--- a/mysql-test/suite/funcs_1/r/memory_trig_0407.result
+++ b/mysql-test/suite/funcs_1/r/memory_trig_0407.result
@@ -91,10 +91,10 @@ f1
Trigger 3.5.4.1
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema = 'db_drop'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
-mtr ts_insert test_suppressions
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1 order by f1;
f1
@@ -152,12 +152,8 @@ Select * from t1;
f1
Trigger 3.5.4.4
Drop database db_drop4;
-Show databases;
-Database
-information_schema
-mtr
-mysql
-test
+Show databases like 'db_drop4';
+Database (db_drop4)
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result
index 2eba325db23..ccbd086b71f 100644
--- a/mysql-test/suite/funcs_1/r/memory_views.result
+++ b/mysql-test/suite/funcs_1/r/memory_views.result
@@ -21369,7 +21369,7 @@ ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check Error Table 'test.v1' doesn't exist
-test.v1 check error Corrupt
+test.v1 check status Operation failed
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
@@ -22826,7 +22826,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.7320508075689
+ABC 1.73205080756888
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -22844,7 +22844,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
SELECT SQRT('DEF');
SQRT('DEF')
0
@@ -22864,7 +22864,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
CREATE TABLE t2 AS SELECT f1, SQRT(f2) my_sqrt FROM t1;
SELECT * FROM t2 order by 2;
f1 ABC
diff --git a/mysql-test/suite/funcs_1/r/myisam_func_view.result b/mysql-test/suite/funcs_1/r/myisam_func_view.result
index 9a2b0a6a293..4e48d9412d1 100644
--- a/mysql-test/suite/funcs_1/r/myisam_func_view.result
+++ b/mysql-test/suite/funcs_1/r/myisam_func_view.result
@@ -5246,7 +5246,7 @@ WHERE select_id = 1 OR select_id IS NULL order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
@@ -5260,7 +5260,7 @@ WHERE select_id = 1 OR select_id IS NULL) order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
diff --git a/mysql-test/suite/funcs_1/r/myisam_storedproc_08.result b/mysql-test/suite/funcs_1/r/myisam_storedproc_08.result
index 2740a2cafa8..7f08a77ef09 100644
--- a/mysql-test/suite/funcs_1/r/myisam_storedproc_08.result
+++ b/mysql-test/suite/funcs_1/r/myisam_storedproc_08.result
@@ -104,7 +104,7 @@ END//
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -209,75 +209,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode NO_ENGINE_SUBSTITUTION
@@ -391,7 +322,7 @@ ALTER FUNCTION fn_2 MODIFIES SQL DATA;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -496,75 +427,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode NO_ENGINE_SUBSTITUTION
@@ -671,7 +533,7 @@ ALTER FUNCTION fn_2 CONTAINS SQL;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -776,75 +638,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode NO_ENGINE_SUBSTITUTION
diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_0102.result b/mysql-test/suite/funcs_1/r/myisam_trig_0102.result
index a95702debcd..c39370dde69 100644
--- a/mysql-test/suite/funcs_1/r/myisam_trig_0102.result
+++ b/mysql-test/suite/funcs_1/r/myisam_trig_0102.result
@@ -349,13 +349,13 @@ for each row set @test_var2='trig1_a';
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema like 'trig_db%'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
trig_db1 trig1_a t1
trig_db1 trig1_b t1
trig_db2 trig2 t1
-mtr ts_insert test_suppressions
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
insert into trig_db2.t1 (f1,f2) values ('insert to db2 t1 from db1',352);
diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result
index feb0017b86b..2f76f5544b9 100644
--- a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result
+++ b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result
@@ -91,10 +91,10 @@ f1
Trigger 3.5.4.1
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema = 'db_drop'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
-mtr ts_insert test_suppressions
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1 order by f1;
f1
@@ -152,12 +152,8 @@ Select * from t1;
f1
Trigger 3.5.4.4
Drop database db_drop4;
-Show databases;
-Database
-information_schema
-mtr
-mysql
-test
+Show databases like 'db_drop4';
+Database (db_drop4)
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
diff --git a/mysql-test/suite/funcs_1/r/myisam_views.result b/mysql-test/suite/funcs_1/r/myisam_views.result
index 3fcd8113df5..9b07a0ae45b 100644
--- a/mysql-test/suite/funcs_1/r/myisam_views.result
+++ b/mysql-test/suite/funcs_1/r/myisam_views.result
@@ -23044,7 +23044,7 @@ ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check Error Table 'test.v1' doesn't exist
-test.v1 check error Corrupt
+test.v1 check status Operation failed
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
@@ -24528,7 +24528,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.7320508075689
+ABC 1.73205080756888
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -24546,7 +24546,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
SELECT SQRT('DEF');
SQRT('DEF')
0
@@ -24566,7 +24566,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
CREATE TABLE t2 AS SELECT f1, SQRT(f2) my_sqrt FROM t1;
SELECT * FROM t2 order by 2;
f1 ABC
diff --git a/mysql-test/suite/funcs_1/r/ndb_func_view.result b/mysql-test/suite/funcs_1/r/ndb_func_view.result
index 1547c5461be..4beb0c8aaf2 100644
--- a/mysql-test/suite/funcs_1/r/ndb_func_view.result
+++ b/mysql-test/suite/funcs_1/r/ndb_func_view.result
@@ -5245,7 +5245,7 @@ WHERE select_id = 1 OR select_id IS NULL order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
@@ -5259,7 +5259,7 @@ WHERE select_id = 1 OR select_id IS NULL) order by id;
sqrt(my_bigint) my_bigint id
NULL NULL 1
NULL -9223372036854775808 2
-3037000499.976 9223372036854775807 3
+3037000499.97605 9223372036854775807 3
0 0 4
NULL -1 5
2 4 6
diff --git a/mysql-test/suite/funcs_1/r/ndb_storedproc_08.result b/mysql-test/suite/funcs_1/r/ndb_storedproc_08.result
index 7bffd77d9c6..2e504af6ed4 100644
--- a/mysql-test/suite/funcs_1/r/ndb_storedproc_08.result
+++ b/mysql-test/suite/funcs_1/r/ndb_storedproc_08.result
@@ -103,7 +103,7 @@ END//
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -208,75 +208,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode
@@ -390,7 +321,7 @@ ALTER FUNCTION fn_2 MODIFIES SQL DATA;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -495,75 +426,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode
@@ -670,7 +532,7 @@ ALTER FUNCTION fn_2 CONTAINS SQL;
... now check what is stored:
-----------------------------
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SPECIFIC_NAME fn_1
ROUTINE_CATALOG NULL
ROUTINE_SCHEMA db_storedproc
@@ -775,75 +637,6 @@ DEFINER root@localhost
CHARACTER_SET_CLIENT latin1
COLLATION_CONNECTION latin1_swedish_ci
DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME add_suppression
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME add_suppression
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN INSERT INTO test_suppressions (pattern) VALUES (pattern); END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_testcase
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_testcase
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name != 'timestamp' ORDER BY VARIABLE_NAME; SELECT * FROM INFORMATION_SCHEMA.SCHEMATA; SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='test'; SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY tables_in_mysql; SELECT CONCAT(table_schema, '.', table_name) AS columns_in_mysql, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, character_set_name, collation_name, column_type, column_key, extra, column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema='mysql' AND table_name != 'ndb_apply_status' ORDER BY columns_in_mysql; checksum table mysql.columns_priv, mysql.db, mysql.func, mysql.help_category, mysql.help_keyword, mysql.help_relation, mysql.host, mysql.proc, mysql.procs_priv, mysql.tables_priv, mysql.time_zone, mysql.time_zone_leap_second, mysql.time_zone_name, mysql.time_zone_transition, mysql.time_zone_transition_type, mysql.user; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
-SPECIFIC_NAME check_warnings
-ROUTINE_CATALOG NULL
-ROUTINE_SCHEMA mtr
-ROUTINE_NAME check_warnings
-ROUTINE_TYPE PROCEDURE
-DTD_IDENTIFIER NULL
-ROUTINE_BODY SQL
-ROUTINE_DEFINITION BEGIN DECLARE `pos` bigint unsigned; SET SQL_LOG_BIN=0; UPDATE error_log el, global_suppressions gs SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP gs.pattern; UPDATE error_log el, test_suppressions ts SET suspicious=0 WHERE el.suspicious=1 AND el.line REGEXP ts.pattern; SELECT COUNT(*) INTO @num_warnings FROM error_log WHERE suspicious=1; IF @num_warnings > 0 THEN SELECT file_name, line FROM error_log WHERE suspicious=1; SELECT 2 INTO result; ELSE SELECT 0 INTO RESULT; END IF; TRUNCATE test_suppressions; DROP TABLE error_log; END
-EXTERNAL_NAME NULL
-EXTERNAL_LANGUAGE NULL
-PARAMETER_STYLE SQL
-IS_DETERMINISTIC NO
-SQL_DATA_ACCESS CONTAINS SQL
-SQL_PATH NULL
-SECURITY_TYPE DEFINER
-CREATED <modified>
-LAST_ALTERED <created>
-SQL_MODE
-ROUTINE_COMMENT
-DEFINER root@localhost
-CHARACTER_SET_CLIENT latin1
-COLLATION_CONNECTION latin1_swedish_ci
-DATABASE_COLLATION latin1_swedish_ci
SHOW CREATE FUNCTION fn_1;
Function fn_1
sql_mode
diff --git a/mysql-test/suite/funcs_1/r/ndb_trig_0102.result b/mysql-test/suite/funcs_1/r/ndb_trig_0102.result
index 86c2d2521ac..5ca24acf0bf 100644
--- a/mysql-test/suite/funcs_1/r/ndb_trig_0102.result
+++ b/mysql-test/suite/funcs_1/r/ndb_trig_0102.result
@@ -348,13 +348,13 @@ for each row set @test_var2='trig1_a';
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema like 'trig_db%'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
trig_db1 trig1_a t1
trig_db1 trig1_b t1
trig_db2 trig2 t1
-mtr ts_insert test_suppressions
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
insert into trig_db2.t1 (f1,f2) values ('insert to db2 t1 from db1',352);
diff --git a/mysql-test/suite/funcs_1/r/ndb_trig_0407.result b/mysql-test/suite/funcs_1/r/ndb_trig_0407.result
index 62c8e0d06db..33e58f50ec1 100644
--- a/mysql-test/suite/funcs_1/r/ndb_trig_0407.result
+++ b/mysql-test/suite/funcs_1/r/ndb_trig_0407.result
@@ -90,10 +90,10 @@ f1
Trigger 3.5.4.1
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
-from information_schema.triggers order by trigger_name;
+from information_schema.triggers
+where trigger_schema = 'db_drop'
+ order by trigger_name;
trigger_schema trigger_name event_object_table
-mtr gs_insert global_suppressions
-mtr ts_insert test_suppressions
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1 order by f1;
f1
@@ -151,12 +151,8 @@ Select * from t1;
f1
Trigger 3.5.4.4
Drop database db_drop4;
-Show databases;
-Database
-information_schema
-mtr
-mysql
-test
+Show databases like 'db_drop4';
+Database (db_drop4)
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
diff --git a/mysql-test/suite/funcs_1/r/ndb_views.result b/mysql-test/suite/funcs_1/r/ndb_views.result
index 671ef590f4d..b75f4955986 100644
--- a/mysql-test/suite/funcs_1/r/ndb_views.result
+++ b/mysql-test/suite/funcs_1/r/ndb_views.result
@@ -21367,7 +21367,7 @@ ERROR 42S02: Table 'test.v1' doesn't exist
CHECK TABLE v1;
Table Op Msg_type Msg_text
test.v1 check Error Table 'test.v1' doesn't exist
-test.v1 check error Corrupt
+test.v1 check status Operation failed
DESCRIBE v1;
ERROR 42S02: Table 'test.v1' doesn't exist
EXPLAIN SELECT * FROM v1;
@@ -22824,7 +22824,7 @@ f1 f2
ABC 3
SELECT * FROM v1 order by 2;
f1 my_sqrt
-ABC 1.7320508075689
+ABC 1.73205080756888
ALTER TABLE t1 CHANGE COLUMN f2 f2 VARCHAR(30);
INSERT INTO t1 SET f1 = 'ABC', f2 = 'DEF';
DESCRIBE t1;
@@ -22842,7 +22842,7 @@ ABC DEF
SELECT * FROM v1 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
SELECT SQRT('DEF');
SQRT('DEF')
0
@@ -22862,7 +22862,7 @@ my_sqrt double YES NULL
SELECT * FROM v2 order by 2;
f1 my_sqrt
ABC 0
-ABC 1.7320508075689
+ABC 1.73205080756888
CREATE TABLE t2 AS SELECT f1, SQRT(f2) my_sqrt FROM t1;
SELECT * FROM t2 order by 2;
f1 ABC
diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
index d862b7424e0..3d341292be1 100644
--- a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
+++ b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
@@ -27,7 +27,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
@@ -97,7 +97,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
diff --git a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result
index 56230a0f806..2932467be2a 100644
--- a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result
+++ b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result
@@ -27,7 +27,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
@@ -97,7 +97,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
diff --git a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result
index 482e143fd23..b0cae801fd6 100644
--- a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result
+++ b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result
@@ -17,7 +17,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
diff --git a/mysql-test/suite/funcs_1/r/processlist_val_ps.result b/mysql-test/suite/funcs_1/r/processlist_val_ps.result
index 72ca56d0ffa..4e4cfa57e36 100644
--- a/mysql-test/suite/funcs_1/r/processlist_val_ps.result
+++ b/mysql-test/suite/funcs_1/r/processlist_val_ps.result
@@ -17,7 +17,7 @@ PROCESSLIST CREATE TEMPORARY TABLE `PROCESSLIST` (
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
- `TIME` bigint(7) NOT NULL DEFAULT '0',
+ `TIME` int(7) NOT NULL DEFAULT '0',
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext
) ENGINE=MyISAM DEFAULT CHARSET=utf8
diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result
index fd5b090e6fb..7e21ddf1544 100644
--- a/mysql-test/suite/funcs_1/r/storedproc.result
+++ b/mysql-test/suite/funcs_1/r/storedproc.result
@@ -92,11 +92,8 @@ END//
ERROR 42000: Identifier name 'sp1_thisisaveryverylongname234872934_thisisaveryverylongnameabcde' is too long
CALL sp1_thisisaveryverylongname234872934_thisisaveryverylongnameabcde( 'abc' );
ERROR 42000: Identifier name 'sp1_thisisaveryverylongname234872934_thisisaveryverylongnameabcde' is too long
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1( f1 BINARY )
LANGUAGE SQL DETERMINISTIC SQL SECURITY INVOKER COMMENT 'this is simple'
@@ -109,12 +106,9 @@ CALL sp1( 34 );
3
Warnings:
Warning 1265 Data truncated for column 'f1' at row 1
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc sp1 PROCEDURE root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1( f1 BLOB )
LANGUAGE SQL NOT DETERMINISTIC SQL SECURITY INVOKER COMMENT 'this is simple'
@@ -125,12 +119,9 @@ END//
CALL sp1( 34 );
@v1
34
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc sp1 PROCEDURE root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1( f1 INT )
LANGUAGE SQL NOT DETERMINISTIC SQL SECURITY INVOKER COMMENT 'this is simple'
@@ -141,12 +132,9 @@ END//
CALL sp1( 34 );
@v1
34
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc sp1 PROCEDURE root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1( f1 DECIMAL(256, 30) )
LANGUAGE SQL NOT DETERMINISTIC SQL SECURITY INVOKER COMMENT 'this is simple'
@@ -185,13 +173,10 @@ LANGUAGE SQL NOT DETERMINISTIC SQL SECURITY INVOKER COMMENT 'this is simple'
BEGIN
RETURN f1;
END//
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc sproc_1 PROCEDURE root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-SHOW FUNCTION STATUS;
+SHOW FUNCTION STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc func_1 FUNCTION root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
UPDATE t1_aux SET f1 = NULL;
@@ -1431,12 +1416,9 @@ f1
value1
Warnings:
Note 1291 Column '' has duplicated value 'value1' in ENUM
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc sp1 PROCEDURE root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1( f1 SET("value1", "value1") )
LANGUAGE SQL NOT DETERMINISTIC SQL SECURITY INVOKER COMMENT 'this is simple'
@@ -1451,12 +1433,9 @@ value1
Warnings:
Note 1291 Column '' has duplicated value 'value1' in SET
Warning 1265 Data truncated for column 'f1' at row 1
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc sp1 PROCEDURE root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1( f1 ENUM("value1", "value1") )
LANGUAGE SQL NOT DETERMINISTIC SQL SECURITY INVOKER COMMENT 'this is simple'
@@ -1470,12 +1449,9 @@ f1
value1
Warnings:
Note 1291 Column '' has duplicated value 'value1' in ENUM
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
db_storedproc sp1 PROCEDURE root@localhost <modified> <created> INVOKER this is simple latin1 latin1_swedish_ci latin1_swedish_ci
-mtr add_suppression PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_testcase PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
-mtr check_warnings PROCEDURE root@localhost <modified> <created> DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
DROP PROCEDURE IF EXISTS sp1;
CREATE PROCEDURE sp1( f1 TEXT ) LANGUAGE SQL SELECT f1;
CALL sp1( 'abc' );
diff --git a/mysql-test/suite/funcs_1/storedproc/storedproc_08_show.inc b/mysql-test/suite/funcs_1/storedproc/storedproc_08_show.inc
index 962d9242675..d6fd397561c 100644
--- a/mysql-test/suite/funcs_1/storedproc/storedproc_08_show.inc
+++ b/mysql-test/suite/funcs_1/storedproc/storedproc_08_show.inc
@@ -2,15 +2,14 @@
#
# used from .../storedproc_08.inc to show all created / altered routines
-let $message= ... now check what is stored:;
---source include/show_msg.inc
+--echo
+--echo ... now check what is stored:
+--echo -----------------------------
--vertical_results
-#--replace_column 16 "YYYY-MM-DD hh:mm:ss" 17 "YYYY-MM-DD hh:mm:ss"
-
--replace_column 16 <modified> 17 <created>
-SELECT * FROM information_schema.routines;
+SELECT * FROM information_schema.routines where routine_schema = 'db_storedproc';
SHOW CREATE FUNCTION fn_1;
diff --git a/mysql-test/suite/funcs_1/t/disabled.def b/mysql-test/suite/funcs_1/t/disabled.def
index fbc48fa0a43..69a69c60708 100644
--- a/mysql-test/suite/funcs_1/t/disabled.def
+++ b/mysql-test/suite/funcs_1/t/disabled.def
@@ -10,4 +10,7 @@
#
##############################################################################
-ndb_trig_1011ext: Bug#32656 NDB: Duplicate key error aborts transaction in handler. Doesn't talk back to SQL \ No newline at end of file
+ndb_trig_1011ext: Bug#32656 NDB: Duplicate key error aborts transaction in handler. Doesn't talk back to SQL
+charset_collation_1: Bug#38346, Bug#40209, Bug#40545, Bug#40618
+charset_collation_2: Bug#38346, Bug#40209, Bug#40545, Bug#40618
+charset_collation_3: Bug#38346, Bug#40209, Bug#40545, Bug#40618
diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test
index cc45101fbed..6877b751ed2 100644
--- a/mysql-test/suite/funcs_1/t/storedproc.test
+++ b/mysql-test/suite/funcs_1/t/storedproc.test
@@ -72,7 +72,7 @@ delimiter ;//
CALL sp1_thisisaveryverylongname234872934_thisisaveryverylongnameabcde( 'abc' );
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--disable_warnings
DROP PROCEDURE IF EXISTS sp1;
@@ -90,7 +90,7 @@ delimiter ;//
CALL sp1( 34 );
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--disable_warnings
DROP PROCEDURE IF EXISTS sp1;
@@ -108,7 +108,7 @@ delimiter ;//
CALL sp1( 34 );
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--disable_warnings
DROP PROCEDURE IF EXISTS sp1;
@@ -126,7 +126,7 @@ delimiter ;//
CALL sp1( 34 );
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--disable_warnings
DROP PROCEDURE IF EXISTS sp1;
@@ -191,9 +191,9 @@ BEGIN
END//
delimiter ;//
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--replace_column 5 <modified> 6 <created>
-SHOW FUNCTION STATUS;
+SHOW FUNCTION STATUS WHERE db = 'db_storedproc';
let $test_value = 1.7976931348623157493578e+308;
--source suite/funcs_1/storedproc/param_check.inc
@@ -245,7 +245,7 @@ delimiter ;//
CALL sp1( "value1" );
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--disable_warnings
DROP PROCEDURE IF EXISTS sp1;
@@ -262,7 +262,7 @@ delimiter ;//
CALL sp1( "value1, value1" );
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--disable_warnings
DROP PROCEDURE IF EXISTS sp1;
@@ -279,7 +279,7 @@ delimiter ;//
CALL sp1( "value1" );
--replace_column 5 <modified> 6 <created>
-SHOW PROCEDURE STATUS;
+SHOW PROCEDURE STATUS WHERE db = 'db_storedproc';
--disable_warnings
DROP PROCEDURE IF EXISTS sp1;
diff --git a/mysql-test/suite/funcs_1/triggers/triggers_0102.inc b/mysql-test/suite/funcs_1/triggers/triggers_0102.inc
index 3afbc3f7aa9..e49bcead9f1 100644
--- a/mysql-test/suite/funcs_1/triggers/triggers_0102.inc
+++ b/mysql-test/suite/funcs_1/triggers/triggers_0102.inc
@@ -458,7 +458,9 @@ let $message= Testcase 3.5.2.1/2/3:;
create trigger trig_db2.trig2 before insert on trig_db2.t1
for each row set @test_var3='trig2';
select trigger_schema, trigger_name, event_object_table
- from information_schema.triggers order by trigger_name;
+ from information_schema.triggers
+ where trigger_schema like 'trig_db%'
+ order by trigger_name;
set @test_var1= '', @test_var2= '', @test_var3= '';
insert into t1 (f1,f2) values ('insert to db1 t1 from db1',352);
diff --git a/mysql-test/suite/funcs_1/triggers/triggers_0407.inc b/mysql-test/suite/funcs_1/triggers/triggers_0407.inc
index a5e3c180a71..af45017ae6a 100644
--- a/mysql-test/suite/funcs_1/triggers/triggers_0407.inc
+++ b/mysql-test/suite/funcs_1/triggers/triggers_0407.inc
@@ -60,7 +60,9 @@ let $message= Testcase 3.5.4.1:;
connection con1_super;
drop trigger trg1;
select trigger_schema, trigger_name, event_object_table
- from information_schema.triggers order by trigger_name;
+ from information_schema.triggers
+ where trigger_schema = 'db_drop'
+ order by trigger_name;
connection con1_general;
Insert into t1 values ('Insert no trigger 3.5.4.1');
Select * from t1 order by f1;
@@ -160,7 +162,7 @@ let $message= Testcase 3.5.4.4:;
Select * from t1;
connection con1_super;
Drop database db_drop4;
- Show databases;
+ Show databases like 'db_drop4';
select trigger_schema, trigger_name, event_object_table
from information_schema.triggers
where information_schema.triggers.trigger_name='trg4';
diff --git a/mysql-test/suite/funcs_2/charset/charset_master.test b/mysql-test/suite/funcs_2/charset/charset_master.test
index 09e24e2c246..99ca4564a0b 100644
--- a/mysql-test/suite/funcs_2/charset/charset_master.test
+++ b/mysql-test/suite/funcs_2/charset/charset_master.test
@@ -86,6 +86,15 @@ let $check_std_csets= 1;
let $check_ucs2_csets= 1;
let $check_utf8_csets= 1;
+# Bug#32784: Timeout in test "innodb_charset": InnoDB much slower
+# than other handlers
+# NOTE: We turn autocommit off to improve the performance of the innodb variant
+# of this test. Per Innobase's recommendation.
+
+--disable_query_log
+SET autocommit=0;
+--enable_query_log
+
#
# Check all charsets/collation combinations
#
diff --git a/mysql-test/suite/ibmdb2i/include/have_i61.inc b/mysql-test/suite/ibmdb2i/include/have_i61.inc
new file mode 100644
index 00000000000..84b9a17c1d8
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/include/have_i61.inc
@@ -0,0 +1,20 @@
+# Check for IBM i 6.1 or later
+--disable_query_log
+system uname -rv > $MYSQLTEST_VARDIR/tmp/version;
+--disable_warnings
+drop table if exists uname_vr;
+--enable_warnings
+create temporary table uname_vr (r int, v int);
+--disable_warnings
+eval LOAD DATA INFILE "$MYSQLTEST_VARDIR/tmp/version" into table uname_vr fields terminated by ' ';
+--enable_warnings
+let $ok = `select count(*) from uname_vr where v > 5`;
+drop table uname_vr;
+remove_file $MYSQLTEST_VARDIR/tmp/version;
+--enable_query_log
+if (!$ok)
+{
+ skip "Need IBM i 6.1 or later";
+}
+
+
diff --git a/mysql-test/suite/ibmdb2i/include/have_ibmdb2i.inc b/mysql-test/suite/ibmdb2i/include/have_ibmdb2i.inc
new file mode 100644
index 00000000000..f3ef0b4f1ac
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/include/have_ibmdb2i.inc
@@ -0,0 +1,6 @@
+if (!`SELECT count(*) FROM information_schema.engines WHERE
+ (support = 'YES' OR support = 'DEFAULT') AND
+ engine = 'ibmdb2i'`)
+{
+ skip Need ibmdb2i engine;
+}
diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44020.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44020.result
new file mode 100644
index 00000000000..ddf92db6bca
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44020.result
@@ -0,0 +1,11 @@
+create schema `A12345_@$#`;
+create table `A12345_@$#`.t1 (i int) engine=ibmdb2i;
+show create table `A12345_@$#`.t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `i` int(11) DEFAULT NULL
+) ENGINE=IBMDB2I DEFAULT CHARSET=latin1
+select * from `A12345_@$#`.t1;
+i
+drop table `A12345_@$#`.t1;
+drop schema `A12345_@$#`;
diff --git a/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44025.result b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44025.result
new file mode 100644
index 00000000000..10a3070fcc4
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/r/ibmdb2i_bug_44025.result
@@ -0,0 +1,4 @@
+create table t1 (c char(10) collate utf8_swedish_ci, index(c)) engine=ibmdb2i;
+drop table t1;
+create table t1 (c char(10) collate ucs2_swedish_ci, index(c)) engine=ibmdb2i;
+drop table t1;
diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44020.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44020.test
new file mode 100644
index 00000000000..09a7c75cfc0
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44020.test
@@ -0,0 +1,9 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source include/have_case_sensitive_file_system.inc;
+
+create schema `A12345_@$#`;
+create table `A12345_@$#`.t1 (i int) engine=ibmdb2i;
+show create table `A12345_@$#`.t1;
+select * from `A12345_@$#`.t1;
+drop table `A12345_@$#`.t1;
+drop schema `A12345_@$#`;
diff --git a/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44025.test b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44025.test
new file mode 100644
index 00000000000..9b033a2298f
--- /dev/null
+++ b/mysql-test/suite/ibmdb2i/t/ibmdb2i_bug_44025.test
@@ -0,0 +1,9 @@
+source suite/ibmdb2i/include/have_ibmdb2i.inc;
+source suite/ibmdb2i/include/have_i61.inc;
+
+
+create table t1 (c char(10) collate utf8_swedish_ci, index(c)) engine=ibmdb2i;
+drop table t1;
+
+create table t1 (c char(10) collate ucs2_swedish_ci, index(c)) engine=ibmdb2i;
+drop table t1;
diff --git a/mysql-test/suite/ndb/r/ndb_gis.result b/mysql-test/suite/ndb/r/ndb_gis.result
index 6c44c6fb822..374d702c408 100644
--- a/mysql-test/suite/ndb/r/ndb_gis.result
+++ b/mysql-test/suite/ndb/r/ndb_gis.result
@@ -292,7 +292,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.416666666667 25.416666666667)
+109 POINT(25.4166666666667 25.4166666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -326,8 +326,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.588527753042 17.426536064114)
-118 POINT(55.588527753042 17.426536064114)
+117 POINT(55.5885277530424 17.426536064114)
+118 POINT(55.5885277530424 17.426536064114)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
@@ -842,7 +842,7 @@ Note 1003 select astext(startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
fid AsText(Centroid(g))
108 POINT(15 15)
-109 POINT(25.416666666667 25.416666666667)
+109 POINT(25.4166666666667 25.4166666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
fid Area(g)
@@ -876,8 +876,8 @@ fid IsClosed(g)
116 0
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
fid AsText(Centroid(g))
-117 POINT(55.588527753042 17.426536064114)
-118 POINT(55.588527753042 17.426536064114)
+117 POINT(55.5885277530424 17.426536064114)
+118 POINT(55.5885277530424 17.426536064114)
119 POINT(2 2)
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
fid Area(g)
diff --git a/mysql-test/suite/ndb/r/ndb_restore.result b/mysql-test/suite/ndb/r/ndb_restore.result
index 48c32bc14b6..f6b50a1dfdc 100644
--- a/mysql-test/suite/ndb/r/ndb_restore.result
+++ b/mysql-test/suite/ndb/r/ndb_restore.result
@@ -131,8 +131,9 @@ create table t9 engine=myisam as select * from t9_c;
create table t10 engine=myisam as select * from t10_c;
ForceVarPart: 0
ForceVarPart: 1
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c;
ForceVarPart: 0
@@ -286,8 +287,9 @@ auto_increment
10001
ALTER TABLE t7_c
PARTITION BY LINEAR KEY (`dardtestard`);
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c;
select count(*) from t1;
@@ -490,8 +492,9 @@ select * from t9_c) a;
count(*)
3
drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c;
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
drop table if exists t2_c;
diff --git a/mysql-test/suite/ndb/r/ndb_restore_partition.result b/mysql-test/suite/ndb/r/ndb_restore_partition.result
index 58a35437a2e..b984c76a91d 100644
--- a/mysql-test/suite/ndb/r/ndb_restore_partition.result
+++ b/mysql-test/suite/ndb/r/ndb_restore_partition.result
@@ -125,8 +125,9 @@ create table t6 engine=myisam as select * from t6_c;
create table t7 engine=myisam as select * from t7_c;
create table t8 engine=myisam as select * from t8_c;
create table t9 engine=myisam as select * from t9_c;
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
select count(*) from t1;
@@ -244,8 +245,9 @@ PARTITION BY LINEAR HASH (`relatta`)
PARTITIONS 4;
ALTER TABLE t7_c
PARTITION BY LINEAR KEY (`dardtestard`);
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
select count(*) from t1;
@@ -448,8 +450,9 @@ select * from t9_c) a;
count(*)
3
drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
Create table test/def/t2_c failed: Translate frm error
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
diff --git a/mysql-test/suite/ndb/r/ndb_restore_print.result b/mysql-test/suite/ndb/r/ndb_restore_print.result
index 7ff15652b3f..fa52513e7d0 100644
--- a/mysql-test/suite/ndb/r/ndb_restore_print.result
+++ b/mysql-test/suite/ndb/r/ndb_restore_print.result
@@ -227,8 +227,9 @@ hex(h3) NULL
hex(i1) NULL
hex(i2) NULL
hex(i3) NULL
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
1;0x1;0x17;0x789A;0x789ABCDE;0xFEDC0001;127;255;32767;65535;2147483647;4294967295;9223372036854775807;18446744073709551615;1;12345678901234567890123456789012;123456789;1;12345678901234567890123456789012;123456789;0x12;0x123456789ABCDEF0;0x012345;0x12;0x123456789ABCDEF0;0x00123450
2;0x0;0x0;0x0;0x0;0x0;-128;0;-32768;0;-2147483648;0;-9223372036854775808;0;;;;;;;0x0;0x0;0x0;0x0;0x0;0x0
@@ -257,8 +258,9 @@ create table t4 (pk int key, a int) engine ndb;
insert into t2 values (1,11),(2,12),(3,13),(4,14),(5,15);
insert into t3 values (1,21),(2,22),(3,23),(4,24),(5,25);
insert into t4 values (1,31),(2,32),(3,33),(4,34),(5,35);
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
'1' '1' '12345678901234567890123456789012' '123456789' '1' '12345678901234567890123456789012' '123456789' '0x20' '0x123456789ABCDEF020' '0x012345000020' '0x1200000020' '0x123456789ABCDEF000000020' '0x00123450000020'
@@ -297,8 +299,9 @@ create table t1
insert into t1 values(1, 8388607, 16777215);
insert into t1 values(2, -8388608, 0);
insert into t1 values(3, -1, 1);
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
1;8388607;16777215
2;-8388608;0
diff --git a/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result b/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result
index 102a96a15f4..12a65a433a3 100644
--- a/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result
+++ b/mysql-test/suite/ndb_team/r/ndb_dd_backuprestore.result
@@ -27,8 +27,9 @@ pk1 c2 c3 hex(c4)
3 Sweden 498 1
4 Sweden 497 1
5 Sweden 496 1
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
DROP TABLE test.t1;
ALTER TABLESPACE table_space1
@@ -91,8 +92,9 @@ LENGTH(data)
SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2;
LENGTH(data)
16384
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
DROP TABLE test.t1;
DROP TABLE test.t2;
@@ -317,8 +319,9 @@ pk1 c2 c3 hex(c4)
248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1
247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1
246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
DROP TABLE test.t1;
DROP TABLE test.t2;
diff --git a/mysql-test/suite/ndb_team/t/ndb_autodiscover.test b/mysql-test/suite/ndb_team/t/ndb_autodiscover.test
index a2fb0c3b25f..9ded27cea31 100644
--- a/mysql-test/suite/ndb_team/t/ndb_autodiscover.test
+++ b/mysql-test/suite/ndb_team/t/ndb_autodiscover.test
@@ -1,6 +1,12 @@
-- source include/have_ndb.inc
-- source include/not_embedded.inc
+# Bug#41308: Test main.ndb_autodiscover.test doesn't work on Windows due
+# to 'grep' calls
+# Test is currently disabled on Windows via the next line until this bug
+# can be resolved.
+--source include/not_windows.inc
+
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
--enable_warnings
diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc
index 26375c72c0c..6963de90c83 100644
--- a/mysql-test/suite/parts/inc/partition_auto_increment.inc
+++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc
@@ -29,10 +29,11 @@ INSERT INTO t1 VALUES (5), (16);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (17);
INSERT INTO t1 VALUES (19), (NULL);
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (NULL), (10), (NULL);
if ($mysql_errno)
{
@@ -116,16 +117,17 @@ ENGINE=$engine
PARTITION BY HASH(c2)
PARTITIONS 2;
INSERT INTO t1 VALUES (1, NULL);
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_KEY, ER_DUP_ENTRY
INSERT INTO t1 VALUES (1, 1), (99, 99);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (1, NULL);
let $old_sql_mode = `select @@session.sql_mode`;
SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (1, 0);
if ($mysql_errno)
{
@@ -140,7 +142,7 @@ eval CREATE TABLE t1 (
ENGINE=$engine
PARTITION BY HASH(c2)
PARTITIONS 2;
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (1, 0);
if ($mysql_errno)
{
@@ -163,26 +165,27 @@ PARTITION BY HASH(c1)
PARTITIONS 2;
INSERT INTO t1 VALUES (2), (4), (NULL);
INSERT INTO t1 VALUES (0);
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_KEY, ER_DUP_ENTRY
INSERT INTO t1 VALUES (5), (16);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (17), (19), (NULL);
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (NULL), (10), (NULL);
if ($mysql_errno)
{
echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno;
}
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (NULL), (9);
if ($mysql_errno)
{
echo # ERROR (only OK if Archive) mysql_errno: $mysql_errno;
}
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (59), (55);
if ($mysql_errno)
{
@@ -270,7 +273,7 @@ SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AND TABLE_NAME='t1';
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AND TABLE_NAME='t1';
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (10);
if ($mysql_errno)
{
@@ -281,7 +284,7 @@ INSERT INTO t1 VALUES (NULL);
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AND TABLE_NAME='t1';
INSERT INTO t1 VALUES (NULL);
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (15);
if ($mysql_errno)
{
@@ -340,7 +343,7 @@ connection con1;
INSERT INTO t1 (c1) VALUES (NULL);
connection default;
-- echo # con default
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 (c1) VALUES (16);
if ($mysql_errno)
{
@@ -426,7 +429,7 @@ connection con1;
INSERT INTO t1 (c1) VALUES (NULL);
connection default;
-- echo # con default
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 (c1) VALUES (16);
if ($mysql_errno)
{
@@ -483,6 +486,7 @@ INSERT INTO t1 VALUES (1, 1);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0);
@@ -492,6 +496,7 @@ INSERT INTO t1 VALUES (2, 2);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (2, 22);
INSERT INTO t1 VALUES (2, NULL);
@@ -527,16 +532,18 @@ INSERT INTO t1 VALUES (1, 1);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (2, NULL);
INSERT INTO t1 VALUES (3, NULL);
INSERT INTO t1 VALUES (3, NULL), (2, 0), (2, NULL);
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (2, 2);
if (!$mysql_errno)
{
-echo # ERROR (only OK if Blackhole/NDB) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # ERROR (only OK if Blackhole/NDB) should give ER_DUP_KEY or ER_DUP_ENTRY;
+ echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (2, 22), (2, NULL);
SELECT * FROM t1 ORDER BY c1,c2;
@@ -550,7 +557,7 @@ eval CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (c1))
PARTITION BY HASH(c1)
PARTITIONS 2;
SHOW CREATE TABLE t1;
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 (c1) VALUES (4);
if ($mysql_errno)
{
@@ -568,7 +575,7 @@ let $old_sql_mode = `select @@session.sql_mode`;
SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
INSERT INTO t1 (c1) VALUES (300);
SHOW CREATE TABLE t1;
--- error 0, ER_DUP_KEY
+-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 (c1) VALUES (0);
if ($mysql_errno)
{
diff --git a/mysql-test/suite/parts/r/ndb_dd_backuprestore.result b/mysql-test/suite/parts/r/ndb_dd_backuprestore.result
index 102a96a15f4..12a65a433a3 100644
--- a/mysql-test/suite/parts/r/ndb_dd_backuprestore.result
+++ b/mysql-test/suite/parts/r/ndb_dd_backuprestore.result
@@ -27,8 +27,9 @@ pk1 c2 c3 hex(c4)
3 Sweden 498 1
4 Sweden 497 1
5 Sweden 496 1
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
DROP TABLE test.t1;
ALTER TABLESPACE table_space1
@@ -91,8 +92,9 @@ LENGTH(data)
SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2;
LENGTH(data)
16384
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
DROP TABLE test.t1;
DROP TABLE test.t2;
@@ -317,8 +319,9 @@ pk1 c2 c3 hex(c4)
248 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 4 1
247 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 6 1
246 TEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXASTEXAS, ITALY, Kyle, JO, JBM,TU 8 1
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
DROP TABLE test.t1;
DROP TABLE test.t2;
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result b/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result
index 7ab726136af..5d584e1da8b 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_2_innodb.result
@@ -86,7 +86,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -578,7 +578,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1085,7 +1085,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1588,7 +1588,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2087,7 +2087,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2597,7 +2597,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -3107,7 +3107,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -3607,7 +3607,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4100,7 +4100,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4592,7 +4592,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5099,7 +5099,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5602,7 +5602,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6101,7 +6101,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6611,7 +6611,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7121,7 +7121,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7621,7 +7621,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8115,7 +8115,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8623,7 +8623,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9146,7 +9146,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9665,7 +9665,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10180,7 +10180,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10706,7 +10706,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11232,7 +11232,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11748,7 +11748,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12257,7 +12257,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12765,7 +12765,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13288,7 +13288,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13807,7 +13807,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14322,7 +14322,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14848,7 +14848,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15374,7 +15374,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15890,7 +15890,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16401,7 +16401,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16894,7 +16894,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17402,7 +17402,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17906,7 +17906,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18406,7 +18406,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18917,7 +18917,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19428,7 +19428,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19929,7 +19929,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20423,7 +20423,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20916,7 +20916,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -21424,7 +21424,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -21928,7 +21928,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22428,7 +22428,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22939,7 +22939,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -23450,7 +23450,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -23951,7 +23951,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24445,7 +24445,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24938,7 +24938,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25446,7 +25446,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25950,7 +25950,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26450,7 +26450,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26961,7 +26961,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27472,7 +27472,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27973,7 +27973,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result b/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result
index 69f2bfa472e..dda69f141df 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_2_myisam.result
@@ -94,7 +94,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -617,7 +617,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1161,7 +1161,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1697,7 +1697,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2233,7 +2233,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2780,7 +2780,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -3327,7 +3327,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -3866,7 +3866,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4384,7 +4384,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4907,7 +4907,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5451,7 +5451,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5987,7 +5987,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6523,7 +6523,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7070,7 +7070,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7617,7 +7617,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8156,7 +8156,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_innodb.result b/mysql-test/suite/parts/r/partition_alter1_1_innodb.result
index eeb55488d93..075346cfe94 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_innodb.result
@@ -404,7 +404,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -896,7 +896,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1403,7 +1403,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1906,7 +1906,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2405,7 +2405,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2917,7 +2917,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -3427,7 +3427,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -3927,7 +3927,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4420,7 +4420,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4912,7 +4912,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5419,7 +5419,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5922,7 +5922,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6421,7 +6421,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6933,7 +6933,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7443,7 +7443,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7943,7 +7943,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8437,7 +8437,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8945,7 +8945,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9468,7 +9468,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9987,7 +9987,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10502,7 +10502,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11030,7 +11030,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11556,7 +11556,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12072,7 +12072,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12581,7 +12581,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13089,7 +13089,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13612,7 +13612,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14131,7 +14131,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14646,7 +14646,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15174,7 +15174,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15700,7 +15700,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16216,7 +16216,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_alter1_1_myisam.result b/mysql-test/suite/parts/r/partition_alter1_1_myisam.result
index 2137c37c3a2..9f616d04df3 100644
--- a/mysql-test/suite/parts/r/partition_alter1_1_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter1_1_myisam.result
@@ -253,7 +253,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -776,7 +776,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1320,7 +1320,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -1856,7 +1856,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2392,7 +2392,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -2941,7 +2941,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -3488,7 +3488,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4027,7 +4027,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4545,7 +4545,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5068,7 +5068,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5612,7 +5612,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6148,7 +6148,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6684,7 +6684,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7233,7 +7233,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7780,7 +7780,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8319,7 +8319,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_alter2_1_innodb.result b/mysql-test/suite/parts/r/partition_alter2_1_innodb.result
index 17d2c1384e0..fcccd52f571 100644
--- a/mysql-test/suite/parts/r/partition_alter2_1_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter2_1_innodb.result
@@ -3815,7 +3815,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4307,7 +4307,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4814,7 +4814,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5317,7 +5317,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5816,7 +5816,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6328,7 +6328,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6838,7 +6838,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7338,7 +7338,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7831,7 +7831,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8323,7 +8323,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8830,7 +8830,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9333,7 +9333,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9832,7 +9832,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10344,7 +10344,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10854,7 +10854,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11354,7 +11354,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11848,7 +11848,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12356,7 +12356,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12879,7 +12879,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13398,7 +13398,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13913,7 +13913,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14441,7 +14441,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14967,7 +14967,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15483,7 +15483,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15992,7 +15992,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16500,7 +16500,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17023,7 +17023,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17542,7 +17542,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18057,7 +18057,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18585,7 +18585,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19111,7 +19111,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19627,7 +19627,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27596,7 +27596,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28088,7 +28088,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28595,7 +28595,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29098,7 +29098,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29597,7 +29597,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30109,7 +30109,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30619,7 +30619,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31119,7 +31119,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31612,7 +31612,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32104,7 +32104,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32611,7 +32611,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33114,7 +33114,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33613,7 +33613,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34123,7 +34123,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34633,7 +34633,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -35133,7 +35133,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -35626,7 +35626,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36118,7 +36118,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36625,7 +36625,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -37128,7 +37128,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -37627,7 +37627,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -38139,7 +38139,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -38649,7 +38649,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -39149,7 +39149,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -39642,7 +39642,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -40134,7 +40134,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -40641,7 +40641,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -41144,7 +41144,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -41643,7 +41643,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -42153,7 +42153,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -42663,7 +42663,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -43163,7 +43163,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -43657,7 +43657,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -44165,7 +44165,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -44688,7 +44688,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -45207,7 +45207,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -45722,7 +45722,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -46250,7 +46250,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -46776,7 +46776,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -47292,7 +47292,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -47801,7 +47801,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -48309,7 +48309,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -48832,7 +48832,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -49351,7 +49351,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -49866,7 +49866,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -50392,7 +50392,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -50918,7 +50918,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -51434,7 +51434,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -51943,7 +51943,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -52451,7 +52451,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -52974,7 +52974,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -53493,7 +53493,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -54008,7 +54008,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -54536,7 +54536,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -55062,7 +55062,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -55578,7 +55578,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -56087,7 +56087,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -56595,7 +56595,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -57118,7 +57118,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -57637,7 +57637,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -58152,7 +58152,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -58678,7 +58678,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -59204,7 +59204,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -59720,7 +59720,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_alter2_1_myisam.result b/mysql-test/suite/parts/r/partition_alter2_1_myisam.result
index 0e0428af48e..902ce9711be 100644
--- a/mysql-test/suite/parts/r/partition_alter2_1_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter2_1_myisam.result
@@ -3971,7 +3971,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4494,7 +4494,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5038,7 +5038,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5574,7 +5574,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6110,7 +6110,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6659,7 +6659,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7206,7 +7206,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7745,7 +7745,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8263,7 +8263,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8786,7 +8786,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9330,7 +9330,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9866,7 +9866,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10402,7 +10402,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10951,7 +10951,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11498,7 +11498,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12037,7 +12037,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20311,7 +20311,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20834,7 +20834,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -21378,7 +21378,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -21914,7 +21914,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22450,7 +22450,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22999,7 +22999,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -23546,7 +23546,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24085,7 +24085,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24603,7 +24603,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25126,7 +25126,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25670,7 +25670,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26206,7 +26206,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26742,7 +26742,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27289,7 +27289,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27836,7 +27836,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28375,7 +28375,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28893,7 +28893,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29416,7 +29416,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29960,7 +29960,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30496,7 +30496,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31032,7 +31032,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31581,7 +31581,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32128,7 +32128,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32667,7 +32667,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33185,7 +33185,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33708,7 +33708,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34252,7 +34252,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34788,7 +34788,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -35324,7 +35324,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -35871,7 +35871,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36418,7 +36418,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36957,7 +36957,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_alter2_2_innodb.result b/mysql-test/suite/parts/r/partition_alter2_2_innodb.result
index e2cf04c35b3..cb9ea4ed60a 100644
--- a/mysql-test/suite/parts/r/partition_alter2_2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_alter2_2_innodb.result
@@ -3826,7 +3826,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4320,7 +4320,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4829,7 +4829,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5334,7 +5334,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5833,7 +5833,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6347,7 +6347,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6857,7 +6857,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7359,7 +7359,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7854,7 +7854,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8348,7 +8348,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8857,7 +8857,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9362,7 +9362,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9861,7 +9861,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10375,7 +10375,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10885,7 +10885,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11387,7 +11387,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11883,7 +11883,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12393,7 +12393,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12918,7 +12918,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13439,7 +13439,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13954,7 +13954,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14484,7 +14484,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15010,7 +15010,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15528,7 +15528,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16039,7 +16039,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16549,7 +16549,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17074,7 +17074,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17595,7 +17595,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18110,7 +18110,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18640,7 +18640,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19166,7 +19166,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19684,7 +19684,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27712,7 +27712,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28207,7 +28207,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28717,7 +28717,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29223,7 +29223,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29727,7 +29727,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30242,7 +30242,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30757,7 +30757,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31260,7 +31260,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31756,7 +31756,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32251,7 +32251,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32761,7 +32761,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33267,7 +33267,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33771,7 +33771,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34286,7 +34286,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34801,7 +34801,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -35304,7 +35304,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -35800,7 +35800,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36295,7 +36295,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36805,7 +36805,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -37311,7 +37311,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -37815,7 +37815,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -38330,7 +38330,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -38845,7 +38845,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -39348,7 +39348,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -39844,7 +39844,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -40339,7 +40339,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -40849,7 +40849,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -41355,7 +41355,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -41859,7 +41859,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -42374,7 +42374,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -42889,7 +42889,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -43392,7 +43392,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -43889,7 +43889,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -44400,7 +44400,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -44926,7 +44926,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -45448,7 +45448,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -45968,7 +45968,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -46499,7 +46499,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -47030,7 +47030,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -47549,7 +47549,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -48061,7 +48061,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -48572,7 +48572,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -49098,7 +49098,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -49620,7 +49620,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -50140,7 +50140,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -50671,7 +50671,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -51202,7 +51202,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -51721,7 +51721,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -52233,7 +52233,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -52744,7 +52744,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -53270,7 +53270,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -53792,7 +53792,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -54312,7 +54312,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -54843,7 +54843,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -55374,7 +55374,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -55893,7 +55893,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -56405,7 +56405,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -56916,7 +56916,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -57442,7 +57442,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -57964,7 +57964,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -58484,7 +58484,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -59015,7 +59015,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -59546,7 +59546,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -60065,7 +60065,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_alter2_2_myisam.result b/mysql-test/suite/parts/r/partition_alter2_2_myisam.result
index c63e8495f26..630ad0aaf08 100644
--- a/mysql-test/suite/parts/r/partition_alter2_2_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter2_2_myisam.result
@@ -3983,7 +3983,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -4508,7 +4508,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5054,7 +5054,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -5592,7 +5592,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6128,7 +6128,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -6679,7 +6679,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7226,7 +7226,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -7767,7 +7767,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8287,7 +8287,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8812,7 +8812,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9358,7 +9358,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9896,7 +9896,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10432,7 +10432,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10983,7 +10983,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11530,7 +11530,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12071,7 +12071,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20404,7 +20404,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20930,7 +20930,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -21477,7 +21477,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22016,7 +22016,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22557,7 +22557,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -23109,7 +23109,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -23661,7 +23661,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24203,7 +24203,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24724,7 +24724,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25250,7 +25250,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25797,7 +25797,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26336,7 +26336,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26877,7 +26877,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27429,7 +27429,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27981,7 +27981,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28523,7 +28523,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29044,7 +29044,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29570,7 +29570,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30117,7 +30117,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30656,7 +30656,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31197,7 +31197,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31749,7 +31749,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32301,7 +32301,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -32843,7 +32843,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33364,7 +33364,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -33890,7 +33890,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34437,7 +34437,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -34976,7 +34976,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -35517,7 +35517,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36069,7 +36069,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -36621,7 +36621,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -37163,7 +37163,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result
index ac39d038c56..7ef5ff88499 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result
@@ -28,6 +28,7 @@ AUTO_INCREMENT
INSERT INTO t1 VALUES (0);
INSERT INTO t1 VALUES (5), (16);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (17);
INSERT INTO t1 VALUES (19), (NULL);
INSERT INTO t1 VALUES (NULL), (10), (NULL);
@@ -144,6 +145,7 @@ PARTITIONS 2;
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (1, 1), (99, 99);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (1, NULL);
SET @@session.sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
INSERT INTO t1 VALUES (1, 0);
@@ -176,6 +178,7 @@ INSERT INTO t1 VALUES (2), (4), (NULL);
INSERT INTO t1 VALUES (0);
INSERT INTO t1 VALUES (5), (16);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (17), (19), (NULL);
INSERT INTO t1 VALUES (NULL), (10), (NULL);
INSERT INTO t1 VALUES (NULL), (9);
@@ -441,11 +444,13 @@ PARTITIONS 2;
INSERT INTO t1 VALUES (1, 0);
INSERT INTO t1 VALUES (1, 1);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (2, NULL), (3, 11), (3, NULL), (2, 0);
INSERT INTO t1 VALUES (2, NULL);
INSERT INTO t1 VALUES (2, 2);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (2, 22);
INSERT INTO t1 VALUES (2, NULL);
SELECT * FROM t1 ORDER BY c1,c2;
@@ -462,12 +467,14 @@ PARTITIONS 2;
INSERT INTO t1 VALUES (1, 0);
INSERT INTO t1 VALUES (1, 1);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (1, NULL);
INSERT INTO t1 VALUES (2, NULL);
INSERT INTO t1 VALUES (3, NULL);
INSERT INTO t1 VALUES (3, NULL), (2, 0), (2, NULL);
INSERT INTO t1 VALUES (2, 2);
# ERROR (only OK if Blackhole/NDB) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (2, 22), (2, NULL);
SELECT * FROM t1 ORDER BY c1,c2;
c1 c2
diff --git a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result
index 408f32cce78..5a1c5b06b36 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result
@@ -649,6 +649,7 @@ INSERT INTO t1 VALUES (3, NULL);
INSERT INTO t1 VALUES (3, NULL), (2, 0), (2, NULL);
INSERT INTO t1 VALUES (2, 2);
# ERROR (only OK if Blackhole/NDB) should give ER_DUP_KEY or ER_DUP_ENTRY
+# mysql_errno: 0
INSERT INTO t1 VALUES (2, 22), (2, NULL);
SELECT * FROM t1 ORDER BY c1,c2;
c1 c2
diff --git a/mysql-test/suite/parts/r/partition_basic_innodb.result b/mysql-test/suite/parts/r/partition_basic_innodb.result
index 15452792f3d..21c5d70e6e3 100644
--- a/mysql-test/suite/parts/r/partition_basic_innodb.result
+++ b/mysql-test/suite/parts/r/partition_basic_innodb.result
@@ -7538,7 +7538,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8030,7 +8030,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8537,7 +8537,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9040,7 +9040,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9539,7 +9539,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10051,7 +10051,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10565,7 +10565,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11065,7 +11065,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11558,7 +11558,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12050,7 +12050,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12557,7 +12557,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13060,7 +13060,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13559,7 +13559,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14071,7 +14071,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14585,7 +14585,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15085,7 +15085,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15578,7 +15578,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16086,7 +16086,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16609,7 +16609,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17128,7 +17128,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17643,7 +17643,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18171,7 +18171,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18701,7 +18701,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19217,7 +19217,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19731,7 +19731,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20223,7 +20223,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20730,7 +20730,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -21233,7 +21233,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -21732,7 +21732,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22242,7 +22242,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -22752,7 +22752,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -23252,7 +23252,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -23745,7 +23745,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24237,7 +24237,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -24744,7 +24744,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25247,7 +25247,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -25746,7 +25746,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26256,7 +26256,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -26766,7 +26766,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27266,7 +27266,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'PRIMARY'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -27759,7 +27759,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28267,7 +28267,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -28790,7 +28790,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29309,7 +29309,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -29824,7 +29824,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30350,7 +30350,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -30876,7 +30876,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -31392,7 +31392,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_basic_myisam.result b/mysql-test/suite/parts/r/partition_basic_myisam.result
index 84d623e63a2..f70dae13bb6 100644
--- a/mysql-test/suite/parts/r/partition_basic_myisam.result
+++ b/mysql-test/suite/parts/r/partition_basic_myisam.result
@@ -7774,7 +7774,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8293,7 +8293,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8833,7 +8833,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9365,7 +9365,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9897,7 +9897,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10442,7 +10442,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10989,7 +10989,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11524,7 +11524,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12043,7 +12043,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12562,7 +12562,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13102,7 +13102,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13634,7 +13634,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14166,7 +14166,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14709,7 +14709,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15252,7 +15252,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15787,7 +15787,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result b/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result
index 602a114c318..146b3d361fb 100644
--- a/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result
+++ b/mysql-test/suite/parts/r/partition_basic_symlink_myisam.result
@@ -8177,7 +8177,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -8725,7 +8725,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9289,7 +9289,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -9845,7 +9845,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10401,7 +10401,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -10966,7 +10966,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -11549,7 +11549,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12108,7 +12108,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -12638,7 +12638,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13186,7 +13186,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -13750,7 +13750,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14306,7 +14306,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -14862,7 +14862,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -15425,7 +15425,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16008,7 +16008,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -16567,7 +16567,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17091,7 +17091,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -17629,7 +17629,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18186,7 +18186,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -18730,7 +18730,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19274,7 +19274,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -19832,7 +19832,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
@@ -20381,7 +20381,7 @@ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
WHERE f_int1 IN (2,3);
-ERROR 23000: Can't write; duplicate key in table 't1'
+ERROR 23000: Duplicate entry '2-2' for key 'uidx1'
# check prerequisites-3 success: 1
# INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result
index 7672ac330fb..30ff27df298 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -329,11 +329,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -559,7 +559,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -793,7 +793,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result
index e85cbeba594..cd55ffbad03 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -329,11 +329,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -559,7 +559,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -793,7 +793,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result
index 1f7197abe6d..faf776e03a3 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -329,11 +329,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -559,7 +559,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -793,7 +793,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result
index cb5228bd78e..827f7a15c24 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -329,11 +329,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -559,7 +559,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -793,7 +793,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result b/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result
index a1d0b78aac4..45b674638e7 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result
index f8238bb9382..443453a2d70 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result
index 5f7ccc3ed51..49ccc7b1808 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result
index c72666f7717..6f34054428c 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result
index 66f9f852108..ac230e29c66 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result b/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result
index c27f769ad72..0a53e1b4a9b 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `tablea` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result
index 70020ee54a6..fc0390c238d 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result
index 7392056b7a5..da111137068 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result
index a71bbfea5e3..a1716ea36c8 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result
index 92b64e4d26c..6bdfa149de0 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -320,11 +320,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
@@ -541,7 +541,7 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
@@ -767,7 +767,7 @@ PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result b/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result
index b234de0efdb..8b9c5be1fb6 100644
--- a/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result
+++ b/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result
@@ -93,11 +93,11 @@ TableA CREATE TABLE `TableA` (
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
-ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
+ERROR HY000: REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
-ERROR HY000: When reorganising a set of partitions they must be in consecutive order
+ERROR HY000: When reorganizing a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
diff --git a/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc b/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
index 6a00dcc6e50..70e17cef9fe 100644
--- a/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
+++ b/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
@@ -83,4 +83,4 @@ sync_slave_with_master;
# will be created. You will need to go to the mysql-test dir and diff
# the files your self to see what is not matching
---exec diff $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql
+--diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql
diff --git a/mysql-test/suite/rpl/r/rpl_bug33931.result b/mysql-test/suite/rpl/r/rpl_bug33931.result
index 1b3f2cfc7dc..85c8fb0da9c 100644
--- a/mysql-test/suite/rpl/r/rpl_bug33931.result
+++ b/mysql-test/suite/rpl/r/rpl_bug33931.result
@@ -1,5 +1,5 @@
reset master;
-call mtr.add_suppression("Failed during slave.*thread initialization");
+call mtr.add_suppression("Failed during slave thread initialization");
stop slave;
reset slave;
SET GLOBAL debug="d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
@@ -23,8 +23,8 @@ Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
-Last_Errno 0
-Last_Error
+Last_Errno #
+Last_Error Failed during slave thread initialization
Skip_Counter 0
Exec_Master_Log_Pos 0
Relay_Log_Space #
@@ -41,6 +41,6 @@ Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
-Last_SQL_Errno 0
-Last_SQL_Error
+Last_SQL_Errno #
+Last_SQL_Error Failed during slave thread initialization
SET GLOBAL debug="";
diff --git a/mysql-test/suite/rpl/r/rpl_bug38694.result b/mysql-test/suite/rpl/r/rpl_bug38694.result
new file mode 100644
index 00000000000..711c4a91c03
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_bug38694.result
@@ -0,0 +1,6 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
diff --git a/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result b/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result
index 1753fc0cb2d..6c8d35619e5 100644
--- a/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result
+++ b/mysql-test/suite/rpl/r/rpl_deadlock_innodb.result
@@ -4,51 +4,57 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
+*** Prepare tables and data ***
CREATE TABLE t1 (a INT NOT NULL, KEY(a)) ENGINE=innodb;
-CREATE TABLE t2 (a INT NOT NULL, KEY(a)) ENGINE=innodb;
-CREATE TABLE t3 (a INT UNIQUE) ENGINE=innodb;
-CREATE TABLE t4 (a INT) ENGINE=innodb;
-show variables like 'slave_transaction_retries';
-Variable_name Value
-slave_transaction_retries 10
-show create table t1;
+CREATE TABLE t2 (a INT) ENGINE=innodb;
+CREATE TABLE t3 (a INT NOT NULL, KEY(a)) ENGINE=innodb;
+SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-show create table t2;
+SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
`a` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-show variables like 'slave_transaction_retries';
+SHOW VARIABLES LIKE 'slave_transaction_retries';
Variable_name Value
slave_transaction_retries 2
-stop slave;
-begin;
-insert into t2 values (0);
-insert into t1 values(1);
-commit;
-begin;
-select * from t1 for update;
+include/stop_slave.inc
+BEGIN;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (2), (2), (2), (2), (2), (2), (2), (2), (2), (2);
+INSERT INTO t3 VALUES (3);
+COMMIT;
+
+*** Test deadlock ***
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
a
-start slave;
-select * from t2 for update /* dl */;
-a
-commit;
-select * from t1;
+START SLAVE;
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+0
+COMMIT;
+SELECT * FROM t1;
a
1
-select * from t2 /* must be 1 */;
+SELECT * FROM t3;
a
-0
-show slave status;
+3
+SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
-Master_Port MASTER_MYPORT
+Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
@@ -83,38 +89,41 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
-stop slave;
-delete from t3;
-change master to master_log_pos=548;
-begin;
-select * from t2 for update;
+
+*** Test lock wait timeout ***
+include/stop_slave.inc
+DELETE FROM t2;
+CHANGE MASTER TO MASTER_LOG_POS=MASTER_POS_BEGIN;
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
a
+1
+START SLAVE;
+SELECT COUNT(*) FROM t2;
+COUNT(*)
0
-start slave;
-select count(*) from t3 /* must be zero */;
-count(*)
-0
-commit;
-select * from t1;
+COMMIT;
+include/start_slave.inc
+SELECT * FROM t1;
a
1
1
-select * from t2;
+SELECT * FROM t3;
a
-0
-0
-show slave status;
+3
+3
+SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
-Master_Port MASTER_MYPORT
+Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
-Slave_IO_Running #
+Slave_IO_Running Yes
Slave_SQL_Running Yes
Replicate_Do_DB
Replicate_Ignore_DB
@@ -138,47 +147,50 @@ Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
-Last_IO_Errno 0
-Last_IO_Error
+Last_IO_Errno #
+Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
-set @my_max_relay_log_size= @@global.max_relay_log_size;
-set global max_relay_log_size=0;
-stop slave;
-delete from t3;
-change master to master_log_pos=548;
-begin;
-select * from t2 for update;
+
+*** Test lock wait timeout and purged relay logs ***
+SET @my_max_relay_log_size= @@global.max_relay_log_size;
+SET global max_relay_log_size=0;
+include/stop_slave.inc
+DELETE FROM t2;
+CHANGE MASTER TO MASTER_LOG_POS=440;
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
a
+1
+1
+START SLAVE;
+SELECT COUNT(*) FROM t2;
+COUNT(*)
0
-0
-start slave;
-select count(*) from t3 /* must be zero */;
-count(*)
-0
-commit;
-select * from t1;
+COMMIT;
+include/start_slave.inc
+SELECT * FROM t1;
a
1
1
1
-select * from t2;
+SELECT * FROM t3;
a
-0
-0
-0
-show slave status;
+3
+3
+3
+SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
-Master_Port MASTER_MYPORT
+Master_Port MASTER_PORT
Connect_Retry 1
Master_Log_File master-bin.000001
Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
-Slave_IO_Running #
+Slave_IO_Running Yes
Slave_SQL_Running Yes
Replicate_Do_DB
Replicate_Ignore_DB
@@ -206,6 +218,8 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
-drop table t1,t2,t3,t4;
-set global max_relay_log_size= @my_max_relay_log_size;
+
+*** Clean up ***
+DROP TABLE t1,t2,t3;
+SET global max_relay_log_size= @my_max_relay_log_size;
End of 5.1 tests
diff --git a/mysql-test/suite/rpl/r/rpl_do_grant.result b/mysql-test/suite/rpl/r/rpl_do_grant.result
index f7f1ce66656..69bcfad4347 100644
--- a/mysql-test/suite/rpl/r/rpl_do_grant.result
+++ b/mysql-test/suite/rpl/r/rpl_do_grant.result
@@ -89,3 +89,81 @@ show grants for rpl_do_grant2@localhost;
ERROR 42000: There is no such grant defined for user 'rpl_do_grant2' on host 'localhost'
show grants for rpl_do_grant2@localhost;
ERROR 42000: There is no such grant defined for user 'rpl_do_grant2' on host 'localhost'
+DROP DATABASE IF EXISTS bug42217_db;
+CREATE DATABASE bug42217_db;
+GRANT CREATE ROUTINE ON bug42217_db.* TO 'create_rout_db'@'localhost'
+ IDENTIFIED BY 'create_rout_db' WITH GRANT OPTION;
+USE bug42217_db;
+CREATE FUNCTION upgrade_del_func() RETURNS CHAR(30)
+BEGIN
+RETURN "INSIDE upgrade_del_func()";
+END//
+USE bug42217_db;
+SELECT * FROM mysql.procs_priv;
+Host Db User Routine_name Routine_type Grantor Proc_priv Timestamp
+localhost bug42217_db create_rout_db upgrade_del_func FUNCTION create_rout_db@localhost Execute,Alter Routine #
+SELECT upgrade_del_func();
+upgrade_del_func()
+INSIDE upgrade_del_func()
+SELECT * FROM mysql.procs_priv;
+Host Db User Routine_name Routine_type Grantor Proc_priv Timestamp
+localhost bug42217_db create_rout_db upgrade_del_func FUNCTION create_rout_db@localhost Execute,Alter Routine #
+SHOW GRANTS FOR 'create_rout_db'@'localhost';
+Grants for create_rout_db@localhost
+GRANT USAGE ON *.* TO 'create_rout_db'@'localhost' IDENTIFIED BY PASSWORD '*08792480350CBA057BDE781B9DF183B263934601'
+GRANT CREATE ROUTINE ON `bug42217_db`.* TO 'create_rout_db'@'localhost' WITH GRANT OPTION
+GRANT EXECUTE, ALTER ROUTINE ON FUNCTION `bug42217_db`.`upgrade_del_func` TO 'create_rout_db'@'localhost'
+USE bug42217_db;
+SHOW CREATE FUNCTION upgrade_del_func;
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+upgrade_del_func CREATE DEFINER=`create_rout_db`@`localhost` FUNCTION `upgrade_del_func`() RETURNS char(30) CHARSET latin1
+BEGIN
+RETURN "INSIDE upgrade_del_func()";
+END latin1 latin1_swedish_ci latin1_swedish_ci
+SELECT upgrade_del_func();
+upgrade_del_func()
+INSIDE upgrade_del_func()
+"Check whether the definer user will be able to execute the replicated routine on slave"
+USE bug42217_db;
+SHOW CREATE FUNCTION upgrade_del_func;
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+upgrade_del_func CREATE DEFINER=`create_rout_db`@`localhost` FUNCTION `upgrade_del_func`() RETURNS char(30) CHARSET latin1
+BEGIN
+RETURN "INSIDE upgrade_del_func()";
+END latin1 latin1_swedish_ci latin1_swedish_ci
+SELECT upgrade_del_func();
+upgrade_del_func()
+INSIDE upgrade_del_func()
+DELETE FROM mysql.procs_priv;
+FLUSH PRIVILEGES;
+USE bug42217_db;
+"Can't execute the replicated routine on slave like before after procs privilege is deleted "
+SELECT upgrade_del_func();
+ERROR 42000: execute command denied to user 'create_rout_db'@'localhost' for routine 'bug42217_db.upgrade_del_func'
+"Test the user who creates a function on master doesn't exist on slave."
+"Hence SQL thread ACL_GLOBAL privilege jumps in and no mysql.procs_priv is inserted"
+DROP USER 'create_rout_db'@'localhost';
+CREATE FUNCTION upgrade_alter_func() RETURNS CHAR(30)
+BEGIN
+RETURN "INSIDE upgrade_alter_func()";
+END//
+SELECT upgrade_alter_func();
+upgrade_alter_func()
+INSIDE upgrade_alter_func()
+SHOW CREATE FUNCTION upgrade_alter_func;
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+upgrade_alter_func CREATE DEFINER=`create_rout_db`@`localhost` FUNCTION `upgrade_alter_func`() RETURNS char(30) CHARSET latin1
+BEGIN
+RETURN "INSIDE upgrade_alter_func()";
+END latin1 latin1_swedish_ci latin1_swedish_ci
+"Should no privilege record for upgrade_alter_func in mysql.procs_priv"
+SELECT * FROM mysql.procs_priv;
+Host Db User Routine_name Routine_type Grantor Proc_priv Timestamp
+SELECT upgrade_alter_func();
+ERROR HY000: The user specified as a definer ('create_rout_db'@'localhost') does not exist
+USE bug42217_db;
+DROP FUNCTION upgrade_del_func;
+DROP FUNCTION upgrade_alter_func;
+DROP DATABASE bug42217_db;
+DROP USER 'create_rout_db'@'localhost';
+"End of test"
diff --git a/mysql-test/suite/rpl/r/rpl_drop_if_exists.result b/mysql-test/suite/rpl/r/rpl_drop_if_exists.result
new file mode 100644
index 00000000000..59a2470cfdb
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_drop_if_exists.result
@@ -0,0 +1,98 @@
+RESET MASTER;
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS db_bug_13684.t
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
+CREATE DATABASE db_bug_13684;
+CREATE TABLE db_bug_13684.t (a int);
+CREATE EVENT db_bug_13684.e
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+DO
+UPDATE db_bug_13684.t SET a = a + 1;
+CREATE VIEW db_bug_13684.v
+AS SELECT * FROM db_bug_13684.t;
+CREATE TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+FOR EACH ROW BEGIN
+END;
+CREATE PROCEDURE db_bug_13684.p (OUT p1 INT)
+BEGIN
+END;
+CREATE FUNCTION db_bug_13684.f (s CHAR(20))
+RETURNS CHAR(50) DETERMINISTIC
+RETURN s;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS db_bug_13684.t
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
+master-bin.000001 # Query # # CREATE DATABASE db_bug_13684
+master-bin.000001 # Query # # use `test`; CREATE TABLE db_bug_13684.t (a int)
+master-bin.000001 # Query # # use `test`; CREATE EVENT db_bug_13684.e
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+DO
+UPDATE db_bug_13684.t SET a = a + 1
+master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db_bug_13684`.`v` AS SELECT * FROM db_bug_13684.t
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+FOR EACH ROW BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `db_bug_13684`.`p`(OUT p1 INT)
+BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `db_bug_13684`.`f`(s CHAR(20)) RETURNS char(50) CHARSET latin1
+ DETERMINISTIC
+RETURN s
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS db_bug_13684.t
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
+master-bin.000001 # Query # # CREATE DATABASE db_bug_13684
+master-bin.000001 # Query # # use `test`; CREATE TABLE db_bug_13684.t (a int)
+master-bin.000001 # Query # # use `test`; CREATE EVENT db_bug_13684.e
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+DO
+UPDATE db_bug_13684.t SET a = a + 1
+master-bin.000001 # Query # # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `db_bug_13684`.`v` AS SELECT * FROM db_bug_13684.t
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+FOR EACH ROW BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `db_bug_13684`.`p`(OUT p1 INT)
+BEGIN
+END
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `db_bug_13684`.`f`(s CHAR(20)) RETURNS char(50) CHARSET latin1
+ DETERMINISTIC
+RETURN s
+master-bin.000001 # Query # # use `test`; DROP PROCEDURE IF EXISTS db_bug_13684.p
+master-bin.000001 # Query # # use `test`; DROP FUNCTION IF EXISTS db_bug_13684.f
+master-bin.000001 # Query # # use `test`; DROP TRIGGER IF EXISTS db_bug_13684.tr
+master-bin.000001 # Query # # use `test`; DROP VIEW IF EXISTS db_bug_13684.v
+master-bin.000001 # Query # # use `test`; DROP EVENT IF EXISTS db_bug_13684.e
+master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS db_bug_13684.t
+master-bin.000001 # Query # # DROP DATABASE IF EXISTS db_bug_13684
diff --git a/mysql-test/suite/rpl/r/rpl_failed_optimize.result b/mysql-test/suite/rpl/r/rpl_failed_optimize.result
index 5c84b1ff5fd..7210898d521 100644
--- a/mysql-test/suite/rpl/r/rpl_failed_optimize.result
+++ b/mysql-test/suite/rpl/r/rpl_failed_optimize.result
@@ -17,7 +17,7 @@ Error 1205 Lock wait timeout exceeded; try restarting transaction
OPTIMIZE TABLE non_existing;
Table Op Msg_type Msg_text
test.non_existing optimize Error Table 'test.non_existing' doesn't exist
-test.non_existing optimize error Corrupt
+test.non_existing optimize status Operation failed
select * from t1;
a
1
diff --git a/mysql-test/suite/rpl/r/rpl_idempotency.result b/mysql-test/suite/rpl/r/rpl_idempotency.result
index f39d0f1f37f..3341c03db0f 100644
--- a/mysql-test/suite/rpl/r/rpl_idempotency.result
+++ b/mysql-test/suite/rpl/r/rpl_idempotency.result
@@ -141,9 +141,9 @@ select * from ti1 order by b /* must be (2),(3) */;
b
2
3
-*** slave must stop
+*** slave must stop (Trying to delete a referenced foreing key)
Last_SQL_Error
-0
+1451
select * from ti1 order by b /* must be (1),(2),(3) - not deleted */;
b
1
@@ -159,7 +159,7 @@ set global slave_exec_mode='STRICT';
*** conspire future problem
delete from ti1 where b=3;
insert into ti2 set a=3, b=3 /* offending write event */;
-*** slave must stop
+*** slave must stop (Trying to insert an invalid foreign key)
Last_SQL_Error
1452
select * from ti2 order by b /* must be (2,2) */;
@@ -179,7 +179,7 @@ a b
*** conspiring query
insert into ti1 set b=1;
insert into ti1 set b=1 /* offending write event */;
-*** slave must stop
+*** slave must stop (Trying to insert a dupliacte key)
Last_SQL_Error
1062
set foreign_key_checks= 0;
@@ -195,32 +195,32 @@ INSERT INTO t2 VALUES (-1),(-2),(-3);
DELETE FROM t1 WHERE a = -2;
DELETE FROM t2 WHERE a = -2;
DELETE FROM t1 WHERE a = -2;
-*** slave must stop
+*** slave must stop (Key was not found)
Last_SQL_Error
1032
set global slave_exec_mode='IDEMPOTENT';
start slave sql_thread;
set global slave_exec_mode='STRICT';
DELETE FROM t2 WHERE a = -2;
-*** slave must stop
+*** slave must stop (Key was not found)
Last_SQL_Error
-0
+1032
set global slave_exec_mode='IDEMPOTENT';
start slave sql_thread;
set global slave_exec_mode='STRICT';
UPDATE t1 SET a = 1 WHERE a = -1;
UPDATE t2 SET a = 1 WHERE a = -1;
UPDATE t1 SET a = 1 WHERE a = -1;
-*** slave must stop
+*** slave must stop (Key was not found)
Last_SQL_Error
1032
set global slave_exec_mode='IDEMPOTENT';
start slave sql_thread;
set global slave_exec_mode='STRICT';
UPDATE t2 SET a = 1 WHERE a = -1;
-*** slave must stop
+*** slave must stop (Key was not found)
Last_SQL_Error
-0
+1032
set global slave_exec_mode='IDEMPOTENT';
start slave sql_thread;
SET @@global.slave_exec_mode= @old_slave_exec_mode;
diff --git a/mysql-test/suite/rpl/r/rpl_init_slave_errors.result b/mysql-test/suite/rpl/r/rpl_init_slave_errors.result
new file mode 100644
index 00000000000..ab957e6d9bc
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_init_slave_errors.result
@@ -0,0 +1,18 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+stop slave;
+reset slave;
+SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
+start slave;
+Reporting the following error: Failed during slave thread initialization
+SET GLOBAL debug= "";
+stop slave;
+reset slave;
+SET GLOBAL init_slave= "garbage";
+start slave;
+Reporting the following error: Slave SQL thread aborted. Can't execute init_slave query
+SET GLOBAL init_slave= "";
diff --git a/mysql-test/suite/rpl/r/rpl_killed_ddl.result b/mysql-test/suite/rpl/r/rpl_killed_ddl.result
new file mode 100644
index 00000000000..a15b3c30766
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_killed_ddl.result
@@ -0,0 +1,169 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP DATABASE IF EXISTS d1;
+DROP DATABASE IF EXISTS d2;
+DROP DATABASE IF EXISTS d3;
+DROP DATABASE IF EXISTS d4;
+DROP EVENT IF EXISTS e1;
+DROP EVENT IF EXISTS e2;
+DROP EVENT IF EXISTS e3;
+DROP EVENT IF EXISTS e4;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP FUNCTION IF EXISTS f3;
+DROP FUNCTION IF EXISTS f4;
+DROP SERVER IF EXISTS s1;
+DROP SERVER IF EXISTS s2;
+DROP SERVER IF EXISTS s3;
+DROP SERVER IF EXISTS s4;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+DROP TRIGGER IF EXISTS tr1;
+DROP TRIGGER IF EXISTS tr2;
+DROP TRIGGER IF EXISTS tr3;
+DROP TRIGGER IF EXISTS tr4;
+CREATE DATABASE d1;
+CREATE EVENT e1
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
+DO INSERT INTO test.t1 VALUES (1);
+CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC
+RETURN 1;
+CREATE PROCEDURE p1 (OUT rows INT)
+BEGIN
+SELECT COUNT(*) INTO rows FROM t1;
+END;
+//
+CREATE SERVER s1
+FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'user1', HOST '192.168.1.106', DATABASE 'test');
+CREATE TABLE t1 (a int);
+CREATE TABLE t3 (a int);
+CREATE TRIGGER tr1 BEFORE INSERT ON t1
+FOR EACH ROW BEGIN
+DELETE FROM t4 WHERE a=NEW.a;
+END;
+//
+CREATE INDEX i1 ON t1 (a);
+CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100;
+[on master]
+[on master1]
+CREATE DATABASE d2;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP DATABASE d1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP DATABASE d2;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+CREATE EVENT e2
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
+DO INSERT INTO test.t1 VALUES (2);
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP EVENT e1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP EVENT IF EXISTS e2;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+CREATE FUNCTION f2 () RETURNS INT DETERMINISTIC
+RETURN 1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+ALTER FUNCTION f1 SQL SECURITY INVOKER;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP FUNCTION f1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+CREATE PROCEDURE p2 (OUT rows INT)
+BEGIN
+SELECT COUNT(*) INTO rows FROM t2;
+END;
+//
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+ALTER PROCEDURE p1 SQL SECURITY INVOKER COMMENT 'return rows of table t1';
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP PROCEDURE p1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+CREATE TABLE t2 (b int);
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+ALTER TABLE t1 ADD (d int);
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+RENAME TABLE t3 TO t4;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+CREATE INDEX i2 on t1 (a);
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP INDEX i1 on t1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+CREATE TRIGGER tr2 BEFORE INSERT ON t4
+FOR EACH ROW BEGIN
+DELETE FROM t1 WHERE a=NEW.a;
+END;
+//
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP TRIGGER tr1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP TRIGGER IF EXISTS tr2;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+CREATE VIEW v2 AS SELECT a FROM t1 WHERE a > 100;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP VIEW v1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP VIEW IF EXISTS v2;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP TABLE t1;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP TABLE IF EXISTS t2;
+source include/kill_query.inc;
+source include/diff_master_slave.inc;
+DROP DATABASE IF EXISTS d1;
+DROP DATABASE IF EXISTS d2;
+DROP DATABASE IF EXISTS d3;
+DROP DATABASE IF EXISTS d4;
+DROP EVENT IF EXISTS e1;
+DROP EVENT IF EXISTS e2;
+DROP EVENT IF EXISTS e3;
+DROP EVENT IF EXISTS e4;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP FUNCTION IF EXISTS f3;
+DROP FUNCTION IF EXISTS f4;
+DROP SERVER IF EXISTS s1;
+DROP SERVER IF EXISTS s2;
+DROP SERVER IF EXISTS s3;
+DROP SERVER IF EXISTS s4;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
diff --git a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result
index 96de55e9dcf..93ef33f3fc0 100644
--- a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result
+++ b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result
@@ -29,3 +29,28 @@ a
2
3
drop table t1;
+==== Bug22504 Initialize ====
+[on master]
+SET sql_mode='ignore_space';
+CREATE TABLE t1(a int);
+insert into t1 values (1), (2), (3), (4);
+select * into outfile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1;
+truncate table t1;
+load data local infile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1;
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+3
+4
+[on slave]
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+3
+4
+==== Clean up ====
+[on master]
+DROP TABLE t1;
+[on slave]
diff --git a/mysql-test/suite/rpl/r/rpl_loadfile.result b/mysql-test/suite/rpl/r/rpl_loadfile.result
index 7a5a7bc50c9..22f65c0b5e5 100644
--- a/mysql-test/suite/rpl/r/rpl_loadfile.result
+++ b/mysql-test/suite/rpl/r/rpl_loadfile.result
@@ -225,3 +225,21 @@ aberration
DROP PROCEDURE IF EXISTS test.p1;
DROP TABLE test.t1;
+**** Resetting master and slave ****
+include/stop_slave.inc
+RESET SLAVE;
+RESET MASTER;
+include/start_slave.inc
+SELECT repeat('x',20) INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug_39701.data';
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (t text);
+CREATE PROCEDURE p(file varchar(4096))
+BEGIN
+INSERT INTO t1 VALUES (LOAD_FILE(file));
+END|
+include/stop_slave.inc
+CALL p('MYSQLTEST_VARDIR/tmp/bug_39701.data');
+include/start_slave.inc
+Comparing tables master:test.t1 and slave:test.t1
+DROP TABLE t1;
+DROP PROCEDURE p;
diff --git a/mysql-test/suite/rpl/r/rpl_mixed_bit_pk.result b/mysql-test/suite/rpl/r/rpl_mixed_bit_pk.result
new file mode 100644
index 00000000000..f1b0b2ae5cb
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_mixed_bit_pk.result
@@ -0,0 +1,32 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
+CREATE TABLE t1 (`bit_key` bit, `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t2 (`bit_key` bit(4), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t3 (`bit_key` bit(7), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t4 (`bit_key` bit(8), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t5 (`bit_key` bit(9), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t6 (`bit_key` bit(14), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t7 (`bit_key` bit(15), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t8 (`bit_key` bit(16), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+INSERT INTO `t1` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t1` WHERE `bit` < 2 LIMIT 4;
+INSERT INTO `t2` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t2` WHERE `bit` < 2 LIMIT 4;
+INSERT INTO `t3` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t3` WHERE `bit` < 2 LIMIT 4;
+INSERT INTO `t4` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t4` WHERE `bit` < 2 LIMIT 4;
+INSERT INTO `t5` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t5` WHERE `bit` < 2 LIMIT 4;
+INSERT INTO `t6` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t6` WHERE `bit` < 2 LIMIT 4;
+INSERT INTO `t7` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t7` WHERE `bit` < 2 LIMIT 4;
+INSERT INTO `t8` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t8` WHERE `bit` < 2 LIMIT 4;
+DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
diff --git a/mysql-test/suite/rpl/r/rpl_name_const.result b/mysql-test/suite/rpl/r/rpl_name_const.result
new file mode 100644
index 00000000000..acb2684d2c8
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_name_const.result
@@ -0,0 +1,28 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+==== Initialize ====
+[on master]
+create table t1 (id int);
+==== create a procedure that has a column aliase in a subquery ====
+drop procedure if exists test_procedure;
+create procedure test_procedure(_id int)
+begin
+insert into t1 (id)
+select a.id
+from
+( select _id as id ) a;
+end;$$
+==== enable the binary log, then call the procedure ====
+call test_procedure(1234);
+[on slave]
+select * from t1 order by id;
+id
+1234
+==== Clean up ====
+[on master]
+drop table t1;
+drop procedure test_procedure;
diff --git a/mysql-test/suite/rpl/r/rpl_rotate_logs.result b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
index 6314a9a61fb..013ba87ec0b 100644
--- a/mysql-test/suite/rpl/r/rpl_rotate_logs.result
+++ b/mysql-test/suite/rpl/r/rpl_rotate_logs.result
@@ -87,9 +87,7 @@ show binary logs;
Log_name File_size
master-bin.000002 #
master-bin.000003 #
-select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND)
-from information_schema.tables
-where TABLE_SCHEMA="test" and TABLE_NAME="t2";
+SELECT @time_for_purge:=DATE_ADD('tmpval', INTERVAL 1 SECOND);
purge master logs before (@time_for_purge);
show binary logs;
Log_name File_size
diff --git a/mysql-test/suite/rpl/r/rpl_row_until.result b/mysql-test/suite/rpl/r/rpl_row_until.result
index be1ec51f74a..ad54450af74 100644
--- a/mysql-test/suite/rpl/r/rpl_row_until.result
+++ b/mysql-test/suite/rpl/r/rpl_row_until.result
@@ -4,16 +4,17 @@ reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
+CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+DROP TABLE t1;
+CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
+INSERT INTO t2 VALUES (1),(2);
+INSERT INTO t2 VALUES (3),(4);
+DROP TABLE t2;
include/stop_slave.inc
-create table t1(n int not null auto_increment primary key);
-insert into t1 values (1),(2),(3),(4);
-drop table t1;
-create table t2(n int not null auto_increment primary key);
-insert into t2 values (1),(2);
-insert into t2 values (3),(4);
-drop table t2;
-start slave until master_log_file='master-bin.000001', master_log_pos=311;
-select * from t1;
+RESET SLAVE;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_drop_t1
+SELECT * FROM t1;
n
1
2
@@ -23,10 +24,10 @@ SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
-Master_Port MASTER_PORT
+Master_Port #
Connect_Retry 1
Master_Log_File master-bin.000001
-Read_Master_Log_Pos 1161
+Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
@@ -41,11 +42,11 @@ Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
-Exec_Master_Log_Pos 454
+Exec_Master_Log_Pos MASTER_POS_DROP_T1
Relay_Log_Space #
Until_Condition Master
Until_Log_File master-bin.000001
-Until_Log_Pos 311
+Until_Log_Pos MASTER_POS_DROP_T1
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
@@ -58,8 +59,8 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
-start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
-select * from t1;
+START SLAVE UNTIL MASTER_LOG_FILE='master-no-such-bin.000001', MASTER_LOG_POS=291;
+SELECT * FROM t1;
n
1
2
@@ -69,10 +70,10 @@ SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
-Master_Port MASTER_PORT
+Master_Port #
Connect_Retry 1
Master_Log_File master-bin.000001
-Read_Master_Log_Pos 1161
+Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
@@ -87,7 +88,7 @@ Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
-Exec_Master_Log_Pos 454
+Exec_Master_Log_Pos MASTER_POS_DROP_T1
Relay_Log_Space #
Until_Condition Master
Until_Log_File master-no-such-bin.000001
@@ -104,8 +105,8 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=1014;
-select * from t2;
+START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=relay_pos_insert1_t2
+SELECT * FROM t2;
n
1
2
@@ -113,10 +114,10 @@ SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
-Master_Port MASTER_PORT
+Master_Port #
Connect_Retry 1
Master_Log_File master-bin.000001
-Read_Master_Log_Pos 1161
+Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
@@ -131,11 +132,11 @@ Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
-Exec_Master_Log_Pos 868
+Exec_Master_Log_Pos MASTER_POS_INSERT1_T2
Relay_Log_Space #
Until_Condition Relay
-Until_Log_File slave-relay-bin.000004
-Until_Log_Pos 1014
+Until_Log_File slave-relay-bin.000002
+Until_Log_Pos RELAY_POS_INSERT1_T2
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
@@ -148,17 +149,17 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
-start slave;
+START SLAVE;
include/stop_slave.inc
-start slave sql_thread until master_log_file='master-bin.000001', master_log_pos=740;
+START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_create_t2
SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
Master_User root
-Master_Port MASTER_PORT
+Master_Port #
Connect_Retry 1
Master_Log_File master-bin.000001
-Read_Master_Log_Pos 1161
+Read_Master_Log_Pos #
Relay_Log_File #
Relay_Log_Pos #
Relay_Master_Log_File master-bin.000001
@@ -173,11 +174,11 @@ Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
-Exec_Master_Log_Pos 1161
+Exec_Master_Log_Pos MASTER_POS_DROP_T2
Relay_Log_Space #
Until_Condition Master
Until_Log_File master-bin.000001
-Until_Log_Pos 740
+Until_Log_Pos MASTER_POS_CREATE_T2
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
@@ -190,17 +191,17 @@ Last_IO_Errno #
Last_IO_Error #
Last_SQL_Errno 0
Last_SQL_Error
-start slave until master_log_file='master-bin', master_log_pos=561;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin', MASTER_LOG_POS=561;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
-start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=561, RELAY_LOG_POS=12;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
-start slave until master_log_file='master-bin.000001';
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001';
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
-start slave until relay_log_file='slave-relay-bin.000002';
+START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000009';
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
-start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
+START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=561;
ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
-start slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=740;
+START SLAVE;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=740;
Warnings:
Note 1254 Slave is already running
diff --git a/mysql-test/suite/rpl/r/rpl_row_wide_table.result b/mysql-test/suite/rpl/r/rpl_row_wide_table.result
new file mode 100644
index 00000000000..da96e84d1d5
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_row_wide_table.result
@@ -0,0 +1,318 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP TABLE IF EXISTS t300;
+create table t300 (
+f1 int,
+f2 int,
+f3 int,
+f4 int,
+f5 int,
+f6 int,
+f7 int,
+f8 int,
+f9 int,
+f10 int,
+f11 int,
+f12 int,
+f13 int,
+f14 int,
+f15 int,
+f16 int,
+f17 int,
+f18 int,
+f19 int,
+f20 int,
+f21 int,
+f22 int,
+f23 int,
+f24 int,
+f25 int,
+f26 int,
+f27 int,
+f28 int,
+f29 int,
+f30 int,
+f31 int,
+f32 int,
+f33 int,
+f34 int,
+f35 int,
+f36 int,
+f37 int,
+f38 int,
+f39 int,
+f40 int,
+f41 int,
+f42 int,
+f43 int,
+f44 int,
+f45 int,
+f46 int,
+f47 int,
+f48 int,
+f49 int,
+f50 int,
+f51 int,
+f52 int,
+f53 int,
+f54 int,
+f55 int,
+f56 int,
+f57 int,
+f58 int,
+f59 int,
+f60 int,
+f61 int,
+f62 int,
+f63 int,
+f64 int,
+f65 int,
+f66 int,
+f67 int,
+f68 int,
+f69 int,
+f70 int,
+f71 int,
+f72 int,
+f73 int,
+f74 int,
+f75 int,
+f76 int,
+f77 int,
+f78 int,
+f79 int,
+f80 int,
+f81 int,
+f82 int,
+f83 int,
+f84 int,
+f85 int,
+f86 int,
+f87 int,
+f88 int,
+f89 int,
+f90 int,
+f91 int,
+f92 int,
+f93 int,
+f94 int,
+f95 int,
+f96 int,
+f97 int,
+f98 int,
+f99 int,
+f100 int,
+f101 int,
+f102 int,
+f103 int,
+f104 int,
+f105 int,
+f106 int,
+f107 int,
+f108 int,
+f109 int,
+f110 int,
+f111 int,
+f112 int,
+f113 int,
+f114 int,
+f115 int,
+f116 int,
+f117 int,
+f118 int,
+f119 int,
+f120 int,
+f121 int,
+f122 int,
+f123 int,
+f124 int,
+f125 int,
+f126 int,
+f127 int,
+f128 int,
+f129 int,
+f130 int,
+f131 int,
+f132 int,
+f133 int,
+f134 int,
+f135 int,
+f136 int,
+f137 int,
+f138 int,
+f139 int,
+f140 int,
+f141 int,
+f142 int,
+f143 int,
+f144 int,
+f145 int,
+f146 int,
+f147 int,
+f148 int,
+f149 int,
+f150 int,
+f151 int,
+f152 int,
+f153 int,
+f154 int,
+f155 int,
+f156 int,
+f157 int,
+f158 int,
+f159 int,
+f160 int,
+f161 int,
+f162 int,
+f163 int,
+f164 int,
+f165 int,
+f166 int,
+f167 int,
+f168 int,
+f169 int,
+f170 int,
+f171 int,
+f172 int,
+f173 int,
+f174 int,
+f175 int,
+f176 int,
+f177 int,
+f178 int,
+f179 int,
+f180 int,
+f181 int,
+f182 int,
+f183 int,
+f184 int,
+f185 int,
+f186 int,
+f187 int,
+f188 int,
+f189 int,
+f190 int,
+f191 int,
+f192 int,
+f193 int,
+f194 int,
+f195 int,
+f196 int,
+f197 int,
+f198 int,
+f199 int,
+f200 int,
+f201 int,
+f202 int,
+f203 int,
+f204 int,
+f205 int,
+f206 int,
+f207 int,
+f208 int,
+f209 int,
+f210 int,
+f211 int,
+f212 int,
+f213 int,
+f214 int,
+f215 int,
+f216 int,
+f217 int,
+f218 int,
+f219 int,
+f220 int,
+f221 int,
+f222 int,
+f223 int,
+f224 int,
+f225 int,
+f226 int,
+f227 int,
+f228 int,
+f229 int,
+f230 int,
+f231 int,
+f232 int,
+f233 int,
+f234 int,
+f235 int,
+f236 int,
+f237 int,
+f238 int,
+f239 int,
+f240 int,
+f241 int,
+f242 int,
+f243 int,
+f244 int,
+f245 int,
+f246 int,
+f247 int,
+f248 int,
+f249 int,
+f250 int,
+f251 int,
+f252 int,
+f253 int,
+f254 int,
+f255 int,
+f256 int,
+f257 int,
+f258 int,
+f259 int,
+f260 int,
+f261 int,
+f262 int,
+f263 int,
+f264 int,
+f265 int,
+f266 int,
+f267 int,
+f268 int,
+f269 int,
+f270 int,
+f271 int,
+f272 int,
+f273 int,
+f274 int,
+f275 int,
+f276 int,
+f277 int,
+f278 int,
+f279 int,
+f280 int,
+f281 int,
+f282 int,
+f283 int,
+f284 int,
+f285 int,
+f286 int,
+f287 int,
+f288 int,
+f289 int,
+f290 int,
+f291 int,
+f292 int,
+f293 int,
+f294 int,
+f295 int,
+f296 int,
+f297 int,
+f298 int,
+f299 int,
+f300 int,
+primary key (f1));
+insert into t300 set f1= 1;
+select f300 from t300;
+f300
+NULL
+select count(*) as one from t300;
+one
+1
+*** Cleanup ***
+DROP TABLE t300;
diff --git a/mysql-test/suite/rpl/r/rpl_skip_error.result b/mysql-test/suite/rpl/r/rpl_skip_error.result
index b90d8113e8e..d955859f030 100644
--- a/mysql-test/suite/rpl/r/rpl_skip_error.result
+++ b/mysql-test/suite/rpl/r/rpl_skip_error.result
@@ -74,19 +74,16 @@ Last_SQL_Error
drop table t1;
create table t1(a int primary key);
insert into t1 values (1),(2);
-delete from t1 where @@server_id=1;
-Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+SET SQL_LOG_BIN=0;
+delete from t1;
+SET SQL_LOG_BIN=1;
set sql_mode=strict_trans_tables;
-insert into t1 values (7), (8), (9);
+insert into t1 values (1), (2), (3);
[on slave]
select * from t1;
a
1
2
-7
-8
-9
SHOW SLAVE STATUS;
Slave_IO_State #
Master_Host 127.0.0.1
@@ -128,3 +125,66 @@ Last_SQL_Errno 0
Last_SQL_Error
==== Clean Up ====
drop table t1;
+==== Using Innodb ====
+SET SQL_LOG_BIN=0;
+CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `data` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SET SQL_LOG_BIN=1;
+CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) NOT NULL,
+ `data` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES(1, 1);
+INSERT INTO t1 VALUES(2, 1);
+INSERT INTO t1 VALUES(3, 1);
+INSERT INTO t1 VALUES(4, 1);
+SET SQL_LOG_BIN=0;
+DELETE FROM t1 WHERE id = 4;
+SET SQL_LOG_BIN=1;
+UPDATE t1 SET id= id + 3, data = 2;
+
+**** We cannot execute a select as there are differences in the
+**** behavior between STMT and RBR.
+==== Using MyIsam ====
+SET SQL_LOG_BIN=0;
+CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `data` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SET SQL_LOG_BIN=1;
+CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL,
+ `data` int(11) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t2 VALUES(1, 1);
+INSERT INTO t2 VALUES(2, 1);
+INSERT INTO t2 VALUES(3, 1);
+INSERT INTO t2 VALUES(5, 1);
+SET SQL_LOG_BIN=0;
+DELETE FROM t2 WHERE id = 5;
+SET SQL_LOG_BIN=1;
+UPDATE t2 SET id= id + 3, data = 2;
+
+**** We cannot execute a select as there are differences in the
+**** behavior between STMT and RBR.
+==== Clean Up ====
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_in.result b/mysql-test/suite/rpl/r/rpl_slave_load_in.result
new file mode 100644
index 00000000000..2cc83fd0a19
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_slave_load_in.result
@@ -0,0 +1,19 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1(a int not null auto_increment, b int, primary key(a));
+create table t2(a int not null auto_increment, b int, primary key(a)) engine=innodb;
+load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+start transaction;
+insert into t2(b) values (1);
+insert into t2(b) values (2);
+load data infile '../../std_data/rpl_loaddata.dat' into table t2;
+load data infile '../../std_data/rpl_loaddata.dat' into table t2;
+commit;
+Comparing tables master:test.t1 and slave:test.t1
+Comparing tables master:test.t2 and slave:test.t2
+drop table t1;
+drop table t2;
diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
new file mode 100644
index 00000000000..777f7d8427b
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_slave_load_remove_tmpfile.result
@@ -0,0 +1,53 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1(a int not null auto_increment, b int, primary key(a)) engine=innodb;
+start transaction;
+insert into t1(b) values (1);
+insert into t1(b) values (2);
+load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+commit;
+show slave status;
+Slave_IO_State #
+Master_Host 127.0.0.1
+Master_User root
+Master_Port MASTER_MYPORT
+Connect_Retry 1
+Master_Log_File master-bin.000001
+Read_Master_Log_Pos #
+Relay_Log_File #
+Relay_Log_Pos #
+Relay_Master_Log_File master-bin.000001
+Slave_IO_Running Yes
+Slave_SQL_Running No
+Replicate_Do_DB
+Replicate_Ignore_DB
+Replicate_Do_Table
+Replicate_Ignore_Table
+Replicate_Wild_Do_Table
+Replicate_Wild_Ignore_Table
+Last_Errno 9
+Last_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed
+Skip_Counter 0
+Exec_Master_Log_Pos #
+Relay_Log_Space #
+Until_Condition None
+Until_Log_File
+Until_Log_Pos 0
+Master_SSL_Allowed No
+Master_SSL_CA_File
+Master_SSL_CA_Path
+Master_SSL_Cert
+Master_SSL_Cipher
+Master_SSL_Key
+Seconds_Behind_Master #
+Master_SSL_Verify_Server_Cert No
+Last_IO_Errno #
+Last_IO_Error #
+Last_SQL_Errno 9
+Last_SQL_Error Error in Begin_load_query event: write to '../../tmp/SQL_LOAD.data' failed
+drop table t1;
+drop table t1;
diff --git a/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result
new file mode 100644
index 00000000000..a158fb5dfc4
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_slave_load_tmpdir_not_exist.result
@@ -0,0 +1,6 @@
+CHANGE MASTER TO MASTER_USER='root',
+MASTER_CONNECT_RETRY=1,
+MASTER_HOST='127.0.0.1',
+MASTER_PORT=MASTER_MYPORT;
+START SLAVE;
+Unable to use slave's temporary directory ../../../error - Can't read dir of '../../../error' (Errcode: 2)
diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result
index 4a8a4050c02..90a362c352b 100644
--- a/mysql-test/suite/rpl/r/rpl_sp.result
+++ b/mysql-test/suite/rpl/r/rpl_sp.result
@@ -195,7 +195,7 @@ set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators
set @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
set global log_bin_trust_routine_creators=1;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
set global log_bin_trust_function_creators=0;
set global log_bin_trust_function_creators=1;
set @old_log_bin_trust_routine_creators= @@global.log_bin_trust_routine_creators;
@@ -511,6 +511,7 @@ master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo
master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1
master-bin.000001 # Query 1 # drop database mysqltest1
master-bin.000001 # Query 1 # drop user "zedjzlcsjhd"@127.0.0.1
+master-bin.000001 # Query 1 # use `test`; drop function if exists f1
master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
READS SQL DATA
begin
@@ -526,12 +527,15 @@ master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
master-bin.000001 # Query 1 # use `test`; insert into t1 (a) values (f1())
master-bin.000001 # Query 1 # use `test`; drop view v1
master-bin.000001 # Query 1 # use `test`; drop function f1
+master-bin.000001 # Query 1 # use `test`; DROP PROCEDURE IF EXISTS p1
master-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS t1
master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(col VARCHAR(10))
master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(arg VARCHAR(10))
INSERT INTO t1 VALUES(arg)
master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test' COLLATE 'latin1_swedish_ci'))
master-bin.000001 # Query 1 # use `test`; DROP PROCEDURE p1
+master-bin.000001 # Query 1 # use `test`; DROP PROCEDURE IF EXISTS p1
+master-bin.000001 # Query 1 # use `test`; DROP FUNCTION IF EXISTS f1
master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
SET @a = 1
master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
@@ -555,11 +559,11 @@ end
master-bin.000001 # Query 1 # use `mysqltest`; SELECT `mysqltest2`.`f1`()
set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
set @@global.log_bin_trust_routine_creators= @old_log_bin_trust_routine_creators;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
set @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
drop database mysqltest;
drop database mysqltest2;
@@ -842,6 +846,9 @@ drop user "zedjzlcsjhd"@127.0.0.1
/*!*/;
use test/*!*/;
SET TIMESTAMP=t/*!*/;
+drop function if exists f1
+/*!*/;
+SET TIMESTAMP=t/*!*/;
CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
READS SQL DATA
begin
@@ -869,6 +876,9 @@ SET TIMESTAMP=t/*!*/;
drop function f1
/*!*/;
SET TIMESTAMP=t/*!*/;
+DROP PROCEDURE IF EXISTS p1
+/*!*/;
+SET TIMESTAMP=t/*!*/;
DROP TABLE IF EXISTS t1
/*!*/;
SET TIMESTAMP=t/*!*/;
@@ -885,6 +895,12 @@ SET TIMESTAMP=t/*!*/;
DROP PROCEDURE p1
/*!*/;
SET TIMESTAMP=t/*!*/;
+DROP PROCEDURE IF EXISTS p1
+/*!*/;
+SET TIMESTAMP=t/*!*/;
+DROP FUNCTION IF EXISTS f1
+/*!*/;
+SET TIMESTAMP=t/*!*/;
CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
SET @a = 1
/*!*/;
diff --git a/mysql-test/suite/rpl/r/rpl_start_stop_slave.result b/mysql-test/suite/rpl/r/rpl_start_stop_slave.result
index 04ece812f35..e2b1935c268 100644
--- a/mysql-test/suite/rpl/r/rpl_start_stop_slave.result
+++ b/mysql-test/suite/rpl/r/rpl_start_stop_slave.result
@@ -10,3 +10,31 @@ start slave;
stop slave io_thread;
start slave io_thread;
drop table t1;
+create table t1i(n int primary key) engine=innodb;
+create table t2m(n int primary key) engine=myisam;
+begin;
+insert into t1i values (1);
+insert into t1i values (2);
+insert into t1i values (3);
+commit;
+begin;
+insert into t1i values (5);
+begin;
+insert into t1i values (4);
+insert into t2m values (1);
+insert into t1i values (5);
+commit;
+zero
+0
+stop slave;
+rollback;
+*** sql thread is *not* running: No ***
+*** the prove: the stopped slave has finished the current transaction ***
+five
+5
+zero
+0
+one
+1
+include/start_slave.inc
+drop table t1i, t2m;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_loadfile.result b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result
new file mode 100644
index 00000000000..72f58268d5f
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_stm_loadfile.result
@@ -0,0 +1,231 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE IF EXISTS test.t1;
+CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
+INSERT INTO test.t1 VALUES(1,'test');
+UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1;
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+create procedure test.p1()
+begin
+INSERT INTO test.t1 VALUES(2,'test');
+UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2;
+end|
+CALL test.p1();
+Warnings:
+Note 1592 Statement is not safe to log in statement format.
+SELECT * FROM test.t1 ORDER BY blob_column;
+a blob_column
+1 abase
+abased
+abasement
+abasements
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+Abba
+abbe
+abbey
+abbeys
+abbot
+abbots
+Abbott
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+Abby
+abdomen
+abdomens
+abdominal
+abduct
+abducted
+abduction
+abductions
+abductor
+abductors
+abducts
+Abe
+abed
+Abel
+Abelian
+Abelson
+Aberdeen
+Abernathy
+aberrant
+aberration
+
+2 abase
+abased
+abasement
+abasements
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+Abba
+abbe
+abbey
+abbeys
+abbot
+abbots
+Abbott
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+Abby
+abdomen
+abdomens
+abdominal
+abduct
+abducted
+abduction
+abductions
+abductor
+abductors
+abducts
+Abe
+abed
+Abel
+Abelian
+Abelson
+Aberdeen
+Abernathy
+aberrant
+aberration
+
+SELECT * FROM test.t1 ORDER BY blob_column;
+a blob_column
+1 abase
+abased
+abasement
+abasements
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+Abba
+abbe
+abbey
+abbeys
+abbot
+abbots
+Abbott
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+Abby
+abdomen
+abdomens
+abdominal
+abduct
+abducted
+abduction
+abductions
+abductor
+abductors
+abducts
+Abe
+abed
+Abel
+Abelian
+Abelson
+Aberdeen
+Abernathy
+aberrant
+aberration
+
+2 abase
+abased
+abasement
+abasements
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+Abba
+abbe
+abbey
+abbeys
+abbot
+abbots
+Abbott
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+Abby
+abdomen
+abdomens
+abdominal
+abduct
+abducted
+abduction
+abductions
+abductor
+abductors
+abducts
+Abe
+abed
+Abel
+Abelian
+Abelson
+Aberdeen
+Abernathy
+aberrant
+aberration
+
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE test.t1;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_log.result b/mysql-test/suite/rpl/r/rpl_stm_log.result
index 715d4976a95..bcefc6f9d3d 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_log.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_log.result
@@ -218,7 +218,7 @@ slave-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL)
slave-bin.000001 # Query 1 # use `test`; drop table t1
slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
slave-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581
-slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1
+slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1
slave-bin.000001 # Query 1 # use `test`; create table t3 (a int)ENGINE=MyISAM
slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4
show binlog events in 'slave-bin.000002' from 4;
diff --git a/mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result b/mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result
new file mode 100644
index 00000000000..feffefc9dad
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result
@@ -0,0 +1,26 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+==== Initialize ====
+[on master]
+CREATE TABLE t1 (a CHAR(48));
+CREATE TEMPORARY TABLE t1_tmp1(a INT);
+INSERT INTO t1 VALUES (UUID());
+[on slave]
+==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+Variable_name Value
+Slave_open_temp_tables 1
+[on master]
+[on slave]
+==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+Variable_name Value
+Slave_open_temp_tables 0
+==== Clean up ====
+[on master]
+DROP TABLE t1;
+[on slave]
diff --git a/mysql-test/suite/rpl/r/rpl_temporary.result b/mysql-test/suite/rpl/r/rpl_temporary.result
index 568d5368adb..8a9ddaec9f6 100644
--- a/mysql-test/suite/rpl/r/rpl_temporary.result
+++ b/mysql-test/suite/rpl/r/rpl_temporary.result
@@ -108,3 +108,16 @@ select * from t1;
a
1
drop table t1;
+-- Bug#43748
+-- make a user on the slave that can list but not kill system threads.
+FLUSH PRIVILEGES;
+GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow';
+GRANT PROCESS ON *.* TO user43748@127.0.0.1;
+-- try to KILL system-thread as that non-privileged user (on slave).
+SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1;
+KILL @id;
+Got one of the listed errors
+-- throw out test-user on slave.
+DROP USER user43748@127.0.0.1;
+-- done. back to master.
+End of 5.1 tests
diff --git a/mysql-test/suite/rpl/r/rpl_timezone.result b/mysql-test/suite/rpl/r/rpl_timezone.result
index 927756dd530..0b5c03b5300 100644
--- a/mysql-test/suite/rpl/r/rpl_timezone.result
+++ b/mysql-test/suite/rpl/r/rpl_timezone.result
@@ -122,4 +122,23 @@ a b
SET @@session.time_zone = default;
DROP TABLE t1;
SET @@session.time_zone = default;
+reset master;
+CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL);
+SET @@session.time_zone='+01:00';
+insert into t1 values('2008-12-23 19:39:39',1);
+SET @@session.time_zone='+02:00';
+insert delayed into t1 values ('2008-12-23 19:39:39',2);
+flush table t1;
+flush logs;
+select * from t1;
+date a
+2008-12-23 20:39:39 1
+2008-12-23 19:39:39 2
+DROP TABLE t1;
+select * from t1 order by a;
+date a
+2008-12-23 20:39:39 1
+2008-12-23 19:39:39 2
+DROP TABLE t1;
+SET @@session.time_zone = default;
End of 5.0 tests
diff --git a/mysql-test/suite/rpl/r/rpl_udf.result b/mysql-test/suite/rpl/r/rpl_udf.result
index 79a82b5fbc7..56df5b30d93 100644
--- a/mysql-test/suite/rpl/r/rpl_udf.result
+++ b/mysql-test/suite/rpl/r/rpl_udf.result
@@ -182,19 +182,19 @@ CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM;
affected rows: 0
INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00));
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
affected rows: 1
INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00));
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
affected rows: 1
INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00));
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
affected rows: 1
INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00));
Warnings:
-Warning 1592 Statement is not safe to log in statement format.
+Note 1592 Statement is not safe to log in statement format.
affected rows: 1
SELECT * FROM t1 ORDER BY sum;
sum price
diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def
index f3f329c4b5b..b7cb6da8127 100644
--- a/mysql-test/suite/rpl/t/disabled.def
+++ b/mysql-test/suite/rpl/t/disabled.def
@@ -10,4 +10,4 @@
#
##############################################################################
-rpl_binlog_corruption : BUG#41793 2008-12-30 sven rpl_binlog_corruption disabled in main (needs new mtr)
+rpl_cross_version : BUG#42311 2009-03-27 joro rpl_cross_version fails on macosx
diff --git a/mysql-test/suite/rpl/t/rpl_000015-slave.sh b/mysql-test/suite/rpl/t/rpl_000015-slave.sh
deleted file mode 100755
index 7deeca3d2d6..00000000000
--- a/mysql-test/suite/rpl/t/rpl_000015-slave.sh
+++ /dev/null
@@ -1 +0,0 @@
-rm -f $MYSQLTEST_VARDIR/slave-data/master.info
diff --git a/mysql-test/suite/rpl/t/rpl_binlog_corruption.test b/mysql-test/suite/rpl/t/rpl_binlog_corruption.test
index 39799180f8b..dfab035a7a8 100644
--- a/mysql-test/suite/rpl/t/rpl_binlog_corruption.test
+++ b/mysql-test/suite/rpl/t/rpl_binlog_corruption.test
@@ -34,6 +34,7 @@ source include/setup_fake_relay_log.inc;
--echo ==== Test ====
START SLAVE SQL_THREAD;
+let $slave_sql_errno= 1594; # ER_SLAVE_RELAY_LOG_READ_FAILURE
source include/wait_for_slave_sql_error.inc;
let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
--echo Last_SQL_Error = $error
diff --git a/mysql-test/suite/rpl/t/rpl_bug33931.test b/mysql-test/suite/rpl/t/rpl_bug33931.test
index a439b346538..13f781c644b 100644
--- a/mysql-test/suite/rpl/t/rpl_bug33931.test
+++ b/mysql-test/suite/rpl/t/rpl_bug33931.test
@@ -15,7 +15,7 @@ reset master;
connection slave;
# Add suppression for expected warnings in slaves error log
-call mtr.add_suppression("Failed during slave.*thread initialization");
+call mtr.add_suppression("Failed during slave thread initialization");
--disable_warnings
stop slave;
@@ -37,8 +37,8 @@ connection slave;
#
source include/wait_for_slave_to_stop.inc;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 8 # 9 # 19 # 23 # 33 # 37 #
query_vertical show slave status;
#
diff --git a/mysql-test/suite/rpl/t/rpl_bug38694-slave.opt b/mysql-test/suite/rpl/t/rpl_bug38694-slave.opt
new file mode 100644
index 00000000000..d96e981b198
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_bug38694-slave.opt
@@ -0,0 +1 @@
+--loose-debug=d,simulate_slave_delay_at_terminate_bug38694
diff --git a/mysql-test/suite/rpl/t/rpl_bug38694.test b/mysql-test/suite/rpl/t/rpl_bug38694.test
new file mode 100644
index 00000000000..41b11d271b9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_bug38694.test
@@ -0,0 +1,10 @@
+# Testing replication threads stopping concurrency issue
+# at the server shutdown
+# Related bugs: bug#38694, bug#29968, bug#25306
+# The test checks if a delay at the termination phase of slave threads
+# DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
+# could cause any issue.
+
+source include/master-slave.inc;
+
+# End of tests
diff --git a/mysql-test/suite/rpl/t/rpl_cross_version.test b/mysql-test/suite/rpl/t/rpl_cross_version.test
index adeba7f2b15..8cd268a5fd9 100644
--- a/mysql-test/suite/rpl/t/rpl_cross_version.test
+++ b/mysql-test/suite/rpl/t/rpl_cross_version.test
@@ -11,7 +11,12 @@
#
--source include/have_log_bin.inc
+
+# The test is disabled for windows due to
+# Bug #42879 CHANGE MASTER RELAY_LOG_FILE=path fails on windows
+# Todo: release it from not_windows
--source include/not_windows.inc
+
#
# Bug#31240 load data infile replication between (4.0 or 4.1) and 5.1 fails
#
diff --git a/mysql-test/suite/rpl/t/rpl_do_grant.test b/mysql-test/suite/rpl/t/rpl_do_grant.test
index 5615900c2dd..806de780086 100644
--- a/mysql-test/suite/rpl/t/rpl_do_grant.test
+++ b/mysql-test/suite/rpl/t/rpl_do_grant.test
@@ -112,3 +112,100 @@ show grants for rpl_do_grant2@localhost;
sync_slave_with_master;
--error 1141
show grants for rpl_do_grant2@localhost;
+
+#####################################################
+# Purpose
+# Test whether mysql.procs_priv get replicated
+# Related bugs:
+# BUG42217 mysql.procs_priv does not get replicated
+#####################################################
+connection master;
+
+--disable_warnings
+DROP DATABASE IF EXISTS bug42217_db;
+--enable_warnings
+CREATE DATABASE bug42217_db;
+
+GRANT CREATE ROUTINE ON bug42217_db.* TO 'create_rout_db'@'localhost'
+ IDENTIFIED BY 'create_rout_db' WITH GRANT OPTION;
+
+connect (create_rout_db_master, localhost, create_rout_db, create_rout_db, bug42217_db,$MASTER_MYPORT,);
+connect (create_rout_db_slave, localhost, create_rout_db, create_rout_db, bug42217_db, $SLAVE_MYPORT,);
+
+connection create_rout_db_master;
+
+
+USE bug42217_db;
+
+DELIMITER //;
+CREATE FUNCTION upgrade_del_func() RETURNS CHAR(30)
+BEGIN
+ RETURN "INSIDE upgrade_del_func()";
+END//
+
+DELIMITER ;//
+
+connection master;
+
+USE bug42217_db;
+--replace_column 8 #
+SELECT * FROM mysql.procs_priv;
+SELECT upgrade_del_func();
+
+sync_slave_with_master;
+--replace_column 8 #
+SELECT * FROM mysql.procs_priv;
+SHOW GRANTS FOR 'create_rout_db'@'localhost';
+
+USE bug42217_db;
+SHOW CREATE FUNCTION upgrade_del_func;
+SELECT upgrade_del_func();
+
+--echo "Check whether the definer user will be able to execute the replicated routine on slave"
+connection create_rout_db_slave;
+USE bug42217_db;
+SHOW CREATE FUNCTION upgrade_del_func;
+SELECT upgrade_del_func();
+
+connection slave;
+DELETE FROM mysql.procs_priv;
+FLUSH PRIVILEGES;
+USE bug42217_db;
+--echo "Can't execute the replicated routine on slave like before after procs privilege is deleted "
+--error 1370
+SELECT upgrade_del_func();
+
+--echo "Test the user who creates a function on master doesn't exist on slave."
+--echo "Hence SQL thread ACL_GLOBAL privilege jumps in and no mysql.procs_priv is inserted"
+DROP USER 'create_rout_db'@'localhost';
+
+connection create_rout_db_master;
+DELIMITER //;
+CREATE FUNCTION upgrade_alter_func() RETURNS CHAR(30)
+BEGIN
+ RETURN "INSIDE upgrade_alter_func()";
+END//
+DELIMITER ;//
+
+connection master;
+SELECT upgrade_alter_func();
+
+sync_slave_with_master;
+SHOW CREATE FUNCTION upgrade_alter_func;
+--echo "Should no privilege record for upgrade_alter_func in mysql.procs_priv"
+--replace_column 8 #
+SELECT * FROM mysql.procs_priv;
+--error 1449
+SELECT upgrade_alter_func();
+
+###### CLEAN UP SECTION ##############
+disconnect create_rout_db_master;
+disconnect create_rout_db_slave;
+connection master;
+USE bug42217_db;
+DROP FUNCTION upgrade_del_func;
+DROP FUNCTION upgrade_alter_func;
+DROP DATABASE bug42217_db;
+DROP USER 'create_rout_db'@'localhost';
+
+--echo "End of test"
diff --git a/mysql-test/suite/rpl/t/rpl_drop_if_exists.test b/mysql-test/suite/rpl/t/rpl_drop_if_exists.test
new file mode 100644
index 00000000000..6b2b37ae791
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_drop_if_exists.test
@@ -0,0 +1,115 @@
+# BUG#13684:
+# SP: DROP PROCEDURE|FUNCTION IF EXISTS not binlogged if routine
+# does not exist
+#
+# There is an inconsistency with DROP DATABASE IF EXISTS, DROP
+# TABLE IF EXISTS and DROP VIEW IF EXISTS: those are binlogged even
+# if the DB or TABLE does not exist, whereas DROP PROCEDURE IF
+# EXISTS does not. It would be nice or at least consistent if DROP
+# PROCEDURE/STATEMENT worked the same too.
+#
+# Description:
+# DROP PROCEDURE|FUNCTION IF EXISTS does not get binlogged whereas DROP
+# DATABASE|TABLE|TRIGGER|... IF EXISTS do.
+#
+# Fixed DROP PROCEDURE|FUNCTION IF EXISTS by adding a call to
+# write_bin_log in mysql_execute_command. Checked also if all
+# documented "DROP (...) IF EXISTS" get binlogged. Left out DROP
+# SERVER IF EXISTS because it seems that it only gets binlogged when
+# using row event (see BUG#25705).
+#
+# TODO: add DROP SERVER IF EXISTS to the test case when its
+# binlogging procedure gets fixed (BUG#25705). Furthermore, when
+# logging in RBR format the events that get logged are effectively in
+# RBR format and not in STATEMENT format meaning that one must needs
+# to be extra careful when writing a test for it, or change the CREATE
+# SERVER logging to always log as STATEMENT. You can quickly check this
+# by enabling the flag below $fixed_bug_25705=1 and watch the diff on
+# the STDOUT. More detail may be found on the generated reject file.
+#
+# Test is implemented as follows:
+#
+# i) test each "drop if exists" (DDL), found in MySQL 5.1 manual,
+# on inexistent objects (except for DROP SERVER);
+# ii) show binlog events;
+# iii) create an object for each drop if exists statement;
+# iv) issue "drop if exists" in existent objects.
+# v) show binlog events;
+#
+# References:
+# http://dev.mysql.com/doc/refman/5.1/en/sql-syntax-data-definition.html
+#
+--source include/have_log_bin.inc
+RESET MASTER;
+
+disable_warnings;
+
+# test all "drop if exists" in manual with inexistent objects
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+
+let $fixed_bug_25705 = 0;
+
+if($fixed_bug_25705)
+{
+ DROP SERVER IF EXISTS s_bug_13684;
+}
+--source include/show_binlog_events.inc
+
+# test drop with existing values
+
+# create
+CREATE DATABASE db_bug_13684;
+
+CREATE TABLE db_bug_13684.t (a int);
+
+CREATE EVENT db_bug_13684.e
+ ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
+ DO
+ UPDATE db_bug_13684.t SET a = a + 1;
+
+CREATE VIEW db_bug_13684.v
+ AS SELECT * FROM db_bug_13684.t;
+
+CREATE TRIGGER db_bug_13684.tr BEFORE INSERT ON db_bug_13684.t
+ FOR EACH ROW BEGIN
+ END;
+
+CREATE PROCEDURE db_bug_13684.p (OUT p1 INT)
+ BEGIN
+ END;
+
+CREATE FUNCTION db_bug_13684.f (s CHAR(20))
+ RETURNS CHAR(50) DETERMINISTIC
+ RETURN s;
+
+if($fixed_bug_25705)
+{
+ CREATE SERVER s_bug_13684
+ FOREIGN DATA WRAPPER mysql
+ OPTIONS (USER 'Remote', HOST '192.168.1.106', DATABASE 'test');
+}
+
+--source include/show_binlog_events.inc
+
+# drop existing
+DROP PROCEDURE IF EXISTS db_bug_13684.p;
+DROP FUNCTION IF EXISTS db_bug_13684.f;
+DROP TRIGGER IF EXISTS db_bug_13684.tr;
+DROP VIEW IF EXISTS db_bug_13684.v;
+DROP EVENT IF EXISTS db_bug_13684.e;
+DROP TABLE IF EXISTS db_bug_13684.t;
+DROP DATABASE IF EXISTS db_bug_13684;
+if($fixed_bug_25705)
+{
+ DROP SERVER IF EXISTS s_bug_13684;
+}
+
+--source include/show_binlog_events.inc
+
+enable_warnings;
diff --git a/mysql-test/suite/rpl/t/rpl_idempotency.test b/mysql-test/suite/rpl/t/rpl_idempotency.test
index 1946aa100ab..bfd1860759e 100644
--- a/mysql-test/suite/rpl/t/rpl_idempotency.test
+++ b/mysql-test/suite/rpl/t/rpl_idempotency.test
@@ -208,7 +208,7 @@ select * from ti1 order by b /* must be (2),(3) */;
# foreign key: row is referenced
---echo *** slave must stop
+--echo *** slave must stop (Trying to delete a referenced foreing key)
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
@@ -242,7 +242,7 @@ delete from ti1 where b=3;
connection master;
insert into ti2 set a=3, b=3 /* offending write event */;
---echo *** slave must stop
+--echo *** slave must stop (Trying to insert an invalid foreign key)
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
@@ -281,7 +281,7 @@ insert into ti1 set b=1;
connection master;
insert into ti1 set b=1 /* offending write event */;
---echo *** slave must stop
+--echo *** slave must stop (Trying to insert a dupliacte key)
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
@@ -316,7 +316,7 @@ DELETE FROM t2 WHERE a = -2;
connection master;
DELETE FROM t1 WHERE a = -2;
---echo *** slave must stop
+--echo *** slave must stop (Key was not found)
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
@@ -333,8 +333,8 @@ sync_slave_with_master;
set global slave_exec_mode='STRICT';
connection master;
-DELETE FROM t2 WHERE a = -2;
---echo *** slave must stop
+DELETE FROM t2 WHERE a = -2;
+--echo *** slave must stop (Key was not found)
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
@@ -356,7 +356,7 @@ UPDATE t2 SET a = 1 WHERE a = -1;
connection master;
UPDATE t1 SET a = 1 WHERE a = -1;
---echo *** slave must stop
+--echo *** slave must stop (Key was not found)
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
@@ -376,7 +376,7 @@ set global slave_exec_mode='STRICT';
connection master;
UPDATE t2 SET a = 1 WHERE a = -1;
---echo *** slave must stop
+--echo *** slave must stop (Key was not found)
connection slave;
source include/wait_for_slave_sql_to_stop.inc;
diff --git a/mysql-test/suite/rpl/t/rpl_init_slave_errors.test b/mysql-test/suite/rpl/t/rpl_init_slave_errors.test
new file mode 100644
index 00000000000..4ca0de6ec66
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_init_slave_errors.test
@@ -0,0 +1,86 @@
+######################################################################
+# Some errors that cause the slave SQL thread to stop are not shown in
+# the Slave_SQL_Error column of "SHOW SLAVE STATUS". Instead, the error
+# is only in the server's error log.
+#
+# Two failures and their respective reporting are verified:
+#
+# 1 - Failures during slave thread initialization
+# 2 - Failures while processing queries passed through the init_slave
+# option.
+#
+# In order to check the first type of failure, we inject a fault in the
+# SQL/IO Threads through SET GLOBAL debug.
+#
+# To check the second type, we set @@global.init_slave to an invalid
+# command thus preventing the initialization of the SQL Thread.
+#
+# Obs:
+# 1 - Note that testing failures while initializing the relay log position
+# is hard as the same function is called before the code reaches the point
+# that we want to test.
+#
+# 2 - This test does not target failures that are reported while applying
+# events such as duplicate keys, errors while reading the relay-log.bin*,
+# etc. Such errors are already checked on other tests.
+######################################################################
+
+######################################################################
+# Configuring the Environment
+######################################################################
+source include/have_debug.inc;
+source include/master-slave.inc;
+source include/have_log_bin.inc;
+
+connection slave;
+
+--disable_warnings
+stop slave;
+--enable_warnings
+reset slave;
+
+######################################################################
+# Injecting faults in the threads' initialization
+######################################################################
+connection slave;
+
+# Set debug flags on slave to force errors to occur
+SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
+
+start slave;
+
+#
+# slave is going to stop because of emulated failures
+# but there won't be any crashes nor asserts hit.
+#
+source include/wait_for_slave_to_stop.inc;
+
+let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1);
+echo Reporting the following error: $error;
+
+SET GLOBAL debug= "";
+
+######################################################################
+# Injecting faults in the init_slave option
+######################################################################
+connection slave;
+
+--disable_warnings
+stop slave;
+--enable_warnings
+source include/wait_for_slave_to_stop.inc;
+
+reset slave;
+
+SET GLOBAL init_slave= "garbage";
+
+start slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1);
+echo Reporting the following error: $error;
+
+######################################################################
+# Clean up
+######################################################################
+SET GLOBAL init_slave= "";
diff --git a/mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt b/mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt
new file mode 100644
index 00000000000..aaf2d8a4251
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_killed_ddl-master.opt
@@ -0,0 +1 @@
+--debug=d,debug_lock_before_query_log_event
diff --git a/mysql-test/suite/rpl/t/rpl_killed_ddl.test b/mysql-test/suite/rpl/t/rpl_killed_ddl.test
new file mode 100644
index 00000000000..26bd4957279
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_killed_ddl.test
@@ -0,0 +1,352 @@
+# ==== Purpose ====
+#
+# This test check if DDL statements are correctly binlogged when the
+# thread is killed
+#
+# ==== Method ====
+#
+# Start a DDL query and kill it, check if the error code of the binlog
+# event is correct.
+#
+# DDL statements tested:
+# CREATE/ALTER/RENAME/DROP DATABASE
+# CREATE/ALTER/DROP EVENT
+# CREATE/ALTER/DROP FUNCTION
+# CREATE/ALTER/DROP PROCEDURE
+# CREATE/ALTER/DROP SERVER
+# CREATE/ALTER/RENAME/DROP TABLE
+# CREATE/DROP TRIGGER
+# CREATE/ALTER/DROP VIEW
+#
+# ==== Bugs =====
+#
+# BUG#37145
+#
+# ==== TODO ====
+#
+# There are some part of the test are temporarily disabled because of
+# the following bugs, please enable then once they get fixed:
+# - BUG#44041
+# - BUG#43353
+# - BUG#25705
+# - BUG#44171
+
+source include/have_debug.inc;
+source include/master-slave.inc;
+
+# Use the DBUG_SYNC_POINT to make sure the thread running the DDL is
+# waiting before creating the query log event
+
+let $debug_lock= "debug_lock.before_query_log_event";
+
+######## INITIALIZATION ########
+
+disable_warnings;
+DROP DATABASE IF EXISTS d1;
+DROP DATABASE IF EXISTS d2;
+DROP DATABASE IF EXISTS d3;
+DROP DATABASE IF EXISTS d4;
+DROP EVENT IF EXISTS e1;
+DROP EVENT IF EXISTS e2;
+DROP EVENT IF EXISTS e3;
+DROP EVENT IF EXISTS e4;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP FUNCTION IF EXISTS f3;
+DROP FUNCTION IF EXISTS f4;
+DROP SERVER IF EXISTS s1;
+DROP SERVER IF EXISTS s2;
+DROP SERVER IF EXISTS s3;
+DROP SERVER IF EXISTS s4;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+DROP TRIGGER IF EXISTS tr1;
+DROP TRIGGER IF EXISTS tr2;
+DROP TRIGGER IF EXISTS tr3;
+DROP TRIGGER IF EXISTS tr4;
+enable_warnings;
+
+CREATE DATABASE d1;
+
+CREATE EVENT e1
+ ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
+ DO INSERT INTO test.t1 VALUES (1);
+
+CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC
+ RETURN 1;
+
+DELIMITER //;
+CREATE PROCEDURE p1 (OUT rows INT)
+ BEGIN
+ SELECT COUNT(*) INTO rows FROM t1;
+ END;
+ //
+DELIMITER ;//
+
+CREATE SERVER s1
+FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'user1', HOST '192.168.1.106', DATABASE 'test');
+
+CREATE TABLE t1 (a int);
+CREATE TABLE t3 (a int);
+
+DELIMITER //;
+CREATE TRIGGER tr1 BEFORE INSERT ON t1
+ FOR EACH ROW BEGIN
+ DELETE FROM t4 WHERE a=NEW.a;
+ END;
+ //
+DELIMITER ;//
+
+CREATE INDEX i1 ON t1 (a);
+
+CREATE VIEW v1 AS SELECT a FROM t1 WHERE a < 100;
+
+sync_slave_with_master;
+
+connection master1;
+let $connection_name= master1;
+let $connection_id= `SELECT CONNECTION_ID()`;
+
+connection master;
+echo [on master];
+
+# This will block the execution of a statement at the DBUG_SYNC_POINT
+# with given lock name
+if (`SELECT '$debug_lock' != ''`)
+{
+ disable_query_log;
+ disable_result_log;
+ eval SELECT IS_FREE_LOCK($debug_lock);
+ eval SELECT GET_LOCK($debug_lock, 10);
+ eval SELECT IS_FREE_LOCK($debug_lock);
+ enable_query_log;
+ enable_result_log;
+}
+
+######## START TEST ########
+
+connection master1;
+echo [on master1];
+
+disable_warnings;
+
+######## DATABASE ########
+
+let $diff_statement= SHOW DATABASES LIKE 'd%';
+
+send CREATE DATABASE d2;
+source include/kill_query_and_diff_master_slave.inc;
+
+# Temporarily disabled, see BUG#44041, the ALTER DATABASE can affect the
+# collation of other database on slave
+#send ALTER DATABASE d1
+# DEFAULT CHARACTER SET = 'utf8';
+#source include/kill_query_and_diff_master_slave.inc;
+
+send DROP DATABASE d1;
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP DATABASE d2;
+source include/kill_query_and_diff_master_slave.inc;
+
+######## EVENT ########
+
+let $diff_statement= SELECT event_name, event_body, execute_at
+ FROM information_schema.events where event_name like 'e%';
+
+send CREATE EVENT e2
+ ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
+ DO INSERT INTO test.t1 VALUES (2);
+source include/kill_query_and_diff_master_slave.inc;
+
+# Temporarily disabled because of BUG#44171, killing ALTER EVENT can
+# crash the server
+#send ALTER EVENT e1
+# ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 DAY;
+#source include/kill_query_and_diff_master_slave.inc;
+
+send DROP EVENT e1;
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP EVENT IF EXISTS e2;
+source include/kill_query_and_diff_master_slave.inc;
+
+######## FUNCTION ########
+
+let $diff_statement= SHOW FUNCTION STATUS LIKE 'f%';
+
+send CREATE FUNCTION f2 () RETURNS INT DETERMINISTIC
+ RETURN 1;
+source include/kill_query_and_diff_master_slave.inc;
+
+send ALTER FUNCTION f1 SQL SECURITY INVOKER;
+source include/kill_query_and_diff_master_slave.inc;
+
+# function f1 probably does not exist because the ALTER query was
+# killed
+send DROP FUNCTION f1;
+source include/kill_query_and_diff_master_slave.inc;
+
+# function f2 probably does not exist because the CREATE query was
+# killed
+#
+# Temporarily disabled. Because of BUG#43353, KILL the query may
+# result in function not found, and for 5.1, DROP statements will be
+# logged if the function is not found on master, so the following DROP
+# FUNCTION statement may be interrupted and not drop the function on
+# master, but still get logged and executed on slave and cause
+# inconsistence. Also disable the following DROP PROCEDURE IF EXITS
+# below.
+#send DROP FUNCTION IF EXISTS f2;
+#source include/kill_query_and_diff_master_slave.inc;
+
+######## PROCEDURE ########
+
+let $diff_statement= SHOW PROCEDURE STATUS LIKE 'p%';
+
+DELIMITER //;
+send CREATE PROCEDURE p2 (OUT rows INT)
+ BEGIN
+ SELECT COUNT(*) INTO rows FROM t2;
+ END;
+ //
+DELIMITER ;//
+source include/kill_query_and_diff_master_slave.inc;
+
+send ALTER PROCEDURE p1 SQL SECURITY INVOKER COMMENT 'return rows of table t1';
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP PROCEDURE p1;
+source include/kill_query_and_diff_master_slave.inc;
+
+# Temporarily disabled, see comment above for DROP FUNCTION IF EXISTS
+#send DROP PROCEDURE IF EXISTS p2;
+#source include/kill_query_and_diff_master_slave.inc;
+
+######## TABLE ########
+
+let $diff_statement= SHOW TABLES LIKE 't%';
+
+send CREATE TABLE t2 (b int);
+source include/kill_query_and_diff_master_slave.inc;
+
+send ALTER TABLE t1 ADD (d int);
+source include/kill_query_and_diff_master_slave.inc;
+
+send RENAME TABLE t3 TO t4;
+source include/kill_query_and_diff_master_slave.inc;
+
+######## INDEX ########
+
+let $diff_statement= SHOW INDEX FROM t1;
+
+send CREATE INDEX i2 on t1 (a);
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP INDEX i1 on t1;
+source include/kill_query_and_diff_master_slave.inc;
+
+
+######## SERVER ########
+
+# Tempoarily disabled, see bug#25705
+
+# let $diff_statement= SELECT * FROM mysql.server WHERE name like 's%';
+
+# send CREATE SERVER s2
+# FOREIGN DATA WRAPPER mysql
+# OPTIONS (USER 'user2', HOST '192.168.1.108', DATABASE 'test');
+# source include/kill_query_and_diff_master_slave.inc;
+
+# send ALTER SERVER s1
+# OPTIONS (DATABASE 'test1');
+# source include/kill_query_and_diff_master_slave.inc;
+
+# send DROP SERVER s1;
+# source include/kill_query_and_diff_master_slave.inc;
+
+# send DROP SERVER IF EXIST s1;
+# source include/kill_query_and_diff_master_slave.inc;
+
+######## TRIGGER ########
+
+let $diff_statement= SHOW TRIGGERS LIKE 'v%';
+
+DELIMITER //;
+send CREATE TRIGGER tr2 BEFORE INSERT ON t4
+ FOR EACH ROW BEGIN
+ DELETE FROM t1 WHERE a=NEW.a;
+ END;
+ //
+DELIMITER ;//
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP TRIGGER tr1;
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP TRIGGER IF EXISTS tr2;
+source include/kill_query_and_diff_master_slave.inc;
+
+######## VIEW ########
+
+let $diff_statement= SHOW TABLES LIKE 'v%';
+
+send CREATE VIEW v2 AS SELECT a FROM t1 WHERE a > 100;
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP VIEW v1;
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP VIEW IF EXISTS v2;
+source include/kill_query_and_diff_master_slave.inc;
+
+######## DROP TABLE ########
+
+let $diff_statement= SHOW TABLES LIKE 't%';
+
+send DROP TABLE t1;
+source include/kill_query_and_diff_master_slave.inc;
+
+send DROP TABLE IF EXISTS t2;
+source include/kill_query_and_diff_master_slave.inc;
+
+######## CLEAN UP ########
+
+connection master;
+
+# The DROP statements above are killed during the process, so they
+# does not make sure the objects are dropped.
+
+disable_warnings;
+DROP DATABASE IF EXISTS d1;
+DROP DATABASE IF EXISTS d2;
+DROP DATABASE IF EXISTS d3;
+DROP DATABASE IF EXISTS d4;
+DROP EVENT IF EXISTS e1;
+DROP EVENT IF EXISTS e2;
+DROP EVENT IF EXISTS e3;
+DROP EVENT IF EXISTS e4;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP FUNCTION IF EXISTS f3;
+DROP FUNCTION IF EXISTS f4;
+DROP SERVER IF EXISTS s1;
+DROP SERVER IF EXISTS s2;
+DROP SERVER IF EXISTS s3;
+DROP SERVER IF EXISTS s4;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+DROP TABLE IF EXISTS t4;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+DROP PROCEDURE IF EXISTS p4;
+enable_warnings;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
index 0de402f301a..23c802ab3de 100644
--- a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
+++ b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
@@ -64,3 +64,37 @@ drop table t1;
save_master_pos;
connection slave;
sync_with_master;
+
+
+#
+# Bug22504 load data infile sql statement in replication architecture get error
+#
+--echo ==== Bug22504 Initialize ====
+
+--echo [on master]
+--connection master
+
+SET sql_mode='ignore_space';
+CREATE TABLE t1(a int);
+insert into t1 values (1), (2), (3), (4);
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval select * into outfile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1;
+truncate table t1;
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval load data local infile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1;
+--remove_file $MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile
+SELECT * FROM t1 ORDER BY a;
+
+--echo [on slave]
+sync_slave_with_master;
+SELECT * FROM t1 ORDER BY a;
+
+--echo ==== Clean up ====
+
+--echo [on master]
+connection master;
+DROP TABLE t1;
+
+--echo [on slave]
+sync_slave_with_master;
+
diff --git a/mysql-test/suite/rpl/t/rpl_loadfile.test b/mysql-test/suite/rpl/t/rpl_loadfile.test
index 5aa4da41fe5..adb23d2c2bc 100644
--- a/mysql-test/suite/rpl/t/rpl_loadfile.test
+++ b/mysql-test/suite/rpl/t/rpl_loadfile.test
@@ -11,43 +11,105 @@
# Includes
-- source include/master-slave.inc
+-- source include/have_binlog_format_mixed_or_row.inc
+-- source extra/rpl_tests/rpl_loadfile.test
+
+# BUG#39701: Mixed binlog format does not switch to row mode on LOAD_FILE
+#
+# DESCRIPTION
+#
+# Problem: when using load_file string function and mixed binlogging format
+# there was no switch to row based binlogging format. This leads
+# to scenarios on which the slave replicates the statement and it
+# will try to load the file from local file system, which in most
+# likely it will not exist.
+#
+# Solution:
+# Marking this function as unsafe for statement format, makes the
+# statement using it to be logged in row based format. As such, data
+# replicated from the master, becomes the content of the loaded file.
+# Consequently, the slave receives the necessary data to complete
+# the load_file instruction correctly.
+#
+# IMPLEMENTATION
+#
+# The test is implemented as follows:
+#
+# On Master,
+# i) write to file the desired content.
+# ii) create table and stored procedure with load_file
+# iii) stop slave
+# iii) execute load_file
+# iv) remove file
+#
+# On Slave,
+# v) start slave
+# vi) sync it with master so that it gets the updates from binlog (which
+# should have bin logged in row format).
+#
+# If the the binlog format does not change to row, then the assertion
+# done in the following step fails. This happens because tables differ
+# since the file does not exist anymore, meaning that when slave
+# attempts to execute LOAD_FILE statement it inserts NULL on table
+# instead of the same contents that the master loaded when it executed
+# the procedure (which was executed when file existed).
+#
+# vii) assert that the contents of master and slave
+# table are the same
-# Begin clean up test section
---disable_warnings
connection master;
-DROP PROCEDURE IF EXISTS test.p1;
-DROP TABLE IF EXISTS test.t1;
---enable_warnings
-
-# Section 1 test
-
-CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
-INSERT INTO test.t1 VALUES(1,'test');
-UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=1;
-delimiter |;
-create procedure test.p1()
-begin
- INSERT INTO test.t1 VALUES(2,'test');
- UPDATE test.t1 SET blob_column=LOAD_FILE('../../std_data/words2.dat') WHERE a=2;
-end|
-delimiter ;|
-
-CALL test.p1();
-SELECT * FROM test.t1 ORDER BY blob_column;
-save_master_pos;
-sync_slave_with_master;
+source include/reset_master_and_slave.inc;
+
+connection master;
+let $file= $MYSQLTEST_VARDIR/tmp/bug_39701.data;
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval SELECT repeat('x',20) INTO OUTFILE '$file'
+
+disable_warnings;
+DROP TABLE IF EXISTS t1;
+enable_warnings;
+
+CREATE TABLE t1 (t text);
+DELIMITER |;
+CREATE PROCEDURE p(file varchar(4096))
+ BEGIN
+ INSERT INTO t1 VALUES (LOAD_FILE(file));
+ END|
+DELIMITER ;|
+
+# stop slave before issuing the load_file on master
connection slave;
-# Need to allow some time when NDB engine is used for
-# the injector thread to have time to populate binlog
-let $wait_condition= SELECT INSTR(blob_column,'aberration') > 0 FROM test.t1 WHERE a = 2;
---source include/wait_condition.inc
-SELECT * FROM test.t1 ORDER BY blob_column;
+source include/stop_slave.inc;
+
+connection master;
+
+# test: check that logging falls back to rbr.
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval CALL p('$file')
+
+# test: remove the file from the filesystem and assert that slave still
+# gets the loaded file
+remove_file $file;
+
+# now that the file is removed it is safe (regarding what we want to test)
+# to start slave
+connection slave;
+source include/start_slave.inc;
-# Cleanup
connection master;
-DROP PROCEDURE IF EXISTS test.p1;
-DROP TABLE test.t1;
sync_slave_with_master;
-# End of 5.0 test case
+# assertion: assert that the slave got the updates even
+# if the file was removed before the slave started,
+# meaning that contents were indeed transfered
+# through binlog (in row format)
+let $diff_table_1=master:test.t1;
+let $diff_table_2=slave:test.t1;
+source include/diff_tables.inc;
+
+# CLEAN UP
+DROP TABLE t1;
+DROP PROCEDURE p;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_mixed_bit_pk.test b/mysql-test/suite/rpl/t/rpl_mixed_bit_pk.test
new file mode 100644
index 00000000000..55f6ad61446
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_mixed_bit_pk.test
@@ -0,0 +1,78 @@
+#
+# BUG
+# ---
+# BUG#39753: Replication failure on MIXED + bit + myisam + no PK
+#
+# Description
+# -----------
+# Simple statements against a bit column cause failure in mixed-mode
+# replication.
+#
+# Implementation is as follows:
+# i) A table with two bit fields is created. One of them is a key.
+# ii) A record is inserted without specifying the key value.
+# iii) The record is deleted using a where clause that matches it.
+# iv) repeat i-iii) for bit key that has different size, generating
+# different extra bits values
+# v) The slave is synchronized with master
+# vi) The table is dropped on master and the slave is re-synchronized
+# with master.
+#
+# Step v) made the bug evident before the patch, as the slave would
+# fail to find the correspondent row in its database (although it did
+# the insert in step ii) ).
+#
+# Obs
+# ---
+# This test is based on the "how to repeat" section from the bug report.
+#
+#
+
+--source include/master-slave.inc
+
+--disable_warnings
+# setup
+
+DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
+CREATE TABLE t1 (`bit_key` bit, `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t2 (`bit_key` bit(4), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t3 (`bit_key` bit(7), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t4 (`bit_key` bit(8), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t5 (`bit_key` bit(9), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t6 (`bit_key` bit(14), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t7 (`bit_key` bit(15), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+CREATE TABLE t8 (`bit_key` bit(16), `bit` bit, key (`bit_key` )) ENGINE=MyISAM;
+
+# insert and delete
+INSERT INTO `t1` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t1` WHERE `bit` < 2 LIMIT 4;
+
+INSERT INTO `t2` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t2` WHERE `bit` < 2 LIMIT 4;
+
+INSERT INTO `t3` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t3` WHERE `bit` < 2 LIMIT 4;
+
+INSERT INTO `t4` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t4` WHERE `bit` < 2 LIMIT 4;
+
+INSERT INTO `t5` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t5` WHERE `bit` < 2 LIMIT 4;
+
+INSERT INTO `t6` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t6` WHERE `bit` < 2 LIMIT 4;
+
+INSERT INTO `t7` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t7` WHERE `bit` < 2 LIMIT 4;
+
+INSERT INTO `t8` ( `bit` ) VALUES ( 0 );
+DELETE FROM `t8` WHERE `bit` < 2 LIMIT 4;
+
+
+--enable_warnings
+sync_slave_with_master;
+
+# clean up
+connection master;
+DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_name_const.test b/mysql-test/suite/rpl/t/rpl_name_const.test
new file mode 100644
index 00000000000..adb71d452ef
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_name_const.test
@@ -0,0 +1,47 @@
+# ==== Purpose ====
+#
+# Test that aliases of variables in binary log aren't ignored with NAME_CONST.
+#
+# ==== Method ====
+#
+# Create a procedure with aliases of variables, then replicate it to slave.
+# BUG#35515 Aliases of variables in binary log are ignored with NAME_CONST.
+#
+
+source include/master-slave.inc;
+
+--echo ==== Initialize ====
+
+--echo [on master]
+--connection master
+
+create table t1 (id int);
+
+--echo ==== create a procedure that has a column aliase in a subquery ====
+--disable_warnings
+drop procedure if exists test_procedure;
+--enable_warnings
+delimiter $$;
+create procedure test_procedure(_id int)
+begin
+insert into t1 (id)
+select a.id
+from
+( select _id as id ) a;
+end;$$
+delimiter ;$$
+
+--echo ==== enable the binary log, then call the procedure ====
+call test_procedure(1234);
+
+
+--echo [on slave]
+sync_slave_with_master;
+select * from t1 order by id;
+
+--echo ==== Clean up ====
+
+--echo [on master]
+connection master;
+drop table t1;
+drop procedure test_procedure;
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
index 2bad7b27272..e06099fd707 100644
--- a/mysql-test/suite/rpl/t/rpl_rotate_logs.test
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
@@ -112,14 +112,24 @@ source include/show_master_logs.inc;
purge binary logs to 'master-bin.000002';
source include/show_binary_logs.inc;
-# Calculate time to use in "purge master logs before" by taking
-# last modification time of t2 and adding 1 second
-# This is donw in order to handle the case where file system
-# time differs from mysqld's time
+# Set the purge time 1 second after the last modify time of master-bin.000002.
+perl;
+open F, ">>".$ENV{'MYSQLTEST_VARDIR'}.'/tmp/rpl_rotate_logs.tmp' or die "Tmp file rpl_rotate_logs.tmp not found";
+my $binlogpath = $ENV{'MYSQLTEST_VARDIR'}.'/mysqld.1/data/master-bin.000002';
+my @array = stat($binlogpath);
+my $filemodifytime = $array[9];
+my @t = localtime $filemodifytime;
+my $modifytime = sprintf "%04u-%02u-%02u %02u:%02u:%02u",$t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0];
+printf F ("let \$tmpval = %s;",$modifytime);
+close F;
+EOF
+
+--source $MYSQLTEST_VARDIR/tmp/rpl_rotate_logs.tmp
+remove_file $MYSQLTEST_VARDIR/tmp/rpl_rotate_logs.tmp;
+
--disable_result_log
-select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND)
- from information_schema.tables
- where TABLE_SCHEMA="test" and TABLE_NAME="t2";
+--replace_result $tmpval tmpval
+--eval SELECT @time_for_purge:=DATE_ADD('$tmpval', INTERVAL 1 SECOND)
--enable_result_log
purge master logs before (@time_for_purge);
diff --git a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
index 62b46eeb58e..3328d582692 100644
--- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
@@ -244,7 +244,7 @@ connection master;
# We should be gold by the time, so I will get rid of our file.
---exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/remote.sql
################### End Bug 17654 ######################
# What is the point of this test? It seems entirely pointless. It
@@ -349,9 +349,9 @@ FLUSH LOGS;
--diff_files $MYSQLTEST_VARDIR/tmp/local.sql $MYSQLTEST_VARDIR/tmp/remote.sql
---exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/remote.sql
---exec rm $MYSQLTEST_VARDIR/tmp/local.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/local.sql
DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_row_until.test b/mysql-test/suite/rpl/t/rpl_row_until.test
index d89de7d9ebd..fe859218ed3 100644
--- a/mysql-test/suite/rpl/t/rpl_row_until.test
+++ b/mysql-test/suite/rpl/t/rpl_row_until.test
@@ -2,76 +2,115 @@
-- source include/have_binlog_format_row.inc
-- source include/master-slave.inc
-# Test is dependent on binlog positions
+# Note: The test is dependent on binlog positions
# prepare version for substitutions
let $VERSION=`select version()`;
-# stop slave before he will start replication also sync with master
-# for avoiding undetermenistic behaviour
+# Create some events on master
+connection master;
+CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+DROP TABLE t1;
+# Save master log postion for query DROP TABLE t1
+save_master_pos;
+let $master_pos_drop_t1= query_get_value(SHOW BINLOG EVENTS, Pos, 7);
+
+CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
+# Save master log postion for query CREATE TABLE t2
+save_master_pos;
+let $master_pos_create_t2= query_get_value(SHOW BINLOG EVENTS, Pos, 8);
+
+INSERT INTO t2 VALUES (1),(2);
+save_master_pos;
+# Save master log postion for query INSERT INTO t2 VALUES (1),(2);
+let $master_pos_insert1_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 12);
sync_slave_with_master;
---source include/stop_slave.inc
+
+# Save relay log postion for query INSERT INTO t2 VALUES (1),(2);
+let $relay_pos_insert1_t2= query_get_value(show slave status, Relay_Log_Pos, 1);
connection master;
-# create some events on master
-create table t1(n int not null auto_increment primary key);
-insert into t1 values (1),(2),(3),(4);
-drop table t1;
-create table t2(n int not null auto_increment primary key);
-insert into t2 values (1),(2);
-insert into t2 values (3),(4);
-drop table t2;
+INSERT INTO t2 VALUES (3),(4);
+DROP TABLE t2;
+# Save master log postion for query INSERT INTO t2 VALUES (1),(2);
+let $master_pos_drop_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 17);
+sync_slave_with_master;
+
+--source include/stop_slave.inc
+# Reset slave.
+RESET SLAVE;
+--disable_query_log
+eval CHANGE MASTER TO MASTER_USER='root', MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT;
+--enable_query_log
-# try to replicate all queries until drop of t1
+# Try to replicate all queries until drop of t1
connection slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=311;
+echo START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_drop_t1;
+--disable_query_log
+eval START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=$master_pos_drop_t1;
+--enable_query_log
--source include/wait_for_slave_sql_to_stop.inc
-# here table should be still not deleted
-select * from t1;
-source include/show_slave_status.inc;
-# this should fail right after start
-start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
+# Here table should be still not deleted
+SELECT * FROM t1;
+--replace_result $master_pos_drop_t1 MASTER_POS_DROP_T1
+--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
+query_vertical SHOW SLAVE STATUS;
+
+# This should fail right after start
+START SLAVE UNTIL MASTER_LOG_FILE='master-no-such-bin.000001', MASTER_LOG_POS=291;
--source include/wait_for_slave_sql_to_stop.inc
# again this table should be still not deleted
-select * from t1;
-source include/show_slave_status.inc;
+SELECT * FROM t1;
+--replace_result $master_pos_drop_t1 MASTER_POS_DROP_T1
+--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
+query_vertical SHOW SLAVE STATUS;
-# try replicate all up to and not including the second insert to t2;
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=1014;
+# Try replicate all up to and not including the second insert to t2;
+echo START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=relay_pos_insert1_t2;
+--disable_query_log
+eval START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=$relay_pos_insert1_t2;
+--enable_query_log
--source include/wait_for_slave_sql_to_stop.inc
-select * from t2;
-source include/show_slave_status.inc;
+SELECT * FROM t2;
+--replace_result $relay_pos_insert1_t2 RELAY_POS_INSERT1_T2 $master_pos_insert1_t2 MASTER_POS_INSERT1_T2
+--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
+query_vertical SHOW SLAVE STATUS;
# clean up
-start slave;
+START SLAVE;
+--source include/wait_for_slave_to_start.inc
connection master;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--source include/stop_slave.inc
-# this should stop immediately as we are already there
-start slave sql_thread until master_log_file='master-bin.000001', master_log_pos=740;
---let $slave_param= Until_Log_Pos
---let $slave_param_value= 740
+# This should stop immediately as we are already there
+echo START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_create_t2;
+--disable_query_log
+eval START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=$master_pos_create_t2;
+--enable_query_log
+let $slave_param= Until_Log_Pos;
+let $slave_param_value= $master_pos_create_t2;
--source include/wait_for_slave_param.inc
--source include/wait_for_slave_sql_to_stop.inc
# here the sql slave thread should be stopped
--replace_result bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
-source include/show_slave_status.inc;
+--replace_result $master_pos_create_t2 MASTER_POS_CREATE_T2 $master_pos_drop_t2 MASTER_POS_DROP_T2
+--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
+query_vertical SHOW SLAVE STATUS;
#testing various error conditions
--error 1277
-start slave until master_log_file='master-bin', master_log_pos=561;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin', MASTER_LOG_POS=561;
--error 1277
-start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=561, RELAY_LOG_POS=12;
--error 1277
-start slave until master_log_file='master-bin.000001';
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001';
--error 1277
-start slave until relay_log_file='slave-relay-bin.000002';
+START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000009';
--error 1277
-start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
+START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=561;
# Warning should be given for second command
-start slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=740;
+START SLAVE;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=740;
diff --git a/mysql-test/suite/rpl/t/rpl_row_wide_table.test b/mysql-test/suite/rpl/t/rpl_row_wide_table.test
new file mode 100644
index 00000000000..7b17d7c4866
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_wide_table.test
@@ -0,0 +1,339 @@
+##################################################################
+# rpl_row_wide_table
+#
+# This test verifies that the table with number of attributes more
+# than 250 is replicated.
+# Related bugs:
+# Bug #42977 RBR logs for rows with more than 250 column results
+# in corrupt binlog
+##################################################################
+
+-- source include/master-slave.inc
+-- source include/have_binlog_format_row.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t300;
+--enable_warnings
+
+connection master;
+
+create table t300 (
+f1 int,
+f2 int,
+f3 int,
+f4 int,
+f5 int,
+f6 int,
+f7 int,
+f8 int,
+f9 int,
+f10 int,
+f11 int,
+f12 int,
+f13 int,
+f14 int,
+f15 int,
+f16 int,
+f17 int,
+f18 int,
+f19 int,
+f20 int,
+f21 int,
+f22 int,
+f23 int,
+f24 int,
+f25 int,
+f26 int,
+f27 int,
+f28 int,
+f29 int,
+f30 int,
+f31 int,
+f32 int,
+f33 int,
+f34 int,
+f35 int,
+f36 int,
+f37 int,
+f38 int,
+f39 int,
+f40 int,
+f41 int,
+f42 int,
+f43 int,
+f44 int,
+f45 int,
+f46 int,
+f47 int,
+f48 int,
+f49 int,
+f50 int,
+f51 int,
+f52 int,
+f53 int,
+f54 int,
+f55 int,
+f56 int,
+f57 int,
+f58 int,
+f59 int,
+f60 int,
+f61 int,
+f62 int,
+f63 int,
+f64 int,
+f65 int,
+f66 int,
+f67 int,
+f68 int,
+f69 int,
+f70 int,
+f71 int,
+f72 int,
+f73 int,
+f74 int,
+f75 int,
+f76 int,
+f77 int,
+f78 int,
+f79 int,
+f80 int,
+f81 int,
+f82 int,
+f83 int,
+f84 int,
+f85 int,
+f86 int,
+f87 int,
+f88 int,
+f89 int,
+f90 int,
+f91 int,
+f92 int,
+f93 int,
+f94 int,
+f95 int,
+f96 int,
+f97 int,
+f98 int,
+f99 int,
+f100 int,
+f101 int,
+f102 int,
+f103 int,
+f104 int,
+f105 int,
+f106 int,
+f107 int,
+f108 int,
+f109 int,
+f110 int,
+f111 int,
+f112 int,
+f113 int,
+f114 int,
+f115 int,
+f116 int,
+f117 int,
+f118 int,
+f119 int,
+f120 int,
+f121 int,
+f122 int,
+f123 int,
+f124 int,
+f125 int,
+f126 int,
+f127 int,
+f128 int,
+f129 int,
+f130 int,
+f131 int,
+f132 int,
+f133 int,
+f134 int,
+f135 int,
+f136 int,
+f137 int,
+f138 int,
+f139 int,
+f140 int,
+f141 int,
+f142 int,
+f143 int,
+f144 int,
+f145 int,
+f146 int,
+f147 int,
+f148 int,
+f149 int,
+f150 int,
+f151 int,
+f152 int,
+f153 int,
+f154 int,
+f155 int,
+f156 int,
+f157 int,
+f158 int,
+f159 int,
+f160 int,
+f161 int,
+f162 int,
+f163 int,
+f164 int,
+f165 int,
+f166 int,
+f167 int,
+f168 int,
+f169 int,
+f170 int,
+f171 int,
+f172 int,
+f173 int,
+f174 int,
+f175 int,
+f176 int,
+f177 int,
+f178 int,
+f179 int,
+f180 int,
+f181 int,
+f182 int,
+f183 int,
+f184 int,
+f185 int,
+f186 int,
+f187 int,
+f188 int,
+f189 int,
+f190 int,
+f191 int,
+f192 int,
+f193 int,
+f194 int,
+f195 int,
+f196 int,
+f197 int,
+f198 int,
+f199 int,
+f200 int,
+f201 int,
+f202 int,
+f203 int,
+f204 int,
+f205 int,
+f206 int,
+f207 int,
+f208 int,
+f209 int,
+f210 int,
+f211 int,
+f212 int,
+f213 int,
+f214 int,
+f215 int,
+f216 int,
+f217 int,
+f218 int,
+f219 int,
+f220 int,
+f221 int,
+f222 int,
+f223 int,
+f224 int,
+f225 int,
+f226 int,
+f227 int,
+f228 int,
+f229 int,
+f230 int,
+f231 int,
+f232 int,
+f233 int,
+f234 int,
+f235 int,
+f236 int,
+f237 int,
+f238 int,
+f239 int,
+f240 int,
+f241 int,
+f242 int,
+f243 int,
+f244 int,
+f245 int,
+f246 int,
+f247 int,
+f248 int,
+f249 int,
+f250 int,
+f251 int,
+f252 int,
+f253 int,
+f254 int,
+f255 int,
+f256 int,
+f257 int,
+f258 int,
+f259 int,
+f260 int,
+f261 int,
+f262 int,
+f263 int,
+f264 int,
+f265 int,
+f266 int,
+f267 int,
+f268 int,
+f269 int,
+f270 int,
+f271 int,
+f272 int,
+f273 int,
+f274 int,
+f275 int,
+f276 int,
+f277 int,
+f278 int,
+f279 int,
+f280 int,
+f281 int,
+f282 int,
+f283 int,
+f284 int,
+f285 int,
+f286 int,
+f287 int,
+f288 int,
+f289 int,
+f290 int,
+f291 int,
+f292 int,
+f293 int,
+f294 int,
+f295 int,
+f296 int,
+f297 int,
+f298 int,
+f299 int,
+f300 int,
+ primary key (f1));
+
+insert into t300 set f1= 1;
+
+sync_slave_with_master;
+
+#
+# prove that slave processed the create as well as the insert
+#
+eval select f300 from t300;
+select count(*) as one from t300;
+
+--echo *** Cleanup ***
+connection master;
+DROP TABLE t300;
+sync_slave_with_master;
+
+# END of Test Case
+
diff --git a/mysql-test/suite/rpl/t/rpl_skip_error.test b/mysql-test/suite/rpl/t/rpl_skip_error.test
index cac797d3797..9c6aa3dcb57 100644
--- a/mysql-test/suite/rpl/t/rpl_skip_error.test
+++ b/mysql-test/suite/rpl/t/rpl_skip_error.test
@@ -8,18 +8,23 @@
# ==== Method ====
#
# We run the slave with --slave-skip-errors=1062 (the code for
-# duplicate key). On slave, we insert value 1 in a table, and then,
-# on master, we insert value 1 in the table. The error should be
-# ignored on slave.
-#
+# duplicate key). Then we have two set of tests. In the first
+# set, we insert value 1 in a table on the slave, and then, on
+# master, we insert value 1 in the table. In the second set, we
+# insert several values on the master, disable the binlog and
+# delete one of the values and re-enable the binlog. Right after,
+# we perform an update on the set of values in order to generate
+# a duplicate key on the slave. The errors should be ignored on
+# the slave.
+#
# ==== Related bugs ====
#
# BUG#28839: Errors in strict mode silently stop SQL thread if --slave-skip-errors exists
-# bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic
+# bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic:
+# BUG#39393: slave-skip-errors does not work when using ROW based replication
source include/master-slave.inc;
-source include/have_binlog_format_statement.inc;
-
+source include/have_innodb.inc;
--echo ==== Test Without sql_mode=strict_trans_tables ====
@@ -64,9 +69,11 @@ sync_slave_with_master;
connection master;
create table t1(a int primary key);
insert into t1 values (1),(2);
-delete from t1 where @@server_id=1;
+SET SQL_LOG_BIN=0;
+delete from t1;
+SET SQL_LOG_BIN=1;
set sql_mode=strict_trans_tables;
-insert into t1 values (7), (8), (9);
+insert into t1 values (1), (2), (3);
--echo [on slave]
sync_slave_with_master;
@@ -80,3 +87,83 @@ connection master;
drop table t1;
sync_slave_with_master;
# End of 5.0 tests
+
+#
+# BUG#39393: slave-skip-errors does not work when using ROW based replication
+#
+--echo ==== Using Innodb ====
+
+connection master;
+
+SET SQL_LOG_BIN=0;
+CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
+SHOW CREATE TABLE t1;
+SET SQL_LOG_BIN=1;
+
+connection slave;
+
+CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
+SHOW CREATE TABLE t1;
+
+connection master;
+
+INSERT INTO t1 VALUES(1, 1);
+INSERT INTO t1 VALUES(2, 1);
+INSERT INTO t1 VALUES(3, 1);
+INSERT INTO t1 VALUES(4, 1);
+
+SET SQL_LOG_BIN=0;
+DELETE FROM t1 WHERE id = 4;
+SET SQL_LOG_BIN=1;
+UPDATE t1 SET id= id + 3, data = 2;
+
+sync_slave_with_master;
+
+let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+echo $error;
+
+--echo **** We cannot execute a select as there are differences in the
+--echo **** behavior between STMT and RBR.
+
+--echo ==== Using MyIsam ====
+
+connection master;
+
+SET SQL_LOG_BIN=0;
+CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
+SHOW CREATE TABLE t2;
+SET SQL_LOG_BIN=1;
+
+connection slave;
+
+CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
+SHOW CREATE TABLE t2;
+
+connection master;
+
+INSERT INTO t2 VALUES(1, 1);
+INSERT INTO t2 VALUES(2, 1);
+INSERT INTO t2 VALUES(3, 1);
+INSERT INTO t2 VALUES(5, 1);
+
+SET SQL_LOG_BIN=0;
+DELETE FROM t2 WHERE id = 5;
+SET SQL_LOG_BIN=1;
+UPDATE t2 SET id= id + 3, data = 2;
+
+sync_slave_with_master;
+
+let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+echo $error;
+
+--echo **** We cannot execute a select as there are differences in the
+--echo **** behavior between STMT and RBR.
+
+--echo ==== Clean Up ====
+
+connection master;
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_in.test b/mysql-test/suite/rpl/t/rpl_slave_load_in.test
new file mode 100644
index 00000000000..54ebdffce69
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_in.test
@@ -0,0 +1,50 @@
+##########################################################################
+# This test verifies if a slave is able to process a "LOAD DATA INFILE"
+# event while the "--secure-file-priv" option is set.
+#
+# The test is divided in two steps:
+# 1 - Creates tables and populates them through "LOAD DATA INFILE".
+# 2 - Compares the master and slave.
+##########################################################################
+--source include/have_innodb.inc
+--source include/master-slave.inc
+
+##########################################################################
+# Loading data
+##########################################################################
+connection master;
+
+create table t1(a int not null auto_increment, b int, primary key(a));
+create table t2(a int not null auto_increment, b int, primary key(a)) engine=innodb;
+
+load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+
+start transaction;
+ insert into t2(b) values (1);
+ insert into t2(b) values (2);
+ load data infile '../../std_data/rpl_loaddata.dat' into table t2;
+ load data infile '../../std_data/rpl_loaddata.dat' into table t2;
+commit;
+
+##########################################################################
+# Checking Consistency
+##########################################################################
+sync_slave_with_master;
+
+let $diff_table_1=master:test.t1;
+let $diff_table_2=slave:test.t1;
+source include/diff_tables.inc;
+
+let $diff_table_1=master:test.t2;
+let $diff_table_2=slave:test.t2;
+source include/diff_tables.inc;
+
+##########################################################################
+# Clean up
+##########################################################################
+connection master;
+
+drop table t1;
+drop table t2;
+
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt
new file mode 100644
index 00000000000..51e410f911f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile-slave.opt
@@ -0,0 +1 @@
+--loose-debug=d,remove_slave_load_file_before_write
diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
new file mode 100644
index 00000000000..39f3b700f94
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_remove_tmpfile.test
@@ -0,0 +1,49 @@
+##########################################################################
+# This test verifies if the slave fails gracefully when the temporary
+# file used to load data is removed while it is about to be used it.
+# Similar errors are caught if the temporary directory is removed.
+#
+# Steps:
+# 1 - Creates a table and populates it through "LOAD DATA INFILE".
+# 2 - Catches error.
+##########################################################################
+--source include/have_binlog_format_mixed_or_statement.inc
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/master-slave.inc
+--source include/not_embedded.inc
+
+##########################################################################
+# Loading data
+##########################################################################
+connection master;
+
+create table t1(a int not null auto_increment, b int, primary key(a)) engine=innodb;
+
+start transaction;
+ insert into t1(b) values (1);
+ insert into t1(b) values (2);
+ load data infile '../../std_data/rpl_loaddata.dat' into table t1;
+commit;
+
+##########################################################################
+# Catch Error
+##########################################################################
+connection slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
+--replace_regex /SQL_LOAD-[0-9]-[0-9]-[0-9]*/SQL_LOAD/
+query_vertical show slave status;
+
+##########################################################################
+# Clean up
+##########################################################################
+connection master;
+
+drop table t1;
+
+connection slave;
+
+drop table t1;
diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt
new file mode 100644
index 00000000000..c4f91e97e3e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist-slave.opt
@@ -0,0 +1 @@
+--slave-load-tmpdir=../../../error
diff --git a/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
new file mode 100644
index 00000000000..3a80fa43f20
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_slave_load_tmpdir_not_exist.test
@@ -0,0 +1,24 @@
+##########################################################################
+# This test verifies if the start slave fails gracefuly when an
+# invalid directory is used to set --slave-load-tmpdir.
+##########################################################################
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
+connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
+connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
+
+connection slave;
+
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+eval CHANGE MASTER TO MASTER_USER='root',
+ MASTER_CONNECT_RETRY=1,
+ MASTER_HOST='127.0.0.1',
+ MASTER_PORT=$MASTER_MYPORT;
+START SLAVE;
+
+source include/wait_for_slave_sql_to_stop.inc;
+let $error=query_get_value("show slave status", Last_SQL_Error, 1);
+echo $error;
diff --git a/mysql-test/suite/rpl/t/rpl_start_stop_slave-slave.opt b/mysql-test/suite/rpl/t/rpl_start_stop_slave-slave.opt
new file mode 100644
index 00000000000..00ea161cd6e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_start_stop_slave-slave.opt
@@ -0,0 +1 @@
+--innodb_lock_wait_timeout=60
diff --git a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
index dbf0775c978..d9b87427321 100644
--- a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
+++ b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
@@ -1,4 +1,5 @@
source include/master-slave.inc;
+source include/have_innodb.inc;
#
# Bug#6148 ()
@@ -35,4 +36,88 @@ save_master_pos;
connection slave;
sync_with_master;
-# End of 4.1 tests
+
+#
+# Bug#38205 Row-based Replication (RBR) causes inconsistencies...
+# Bug#319 if while a non-transactional slave is replicating a transaction...
+#
+# Verifying that STOP SLAVE does not interrupt excution of a group
+# execution of events if the group can not roll back.
+# Killing the sql thread continues to provide a "hard" stop (the
+# part II, moved to the bugs suite as it's hard to make it
+# deterministic with KILL).
+#
+
+#
+# Part I. The being stopped sql thread finishes first the current group of
+# events if the group contains an event on a non-transaction table.
+
+connection master;
+create table t1i(n int primary key) engine=innodb;
+create table t2m(n int primary key) engine=myisam;
+begin;
+insert into t1i values (1);
+insert into t1i values (2);
+insert into t1i values (3);
+commit;
+
+sync_slave_with_master;
+connection slave;
+begin;
+insert into t1i values (5);
+
+connection master;
+let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+begin;
+insert into t1i values (4);
+insert into t2m values (1); # non-ta update to process
+insert into t1i values (5); # to block at. to be played with stopped
+commit;
+
+connection slave;
+# slave sql thread must be locked out by the conn `slave' explicit lock
+let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+--disable_query_log
+eval select $pos0_master - $pos0_slave as zero;
+--enable_query_log
+
+connection slave1;
+let $count= 1;
+let $table= t2m;
+source include/wait_until_rows_count.inc;
+send stop slave;
+
+connection slave;
+rollback; # release the sql thread
+
+connection slave1;
+reap;
+source include/wait_for_slave_to_stop.inc;
+let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
+--echo *** sql thread is *not* running: $sql_status ***
+
+
+connection master;
+let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+connection slave;
+
+let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
+
+--echo *** the prove: the stopped slave has finished the current transaction ***
+
+--disable_query_log
+select count(*) as five from t1i;
+eval select $pos1_master - $pos1_slave as zero;
+eval select $pos1_slave > $pos0_slave as one;
+--enable_query_log
+
+source include/start_slave.inc;
+
+# clean-up
+connection master;
+drop table t1i, t2m;
+
+sync_slave_with_master;
+
+# End of tests
diff --git a/mysql-test/suite/rpl/t/rpl_stm_loadfile.test b/mysql-test/suite/rpl/t/rpl_stm_loadfile.test
new file mode 100644
index 00000000000..3db8385a2f2
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_loadfile.test
@@ -0,0 +1,20 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+#############################################################################
+# TEST: To test the LOAD_FILE() in rbr #
+#############################################################################
+# Change Author: JBM
+# Change Date: 2006-01-16
+# Change: Added Order by for NDB
+# Change: Split the original test file. This one forces STATEMENT only because
+# when in STATEMENT mode, the load_file will issue a warning, whereas
+# in RBR or MIXED mode it does not (by lsoares).
+##########
+
+# Includes
+-- source include/master-slave.inc
+-- source include/have_binlog_format_statement.inc
+
+-- source extra/rpl_tests/rpl_loadfile.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test b/mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test
new file mode 100644
index 00000000000..0cb7f2cbf80
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test
@@ -0,0 +1,53 @@
+# ==== Purpose ====
+#
+# Test that temporary tables are correctly replicated after switching to ROW format in MIX mode.
+# This test case will test the condition of the bug#40013.
+# The test step is:
+# 1: create temp table on connection 'master';
+# 2: switch to ROW format using 'INSERT INTO t1 VALUES (UUID());'
+# 3: disconnect 'master' and connect to a new connection 'master1';
+# 4: sync to slave and check the number of temp tables on slave.
+#
+
+source include/master-slave.inc;
+source include/have_binlog_format_mixed.inc;
+
+--echo ==== Initialize ====
+
+--echo [on master]
+--connection master
+
+CREATE TABLE t1 (a CHAR(48));
+CREATE TEMPORARY TABLE t1_tmp1(a INT);
+INSERT INTO t1 VALUES (UUID());
+
+--echo [on slave]
+sync_slave_with_master;
+
+--echo ==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+
+--echo [on master]
+--connection master
+
+disconnect master;
+--connection master1
+
+# waiting DROP TEMPORARY TABLE event to be written into binlog
+let $wait_binlog_event= DROP;
+source include/wait_for_binlog_event.inc;
+
+--echo [on slave]
+sync_slave_with_master;
+
+--echo ==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+
+--echo ==== Clean up ====
+
+--echo [on master]
+--connection master1
+DROP TABLE t1;
+
+--echo [on slave]
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test
index 0bf3ecf97a2..4e83d39710c 100644
--- a/mysql-test/suite/rpl/t/rpl_temporary.test
+++ b/mysql-test/suite/rpl/t/rpl_temporary.test
@@ -222,4 +222,40 @@ drop table t1;
# Delete the anonymous users
source include/delete_anonymous_users.inc;
-# End of tests
+
+
+#
+# Bug#43748: crash when non-super user tries to kill the replication threads
+#
+
+--echo -- Bug#43748
+
+--echo -- make a user on the slave that can list but not kill system threads.
+connection slave;
+
+FLUSH PRIVILEGES;
+GRANT USAGE ON *.* TO user43748@127.0.0.1 IDENTIFIED BY 'meow';
+GRANT PROCESS ON *.* TO user43748@127.0.0.1;
+
+--echo -- try to KILL system-thread as that non-privileged user (on slave).
+connect (cont43748,127.0.0.1,user43748,meow,test,$SLAVE_MYPORT,);
+connection cont43748;
+
+SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1;
+
+--error ER_KILL_DENIED_ERROR,ER_NO_SUCH_THREAD
+KILL @id;
+
+disconnect cont43748;
+
+--echo -- throw out test-user on slave.
+connection slave;
+
+DROP USER user43748@127.0.0.1;
+
+--echo -- done. back to master.
+connection master;
+
+
+
+--echo End of 5.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_timezone.test b/mysql-test/suite/rpl/t/rpl_timezone.test
index d65242f2a22..40a2a4444b9 100644
--- a/mysql-test/suite/rpl/t/rpl_timezone.test
+++ b/mysql-test/suite/rpl/t/rpl_timezone.test
@@ -165,5 +165,32 @@ connection master;
DROP TABLE t1;
SET @@session.time_zone = default;
+# Bug#41719 delayed INSERT into timestamp col needs set time_zone for concurrent binlogging
+# To test that time_zone is correctly binloging for 'insert delayed' statement
+# Insert 2 values into timestamp col with different time_zone. Check result.
+
+--connection master
+reset master;
+CREATE TABLE t1 (date timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, a int(11) default NULL);
+
+SET @@session.time_zone='+01:00';
+insert into t1 values('2008-12-23 19:39:39',1);
+
+--connection master1
+SET @@session.time_zone='+02:00';
+insert delayed into t1 values ('2008-12-23 19:39:39',2);
+# Forces table t1 to be closed and flushes the query cache.
+# This makes sure that 'delayed insert' is executed before next statement.
+flush table t1;
+flush logs;
+select * from t1;
+DROP TABLE t1;
+
+let $MYSQLD_DATADIR= `select @@datadir;`;
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL
+--connection master1
+select * from t1 order by a;
+DROP TABLE t1;
+SET @@session.time_zone = default;
--echo End of 5.0 tests
diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result
index c788893e055..3ef5e2b7e53 100644
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result
@@ -25,8 +25,9 @@ hex(c2) hex(c3) c1
0 1 BCDEF
1 0 CD
0 0 DEFGHIJKL
-CREATE TEMPORARY TABLE test.backup_info (id INT, backup_id INT) ENGINE = HEAP;
-LOAD DATA INFILE 'DUMP_FILE' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
+CREATE TEMPORARY TABLE IF NOT EXISTS test.backup_info
+(id INT, backup_id INT) ENGINE = MEMORY;
+LOAD DATA INFILE '<MYSQLTEST_VARDIR>/tmp.dat' INTO TABLE test.backup_info FIELDS TERMINATED BY ',';
DROP TABLE test.backup_info;
UPDATE t1 SET c2=0 WHERE c3="row2";
SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
diff --git a/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc b/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc
index 6bbed3b1982..28ba8791b0a 100644
--- a/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc
+++ b/mysql-test/suite/sys_vars/inc/slave_transaction_retries_basic.inc
@@ -23,6 +23,7 @@
# #
###############################################################################
+--source include/not_embedded.inc
--source include/load_sysvars.inc
###################################################################
diff --git a/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc b/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc
index b66509bbb5e..04adab85ac8 100644
--- a/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc
+++ b/mysql-test/suite/sys_vars/inc/sync_binlog_basic.inc
@@ -23,6 +23,7 @@
# #
###############################################################################
+--source include/not_embedded.inc
--source include/load_sysvars.inc
##################################################################
diff --git a/mysql-test/suite/sys_vars/r/auto_increment_increment_basic.result b/mysql-test/suite/sys_vars/r/auto_increment_increment_basic.result
index c453d2322cf..3cfdc54457b 100644
--- a/mysql-test/suite/sys_vars/r/auto_increment_increment_basic.result
+++ b/mysql-test/suite/sys_vars/r/auto_increment_increment_basic.result
@@ -55,13 +55,13 @@ SELECT @@session.auto_increment_increment;
'#------------------FN_DYNVARS_001_05-----------------------#'
SET @@global.auto_increment_increment = 0;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-increment value: '0'
+Warning 1292 Truncated incorrect auto_increment_increment value: '0'
SELECT @@global.auto_increment_increment;
@@global.auto_increment_increment
1
SET @@global.auto_increment_increment = -1024;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-increment value: '0'
+Warning 1292 Truncated incorrect auto_increment_increment value: '-1024'
SELECT @@global.auto_increment_increment;
@@global.auto_increment_increment
1
@@ -83,13 +83,13 @@ SELECT @@global.auto_increment_increment;
65535
SET @@session.auto_increment_increment = 0;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-increment value: '0'
+Warning 1292 Truncated incorrect auto_increment_increment value: '0'
SELECT @@session.auto_increment_increment;
@@session.auto_increment_increment
1
SET @@session.auto_increment_increment = -2;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-increment value: '0'
+Warning 1292 Truncated incorrect auto_increment_increment value: '-2'
SELECT @@session.auto_increment_increment;
@@session.auto_increment_increment
1
@@ -126,7 +126,7 @@ SELECT @@global.auto_increment_increment;
1
SET @@global.auto_increment_increment = FALSE;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-increment value: '0'
+Warning 1292 Truncated incorrect auto_increment_increment value: '0'
SELECT @@global.auto_increment_increment;
@@global.auto_increment_increment
1
diff --git a/mysql-test/suite/sys_vars/r/auto_increment_increment_func.result b/mysql-test/suite/sys_vars/r/auto_increment_increment_func.result
index f0f1ada6d95..eeaa3949886 100644
--- a/mysql-test/suite/sys_vars/r/auto_increment_increment_func.result
+++ b/mysql-test/suite/sys_vars/r/auto_increment_increment_func.result
@@ -169,7 +169,7 @@ id name
## Verifying behavior of variable with negative value ##
SET @@auto_increment_increment = -10;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-increment value: '0'
+Warning 1292 Truncated incorrect auto_increment_increment value: '-10'
INSERT into t1(name) values('Record_17');
INSERT into t1(name) values('Record_18');
SELECT * from t1;
diff --git a/mysql-test/suite/sys_vars/r/auto_increment_offset_basic.result b/mysql-test/suite/sys_vars/r/auto_increment_offset_basic.result
index b5ccca8ce56..7752851cb4c 100644
--- a/mysql-test/suite/sys_vars/r/auto_increment_offset_basic.result
+++ b/mysql-test/suite/sys_vars/r/auto_increment_offset_basic.result
@@ -55,13 +55,13 @@ SELECT @@session.auto_increment_offset;
'#------------------FN_DYNVARS_002_05-----------------------#'
SET @@global.auto_increment_offset = 0;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-offset value: '0'
+Warning 1292 Truncated incorrect auto_increment_offset value: '0'
SELECT @@global.auto_increment_offset;
@@global.auto_increment_offset
1
SET @@global.auto_increment_offset = -1024;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-offset value: '0'
+Warning 1292 Truncated incorrect auto_increment_offset value: '-1024'
SELECT @@global.auto_increment_offset;
@@global.auto_increment_offset
1
@@ -88,13 +88,13 @@ SELECT @@global.auto_increment_offset;
65535
SET @@session.auto_increment_offset = 0;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-offset value: '0'
+Warning 1292 Truncated incorrect auto_increment_offset value: '0'
SELECT @@session.auto_increment_offset;
@@session.auto_increment_offset
1
SET @@session.auto_increment_offset = -2;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-offset value: '0'
+Warning 1292 Truncated incorrect auto_increment_offset value: '-2'
SELECT @@session.auto_increment_offset;
@@session.auto_increment_offset
1
@@ -139,7 +139,7 @@ SELECT @@global.auto_increment_offset;
1
SET @@global.auto_increment_offset = FALSE;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-offset value: '0'
+Warning 1292 Truncated incorrect auto_increment_offset value: '0'
SELECT @@global.auto_increment_offset;
@@global.auto_increment_offset
1
diff --git a/mysql-test/suite/sys_vars/r/auto_increment_offset_func.result b/mysql-test/suite/sys_vars/r/auto_increment_offset_func.result
index 5c953544e73..e166cb149f6 100644
--- a/mysql-test/suite/sys_vars/r/auto_increment_offset_func.result
+++ b/mysql-test/suite/sys_vars/r/auto_increment_offset_func.result
@@ -178,7 +178,7 @@ id name
## Assigning -ve value to variable ##
SET @@auto_increment_offset = -10;
Warnings:
-Warning 1292 Truncated incorrect auto-increment-offset value: '0'
+Warning 1292 Truncated incorrect auto_increment_offset value: '-10'
SELECT @@auto_increment_offset = -10;
@@auto_increment_offset = -10
0
diff --git a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result
index 6267c5493da..2f439c8f834 100644
--- a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_32.result
@@ -44,7 +44,7 @@ SET @@global.binlog_cache_size = 10000.01;
ERROR 42000: Incorrect argument type to variable 'binlog_cache_size'
SET @@global.binlog_cache_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect binlog_cache_size value: '0'
+Warning 1292 Truncated incorrect binlog_cache_size value: '-1024'
SELECT @@global.binlog_cache_size;
@@global.binlog_cache_size
4096
diff --git a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result
index 45ed43589a3..3858df0f4d6 100644
--- a/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/binlog_cache_size_basic_64.result
@@ -44,7 +44,7 @@ SET @@global.binlog_cache_size = 10000.01;
ERROR 42000: Incorrect argument type to variable 'binlog_cache_size'
SET @@global.binlog_cache_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect binlog_cache_size value: '0'
+Warning 1292 Truncated incorrect binlog_cache_size value: '-1024'
SELECT @@global.binlog_cache_size;
@@global.binlog_cache_size
4096
diff --git a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result
index 1194a0e7ce7..3e071f76f98 100644
--- a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_32.result
@@ -68,6 +68,8 @@ SELECT @@global.bulk_insert_buffer_size;
@@global.bulk_insert_buffer_size
4294967295
SET @@global.bulk_insert_buffer_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-1024'
SELECT @@global.bulk_insert_buffer_size;
@@global.bulk_insert_buffer_size
0
@@ -84,6 +86,8 @@ SELECT @@session.bulk_insert_buffer_size;
@@session.bulk_insert_buffer_size
4294967295
SET @@session.bulk_insert_buffer_size = -2;
+Warnings:
+Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-2'
SELECT @@session.bulk_insert_buffer_size;
@@session.bulk_insert_buffer_size
0
diff --git a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result
index 9e0e8e07470..320290fbca1 100644
--- a/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/bulk_insert_buffer_size_basic_64.result
@@ -66,6 +66,8 @@ SELECT @@global.bulk_insert_buffer_size;
@@global.bulk_insert_buffer_size
42949672950
SET @@global.bulk_insert_buffer_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-1024'
SELECT @@global.bulk_insert_buffer_size;
@@global.bulk_insert_buffer_size
0
@@ -80,6 +82,8 @@ SELECT @@session.bulk_insert_buffer_size;
@@session.bulk_insert_buffer_size
42949672950
SET @@session.bulk_insert_buffer_size = -2;
+Warnings:
+Warning 1292 Truncated incorrect bulk_insert_buffer_size value: '-2'
SELECT @@session.bulk_insert_buffer_size;
@@session.bulk_insert_buffer_size
0
diff --git a/mysql-test/suite/sys_vars/r/completion_type_func.result b/mysql-test/suite/sys_vars/r/completion_type_func.result
index daee738c10d..f3ddcd287b6 100644
--- a/mysql-test/suite/sys_vars/r/completion_type_func.result
+++ b/mysql-test/suite/sys_vars/r/completion_type_func.result
@@ -2,76 +2,187 @@ DROP TABLE IF EXISTS t1;
## Creating new table ##
CREATE TABLE t1
(
-id INT NOT NULL AUTO_INCREMENT,
+id INT NOT NULL,
PRIMARY KEY (id),
name VARCHAR(30)
) ENGINE = INNODB;
-'#--------------------FN_DYNVARS_017_01-------------------------#'
-## Creating new connection ##
-INSERT INTO t1(name) VALUES('Record_1');
-SET @@autocommit = 0;
+## Creating new connections test_con1, test_con2 ##
+#########################################################
+# Setting initial value of completion_type to zero #
+#########################################################
+INSERT INTO t1 VALUES(1,'Record_1');
SELECT * FROM t1;
id name
1 Record_1
## Setting value of variable to 0 ##
SET @@session.completion_type = 0;
## Here commit & rollback should work normally ##
+## test commit ##
START TRANSACTION;
+INSERT INTO t1 VALUES(2,'Record_2');
+INSERT INTO t1 VALUES(3,'Record_3');
SELECT * FROM t1;
id name
1 Record_1
-INSERT INTO t1(name) VALUES('Record_2');
-INSERT INTO t1(name) VALUES('Record_3');
+2 Record_2
+3 Record_3
+Switching to connection test_con1
+## Don't expect to see id's 2 and 3 in the table w/o COMMIT ##
+SELECT * FROM t1;
+id name
+1 Record_1
+Switching to default connection
+COMMIT;
+## test rollback ##
+START TRANSACTION;
+INSERT INTO t1 VALUES(4,'Record_4');
+INSERT INTO t1 VALUES(5,'Record_5');
+SELECT * FROM t1;
+id name
+1 Record_1
+2 Record_2
+3 Record_3
+4 Record_4
+5 Record_5
+Switching to connection test_con1
+## Don't expect to see id's 4 and 5 here ##
+## Expect to see 3, Record_3 ##
SELECT * FROM t1;
id name
1 Record_1
2 Record_2
3 Record_3
-DELETE FROM t1 WHERE id = 2;
+Switching to connection default;
+ROLLBACK;
+## Don't expect to see id's 4 and 5 now ##
SELECT * FROM t1;
id name
1 Record_1
+2 Record_2
3 Record_3
+
+#########################################################
+# Setting initial value of completion_type to one #
+#########################################################
+Switching to connection test_con1;
+SET @@session.completion_type = 1;
START TRANSACTION;
SELECT * FROM t1;
id name
1 Record_1
+2 Record_2
3 Record_3
-INSERT INTO t1(name) VALUES('Record_4');
-INSERT INTO t1(name) VALUES('Record_5');
+INSERT INTO t1 VALUES(6,'Record_6');
+INSERT INTO t1 VALUES(7,'Record_7');
COMMIT;
-'#--------------------FN_DYNVARS_017_02-------------------------#'
+## Expect to immediately have a new transaction ##
+INSERT INTO t1 VALUES(8,'Record_8');
+SELECT * FROM t1;
+id name
+1 Record_1
+2 Record_2
+3 Record_3
+6 Record_6
+7 Record_7
+8 Record_8
+switching to test_con2
+## Do not expect to see 8, Record_8 as no COMMIT has occurred ##
+SELECT * FROM t1;
+id name
+1 Record_1
+2 Record_2
+3 Record_3
+6 Record_6
+7 Record_7
+switch to connection test_con1
+## Testing ROLLBACK behavior
+START TRANSACTION;
+INSERT INTO t1 VALUES(9, 'Record_9');
+INSERT INTO t1 VALUES(10, 'Record_10');
+## Expect to see id's 8, 9, 10 here ##
+## 8, Record_8 COMMITted with the start of this transaction ##
+SELECT * FROM t1;
+id name
+1 Record_1
+2 Record_2
+3 Record_3
+6 Record_6
+7 Record_7
+8 Record_8
+9 Record_9
+10 Record_10
+ROLLBACK;
+## id's 9 and 10 are gone now due to ROLLBACK ##
+SELECT * FROM t1;
+id name
+1 Record_1
+2 Record_2
+3 Record_3
+6 Record_6
+7 Record_7
+8 Record_8
+## Expect a new transaction ##
+INSERT INTO t1 VALUES(9, 'Record_9');
+Switching to connection test_con2
+## Don't expect to see 9, Record_9 due to no COMMIT yet ##
+SELECT * FROM t1;
+id name
+1 Record_1
+2 Record_2
+3 Record_3
+6 Record_6
+7 Record_7
+8 Record_8
+Switching to connection test_con1
+ROLLBACK;
+## Don't expect to see 9, Record_9
+SELECT * FROM t1;
+id name
+1 Record_1
+2 Record_2
+3 Record_3
+6 Record_6
+7 Record_7
+8 Record_8
+#########################################################
+# Setting initial value of completion_type to 2 #
+#########################################################
SET @@session.completion_type = 2;
## Here commit should work as COMMIT RELEASE ##
START TRANSACTION;
SELECT * FROM t1;
id name
1 Record_1
+2 Record_2
3 Record_3
-4 Record_4
-5 Record_5
-INSERT INTO t1(name) VALUES('Record_6');
-INSERT INTO t1(name) VALUES('Record_7');
+6 Record_6
+7 Record_7
+8 Record_8
+INSERT INTO t1 VALUES(9,'Record_9');
+INSERT INTO t1 VALUES(10,'Record_10');
COMMIT;
## Inserting rows should give error here because connection should ##
## disconnect after using COMMIT ##
-INSERT INTO t1(name) VALUES('Record_4');
+INSERT INTO t1 VALUES(4,'Record_4');
Got one of the listed errors
-## Creating new connection test_con2 ##
+switch to connection test_con2
SET @@session.completion_type = 2;
## Inserting rows and using Rollback which should Rollback & release ##
START TRANSACTION;
SELECT * FROM t1;
id name
1 Record_1
+2 Record_2
3 Record_3
-4 Record_4
-5 Record_5
6 Record_6
7 Record_7
-INSERT INTO t1(name) VALUES('Record_8');
-INSERT INTO t1(name) VALUES('Record_9');
+8 Record_8
+9 Record_9
+10 Record_10
+INSERT INTO t1 VALUES(11,'Record_11');
+INSERT INTO t1 VALUES(12,'Record_12');
ROLLBACK;
-INSERT INTO t1(name) VALUES('Record_4');
+## Expect a failure due to COMMIT/ROLLBACK AND RELEASE behavior ##
+INSERT INTO t1 VALUES(4,'Record_4');
Got one of the listed errors
DROP TABLE t1;
diff --git a/mysql-test/suite/sys_vars/r/concurrent_insert_basic.result b/mysql-test/suite/sys_vars/r/concurrent_insert_basic.result
index e6614ea6abb..1ea9c37c2a1 100644
--- a/mysql-test/suite/sys_vars/r/concurrent_insert_basic.result
+++ b/mysql-test/suite/sys_vars/r/concurrent_insert_basic.result
@@ -28,12 +28,14 @@ SELECT @@global.concurrent_insert;
2
'#--------------------FN_DYNVARS_018_04-------------------------#'
SET @@global.concurrent_insert = -1;
+Warnings:
+Warning 1292 Truncated incorrect concurrent_insert value: '-1'
Select @@global.concurrent_insert;
@@global.concurrent_insert
0
SET @@global.concurrent_insert = 100;
Warnings:
-Warning 1292 Truncated incorrect concurrent-insert value: '100'
+Warning 1292 Truncated incorrect concurrent_insert value: '100'
Select @@global.concurrent_insert;
@@global.concurrent_insert
2
diff --git a/mysql-test/suite/sys_vars/r/connect_timeout_basic.result b/mysql-test/suite/sys_vars/r/connect_timeout_basic.result
index 7cdd747fc15..cc84405cf86 100644
--- a/mysql-test/suite/sys_vars/r/connect_timeout_basic.result
+++ b/mysql-test/suite/sys_vars/r/connect_timeout_basic.result
@@ -35,7 +35,7 @@ SELECT @@global.connect_timeout;
2
SET @@global.connect_timeout = -1024;
Warnings:
-Warning 1292 Truncated incorrect connect_timeout value: '0'
+Warning 1292 Truncated incorrect connect_timeout value: '-1024'
SELECT @@global.connect_timeout;
@@global.connect_timeout
2
diff --git a/mysql-test/suite/sys_vars/r/default_week_format_basic.result b/mysql-test/suite/sys_vars/r/default_week_format_basic.result
index d513ef1c41e..aa5e0b264d3 100644
--- a/mysql-test/suite/sys_vars/r/default_week_format_basic.result
+++ b/mysql-test/suite/sys_vars/r/default_week_format_basic.result
@@ -64,6 +64,8 @@ SELECT @@global.default_week_format;
@@global.default_week_format
7
SET @@global.default_week_format = -1024;
+Warnings:
+Warning 1292 Truncated incorrect default_week_format value: '-1024'
SELECT @@global.default_week_format;
@@global.default_week_format
0
@@ -100,6 +102,8 @@ SELECT @@session.default_week_format;
@@session.default_week_format
7
SET @@session.default_week_format = -2;
+Warnings:
+Warning 1292 Truncated incorrect default_week_format value: '-2'
SELECT @@session.default_week_format;
@@session.default_week_format
0
diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result
index cb6820b2941..f55c966dc38 100644
--- a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_32.result
@@ -35,7 +35,7 @@ SELECT @@global.delayed_insert_limit;
1
SET @@global.delayed_insert_limit = -1024;
Warnings:
-Warning 1292 Truncated incorrect delayed_insert_limit value: '0'
+Warning 1292 Truncated incorrect delayed_insert_limit value: '-1024'
SELECT @@global.delayed_insert_limit;
@@global.delayed_insert_limit
1
diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result
index 246bf0e8734..1f7d0a52e72 100644
--- a/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/delayed_insert_limit_basic_64.result
@@ -35,7 +35,7 @@ SELECT @@global.delayed_insert_limit;
1
SET @@global.delayed_insert_limit = -1024;
Warnings:
-Warning 1292 Truncated incorrect delayed_insert_limit value: '0'
+Warning 1292 Truncated incorrect delayed_insert_limit value: '-1024'
SELECT @@global.delayed_insert_limit;
@@global.delayed_insert_limit
1
diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result b/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result
index d7129d24498..0496efa4296 100644
--- a/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result
+++ b/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result
@@ -3,98 +3,75 @@
Creating connection con0
Creating connection con1
SET @global_delayed_insert_limit = @@GLOBAL.delayed_insert_limit;
-CREATE TABLE t1 (a varchar(100));
+CREATE TABLE t1 (a VARCHAR(100),b VARCHAR(100),c VARCHAR(100));
'#--------------------FN_DYNVARS_25_01-------------------------#'
-SET GLOBAL delayed_insert_limit = 9;
-** Connection con0 **
-SET GLOBAL delayed_insert_limit = 9;
-** Connection con1 **
-SET GLOBAL delayed_insert_limit = 9;
-** Connection default **
-SET GLOBAL delayed_insert_limit = 9;
-INSERT INTO t1 VALUES('1');
-INSERT INTO t1 VALUES('2');
-INSERT INTO t1 VALUES('3');
-INSERT INTO t1 VALUES('4');
-INSERT INTO t1 VALUES('5');
-INSERT INTO t1 VALUES('6');
+SET GLOBAL delayed_insert_limit = 14;
+INSERT INTO t1 VALUES('1','1','1');
+INSERT INTO t1 VALUES('2','1','1');
+INSERT INTO t1 VALUES('3','1','1');
+INSERT INTO t1 VALUES('4','1','1');
+INSERT INTO t1 VALUES('5','1','1');
+INSERT INTO t1 VALUES('6','1','1');
LOCK TABLE t1 WRITE;
** Connection con1 **
-INSERT DELAYED INTO t1 VALUES('7');
-INSERT DELAYED INTO t1 VALUES('8');
-INSERT DELAYED INTO t1 VALUES('9');
-INSERT DELAYED INTO t1 VALUES('10');
-INSERT DELAYED INTO t1 VALUES('11');
-INSERT DELAYED INTO t1 VALUES('12');
-INSERT DELAYED INTO t1 VALUES('13');
-INSERT DELAYED INTO t1 VALUES('14');
-INSERT DELAYED INTO t1 VALUES('15');
-INSERT DELAYED INTO t1 VALUES('16');
-INSERT DELAYED INTO t1 VALUES('17');
-INSERT DELAYED INTO t1 VALUES('18');
-INSERT DELAYED INTO t1 VALUES('19');
-INSERT DELAYED INTO t1 VALUES('20');
-INSERT DELAYED INTO t1 VALUES('21');
-INSERT DELAYED INTO t1 VALUES('22');|
+INSERT DELAYED INTO t1 VALUES('7','1','1');
+INSERT DELAYED INTO t1 VALUES('8','1','1');
+INSERT DELAYED INTO t1 VALUES('9','1','1');
+INSERT DELAYED INTO t1 VALUES('10','1','1');
+INSERT DELAYED INTO t1 VALUES('11','1','1');
+INSERT DELAYED INTO t1 VALUES('12','1','1');
+INSERT DELAYED INTO t1 VALUES('13','1','1');
+INSERT DELAYED INTO t1 VALUES('14','1','1');
+INSERT DELAYED INTO t1 VALUES('15','1','1');
+INSERT DELAYED INTO t1 VALUES('16','1','1');
+INSERT DELAYED INTO t1 VALUES('17','1','1');
+INSERT DELAYED INTO t1 VALUES('18','1','1');
+INSERT DELAYED INTO t1 VALUES('19','1','1');
+INSERT DELAYED INTO t1 VALUES('20','1','1');
+INSERT DELAYED INTO t1 VALUES('21','1','1');
+INSERT DELAYED INTO t1 VALUES('22','1','1');
+INSERT DELAYED INTO t1 VALUES('23','1','1');
+INSERT DELAYED INTO t1 VALUES('24','1','1');
+INSERT DELAYED INTO t1 VALUES('25','1','1');
+INSERT DELAYED INTO t1 VALUES('26','1','1');
+INSERT DELAYED INTO t1 VALUES('27','1','1');
+INSERT DELAYED INTO t1 VALUES('28','1','1');
+INSERT DELAYED INTO t1 VALUES('29','1','1');
+INSERT DELAYED INTO t1 VALUES('30','1','1');
+INSERT DELAYED INTO t1 VALUES('31','1','1');
+INSERT DELAYED INTO t1 VALUES('32','1','1');
+INSERT DELAYED INTO t1 VALUES('33','1','1');
+INSERT DELAYED INTO t1 VALUES('34','1','1');
+INSERT DELAYED INTO t1 VALUES('35','1','1');
+INSERT DELAYED INTO t1 VALUES('36','1','1');
+INSERT DELAYED INTO t1 VALUES('37','1','1');
+INSERT DELAYED INTO t1 VALUES('38','1','1');
+INSERT DELAYED INTO t1 VALUES('39','1','1');
+INSERT DELAYED INTO t1 VALUES('40','1','1');
+INSERT DELAYED INTO t1 VALUES('41','1','1');
+INSERT DELAYED INTO t1 VALUES('42','1','1');
+INSERT DELAYED INTO t1 VALUES('43','1','1');|
** Connection con0 **
-SELECT * FROM t1;|
+SELECT COUNT(*) FROM t1;
** Connection default **
-Waiting for 1 sec
+** Wait till con0 is blocked **
UNLOCK TABLES;
+** Connection con1 **
+Asynchronous "reap" result
** Connection con0 **
-a
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-'Bug#35386: insert delayed inserts 1 + limit rows instead of just limit rows'
+Asynchronous "reap" result
+The next result suffers from
+'# Bug#35386 insert delayed inserts 1 + limit rows instead of just limit rows'
+COUNT(*)
+21
** Connection default **
-Waiting for 1 sec
Checking if the delayed insert continued afterwards
-SELECT * FROM t1;
-a
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-DELETE FROM t1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+43
+DROP TABLE t1;
'#--------------------FN_DYNVARS_25_02-------------------------#'
-SET GLOBAL delayed_insert_limit = 20;
-** Connection con0 **
-SET GLOBAL delayed_insert_limit = 20;
-** Connection con1 **
-SET GLOBAL delayed_insert_limit = 20;
-** Connection default **
+CREATE TABLE t1 (a VARCHAR(100));
SET GLOBAL delayed_insert_limit = 20;
INSERT INTO t1 VALUES('1');
INSERT INTO t1 VALUES('2');
@@ -123,64 +100,21 @@ INSERT DELAYED INTO t1 VALUES('21');
INSERT DELAYED INTO t1 VALUES('22');|
** Connection con0 **
Asynchronous execute
-SELECT * FROM t1;|
+SELECT COUNT(*) = 22 FROM t1;
** Connection default **
-Waiting for 1 sec
+** Wait till con0 is blocked **
UNLOCK TABLES;
+** Connection con1 **
** Connection con0 **
-Asynchronous execute result
-a
+Asynchronous "reap" result
+COUNT(*) = 22
1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
** Connection default**
-Waiting for 1 sec
Checking if the delayed insert gives the same result afterwards
-SELECT * FROM t1;
-a
+SELECT COUNT(*) = 22 FROM t1;
+COUNT(*) = 22
1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-DELETE FROM t1;
-Switching to default
-Disconnecting from con1, con0
+** Connection default**
DROP TABLE t1;
SET @@GLOBAL.delayed_insert_limit = @global_delayed_insert_limit;
+Disconnecting from con1, con0
diff --git a/mysql-test/suite/sys_vars/r/delayed_insert_timeout_basic.result b/mysql-test/suite/sys_vars/r/delayed_insert_timeout_basic.result
index 4049907eb80..e8eab4da3cc 100644
--- a/mysql-test/suite/sys_vars/r/delayed_insert_timeout_basic.result
+++ b/mysql-test/suite/sys_vars/r/delayed_insert_timeout_basic.result
@@ -35,7 +35,7 @@ SELECT @@global.delayed_insert_timeout;
1
SET @@global.delayed_insert_timeout = -1024;
Warnings:
-Warning 1292 Truncated incorrect delayed_insert_timeout value: '0'
+Warning 1292 Truncated incorrect delayed_insert_timeout value: '-1024'
SELECT @@global.delayed_insert_timeout;
@@global.delayed_insert_timeout
1
diff --git a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result
index 6bfa6f0de40..3b356c6d866 100644
--- a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_32.result
@@ -35,7 +35,7 @@ SELECT @@global.delayed_queue_size;
1
SET @@global.delayed_queue_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect delayed_queue_size value: '0'
+Warning 1292 Truncated incorrect delayed_queue_size value: '-1024'
SELECT @@global.delayed_queue_size;
@@global.delayed_queue_size
1
diff --git a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result
index d575626b0a1..ed866b7e0b4 100644
--- a/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/delayed_queue_size_basic_64.result
@@ -35,7 +35,7 @@ SELECT @@global.delayed_queue_size;
1
SET @@global.delayed_queue_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect delayed_queue_size value: '0'
+Warning 1292 Truncated incorrect delayed_queue_size value: '-1024'
SELECT @@global.delayed_queue_size;
@@global.delayed_queue_size
1
diff --git a/mysql-test/suite/sys_vars/r/div_precision_increment_basic.result b/mysql-test/suite/sys_vars/r/div_precision_increment_basic.result
index d0311afa681..f78855fcaae 100644
--- a/mysql-test/suite/sys_vars/r/div_precision_increment_basic.result
+++ b/mysql-test/suite/sys_vars/r/div_precision_increment_basic.result
@@ -78,6 +78,8 @@ SELECT @@global.div_precision_increment;
@@global.div_precision_increment
30
SET @@global.div_precision_increment = -1024;
+Warnings:
+Warning 1292 Truncated incorrect div_precision_increment value: '-1024'
SELECT @@global.div_precision_increment;
@@global.div_precision_increment
0
@@ -100,6 +102,8 @@ SELECT @@session.div_precision_increment;
@@session.div_precision_increment
30
SET @@session.div_precision_increment = -2;
+Warnings:
+Warning 1292 Truncated incorrect div_precision_increment value: '-2'
SELECT @@session.div_precision_increment;
@@session.div_precision_increment
0
diff --git a/mysql-test/suite/sys_vars/r/event_scheduler_func.result b/mysql-test/suite/sys_vars/r/event_scheduler_func.result
deleted file mode 100644
index 8da942e919c..00000000000
--- a/mysql-test/suite/sys_vars/r/event_scheduler_func.result
+++ /dev/null
@@ -1,44 +0,0 @@
-drop table if exists t1;
-## Creating new table ##
-CREATE TABLE t1
-(
-id INT NOT NULL auto_increment,
-PRIMARY KEY (id),
-name VARCHAR(30)
-);
-'#--------------------FN_DYNVARS_018_01-------------------------#'
-## Setting initial value of variable to ON ##
-SET @@global.event_scheduler = ON;
-SELECT @@event_scheduler;
-@@event_scheduler
-ON
-## Creating new event ##
-CREATE EVENT test_event_1
-ON SCHEDULE EVERY 3 SECOND
-DO
-INSERT into t1(name) values('Record_1');
-SELECT * from t1;
-id name
-1 Record_1
-2 Record_1
-DROP EVENT test_event_1;
-DELETE from t1;
-select * from t1;
-id name
-'#--------------------FN_DYNVARS_018_02-------------------------#'
-## Setting value of variable to OFF ##
-SET @@global.event_scheduler = OFF;
-SELECT @@event_scheduler;
-@@event_scheduler
-OFF
-## Creating new event ##
-CREATE EVENT test_event_1
-ON SCHEDULE EVERY 3 SECOND
-DO
-INSERT into t1(name) values('Record_2');
-## Table should be empty ##
-SELECT * from t1;
-id name
-DROP EVENT test_event_1;
-## Dropping table ##
-DROP table t1;
diff --git a/mysql-test/suite/sys_vars/r/expire_logs_days_basic.result b/mysql-test/suite/sys_vars/r/expire_logs_days_basic.result
index 66aa5fa42a5..1abab8e68b0 100644
--- a/mysql-test/suite/sys_vars/r/expire_logs_days_basic.result
+++ b/mysql-test/suite/sys_vars/r/expire_logs_days_basic.result
@@ -32,6 +32,8 @@ SELECT @@global.expire_logs_days;
21
'#--------------------FN_DYNVARS_029_04-------------------------#'
SET @@global.expire_logs_days = -1;
+Warnings:
+Warning 1292 Truncated incorrect expire_logs_days value: '-1'
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
0
@@ -53,6 +55,8 @@ SELECT @@global.expire_logs_days;
@@global.expire_logs_days
99
SET @@global.expire_logs_days = -1024;
+Warnings:
+Warning 1292 Truncated incorrect expire_logs_days value: '-1024'
SELECT @@global.expire_logs_days;
@@global.expire_logs_days
0
diff --git a/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result b/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result
index 4a3159c77c3..0096c553155 100644
--- a/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result
+++ b/mysql-test/suite/sys_vars/r/ft_boolean_syntax_func.result
@@ -70,7 +70,7 @@ FROM articles WHERE MATCH (title,body)
AGAINST ('+security configuring' IN BOOLEAN MODE);
id title body relevance
8 MySQL Security When configured properly, MySQL ... 1
-9 Database Security Configuring MySQL for ... 1.3333333730698
+9 Database Security Configuring MySQL for ... 1.33333337306976
SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('"faster than"' IN BOOLEAN MODE);
id title body
@@ -91,7 +91,7 @@ AGAINST ('+MySQL +(>show <dbms)' IN BOOLEAN MODE)
ORDER BY relevance DESC;
id title body relevance
4 Optimizing MySQL In this tutorial we will show .... Run command line ... 1.25
-1 MySQL Tutorial DBMS stands for DataBase ... 0.83333337306976
+1 MySQL Tutorial DBMS stands for DataBase ... 0.833333373069763
'---try setting different operators. Default '+ -><()~*:""&|'--'
SET @@global.ft_boolean_syntax='~ /!@#$%^&*()-';
SELECT * FROM articles WHERE MATCH (title,body)
diff --git a/mysql-test/suite/sys_vars/r/group_concat_max_len_basic.result b/mysql-test/suite/sys_vars/r/group_concat_max_len_basic.result
index 5704f00c014..4821ca91308 100644
--- a/mysql-test/suite/sys_vars/r/group_concat_max_len_basic.result
+++ b/mysql-test/suite/sys_vars/r/group_concat_max_len_basic.result
@@ -65,7 +65,7 @@ SELECT @@global.group_concat_max_len;
4
SET @@global.group_concat_max_len = -1024;
Warnings:
-Warning 1292 Truncated incorrect group_concat_max_len value: '0'
+Warning 1292 Truncated incorrect group_concat_max_len value: '-1024'
SELECT @@global.group_concat_max_len;
@@global.group_concat_max_len
4
@@ -91,7 +91,7 @@ SELECT @@session.group_concat_max_len;
4
SET @@session.group_concat_max_len = -2;
Warnings:
-Warning 1292 Truncated incorrect group_concat_max_len value: '0'
+Warning 1292 Truncated incorrect group_concat_max_len value: '-2'
SELECT @@session.group_concat_max_len;
@@session.group_concat_max_len
4
diff --git a/mysql-test/suite/sys_vars/r/interactive_timeout_basic.result b/mysql-test/suite/sys_vars/r/interactive_timeout_basic.result
index 0777596db07..519fef8a6e5 100644
--- a/mysql-test/suite/sys_vars/r/interactive_timeout_basic.result
+++ b/mysql-test/suite/sys_vars/r/interactive_timeout_basic.result
@@ -61,7 +61,7 @@ SELECT @@global.interactive_timeout;
1
SET @@global.interactive_timeout = -1024;
Warnings:
-Warning 1292 Truncated incorrect interactive_timeout value: '0'
+Warning 1292 Truncated incorrect interactive_timeout value: '-1024'
SELECT @@global.interactive_timeout;
@@global.interactive_timeout
1
@@ -89,7 +89,7 @@ SELECT @@session.interactive_timeout;
1
SET @@session.interactive_timeout = -2;
Warnings:
-Warning 1292 Truncated incorrect interactive_timeout value: '0'
+Warning 1292 Truncated incorrect interactive_timeout value: '-2'
SELECT @@session.interactive_timeout;
@@session.interactive_timeout
1
diff --git a/mysql-test/suite/sys_vars/r/interactive_timeout_func.result b/mysql-test/suite/sys_vars/r/interactive_timeout_func.result
index b97f7c90908..2ecd32f53bd 100644
--- a/mysql-test/suite/sys_vars/r/interactive_timeout_func.result
+++ b/mysql-test/suite/sys_vars/r/interactive_timeout_func.result
@@ -9,22 +9,27 @@ name VARCHAR(30)
'#--------------------FN_DYNVARS_052_01-------------------------#'
## Setting initial value of variable to 1 ##
SET @@global.interactive_timeout = 1;
-## Creating new interactive connection test_con1 ##
+## Creating new connection test_con1 ##
## Inserting record in table ##
INSERT into t1(name) values('Record_1');
-## Setting session value of interactive_timeout ##
+## Setting session value of interactive_timeout ##
SET @@session.interactive_timeout = 1;
-## Verifying values of variable ##
+## Verifying values of variable ##
SELECT @@session.interactive_timeout;
@@session.interactive_timeout
1
SELECT @@global.interactive_timeout;
@@global.interactive_timeout
1
-## Using sleep to check timeout ##
+connection default;
+## Using sleep to check timeout ##
+sleep 2;
+connection test_con1;
SELECT * from t1;
id name
1 Record_1
-'Bug#35377: Error should appear here because interactive_timeout value';
-'is 1 and connection remains idle for 5 secs';
INSERT into t1(name) values('Record_2');
+connection default;
+disconnect test_con1;
+DROP TABLE t1;
+SET @@global.interactive_timeout= 28800;
diff --git a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result
index e3016a2b22c..2318c6d7055 100644
--- a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_32.result
@@ -75,7 +75,7 @@ SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228;
1
SET @@global.join_buffer_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect join_buffer_size value: '0'
+Warning 1292 Truncated incorrect join_buffer_size value: '-1024'
SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228;
@@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228
1
@@ -109,7 +109,7 @@ SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228;
1
SET @@session.join_buffer_size = -2;
Warnings:
-Warning 1292 Truncated incorrect join_buffer_size value: '0'
+Warning 1292 Truncated incorrect join_buffer_size value: '-2'
SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228;
@@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228
1
diff --git a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result
index ed652af67d2..4811d4732df 100644
--- a/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/join_buffer_size_basic_64.result
@@ -71,7 +71,7 @@ SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228;
1
SET @@global.join_buffer_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect join_buffer_size value: '0'
+Warning 1292 Truncated incorrect join_buffer_size value: '-1024'
SELECT @@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228;
@@global.join_buffer_size=8200 OR @@global.join_buffer_size= 8228
1
@@ -103,7 +103,7 @@ SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228;
1
SET @@session.join_buffer_size = -2;
Warnings:
-Warning 1292 Truncated incorrect join_buffer_size value: '0'
+Warning 1292 Truncated incorrect join_buffer_size value: '-2'
SELECT @@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228;
@@session.join_buffer_size=8200 OR @@session.join_buffer_size= 8228
1
diff --git a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result
index 7221da16ed8..eea782701bb 100644
--- a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result
@@ -17,8 +17,6 @@ SELECT @@global.key_buffer_size BETWEEN 8 AND 36;
@@global.key_buffer_size BETWEEN 8 AND 36
1
SET @@global.key_buffer_size = 1800;
-Warnings:
-Warning 1292 Truncated incorrect key_buffer_size value: '1800'
SELECT @@global.key_buffer_size BETWEEN 8 AND 36;
@@global.key_buffer_size BETWEEN 8 AND 36
1
@@ -55,13 +53,13 @@ SELECT @@global.key_buffer_size BETWEEN 8 AND 36;
@@global.key_buffer_size BETWEEN 8 AND 36
1
'#----------------------FN_DYNVARS_055_06------------------------#'
-SELECT @@global.key_buffer_size = VARIABLE_VALUE
-FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
+SELECT @@global.key_buffer_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='key_buffer_size';
@@global.key_buffer_size = VARIABLE_VALUE
1
-SELECT @@key_buffer_size = VARIABLE_VALUE
-FROM INFORMATION_SCHEMA.SESSION_VARIABLES
+SELECT @@key_buffer_size = VARIABLE_VALUE
+FROM INFORMATION_SCHEMA.SESSION_VARIABLES
WHERE VARIABLE_NAME='key_buffer_size';
@@key_buffer_size = VARIABLE_VALUE
1
diff --git a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result
index 9ce1ab20993..eea782701bb 100644
--- a/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result
@@ -17,8 +17,6 @@ SELECT @@global.key_buffer_size BETWEEN 8 AND 36;
@@global.key_buffer_size BETWEEN 8 AND 36
1
SET @@global.key_buffer_size = 1800;
-Warnings:
-Warning 1292 Truncated incorrect key_buffer_size value: '1800'
SELECT @@global.key_buffer_size BETWEEN 8 AND 36;
@@global.key_buffer_size BETWEEN 8 AND 36
1
diff --git a/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result b/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result
index 023b23ea425..c79e7beb198 100644
--- a/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/key_cache_age_threshold_basic_32.result
@@ -37,10 +37,14 @@ SELECT @@global.key_cache_age_threshold;
'Bug# 34877 : Invalid Values are coming in variable on assigning valid values and Out Of Memory Warnings are coming';
'#--------------------FN_DYNVARS_056_04-------------------------#'
SET @@global.key_cache_age_threshold = -1;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_age_threshold value: '18446744073709551615'
SELECT @@global.key_cache_age_threshold;
@@global.key_cache_age_threshold
4294967200
SET @@global.key_cache_age_threshold = 42949672951;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_age_threshold value: '42949672951'
SELECT @@global.key_cache_age_threshold;
@@global.key_cache_age_threshold
4294967200
@@ -50,9 +54,11 @@ SELECT @@global.key_cache_age_threshold;
@@global.key_cache_age_threshold
4294967200
SET @@global.key_cache_age_threshold = -1024;
+Warnings:
+Warning 1292 Truncated incorrect key_cache_age_threshold value: '18446744073709550592'
SELECT @@global.key_cache_age_threshold;
@@global.key_cache_age_threshold
-4294966200
+4294967200
SET @@global.key_cache_age_threshold = 99;
Warnings:
Warning 1292 Truncated incorrect key_cache_age_threshold value: '99'
diff --git a/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result
index ac78acb8244..46ce1f26b29 100644
--- a/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/key_cache_block_size_basic_32.result
@@ -36,13 +36,13 @@ SELECT @@global.key_cache_block_size;
'#--------------------FN_DYNVARS_057_04-------------------------#'
SET @@global.key_cache_block_size = -1;
Warnings:
-Warning 1292 Truncated incorrect key_cache_block_size value: '4294967295'
+Warning 1292 Truncated incorrect key_cache_block_size value: '18446744073709551615'
SELECT @@global.key_cache_block_size;
@@global.key_cache_block_size
16384
SET @@global.key_cache_block_size = 42949672951;
Warnings:
-Warning 1292 Truncated incorrect key_cache_block_size value: '4294967287'
+Warning 1292 Truncated incorrect key_cache_block_size value: '42949672951'
SELECT @@global.key_cache_block_size;
@@global.key_cache_block_size
16384
@@ -53,7 +53,7 @@ SELECT @@global.key_cache_block_size;
16384
SET @@global.key_cache_block_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect key_cache_block_size value: '4294966272'
+Warning 1292 Truncated incorrect key_cache_block_size value: '18446744073709550592'
SELECT @@global.key_cache_block_size;
@@global.key_cache_block_size
16384
diff --git a/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result b/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result
index 5902dbcdf89..cd0cdcbca05 100644
--- a/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/key_cache_division_limit_basic_32.result
@@ -35,7 +35,7 @@ SELECT @@global.key_cache_division_limit;
'#--------------------FN_DYNVARS_058_04-------------------------#'
SET @@global.key_cache_division_limit = -1;
Warnings:
-Warning 1292 Truncated incorrect key_cache_division_limit value: '4294967295'
+Warning 1292 Truncated incorrect key_cache_division_limit value: '18446744073709551615'
SELECT @@global.key_cache_division_limit;
@@global.key_cache_division_limit
100
@@ -52,7 +52,7 @@ SELECT @@global.key_cache_division_limit;
100
SET @@global.key_cache_division_limit = -1024;
Warnings:
-Warning 1292 Truncated incorrect key_cache_division_limit value: '4294966272'
+Warning 1292 Truncated incorrect key_cache_division_limit value: '18446744073709550592'
SELECT @@global.key_cache_division_limit;
@@global.key_cache_division_limit
100
diff --git a/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result b/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result
index cfcbcddfca3..66e253645b1 100644
--- a/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result
+++ b/mysql-test/suite/sys_vars/r/log_bin_trust_routine_creators_basic.result
@@ -5,17 +5,17 @@ SELECT @start_global_value;
'#--------------------FN_DYNVARS_064_01-------------------------#'
SET @@global.log_bin_trust_routine_creators = TRUE;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SET @@global.log_bin_trust_routine_creators = DEFAULT;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
0
'#--------------------FN_DYNVARS_064_02-------------------------#'
SET @@global.log_bin_trust_routine_creators = DEFAULT;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators = 'FALSE';
@@global.log_bin_trust_routine_creators = 'FALSE'
1
@@ -24,37 +24,37 @@ Warning 1292 Truncated incorrect DOUBLE value: 'FALSE'
'#--------------------FN_DYNVARS_064_03-------------------------#'
SET @@global.log_bin_trust_routine_creators = ON;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
1
SET @@global.log_bin_trust_routine_creators = OFF;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
0
SET @@global.log_bin_trust_routine_creators = 0;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
0
SET @@global.log_bin_trust_routine_creators = 1;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
1
SET @@global.log_bin_trust_routine_creators = TRUE;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
1
SET @@global.log_bin_trust_routine_creators = FALSE;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
0
@@ -70,7 +70,7 @@ SET @@global.log_bin_trust_routine_creators = "OFFF";
ERROR 42000: Variable 'log_bin_trust_routine_creators' can't be set to the value of 'OFFF'
SET @@global.log_bin_trust_routine_creators = OF;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
0
@@ -96,14 +96,14 @@ ERROR HY000: Variable 'log_bin_trust_routine_creators' is a GLOBAL variable
'#---------------------FN_DYNVARS_064_07----------------------#'
SET @@global.log_bin_trust_routine_creators = TRUE;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@log_bin_trust_routine_creators = @@global.log_bin_trust_routine_creators;
@@log_bin_trust_routine_creators = @@global.log_bin_trust_routine_creators
1
'#---------------------FN_DYNVARS_064_08----------------------#'
SET @@global.log_bin_trust_routine_creators = TRUE;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@log_bin_trust_routine_creators;
@@log_bin_trust_routine_creators
1
@@ -115,7 +115,7 @@ SELECT log_bin_trust_routine_creators = @@session.log_bin_trust_routine_creators
ERROR 42S22: Unknown column 'log_bin_trust_routine_creators' in 'field list'
SET @@global.log_bin_trust_routine_creators = @start_global_value;
Warnings:
-Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use '@@log_bin_trust_function_creators' instead
+Warning 1287 The syntax '@@log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 6.0. Please use '@@log_bin_trust_function_creators' instead
SELECT @@global.log_bin_trust_routine_creators;
@@global.log_bin_trust_routine_creators
1
diff --git a/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result b/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result
index 900bb487706..92b0f4e5e91 100644
--- a/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/log_warnings_basic_32.result
@@ -76,6 +76,8 @@ SELECT @@global.log_warnings;
@@global.log_warnings
4294967295
SET @@global.log_warnings = -1024;
+Warnings:
+Warning 1292 Truncated incorrect log_warnings value: '-1024'
SELECT @@global.log_warnings;
@@global.log_warnings
0
@@ -96,6 +98,8 @@ SELECT @@session.log_warnings;
@@session.log_warnings
4294967295
SET @@session.log_warnings = -2;
+Warnings:
+Warning 1292 Truncated incorrect log_warnings value: '-2'
SELECT @@session.log_warnings;
@@session.log_warnings
0
diff --git a/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result b/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result
index ba6671c87a4..6a94881dad0 100644
--- a/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/log_warnings_basic_64.result
@@ -74,6 +74,8 @@ SELECT @@global.log_warnings;
@@global.log_warnings
100000000000
SET @@global.log_warnings = -1024;
+Warnings:
+Warning 1292 Truncated incorrect log_warnings value: '-1024'
SELECT @@global.log_warnings;
@@global.log_warnings
0
@@ -92,6 +94,8 @@ SELECT @@session.log_warnings;
@@session.log_warnings
100000000000
SET @@session.log_warnings = -2;
+Warnings:
+Warning 1292 Truncated incorrect log_warnings value: '-2'
SELECT @@session.log_warnings;
@@session.log_warnings
0
diff --git a/mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result b/mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result
index 0745d5a36e1..ca5b87f19cb 100644
--- a/mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_allowed_packet_basic.result
@@ -76,7 +76,7 @@ SELECT @@global.max_allowed_packet;
1024
SET @@global.max_allowed_packet = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_allowed_packet value: '0'
+Warning 1292 Truncated incorrect max_allowed_packet value: '-1024'
SELECT @@global.max_allowed_packet;
@@global.max_allowed_packet
1024
diff --git a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result
index a594295c0f5..1b3b65010b2 100644
--- a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_32.result
@@ -39,7 +39,7 @@ SELECT @@global.max_binlog_cache_size;
'#--------------------FN_DYNVARS_072_04-------------------------#'
SET @@global.max_binlog_cache_size = -1;
Warnings:
-Warning 1292 Truncated incorrect max_binlog_cache_size value: '0'
+Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1'
SELECT @@global.max_binlog_cache_size;
@@global.max_binlog_cache_size
4096
@@ -56,7 +56,7 @@ SELECT @@global.max_binlog_cache_size;
4294963200
SET @@global.max_binlog_cache_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_binlog_cache_size value: '0'
+Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1024'
SELECT @@global.max_binlog_cache_size;
@@global.max_binlog_cache_size
4096
diff --git a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result
index 30db3f14dd4..10a42f6ab0e 100644
--- a/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic_64.result
@@ -1,7 +1,7 @@
SET @start_value = @@global.max_binlog_cache_size;
SELECT @start_value;
@start_value
-18446744073709551615
+18446744073709547520
'#--------------------FN_DYNVARS_072_01------------------------#'
SET @@global.max_binlog_cache_size = 5000;
SET @@global.max_binlog_cache_size = DEFAULT;
@@ -39,7 +39,7 @@ SELECT @@global.max_binlog_cache_size;
'#--------------------FN_DYNVARS_072_04-------------------------#'
SET @@global.max_binlog_cache_size = -1;
Warnings:
-Warning 1292 Truncated incorrect max_binlog_cache_size value: '0'
+Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1'
SELECT @@global.max_binlog_cache_size;
@@global.max_binlog_cache_size
4096
@@ -54,7 +54,7 @@ SELECT @@global.max_binlog_cache_size;
99999997952
SET @@global.max_binlog_cache_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_binlog_cache_size value: '0'
+Warning 1292 Truncated incorrect max_binlog_cache_size value: '-1024'
SELECT @@global.max_binlog_cache_size;
@@global.max_binlog_cache_size
4096
diff --git a/mysql-test/suite/sys_vars/r/max_binlog_size_basic.result b/mysql-test/suite/sys_vars/r/max_binlog_size_basic.result
index 291b687f76c..658289628b0 100644
--- a/mysql-test/suite/sys_vars/r/max_binlog_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_binlog_size_basic.result
@@ -39,7 +39,7 @@ SELECT @@global.max_binlog_size;
'#--------------------FN_DYNVARS_072_04-------------------------#'
SET @@global.max_binlog_size = -1;
Warnings:
-Warning 1292 Truncated incorrect max_binlog_size value: '0'
+Warning 1292 Truncated incorrect max_binlog_size value: '-1'
SELECT @@global.max_binlog_size;
@@global.max_binlog_size
4096
@@ -56,7 +56,7 @@ SELECT @@global.max_binlog_size;
1073741824
SET @@global.max_binlog_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_binlog_size value: '0'
+Warning 1292 Truncated incorrect max_binlog_size value: '-1024'
SELECT @@global.max_binlog_size;
@@global.max_binlog_size
4096
diff --git a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result
index b786e0ce31a..42e64f1b418 100644
--- a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_32.result
@@ -39,7 +39,7 @@ SELECT @@global.max_connect_errors;
'#--------------------FN_DYNVARS_073_04-------------------------#'
SET @@global.max_connect_errors = -1;
Warnings:
-Warning 1292 Truncated incorrect max_connect_errors value: '0'
+Warning 1292 Truncated incorrect max_connect_errors value: '-1'
SELECT @@global.max_connect_errors;
@@global.max_connect_errors
1
@@ -56,7 +56,7 @@ SELECT @@global.max_connect_errors;
4294967295
SET @@global.max_connect_errors = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_connect_errors value: '0'
+Warning 1292 Truncated incorrect max_connect_errors value: '-1024'
SELECT @@global.max_connect_errors;
@@global.max_connect_errors
1
diff --git a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result
index 8117b650651..762cfd14a3a 100644
--- a/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/max_connect_errors_basic_64.result
@@ -39,7 +39,7 @@ SELECT @@global.max_connect_errors;
'#--------------------FN_DYNVARS_073_04-------------------------#'
SET @@global.max_connect_errors = -1;
Warnings:
-Warning 1292 Truncated incorrect max_connect_errors value: '0'
+Warning 1292 Truncated incorrect max_connect_errors value: '-1'
SELECT @@global.max_connect_errors;
@@global.max_connect_errors
1
@@ -54,7 +54,7 @@ SELECT @@global.max_connect_errors;
100000000000
SET @@global.max_connect_errors = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_connect_errors value: '0'
+Warning 1292 Truncated incorrect max_connect_errors value: '-1024'
SELECT @@global.max_connect_errors;
@@global.max_connect_errors
1
diff --git a/mysql-test/suite/sys_vars/r/max_connections_basic.result b/mysql-test/suite/sys_vars/r/max_connections_basic.result
index ccedff01c54..d917cd97b25 100644
--- a/mysql-test/suite/sys_vars/r/max_connections_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_connections_basic.result
@@ -39,7 +39,7 @@ SELECT @@global.max_connections;
'#--------------------FN_DYNVARS_074_04-------------------------#'
SET @@global.max_connections = -1;
Warnings:
-Warning 1292 Truncated incorrect max_connections value: '0'
+Warning 1292 Truncated incorrect max_connections value: '-1'
SELECT @@global.max_connections;
@@global.max_connections
1
@@ -56,7 +56,7 @@ SELECT @@global.max_connections;
100000
SET @@global.max_connections = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_connections value: '0'
+Warning 1292 Truncated incorrect max_connections value: '-1024'
SELECT @@global.max_connections;
@@global.max_connections
1
diff --git a/mysql-test/suite/sys_vars/r/max_delayed_threads_basic.result b/mysql-test/suite/sys_vars/r/max_delayed_threads_basic.result
index e0b2a3ee1cd..946c24e3082 100644
--- a/mysql-test/suite/sys_vars/r/max_delayed_threads_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_delayed_threads_basic.result
@@ -76,10 +76,14 @@ SELECT @@session.max_delayed_threads;
16383
'#------------------FN_DYNVARS_075_05-----------------------#'
SET @@global.max_delayed_threads = -1024;
+Warnings:
+Warning 1292 Truncated incorrect max_delayed_threads value: '-1024'
SELECT @@global.max_delayed_threads;
@@global.max_delayed_threads
0
SET @@global.max_delayed_threads = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_delayed_threads value: '-1'
SELECT @@global.max_delayed_threads;
@@global.max_delayed_threads
0
diff --git a/mysql-test/suite/sys_vars/r/max_error_count_basic.result b/mysql-test/suite/sys_vars/r/max_error_count_basic.result
index 2046a5e9dfa..7be8e0f37a3 100644
--- a/mysql-test/suite/sys_vars/r/max_error_count_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_error_count_basic.result
@@ -63,10 +63,14 @@ SELECT @@session.max_error_count;
65534
'#------------------FN_DYNVARS_076_05-----------------------#'
SET @@global.max_error_count = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_error_count value: '-1'
SELECT @@global.max_error_count;
@@global.max_error_count
0
SET @@global.max_error_count = -1024;
+Warnings:
+Warning 1292 Truncated incorrect max_error_count value: '-1024'
SELECT @@global.max_error_count;
@@global.max_error_count
0
@@ -93,6 +97,8 @@ SELECT @@global.max_error_count;
@@global.max_error_count
65535
SET @@session.max_error_count = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_error_count value: '-1'
SELECT @@session.max_error_count;
@@session.max_error_count
0
@@ -102,6 +108,8 @@ SELECT @@session.max_error_count;
@@session.max_error_count
65535
SET @@session.max_error_count = -2;
+Warnings:
+Warning 1292 Truncated incorrect max_error_count value: '-2'
SELECT @@session.max_error_count;
@@session.max_error_count
0
diff --git a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result
index 04eaa3ddd19..deedb9ae43c 100644
--- a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_32.result
@@ -40,10 +40,14 @@ SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
64512
SET @@global.max_heap_table_size = 4294967294;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '4294967294'
SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
4294966272
SET @@global.max_heap_table_size = 4294967295;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '4294967295'
SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
4294966272
@@ -62,10 +66,14 @@ SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
64512
SET @@session.max_heap_table_size = 4294967294;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '4294967294'
SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
4294966272
SET @@session.max_heap_table_size = 4294967295;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '4294967295'
SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
4294966272
@@ -73,13 +81,13 @@ SELECT @@session.max_heap_table_size;
'#------------------FN_DYNVARS_077_05-----------------------#'
SET @@global.max_heap_table_size = -1;
Warnings:
-Warning 1292 Truncated incorrect max_heap_table_size value: '0'
+Warning 1292 Truncated incorrect max_heap_table_size value: '-1'
SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
16384
SET @@global.max_heap_table_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_heap_table_size value: '0'
+Warning 1292 Truncated incorrect max_heap_table_size value: '-1024'
SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
16384
@@ -96,6 +104,8 @@ SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
16384
SET @@global.max_heap_table_size = 4294967296;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '4294967296'
SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
4294966272
@@ -111,7 +121,7 @@ SELECT @@global.max_heap_table_size;
4294966272
SET @@session.max_heap_table_size = -1;
Warnings:
-Warning 1292 Truncated incorrect max_heap_table_size value: '0'
+Warning 1292 Truncated incorrect max_heap_table_size value: '-1'
SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
16384
@@ -122,12 +132,16 @@ SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
16384
SET @@session.max_heap_table_size = 4294967296;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '4294967296'
SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
4294966272
SET @@session.max_heap_table_size = 65530.34.;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
SET @@session.max_heap_table_size = 10737418241;
+Warnings:
+Warning 1292 Truncated incorrect max_heap_table_size value: '10737418241'
SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
4294966272
diff --git a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result
index ebab80f376b..6642b6024b5 100644
--- a/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/max_heap_table_size_basic_64.result
@@ -73,13 +73,13 @@ SELECT @@session.max_heap_table_size;
'#------------------FN_DYNVARS_077_05-----------------------#'
SET @@global.max_heap_table_size = -1;
Warnings:
-Warning 1292 Truncated incorrect max_heap_table_size value: '0'
+Warning 1292 Truncated incorrect max_heap_table_size value: '-1'
SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
16384
SET @@global.max_heap_table_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_heap_table_size value: '0'
+Warning 1292 Truncated incorrect max_heap_table_size value: '-1024'
SELECT @@global.max_heap_table_size;
@@global.max_heap_table_size
16384
@@ -111,7 +111,7 @@ SELECT @@global.max_heap_table_size;
4294967296
SET @@session.max_heap_table_size = -1;
Warnings:
-Warning 1292 Truncated incorrect max_heap_table_size value: '0'
+Warning 1292 Truncated incorrect max_heap_table_size value: '-1'
SELECT @@session.max_heap_table_size;
@@session.max_heap_table_size
16384
diff --git a/mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result b/mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result
index 31c1fcec396..2f2f7f0c0fc 100644
--- a/mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_insert_delayed_threads_basic.result
@@ -77,10 +77,14 @@ SELECT @@session.max_insert_delayed_threads;
16383
'#------------------FN_DYNVARS_078_05-----------------------#'
SET @@global.max_insert_delayed_threads = -1024;
+Warnings:
+Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-1024'
SELECT @@global.max_insert_delayed_threads;
@@global.max_insert_delayed_threads
0
SET @@global.max_insert_delayed_threads = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_insert_delayed_threads value: '-1'
SELECT @@global.max_insert_delayed_threads;
@@global.max_insert_delayed_threads
0
diff --git a/mysql-test/suite/sys_vars/r/max_length_for_sort_data_basic.result b/mysql-test/suite/sys_vars/r/max_length_for_sort_data_basic.result
index 3edd3e86262..8936946c774 100644
--- a/mysql-test/suite/sys_vars/r/max_length_for_sort_data_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_length_for_sort_data_basic.result
@@ -71,7 +71,7 @@ SELECT @@session.max_length_for_sort_data;
'#------------------FN_DYNVARS_080_05-----------------------#'
SET @@global.max_length_for_sort_data = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
+Warning 1292 Truncated incorrect max_length_for_sort_data value: '-1024'
SELECT @@global.max_length_for_sort_data;
@@global.max_length_for_sort_data
4
@@ -111,7 +111,7 @@ SELECT @@session.max_length_for_sort_data;
8388608
SET @@session.max_length_for_sort_data = -1;
Warnings:
-Warning 1292 Truncated incorrect max_length_for_sort_data value: '0'
+Warning 1292 Truncated incorrect max_length_for_sort_data value: '-1'
SELECT @@session.max_length_for_sort_data;
@@session.max_length_for_sort_data
4
diff --git a/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result b/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result
index ebc7da8c7f8..9c28c287980 100644
--- a/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_prepared_stmt_count_basic.result
@@ -36,6 +36,8 @@ SELECT @@global.max_prepared_stmt_count;
65535
'#--------------------FN_DYNVARS_081_04-------------------------#'
SET @@global.max_prepared_stmt_count = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_prepared_stmt_count value: '-1'
SELECT @@global.max_prepared_stmt_count;
@@global.max_prepared_stmt_count
0
@@ -51,6 +53,8 @@ SELECT @@global.max_prepared_stmt_count;
@@global.max_prepared_stmt_count
1048576
SET @@global.max_prepared_stmt_count = -1024;
+Warnings:
+Warning 1292 Truncated incorrect max_prepared_stmt_count value: '-1024'
SELECT @@global.max_prepared_stmt_count;
@@global.max_prepared_stmt_count
0
diff --git a/mysql-test/suite/sys_vars/r/max_relay_log_size_basic.result b/mysql-test/suite/sys_vars/r/max_relay_log_size_basic.result
index c0042f497ad..168459cf7b6 100644
--- a/mysql-test/suite/sys_vars/r/max_relay_log_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_relay_log_size_basic.result
@@ -38,6 +38,8 @@ SELECT @@global.max_relay_log_size;
'Bug# 34877: Invalid Values are coming in variable on assigning valid values';
'#--------------------FN_DYNVARS_082_04-------------------------#'
SET @@global.max_relay_log_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_relay_log_size value: '-1'
SELECT @@global.max_relay_log_size;
@@global.max_relay_log_size
0
@@ -53,6 +55,8 @@ SELECT @@global.max_relay_log_size;
@@global.max_relay_log_size
1073741824
SET @@global.max_relay_log_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect max_relay_log_size value: '-1024'
SELECT @@global.max_relay_log_size;
@@global.max_relay_log_size
0
diff --git a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result
index 64828fbe619..9a58ad44cff 100644
--- a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_32.result
@@ -77,7 +77,7 @@ SELECT @@global.max_seeks_for_key;
1
SET @@global.max_seeks_for_key = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_seeks_for_key value: '0'
+Warning 1292 Truncated incorrect max_seeks_for_key value: '-1024'
SELECT @@global.max_seeks_for_key;
@@global.max_seeks_for_key
1
@@ -105,7 +105,7 @@ SELECT @@session.max_seeks_for_key;
1
SET @@session.max_seeks_for_key = -2;
Warnings:
-Warning 1292 Truncated incorrect max_seeks_for_key value: '0'
+Warning 1292 Truncated incorrect max_seeks_for_key value: '-2'
SELECT @@session.max_seeks_for_key;
@@session.max_seeks_for_key
1
diff --git a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result
index eefb829cdae..5b1e076c188 100644
--- a/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/max_seeks_for_key_basic_64.result
@@ -77,7 +77,7 @@ SELECT @@global.max_seeks_for_key;
1
SET @@global.max_seeks_for_key = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_seeks_for_key value: '0'
+Warning 1292 Truncated incorrect max_seeks_for_key value: '-1024'
SELECT @@global.max_seeks_for_key;
@@global.max_seeks_for_key
1
@@ -103,7 +103,7 @@ SELECT @@session.max_seeks_for_key;
1
SET @@session.max_seeks_for_key = -2;
Warnings:
-Warning 1292 Truncated incorrect max_seeks_for_key value: '0'
+Warning 1292 Truncated incorrect max_seeks_for_key value: '-2'
SELECT @@session.max_seeks_for_key;
@@session.max_seeks_for_key
1
diff --git a/mysql-test/suite/sys_vars/r/max_sort_length_basic.result b/mysql-test/suite/sys_vars/r/max_sort_length_basic.result
index 73dd31ea4e7..f0a9ca83376 100644
--- a/mysql-test/suite/sys_vars/r/max_sort_length_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_sort_length_basic.result
@@ -71,7 +71,7 @@ SELECT @@session.max_sort_length;
'#------------------FN_DYNVARS_084_05-----------------------#'
SET @@global.max_sort_length = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_sort_length value: '0'
+Warning 1292 Truncated incorrect max_sort_length value: '-1024'
SELECT @@global.max_sort_length;
@@global.max_sort_length
4
@@ -111,7 +111,7 @@ SELECT @@session.max_sort_length;
8388608
SET @@session.max_sort_length = -1;
Warnings:
-Warning 1292 Truncated incorrect max_sort_length value: '0'
+Warning 1292 Truncated incorrect max_sort_length value: '-1'
SELECT @@session.max_sort_length;
@@session.max_sort_length
4
diff --git a/mysql-test/suite/sys_vars/r/max_sp_recursion_depth_basic.result b/mysql-test/suite/sys_vars/r/max_sp_recursion_depth_basic.result
index 8c79f3c5fc7..e5f267253f4 100644
--- a/mysql-test/suite/sys_vars/r/max_sp_recursion_depth_basic.result
+++ b/mysql-test/suite/sys_vars/r/max_sp_recursion_depth_basic.result
@@ -74,6 +74,8 @@ SELECT @@session.max_sp_recursion_depth;
150
'#------------------FN_DYNVARS_085_05-----------------------#'
SET @@global.max_sp_recursion_depth = -1024;
+Warnings:
+Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1024'
SELECT @@global.max_sp_recursion_depth;
@@global.max_sp_recursion_depth
0
@@ -84,6 +86,8 @@ SELECT @@global.max_sp_recursion_depth;
@@global.max_sp_recursion_depth
255
SET @@global.max_sp_recursion_depth = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1'
SELECT @@global.max_sp_recursion_depth;
@@global.max_sp_recursion_depth
0
@@ -110,6 +114,8 @@ SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
255
SET @@session.max_sp_recursion_depth = -1;
+Warnings:
+Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1'
SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
0
@@ -120,6 +126,8 @@ SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
255
SET @@session.max_sp_recursion_depth = -001;
+Warnings:
+Warning 1292 Truncated incorrect max_sp_recursion_depth value: '-1'
SELECT @@session.max_sp_recursion_depth;
@@session.max_sp_recursion_depth
0
diff --git a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result
index 5f959069661..1346d24ca47 100644
--- a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_32.result
@@ -71,7 +71,7 @@ SELECT @@session.max_tmp_tables;
'#------------------FN_DYNVARS_086_05-----------------------#'
SET @@global.max_tmp_tables = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1024'
SELECT @@global.max_tmp_tables;
@@global.max_tmp_tables
1
@@ -83,7 +83,7 @@ SELECT @@global.max_tmp_tables;
4294967295
SET @@global.max_tmp_tables = -1;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1'
SELECT @@global.max_tmp_tables;
@@global.max_tmp_tables
1
@@ -111,7 +111,7 @@ SELECT @@session.max_tmp_tables;
4294967295
SET @@session.max_tmp_tables = -1;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1'
SELECT @@session.max_tmp_tables;
@@session.max_tmp_tables
1
@@ -123,7 +123,7 @@ SELECT @@session.max_tmp_tables;
4294967295
SET @@session.max_tmp_tables = -001;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1'
SELECT @@session.max_tmp_tables;
@@session.max_tmp_tables
1
diff --git a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result
index 4b9f68c509e..808e99b739d 100644
--- a/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/max_tmp_tables_basic_64.result
@@ -71,7 +71,7 @@ SELECT @@session.max_tmp_tables;
'#------------------FN_DYNVARS_086_05-----------------------#'
SET @@global.max_tmp_tables = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1024'
SELECT @@global.max_tmp_tables;
@@global.max_tmp_tables
1
@@ -81,7 +81,7 @@ SELECT @@global.max_tmp_tables;
4294967296
SET @@global.max_tmp_tables = -1;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1'
SELECT @@global.max_tmp_tables;
@@global.max_tmp_tables
1
@@ -105,7 +105,7 @@ SELECT @@session.max_tmp_tables;
4294967296
SET @@session.max_tmp_tables = -1;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1'
SELECT @@session.max_tmp_tables;
@@session.max_tmp_tables
1
@@ -115,7 +115,7 @@ SELECT @@session.max_tmp_tables;
429496729500
SET @@session.max_tmp_tables = -001;
Warnings:
-Warning 1292 Truncated incorrect max_tmp_tables value: '0'
+Warning 1292 Truncated incorrect max_tmp_tables value: '-1'
SELECT @@session.max_tmp_tables;
@@session.max_tmp_tables
1
diff --git a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result
index 0c9c3c00c1f..24af37260b7 100644
--- a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_32.result
@@ -37,7 +37,7 @@ SELECT @@global.max_write_lock_count;
'#------------------FN_DYNVARS_088_04-----------------------#'
SET @@global.max_write_lock_count = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_write_lock_count value: '0'
+Warning 1292 Truncated incorrect max_write_lock_count value: '-1024'
SELECT @@global.max_write_lock_count;
@@global.max_write_lock_count
1
@@ -49,7 +49,7 @@ SELECT @@global.max_write_lock_count;
4294967295
SET @@global.max_write_lock_count = -1;
Warnings:
-Warning 1292 Truncated incorrect max_write_lock_count value: '0'
+Warning 1292 Truncated incorrect max_write_lock_count value: '-1'
SELECT @@global.max_write_lock_count;
@@global.max_write_lock_count
1
diff --git a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result
index d74586841dd..934777e38d3 100644
--- a/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/max_write_lock_count_basic_64.result
@@ -37,7 +37,7 @@ SELECT @@global.max_write_lock_count;
'#------------------FN_DYNVARS_088_04-----------------------#'
SET @@global.max_write_lock_count = -1024;
Warnings:
-Warning 1292 Truncated incorrect max_write_lock_count value: '0'
+Warning 1292 Truncated incorrect max_write_lock_count value: '-1024'
SELECT @@global.max_write_lock_count;
@@global.max_write_lock_count
1
@@ -47,7 +47,7 @@ SELECT @@global.max_write_lock_count;
4294967296
SET @@global.max_write_lock_count = -1;
Warnings:
-Warning 1292 Truncated incorrect max_write_lock_count value: '0'
+Warning 1292 Truncated incorrect max_write_lock_count value: '-1'
SELECT @@global.max_write_lock_count;
@@global.max_write_lock_count
1
diff --git a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result
index c0315944a8a..c40640ffa3a 100644
--- a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_32.result
@@ -82,6 +82,8 @@ SELECT @@global.min_examined_row_limit;
@@global.min_examined_row_limit
429496726
SET @@global.min_examined_row_limit = -1024;
+Warnings:
+Warning 1292 Truncated incorrect min_examined_row_limit value: '-1024'
SELECT @@global.min_examined_row_limit;
@@global.min_examined_row_limit
0
@@ -108,6 +110,8 @@ SELECT @@session.min_examined_row_limit;
@@session.min_examined_row_limit
4294967295
SET @@session.min_examined_row_limit = -1;
+Warnings:
+Warning 1292 Truncated incorrect min_examined_row_limit value: '-1'
SELECT @@session.min_examined_row_limit;
@@session.min_examined_row_limit
0
diff --git a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result
index fa11659c6c5..5cf77ed6dc8 100644
--- a/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/min_examined_row_limit_basic_64.result
@@ -82,6 +82,8 @@ SELECT @@global.min_examined_row_limit;
@@global.min_examined_row_limit
429496726
SET @@global.min_examined_row_limit = -1024;
+Warnings:
+Warning 1292 Truncated incorrect min_examined_row_limit value: '-1024'
SELECT @@global.min_examined_row_limit;
@@global.min_examined_row_limit
0
@@ -104,6 +106,8 @@ SELECT @@session.min_examined_row_limit;
@@session.min_examined_row_limit
4294967296
SET @@session.min_examined_row_limit = -1;
+Warnings:
+Warning 1292 Truncated incorrect min_examined_row_limit value: '-1'
SELECT @@session.min_examined_row_limit;
@@session.min_examined_row_limit
0
diff --git a/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result b/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result
index f6ac6490479..33222f781f2 100644
--- a/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/multi_range_count_basic_32.result
@@ -83,7 +83,7 @@ SELECT @@global.multi_range_count;
4294967295
SET @@global.multi_range_count = -1024;
Warnings:
-Warning 1292 Truncated incorrect multi_range_count value: '0'
+Warning 1292 Truncated incorrect multi_range_count value: '-1024'
SELECT @@global.multi_range_count;
@@global.multi_range_count
1
@@ -117,7 +117,7 @@ SELECT @@session.multi_range_count;
4294967295
SET @@session.multi_range_count = -1;
Warnings:
-Warning 1292 Truncated incorrect multi_range_count value: '0'
+Warning 1292 Truncated incorrect multi_range_count value: '-1'
SELECT @@session.multi_range_count;
@@session.multi_range_count
1
diff --git a/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result b/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result
index f2115aec2e2..29019ca5971 100644
--- a/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/multi_range_count_basic_64.result
@@ -81,7 +81,7 @@ SELECT @@global.multi_range_count;
4294967296
SET @@global.multi_range_count = -1024;
Warnings:
-Warning 1292 Truncated incorrect multi_range_count value: '0'
+Warning 1292 Truncated incorrect multi_range_count value: '-1024'
SELECT @@global.multi_range_count;
@@global.multi_range_count
1
@@ -111,7 +111,7 @@ SELECT @@session.multi_range_count;
4294967296
SET @@session.multi_range_count = -1;
Warnings:
-Warning 1292 Truncated incorrect multi_range_count value: '0'
+Warning 1292 Truncated incorrect multi_range_count value: '-1'
SELECT @@session.multi_range_count;
@@session.multi_range_count
1
diff --git a/mysql-test/suite/sys_vars/r/myisam_data_pointer_size_basic.result b/mysql-test/suite/sys_vars/r/myisam_data_pointer_size_basic.result
index d2b0bebe029..86f7788fcdf 100644
--- a/mysql-test/suite/sys_vars/r/myisam_data_pointer_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/myisam_data_pointer_size_basic.result
@@ -48,7 +48,7 @@ ERROR HY000: Variable 'myisam_data_pointer_size' is a GLOBAL variable and should
'#------------------FN_DYNVARS_093_05-----------------------#'
SET @@global.myisam_data_pointer_size = -1;
Warnings:
-Warning 1292 Truncated incorrect myisam_data_pointer_size value: '0'
+Warning 1292 Truncated incorrect myisam_data_pointer_size value: '-1'
SELECT @@global.myisam_data_pointer_size;
@@global.myisam_data_pointer_size
2
diff --git a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result
index 7467537eaba..b2a8603de92 100644
--- a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_32.result
@@ -48,14 +48,20 @@ SET @@local.myisam_max_sort_file_size = 4;
ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_094_05-----------------------#'
SET @@global.myisam_max_sort_file_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-1'
SELECT @@global.myisam_max_sort_file_size;
@@global.myisam_max_sort_file_size
0
SET @@global.myisam_max_sort_file_size = -2147483648;
+Warnings:
+Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483648'
SELECT @@global.myisam_max_sort_file_size;
@@global.myisam_max_sort_file_size
0
SET @@global.myisam_max_sort_file_size = -2147483649;
+Warnings:
+Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483649'
SELECT @@global.myisam_max_sort_file_size;
@@global.myisam_max_sort_file_size
0
diff --git a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result
index 00ff1dfc1ab..df2a49e4dd5 100644
--- a/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/myisam_max_sort_file_size_basic_64.result
@@ -1,7 +1,7 @@
SET @start_global_value = @@global.myisam_max_sort_file_size;
SELECT @start_global_value;
@start_global_value
-9223372036854775807
+9223372036853727232
'#--------------------FN_DYNVARS_094_01-------------------------#'
SET @@global.myisam_max_sort_file_size = 500000;
SET @@global.myisam_max_sort_file_size = DEFAULT;
@@ -48,14 +48,20 @@ SET @@local.myisam_max_sort_file_size = 4;
ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_094_05-----------------------#'
SET @@global.myisam_max_sort_file_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-1'
SELECT @@global.myisam_max_sort_file_size;
@@global.myisam_max_sort_file_size
0
SET @@global.myisam_max_sort_file_size = -2147483648;
+Warnings:
+Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483648'
SELECT @@global.myisam_max_sort_file_size;
@@global.myisam_max_sort_file_size
0
SET @@global.myisam_max_sort_file_size = -2147483649;
+Warnings:
+Warning 1292 Truncated incorrect myisam_max_sort_file_size value: '-2147483649'
SELECT @@global.myisam_max_sort_file_size;
@@global.myisam_max_sort_file_size
0
diff --git a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result
index c91128e3f4c..64321814746 100644
--- a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_32.result
@@ -61,7 +61,7 @@ SELECT @@global.myisam_repair_threads ;
1
SET @@global.myisam_repair_threads = -1024;
Warnings:
-Warning 1292 Truncated incorrect myisam_repair_threads value: '0'
+Warning 1292 Truncated incorrect myisam_repair_threads value: '-1024'
SELECT @@global.myisam_repair_threads ;
@@global.myisam_repair_threads
1
@@ -104,7 +104,7 @@ SELECT @@session.myisam_repair_threads ;
1
SET @@session.myisam_repair_threads = -2;
Warnings:
-Warning 1292 Truncated incorrect myisam_repair_threads value: '0'
+Warning 1292 Truncated incorrect myisam_repair_threads value: '-2'
SELECT @@session.myisam_repair_threads ;
@@session.myisam_repair_threads
1
diff --git a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result
index 8271451cc9e..0a317d28b11 100644
--- a/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/myisam_repair_threads_basic_64.result
@@ -61,7 +61,7 @@ SELECT @@global.myisam_repair_threads ;
1
SET @@global.myisam_repair_threads = -1024;
Warnings:
-Warning 1292 Truncated incorrect myisam_repair_threads value: '0'
+Warning 1292 Truncated incorrect myisam_repair_threads value: '-1024'
SELECT @@global.myisam_repair_threads ;
@@global.myisam_repair_threads
1
@@ -102,7 +102,7 @@ SELECT @@session.myisam_repair_threads ;
1
SET @@session.myisam_repair_threads = -2;
Warnings:
-Warning 1292 Truncated incorrect myisam_repair_threads value: '0'
+Warning 1292 Truncated incorrect myisam_repair_threads value: '-2'
SELECT @@session.myisam_repair_threads ;
@@session.myisam_repair_threads
1
diff --git a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result
index 74d2fb3ec86..2657d599df7 100644
--- a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_32.result
@@ -61,7 +61,7 @@ SELECT @@global.myisam_sort_buffer_size ;
4
SET @@global.myisam_sort_buffer_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0'
+Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-1024'
SELECT @@global.myisam_sort_buffer_size ;
@@global.myisam_sort_buffer_size
4
@@ -104,7 +104,7 @@ SELECT @@session.myisam_sort_buffer_size ;
4
SET @@session.myisam_sort_buffer_size = -2;
Warnings:
-Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0'
+Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-2'
SELECT @@session.myisam_sort_buffer_size ;
@@session.myisam_sort_buffer_size
4
diff --git a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result
index bfcada76a46..be9e415d830 100644
--- a/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/myisam_sort_buffer_size_basic_64.result
@@ -61,7 +61,7 @@ SELECT @@global.myisam_sort_buffer_size ;
4
SET @@global.myisam_sort_buffer_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0'
+Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-1024'
SELECT @@global.myisam_sort_buffer_size ;
@@global.myisam_sort_buffer_size
4
@@ -102,7 +102,7 @@ SELECT @@session.myisam_sort_buffer_size ;
4
SET @@session.myisam_sort_buffer_size = -2;
Warnings:
-Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '0'
+Warning 1292 Truncated incorrect myisam_sort_buffer_size value: '-2'
SELECT @@session.myisam_sort_buffer_size ;
@@session.myisam_sort_buffer_size
4
diff --git a/mysql-test/suite/sys_vars/r/net_buffer_length_basic.result b/mysql-test/suite/sys_vars/r/net_buffer_length_basic.result
index be7e9082332..07f933b5a4b 100644
--- a/mysql-test/suite/sys_vars/r/net_buffer_length_basic.result
+++ b/mysql-test/suite/sys_vars/r/net_buffer_length_basic.result
@@ -50,7 +50,7 @@ SELECT @@global.net_buffer_length;
1024
SET @@global.net_buffer_length = -1024;
Warnings:
-Warning 1292 Truncated incorrect net_buffer_length value: '0'
+Warning 1292 Truncated incorrect net_buffer_length value: '-1024'
SELECT @@global.net_buffer_length;
@@global.net_buffer_length
1024
diff --git a/mysql-test/suite/sys_vars/r/net_read_timeout_basic.result b/mysql-test/suite/sys_vars/r/net_read_timeout_basic.result
index 90a6ef72718..aeee25c6526 100644
--- a/mysql-test/suite/sys_vars/r/net_read_timeout_basic.result
+++ b/mysql-test/suite/sys_vars/r/net_read_timeout_basic.result
@@ -61,7 +61,7 @@ SELECT @@global.net_read_timeout;
1
SET @@global.net_read_timeout = -1024;
Warnings:
-Warning 1292 Truncated incorrect net_read_timeout value: '0'
+Warning 1292 Truncated incorrect net_read_timeout value: '-1024'
SELECT @@global.net_read_timeout;
@@global.net_read_timeout
1
@@ -89,7 +89,7 @@ SELECT @@session.net_read_timeout;
1
SET @@session.net_read_timeout = -2;
Warnings:
-Warning 1292 Truncated incorrect net_read_timeout value: '0'
+Warning 1292 Truncated incorrect net_read_timeout value: '-2'
SELECT @@session.net_read_timeout;
@@session.net_read_timeout
1
diff --git a/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result b/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result
index 3923df539e7..7a8b99ac55c 100644
--- a/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/net_retry_count_basic_32.result
@@ -77,7 +77,7 @@ SELECT @@global.net_retry_count;
1
SET @@global.net_retry_count = -1024;
Warnings:
-Warning 1292 Truncated incorrect net_retry_count value: '0'
+Warning 1292 Truncated incorrect net_retry_count value: '-1024'
SELECT @@global.net_retry_count;
@@global.net_retry_count
1
@@ -111,7 +111,7 @@ SELECT @@session.net_retry_count;
1
SET @@session.net_retry_count = -2;
Warnings:
-Warning 1292 Truncated incorrect net_retry_count value: '0'
+Warning 1292 Truncated incorrect net_retry_count value: '-2'
SELECT @@session.net_retry_count;
@@session.net_retry_count
1
diff --git a/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result b/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result
index db133d23f79..67dae3d1291 100644
--- a/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/net_retry_count_basic_64.result
@@ -77,7 +77,7 @@ SELECT @@global.net_retry_count;
1
SET @@global.net_retry_count = -1024;
Warnings:
-Warning 1292 Truncated incorrect net_retry_count value: '0'
+Warning 1292 Truncated incorrect net_retry_count value: '-1024'
SELECT @@global.net_retry_count;
@@global.net_retry_count
1
@@ -107,7 +107,7 @@ SELECT @@session.net_retry_count;
1
SET @@session.net_retry_count = -2;
Warnings:
-Warning 1292 Truncated incorrect net_retry_count value: '0'
+Warning 1292 Truncated incorrect net_retry_count value: '-2'
SELECT @@session.net_retry_count;
@@session.net_retry_count
1
diff --git a/mysql-test/suite/sys_vars/r/net_write_timeout_basic.result b/mysql-test/suite/sys_vars/r/net_write_timeout_basic.result
index 35a2cf069e3..8857b8c0e37 100644
--- a/mysql-test/suite/sys_vars/r/net_write_timeout_basic.result
+++ b/mysql-test/suite/sys_vars/r/net_write_timeout_basic.result
@@ -61,7 +61,7 @@ SELECT @@global.net_write_timeout;
1
SET @@global.net_write_timeout = -1024;
Warnings:
-Warning 1292 Truncated incorrect net_write_timeout value: '0'
+Warning 1292 Truncated incorrect net_write_timeout value: '-1024'
SELECT @@global.net_write_timeout;
@@global.net_write_timeout
1
@@ -89,7 +89,7 @@ SELECT @@session.net_write_timeout;
1
SET @@session.net_write_timeout = -2;
Warnings:
-Warning 1292 Truncated incorrect net_write_timeout value: '0'
+Warning 1292 Truncated incorrect net_write_timeout value: '-2'
SELECT @@session.net_write_timeout;
@@session.net_write_timeout
1
diff --git a/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result b/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result
index 46fe70c40d0..c126569ebcd 100644
--- a/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result
+++ b/mysql-test/suite/sys_vars/r/optimizer_prune_level_basic.result
@@ -81,6 +81,8 @@ ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@global.optimizer_prune_level = FELSE;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@global.optimizer_prune_level = -1024;
+Warnings:
+Warning 1292 Truncated incorrect optimizer_prune_level value: '-1024'
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
0
@@ -107,6 +109,8 @@ ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@session.optimizer_prune_level = 'OFN';
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@session.optimizer_prune_level = -2;
+Warnings:
+Warning 1292 Truncated incorrect optimizer_prune_level value: '-2'
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
0
diff --git a/mysql-test/suite/sys_vars/r/optimizer_search_depth_basic.result b/mysql-test/suite/sys_vars/r/optimizer_search_depth_basic.result
index 9c26339839e..9c49ae7e73f 100644
--- a/mysql-test/suite/sys_vars/r/optimizer_search_depth_basic.result
+++ b/mysql-test/suite/sys_vars/r/optimizer_search_depth_basic.result
@@ -72,6 +72,8 @@ SELECT @@global.optimizer_search_depth;
@@global.optimizer_search_depth
63
SET @@global.optimizer_search_depth = -1;
+Warnings:
+Warning 1292 Truncated incorrect optimizer_search_depth value: '-1'
SELECT @@global.optimizer_search_depth;
@@global.optimizer_search_depth
0
@@ -98,6 +100,8 @@ SELECT @@session.optimizer_search_depth;
@@session.optimizer_search_depth
63
SET @@session.optimizer_search_depth = -2;
+Warnings:
+Warning 1292 Truncated incorrect optimizer_search_depth value: '-2'
SELECT @@session.optimizer_search_depth;
@@session.optimizer_search_depth
0
diff --git a/mysql-test/suite/sys_vars/r/preload_buffer_size_basic.result b/mysql-test/suite/sys_vars/r/preload_buffer_size_basic.result
index 775b670d3bc..fd8bdd222d2 100644
--- a/mysql-test/suite/sys_vars/r/preload_buffer_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/preload_buffer_size_basic.result
@@ -77,7 +77,7 @@ SELECT @@global.preload_buffer_size;
1024
SET @@global.preload_buffer_size = -1;
Warnings:
-Warning 1292 Truncated incorrect preload_buffer_size value: '0'
+Warning 1292 Truncated incorrect preload_buffer_size value: '-1'
SELECT @@global.preload_buffer_size;
@@global.preload_buffer_size
1024
@@ -111,7 +111,7 @@ SELECT @@session.preload_buffer_size;
1024
SET @@session.preload_buffer_size = -2;
Warnings:
-Warning 1292 Truncated incorrect preload_buffer_size value: '0'
+Warning 1292 Truncated incorrect preload_buffer_size value: '-2'
SELECT @@session.preload_buffer_size;
@@session.preload_buffer_size
1024
diff --git a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result
index 32b9371977c..2ea0831a36d 100644
--- a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_32.result
@@ -86,7 +86,7 @@ SELECT @@global.query_alloc_block_size;
1024
SET @@global.query_alloc_block_size = -1;
Warnings:
-Warning 1292 Truncated incorrect query_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect query_alloc_block_size value: '-1'
SELECT @@global.query_alloc_block_size;
@@global.query_alloc_block_size
1024
@@ -120,7 +120,7 @@ SELECT @@session.query_alloc_block_size;
1024
SET @@session.query_alloc_block_size = -2;
Warnings:
-Warning 1292 Truncated incorrect query_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect query_alloc_block_size value: '-2'
SELECT @@session.query_alloc_block_size;
@@session.query_alloc_block_size
1024
diff --git a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result
index 57c96a8168a..7c573bdb7cb 100644
--- a/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/query_alloc_block_size_basic_64.result
@@ -78,7 +78,7 @@ SELECT @@global.query_alloc_block_size;
1024
SET @@global.query_alloc_block_size = -1;
Warnings:
-Warning 1292 Truncated incorrect query_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect query_alloc_block_size value: '-1'
SELECT @@global.query_alloc_block_size;
@@global.query_alloc_block_size
1024
@@ -110,7 +110,7 @@ SELECT @@session.query_alloc_block_size;
1024
SET @@session.query_alloc_block_size = -2;
Warnings:
-Warning 1292 Truncated incorrect query_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect query_alloc_block_size value: '-2'
SELECT @@session.query_alloc_block_size;
@@session.query_alloc_block_size
1024
diff --git a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result
index bb66233732d..4fab29b8952 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_32.result
@@ -32,6 +32,8 @@ SELECT @@global.query_cache_limit;
1048575
'#--------------------FN_DYNVARS_131_04-------------------------#'
SET @@global.query_cache_limit = -1;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_limit value: '-1'
SELECT @@global.query_cache_limit;
@@global.query_cache_limit
0
@@ -53,6 +55,8 @@ SELECT @@global.query_cache_limit;
@@global.query_cache_limit
4294967295
SET @@global.query_cache_limit = -1024;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_limit value: '-1024'
SELECT @@global.query_cache_limit;
@@global.query_cache_limit
0
diff --git a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result
index a592883ef91..7b3e759deb4 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_limit_basic_64.result
@@ -32,6 +32,8 @@ SELECT @@global.query_cache_limit;
1048575
'#--------------------FN_DYNVARS_131_04-------------------------#'
SET @@global.query_cache_limit = -1;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_limit value: '-1'
SELECT @@global.query_cache_limit;
@@global.query_cache_limit
0
@@ -49,6 +51,8 @@ SELECT @@global.query_cache_limit;
@@global.query_cache_limit
10240022115
SET @@global.query_cache_limit = -1024;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_limit value: '-1024'
SELECT @@global.query_cache_limit;
@@global.query_cache_limit
0
diff --git a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result
index e0d8a0d2a30..b6e274d6ad2 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_32.result
@@ -42,6 +42,8 @@ SELECT @@global.query_cache_min_res_unit;
1048576
'#--------------------FN_DYNVARS_132_04-------------------------#'
SET @@global.query_cache_min_res_unit = -1;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1'
SELECT @@global.query_cache_min_res_unit;
@@global.query_cache_min_res_unit
512
@@ -61,6 +63,8 @@ SELECT @@global.query_cache_min_res_unit;
@@global.query_cache_min_res_unit
512
SET @@global.query_cache_min_res_unit = -1024;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1024'
SELECT @@global.query_cache_min_res_unit;
@@global.query_cache_min_res_unit
512
diff --git a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result
index e1c74d2bbc1..fdbbc71f108 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_min_res_unit_basic_64.result
@@ -42,6 +42,8 @@ SELECT @@global.query_cache_min_res_unit;
1048576
'#--------------------FN_DYNVARS_132_04-------------------------#'
SET @@global.query_cache_min_res_unit = -1;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1'
SELECT @@global.query_cache_min_res_unit;
@@global.query_cache_min_res_unit
512
@@ -59,6 +61,8 @@ SELECT @@global.query_cache_min_res_unit;
@@global.query_cache_min_res_unit
512
SET @@global.query_cache_min_res_unit = -1024;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_min_res_unit value: '-1024'
SELECT @@global.query_cache_min_res_unit;
@@global.query_cache_min_res_unit
512
diff --git a/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result b/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result
index 1793726b2f1..5ceb02182b3 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_size_basic_32.result
@@ -41,6 +41,8 @@ SELECT @@global.query_cache_size;
1047552
'#--------------------FN_DYNVARS_133_04-------------------------#'
SET @@global.query_cache_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_size value: '-1'
SELECT @@global.query_cache_size;
@@global.query_cache_size
0
@@ -61,6 +63,8 @@ SELECT @@global.query_cache_size;
@@global.query_cache_size
0
SET @@global.query_cache_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_size value: '-1024'
SELECT @@global.query_cache_size;
@@global.query_cache_size
0
diff --git a/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result b/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result
index 0cc508b169e..c6d7999677f 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_size_basic_64.result
@@ -41,6 +41,8 @@ SELECT @@global.query_cache_size;
1047552
'#--------------------FN_DYNVARS_133_04-------------------------#'
SET @@global.query_cache_size = -1;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_size value: '-1'
SELECT @@global.query_cache_size;
@@global.query_cache_size
0
@@ -58,6 +60,8 @@ SELECT @@global.query_cache_size;
@@global.query_cache_size
0
SET @@global.query_cache_size = -1024;
+Warnings:
+Warning 1292 Truncated incorrect query_cache_size value: '-1024'
SELECT @@global.query_cache_size;
@@global.query_cache_size
0
diff --git a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result
index 71ee11a5235..6b90b61a035 100644
--- a/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result
+++ b/mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result
@@ -53,7 +53,7 @@ LOCK TABLE t1 WRITE;
** Asynchronous Execution **
SELECT * FROM t1;
** Connection con0 **
-Sleeping 2 Seconds before unlock
+wait until table is locked
UNLOCK TABLES;
** Connection con1 **
** Asynchronous Result **
@@ -108,8 +108,17 @@ id value
1 val1
2 val2
3 val3
+SELECT * FROM t1;
+id value
+1 val1
+2 val2
+3 val3
+SELECT * FROM t1;
+id value
+1 val1
+2 val2
+3 val3
** Connection con0 **
-Sleeping 2 Seconds before unlock
UNLOCK TABLES;
** Connection con1 **
'#----------------------------FN_DYNVARS_136_05------------------------#'
diff --git a/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result b/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result
index 0e61fbcd4b5..a16c56f95c5 100644
--- a/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/query_prealloc_size_basic_64.result
@@ -35,10 +35,6 @@ SET @@global.query_prealloc_size = 8192;
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
8192
-SET @@global.query_prealloc_size = 4294967295;
-SELECT @@global.query_prealloc_size ;
-@@global.query_prealloc_size
-4294966272
SET @@global.query_prealloc_size = 655354;
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
@@ -48,10 +44,6 @@ SET @@session.query_prealloc_size = 8192;
SELECT @@session.query_prealloc_size ;
@@session.query_prealloc_size
8192
-SET @@session.query_prealloc_size = 4294967295;
-SELECT @@session.query_prealloc_size ;
-@@session.query_prealloc_size
-4294966272
SET @@session.query_prealloc_size = 655345;
SELECT @@session.query_prealloc_size ;
@@session.query_prealloc_size
@@ -63,48 +55,32 @@ Warning 1292 Truncated incorrect query_prealloc_size value: '0'
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
8192
-SET @@global.query_prealloc_size = -1024;
-Warnings:
-Warning 1292 Truncated incorrect query_prealloc_size value: '0'
-SELECT @@global.query_prealloc_size ;
-@@global.query_prealloc_size
-8192
-SET @@global.query_prealloc_size = 429496729533;
-SELECT @@global.query_prealloc_size ;
-@@global.query_prealloc_size
-429496728576
SET @@global.query_prealloc_size = 65530.34.;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
-429496728576
+8192
SET @@global.query_prealloc_size = test;
ERROR 42000: Incorrect argument type to variable 'query_prealloc_size'
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
-429496728576
+8192
SET @@global.query_prealloc_size = "test";
ERROR 42000: Incorrect argument type to variable 'query_prealloc_size'
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
-429496728576
+8192
SET @@global.query_prealloc_size = 'test';
ERROR 42000: Incorrect argument type to variable 'query_prealloc_size'
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
-429496728576
+8192
SET @@global.query_prealloc_size = ON;
ERROR 42000: Incorrect argument type to variable 'query_prealloc_size'
SELECT @@global.query_prealloc_size ;
@@global.query_prealloc_size
-429496728576
-SET @@session.query_prealloc_size = 0;
-Warnings:
-Warning 1292 Truncated incorrect query_prealloc_size value: '0'
-SELECT @@session.query_prealloc_size ;
-@@session.query_prealloc_size
8192
-SET @@session.query_prealloc_size = -2;
+SET @@session.query_prealloc_size = 0;
Warnings:
Warning 1292 Truncated incorrect query_prealloc_size value: '0'
SELECT @@session.query_prealloc_size ;
diff --git a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result
index 95e22dfcf14..9e3b7851d8a 100644
--- a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_32.result
@@ -79,7 +79,7 @@ SELECT @@global.range_alloc_block_size;
4096
SET @@global.range_alloc_block_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect range_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect range_alloc_block_size value: '-1024'
SELECT @@global.range_alloc_block_size;
@@global.range_alloc_block_size
4096
@@ -107,7 +107,7 @@ SELECT @@session.range_alloc_block_size;
4096
SET @@session.range_alloc_block_size = -2;
Warnings:
-Warning 1292 Truncated incorrect range_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect range_alloc_block_size value: '-2'
SELECT @@session.range_alloc_block_size;
@@session.range_alloc_block_size
4096
diff --git a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result
index 26ddfdd2bae..29bf939edac 100644
--- a/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/range_alloc_block_size_basic_64.result
@@ -71,7 +71,7 @@ SELECT @@global.range_alloc_block_size;
4096
SET @@global.range_alloc_block_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect range_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect range_alloc_block_size value: '-1024'
SELECT @@global.range_alloc_block_size;
@@global.range_alloc_block_size
4096
@@ -97,7 +97,7 @@ SELECT @@session.range_alloc_block_size;
4096
SET @@session.range_alloc_block_size = -2;
Warnings:
-Warning 1292 Truncated incorrect range_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect range_alloc_block_size value: '-2'
SELECT @@session.range_alloc_block_size;
@@session.range_alloc_block_size
4096
diff --git a/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result b/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result
index 3c007dc1515..6aee841c939 100644
--- a/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/read_buffer_size_basic.result
@@ -81,7 +81,7 @@ SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ;
1
SET @@global.read_buffer_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect read_buffer_size value: '0'
+Warning 1292 Truncated incorrect read_buffer_size value: '-1024'
SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ;
@@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228
1
@@ -109,7 +109,7 @@ SELECT @@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228 ;
1
SET @@session.read_buffer_size = -2;
Warnings:
-Warning 1292 Truncated incorrect read_buffer_size value: '0'
+Warning 1292 Truncated incorrect read_buffer_size value: '-2'
SELECT @@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228 ;
@@session.read_buffer_size= 8200 OR @@session.read_buffer_size= 8228
1
@@ -155,15 +155,11 @@ SELECT @@global.read_buffer_size= 8200 OR @@global.read_buffer_size= 8228 ;
'Bug: FN_DYNVARS_138_08- Errors are not coming on assigning TRUE/FALSE to variable'
'#---------------------FN_DYNVARS_138_09----------------------#'
SET @@global.read_buffer_size = 9000;
-Warnings:
-Warning 1292 Truncated incorrect read_buffer_size value: '9000'
SELECT @@read_buffer_size = @@global.read_buffer_size;
@@read_buffer_size = @@global.read_buffer_size
0
'#---------------------FN_DYNVARS_138_10----------------------#'
SET @@read_buffer_size = 9000;
-Warnings:
-Warning 1292 Truncated incorrect read_buffer_size value: '9000'
SELECT @@read_buffer_size = @@local.read_buffer_size;
@@read_buffer_size = @@local.read_buffer_size
1
@@ -172,8 +168,6 @@ SELECT @@local.read_buffer_size = @@session.read_buffer_size;
1
'#---------------------FN_DYNVARS_138_11----------------------#'
SET read_buffer_size = 9100;
-Warnings:
-Warning 1292 Truncated incorrect read_buffer_size value: '9100'
SELECT @@read_buffer_size= 8200 OR @@read_buffer_size= 8228 ;
@@read_buffer_size= 8200 OR @@read_buffer_size= 8228
1
diff --git a/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result b/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result
index c6440ac032e..f2645e4d527 100644
--- a/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/read_rnd_buffer_size_basic.result
@@ -83,7 +83,7 @@ SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 822
1
SET @@global.read_rnd_buffer_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect read_rnd_buffer_size value: '0'
+Warning 1292 Truncated incorrect read_rnd_buffer_size value: '-1024'
SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228;
@@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 8228
1
@@ -111,7 +111,7 @@ SELECT @@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8
1
SET @@session.read_rnd_buffer_size = -2;
Warnings:
-Warning 1292 Truncated incorrect read_rnd_buffer_size value: '0'
+Warning 1292 Truncated incorrect read_rnd_buffer_size value: '-2'
SELECT @@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8228;
@@session.read_rnd_buffer_size= 8200 OR @@session.read_rnd_buffer_size= 8228
1
@@ -154,15 +154,11 @@ SELECT @@global.read_rnd_buffer_size= 8200 OR @@global.read_rnd_buffer_size= 822
1
'#---------------------FN_DYNVARS_140_09----------------------#'
SET @@global.read_rnd_buffer_size = 9000;
-Warnings:
-Warning 1292 Truncated incorrect read_rnd_buffer_size value: '9000'
SELECT @@read_rnd_buffer_size = @@global.read_rnd_buffer_size;
@@read_rnd_buffer_size = @@global.read_rnd_buffer_size
0
'#---------------------FN_DYNVARS_140_10----------------------#'
SET @@read_rnd_buffer_size = 9000;
-Warnings:
-Warning 1292 Truncated incorrect read_rnd_buffer_size value: '9000'
SELECT @@read_rnd_buffer_size = @@local.read_rnd_buffer_size;
@@read_rnd_buffer_size = @@local.read_rnd_buffer_size
1
@@ -171,8 +167,6 @@ SELECT @@local.read_rnd_buffer_size = @@session.read_rnd_buffer_size;
1
'#---------------------FN_DYNVARS_140_11----------------------#'
SET read_rnd_buffer_size = 9100;
-Warnings:
-Warning 1292 Truncated incorrect read_rnd_buffer_size value: '9100'
SELECT @@read_rnd_buffer_size= 8200 OR @@read_rnd_buffer_size= 8228;
@@read_rnd_buffer_size= 8200 OR @@read_rnd_buffer_size= 8228
1
diff --git a/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result b/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result
index 0d1f4d483d8..5f730bff882 100644
--- a/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result
+++ b/mysql-test/suite/sys_vars/r/rpl_init_slave_func.result
@@ -12,7 +12,7 @@ DROP TABLE IF EXISTS t1;
CREATE TEMPORARY TABLE t1 AS SELECT @@global.init_slave AS my_column;
DESCRIBE t1;
Field Type Null Key Default Extra
-my_column longtext NO NULL
+my_column varchar(59) NO
DROP TABLE t1;
SELECT @@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1';
@@global.init_slave = 'SET @@global.max_connections = @@global.max_connections + 1'
diff --git a/mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result b/mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result
index 0d0a1ae03c4..57b70814698 100644
--- a/mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result
+++ b/mysql-test/suite/sys_vars/r/rpl_max_binlog_size_func.result
@@ -1,8 +1,11 @@
DROP TABLE IF EXISTS t1;
-'--- check if log file is rotated after 4096 bytes ----'
+'--- check if log file is rotated after 4096 bytes ----'
SET @saved_max_binlog_size= @@global.max_binlog_size;
SET @@global.max_binlog_size = 4096;
CREATE TABLE t1(a CHAR(5));
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+50
'mylog.000002 exists'
SET @@global.max_binlog_size= @saved_max_binlog_size;
DROP TABLE t1;
diff --git a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result
index d4dd46eba71..3b7ecf9dc4a 100644
--- a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_32.result
@@ -23,13 +23,13 @@ SELECT @@global.rpl_recovery_rank;
123456789
SET @@global.rpl_recovery_rank = 2147483648*2;
Warnings:
-Warning 1292 Truncated incorrect rpl-recovery-rank value: '4294967296'
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '4294967296'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
4294967295
SET @@global.rpl_recovery_rank = 2147483648*1024;
Warnings:
-Warning 1292 Truncated incorrect rpl-recovery-rank value: '2199023255552'
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '2199023255552'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
4294967295
@@ -38,7 +38,7 @@ SELECT @@global.rpl_recovery_rank;
4294967295
SET @@global.rpl_recovery_rank = 2147483648*2147483648;
Warnings:
-Warning 1292 Truncated incorrect rpl-recovery-rank value: '4611686018427387904'
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '4611686018427387904'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
4294967295
@@ -51,14 +51,20 @@ SET @@local.rpl_recovery_rank = 4;
ERROR HY000: Variable 'rpl_recovery_rank' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_142_04-----------------------#'
SET @@global.rpl_recovery_rank = -1;
+Warnings:
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '-1'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
0
SET @@global.rpl_recovery_rank = -2147483648;
+Warnings:
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483648'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
0
SET @@global.rpl_recovery_rank = -2147483649;
+Warnings:
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483649'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
0
diff --git a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result
index 74a47fa0f08..9ec34c677e1 100644
--- a/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/rpl_recovery_rank_basic_64.result
@@ -45,14 +45,20 @@ SET @@local.rpl_recovery_rank = 4;
ERROR HY000: Variable 'rpl_recovery_rank' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_142_04-----------------------#'
SET @@global.rpl_recovery_rank = -1;
+Warnings:
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '-1'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
0
SET @@global.rpl_recovery_rank = -2147483648;
+Warnings:
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483648'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
0
SET @@global.rpl_recovery_rank = -2147483649;
+Warnings:
+Warning 1292 Truncated incorrect rpl_recovery_rank value: '-2147483649'
SELECT @@global.rpl_recovery_rank;
@@global.rpl_recovery_rank
0
diff --git a/mysql-test/suite/sys_vars/r/server_id_basic_32.result b/mysql-test/suite/sys_vars/r/server_id_basic_32.result
index 6f801fc627b..12d49248f54 100644
--- a/mysql-test/suite/sys_vars/r/server_id_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/server_id_basic_32.result
@@ -52,16 +52,20 @@ SET @@local.server_id = 4;
ERROR HY000: Variable 'server_id' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_144_05-----------------------#'
SET @@global.server_id = -1;
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '-1'
SELECT @@global.server_id;
@@global.server_id
0
SET @@global.server_id = -2147483648;
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '-2147483648'
SELECT @@global.server_id;
@@global.server_id
0
SET @@global.server_id = 2147483649*2;
Warnings:
-Warning 1292 Truncated incorrect server-id value: '4294967298'
+Warning 1292 Truncated incorrect server_id value: '4294967298'
SELECT @@global.server_id;
@@global.server_id
4294967295
diff --git a/mysql-test/suite/sys_vars/r/server_id_basic_64.result b/mysql-test/suite/sys_vars/r/server_id_basic_64.result
index b6f3095ccfe..12d49248f54 100644
--- a/mysql-test/suite/sys_vars/r/server_id_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/server_id_basic_64.result
@@ -52,17 +52,23 @@ SET @@local.server_id = 4;
ERROR HY000: Variable 'server_id' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_144_05-----------------------#'
SET @@global.server_id = -1;
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '-1'
SELECT @@global.server_id;
@@global.server_id
0
SET @@global.server_id = -2147483648;
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '-2147483648'
SELECT @@global.server_id;
@@global.server_id
0
SET @@global.server_id = 2147483649*2;
+Warnings:
+Warning 1292 Truncated incorrect server_id value: '4294967298'
SELECT @@global.server_id;
@@global.server_id
-4294967298
+4294967295
SET @@global.server_id = 65530.34.;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
SET @@global.server_id = '125';
diff --git a/mysql-test/suite/sys_vars/r/slave_net_timeout_basic.result b/mysql-test/suite/sys_vars/r/slave_net_timeout_basic.result
index 7903d7f8215..728ce106625 100644
--- a/mysql-test/suite/sys_vars/r/slave_net_timeout_basic.result
+++ b/mysql-test/suite/sys_vars/r/slave_net_timeout_basic.result
@@ -58,13 +58,13 @@ ERROR HY000: Variable 'slave_net_timeout' is a GLOBAL variable and should be set
'#------------------FN_DYNVARS_146_05-----------------------#'
SET @@global.slave_net_timeout = -1;
Warnings:
-Warning 1292 Truncated incorrect slave_net_timeout value: '0'
+Warning 1292 Truncated incorrect slave_net_timeout value: '-1'
SELECT @@global.slave_net_timeout;
@@global.slave_net_timeout
1
SET @@global.slave_net_timeout = -2147483648;
Warnings:
-Warning 1292 Truncated incorrect slave_net_timeout value: '0'
+Warning 1292 Truncated incorrect slave_net_timeout value: '-2147483648'
SELECT @@global.slave_net_timeout;
@@global.slave_net_timeout
1
diff --git a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result
index 5b77c500aa0..1b6edb18f8d 100644
--- a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_32.result
@@ -57,6 +57,8 @@ SET @@local.slave_transaction_retries = 4;
ERROR HY000: Variable 'slave_transaction_retries' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_149_05-----------------------#'
SET @@global.slave_transaction_retries = -1;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retries value: '-1'
SELECT @@global.slave_transaction_retries;
@@global.slave_transaction_retries
0
diff --git a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result
index 9434b14b238..6e0bc659f9e 100644
--- a/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/slave_transaction_retries_basic_64.result
@@ -55,6 +55,8 @@ SET @@local.slave_transaction_retries = 4;
ERROR HY000: Variable 'slave_transaction_retries' is a GLOBAL variable and should be set with SET GLOBAL
'#------------------FN_DYNVARS_149_05-----------------------#'
SET @@global.slave_transaction_retries = -1;
+Warnings:
+Warning 1292 Truncated incorrect slave_transaction_retries value: '-1'
SELECT @@global.slave_transaction_retries;
@@global.slave_transaction_retries
0
diff --git a/mysql-test/suite/sys_vars/r/slow_launch_time_basic.result b/mysql-test/suite/sys_vars/r/slow_launch_time_basic.result
index c42942fba1a..da13af4f4e8 100644
--- a/mysql-test/suite/sys_vars/r/slow_launch_time_basic.result
+++ b/mysql-test/suite/sys_vars/r/slow_launch_time_basic.result
@@ -36,6 +36,8 @@ SELECT @@global.slow_launch_time;
65536
'#--------------------FN_DYNVARS_150_04-------------------------#'
SET @@global.slow_launch_time = -1;
+Warnings:
+Warning 1292 Truncated incorrect slow_launch_time value: '-1'
SELECT @@global.slow_launch_time;
@@global.slow_launch_time
0
@@ -57,6 +59,8 @@ SELECT @@global.slow_launch_time;
@@global.slow_launch_time
31536000
SET @@global.slow_launch_time = -1024;
+Warnings:
+Warning 1292 Truncated incorrect slow_launch_time value: '-1024'
SELECT @@global.slow_launch_time;
@@global.slow_launch_time
0
diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_func.result b/mysql-test/suite/sys_vars/r/slow_query_log_func.result
index 83edb4c187e..d5485e2e6d7 100644
--- a/mysql-test/suite/sys_vars/r/slow_query_log_func.result
+++ b/mysql-test/suite/sys_vars/r/slow_query_log_func.result
@@ -17,8 +17,8 @@ TRUNCATE mysql.slow_log;
SELECT sleep(2);
sleep(2)
0
-SELECT count(*) FROM mysql.slow_log;
-count(*)
+SELECT count(*) > 0 FROM mysql.slow_log;
+count(*) > 0
1
SET @@global.log_output = @global_log_output;
SET @global.slow_query_log = @global_slow_query_log;
diff --git a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result
index f0874ae7414..584ca4c6f8f 100644
--- a/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result
+++ b/mysql-test/suite/sys_vars/r/sql_low_priority_updates_func.result
@@ -29,7 +29,6 @@ LOCK TABLE t1 READ;
SELECT * FROM t1;
UNLOCK TABLES;|
** Connection default **
-Sleeping for 1 secs
UNLOCK TABLES;
** Connection con0 **
** Asynchronous Result **
@@ -66,7 +65,6 @@ LOCK TABLE t1 READ;
SELECT * FROM t1;
UNLOCK TABLES;|
** Connection default **
-Sleeping for 1 secs
UNLOCK TABLES;
** Connection con0 **
** Asynchronous Result **
diff --git a/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result b/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result
index 3d9bfb6d218..cae626ad63b 100644
--- a/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/sync_binlog_basic_32.result
@@ -36,47 +36,57 @@ SELECT @@global.sync_binlog;
65536
'#--------------------FN_DYNVARS_168_04-------------------------#'
SET @@global.sync_binlog = -1;
+Warnings:
+Warning 1292 Truncated incorrect sync_binlog value: '-1'
SELECT @@global.sync_binlog;
@@global.sync_binlog
0
SET @@global.sync_binlog = 4294967296;
+Warnings:
+Warning 1292 Truncated incorrect sync_binlog value: '4294967296'
SELECT @@global.sync_binlog;
@@global.sync_binlog
-0
+4294967295
SET @@global.sync_binlog = 10240022115;
+Warnings:
+Warning 1292 Truncated incorrect sync_binlog value: '10240022115'
SELECT @@global.sync_binlog;
@@global.sync_binlog
-1650087523
+4294967295
SET @@global.sync_binlog = 10000.01;
ERROR 42000: Incorrect argument type to variable 'sync_binlog'
SELECT @@global.sync_binlog;
@@global.sync_binlog
-1650087523
+4294967295
SET @@global.sync_binlog = -1024;
+Warnings:
+Warning 1292 Truncated incorrect sync_binlog value: '-1024'
SELECT @@global.sync_binlog;
@@global.sync_binlog
0
SET @@global.sync_binlog = 42949672950;
+Warnings:
+Warning 1292 Truncated incorrect sync_binlog value: '42949672950'
SELECT @@global.sync_binlog;
@@global.sync_binlog
-4294967286
+4294967295
'Bug # 34837: Errors are not coming on assigning invalid values to variable';
SET @@global.sync_binlog = ON;
ERROR 42000: Incorrect argument type to variable 'sync_binlog'
SELECT @@global.sync_binlog;
@@global.sync_binlog
-4294967286
+4294967295
SET @@global.sync_binlog = 'test';
ERROR 42000: Incorrect argument type to variable 'sync_binlog'
SELECT @@global.sync_binlog;
@@global.sync_binlog
-4294967286
+4294967295
'#-------------------FN_DYNVARS_168_05----------------------------#'
SET @@session.sync_binlog = 0;
ERROR HY000: Variable 'sync_binlog' is a GLOBAL variable and should be set with SET GLOBAL
SELECT @@sync_binlog;
@@sync_binlog
-4294967286
+4294967295
'#----------------------FN_DYNVARS_168_06------------------------#'
SELECT @@global.sync_binlog = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
@@ -88,7 +98,7 @@ SET sync_binlog = 1;
ERROR HY000: Variable 'sync_binlog' is a GLOBAL variable and should be set with SET GLOBAL
SELECT @@sync_binlog;
@@sync_binlog
-4294967286
+4294967295
SET local.sync_binlog = 1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sync_binlog = 1' at line 1
SELECT local.sync_binlog;
diff --git a/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result b/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result
index ffd1b3fc4f1..d3cc4e2a9c2 100644
--- a/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/sync_binlog_basic_64.result
@@ -36,6 +36,8 @@ SELECT @@global.sync_binlog;
65536
'#--------------------FN_DYNVARS_168_04-------------------------#'
SET @@global.sync_binlog = -1;
+Warnings:
+Warning 1292 Truncated incorrect sync_binlog value: '-1'
SELECT @@global.sync_binlog;
@@global.sync_binlog
0
@@ -53,6 +55,8 @@ SELECT @@global.sync_binlog;
@@global.sync_binlog
10240022115
SET @@global.sync_binlog = -1024;
+Warnings:
+Warning 1292 Truncated incorrect sync_binlog value: '-1024'
SELECT @@global.sync_binlog;
@@global.sync_binlog
0
diff --git a/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result b/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result
index 13055d00600..611fda6f84a 100644
--- a/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result
+++ b/mysql-test/suite/sys_vars/r/table_definition_cache_basic.result
@@ -45,7 +45,7 @@ SELECT @@global.table_definition_cache;
256
SET @@global.table_definition_cache = -1024;
Warnings:
-Warning 1292 Truncated incorrect table_definition_cache value: '0'
+Warning 1292 Truncated incorrect table_definition_cache value: '-1024'
SELECT @@global.table_definition_cache;
@@global.table_definition_cache
256
diff --git a/mysql-test/suite/sys_vars/r/table_lock_wait_timeout_basic.result b/mysql-test/suite/sys_vars/r/table_lock_wait_timeout_basic.result
index 13771980188..a500581c228 100644
--- a/mysql-test/suite/sys_vars/r/table_lock_wait_timeout_basic.result
+++ b/mysql-test/suite/sys_vars/r/table_lock_wait_timeout_basic.result
@@ -37,13 +37,13 @@ SELECT @@global.table_lock_wait_timeout ;
'#--------------------FN_DYNVARS_001_04-------------------------#'
SET @@global.table_lock_wait_timeout = -1;
Warnings:
-Warning 1292 Truncated incorrect table_lock_wait_timeout value: '0'
+Warning 1292 Truncated incorrect table_lock_wait_timeout value: '-1'
SET @@global.table_lock_wait_timeout= 100000000000;
Warnings:
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '100000000000'
SET @@global.table_lock_wait_timeout= -1024;
Warnings:
-Warning 1292 Truncated incorrect table_lock_wait_timeout value: '0'
+Warning 1292 Truncated incorrect table_lock_wait_timeout value: '-1024'
SET @@global.table_lock_wait_timeout= 0;
Warnings:
Warning 1292 Truncated incorrect table_lock_wait_timeout value: '0'
diff --git a/mysql-test/suite/sys_vars/r/table_open_cache_basic.result b/mysql-test/suite/sys_vars/r/table_open_cache_basic.result
index b6891956489..da9b8c0d1aa 100644
--- a/mysql-test/suite/sys_vars/r/table_open_cache_basic.result
+++ b/mysql-test/suite/sys_vars/r/table_open_cache_basic.result
@@ -39,7 +39,7 @@ SELECT @@global.table_open_cache ;
'#--------------------FN_DYNVARS_001_04-------------------------#'
SET @@global.table_open_cache = -1;
Warnings:
-Warning 1292 Truncated incorrect table_open_cache value: '0'
+Warning 1292 Truncated incorrect table_open_cache value: '-1'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
@@ -51,7 +51,7 @@ SELECT @@global.table_open_cache ;
524288
SET @@global.table_open_cache = -1024;
Warnings:
-Warning 1292 Truncated incorrect table_open_cache value: '0'
+Warning 1292 Truncated incorrect table_open_cache value: '-1024'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
diff --git a/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result b/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result
index 3b4099d30ae..2ebeb8d61d8 100644
--- a/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result
+++ b/mysql-test/suite/sys_vars/r/tmp_table_size_basic.result
@@ -51,7 +51,7 @@ SELECT @@global.tmp_table_size;
1024
SET @@global.tmp_table_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect tmp_table_size value: '0'
+Warning 1292 Truncated incorrect tmp_table_size value: '-1024'
SELECT @@global.tmp_table_size;
@@global.tmp_table_size
1024
@@ -100,6 +100,8 @@ SELECT @@session.tmp_table_size;
SET @@session.tmp_table_size = "Test";
ERROR 42000: Incorrect argument type to variable 'tmp_table_size'
SET @@session.tmp_table_size = 12345678901;
+Warnings:
+Warning 1292 Truncated incorrect tmp_table_size value: '12345678901'
SELECT @@session.tmp_table_size IN (12345678901,4294967295);
@@session.tmp_table_size IN (12345678901,4294967295)
1
diff --git a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result
index 4aaf67c4064..8c6a788862d 100644
--- a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_32.result
@@ -71,7 +71,7 @@ SELECT @@global.transaction_alloc_block_size;
1024
SET @@global.transaction_alloc_block_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect transaction_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect transaction_alloc_block_size value: '-1024'
SELECT @@global.transaction_alloc_block_size;
@@global.transaction_alloc_block_size
1024
diff --git a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result
index c968d6f108c..749df56c60b 100644
--- a/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/transaction_alloc_block_size_basic_64.result
@@ -67,7 +67,7 @@ SELECT @@global.transaction_alloc_block_size;
1024
SET @@global.transaction_alloc_block_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect transaction_alloc_block_size value: '0'
+Warning 1292 Truncated incorrect transaction_alloc_block_size value: '-1024'
SELECT @@global.transaction_alloc_block_size;
@@global.transaction_alloc_block_size
1024
diff --git a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result
index 3df7a55595e..4912653a8e5 100644
--- a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_32.result
@@ -66,7 +66,7 @@ SELECT @@global.transaction_prealloc_size;
1024
SET @@global.transaction_prealloc_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect transaction_prealloc_size value: '0'
+Warning 1292 Truncated incorrect transaction_prealloc_size value: '-1024'
SELECT @@global.transaction_prealloc_size;
@@global.transaction_prealloc_size
1024
diff --git a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result
index 2fb6451372f..3455b9479c0 100644
--- a/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/transaction_prealloc_size_basic_64.result
@@ -66,7 +66,7 @@ SELECT @@global.transaction_prealloc_size;
1024
SET @@global.transaction_prealloc_size = -1024;
Warnings:
-Warning 1292 Truncated incorrect transaction_prealloc_size value: '0'
+Warning 1292 Truncated incorrect transaction_prealloc_size value: '-1024'
SELECT @@global.transaction_prealloc_size;
@@global.transaction_prealloc_size
1024
diff --git a/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result b/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result
index ae03e677e56..c9bffc61b6f 100644
--- a/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result
+++ b/mysql-test/suite/sys_vars/r/wait_timeout_basic_32.result
@@ -44,7 +44,7 @@ Warnings:
Warning 1292 Truncated incorrect wait_timeout value: '0'
SET @@global.wait_timeout = -1024;
Warnings:
-Warning 1292 Truncated incorrect wait_timeout value: '0'
+Warning 1292 Truncated incorrect wait_timeout value: '-1024'
'Bug # 34837: Errors are not coming on assigning invalid values to variable';
SET @@global.wait_timeout = ON;
ERROR 42000: Incorrect argument type to variable 'wait_timeout'
diff --git a/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result b/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result
index ae03e677e56..c9bffc61b6f 100644
--- a/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result
+++ b/mysql-test/suite/sys_vars/r/wait_timeout_basic_64.result
@@ -44,7 +44,7 @@ Warnings:
Warning 1292 Truncated incorrect wait_timeout value: '0'
SET @@global.wait_timeout = -1024;
Warnings:
-Warning 1292 Truncated incorrect wait_timeout value: '0'
+Warning 1292 Truncated incorrect wait_timeout value: '-1024'
'Bug # 34837: Errors are not coming on assigning invalid values to variable';
SET @@global.wait_timeout = ON;
ERROR 42000: Incorrect argument type to variable 'wait_timeout'
diff --git a/mysql-test/suite/sys_vars/t/completion_type_func-master.opt b/mysql-test/suite/sys_vars/t/completion_type_func-master.opt
deleted file mode 100644
index 627becdbfb5..00000000000
--- a/mysql-test/suite/sys_vars/t/completion_type_func-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---innodb
diff --git a/mysql-test/suite/sys_vars/t/completion_type_func.test b/mysql-test/suite/sys_vars/t/completion_type_func.test
index ed0f04c37b4..8e363ed2a7d 100644
--- a/mysql-test/suite/sys_vars/t/completion_type_func.test
+++ b/mysql-test/suite/sys_vars/t/completion_type_func.test
@@ -1,4 +1,4 @@
-############## mysql-test\t\completion_type_func.test ##########################
+############## mysql-test/suite/sys_vars/t/completion_type_func.test ###########
# #
# Variable Name: completion_type #
# Scope: GLOBAL & SESSION #
@@ -25,84 +25,154 @@
DROP TABLE IF EXISTS t1;
--enable_warnings
-#########################
-# Creating new table #
-#########################
+##############################
+# Setup: Table + connections #
+##############################
--echo ## Creating new table ##
CREATE TABLE t1
(
-id INT NOT NULL AUTO_INCREMENT,
+id INT NOT NULL,
PRIMARY KEY (id),
name VARCHAR(30)
) ENGINE = INNODB;
---echo '#--------------------FN_DYNVARS_017_01-------------------------#'
-#########################################################
-# Setting initial value of completion_type to zero #
-#########################################################
-
---echo ## Creating new connection ##
+--echo ## Creating new connections test_con1, test_con2 ##
connect (test_con1,localhost,root,,);
-connection test_con1;
+connect (test_con2,localhost,root,,);
+
+connection default;
+
+--echo #########################################################
+--echo # Setting initial value of completion_type to zero #
+--echo #########################################################
-INSERT INTO t1(name) VALUES('Record_1');
-SET @@autocommit = 0;
+INSERT INTO t1 VALUES(1,'Record_1');
SELECT * FROM t1;
--echo ## Setting value of variable to 0 ##
SET @@session.completion_type = 0;
--echo ## Here commit & rollback should work normally ##
+--echo ## test commit ##
+START TRANSACTION;
+INSERT INTO t1 VALUES(2,'Record_2');
+INSERT INTO t1 VALUES(3,'Record_3');
+SELECT * FROM t1;
+
+--echo Switching to connection test_con1
+connection test_con1;
+--echo ## Don't expect to see id's 2 and 3 in the table w/o COMMIT ##
+SELECT * FROM t1;
+
+--echo Switching to default connection
+connection default;
+COMMIT;
+
+--echo ## test rollback ##
START TRANSACTION;
+INSERT INTO t1 VALUES(4,'Record_4');
+INSERT INTO t1 VALUES(5,'Record_5');
SELECT * FROM t1;
-INSERT INTO t1(name) VALUES('Record_2');
-INSERT INTO t1(name) VALUES('Record_3');
+
+--echo Switching to connection test_con1
+connection test_con1;
+--echo ## Don't expect to see id's 4 and 5 here ##
+--echo ## Expect to see 3, Record_3 ##
SELECT * FROM t1;
-DELETE FROM t1 WHERE id = 2;
+
+--echo Switching to connection default;
+connection default;
+
+
+ROLLBACK;
+--echo ## Don't expect to see id's 4 and 5 now ##
SELECT * FROM t1;
+--echo
+--echo #########################################################
+--echo # Setting initial value of completion_type to one #
+--echo #########################################################
+
+--echo Switching to connection test_con1;
+connection test_con1;
+SET @@session.completion_type = 1;
START TRANSACTION;
SELECT * FROM t1;
-INSERT INTO t1(name) VALUES('Record_4');
-INSERT INTO t1(name) VALUES('Record_5');
+INSERT INTO t1 VALUES(6,'Record_6');
+INSERT INTO t1 VALUES(7,'Record_7');
COMMIT;
+--echo ## Expect to immediately have a new transaction ##
+INSERT INTO t1 VALUES(8,'Record_8');
+SELECT * FROM t1;
+
+connection test_con2;
+--echo switching to test_con2
+--echo ## Do not expect to see 8, Record_8 as no COMMIT has occurred ##
+SELECT * FROM t1;
+
+--echo switch to connection test_con1
+connection test_con1;
+
+--echo ## Testing ROLLBACK behavior
+START TRANSACTION;
+INSERT INTO t1 VALUES(9, 'Record_9');
+INSERT INTO t1 VALUES(10, 'Record_10');
+--echo ## Expect to see id's 8, 9, 10 here ##
+--echo ## 8, Record_8 COMMITted with the start of this transaction ##
+SELECT * FROM t1;
+ROLLBACK;
+--echo ## id's 9 and 10 are gone now due to ROLLBACK ##
+SELECT * FROM t1;
+
+--echo ## Expect a new transaction ##
+INSERT INTO t1 VALUES(9, 'Record_9');
---echo '#--------------------FN_DYNVARS_017_02-------------------------#'
-#########################################################
-# Setting initial value of completion_type to 2 #
-#########################################################
+--echo Switching to connection test_con2
+connection test_con2;
+--echo ## Don't expect to see 9, Record_9 due to no COMMIT yet ##
+SELECT * FROM t1;
+
+--echo Switching to connection test_con1
+connection test_con1;
+ROLLBACK;
+--echo ## Don't expect to see 9, Record_9
+SELECT * FROM t1;
+
+--echo #########################################################
+--echo # Setting initial value of completion_type to 2 #
+--echo #########################################################
SET @@session.completion_type = 2;
--echo ## Here commit should work as COMMIT RELEASE ##
START TRANSACTION;
SELECT * FROM t1;
-INSERT INTO t1(name) VALUES('Record_6');
-INSERT INTO t1(name) VALUES('Record_7');
+INSERT INTO t1 VALUES(9,'Record_9');
+INSERT INTO t1 VALUES(10,'Record_10');
COMMIT;
--echo ## Inserting rows should give error here because connection should ##
--echo ## disconnect after using COMMIT ##
---Error 2006,2013,1053
-INSERT INTO t1(name) VALUES('Record_4');
+--Error 2006,2013,ER_SERVER_SHUTDOWN
+INSERT INTO t1 VALUES(4,'Record_4');
---echo ## Creating new connection test_con2 ##
-connect (test_con2,localhost,root,,);
+--echo switch to connection test_con2
connection test_con2;
SET @@session.completion_type = 2;
--echo ## Inserting rows and using Rollback which should Rollback & release ##
START TRANSACTION;
SELECT * FROM t1;
-INSERT INTO t1(name) VALUES('Record_8');
-INSERT INTO t1(name) VALUES('Record_9');
+INSERT INTO t1 VALUES(11,'Record_11');
+INSERT INTO t1 VALUES(12,'Record_12');
ROLLBACK;
---Error 2006,2013,1053
-INSERT INTO t1(name) VALUES('Record_4');
+--echo ## Expect a failure due to COMMIT/ROLLBACK AND RELEASE behavior ##
+--Error 2006,2013,ER_SERVER_SHUTDOWN,
+INSERT INTO t1 VALUES(4,'Record_4');
connection default;
disconnect test_con1;
diff --git a/mysql-test/suite/sys_vars/t/concurrent_insert_func.test b/mysql-test/suite/sys_vars/t/concurrent_insert_func.test
index cdeb76d9cac..1a600ffd7f6 100644
--- a/mysql-test/suite/sys_vars/t/concurrent_insert_func.test
+++ b/mysql-test/suite/sys_vars/t/concurrent_insert_func.test
@@ -11,6 +11,11 @@
# Creation Date: 2008-03-07 #
# Author: Salman Rawala #
# #
+# Modified: HHunger 2009-02-23 Inserted a wait condition right after the #
+# "INSERT ..record_6" to wait for the end of #
+# the insert. #
+# mleich This test needs some inporovements #
+# #
# Description: Test Cases of Dynamic System Variable "concurrent_insert" #
# that checks functionality of this variable #
# #
@@ -62,7 +67,6 @@ connection test_con1;
INSERT INTO t1(name) VALUES('Record_4');
SELECT * FROM t1;
-
--echo ## unlocking tables ##
--echo connection default;
connection default;
@@ -106,6 +110,8 @@ UNLOCK TABLES;
--echo ## table contens after UNLOCK ##
SELECT * FROM t1;
INSERT INTO t1(name) VALUES('Record_6');
+let $wait_condition= SELECT COUNT(*) = 5 FROM t1;
+--source include/wait_condition.inc
--echo connection test_con1;
connection test_con1;
diff --git a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test
index 97e1f2daed1..61f7d801a1a 100644
--- a/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test
+++ b/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test
@@ -1,23 +1,26 @@
-############# mysql-test\t\sql_low_priority_updates_func.test ###########################
-# #
-# Variable Name: sql_low_priority_updates #
-# Scope: GLOBAL #
-# Access Type: Dynamic #
-# Data Type: BOOLEAN #
-# Default Value: 1 TRUE #
-# Values: 1 TRUE, 0 FALSE #
-# #
-# #
-# Creation Date: 2008-02-25 #
-# Author: Sharique Abdullah #
-# #
-# Description: Test Cases of Dynamic System Variable "sql_low_priority_updates" #
-# that checks behavior of this variable in the following ways #
-# * Functionality based on different values #
-# #
-# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html #
-# #
-#########################################################################################
+################################################################################
+# #
+# Variable Name: sql_low_priority_updates #
+# Scope: GLOBAL #
+# Access Type: Dynamic #
+# Data Type: BOOLEAN #
+# Default Value: 1 TRUE #
+# Values: 1 TRUE, 0 FALSE #
+# #
+# #
+# Creation Date: 2008-02-25 #
+# Author: Sharique Abdullah #
+# Modified: HHunger 2009-02-26 Replaced 2 sleeps by wait conditions #
+# Modified: mleich 2009-03-18 Partially reimplemented #
+# #
+# Description: Test Cases of Dynamic System Variable "sql_low_priority_updates"#
+# that checks behavior of this variable in the following ways #
+# * Functionality based on different values #
+# #
+# Reference: #
+# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html #
+# #
+################################################################################
--echo ** Setup **
--echo
@@ -29,8 +32,10 @@
--echo Creating connection con0
connect (con0,localhost,root,,);
+let $con0_id=`SELECT CONNECTION_ID()`;
--echo Creating connection con1
connect (con1,localhost,root,,);
+let $con1_id=`SELECT CONNECTION_ID()`;
connection default;
@@ -40,31 +45,20 @@ SET @global_delayed_insert_limit = @@GLOBAL.delayed_insert_limit;
# Create Table
#
-CREATE TABLE t1 (a varchar(100));
+CREATE TABLE t1 (a VARCHAR(100),b VARCHAR(100),c VARCHAR(100));
--echo '#--------------------FN_DYNVARS_25_01-------------------------#'
-#
-# Value less than the provided INSERTS (9)
-#
-SET GLOBAL delayed_insert_limit = 9;
+# delayed_insert_limit is smaller than the number of inserted rows
---echo ** Connection con0 **
-connection con0;
-SET GLOBAL delayed_insert_limit = 9;
---echo ** Connection con1 **
-connection con1;
-SET GLOBAL delayed_insert_limit = 9;
---echo ** Connection default **
-connection default;
-SET GLOBAL delayed_insert_limit = 9;
+SET GLOBAL delayed_insert_limit = 14;
-INSERT INTO t1 VALUES('1');
-INSERT INTO t1 VALUES('2');
-INSERT INTO t1 VALUES('3');
-INSERT INTO t1 VALUES('4');
-INSERT INTO t1 VALUES('5');
-INSERT INTO t1 VALUES('6');
+INSERT INTO t1 VALUES('1','1','1');
+INSERT INTO t1 VALUES('2','1','1');
+INSERT INTO t1 VALUES('3','1','1');
+INSERT INTO t1 VALUES('4','1','1');
+INSERT INTO t1 VALUES('5','1','1');
+INSERT INTO t1 VALUES('6','1','1');
LOCK TABLE t1 WRITE;
@@ -72,76 +66,94 @@ LOCK TABLE t1 WRITE;
connection con1;
delimiter |;
-
send
-INSERT DELAYED INTO t1 VALUES('7');
-INSERT DELAYED INTO t1 VALUES('8');
-INSERT DELAYED INTO t1 VALUES('9');
-INSERT DELAYED INTO t1 VALUES('10');
-INSERT DELAYED INTO t1 VALUES('11');
-INSERT DELAYED INTO t1 VALUES('12');
-INSERT DELAYED INTO t1 VALUES('13');
-INSERT DELAYED INTO t1 VALUES('14');
-INSERT DELAYED INTO t1 VALUES('15');
-INSERT DELAYED INTO t1 VALUES('16');
-INSERT DELAYED INTO t1 VALUES('17');
-INSERT DELAYED INTO t1 VALUES('18');
-INSERT DELAYED INTO t1 VALUES('19');
-INSERT DELAYED INTO t1 VALUES('20');
-INSERT DELAYED INTO t1 VALUES('21');
-INSERT DELAYED INTO t1 VALUES('22');|
-
+INSERT DELAYED INTO t1 VALUES('7','1','1');
+INSERT DELAYED INTO t1 VALUES('8','1','1');
+INSERT DELAYED INTO t1 VALUES('9','1','1');
+INSERT DELAYED INTO t1 VALUES('10','1','1');
+INSERT DELAYED INTO t1 VALUES('11','1','1');
+INSERT DELAYED INTO t1 VALUES('12','1','1');
+INSERT DELAYED INTO t1 VALUES('13','1','1');
+INSERT DELAYED INTO t1 VALUES('14','1','1');
+INSERT DELAYED INTO t1 VALUES('15','1','1');
+INSERT DELAYED INTO t1 VALUES('16','1','1');
+INSERT DELAYED INTO t1 VALUES('17','1','1');
+INSERT DELAYED INTO t1 VALUES('18','1','1');
+INSERT DELAYED INTO t1 VALUES('19','1','1');
+INSERT DELAYED INTO t1 VALUES('20','1','1');
+INSERT DELAYED INTO t1 VALUES('21','1','1');
+INSERT DELAYED INTO t1 VALUES('22','1','1');
+INSERT DELAYED INTO t1 VALUES('23','1','1');
+INSERT DELAYED INTO t1 VALUES('24','1','1');
+INSERT DELAYED INTO t1 VALUES('25','1','1');
+INSERT DELAYED INTO t1 VALUES('26','1','1');
+INSERT DELAYED INTO t1 VALUES('27','1','1');
+INSERT DELAYED INTO t1 VALUES('28','1','1');
+INSERT DELAYED INTO t1 VALUES('29','1','1');
+INSERT DELAYED INTO t1 VALUES('30','1','1');
+INSERT DELAYED INTO t1 VALUES('31','1','1');
+INSERT DELAYED INTO t1 VALUES('32','1','1');
+INSERT DELAYED INTO t1 VALUES('33','1','1');
+INSERT DELAYED INTO t1 VALUES('34','1','1');
+INSERT DELAYED INTO t1 VALUES('35','1','1');
+INSERT DELAYED INTO t1 VALUES('36','1','1');
+INSERT DELAYED INTO t1 VALUES('37','1','1');
+INSERT DELAYED INTO t1 VALUES('38','1','1');
+INSERT DELAYED INTO t1 VALUES('39','1','1');
+INSERT DELAYED INTO t1 VALUES('40','1','1');
+INSERT DELAYED INTO t1 VALUES('41','1','1');
+INSERT DELAYED INTO t1 VALUES('42','1','1');
+INSERT DELAYED INTO t1 VALUES('43','1','1');|
delimiter ;|
--echo ** Connection con0 **
connection con0;
-
-delimiter |;
-
-send
-SELECT * FROM t1;|
-
-delimiter ;|
+let $wait_condition=
+ SELECT variable_value > 0 FROM information_schema.global_status
+ WHERE variable_name like 'Not_flushed_delayed_rows';
+--source include/wait_condition.inc
+let $my_select= SELECT COUNT(*) BETWEEN 21 AND 43 FROM t1;
+let $my_select= SELECT COUNT(*) FROM t1;
+send;
+eval $my_select;
--echo ** Connection default **
connection default;
-
---echo Waiting for 1 sec
---sleep 1
-
+--echo ** Wait till con0 is blocked **
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = 'Locked' AND info = '$my_select';
+--source include/wait_condition.inc
UNLOCK TABLES;
+--echo ** Connection con1 **
+connection con1;
+--echo Asynchronous "reap" result
+reap;
+
--echo ** Connection con0 **
connection con0;
+--echo Asynchronous "reap" result
+--echo The next result suffers from
+--echo '# Bug#35386 insert delayed inserts 1 + limit rows instead of just limit rows'
reap;
---echo 'Bug#35386: insert delayed inserts 1 + limit rows instead of just limit rows'
--echo ** Connection default **
connection default;
-
---echo Waiting for 1 sec
---sleep 1
+let $wait_condition= SELECT count(*) = 43 FROM t1;
+--source include/wait_condition.inc
--echo Checking if the delayed insert continued afterwards
-SELECT * FROM t1;
+SELECT COUNT(*) FROM t1;
-DELETE FROM t1;
+DROP TABLE t1;
--echo '#--------------------FN_DYNVARS_25_02-------------------------#'
-#
-# Value 5
-#
-SET GLOBAL delayed_insert_limit = 20;
+# delayed_insert_limit is bigger than the number of inserted rows
+
+CREATE TABLE t1 (a VARCHAR(100));
---echo ** Connection con0 **
-connection con0;
-SET GLOBAL delayed_insert_limit = 20;
---echo ** Connection con1 **
-connection con1;
-SET GLOBAL delayed_insert_limit = 20;
---echo ** Connection default **
-connection default;
SET GLOBAL delayed_insert_limit = 20;
INSERT INTO t1 VALUES('1');
@@ -181,49 +193,52 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
-
+let $wait_condition=
+ SELECT variable_value > 0 FROM information_schema.global_status
+ WHERE variable_name like 'Not_flushed_delayed_rows';
+--source include/wait_condition.inc
--echo Asynchronous execute
-delimiter |;
-
-send
-SELECT * FROM t1;|
-
-delimiter ;|
+let $my_select= SELECT COUNT(*) = 22 FROM t1;
+send;
+eval $my_select;
--echo ** Connection default **
connection default;
-
---echo Waiting for 1 sec
---sleep 1
-
+--echo ** Wait till con0 is blocked **
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM information_schema.processlist
+ WHERE state = 'Locked' AND info = '$my_select';
+--source include/wait_condition.inc
UNLOCK TABLES;
+--echo ** Connection con1 **
+connection con1;
+reap;
+
--echo ** Connection con0 **
connection con0;
---echo Asynchronous execute result
+--echo Asynchronous "reap" result
reap;
--echo ** Connection default**
connection default;
-
---echo Waiting for 1 sec
---sleep 1
--echo Checking if the delayed insert gives the same result afterwards
-SELECT * FROM t1;
+eval $my_select;
-DELETE FROM t1;
#
# Cleanup
#
---echo Switching to default
+--echo ** Connection default**
connection default;
+DROP TABLE t1;
+SET @@GLOBAL.delayed_insert_limit = @global_delayed_insert_limit;
--echo Disconnecting from con1, con0
disconnect con0;
disconnect con1;
-
-DROP TABLE t1;
-
-SET @@GLOBAL.delayed_insert_limit = @global_delayed_insert_limit;
+let $wait_condition=
+ SELECT COUNT(*) = 0 FROM information_schema.processlist
+ WHERE id IN ($con0_id,$con1_id);
+--source include/wait_condition.inc
diff --git a/mysql-test/suite/sys_vars/t/event_scheduler_func.test b/mysql-test/suite/sys_vars/t/event_scheduler_func.test
deleted file mode 100644
index f727b2b6833..00000000000
--- a/mysql-test/suite/sys_vars/t/event_scheduler_func.test
+++ /dev/null
@@ -1,91 +0,0 @@
-############## mysql-test\t\event_scheduler_func.test ##########################
-# #
-# Variable Name: event_scheduler #
-# Scope: GLOBAL #
-# Access Type: Dynamic #
-# Data Type: Boolean #
-# Default Value: OFF #
-# Valid Values: ON, OFF & DISABLED #
-# #
-# #
-# Creation Date: 2008-03-17 #
-# Author: Salman Rawala #
-# #
-# Description: Test Cases of Dynamic System Variable "event_scheduler" #
-# that checks functionality of this variable #
-# #
-# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
-# server-system-variables.html#option_mysqld_event_scheduler #
-# #
-################################################################################
-
--- source include/not_embedded.inc
-
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-#########################
-# Creating new table #
-#########################
-
---echo ## Creating new table ##
-CREATE TABLE t1
-(
-id INT NOT NULL auto_increment,
-PRIMARY KEY (id),
-name VARCHAR(30)
-);
-
---echo '#--------------------FN_DYNVARS_018_01-------------------------#'
-####################################################################
-# Setting initial value of event_scheduler to ON and verifying
-# its behavior
-####################################################################
-
---echo ## Setting initial value of variable to ON ##
-SET @@global.event_scheduler = ON;
-SELECT @@event_scheduler;
-
---echo ## Creating new event ##
-CREATE EVENT test_event_1
-ON SCHEDULE EVERY 3 SECOND
-DO
- INSERT into t1(name) values('Record_1');
-
---sleep 4
-
-SELECT * from t1;
-
-DROP EVENT test_event_1;
-
---sleep 1
-DELETE from t1;
-select * from t1;
-
-
---echo '#--------------------FN_DYNVARS_018_02-------------------------#'
-####################################################################
-# Setting initial value of event_scheduler to OFF and verifying
-# its behavior
-####################################################################
-
---echo ## Setting value of variable to OFF ##
-SET @@global.event_scheduler = OFF;
-SELECT @@event_scheduler;
-
---echo ## Creating new event ##
-CREATE EVENT test_event_1
-ON SCHEDULE EVERY 3 SECOND
-DO
- INSERT into t1(name) values('Record_2');
-
---sleep 4
-
---echo ## Table should be empty ##
-SELECT * from t1;
-
-DROP EVENT test_event_1;
---echo ## Dropping table ##
-DROP table t1;
-
diff --git a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test
index d077a3acf50..b577ae5fcc4 100644
--- a/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test
+++ b/mysql-test/suite/sys_vars/t/innodb_max_dirty_pages_pct_func.test
@@ -1,4 +1,4 @@
-################# mysql-test\t\innodb_max_dirty_pages_pct_func.test ##########
+###############################################################################
# #
# Variable Name: innodb_max_dirty_pages_pct #
# Scope: GLOBAL #
diff --git a/mysql-test/suite/sys_vars/t/interactive_timeout_func.test b/mysql-test/suite/sys_vars/t/interactive_timeout_func.test
index e3a210bf508..0df069ad73e 100644
--- a/mysql-test/suite/sys_vars/t/interactive_timeout_func.test
+++ b/mysql-test/suite/sys_vars/t/interactive_timeout_func.test
@@ -1,23 +1,26 @@
-############## mysql-test\t\interactive_timeout_func.test #####################
-# #
-# Variable Name: interactive_timeout #
-# Scope: GLOBAL | SESSION #
-# Access Type: Dynamic #
-# Data Type: numeric #
-# Default Value:28800 #
-# Minvalue: 1 #
-# #
-# #
-# Creation Date: 2008-03-07 #
-# Author: Salman Rawala #
-# #
-# Description: Test Cases of Dynamic System Variable interactive_timeout #
-# that checks the functionality of this variable #
-# #
-# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
-# server-system-variables.html #
-# #
-###############################################################################
+################################################################################
+# #
+# Variable Name: interactive_timeout #
+# Scope: GLOBAL | SESSION #
+# Access Type: Dynamic #
+# Data Type: numeric #
+# Default Value:28800 #
+# Minvalue: 1 #
+# #
+# #
+# Creation Date: 2008-03-07 #
+# Author: Salman Rawala #
+# #
+# Description: Test Cases of Dynamic System Variable interactive_timeout #
+# that checks the functionality of this variable #
+# Modified: HHunger 2009-02-26 Inserted clean up, beautifications. #
+# It is not yet possible to set CLIENT_INTERACIVE #
+# When connecting, so the test has not the #
+# desired effect. See 'wait_timeout_func'. #
+# Reference: #
+# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html #
+# #
+################################################################################
--disable_warnings
@@ -42,29 +45,44 @@ name VARCHAR(30)
# Setting initial value of interactive_timeout to 1 and verifying its
# behavior
#######################################################################
+let $start_value= `SELECT @@global.interactive_timeout`;
--echo ## Setting initial value of variable to 1 ##
SET @@global.interactive_timeout = 1;
---echo ## Creating new interactive connection test_con1 ##
-connect (test_con1, localhost, root,);
+--echo ## Creating new connection test_con1 ##
+# Not yet possible to set CLEAN_INTERACTIVE flag
+connect (test_con1, localhost, root,,,,,);
connection test_con1;
--echo ## Inserting record in table ##
INSERT into t1(name) values('Record_1');
---echo ## Setting session value of interactive_timeout ##
+--echo ## Setting session value of interactive_timeout ##
SET @@session.interactive_timeout = 1;
---echo ## Verifying values of variable ##
+--echo ## Verifying values of variable ##
SELECT @@session.interactive_timeout;
SELECT @@global.interactive_timeout;
---echo ## Using sleep to check timeout ##
-sleep 5;
-SELECT * from t1;
+--echo connection default;
+connection default;
+--echo ## Using sleep to check timeout ##
+--echo sleep 2;
+sleep 2;
---echo 'Bug#35377: Error should appear here because interactive_timeout value';
---echo 'is 1 and connection remains idle for 5 secs';
+--echo connection test_con1;
+connection test_con1;
+SELECT * from t1;
INSERT into t1(name) values('Record_2');
+
+--echo connection default;
+connection default;
+
+--echo disconnect test_con1;
+disconnect test_con1;
+DROP TABLE t1;
+
+eval SET @@global.interactive_timeout= $start_value;
+
diff --git a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test
index 83b0c446b28..e5ced59d175 100644
--- a/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test
+++ b/mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test
@@ -1,4 +1,4 @@
-############# mysql-test\t\query_cache_wlock_invalidate_func.test ####################
+######################################################################################
# #
# Variable Name: query_cache_wlock_invalidate #
# Scope: GLOBAL & SESSION #
@@ -10,6 +10,7 @@
# #
# Creation Date: 2008-02-21 #
# Author: Sharique Abdullah #
+# Modified: HHunger 2009-02-27 Replaced sleeps, beautifications #
# #
# Description: Test Cases of Dynamic System Variable "query_cache_wlock_invalidate" #
# that checks behavior of this variable in the following ways #
@@ -18,8 +19,8 @@
# * Scope & Access method #
# * Cache behaviors #
# #
-# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
-# server-system-variables.html#option_mysqld_query_cache_wlock_invalidate #
+# Reference: #
+# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html #
# #
######################################################################################
@@ -29,6 +30,8 @@
# Setup
#
+--source include/not_embedded.inc
+
# disabled due to differences in the result
--disable_ps_protocol
#
@@ -135,8 +138,9 @@ send SELECT * FROM t1;
--echo ** Connection con0 **
connection con0;
---echo Sleeping 2 Seconds before unlock
---sleep 2
+--echo wait until table is locked
+let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE state= 'Locked';
+--source include/wait_condition.inc
UNLOCK TABLES;
--echo ** Connection con1 **
@@ -195,20 +199,17 @@ SELECT * FROM t1;
--echo ** Connection con0 **
connection con0;
-
LOCK TABLE t1 WRITE;
--echo ** Connection con1 **
connection con1;
-
--echo ** Should not be blocked **
SELECT * FROM t1;
+SELECT * FROM t1;
+SELECT * FROM t1;
--echo ** Connection con0 **
connection con0;
-
---echo Sleeping 2 Seconds before unlock
---sleep 2
UNLOCK TABLES;
--echo ** Connection con1 **
diff --git a/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test b/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test
index f17cc1289b1..f2c66eb3a0a 100644
--- a/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test
+++ b/mysql-test/suite/sys_vars/t/rpl_init_slave_func.test
@@ -1,4 +1,4 @@
-###################### mysql-test\t\init_slave_func.test #####################
+###############################################################################
# #
# Variable Name: init_slave #
# Scope: GLOBAL #
diff --git a/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test b/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test
index c00db582deb..efcec4561bd 100644
--- a/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test
+++ b/mysql-test/suite/sys_vars/t/rpl_max_binlog_size_func.test
@@ -7,9 +7,8 @@ source include/have_log_bin.inc;
DROP TABLE IF EXISTS t1;
--enable_warnings
-
#==============================================================
---echo '--- check if log file is rotated after 4096 bytes ----'
+--echo '--- check if log file is rotated after 4096 bytes ----'
#==============================================================
SET @saved_max_binlog_size= @@global.max_binlog_size;
@@ -24,8 +23,7 @@ INSERT INTO t1 VALUES ('mysql');
dec $a;
}
--enable_query_log
-
---sleep 2
+SELECT COUNT(*) FROM t1;
# if log file is not created then this will fail
let $MYSQLD_DATADIR=`select @@datadir`;
diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_func.test b/mysql-test/suite/sys_vars/t/slow_query_log_func.test
index 9bcbeb14fd7..d2653f89de4 100644
--- a/mysql-test/suite/sys_vars/t/slow_query_log_func.test
+++ b/mysql-test/suite/sys_vars/t/slow_query_log_func.test
@@ -1,4 +1,3 @@
-
# save
SET @global_slow_query_log = @@global.slow_query_log;
SET @global_log_output = @@global.log_output;
@@ -16,6 +15,7 @@ SET @@global.log_output = 'TABLE';
SET @@global.slow_query_log = OFF;
TRUNCATE mysql.slow_log;
+# The sleep is the slow query
SELECT sleep(2);
SELECT count(*) FROM mysql.slow_log;
@@ -26,9 +26,10 @@ SELECT count(*) FROM mysql.slow_log;
SET @@global.slow_query_log = ON;
TRUNCATE mysql.slow_log;
+# The sleep is the slow query
SELECT sleep(2);
-SELECT count(*) FROM mysql.slow_log;
+SELECT count(*) > 0 FROM mysql.slow_log;
#restore
SET @@global.log_output = @global_log_output;
@@ -37,3 +38,4 @@ SET @global.slow_query_log = @global_slow_query_log;
###############################################################################
# End of the functionality test for slow_query_log #
###############################################################################
+
diff --git a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test
index 6ff684af6cd..2ef6e34b0b3 100644
--- a/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test
+++ b/mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test
@@ -1,23 +1,23 @@
-############# mysql-test\t\sql_low_priority_updates_func.test #################
-# #
-# Variable Name: sql_low_priority_updates #
-# Scope: GLOBAL & SESSION #
-# Access Type: Dynamic #
-# Data Type: BOOLEAN #
-# Default Value: 1 TRUE #
-# Values: 1 TRUE, 0 FALSE #
-# #
-# #
-# Creation Date: 2008-02-25 #
-# Author: Sharique Abdullah #
-# #
-# Description: Test Cases of Dynamic System Variable sql_low_priority_updates#
-# that checks behavior of this variable in the following ways #
-# * Functionality based on different values #
-# #
-# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html #
-# #
-###############################################################################
+################################################################################
+# #
+# Variable Name: sql_low_priority_updates #
+# Scope: GLOBAL & SESSION #
+# Access Type: Dynamic #
+# Data Type: BOOLEAN #
+# Default Value: 1 TRUE #
+# Values: 1 TRUE, 0 FALSE #
+# #
+# #
+# Creation Date: 2008-02-25 #
+# Author: Sharique Abdullah #
+# #
+# Description: Test Cases of Dynamic System Variable sql_low_priority_updates #
+# that checks behavior of this variable in the following ways #
+# * Functionality based on different values #
+# #
+# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html #
+# #
+################################################################################
--source include/not_embedded.inc
@@ -85,6 +85,9 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
+let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Locked' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
+--source include/wait_condition.inc
+
--echo ** Asynchronous Execution **
delimiter |;
@@ -98,9 +101,8 @@ delimiter ;|
--echo ** Connection default **
connection default;
---echo Sleeping for 1 secs
---sleep 1
-
+let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Locked';
+--source include/wait_condition.inc
UNLOCK TABLES;
--echo ** Connection con0 **
@@ -153,6 +155,9 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
+let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Locked' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
+--source include/wait_condition.inc
+
--echo ** Asynchronous Execution **
delimiter |;
@@ -166,9 +171,8 @@ delimiter ;|
--echo ** Connection default **
connection default;
---echo Sleeping for 1 secs
---sleep 1
-
+let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Locked';
+--source include/wait_condition.inc
UNLOCK TABLES;
--echo ** Connection con0 **
diff --git a/mysql-test/suite/sys_vars/t/timestamp_func.test b/mysql-test/suite/sys_vars/t/timestamp_func.test
index e119f1b6253..e93614e89fb 100644
--- a/mysql-test/suite/sys_vars/t/timestamp_func.test
+++ b/mysql-test/suite/sys_vars/t/timestamp_func.test
@@ -1,4 +1,4 @@
-############# mysql-test\t\timestamp_func.test #############################
+############################################################################
# #
# Variable Name: timestamp #
# Scope: GLOBAL #
diff --git a/mysql-test/suite/sys_vars/t/wait_timeout_func.test b/mysql-test/suite/sys_vars/t/wait_timeout_func.test
index 6b7c8d016d2..e33c39016cc 100644
--- a/mysql-test/suite/sys_vars/t/wait_timeout_func.test
+++ b/mysql-test/suite/sys_vars/t/wait_timeout_func.test
@@ -1,4 +1,4 @@
-############## mysql-test\t\wait_timeout_func.test ############################
+###############################################################################
# #
# Variable Name: wait_timeout #
# Scope: GLOBAL | SESSION #
diff --git a/mysql-test/t/alter_table-big.test b/mysql-test/t/alter_table-big.test
index 5d2c0ba0bb6..1dcc1f1c9bd 100644
--- a/mysql-test/t/alter_table-big.test
+++ b/mysql-test/t/alter_table-big.test
@@ -9,10 +9,9 @@
# in proper order.
--source include/have_binlog_format_mixed_or_statement.inc
-
#
-# Test for bug #25044 "ALTER TABLE ... ENABLE KEYS acquires global
-# 'opening tables' lock".
+# Test for Bug#25044 ALTER TABLE ... ENABLE KEYS acquires global
+# 'opening tables' lock
#
# ALTER TABLE ... ENABLE KEYS should not acquire LOCK_open mutex for
# the whole its duration as it prevents other queries from execution.
@@ -56,6 +55,7 @@ show binlog events in 'master-bin.000001' from 106;
# Clean up
drop tables t1, t2;
+disconnect addconroot;
--echo End of 5.0 tests
@@ -76,6 +76,7 @@ create table t1 (i int);
reset master;
set session debug="+d,sleep_alter_before_main_binlog";
--send alter table t1 change i c char(10) default 'Test1';
+connect (addconroot, localhost, root,,);
connection addconroot;
--sleep 2
insert into t1 values ();
@@ -105,6 +106,7 @@ connection addconroot;
rename table t1 to t3;
connection default;
--reap
+disconnect addconroot;
drop table t3;
set session debug="-d,sleep_alter_before_main_binlog";
@@ -114,3 +116,4 @@ show binlog events in 'master-bin.000001' from 106;
--echo End of 5.1 tests
+
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index 61e80ec682e..c761f48cbcb 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -1,7 +1,10 @@
# The server need to be started in $MYSQLTEST_VARDIR since it
# uses ../../std_data/
--- source include/uses_vardir.inc
+--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
@@ -57,6 +60,9 @@ 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;
@@ -68,6 +74,7 @@ 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
@@ -87,4 +94,11 @@ DROP TABLE `t+1`;
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/check.test b/mysql-test/t/check.test
index 363f9d419d6..ff23b352b5a 100644
--- a/mysql-test/t/check.test
+++ b/mysql-test/t/check.test
@@ -1,3 +1,6 @@
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
@@ -21,16 +24,18 @@ connection con2;
insert into t1 values (200000);
connection con1;
reap;
+connection default;
+disconnect con1;
+disconnect con2;
drop table t1;
+
# End of 4.1 tests
#
-# Bug #9897 Views: 'Check Table' crashes MySQL, with a view and a table
-# in the statement
+# Bug#9897 Views: 'Check Table' crashes MySQL, with a view and a table
+# in the statement
#
-
-connection default;
Create table t1(f1 int);
Create table t2(f1 int);
Create view v1 as Select * from t1;
@@ -38,11 +43,15 @@ Check Table v1,t2;
drop view v1;
drop table t1, t2;
+
#
-# BUG#26325 - TEMPORARY TABLE "corrupt" after first read, according to CHECK
-# TABLE
+# Bug#26325 TEMPORARY TABLE "corrupt" after first read, according to CHECK TABLE
#
CREATE TEMPORARY TABLE t1(a INT);
CHECK TABLE t1;
REPAIR TABLE t1;
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/compress.test b/mysql-test/t/compress.test
index cd40aef002c..0a20daef8de 100644
--- a/mysql-test/t/compress.test
+++ b/mysql-test/t/compress.test
@@ -6,6 +6,10 @@
-- source include/have_compress.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
connect (comp_con,localhost,root,,,,,COMPRESS);
# Check compression turned on
@@ -17,3 +21,10 @@ select * from information_schema.session_status where variable_name= 'COMPRESSIO
# Check compression turned on
SHOW STATUS LIKE 'Compression';
+
+connection default;
+disconnect comp_con;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
index 0893bf9ad18..f609240646a 100644
--- a/mysql-test/t/connect.test
+++ b/mysql-test/t/connect.test
@@ -9,11 +9,14 @@
# of the log tables (which are CSV-based). By connect mysql; show tables;
--source include/have_csv.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
-
#connect (con1,localhost,root,,"");
#show tables;
connect (con1,localhost,root,,mysql);
@@ -22,12 +25,16 @@ connect (con2,localhost,root,,test);
show tables;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,root,z,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,root,z,);
+connection default;
+disconnect con1;
+disconnect con2;
+
grant ALL on *.* to test@localhost identified by "gambling";
grant ALL on *.* to test@127.0.0.1 identified by "gambling";
@@ -39,20 +46,23 @@ show tables;
connect (con4,localhost,test,gambling,test);
show tables;
+connection default;
+disconnect con3;
+disconnect con4;
+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,,"");
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,zorro,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,zorro,);
-
# check if old password version also works
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
@@ -61,55 +71,57 @@ connect (con10,localhost,test,gambling2,);
connect (con5,localhost,test,gambling2,mysql);
connection con5;
set password="";
---error 1372
+--error ER_PASSWD_LENGTH
set password='gambling3';
set password=old_password('gambling3');
show tables;
connect (con6,localhost,test,gambling3,test);
show tables;
+connection default;
+disconnect con10;
+disconnect con5;
+disconnect con6;
+
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,,);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,zorro,test2);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,zorro,);
# remove user 'test' so that other tests which may use 'test'
# do not depend on this test.
-
delete from mysql.user where user=_binary"test";
flush privileges;
#
-# Bug#12517: Clear user variables and replication events before
-# closing temp tables in thread cleanup.
+# Bug#12517 Clear user variables and replication events before
+# closing temp tables in thread cleanup.
connect (con7,localhost,root,,test);
connection con7;
+let $connection_id= `select connection_id()`;
create table t1 (id integer not null auto_increment primary key);
create temporary table t2(id integer not null auto_increment primary key);
set @id := 1;
delete from t1 where id like @id;
-disconnect con7;
---sleep 5
connection default;
+disconnect con7;
+# Wait till the session con7 is disconnected
+let $wait_condition =
+ SELECT COUNT(*) = 0
+ FROM information_schema.processlist
+ WHERE id = '$connection_id';
+--source include/wait_condition.inc
drop table t1;
---disconnect con1
---disconnect con2
---disconnect con3
---disconnect con4
---disconnect con5
---disconnect con6
---disconnect con10
-
--echo # ------------------------------------------------------------------
--echo # -- End of 4.1 tests
--echo # ------------------------------------------------------------------
@@ -147,7 +159,7 @@ let $wait_condition =
--echo # -- Check that we allow exactly three user connections, no matter how
--echo # -- many threads are running.
---echo
+--echo
--echo # -- Connecting (1)...
let $con_name = con_1;
let $con_user_name = mysqltest_u1;
@@ -237,7 +249,7 @@ DROP USER mysqltest_u1@localhost;
###########################################################################
---echo # -- Bug#35074: max_used_connections is not correct.
+--echo # -- Bug#35074: max_used_connections is not correct.
--echo
FLUSH STATUS;
@@ -250,11 +262,7 @@ SHOW STATUS LIKE 'max_used_connections';
SET GLOBAL event_scheduler = ON;
--echo # -- Waiting for Event Scheduler to start...
-let $wait_condition =
- SELECT COUNT(*) = 1
- FROM information_schema.processlist
- WHERE user = 'event_scheduler';
---source include/wait_condition.inc
+--source include/running_event_scheduler.inc
# NOTE: We should use a new connection here instead of reconnect in order to
# avoid races (we can not for sure when the connection being disconnected is
@@ -278,11 +286,7 @@ SHOW STATUS LIKE 'max_used_connections';
SET GLOBAL event_scheduler = OFF;
--echo # -- Waiting for Event Scheduler to stop...
-let $wait_condition =
- SELECT COUNT(*) = 0
- FROM information_schema.processlist
- WHERE user = 'event_scheduler';
---source include/wait_condition.inc
+--source include/no_running_events.inc
--echo
--echo # -- End of Bug#35074.
@@ -291,3 +295,7 @@ let $wait_condition =
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/consistent_snapshot.test b/mysql-test/t/consistent_snapshot.test
index 8da8e9ce660..82edf2e22b2 100644
--- a/mysql-test/t/consistent_snapshot.test
+++ b/mysql-test/t/consistent_snapshot.test
@@ -1,43 +1,61 @@
--- source include/have_innodb.inc
+--source include/have_innodb.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
--disable_warnings
-drop table if exists t1;
+DROP TABLE IF EXISTS t1;
--enable_warnings
+--echo # Establish connection con1 (user=root)
connect (con1,localhost,root,,);
+--echo # Establish connection con2 (user=root)
connect (con2,localhost,root,,);
### Test 1:
### - While a consistent snapshot transaction is executed,
### no external inserts should be visible to the transaction.
+--echo # Switch to connection con1
connection con1;
-create table t1 (a int) engine=innodb;
-start transaction with consistent snapshot;
+CREATE TABLE t1 (a INT) ENGINE=innodb;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+--echo # Switch to connection con2
connection con2;
-insert into t1 values(1);
+INSERT INTO t1 VALUES(1);
+--echo # Switch to connection con1
connection con1;
-select * from t1; # if consistent snapshot was set as expected, we
+SELECT * FROM t1; # if consistent snapshot was set as expected, we
# should see nothing.
-commit;
+COMMIT;
### Test 2:
### - For any non-consistent snapshot transaction, external
### committed inserts should be visible to the transaction.
-delete from t1;
-start transaction; # Now we omit WITH CONSISTENT SNAPSHOT
+DELETE FROM t1;
+START TRANSACTION; # Now we omit WITH CONSISTENT SNAPSHOT
+--echo # Switch to connection con2
connection con2;
-insert into t1 values(1);
+INSERT INTO t1 VALUES(1);
+--echo # Switch to connection con1
connection con1;
-select * from t1; # if consistent snapshot was not set, as expected, we
+SELECT * FROM t1; # if consistent snapshot was not set, as expected, we
# should see 1.
-commit;
+COMMIT;
-drop table t1;
+--echo # Switch to connection default + close connections con1 and con2
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
# End of 4.1 tests
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test
index f817b2c635d..2f7cf7e5260 100644
--- a/mysql-test/t/count_distinct3.test
+++ b/mysql-test/t/count_distinct3.test
@@ -1,4 +1,4 @@
-#
+# Bug #958 a big table without indices and select with group by doesnt work
# this is a test for error 1032 in count(distinct) + group by, introduced in
# mysql-4.1
#
@@ -21,27 +21,16 @@ while ($1)
INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev);
dec $1;
}
-set @@read_buffer_size=2*1024*1024;
-CREATE TABLE t2 SELECT * FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
-INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
-DROP TABLE t2;
+
+# We increase the size of t1 here.
+SET @orig_myisam_sort_buffer_size = @@session.myisam_sort_buffer_size;
+SET session myisam_sort_buffer_size=20000000;
+INSERT INTO t1
+SELECT A.id, A.grp, A.id_rev
+FROM
+ t1 A,
+ (SELECT * FROM t1 B LIMIT 100) B,
+ (SELECT * FROM t1 Z LIMIT 42) Z;
--enable_query_log
SELECT COUNT(*) FROM t1;
@@ -49,12 +38,12 @@ SELECT COUNT(*) FROM t1;
# As t1 contains random numbers, results are different from test to test.
# That's okay, because we test only that select doesn't yield an
# error. Note, that --disable_result_log doesn't suppress error output.
-
--disable_result_log
SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
--enable_result_log
-DROP TABLE t1;
-set @@read_buffer_size=default;
+--echo # Begin cleanup
+SET session myisam_sort_buffer_size = @orig_myisam_sort_buffer_size;
+DROP TABLE t1;
# End of 4.1 tests
diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test
index cfef8dfe81a..6b6abbcfbcc 100644
--- a/mysql-test/t/ctype_collate.test
+++ b/mysql-test/t/ctype_collate.test
@@ -229,3 +229,17 @@ insert into t1 set a=0x6c;
insert into t1 set a=0x4c98;
check table t1 extended;
drop table t1;
+
+#
+# Bug#41627 Illegal mix of collations in LEAST / GREATEST / CASE
+#
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
+create table t1
+select least(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci) as f1;
+show create table t1;
+drop table t1;
+
+select case _latin1'a' when _latin2'b' then 1 when _latin5'c' collate
+latin5_turkish_ci then 2 else 3 end;
+
+select concat(_latin1'a',_latin2'b',_latin5'c' collate latin5_turkish_ci);
diff --git a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test
index e3bed098126..2d94a899aad 100644
--- a/mysql-test/t/ddl_i18n_koi8r.test
+++ b/mysql-test/t/ddl_i18n_koi8r.test
@@ -143,10 +143,12 @@ set names koi8r|
# - Dump mysqltest1;
+--let $views_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
+
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1
# - Clean mysqltest1;
@@ -161,7 +163,9 @@ DROP DATABASE mysqltest1|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.views.mysqltest1.sql
+--exec $MYSQL test < $views_dump1
+
+--remove_file $views_dump1
#
# Third-round checks.
@@ -398,6 +402,9 @@ set names koi8r|
# - Dump mysqltest1, mysqltest2;
+--let $sp_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
+--let $sp_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
+
--echo
--echo ---> Dump of mysqltest1
@@ -406,7 +413,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1
--echo
--echo ---> Dump of mysqltest2
@@ -416,7 +423,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2
# - Clean mysqltest1, mysqltest2;
@@ -432,10 +439,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest1.sql
+--exec $MYSQL test < $sp_dump1
--echo ---> Restoring mysqltest2...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.sp.mysqltest2.sql
+--exec $MYSQL test < $sp_dump2
+
+--remove_file $sp_dump1
+--remove_file $sp_dump2
#
# Third-round checks.
@@ -669,6 +679,9 @@ use mysqltest1|
# - Dump mysqltest1, mysqltest2;
+--let $triggers_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
+--let $triggers_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
+
--echo
--echo ---> Dump of mysqltest1
@@ -677,7 +690,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1
--echo
--echo ---> Dump of mysqltest2
@@ -687,7 +700,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2
# - Clean mysqltest1, mysqltest2;
@@ -703,10 +716,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest1.sql
+--exec $MYSQL test < $triggers_dump1
--echo ---> Restoring mysqltest2...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.triggers.mysqltest2.sql
+--exec $MYSQL test < $triggers_dump2
+
+--remove_file $triggers_dump1
+--remove_file $triggers_dump2
#
# Third-round checks.
@@ -924,6 +940,9 @@ set names koi8r|
# - Dump mysqltest1, mysqltest2;
+--let $events_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
+--let $events_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
+
--echo
--echo ---> Dump of mysqltest1
@@ -932,7 +951,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1
--echo
--echo ---> Dump of mysqltest2
@@ -942,7 +961,7 @@ set names koi8r|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_koi8r.events.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2
# - Clean mysqltest1, mysqltest2;
@@ -958,10 +977,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest1.sql
+--exec $MYSQL test < $events_dump1
--echo ---> Restoring mysqltest2...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_koi8r.events.mysqltest2.sql
+--exec $MYSQL test < $events_dump2
+
+--remove_file $events_dump1
+--remove_file $events_dump2
#
# Third-round checks.
diff --git a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test
index d76debcba5b..1d5415d9373 100644
--- a/mysql-test/t/ddl_i18n_utf8.test
+++ b/mysql-test/t/ddl_i18n_utf8.test
@@ -143,10 +143,12 @@ set names utf8|
# - Dump mysqltest1;
+--let $views_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
+
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $views_dump1
# - Clean mysqltest1;
@@ -161,7 +163,9 @@ DROP DATABASE mysqltest1|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8views.mysqltest1.sql
+--exec $MYSQL test < $views_dump1
+
+--remove_file $views_dump1
#
# Third-round checks.
@@ -398,6 +402,9 @@ set names utf8|
# - Dump mysqltest1, mysqltest2;
+--let $sp_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
+--let $sp_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
+
--echo
--echo ---> Dump of mysqltest1
@@ -406,7 +413,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest1 > $sp_dump1
--echo
--echo ---> Dump of mysqltest2
@@ -416,7 +423,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --routines --databases mysqltest2 > $sp_dump2
# - Clean mysqltest1, mysqltest2;
@@ -432,10 +439,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest1.sql
+--exec $MYSQL test < $sp_dump1
--echo ---> Restoring mysqltest2...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8sp.mysqltest2.sql
+--exec $MYSQL test < $sp_dump2
+
+--remove_file $sp_dump1
+--remove_file $sp_dump2
#
# Third-round checks.
@@ -669,6 +679,9 @@ use mysqltest1|
# - Dump mysqltest1, mysqltest2;
+--let $triggers_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
+--let $triggers_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
+
--echo
--echo ---> Dump of mysqltest1
@@ -677,7 +690,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest1 > $triggers_dump1
--echo
--echo ---> Dump of mysqltest2
@@ -687,7 +700,7 @@ use mysqltest1|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --triggers --databases mysqltest2 > $triggers_dump2
# - Clean mysqltest1, mysqltest2;
@@ -703,10 +716,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest1.sql
+--exec $MYSQL test < $triggers_dump1
--echo ---> Restoring mysqltest2...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8triggers.mysqltest2.sql
+--exec $MYSQL test < $triggers_dump2
+
+--remove_file $triggers_dump1
+--remove_file $triggers_dump2
#
# Third-round checks.
@@ -924,6 +940,9 @@ set names utf8|
# - Dump mysqltest1, mysqltest2;
+--let $events_dump1 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
+--let $events_dump2 = $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
+
--echo
--echo ---> Dump of mysqltest1
@@ -932,7 +951,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest1 > $events_dump1
--echo
--echo ---> Dump of mysqltest2
@@ -942,7 +961,7 @@ set names utf8|
--echo
--echo ---> Dumping mysqltest2 to ddl_i18n_utf8events.mysqltest2.sql
---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --compact --events --databases mysqltest2 > $events_dump2
# - Clean mysqltest1, mysqltest2;
@@ -958,10 +977,13 @@ DROP DATABASE mysqltest2|
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest1.sql
+--exec $MYSQL test < $events_dump1
--echo ---> Restoring mysqltest2...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ddl_i18n_utf8events.mysqltest2.sql
+--exec $MYSQL test < $events_dump2
+
+--remove_file $events_dump1
+--remove_file $events_dump2
#
# Third-round checks.
diff --git a/mysql-test/t/dirty_close.test b/mysql-test/t/dirty_close.test
index f1c2c88ae83..1bbd53e8c06 100644
--- a/mysql-test/t/dirty_close.test
+++ b/mysql-test/t/dirty_close.test
@@ -1,3 +1,7 @@
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
@@ -5,12 +9,19 @@ dirty_close con1;
connection con2;
--disable_warnings
-drop table if exists t1;
+DROP TABLE IF EXISTS t1;
--enable_warnings
-create table t1 (n int);
-insert into t1 values (1),(2),(3);
-select * from t1;
-drop table t1;
+CREATE TABLE t1 (n INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+connection default;
+disconnect con2;
# End of 4.1 tests
+
+# 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 f61090102ff..760c29bbae6 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -10,5 +10,8 @@
#
##############################################################################
kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
-query_cache_28249 : Bug#41098 Query Cache returns wrong result with concurrent insert
innodb_bug39438 : BUG#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently"
+query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
+
+#concurrent_innodb_safelog: disabled for embedded server due to bug#43733 Select on processlist let the embedded server crash (concurrent_innodb_safelog).
+#concurrent_innodb_unsafelog: disabled for embedded server due to bug#43733.
diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test
index 4f0777922b8..91345886e93 100644
--- a/mysql-test/t/drop.test
+++ b/mysql-test/t/drop.test
@@ -150,17 +150,30 @@ DROP DATABASE IF EXISTS mysql_test;
CREATE DATABASE mysql_test;
let $MYSQLD_DATADIR= `select @@datadir`;
---copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/bug29958.proc.frm
---copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYD
---copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYI
+
+--let $proc_frm = $MYSQLD_DATADIR/mysql/proc.frm
+--let $proc_MYD = $MYSQLD_DATADIR/mysql/proc.MYD
+--let $proc_MYI = $MYSQLD_DATADIR/mysql/proc.MYI
+
+--let $copy_of_proc_frm = $MYSQLTEST_VARDIR/tmp/bug29958.copy.frm
+--let $copy_of_proc_MYD = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYD
+--let $copy_of_proc_MYI = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYI
+
+--copy_file $proc_frm $copy_of_proc_frm
+--copy_file $proc_MYD $copy_of_proc_MYD
+--copy_file $proc_MYI $copy_of_proc_MYI
DROP TABLE mysql.proc;
DROP DATABASE mysql_test;
---copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.frm $MYSQLD_DATADIR/mysql/proc.frm
---copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD
---copy_file $MYSQLTEST_VARDIR/tmp/bug29958.proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI
+--copy_file $copy_of_proc_frm $proc_frm
+--copy_file $copy_of_proc_MYD $proc_MYD
+--copy_file $copy_of_proc_MYI $proc_MYI
+
+--remove_file $copy_of_proc_frm
+--remove_file $copy_of_proc_MYD
+--remove_file $copy_of_proc_MYI
--echo
--echo # --
diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test
index 69e2f681aa2..81397b333f9 100644
--- a/mysql-test/t/events_bugs.test
+++ b/mysql-test/t/events_bugs.test
@@ -1209,6 +1209,18 @@ select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mo
select name from mysql.event where name = 'p' and sql_mode = @full_mode;
drop event e1;
+#
+# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id
+#
+
+SET @old_server_id = @@GLOBAL.server_id;
+SET GLOBAL server_id = (1 << 32) - 1;
+SELECT @@GLOBAL.server_id;
+CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS;
+DROP EVENT ev1;
+SET GLOBAL server_id = @old_server_id;
+
###########################################################################
#
# End of tests
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index 3a71fde4421..755e126baf2 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -123,6 +123,21 @@ execute s1;
DROP TABLE t1,t2;
+
+#
+# Bug #43354: Use key hint can crash server in explain extended query
+#
+
+CREATE TABLE t1 (a INT PRIMARY KEY);
+
+--error ER_KEY_DOES_NOT_EXITS
+EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a);
+
+DROP TABLE t1;
+
+
+# End of 5.0 tests.
+
--echo #
--echo # Bug#37870: Usage of uninitialized value caused failed assertion.
--echo #
@@ -141,4 +156,4 @@ flush tables;
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
drop tables t1, t2;
-# End of 5.0 tests.
+--echo End of 5.1 tests.
diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test
index 0c1d2b82df6..74892def63f 100644
--- a/mysql-test/t/flush_block_commit.test
+++ b/mysql-test/t/flush_block_commit.test
@@ -4,74 +4,106 @@
# This is intended to mimick how mysqldump and innobackup work.
# And it requires InnoDB
--- source include/have_innodb.inc
+--source include/have_innodb.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--echo # Establish connection con1 (user=root)
connect (con1,localhost,root,,);
+--echo # Establish connection con2 (user=root)
connect (con2,localhost,root,,);
+--echo # Establish connection con3 (user=root)
connect (con3,localhost,root,,);
+--echo # Switch to connection con1
connection con1;
--disable_warnings
-drop table if exists t1;
+DROP TABLE IF EXISTS t1;
--enable_warnings
-create table t1 (a int) engine=innodb;
+CREATE TABLE t1 (a INT) ENGINE=innodb;
# blocks COMMIT ?
-begin;
-insert into t1 values(1);
+BEGIN;
+INSERT INTO t1 VALUES(1);
+--echo # Switch to connection con2
connection con2;
-flush tables with read lock;
-select * from t1;
+FLUSH TABLES WITH READ LOCK;
+SELECT * FROM t1;
+--echo # Switch to connection con1
connection con1;
-send commit; # blocked by con2
+send COMMIT; # blocked by con2
sleep 1;
+--echo # Switch to connection con2
connection con2;
-select * from t1; # verify con1 was blocked and data did not move
-unlock tables;
+SELECT * FROM t1; # verify con1 was blocked and data did not move
+UNLOCK TABLES;
+--echo # Switch to connection con1
connection con1;
reap;
# No deadlock ?
+--echo # Switch to connection con1
connection con1;
-begin;
-select * from t1 for update;
+BEGIN;
+SELECT * FROM t1 FOR UPDATE;
+--echo # Switch to connection con2
connection con2;
-begin;
-send select * from t1 for update; # blocked by con1
+BEGIN;
+send SELECT * FROM t1 FOR UPDATE; # blocked by con1
sleep 1;
+--echo # Switch to connection con3
connection con3;
-send flush tables with read lock; # blocked by con2
+send FLUSH TABLES WITH READ LOCK; # blocked by con2
+--echo # Switch to connection con1
connection con1;
-commit; # should not be blocked by con3
+COMMIT; # should not be blocked by con3
+--echo # Switch to connection con2
connection con2;
reap;
+--echo # Switch to connection con3
connection con3;
reap;
-unlock tables;
+UNLOCK TABLES;
-# BUG#6732 FLUSH TABLES WITH READ LOCK + COMMIT hangs later FLUSH TABLES
-# WITH READ LOCK
+# Bug#6732 FLUSH TABLES WITH READ LOCK + COMMIT hangs later FLUSH TABLES
+# WITH READ LOCK
+--echo # Switch to connection con2
connection con2;
-commit; # unlock InnoDB row locks to allow insertions
+COMMIT; # unlock InnoDB row locks to allow insertions
+--echo # Switch to connection con1
connection con1;
-begin;
-insert into t1 values(10);
-flush tables with read lock;
-commit;
-unlock tables;
+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
-unlock tables;
+FLUSH TABLES WITH READ LOCK; # bug caused hang here
+UNLOCK TABLES;
+
+# Bug#7358 SHOW CREATE DATABASE fails if open transaction
+
+BEGIN;
+SELECT * FROM t1;
+SHOW CREATE DATABASE test;
-# BUG#7358 SHOW CREATE DATABASE fails if open transaction
+DROP TABLE t1;
-begin;
-select * from t1;
-show create database test;
-drop table t1;
+# 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
+
+# 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 4a0300acf78..aea38250218 100644
--- a/mysql-test/t/flush_block_commit_notembedded.test
+++ b/mysql-test/t/flush_block_commit_notembedded.test
@@ -3,32 +3,51 @@
# We verify that we did not introduce a deadlock.
# This is intended to mimick how mysqldump and innobackup work.
--- source include/have_log_bin.inc
+--source include/have_log_bin.inc
# And it requires InnoDB
--- source include/have_log_bin.inc
--- source include/have_innodb.inc
+--source include/have_log_bin.inc
+--source include/have_innodb.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
+--echo # Establish connection con1 (user=root)
connect (con1,localhost,root,,);
+--echo # Establish connection con2 (user=root)
connect (con2,localhost,root,,);
# FLUSH TABLES WITH READ LOCK should block writes to binlog too
+--echo # Switch to connection con1
connection con1;
-create table t1 (a int) engine=innodb;
-reset master;
-set autocommit=0;
-insert t1 values (1);
+CREATE TABLE t1 (a INT) ENGINE=innodb;
+RESET MASTER;
+SET AUTOCOMMIT=0;
+INSERT t1 VALUES (1);
+--echo # Switch to connection con2
connection con2;
-flush tables with read lock;
-show master status;
+FLUSH TABLES WITH READ LOCK;
+SHOW MASTER STATUS;
+--echo # Switch to connection con1
connection con1;
-send commit;
+send COMMIT;
+--echo # Switch to connection con2
connection con2;
sleep 1;
-show master status;
-unlock tables;
+SHOW MASTER STATUS;
+UNLOCK TABLES;
+--echo # Switch to connection con1
connection con1;
reap;
-drop table t1;
-set autocommit=1;
+DROP TABLE t1;
+SET AUTOCOMMIT=1;
+
+--echo # Switch to connection default and close connections con1 and con2
+connection default;
+disconnect con1;
+disconnect con2;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/flush_read_lock_kill.test b/mysql-test/t/flush_read_lock_kill.test
index c03f3be2534..aeb09d52460 100644
--- a/mysql-test/t/flush_read_lock_kill.test
+++ b/mysql-test/t/flush_read_lock_kill.test
@@ -8,24 +8,27 @@
# won't test anything interesting).
# This also won't work with the embedded server test
--- source include/not_embedded.inc
+--source include/not_embedded.inc
--- source include/have_debug.inc
+--source include/have_debug.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;
+SET @old_concurrent_insert= @@global.concurrent_insert;
+SET @@global.concurrent_insert= 0;
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
--disable_warnings
-drop table if exists t1;
+DROP TABLE IF EXISTS t1;
--enable_warnings
-create table t1 (kill_id int);
-insert into t1 values(connection_id());
+CREATE TABLE t1 (kill_id INT);
+INSERT INTO t1 VALUES(connection_id());
# Thanks to the parameter we passed to --debug, this FLUSH will
# block on a debug build running with our --debug=make_global... It
@@ -33,11 +36,11 @@ insert into t1 values(connection_id());
# --debug) it will succeed immediately
connection con1;
-send flush tables with read lock;
+send FLUSH TABLES WITH READ LOCK;
# kill con1
connection con2;
-select ((@id := kill_id) - kill_id) from t1;
+SELECT ((@id := kill_id) - kill_id) FROM t1;
# Wait for the debug sync point, test won't run on non-debug
# builds anyway.
@@ -47,7 +50,7 @@ let $wait_condition=
and info = "flush tables with read lock";
--source include/wait_condition.inc
-kill connection @id;
+KILL CONNECTION @id;
connection con1;
# On debug builds it will be error 1053 (killed); on non-debug, or
@@ -58,8 +61,14 @@ connection con1;
reap;
connection con2;
-drop table t1;
+DROP TABLE t1;
+
connection default;
+disconnect con2;
# Restore global concurrent_insert value
-set @@global.concurrent_insert= @old_concurrent_insert;
+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/fulltext.test b/mysql-test/t/fulltext.test
index 852369fd568..b565485bab9 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -454,3 +454,20 @@ INSERT INTO t1 VALUES('aaa15');
SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa16' IN BOOLEAN MODE) FROM t1;
SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) FROM t1;
DROP TABLE t1;
+
+#
+# BUG#36737 - having + full text operator crashes mysql
+#
+CREATE TABLE t1(a TEXT);
+--error ER_WRONG_ARGUMENTS
+SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE);
+DROP TABLE t1;
+
+#
+# BUG#42907 - Multi-term boolean fulltext query containing a single
+# quote fails in 5.1.x
+#
+CREATE TABLE t1(a VARCHAR(64), FULLTEXT(a));
+INSERT INTO t1 VALUES('awrd bwrd cwrd'),('awrd bwrd cwrd'),('awrd bwrd cwrd');
+SELECT * FROM t1 WHERE MATCH(a) AGAINST('+awrd bwrd* +cwrd*' IN BOOLEAN MODE);
+DROP TABLE t1;
diff --git a/mysql-test/t/func_des_encrypt.test b/mysql-test/t/func_des_encrypt.test
index b757a632adf..2c364a40090 100644
--- a/mysql-test/t/func_des_encrypt.test
+++ b/mysql-test/t/func_des_encrypt.test
@@ -9,3 +9,31 @@
select des_encrypt('hello');
# End of 4.1 tests
+
+--echo #
+--echo # Bug #11643: des_encrypt() causes server to die
+--echo #
+
+CREATE TABLE t1 (des VARBINARY(200) NOT NULL DEFAULT '') ENGINE=MyISAM;
+
+INSERT INTO t1 VALUES ('1234'), ('12345'), ('123456'), ('1234567');
+
+UPDATE t1 SET des=DES_ENCRYPT('1234');
+
+SELECT LENGTH(des) FROM t1;
+SELECT DES_DECRYPT(des) FROM t1;
+
+SELECT
+ LENGTH(DES_ENCRYPT('1234')),
+ LENGTH(DES_ENCRYPT('12345')),
+ LENGTH(DES_ENCRYPT('123456')),
+ LENGTH(DES_ENCRYPT('1234567'));
+SELECT
+ DES_DECRYPT(DES_ENCRYPT('1234')),
+ DES_DECRYPT(DES_ENCRYPT('12345')),
+ DES_DECRYPT(DES_ENCRYPT('123456')),
+ DES_DECRYPT(DES_ENCRYPT('1234567'));
+
+DROP TABLE t1;
+
+--Echo End of 5.0 tests
diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test
index bcf1e5a77f4..879732fc81f 100644
--- a/mysql-test/t/func_encrypt.test
+++ b/mysql-test/t/func_encrypt.test
@@ -88,3 +88,18 @@ select hex(des_decrypt(des_encrypt("hello","hidden")));
explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden"));
# End of 4.1 tests
+
+#
+# Bug#44365 valgrind warnings with encrypt() function
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (f1 smallint(6) default null, f2 mediumtext character set utf8)
+engine=myisam default charset=latin1;
+insert into t1 values (null,'contraction\'s');
+insert into t1 values (-15818,'requirement\'s');
+--disable_result_log
+select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a;
+--enable_result_log
+drop table t1;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index be4e9c32686..b0a3d0feb79 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -18,6 +18,8 @@ insert into t1 values (3,5,"C");
insert into t1 values (3,6,"D");
# Test of MySQL field extension with and without matching records.
+#### Note: The two following statements may fail if the execution plan
+#### or optimizer is changed. The result for column c is undefined.
select a,c,sum(a) from t1 group by a;
select a,c,sum(a) from t1 where a > 10 group by a;
select sum(a) from t1 where a > 10;
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index 87b172a6436..e67f5f29e3a 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -248,6 +248,27 @@ INSERT INTO t1 VALUES ('a');
SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
DROP TABLE t1;
+#
+# Bug #15936: "round" differs on Windows to Unix
+#
+
+CREATE TABLE t1 (a DOUBLE);
+
+INSERT INTO t1 VALUES (-1.1), (1.1),
+ (-1.5), (1.5),
+ (-1.9), (1.9),
+ (-2.1), (2.1),
+ (-2.5), (2.5),
+ (-2.9), (2.9),
+# Check numbers with absolute values > 2^53 - 1
+# (see comments for MAX_EXACT_INTEGER)
+ (-1e16 - 0.5), (1e16 + 0.5),
+ (-1e16 - 1.5), (1e16 + 1.5);
+
+SELECT a, ROUND(a) FROM t1;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index eb243d38238..6590b43f2dc 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -454,6 +454,11 @@ SELECT * FROM t1 WHERE a = NAME_CONST('reportDate',
_binary'2009-01-09' COLLATE 'binary');
DROP TABLE t1;
+#
+# Bug#35515: Aliases of variables in binary log are ignored with NAME_CONST
+#
+select NAME_CONST('_id',1234) as id;
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test
index e4fde6e0e0e..5f37cd2a13e 100644
--- a/mysql-test/t/func_set.test
+++ b/mysql-test/t/func_set.test
@@ -72,3 +72,15 @@ SELECT INTERVAL(0.0, CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL),
CAST(DATE(NULL) AS DECIMAL), CAST(DATE(NULL) AS DECIMAL));
--echo End of 5.0 tests
+
+#
+# Bug#44367 valgrind warnings with find_in_set() functions
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (f1 set('test1','test2','test3') character set utf8 default null)
+engine=myisam default charset=latin1;
+insert into t1 values (''),(null),(null),(''),(''),('');
+select find_in_set(f1,f1) as a from t1,(select find_in_set(f1,f1) as b from t1) a;
+drop table t1;
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 5d77c678d52..ef406d2aeca 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -1273,4 +1273,25 @@ select format(a, 2) from t1;
--disable_metadata
drop table t1;
+#
+# Bug #41868: crash or memory overrun with concat + upper, date_format functions
+#
+
+CREATE TABLE t1 (c DATE, aa VARCHAR(30));
+INSERT INTO t1 VALUES ('2008-12-31','aaaaaa');
+SELECT DATE_FORMAT(c, GET_FORMAT(DATE, 'eur')) h, CONCAT(UPPER(aa),', ', aa) i FROM t1;
+DROP TABLE t1;
+
--echo End of 5.0 tests
+
+#
+# Bug#44358 valgrind errors with decode() function
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1(f1 tinyint default null)engine=myisam;
+insert into t1 values (-1),(null);
+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;
diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
index dad22f42571..19bbcf19cca 100644
--- a/mysql-test/t/gis-rtree.test
+++ b/mysql-test/t/gis-rtree.test
@@ -41,7 +41,7 @@ while ($1)
let $2=10;
while ($2)
{
- eval INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
+ eval INSERT INTO t2 (g) VALUES (LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)));
dec $2;
}
dec $1;
@@ -61,7 +61,7 @@ while ($1)
let $2=10;
while ($2)
{
- eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)))));
+ eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
SELECT count(*) FROM t2;
dec $2;
}
@@ -235,11 +235,11 @@ DROP TABLE t1;
# Bug #21888: Query on GEOMETRY field using PointFromWKB() results in lost connection
#
CREATE TABLE t1 (foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,0)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,0)));
-SELECT 1 FROM t1 WHERE foo != PointFromWKB(POINT(0,0));
+INSERT INTO t1 (foo) VALUES (POINT(1,1));
+INSERT INTO t1 (foo) VALUES (POINT(1,0));
+INSERT INTO t1 (foo) VALUES (POINT(0,1));
+INSERT INTO t1 (foo) VALUES (POINT(0,0));
+SELECT 1 FROM t1 WHERE foo != POINT(0,0);
DROP TABLE t1;
#
@@ -802,35 +802,35 @@ DROP TABLE t1;
#
create table t1 (a geometry not null, spatial index(a));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
-insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
-insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
-insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
-insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
-insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
-insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
-insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
-insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
-insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
-insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
-insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
+insert into t1 values (POINT(1.1517219314031e+164, 131072));
+insert into t1 values (POINT(9.1248812352444e+192, 2.9740338169556e+284));
+insert into t1 values (POINT(4.7783097267365e-299, -0));
+insert into t1 values (POINT(1.49166814624e-154, 2.0880974297595e-53));
+insert into t1 values (POINT(4.0917382598702e+149, 1.2024538023802e+111));
+insert into t1 values (POINT(2.0349165139404e+236, 2.9993936277913e-241));
+insert into t1 values (POINT(2.5243548967072e-29, 1.2024538023802e+111));
+insert into t1 values (POINT(0, 6.9835074892995e-251));
+insert into t1 values (POINT(2.0880974297595e-53, 3.1050361846014e+231));
+insert into t1 values (POINT(2.8728483499323e-188, 2.4600631144627e+260));
+insert into t1 values (POINT(3.0517578125e-05, 2.0349165139404e+236));
+insert into t1 values (POINT(1.1517219314031e+164, 1.1818212630766e-125));
+insert into t1 values (POINT(2.481040258324e-265, 5.7766220027675e-275));
+insert into t1 values (POINT(2.0880974297595e-53, 2.5243548967072e-29));
+insert into t1 values (POINT(5.7766220027675e-275, 9.9464647281957e+86));
+insert into t1 values (POINT(2.2181357552967e+130, 3.7857669957337e-270));
+insert into t1 values (POINT(4.5767114681874e-246, 3.6893488147419e+19));
+insert into t1 values (POINT(4.5767114681874e-246, 3.7537584144024e+255));
+insert into t1 values (POINT(3.7857669957337e-270, 1.8033161362863e-130));
+insert into t1 values (POINT(0, 5.8774717541114e-39));
+insert into t1 values (POINT(1.1517219314031e+164, 2.2761049594727e-159));
+insert into t1 values (POINT(6.243497100632e+144, 3.7857669957337e-270));
+insert into t1 values (POINT(3.7857669957337e-270, 2.6355494858076e-82));
+insert into t1 values (POINT(2.0349165139404e+236, 3.8518598887745e-34));
+insert into t1 values (POINT(4.6566128730774e-10, 2.0880974297595e-53));
+insert into t1 values (POINT(2.0880974297595e-53, 1.8827498946116e-183));
+insert into t1 values (POINT(1.8033161362863e-130, 9.1248812352444e+192));
+insert into t1 values (POINT(4.7783097267365e-299, 2.2761049594727e-159));
+insert into t1 values (POINT(1.94906280228e+289, 1.2338789709327e-178));
drop table t1;
# End of 4.1 tests
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index f8b8b0e17a7..0dae4509518 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -37,32 +37,32 @@ INSERT INTO gis_point VALUES
INSERT INTO gis_line VALUES
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
-(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
+(107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
INSERT INTO gis_polygon VALUES
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
-(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
+(110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
INSERT INTO gis_multi_point VALUES
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
-(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
+(113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
INSERT INTO gis_multi_line VALUES
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
-(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
+(116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
INSERT INTO gis_multi_polygon VALUES
(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
-(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
+(119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
INSERT INTO gis_geometrycollection VALUES
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
-(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
+(121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))));
INSERT into gis_geometry SELECT * FROM gis_point;
INSERT into gis_geometry SELECT * FROM gis_line;
@@ -356,6 +356,9 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85998;
+# Expected result is 36.3310176346905, but IA64 returns 36.3310176346904
+# due to fused multiply-add instructions.
+--replace_result 36.3310176346904 36.3310176346905
select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from
t1 where object_id=85984;
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index a9491dc2736..2e42bdbf06c 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -3,6 +3,9 @@
# Grant tests not performed with embedded server
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
SET GLOBAL log_bin_trust_function_creators = 1;
@@ -81,7 +84,7 @@ delete from mysql.db where user='mysqltest_1';
delete from mysql.tables_priv where user='mysqltest_1';
delete from mysql.columns_priv where user='mysqltest_1';
flush privileges;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for mysqltest_1@localhost;
#
@@ -119,15 +122,15 @@ drop table t1;
#
# Test some error conditions
#
---error 1221
+--error ER_WRONG_USAGE
GRANT FILE on mysqltest.* to mysqltest_1@localhost;
-select 1; # To test that the previous command didn't cause problems
+select 1; # To test that the previous command didn't cause problems
#
-# Bug #4898: User privileges depending on ORDER BY Settings of table db
+# Bug#4898 User privileges depending on ORDER BY Settings of table db
#
insert into mysql.user (host, user) values ('localhost', 'test11');
-insert into mysql.db (host, db, user, select_priv) values
+insert into mysql.db (host, db, user, select_priv) values
('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y');
alter table mysql.db order by db asc;
flush privileges;
@@ -139,7 +142,7 @@ delete from mysql.user where user='test11';
delete from mysql.db where user='test11';
#
-# Bug#6123: GRANT USAGE inserts useless Db row
+# Bug#6123 GRANT USAGE inserts useless Db row
#
create database mysqltest1;
grant usage on mysqltest1.* to test6123 identified by 'magic123';
@@ -148,7 +151,7 @@ delete from mysql.user where user='test6123';
drop database mysqltest1;
#
-# Test for 'drop user', 'revoke privileges, grant'
+# Test for 'drop user', 'revoke privileges, grant'
#
create table t1 (a int);
@@ -163,7 +166,7 @@ grant select(a) on test.t1 to drop_user@localhost;
show grants for drop_user@localhost;
#
-# Bug3086
+# Bug#3086 SHOW GRANTS doesn't follow ANSI_QUOTES
#
set sql_mode=ansi_quotes;
show grants for drop_user@localhost;
@@ -181,7 +184,7 @@ show grants for drop_user@localhost;
revoke all privileges, grant option from drop_user@localhost;
show grants for drop_user@localhost;
drop user drop_user@localhost;
---error 1269
+--error ER_REVOKE_GRANTS
revoke all privileges, grant option from drop_user@localhost;
grant select(a) on test.t1 to drop_user1@localhost;
@@ -191,10 +194,10 @@ grant select on *.* to drop_user4@localhost;
# Drop user now implicitly revokes all privileges.
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
drop_user4@localhost;
---error 1269
+--error ER_REVOKE_GRANTS
revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost,
drop_user3@localhost, drop_user4@localhost;
---error 1396
+--error ER_CANNOT_USER
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
drop_user4@localhost;
drop table t1;
@@ -204,12 +207,12 @@ show grants for mysqltest_1@localhost;
drop user mysqltest_1@localhost;
#
-# Bug #3403 Wrong encodin in SHOW GRANTS output
+# Bug#3403 Wrong encoding in SHOW GRANTS output
#
SET NAMES koi8r;
CREATE DATABASE ÂÄ;
USE ÂÄ;
-CREATE TABLE ÔÁÂ (ËÏÌ int);
+CREATE TABLE ÔÁÂ (ËÏÌ INT);
GRANT SELECT ON ÂÄ.* TO ÀÚÅÒ@localhost;
SHOW GRANTS FOR ÀÚÅÒ@localhost;
@@ -230,7 +233,7 @@ DROP DATABASE ÂÄ;
SET NAMES latin1;
#
-# Bug #5831: REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything
+# Bug#5831 REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything
#
USE test;
CREATE TABLE t1 (a int );
@@ -299,7 +302,7 @@ DROP DATABASE testdb9;
DROP DATABASE testdb10;
#
-# Bug #6932: a problem with 'revoke ALL PRIVILEGES'
+# Bug#6932 a problem with 'revoke ALL PRIVILEGES'
#
create table t1(a int, b int, c int, d int);
@@ -313,7 +316,7 @@ drop user grant_user@localhost;
drop table t1;
#
-# Bug#7391: Cross-database multi-table UPDATE security problem
+# Bug#7391 Cross-database multi-table UPDATE security problem
#
create database mysqltest_1;
create database mysqltest_2;
@@ -322,36 +325,36 @@ create table mysqltest_1.t2 select 1 b, 2 r;
create table mysqltest_2.t1 select 1 c, 2 s;
create table mysqltest_2.t2 select 1 d, 2 t;
-#test the column privileges
+# test the column privileges
grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
connect (conn1,localhost,mysqltest_3,,);
connection conn1;
-SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
- WHERE GRANTEE = '''mysqltest_3''@''localhost'''
+SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
+ WHERE GRANTEE = '''mysqltest_3''@''localhost'''
ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
- WHERE GRANTEE = '''mysqltest_3''@''localhost'''
+ WHERE GRANTEE = '''mysqltest_3''@''localhost'''
ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
- WHERE GRANTEE = '''mysqltest_3''@''localhost'''
+ WHERE GRANTEE = '''mysqltest_3''@''localhost'''
ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
WHERE GRANTEE = '''mysqltest_3''@''localhost'''
ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE;
---error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
---error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
---error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
-#the following two should work
+# the following two should work
update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
connection master;
@@ -362,7 +365,7 @@ revoke all on mysqltest_1.t2 from mysqltest_3@localhost;
revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
-#test the db/table level privileges
+# test the db/table level privileges
grant all on mysqltest_2.* to mysqltest_3@localhost;
grant select on *.* to mysqltest_3@localhost;
# Next grant is needed to trigger bug#7391. Do not optimize!
@@ -374,17 +377,17 @@ connection conn2;
use mysqltest_1;
update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
# the following failed before, should fail now.
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
use mysqltest_2;
-#the following used to succeed, it must fail now.
---error 1142
+# the following used to succeed, it must fail now.
+--error ER_TABLEACCESS_DENIED_ERROR
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
-#lets see the result
+# lets see the result
connection master;
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
@@ -396,6 +399,7 @@ delete from mysql.columns_priv where user="mysqltest_3";
flush privileges;
drop database mysqltest_1;
drop database mysqltest_2;
+disconnect conn2;
#
# just SHOW PRIVILEGES test
@@ -403,7 +407,7 @@ drop database mysqltest_2;
SHOW PRIVILEGES;
#
-# Rights for renaming test (Bug #3270)
+# Rights for renaming test (Bug#3270)
#
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root;
@@ -414,16 +418,18 @@ create table mysqltest.t1 (a int,b int,c int);
grant all on mysqltest.t1 to mysqltest_1@localhost;
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user1;
--- error 1142
+-- error ER_TABLEACCESS_DENIED_ERROR
alter table t1 rename t2;
disconnect user1;
connection root;
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1';
drop database mysqltest;
+connection default;
+disconnect root;
#
-# check all new table priveleges
+# check all new table privileges
#
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
@@ -488,7 +494,7 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
#
-# Bug #11330: Entry in tables_priv with host = '' causes crash
+# Bug#11330 Entry in tables_priv with host = '' causes crash
#
connection default;
use mysql;
@@ -499,7 +505,7 @@ flush privileges;
use test;
#
-# Bug #10892 user variables not auto cast for comparisons
+# Bug#10892 user variables not auto cast for comparisons
# Check that we don't get illegal mix of collations
#
set @user123="non-existent";
@@ -518,18 +524,18 @@ show grants for root@localhost;
set names latin1;
#
-# Bug #15598 Server crashes in specific case during setting new password
+# Bug#15598 Server crashes in specific case during setting new password
# - Caused by a user with host ''
#
create user mysqltest_7@;
set password for mysqltest_7@ = password('systpass');
show grants for mysqltest_7@;
drop user mysqltest_7@;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for mysqltest_7@;
#
-# Bug#14385: GRANT and mapping to correct user account problems
+# Bug#14385 GRANT and mapping to correct user account problems
#
create database mysqltest;
use mysqltest;
@@ -545,7 +551,7 @@ flush privileges;
drop database mysqltest;
#
-# Bug #27515: DROP previlege is not required for RENAME TABLE
+# Bug#27515 DROP previlege is not required for RENAME TABLE
#
connection master;
create database db27515;
@@ -556,7 +562,7 @@ grant insert, create on db27515.t2 to user27515@localhost;
connect (conn27515, localhost, user27515, , db27515);
connection conn27515;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
rename table t1 to t2;
disconnect conn27515;
@@ -568,7 +574,7 @@ drop database db27515;
--echo End of 4.1 tests
#
-# Bug #16297 In memory grant tables not flushed when users's hostname is ""
+# Bug#16297 In memory grant tables not flushed when users's hostname is ""
#
use test;
create table t1 (a int);
@@ -585,11 +591,11 @@ create user mysqltest_8;
create user mysqltest_8@host8;
# Try to create them again
---error 1396
+--error ER_CANNOT_USER
create user mysqltest_8@'';
---error 1396
+--error ER_CANNOT_USER
create user mysqltest_8;
---error 1396
+--error ER_CANNOT_USER
create user mysqltest_8@host8;
select user, QUOTE(host) from mysql.user where user="mysqltest_8";
@@ -684,44 +690,43 @@ flush privileges;
show grants for mysqltest_8@'';
show grants for mysqltest_8;
drop user mysqltest_8@'';
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for mysqltest_8@'';
show grants for mysqltest_8;
select * from information_schema.user_privileges
where grantee like "'mysqltest_8'%";
drop user mysqltest_8;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error 1045
+--error ER_ACCESS_DENIED_ERROR
connect (conn6,localhost,mysqltest_8,,);
connection master;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for mysqltest_8;
drop user mysqltest_8@host8;
---error 1141
+--error ER_NONEXISTING_GRANT
show grants for mysqltest_8@host8;
# Restore the anonymous users.
insert into mysql.user select * from t2;
flush privileges;
drop table t2;
-
drop table t1;
#
-# Bug#20214: Incorrect error when user calls SHOW CREATE VIEW on non
-# privileged view
+# Bug#20214 Incorrect error when user calls SHOW CREATE VIEW on non
+# privileged view
#
connection master;
CREATE DATABASE mysqltest3;
-use mysqltest3;
+USE mysqltest3;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
CREATE DATABASE mysqltest2;
-use mysqltest2;
+USE mysqltest2;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
@@ -743,24 +748,18 @@ SHOW CREATE VIEW mysqltest2.v_nn;
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest2.v_nn;
-
-
# fail because of missing SHOW VIEW
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE VIEW mysqltest2.v_yn;
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest2.v_yn;
-
-
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
SHOW CREATE TABLE mysqltest2.v_ny;
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
SHOW CREATE VIEW mysqltest2.v_ny;
-
-
# fail because of missing (specific or generic) SELECT
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest3.t_nn;
@@ -769,16 +768,12 @@ SHOW CREATE TABLE mysqltest3.t_nn;
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE VIEW mysqltest3.t_nn;
-
-
# fail because of missing missing (specific or generic) SELECT (and SHOW VIEW)
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE VIEW mysqltest3.v_nn;
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest3.v_nn;
-
-
# succeed thanks to generic SELECT
SHOW CREATE TABLE mysqltest2.t_nn;
@@ -786,17 +781,13 @@ SHOW CREATE TABLE mysqltest2.t_nn;
--error ER_WRONG_OBJECT
SHOW CREATE VIEW mysqltest2.t_nn;
-
-
# succeed, have SELECT and SHOW VIEW
SHOW CREATE VIEW mysqltest2.v_yy;
# succeed, have SELECT and SHOW VIEW
SHOW CREATE TABLE mysqltest2.v_yy;
-
-
-#clean-up
+# clean-up
connection master;
# succeed, we're root
@@ -809,38 +800,33 @@ SHOW CREATE TABLE mysqltest2.t_nn;
--error ER_WRONG_OBJECT
SHOW CREATE VIEW mysqltest2.t_nn;
-
-
DROP VIEW mysqltest2.v_nn;
DROP VIEW mysqltest2.v_yn;
DROP VIEW mysqltest2.v_ny;
DROP VIEW mysqltest2.v_yy;
-
DROP TABLE mysqltest2.t_nn;
-
DROP DATABASE mysqltest2;
-
-
-
DROP VIEW mysqltest3.v_nn;
DROP TABLE mysqltest3.t_nn;
-
DROP DATABASE mysqltest3;
-
+disconnect mysqltest_1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
DROP USER 'mysqltest_1'@'localhost';
# restore the original database
-use test;
+USE test;
+connection default;
+disconnect master;
+
#
-# Bug #10668: CREATE USER does not enforce username length limit
+# Bug#10668 CREATE USER does not enforce username length limit
#
--error ER_WRONG_STRING_LENGTH
create user mysqltest1_thisisreallytoolong;
#
-# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+# Test for Bug#16899 Possible buffer overflow in handling of DEFINER-clause.
#
# These checks are intended to ensure that appropriate errors are risen when
# illegal user name or hostname is specified in user-clause of GRANT/REVOKE
@@ -848,7 +834,7 @@ create user mysqltest1_thisisreallytoolong;
#
#
-# Bug #22369: Alter table rename combined with other alterations causes lost tables
+# Bug#22369 Alter table rename combined with other alterations causes lost tables
#
CREATE DATABASE mysqltest1;
CREATE TABLE mysqltest1.t1 (
@@ -968,7 +954,7 @@ REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij123456789
#
-# BUG#23556: TRUNCATE TABLE still maps to DELETE
+# Bug#23556 TRUNCATE TABLE still maps to DELETE
#
CREATE USER bug23556@localhost;
CREATE DATABASE bug23556;
@@ -1000,8 +986,12 @@ DROP TABLE t1;
USE test;
DROP DATABASE bug23556;
DROP USER bug23556@localhost;
+connection default;
+disconnect bug23556;
+
+
#
-# Bug #6774: Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES
+# Bug#6774 Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES
#
# Check if GRANT ... ON * ... fails when no database is selected
connect (con1, localhost, root,,*NO-ONE*);
@@ -1013,7 +1003,7 @@ connection default;
#
-# BUG#9504: Stored procedures: execute privilege doesn't make 'use database'
+# Bug#9504 Stored procedures: execute privilege doesn't make 'use database'
# okay.
#
@@ -1038,8 +1028,8 @@ CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
SELECT 1;
CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
- RETURN 1;
-
+ RETURN 1;
+
CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
RETURN 1;
@@ -1095,7 +1085,7 @@ DROP USER mysqltest_1@localhost;
#
-# BUG#27337: Privileges are not restored properly.
+# Bug#27337 Privileges are not restored properly.
#
# Actually, the patch for this bugs fixes two problems. So, here are two test
# cases.
@@ -1157,7 +1147,7 @@ DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
-# Test case 2: priveleges are not checked properly for prepared statements.
+# Test case 2: privileges are not checked properly for prepared statements.
# Prepare.
@@ -1230,6 +1220,7 @@ EXECUTE stmt2;
--echo
--echo ---> connection: default
+--disconnect bug27337_con1
--disconnect bug27337_con2
DROP DATABASE mysqltest1;
@@ -1239,21 +1230,21 @@ DROP USER mysqltest_1@localhost;
DROP USER mysqltest_2@localhost;
#
-# Bug#27878: Unchecked privileges on a view referring to a table from another
-# database.
+# Bug#27878 Unchecked privileges on a view referring to a table from another
+# database.
#
-use test;
+USE test;
CREATE TABLE t1 (f1 int, f2 int);
INSERT INTO t1 VALUES(1,1), (2,2);
CREATE DATABASE db27878;
GRANT UPDATE(f1) ON t1 TO 'mysqltest_1'@'localhost';
GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost';
GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost';
-use db27878;
+USE db27878;
CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1;
connect (user1,localhost,mysqltest_1,,test);
connection user1;
-use db27878;
+USE db27878;
--error 1356
UPDATE v1 SET f2 = 4;
SELECT * FROM test.t1;
@@ -1264,7 +1255,7 @@ REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost';
REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost';
DROP USER mysqltest_1@localhost;
DROP DATABASE db27878;
-use test;
+USE test;
DROP TABLE t1;
--echo #
@@ -1273,8 +1264,10 @@ DROP TABLE t1;
CREATE TEMPORARY TABLE mysql.user (id INT);
FLUSH PRIVILEGES;
DROP TABLE mysql.user;
+
+
#
-# Bug #33201 Crash occurs when granting update privilege on one column of a view
+# Bug#33201 Crash occurs when granting update privilege on one column of a view
#
drop table if exists test;
drop function if exists test_function;
@@ -1305,7 +1298,7 @@ SET PASSWORD FOR CURRENT_USER() = PASSWORD("");
--echo End of 5.0 tests
#
-# Bug#21432: Database/Table name limited to 64 bytes, not chars, problems with multi-byte
+# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
#
set names utf8;
grant select on test.* to юзер_юзер@localhost;
@@ -1317,7 +1310,7 @@ grant select on test.* to очень_длинный_юзер@localhost;
set names default;
#
-# Bug #20901 - CREATE privilege is enough to insert into a table
+# Bug#20901 CREATE privilege is enough to insert into a table
#
create database mysqltest;
@@ -1329,7 +1322,7 @@ create table t1 (i INT);
connect (user1,localhost,mysqltest,,mysqltest);
connection user1;
# show we don't have INSERT
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
insert into t1 values (1);
# show we have CREATE
create table t2 (i INT);
@@ -1348,11 +1341,11 @@ insert into t2 values (1);
# CREATE IF NOT EXISTS...SELECT, t1 exists, no INSERT, must fail
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create table if not exists t1 select * from t2;
# CREATE IF NOT EXISTS...SELECT, no t3 yet, no INSERT, must fail
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create table if not exists t3 select * from t2;
# CREATE IF NOT EXISTS...SELECT, t4 exists, have INSERT, must succeed
@@ -1366,7 +1359,7 @@ create table if not exists t5 select * from t2;
create table t6 select * from t2;
# CREATE...SELECT, no t7 yet, no INSERT, must fail
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create table t7 select * from t2;
# CREATE...SELECT, t4 exists, have INSERT, must still fail (exists)
@@ -1374,7 +1367,7 @@ create table t7 select * from t2;
create table t4 select * from t2;
# CREATE...SELECT, t1 exists, no INSERT, must fail
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create table t1 select * from t2;
@@ -1394,7 +1387,7 @@ use test;
#
-# Bug #16470 crash on grant if old grant tables
+# Bug#16470 crash on grant if old grant tables
#
--echo FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
@@ -1415,7 +1408,7 @@ FLUSH PRIVILEGES;
#
-# Bug#33464: DROP FUNCTION caused a crash.
+# Bug#33464 DROP FUNCTION caused a crash.
#
CREATE DATABASE dbbug33464;
CREATE USER 'userbug33464'@'localhost';
@@ -1472,8 +1465,11 @@ DROP PROCEDURE sp3;
--error 0, ER_CANNOT_USER
DROP USER 'userbug33464'@'localhost';
-use test;
+USE test;
DROP DATABASE dbbug33464;
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index e3cf3ca856d..5b96213034a 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1139,4 +1139,22 @@ DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
+#
+# Bug#42567 Invalid GROUP BY error
+#
+
+# Setup of the subtest
+SET @old_sql_mode = @@sql_mode;
+SET @@sql_mode='ONLY_FULL_GROUP_BY';
+
+CREATE TABLE t1(i INT);
+INSERT INTO t1 VALUES (1), (10);
+
+# The actual test
+SELECT COUNT(i) FROM t1;
+SELECT COUNT(i) FROM t1 WHERE i > 1;
+
+# Cleanup of subtest
+DROP TABLE t1;
+SET @@sql_mode = @old_sql_mode;
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index a7f4325b2d1..adfa77c881c 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -961,3 +961,25 @@ insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a;
select * from t1;
explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
drop table t1;
+
+
+#
+# Bug #41610: key_infix_len can be overwritten causing some group by queries
+# to return no rows
+#
+
+CREATE TABLE t1 (a int, b int, c int, d int,
+ KEY foo (c,d,a,b), KEY bar (c,a,b,d));
+
+INSERT INTO t1 VALUES (1, 1, 1, 1), (1, 1, 1, 2), (1, 1, 1, 3), (1, 1, 1, 4);
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT a,b,c+1,d FROM t1;
+
+#Should be non-empty
+EXPLAIN SELECT DISTINCT c FROM t1 WHERE d=4;
+SELECT DISTINCT c FROM t1 WHERE d=4;
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test
index 8fdda2b772b..dccaecef20a 100644
--- a/mysql-test/t/index_merge_myisam.test
+++ b/mysql-test/t/index_merge_myisam.test
@@ -19,3 +19,170 @@ let $merge_table_support= 1;
--source include/index_merge2.inc
--source include/index_merge_2sweeps.inc
--source include/index_merge_ror_cpk.inc
+
+--echo #
+--echo # Generic @@optimizer_switch tests (move those into a separate file if
+--echo # we get another @@optimizer_switch user)
+--echo #
+
+select @@optimizer_switch;
+
+set optimizer_switch='index_merge=off,index_merge_union=off';
+select @@optimizer_switch;
+
+set optimizer_switch='index_merge_union=on';
+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
+set optimizer_switch=NULL;
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='default,index_merge';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='index_merge=index_merge';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='index_merge=on,but...';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='index_merge=';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='index_merge';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='on';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='index_merge=on,index_merge=off';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='index_merge_union=on,index_merge_union=default';
+
+--error ER_WRONG_VALUE_FOR_VAR
+set optimizer_switch='default,index_merge=on,index_merge=off,default';
+
+set optimizer_switch=default;
+set optimizer_switch='index_merge=off,index_merge_union=off,default';
+select @@optimizer_switch;
+set optimizer_switch=default;
+
+# Check setting defaults for global vars
+select @@global.optimizer_switch;
+set @@global.optimizer_switch=default;
+select @@global.optimizer_switch;
+
+--echo #
+--echo # Check index_merge's @@optimizer_switch flags
+--echo #
+select @@optimizer_switch;
+
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int, b int, c int, filler char(100),
+ key(a), key(b), key(c));
+insert into t1 select
+ A.a * B.a*10 + C.a*100,
+ A.a * B.a*10 + C.a*100,
+ A.a,
+ 'filler'
+from t0 A, t0 B, t0 C;
+
+--echo This should use union:
+explain select * from t1 where a=1 or b=1;
+
+--echo This should use ALL:
+set optimizer_switch='default,index_merge=off';
+explain select * from t1 where a=1 or b=1;
+
+--echo This should use sort-union:
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a=1 or b=1;
+
+--echo This will use sort-union:
+set optimizer_switch=default;
+explain select * from t1 where a<1 or b <1;
+
+--echo This should use ALL:
+set optimizer_switch='default,index_merge_sort_union=off';
+explain select * from t1 where a<1 or b <1;
+
+
+--echo This should use ALL:
+set optimizer_switch='default,index_merge=off';
+explain select * from t1 where a<1 or b <1;
+
+--echo This will use sort-union:
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a<1 or b <1;
+
+alter table t1 add d int, add key(d);
+update t1 set d=a;
+
+--echo This will use sort_union:
+set optimizer_switch=default;
+explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
+
+--echo And if we disable sort_union, union:
+set optimizer_switch='default,index_merge_sort_union=off';
+explain select * from t1 where (a=3 or b in (1,2)) and (c=3 or d=4);
+
+drop table t1;
+
+# Now test that intersection can be disabled
+create table t1 (
+ a int, b int, c int,
+ filler1 char(200), filler2 char(200),
+ key(a),key(b),key(c)
+);
+
+insert into t1
+select A.a+10*B.a, A.a+10*B.a, A.a+10*B.a+100*C.a, 'foo', 'bar'
+from t0 A, t0 B, t0 C, t0 D where D.a<5;
+
+--echo This should be intersect:
+set optimizer_switch=default;
+explain select * from t1 where a=10 and b=10;
+
+--echo No intersect when index_merge is disabled:
+set optimizer_switch='default,index_merge=off';
+explain select * from t1 where a=10 and b=10;
+
+--echo No intersect if it is disabled:
+set optimizer_switch='default,index_merge_intersection=off';
+explain select * from t1 where a=10 and b=10;
+
+--echo Do intersect when union was disabled
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a=10 and b=10;
+
+--echo Do intersect when sort_union was disabled
+set optimizer_switch='default,index_merge_sort_union=off';
+explain select * from t1 where a=10 and b=10;
+
+# Now take union-of-intersection and see how we can disable parts of it
+--echo This will use intersection inside a union:
+set optimizer_switch=default;
+explain select * from t1 where a=10 and b=10 or c=10;
+
+--echo Should be only union left:
+set optimizer_switch='default,index_merge_intersection=off';
+explain select * from t1 where a=10 and b=10 or c=10;
+
+--echo This will switch to sort-union (intersection will be gone, too,
+--echo thats a known limitation:
+set optimizer_switch='default,index_merge_union=off';
+explain select * from t1 where a=10 and b=10 or c=10;
+
+set optimizer_switch=default;
+show variables like 'optimizer_switch';
+
+drop table t0, t1;
+
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 7105d7e04f0..392d1062492 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -5,6 +5,10 @@
# 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 for information_schema.schemata &
# show databases
@@ -44,11 +48,11 @@ create view v1 (c) as
table_name<>'ndb_apply_status';
select * from v1;
-select c,table_name from v1
+select c,table_name from v1
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
-select c,table_name from v1
+select c,table_name from v1
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
@@ -77,16 +81,17 @@ grant select (a) on mysqltest.t1 to mysqltest_2@localhost;
grant select on mysqltest.v1 to mysqltest_3;
connect (user3,localhost,mysqltest_2,,);
connection user3;
-select table_name, column_name, privileges from information_schema.columns
+select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 't1';
show columns from mysqltest.t1;
connect (user4,localhost,mysqltest_3,,mysqltest);
connection user4;
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 'v1';
---error 1345
+--error ER_VIEW_NO_EXPLAIN
explain select * from v1;
connection default;
+disconnect user4;
drop view v1, mysqltest.v1;
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
@@ -136,7 +141,7 @@ delimiter ;|
#
# Bug#7222 information_schema: errors in "routines"
#
-select parameter_style, sql_data_access, dtd_identifier
+select parameter_style, sql_data_access, dtd_identifier
from information_schema.routines where routine_schema='test';
--replace_column 5 # 6 #
@@ -163,7 +168,7 @@ drop view v1;
connect (user1,localhost,mysqltest_1,,);
connection user1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
---error 1305
+--error ER_SP_DOES_NOT_EXIST
show create function sub1;
connection user3;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
@@ -182,6 +187,7 @@ show create function sub2;
show function status like "sub2";
connection default;
disconnect user1;
+disconnect user3;
drop function sub2;
show create procedure sel2;
@@ -321,7 +327,7 @@ drop view v1;
create table t1(a NUMERIC(5,3), b NUMERIC(5,1), c float(5,2),
d NUMERIC(6,4), e float, f DECIMAL(6,3), g int(11), h DOUBLE(10,3),
i DOUBLE);
-select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
+select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH,
CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
from information_schema.columns where table_name= 't1';
drop table t1;
@@ -334,7 +340,7 @@ drop table t115;
delimiter //;
create procedure p108 () begin declare c cursor for select data_type
from information_schema.columns; open c; open c; end;//
---error 1325
+--error ER_SP_CURSOR_ALREADY_OPEN
call p108()//
delimiter ;//
drop procedure p108;
@@ -344,24 +350,24 @@ where table_name= "user";
select * from v1;
drop view v1;
-create view vo as select 'a' union select 'a';
+create view vo as select 'a' union select 'a';
show index from vo;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_NAME= "vo";
select * from information_schema.KEY_COLUMN_USAGE where
-TABLE_NAME= "vo";
+TABLE_NAME= "vo";
drop view vo;
select TABLE_NAME,TABLE_TYPE,ENGINE
-from information_schema.tables
+from information_schema.tables
where table_schema='information_schema' limit 2;
show tables from information_schema like "T%";
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
create database information_schema;
use information_schema;
show full tables like "T%";
---error 1109
+--error ER_UNKNOWN_TABLE
create table t1(a int);
use test;
show tables;
@@ -369,15 +375,15 @@ use information_schema;
show tables like "T%";
#
-# Bug#7210: information_schema: can't access when table-name = reserved word
+# Bug#7210 information_schema: can't access when table-name = reserved word
#
select table_name from tables where table_name='user';
select column_name, privileges from columns
where table_name='user' and column_name like '%o%';
#
-# Bug#7212: information_schema: "Can't find file" errors if storage engine gone
-# Bug#7211: information_schema: crash if bad view
+# Bug#7212 information_schema: "Can't find file" errors if storage engine gone
+# Bug#7211 information_schema: crash if bad view
#
use test;
create function sub1(i int) returns int
@@ -404,9 +410,9 @@ drop view v3;
drop table t4;
#
-# Bug#7213: information_schema: redundant non-standard TABLE_NAMES table
+# Bug#7213 information_schema: redundant non-standard TABLE_NAMES table
#
---error 1109
+--error ER_UNKNOWN_TABLE
select * from information_schema.table_names;
#
@@ -419,7 +425,7 @@ where table_schema="information_schema" and table_name="COLUMNS" and
#
# Bug#2718 information_schema: errors in "tables"
#
-select TABLE_ROWS from information_schema.tables where
+select TABLE_ROWS from information_schema.tables where
table_schema="information_schema" and table_name="COLUMNS";
select table_type from information_schema.tables
where table_schema="mysql" and table_name="user";
@@ -432,14 +438,14 @@ show status where variable_name like "%database%";
show variables where variable_name like "skip_show_databas";
#
-# Bug #7981:SHOW GLOBAL STATUS crashes server
+# Bug#7981 SHOW GLOBAL STATUS crashes server
#
# We don't actually care about the value, just that it doesn't crash.
--replace_column 2 #
show global status like "Threads_running";
#
-# Bug #7915 crash,JOIN VIEW, subquery,
+# Bug#7915 crash,JOIN VIEW, subquery,
# SELECT .. FROM INFORMATION_SCHEMA.COLUMNS
#
create table t1(f1 int);
@@ -450,7 +456,7 @@ drop view v1;
drop table t1, t2;
#
-# Bug #7476: crash on SELECT * FROM INFORMATION_SCHEMA.TABLES
+# Bug#7476 crash on SELECT * FROM INFORMATION_SCHEMA.TABLES
#
use test;
CREATE TABLE t_crashme ( f1 BIGINT);
@@ -478,26 +484,26 @@ drop view a2, a1;
drop table t_crashme;
#
-# Bug #7215 information_schema: columns are longtext instead of varchar
-# Bug #7217 information_schema: columns are varbinary() instead of timestamp
+# Bug#7215 information_schema: columns are longtext instead of varchar
+# Bug#7217 information_schema: columns are varbinary() instead of timestamp
#
select table_schema,table_name, column_name from
-information_schema.columns
+information_schema.columns
where data_type = 'longtext';
select table_name, column_name, data_type from information_schema.columns
where data_type = 'datetime';
#
-# Bug #8164 subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
+# Bug#8164 subquery with INFORMATION_SCHEMA.COLUMNS, 100 % CPU
#
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES A
-WHERE NOT EXISTS
+WHERE NOT EXISTS
(SELECT * FROM INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME);
#
-# Bug #9344 INFORMATION_SCHEMA, wrong content, numeric columns
+# Bug#9344 INFORMATION_SCHEMA, wrong content, numeric columns
#
create table t1
@@ -515,21 +521,22 @@ WHERE TABLE_NAME= 't1';
drop table t1;
#
-# Bug#10261 INFORMATION_SCHEMA.COLUMNS, incomplete result for non root user
+# Bug#10261 INFORMATION_SCHEMA.COLUMNS, incomplete result for non root user
#
grant select on test.* to mysqltest_4@localhost;
connect (user10261,localhost,mysqltest_4,,);
connection user10261;
-SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
+SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME='TABLE_NAME';
connection default;
+disconnect user10261;
delete from mysql.user where user='mysqltest_4';
delete from mysql.db where user='mysqltest_4';
flush privileges;
#
-# Bug #9404 information_schema: Weird error messages
+# 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;
@@ -570,7 +577,7 @@ drop table t1;
#
-# Bug #10964 Information Schema:Authorization check on privilege tables is improper
+# Bug#10964 Information Schema:Authorization check on privilege tables is improper
#
create database mysqltest;
@@ -614,12 +621,16 @@ select * from information_schema.user_privileges where grantee like '%user%'
order by grantee;
show grants;
connection default;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+disconnect con4;
drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost;
use test;
drop database mysqltest;
#
-# Bug #11055 information_schema: routines.sql_data_access has wrong value
+# Bug#11055 information_schema: routines.sql_data_access has wrong value
#
--disable_warnings
drop procedure if exists p1;
@@ -634,13 +645,13 @@ drop procedure p1;
drop procedure p2;
#
-# Bug #9434 SHOW CREATE DATABASE information_schema;
+# Bug#9434 SHOW CREATE DATABASE information_schema;
#
show create database information_schema;
#
-# Bug #11057 information_schema: columns table has some questionable contents
-# Bug #12301 information_schema: NUMERIC_SCALE must be 0 for integer columns
+# Bug#11057 information_schema: columns table has some questionable contents
+# Bug#12301 information_schema: NUMERIC_SCALE must be 0 for integer columns
#
create table t1(f1 LONGBLOB, f2 LONGTEXT);
select column_name,data_type,CHARACTER_OCTET_LENGTH,
@@ -656,7 +667,7 @@ where table_name='t1';
drop table t1;
#
-# Bug #12127 triggers do not show in info_schema before they are used if set to the database
+# Bug#12127 triggers do not show in info_schema before they are used if set to the database
#
create table t1 (f1 integer);
create trigger tr1 after insert on t1 for each row set @test_var=42;
@@ -678,8 +689,8 @@ show columns from t1;
drop table t1;
#
-# Bug #12636: SHOW TABLE STATUS with where condition containing a subquery
-# over information schema
+# Bug#12636 SHOW TABLE STATUS with where condition containing a subquery
+# over information schema
#
CREATE TABLE t1 (a int);
@@ -693,7 +704,7 @@ SHOW TABLE STATUS FROM test
DROP TABLE t1,t2;
#
-# Bug #12905 show fields from view behaving erratically with current database
+# Bug#12905 show fields from view behaving erratically with current database
#
create table t1(f1 int);
create view v1 (c) as select f1 from t1;
@@ -701,28 +712,29 @@ connect (con5,localhost,root,,*NO-ONE*);
select database();
show fields from test.v1;
connection default;
+disconnect con5;
drop view v1;
drop table t1;
#
-# Bug #9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
+# Bug#9846 Inappropriate error displayed while dropping table from 'INFORMATION_SCHEMA'
#
--error ER_PARSE_ERROR
alter database information_schema;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
drop database information_schema;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
drop table information_schema.tables;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
alter table information_schema.tables;
#
-# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
+# Bug#9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
#
use information_schema;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
create temporary table schemata(f1 char(10));
#
-# Bug #10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA
+# Bug#10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA
#
delimiter |;
--error ER_BAD_DB_ERROR
@@ -731,13 +743,13 @@ BEGIN
SELECT 'foo' FROM DUAL;
END |
delimiter ;|
-select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema';
+select ROUTINE_NAME from routines where ROUTINE_SCHEMA='information_schema';
#
-# Bug #10734 Grant of privileges other than 'select' and 'create view' should fail on schema
+# Bug#10734 Grant of privileges other than 'select' and 'create view' should fail on schema
#
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
grant all on information_schema.* to 'user1'@'localhost';
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
grant select on information_schema.* to 'user1'@'localhost';
#
@@ -763,9 +775,9 @@ where table_name="v1";
drop view v1;
#
-# Bug #14387 SHOW COLUMNS doesn't work on temporary tables
-# Bug #15224 SHOW INDEX from temporary table doesn't work
-# Bug #12770 DESC cannot display the info. about temporary table
+# Bug#14387 SHOW COLUMNS doesn't work on temporary tables
+# Bug#15224 SHOW INDEX from temporary table doesn't work
+# Bug#12770 DESC cannot display the info. about temporary table
#
create temporary table t1(f1 int, index(f1));
show columns from t1;
@@ -850,6 +862,7 @@ connection con16681;
select * from information_schema.views
where table_name='v1' or table_name='v2';
connection default;
+disconnect con16681;
drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
@@ -864,8 +877,9 @@ select concat(@a, table_name), @a, table_name
from information_schema.tables where table_schema = 'test';
drop table t1,t2;
+
#
-# Bug#20230: routine_definition is not null
+# Bug#20230 routine_definition is not null
#
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
@@ -898,7 +912,7 @@ DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
#
-# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
+# Bug#18925 subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
#
SELECT t.table_name, c1.column_name
@@ -931,8 +945,8 @@ SELECT t.table_name, c1.column_name
);
#
-# Bug#21231: query with a simple non-correlated subquery over
-# INFORMARTION_SCHEMA.TABLES
+# Bug#2123 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');
@@ -940,7 +954,7 @@ SELECT table_name from information_schema.tables
WHERE table_name=(SELECT MAX(table_name)
FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'));
#
-# Bug #23037: Bug in field "Default" of query "SHOW COLUMNS FROM table"
+# Bug#23037 Bug in field "Default" of query "SHOW COLUMNS FROM table"
#
# Note, MyISAM/InnoDB can't take more that 65532 chars, because the row
# size is limited to 65535 bytes (BLOBs not counted)
@@ -981,7 +995,7 @@ DROP TABLE bug23037;
DROP FUNCTION get_value;
#
-# Bug#22413: EXPLAIN SELECT FROM view with ORDER BY yield server crash
+# Bug#22413 EXPLAIN SELECT FROM view with ORDER BY yield server crash
#
create view v1 as
select table_schema as object_schema,
@@ -1007,7 +1021,7 @@ drop table t1,t2;
#
-# Bug#24630 Subselect query crashes mysqld
+# Bug#24630 Subselect query crashes mysqld
#
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
(select cast(table_name as char) from information_schema.tables
@@ -1034,8 +1048,8 @@ group by t.table_name order by num1, t.table_name;
#
create table t1(f1 int);
create view v1 as select f1+1 as a from t1;
-create table t2 (f1 int, f2 int);
-create view v2 as select f1+1 as a, f2 as b from t2;
+create table t2 (f1 int, f2 int);
+create view v2 as select f1+1 as a, f2 as b from t2;
select table_name, is_updatable from information_schema.views;
#
# Note: we can perform 'delete' for non updatable view.
@@ -1045,7 +1059,7 @@ drop view v1,v2;
drop table t1,t2;
#
-# Bug#25859 ALTER DATABASE works w/o parameters
+# Bug#25859 ALTER DATABASE works w/o parameters
#
--error ER_PARSE_ERROR
alter database;
@@ -1074,6 +1088,7 @@ show triggers;
select trigger_name from information_schema.triggers
where event_object_table='t1';
connection default;
+disconnect con27629;
drop user mysqltest_1@localhost;
drop database mysqltest;
@@ -1097,13 +1112,13 @@ drop table t1;
#
# Bug#30079 A check for "hidden" I_S tables is flawed
#
---error 1109
+--error ER_UNKNOWN_TABLE
show fields from information_schema.table_names;
---error 1109
+--error ER_UNKNOWN_TABLE
show keys from information_schema.table_names;
#
-# Bug#34529: Crash on complex Falcon I_S select after ALTER .. PARTITION BY
+# Bug#34529 Crash on complex Falcon I_S select after ALTER .. PARTITION BY
#
USE information_schema;
SET max_heap_table_size = 16384;
@@ -1112,9 +1127,9 @@ CREATE TABLE test.t1( a INT );
# What we need to create here is a bit of a corner case:
# We need a star query with information_schema tables, where the first
-# branch of the star join produces zero rows, so that reading of the
+# branch of the star join produces zero rows, so that reading of the
# second branch never happens. At the same time we have to make sure
-# that data for at least the last table is swapped from MEMORY/HEAP to
+# that data for at least the last table is swapped from MEMORY/HEAP to
# MyISAM. This and only this triggers the bug.
SELECT *
FROM tables ta
@@ -1142,10 +1157,11 @@ connect (con3148,localhost,user3148,,test);
connection con3148;
select user,db from information_schema.processlist;
connection default;
+disconnect con3148;
drop user user3148@localhost;
#
-# Bug #26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS
+# Bug#26174 Server Crash: INSERT ... SELECT ... FROM I_S.GLOBAL_STATUS
# in Event (see also openssl_1.test)
#
--disable_warnings
@@ -1183,7 +1199,7 @@ SET GLOBAL event_scheduler=0;
#
# WL#3732 Information schema optimization
-#
+#
explain select table_name from information_schema.views where
table_schema='test' and table_name='v1';
@@ -1231,7 +1247,7 @@ DROP VIEW v1;
#
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME ='information_schema';
-
+
#
# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA
#
@@ -1277,7 +1293,7 @@ show events where Db= 'information_schema';
use test;
--echo #
---echo # Bug#34166: Server crash in SHOW OPEN TABLES and prelocking
+--echo # Bug#34166 Server crash in SHOW OPEN TABLES and prelocking
--echo #
--disable_warnings
drop table if exists t1;
@@ -1299,8 +1315,8 @@ drop table t1;
drop function f1;
#
-# BUG#34656 - KILL a query = Assertion failed: m_status == DA_ERROR ||
-# m_status == DA_OK
+# Bug#34656 KILL a query = Assertion failed: m_status == DA_ERROR ||
+# m_status == DA_OK
#
connect (conn1, localhost, root,,);
connection conn1;
@@ -1378,13 +1394,13 @@ select * from information_schema.global_variables where variable_name='init_conn
set global init_connect="";
#
-# Bug #34517 SHOW GLOBAL STATUS does not work properly in embedded server.
+# Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
#
create table t0 select * from information_schema.global_status where VARIABLE_NAME='COM_SELECT';
SELECT 1;
select a.VARIABLE_VALUE - b.VARIABLE_VALUE from t0 b, information_schema.global_status a
- where a.VARIABLE_NAME = b.VARIABLE_NAME;
+ where a.VARIABLE_NAME = b.VARIABLE_NAME;
drop table t0;
#
@@ -1394,4 +1410,17 @@ CREATE TABLE t1(a INT) KEY_BLOCK_SIZE=1;
SELECT CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
DROP TABLE t1;
+#
+# Bug #22047: Time in SHOW PROCESSLIST for SQL thread in replication seems
+# to become negative
+#
+
+SET TIMESTAMP=@@TIMESTAMP + 10000000;
+SELECT 'OK' AS TEST_RESULT FROM INFORMATION_SCHEMA.PROCESSLIST WHERE time < 0;
+SET TIMESTAMP=DEFAULT;
+
--echo End of 5.1 tests.
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/init_connect.test b/mysql-test/t/init_connect.test
index 0a08559279c..b6bac5f65fa 100644
--- a/mysql-test/t/init_connect.test
+++ b/mysql-test/t/init_connect.test
@@ -5,6 +5,9 @@
# should work with embedded server after mysqltest is fixed
--source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
--source include/add_anonymous_users.inc
connect (con0,localhost,root,,);
@@ -233,7 +236,8 @@ connect (con1,localhost,mysqltest1,,);
connection con1;
select * from t1;
-connection con0;
+connection default;
+disconnect con0;
disconnect con1;
drop trigger trg1;
@@ -244,3 +248,7 @@ set global init_connect="set @a='a\\0c'";
revoke all privileges, grant option from mysqltest1@localhost;
drop user mysqltest1@localhost;
drop table t1, t2;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/innodb-autoinc.test b/mysql-test/t/innodb-autoinc.test
index e6b804c4fff..d76b29a7dc8 100644
--- a/mysql-test/t/innodb-autoinc.test
+++ b/mysql-test/t/innodb-autoinc.test
@@ -390,3 +390,91 @@ INSERT INTO t1 VALUES (NULL);
#endif
SELECT * FROM t1;
DROP TABLE t1;
+
+#
+# Check for floating point autoinc column handling
+#
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+SET @@INSERT_ID=1;
+SHOW VARIABLES LIKE "%auto_inc%";
+CREATE TABLE t1 (c1 DOUBLE NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 FLOAT NOT NULL AUTO_INCREMENT, c2 INT, PRIMARY KEY (c1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES(NULL, 1);
+INSERT INTO t1 VALUES(NULL, 2);
+SELECT * FROM t1;
+ALTER TABLE t1 CHANGE c1 c1 SERIAL;
+SELECT * FROM t1;
+INSERT INTO t1 VALUES(NULL, 3);
+INSERT INTO t1 VALUES(NULL, 4);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# Bug# 42714: AUTOINC column calculated next value not greater than highest
+# value stored in table.
+#
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+ a INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ b INT(10) UNSIGNED NOT NULL,
+ c ENUM('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (a)) ENGINE = InnoDB;
+CREATE TABLE t2 (
+ m INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ n INT(10) UNSIGNED NOT NULL,
+ o enum('FALSE','TRUE') DEFAULT NULL,
+ PRIMARY KEY (m)) ENGINE = InnoDB;
+INSERT INTO t2 (n,o) VALUES
+ (1 , 'true'), (1 , 'false'), (2 , 'true'), (2 , 'false'), (3 , 'true'),
+ (3 , 'false'), (4 , 'true'), (4 , 'false'), (5 , 'true'), (5 , 'false');
+SHOW CREATE TABLE t2;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 ;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 (b,c) SELECT n,o FROM t2 WHERE o = 'false';
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+DROP TABLE t2;
+#
+# 43203: Overflow from auto incrementing causes server segv
+#
+
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1(
+ c1 INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
+ PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
+CREATE TABLE t2(
+ c1 TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT
+ PRIMARY KEY) ENGINE=InnoDB;
+-- error ER_DUP_ENTRY,1062
+INSERT INTO t2 SELECT c1 FROM t1;
+-- error ER_DUP_ENTRY,1467
+INSERT INTO t2 SELECT NULL FROM t1;
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/t/innodb-semi-consistent.test b/mysql-test/t/innodb-semi-consistent.test
index 6d3020bb560..61ad7815ca9 100644
--- a/mysql-test/t/innodb-semi-consistent.test
+++ b/mysql-test/t/innodb-semi-consistent.test
@@ -53,3 +53,16 @@ drop table t1;
connection default;
disconnect a;
disconnect b;
+
+# Bug 39320
+create table t1 (a int, b int) engine=myisam;
+create table t2 (c int, d int, key (c)) engine=innodb;
+insert into t1 values (1,1);
+insert into t2 values (1,2);
+connect (a,localhost,root,,);
+connection a;
+set session transaction isolation level read committed;
+delete from t1 using t1 join t2 on t1.a = t2.c where t2.d in (1);
+connection default;
+disconnect a;
+drop table t1, t2;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index b0353ed5268..42c24324ebc 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -6,22 +6,45 @@
# Use innodb_mysql.[test|result] files instead. #
# #
# If nevertheless you need to make some changes here, please, forward #
-# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com #
+# your commit message #
+# To: innodb_dev_ww@oracle.com #
+# Cc: dev-innodb@mysql.com #
# (otherwise your changes may be erased). #
# #
#######################################################################
-- source include/have_innodb.inc
-#
-# Small basic test with ignore
-#
+# Save the original values of some variables in order to be able to
+# estimate how much they have changed during the tests. Previously this
+# test assumed that e.g. rows_deleted is 0 here and after deleting 23
+# rows it expected that rows_deleted will be 23. Now we do not make
+# assumptions about the values of the variables at the beginning, e.g.
+# rows_deleted should be 23 + "rows_deleted before the test". This allows
+# the test to be run multiple times without restarting the mysqld server.
+# See Bug#43309 Test main.innodb can't be run twice
+-- disable_query_log
+SET @innodb_thread_concurrency_orig = @@innodb_thread_concurrency;
+
+SET @innodb_rows_deleted_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted');
+SET @innodb_rows_inserted_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted');
+SET @innodb_rows_updated_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated');
+SET @innodb_row_lock_waits_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits');
+SET @innodb_row_lock_current_waits_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits');
+SET @innodb_row_lock_time_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time');
+SET @innodb_row_lock_time_max_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max');
+SET @innodb_row_lock_time_avg_orig = (SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg');
+-- enable_query_log
--disable_warnings
drop table if exists t1,t2,t3,t4;
drop database if exists mysqltest;
--enable_warnings
+#
+# Small basic test with ignore
+#
+
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb;
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
@@ -1294,18 +1317,18 @@ drop table t1;
# Test for testable InnoDB status variables. This test
# uses previous ones(pages_created, rows_deleted, ...).
-show status like "Innodb_buffer_pool_pages_total";
-show status like "Innodb_page_size";
-show status like "Innodb_rows_deleted";
-show status like "Innodb_rows_inserted";
-show status like "Innodb_rows_updated";
+SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
+SELECT variable_value FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_page_size';
+SELECT variable_value - @innodb_rows_deleted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_deleted';
+SELECT variable_value - @innodb_rows_inserted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted';
+SELECT variable_value - @innodb_rows_updated_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated';
# Test for row locks InnoDB status variables.
-show status like "Innodb_row_lock_waits";
-show status like "Innodb_row_lock_current_waits";
-show status like "Innodb_row_lock_time";
-show status like "Innodb_row_lock_time_max";
-show status like "Innodb_row_lock_time_avg";
+SELECT variable_value - @innodb_row_lock_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_waits';
+SELECT variable_value - @innodb_row_lock_current_waits_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_current_waits';
+SELECT variable_value - @innodb_row_lock_time_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time';
+SELECT variable_value - @innodb_row_lock_time_max_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_max';
+SELECT variable_value - @innodb_row_lock_time_avg_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_row_lock_time_avg';
# Test for innodb_sync_spin_loops variable
show variables like "innodb_sync_spin_loops";
@@ -2524,6 +2547,8 @@ DROP TABLE bug35537;
DISCONNECT c1;
CONNECTION default;
+SET GLOBAL innodb_thread_concurrency = @innodb_thread_concurrency_orig;
+
#######################################################################
# #
# Please, DO NOT TOUCH this file as well as the innodb.result file. #
@@ -2532,7 +2557,9 @@ CONNECTION default;
# Use innodb_mysql.[test|result] files instead. #
# #
# If nevertheless you need to make some changes here, please, forward #
-# your commit message To: dev@innodb.com Cc: dev-innodb@mysql.com #
+# your commit message #
+# To: innodb_dev_ww@oracle.com #
+# Cc: dev-innodb@mysql.com #
# (otherwise your changes may be erased). #
# #
#######################################################################
diff --git a/mysql-test/t/innodb_bug42419.test b/mysql-test/t/innodb_bug42419.test
new file mode 100644
index 00000000000..93c4764252a
--- /dev/null
+++ b/mysql-test/t/innodb_bug42419.test
@@ -0,0 +1,78 @@
+#
+# Testcase for InnoDB
+# Bug#42419 Server crash with "Pure virtual method called" on two concurrent connections
+#
+
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+
+let $innodb_lock_wait_timeout= query_get_value(SHOW VARIABLES LIKE 'innodb_lock_wait_timeout%', Value, 1);
+if (`SELECT $innodb_lock_wait_timeout < 10`)
+{
+ --echo # innodb_lock_wait_timeout must be >= 10 seconds
+ --echo # so that this test can work all time fine on an overloaded testing box
+ SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';
+ exit;
+}
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+# First session
+connection default;
+
+
+--enable_warnings
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b INT) ENGINE = InnoDB;
+
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+COMMIT;
+SET AUTOCOMMIT = 0;
+
+CREATE TEMPORARY TABLE t1_tmp ( b INT );
+
+INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 3;
+INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 2;
+
+# Second session
+connect (user2,localhost,root,,,$MASTER_MYPORT,$MASTER_MYSOCK);
+
+SET AUTOCOMMIT = 0;
+
+CREATE TEMPORARY TABLE t2_tmp ( a int, new_a int );
+INSERT INTO t2_tmp VALUES (1,51),(2,52),(3,53);
+
+UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 1;
+send
+UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 2;
+
+# The last update will wait for a lock held by the first session
+
+# First session
+connection default;
+
+# Poll till the UPDATE of the second session waits for lock
+let $show_statement= SHOW PROCESSLIST;
+let $field= State;
+let $condition= = 'Updating';
+--source include/wait_show_condition.inc
+
+# If the testing box is overloadeded and innodb_lock_wait_timeout is too small
+# we might get here ER_LOCK_WAIT_TIMEOUT.
+--error ER_LOCK_DEADLOCK
+INSERT INTO t1_tmp (b) SELECT b FROM t1 WHERE a = 1;
+
+# Second session
+connection user2;
+--echo Reap the server message for connection user2 UPDATE t1 ...
+reap;
+
+# The server crashed when executing this UPDATE or the succeeding SQL command.
+UPDATE t1 SET a = (SELECT new_a FROM t2_tmp WHERE t2_tmp.a = t1.a) WHERE a = 3;
+
+connection default;
+disconnect user2;
+DROP TABLE t1;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index 21ee440f10b..ad9e726f5b4 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -91,6 +91,7 @@ INSERT INTO foo2 SELECT * FROM foo;
DROP TABLE foo, bar, foo2;
+
#
# Bug#41348: INSERT INTO tbl SELECT * FROM temp_tbl overwrites locking type of temp table
#
@@ -184,4 +185,151 @@ TRUNCATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;
+--echo #
+--echo # Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0
+--echo #
+CREATE TABLE t1 (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB;
+
+CREATE TABLE t2 (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ aid INT UNSIGNED NOT NULL,
+ PRIMARY KEY (id),
+ FOREIGN KEY (aid) REFERENCES t1 (id)
+) ENGINE=InnoDB;
+
+CREATE TABLE t3 (
+ bid INT UNSIGNED NOT NULL,
+ FOREIGN KEY (bid) REFERENCES t2 (id)
+) ENGINE=InnoDB;
+
+CREATE TABLE t4 (
+ a INT
+) ENGINE=InnoDB;
+
+CREATE TABLE t5 (
+ a INT
+) ENGINE=InnoDB;
+
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id, aid) VALUES (1, 1),(2,1),(3,1),(4,1);
+INSERT INTO t3 (bid) VALUES (1);
+
+INSERT INTO t4 VALUES (1),(2),(3),(4),(5);
+INSERT INTO t5 VALUES (1);
+
+DELETE t5 FROM t4 LEFT JOIN t5 ON t4.a= t5.a;
+
+--error ER_ROW_IS_REFERENCED_2
+DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
+--error ER_ROW_IS_REFERENCED_2
+DELETE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
+
+DELETE IGNORE t2, t1 FROM t2 INNER JOIN t1 ON (t2.aid = t1.id) WHERE t2.id = 1;
+
+DROP TABLE t3;
+DROP TABLE t2;
+DROP TABLE t1;
+DROP TABLES t4,t5;
+
+--echo # Bug#40127 Multiple table DELETE IGNORE hangs on foreign key constraint violation on 5.0
+--echo # Testing for any side effects of IGNORE on AFTER DELETE triggers used with
+--echo # transactional tables.
+--echo #
+CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t2 (a VARCHAR(100)) ENGINE=InnoDB;
+CREATE TABLE t3 (i INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
+CREATE TABLE t4 (i INT NOT NULL PRIMARY KEY, t1i INT,
+ FOREIGN KEY (t1i) REFERENCES t1(i))
+ ENGINE=InnoDB;
+delimiter ||;
+CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+ SET @b:='EXECUTED TRIGGER';
+ INSERT INTO t2 VALUES (@b);
+ SET @a:= error_happens_here;
+END||
+delimiter ;||
+
+SET @b:="";
+SET @a:="";
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t3 SELECT * FROM t1;
+--echo ** An error in a trigger causes rollback of the statement.
+--error ER_BAD_FIELD_ERROR
+DELETE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+SELECT @a,@b;
+SELECT * FROM t2;
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+
+--echo ** Same happens with the IGNORE option
+--error ER_BAD_FIELD_ERROR
+DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+SELECT * FROM t2;
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+
+--echo **
+--echo ** The following is an attempt to demonstrate
+--echo ** error handling inside a row iteration.
+--echo **
+DROP TRIGGER trg;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+TRUNCATE TABLE t3;
+
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t3 VALUES (1),(2),(3),(4);
+INSERT INTO t4 VALUES (3,3),(4,4);
+
+delimiter ||;
+CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+ SET @b:= CONCAT('EXECUTED TRIGGER FOR ROW ',CAST(OLD.i AS CHAR));
+ INSERT INTO t2 VALUES (@b);
+END||
+delimiter ;||
+
+--echo ** DELETE is prevented by foreign key constrains but errors are silenced.
+--echo ** The AFTER trigger isn't fired.
+DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+--echo ** Tables are modified by best effort:
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+--echo ** The AFTER trigger was only executed on successful rows:
+SELECT * FROM t2;
+
+DROP TRIGGER trg;
+
+--echo **
+--echo ** Induce an error midway through an AFTER-trigger
+--echo **
+TRUNCATE TABLE t4;
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t3;
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t3 VALUES (1),(2),(3),(4);
+delimiter ||;
+CREATE TRIGGER trg AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+ SET @a:= @a+1;
+ IF @a > 2 THEN
+ INSERT INTO t4 VALUES (5,5);
+ END IF;
+END||
+delimiter ;||
+
+SET @a:=0;
+--echo ** Errors in the trigger causes the statement to abort.
+--error ER_NO_REFERENCED_ROW_2
+DELETE IGNORE t1 FROM t3 LEFT JOIN t1 ON t1.i=t3.i;
+SELECT * FROM t1 LEFT JOIN t3 ON t1.i=t3.i;
+SELECT * FROM t4;
+
+DROP TRIGGER trg;
+DROP TABLE t4;
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index c58fb61ad30..8f9ed6c7d06 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -488,5 +488,14 @@ SELECT * FROM t2;
DROP TABLE t1, t2;
+#
+# Bug#43833 Simple INSERT crashes the server
+#
+CREATE TABLE t1(f1 FLOAT);
+INSERT INTO t1 VALUES (1.23);
+CREATE TABLE t2(f1 CHAR(1));
+INSERT INTO t2 SELECT f1 FROM t1;
+DROP TABLE t1, t2;
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test
index 6069bbf7018..30f4d4d6c61 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -214,4 +214,34 @@ create view v_bug5719 as select * from t2;
--echo
drop table t2, t3;
+--echo #
+--echo # Bug#39843 DELETE requires write access to table in subquery in where clause
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+CREATE TABLE t1 (
+table1_rowid SMALLINT NOT NULL
+);
+CREATE TABLE t2 (
+table2_rowid SMALLINT NOT NULL
+);
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+LOCK TABLES t1 WRITE, t2 READ;
+--echo # Sub-select should not try to aquire a write lock.
+DELETE FROM t1
+WHERE EXISTS
+(
+SELECT 'x'
+FROM t2
+WHERE t1.table1_rowid = t2.table2_rowid
+) ;
+--echo # While implementing the patch we didn't break old behavior;
+--echo # The following sub-select should still requires a write lock:
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+SELECT * FROM t1 WHERE 1 IN (SELECT * FROM t2 FOR UPDATE);
+UNLOCK TABLES;
+DROP TABLE t1,t2;
+
--echo End of 5.1 tests.
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 08747b0f92e..47b5aa0292b 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -1,4 +1,8 @@
-- source include/not_embedded.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
@@ -14,14 +18,18 @@ create table t1(n int);
insert into t1 values (1);
lock tables t1 write;
connection writer;
-send update low_priority t1 set n = 4;
+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";
--source include/wait_condition.inc
-send select n from t1;
+send
+select n from t1;
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 = "Locked" and info = "select n from t1";
@@ -38,8 +46,10 @@ create table t1(n int);
insert into t1 values (1);
lock tables t1 read;
connection writer;
-send update low_priority t1 set n = 4;
+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";
@@ -72,7 +82,7 @@ drop table t1;
drop table t2;
#
-# Test problem when using locks on many tables and droping a table that
+# Test problem when using locks on many tables and dropping a table that
# is to-be-locked by another thread
#
#
@@ -81,7 +91,8 @@ create table t1 (a int);
create table t2 (a int);
lock table t1 write, t2 write;
connection reader;
-send insert t1 select * from t2;
+send
+insert t1 select * from t2;
connection locker;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
@@ -89,7 +100,7 @@ let $wait_condition=
--source include/wait_condition.inc
drop table t2;
connection reader;
---error 1146
+--error ER_NO_SUCH_TABLE
reap;
connection locker;
drop table t1;
@@ -103,15 +114,17 @@ create table t1 (a int);
create table t2 (a int);
lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
connection reader;
-send insert t1 select * from t2;
+send
+insert t1 select * from t2;
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";
--source include/wait_condition.inc
drop table t2;
connection reader;
---error 1146
+--error ER_NO_SUCH_TABLE
reap;
connection locker;
drop table t1;
@@ -120,7 +133,7 @@ drop table t1;
--echo End of 4.1 tests
#
-# BUG#9998 - MySQL client hangs on USE "database"
+# Bug#9998 MySQL client hangs on USE "database"
#
create table t1(a int);
lock tables t1 write;
@@ -131,26 +144,28 @@ unlock tables;
drop table t1;
#
-# Bug#16986 - Deadlock condition with MyISAM tables
+# Bug#16986 Deadlock condition with MyISAM tables
#
# Need a matching user in mysql.user for multi-table select
--source include/add_anonymous_users.inc
connection locker;
-use mysql;
+USE mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES;
#
connection reader;
-use mysql;
-#NOTE: This must be a multi-table select, otherwise the deadlock will not occur
-send SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
+USE mysql;
+# Note: This must be a multi-table select, otherwise the deadlock will not occur
+send
+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 =
+ where state = "Waiting for table" 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.
@@ -160,7 +175,7 @@ UNLOCK TABLES;
#
connection reader;
reap;
-use test;
+USE test;
#
connection locker;
use test;
@@ -175,9 +190,11 @@ LOCK TABLE t1 WRITE;
#
# This waits until t1 is unlocked.
connection locker;
-send FLUSH TABLES WITH READ LOCK;
+send
+FLUSH TABLES WITH READ LOCK;
#
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";
@@ -202,15 +219,17 @@ LOCK TABLE t1 WRITE;
#
# This waits until t1 is unlocked.
connection locker;
-send FLUSH TABLES WITH READ LOCK;
+send
+FLUSH TABLES WITH READ LOCK;
#
# This must not block.
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";
--source include/wait_condition.inc
---error 1100
+--error ER_TABLE_NOT_LOCKED
CREATE TABLE t2 AS SELECT * FROM t1;
UNLOCK TABLES;
#
@@ -225,7 +244,7 @@ DROP TABLE t1;
--source include/delete_anonymous_users.inc
#
-# Bug#19815 - CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
+# Bug#19815 CREATE/RENAME/DROP DATABASE can deadlock on a global read lock
#
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
@@ -237,11 +256,13 @@ FLUSH TABLES WITH READ LOCK;
# With bug in place: acquire LOCK_mysql_create_table and
# wait in wait_if_global_read_lock().
connection con2;
-send DROP DATABASE mysqltest_1;
+send
+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"
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for release of readlock"
@@ -263,7 +284,7 @@ disconnect con2;
DROP DATABASE mysqltest_1;
#
-# Bug #17264: MySQL Server freeze
+# Bug#17264 MySQL Server freeze
#
connection locker;
# Disable warnings to allow test to run also without InnoDB
@@ -272,14 +293,18 @@ create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) e
--enable_warnings
lock tables t1 write;
connection writer;
-send alter table t1 auto_increment=0;
+send
+alter table t1 auto_increment=0;
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";
--source include/wait_condition.inc
-send alter table t1 auto_increment=0;
+send
+alter table t1 auto_increment=0;
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";
@@ -293,344 +318,154 @@ connection locker;
drop table t1;
#
-# Bug #38691: segfault/abort in ``UPDATE ...JOIN'' while
-# ``FLUSH TABLES WITH READ LOCK''
+# Bug#43230: SELECT ... FOR UPDATE can hang with FLUSH TABLES WITH READ LOCK indefinitely
#
---connection default
-CREATE TABLE t1 (
- a int(11) unsigned default NULL,
- b varchar(255) default NULL,
- UNIQUE KEY a (a),
- KEY b (b)
-);
-
-INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
-CREATE TABLE t2 SELECT * FROM t1;
-CREATE TABLE t3 SELECT * FROM t1;
-
---echo # test altering of columns that multiupdate doesn't use
-
---echo # normal mode
-
---disable_query_log
-let $i = 100;
-while ($i) {
---dec $i
-
---connection writer
- send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
- SET a = NULL WHERE t1.b <> t2.b;
-
---connection locker
- ALTER TABLE t2 ADD COLUMN (c INT);
- ALTER TABLE t2 DROP COLUMN c;
-
---connection writer
---reap
-}
-
---echo # PS mode
-
---connection writer
-PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
- SET a = NULL WHERE t1.b <> t2.b';
-
-let $i = 100;
-while ($i) {
---dec $i
-
---connection writer
---send EXECUTE stmt
-
---connection locker
- ALTER TABLE t2 ADD COLUMN (c INT);
- ALTER TABLE t2 DROP COLUMN c;
-
---connection writer
---reap
-}
---enable_query_log
-
-
---echo # test altering of columns that multiupdate uses
-
---echo # normal mode
-
---connection default
-
---disable_query_log
-let $i = 100;
-while ($i) {
- dec $i;
-
---connection locker
---error 0,1060
- ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
- UPDATE t2 SET a=b;
-
---connection writer
---send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b
-
---connection locker
---error 0,1091
- ALTER TABLE t2 DROP COLUMN a;
-
---connection writer
---error 0,1054
---reap
-}
---enable_query_log
-
---echo # PS mode
-
---disable_query_log
-let $i = 100;
-while ($i) {
- dec $i;
-
---connection locker
---error 0,1060
- ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
- UPDATE t2 SET a=b;
-
---connection writer
- PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b';
---send EXECUTE stmt
-
---connection locker
---error 0,1091
- ALTER TABLE t2 DROP COLUMN a;
-
---connection writer
---error 0,1054
---reap
-
-}
---enable_query_log
---connection default
-DROP TABLE t1, t2, t3;
-
-#
-# Bug#38499: flush tables and multitable table update with derived table cause
-# crash
-#
-
-CREATE TABLE t1( a INT, b INT );
-INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
-
---echo # 1. test regular tables
---echo # 1.1. test altering of columns that multiupdate doesn't use
---echo # 1.1.1. normal mode
-
---disable_query_log
-let $i = 100;
-while ($i) {
---dec $i
-
---connection writer
- send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
-
---connection locker
- ALTER TABLE t1 ADD COLUMN (c INT);
- ALTER TABLE t1 DROP COLUMN c;
-
---connection writer
---reap
-}
-
---echo # 1.1.2. PS mode
-
---connection writer
-PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
-
-let $i = 100;
-while ($i) {
---dec $i
-
---connection writer
---send EXECUTE stmt
-
---connection locker
- ALTER TABLE t1 ADD COLUMN (c INT);
- ALTER TABLE t1 DROP COLUMN c;
-
---connection writer
---reap
-}
---enable_query_log
-
---echo # 1.2. test altering of columns that multiupdate uses
---echo # 1.2.1. normal mode
-
---connection default
-
---disable_query_log
-let $i = 100;
-while ($i) {
- dec $i;
-
---connection locker
---error 0,1060
- ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
- UPDATE t1 SET a=b;
-
---connection writer
---send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
-
---connection locker
---error 0,1091
- ALTER TABLE t1 DROP COLUMN a;
-
---connection writer
---error 0,1054 # unknown column error
---reap
-}
---enable_query_log
-
---echo # 1.2.2. PS mode
-
---disable_query_log
-let $i = 100;
-while ($i) {
- dec $i;
-
---connection locker
---error 0,1060
- ALTER TABLE t1 ADD COLUMN a INT;
- UPDATE t1 SET a=b;
-
---connection writer
- PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
---send EXECUTE stmt
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+connect (con3,localhost,root,,);
+connect (con4,localhost,root,,);
+connect (con5,localhost,root,,);
---connection locker
---error 0,1091
- ALTER TABLE t1 DROP COLUMN a;
+create table t1 (a int);
+create table t2 like t1;
---connection writer
---error 0,1054 # Unknown column 'a' in 'field list'
+connection con1;
+--echo # con1
+lock tables t1 write;
+connection con2;
+--echo # 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
+--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
+--echo # waiting for release of read lock
+connection con4;
+--echo # con4
+--echo # would hang and later cause a deadlock
+flush tables t2;
+connection con1;
+--echo # clean up
+unlock tables;
+connection con2;
--reap
-}
---enable_query_log
---connection default
-ALTER TABLE t1 ADD COLUMN a INT;
-
---echo # 2. test UNIONs
---echo # 2.1. test altering of columns that multiupdate doesn't use
---echo # 2.1.1. normal mode
-
---disable_query_log
-let $i = 100;
-while ($i) {
---dec $i
-
---connection writer
- send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
-
---connection locker
- ALTER TABLE t1 ADD COLUMN (c INT);
- ALTER TABLE t1 DROP COLUMN c;
-
---connection writer
+unlock tables;
+connection con3;
--reap
-}
+connection default;
+disconnect con5;
+disconnect con4;
+disconnect con3;
+disconnect con2;
+disconnect con1;
---echo # 2.1.2. PS mode
+drop table t1,t2;
---connection writer
-PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
+--echo #
+--echo # Lightweight version:
+--echo # Ensure that the wait for a GRL is done before opening tables.
+--echo #
-let $i = 100;
-while ($i) {
---dec $i
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
---connection writer
---send EXECUTE stmt
+create table t1 (a int);
+create table t2 like t1;
---connection locker
- ALTER TABLE t1 ADD COLUMN (c INT);
- ALTER TABLE t1 DROP COLUMN c;
+--echo #
+--echo # UPDATE
+--echo #
---connection writer
+connection default;
+--echo # default
+flush tables with read lock;
+connection con1;
+--echo # 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
+--echo # statement is waiting for release of read lock
+connection con2;
+--echo # con2
+flush table t2;
+connection default;
+--echo # default
+unlock tables;
+connection con1;
+--echo # con1
--reap
-}
---enable_query_log
-
---echo # 2.2. test altering of columns that multiupdate uses
---echo # 2.2.1. normal mode
-
---connection default
-
---disable_query_log
-let $i = 100;
-while ($i) {
- dec $i;
-
---connection locker
---error 0,1060
- ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
- UPDATE t1 SET a=b;
---connection writer
---send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
+--echo #
+--echo # LOCK TABLES .. WRITE
+--echo #
---connection locker
---error 0,1091
- ALTER TABLE t1 DROP COLUMN a;
-
---connection writer
---error 0,1054 # Unknown column 'a' in 'field list'
+connection default;
+--echo # default
+flush tables with read lock;
+connection con1;
+--echo # 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
+--echo # statement is waiting for release of read lock
+connection con2;
+--echo # con2
+flush table t2;
+connection default;
+--echo # default
+unlock tables;
+connection con1;
+--echo # con1
--reap
-}
---enable_query_log
-
---echo # 2.2.2. PS mode
-
---disable_query_log
-let $i = 100;
-while ($i) {
- dec $i;
+unlock tables;
---connection locker
---error 0,1060
- ALTER TABLE t1 ADD COLUMN a INT;
- UPDATE t1 SET a=b;
+connection default;
+disconnect con2;
+disconnect con1;
---connection writer
- PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
---send EXECUTE stmt
+drop table t1,t2;
---connection locker
---error 0,1091
- ALTER TABLE t1 DROP COLUMN a;
-
---connection writer
---error 0,1054 # Unknown column 'a' in 'field list'
---reap
-}
---enable_query_log
---connection default
-DROP TABLE t1;
--echo End of 5.0 tests
#
-# Bug #21281 "Pending write lock is incorrectly removed when its
-# statement being KILLed"
+# Bug#21281 Pending write lock is incorrectly removed when its
+# statement being KILLed
#
create table t1 (i int);
connection locker;
lock table t1 read;
connection writer;
---send update t1 set i= 10;
+send
+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";
--source include/wait_condition.inc
---send select * from t1;
+send
+select * from t1;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
@@ -642,7 +477,7 @@ eval kill query $ID;
connection reader;
--reap
connection writer;
---error ER_QUERY_INTERRUPTED
+--error ER_QUERY_INTERRUPTED
--reap
connection locker;
unlock tables;
@@ -650,7 +485,7 @@ connection default;
drop table t1;
#
-# Bug#25856 - HANDLER table OPEN in one connection lock DROP TABLE in another one
+# Bug#25856 HANDLER table OPEN in one connection lock DROP TABLE in another one
#
--disable_warnings
drop table if exists t1;
@@ -658,12 +493,19 @@ drop table if exists t1;
create table t1 (a int) ENGINE=MEMORY;
--echo --> client 2
connection locker;
---error 1031
+--error ER_ILLEGAL_HA
handler t1 open;
--echo --> client 1
connection default;
drop table t1;
+
+# Disconnect sessions used in many subtests above
+disconnect locker;
+disconnect reader;
+disconnect writer;
+
+
#
# Bug#32395 Alter table under a impending global read lock causes a server crash
#
@@ -764,7 +606,7 @@ disconnect flush;
drop table t1;
#
-# Bug#30331: Table_locks_waited shows inaccurate values
+# Bug#30331 Table_locks_waited shows inaccurate values
#
--disable_warnings
@@ -794,3 +636,7 @@ eval SET @tlwb= SUBSTRING_INDEX('$tlwb', ' ', -1);
select @tlwa < @tlwb;
--echo End of 5.1 tests
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/lock_multi_bug38499.test b/mysql-test/t/lock_multi_bug38499.test
new file mode 100644
index 00000000000..8178987e802
--- /dev/null
+++ b/mysql-test/t/lock_multi_bug38499.test
@@ -0,0 +1,221 @@
+# Bug38499 flush tables and multitable table update with derived table cause crash
+# MySQL >= 5.0
+#
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+connect (locker,localhost,root,,);
+connect (writer,localhost,root,,);
+
+--connection default
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1( a INT, b INT );
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
+
+--echo # 1. test regular tables
+--echo # 1.1. test altering of columns that multiupdate doesn't use
+--echo # 1.1.1. normal mode
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+--dec $i
+
+--connection writer
+ send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
+
+--connection locker
+ ALTER TABLE t1 ADD COLUMN (c INT);
+ ALTER TABLE t1 DROP COLUMN c;
+
+--connection writer
+--reap
+}
+
+--echo # 1.1.2. PS mode
+
+--connection writer
+PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
+
+let $i = 100;
+while ($i) {
+--dec $i
+
+--connection writer
+--send EXECUTE stmt
+
+--connection locker
+ ALTER TABLE t1 ADD COLUMN (c INT);
+ ALTER TABLE t1 DROP COLUMN c;
+
+--connection writer
+--reap
+}
+--enable_query_log
+
+--echo # 1.2. test altering of columns that multiupdate uses
+--echo # 1.2.1. normal mode
+
+--connection default
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+ dec $i;
+
+--connection locker
+--error 0,ER_DUP_FIELDNAME
+ ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
+ UPDATE t1 SET a=b;
+
+--connection writer
+--send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
+
+--connection locker
+--error 0,ER_CANT_DROP_FIELD_OR_KEY
+ ALTER TABLE t1 DROP COLUMN a;
+
+--connection writer
+--error 0,ER_BAD_FIELD_ERROR # unknown column error
+--reap
+}
+--enable_query_log
+
+--echo # 1.2.2. PS mode
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+ dec $i;
+
+--connection locker
+--error 0,ER_DUP_FIELDNAME
+ ALTER TABLE t1 ADD COLUMN a INT;
+ UPDATE t1 SET a=b;
+
+--connection writer
+ PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
+--send EXECUTE stmt
+
+--connection locker
+--error 0,ER_CANT_DROP_FIELD_OR_KEY
+ ALTER TABLE t1 DROP COLUMN a;
+
+--connection writer
+--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
+--reap
+}
+--enable_query_log
+--connection default
+ALTER TABLE t1 ADD COLUMN a INT;
+
+--echo # 2. test UNIONs
+--echo # 2.1. test altering of columns that multiupdate doesn't use
+--echo # 2.1.1. normal mode
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+--dec $i
+
+--connection writer
+ send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
+
+--connection locker
+ ALTER TABLE t1 ADD COLUMN (c INT);
+ ALTER TABLE t1 DROP COLUMN c;
+
+--connection writer
+--reap
+}
+
+--echo # 2.1.2. PS mode
+
+--connection writer
+PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
+
+let $i = 100;
+while ($i) {
+--dec $i
+
+--connection writer
+--send EXECUTE stmt
+
+--connection locker
+ ALTER TABLE t1 ADD COLUMN (c INT);
+ ALTER TABLE t1 DROP COLUMN c;
+
+--connection writer
+--reap
+}
+--enable_query_log
+
+--echo # 2.2. test altering of columns that multiupdate uses
+--echo # 2.2.1. normal mode
+
+--connection default
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+ dec $i;
+
+--connection locker
+--error 0,ER_DUP_FIELDNAME
+ ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
+ UPDATE t1 SET a=b;
+
+--connection writer
+--send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
+
+--connection locker
+--error 0,ER_CANT_DROP_FIELD_OR_KEY
+ ALTER TABLE t1 DROP COLUMN a;
+
+--connection writer
+--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
+--reap
+}
+--enable_query_log
+
+--echo # 2.2.2. PS mode
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+ dec $i;
+
+--connection locker
+--error 0,ER_DUP_FIELDNAME
+ ALTER TABLE t1 ADD COLUMN a INT;
+ UPDATE t1 SET a=b;
+
+--connection writer
+ PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
+--send EXECUTE stmt
+
+--connection locker
+--error 0,ER_CANT_DROP_FIELD_OR_KEY
+ ALTER TABLE t1 DROP COLUMN a;
+
+--connection writer
+--error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
+--reap
+}
+--enable_query_log
+--connection default
+DROP TABLE t1;
+
+
+# Close connections
+--disconnect locker
+--disconnect writer
+
+# End of 5.0 tests
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/lock_multi_bug38691.test b/mysql-test/t/lock_multi_bug38691.test
new file mode 100644
index 00000000000..0458f31579e
--- /dev/null
+++ b/mysql-test/t/lock_multi_bug38691.test
@@ -0,0 +1,141 @@
+#
+# Bug#38691 segfault/abort in ``UPDATE ...JOIN'' while
+# ``FLUSH TABLES WITH READ LOCK''
+# MySQL >= 5.0
+#
+
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+# Test to see if select will get the lock ahead of low priority update
+
+connect (locker,localhost,root,,);
+connect (writer,localhost,root,,);
+
+--connection default
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+--enable_warnings
+
+CREATE TABLE t1 (
+ a int(11) unsigned default NULL,
+ b varchar(255) default NULL,
+ UNIQUE KEY a (a),
+ KEY b (b)
+);
+
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+CREATE TABLE t2 SELECT * FROM t1;
+CREATE TABLE t3 SELECT * FROM t1;
+
+--echo # test altering of columns that multiupdate doesn't use
+
+--echo # normal mode
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+--dec $i
+
+--connection writer
+ send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
+ SET a = NULL WHERE t1.b <> t2.b;
+
+--connection locker
+ ALTER TABLE t2 ADD COLUMN (c INT);
+ ALTER TABLE t2 DROP COLUMN c;
+
+--connection writer
+--reap
+}
+
+--echo # PS mode
+
+--connection writer
+PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a)
+ SET a = NULL WHERE t1.b <> t2.b';
+
+let $i = 100;
+while ($i) {
+--dec $i
+
+--connection writer
+--send EXECUTE stmt
+
+--connection locker
+ ALTER TABLE t2 ADD COLUMN (c INT);
+ ALTER TABLE t2 DROP COLUMN c;
+
+--connection writer
+--reap
+}
+--enable_query_log
+
+
+--echo # test altering of columns that multiupdate uses
+
+--echo # normal mode
+
+--connection default
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+ dec $i;
+
+--connection locker
+--error 0,ER_DUP_FIELDNAME
+ ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
+ UPDATE t2 SET a=b;
+
+--connection writer
+--send UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b
+
+--connection locker
+--error 0,ER_CANT_DROP_FIELD_OR_KEY
+ ALTER TABLE t2 DROP COLUMN a;
+
+--connection writer
+--error 0,ER_BAD_FIELD_ERROR
+--reap
+}
+--enable_query_log
+
+--echo # PS mode
+
+--disable_query_log
+let $i = 100;
+while ($i) {
+ dec $i;
+
+--connection locker
+--error 0,ER_DUP_FIELDNAME
+ ALTER TABLE t2 ADD COLUMN a int(11) unsigned default NULL;
+ UPDATE t2 SET a=b;
+
+--connection writer
+ PREPARE stmt FROM 'UPDATE t2 INNER JOIN (t1 JOIN t3 USING(a)) USING(a) SET a = NULL WHERE t1.b <> t2.b';
+--send EXECUTE stmt
+
+--connection locker
+--error 0,ER_CANT_DROP_FIELD_OR_KEY
+ ALTER TABLE t2 DROP COLUMN a;
+
+--connection writer
+--error 0,ER_BAD_FIELD_ERROR
+--reap
+
+}
+--enable_query_log
+--connection default
+DROP TABLE t1, t2, t3;
+
+
+# Close connections
+--disconnect locker
+--disconnect writer
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test
index 326914f09d9..076f2e8bc3b 100644
--- a/mysql-test/t/log_tables.test
+++ b/mysql-test/t/log_tables.test
@@ -287,7 +287,7 @@ CREATE TABLE `general_log` (
ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`thread_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`command_type` varchar(64) NOT NULL,
`argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
@@ -303,7 +303,7 @@ CREATE TABLE `slow_log` (
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
- `server_id` int(11) NOT NULL,
+ `server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
diff --git a/mysql-test/t/lowercase_table3.test b/mysql-test/t/lowercase_table3.test
index e71d9029606..4748953fe95 100644
--- a/mysql-test/t/lowercase_table3.test
+++ b/mysql-test/t/lowercase_table3.test
@@ -9,7 +9,7 @@
--source include/have_case_insensitive_file_system.inc
--source include/not_windows.inc
-call mtr.add_suppression("Cannot find or open table test/BUG29839 from");
+call mtr.add_suppression("Cannot find or open table test/BUG29839 from .*");
--disable_warnings
DROP TABLE IF EXISTS t1,T1;
@@ -18,11 +18,10 @@ DROP TABLE IF EXISTS t1,T1;
#
# This is actually an error, but ok as the user has forced this
# by using --lower-case-table-names=0
-
-CREATE TABLE t1 (a int);
-SELECT * from T1;
-drop table t1;
-flush tables;
+CREATE TABLE t1 (a INT);
+SELECT * FROM T1;
+FLUSH TABLES;
+DROP TABLE t1;
#
# InnoDB should in this case be case sensitive
@@ -30,9 +29,9 @@ flush tables;
# storing things in lower case.
#
-CREATE TABLE bug29839 (a int) ENGINE=INNODB;
---error 1146
-SELECT * from BUG29839;
-drop table bug29839;
+CREATE TABLE bug29839 (a INT) ENGINE=INNODB;
+--error ER_NO_SUCH_TABLE
+SELECT * FROM BUG29839;
+DROP TABLE bug29839;
# End of 4.1 tests
diff --git a/mysql-test/t/lowercase_utf8-master.opt b/mysql-test/t/lowercase_utf8-master.opt
new file mode 100644
index 00000000000..1b70aa33023
--- /dev/null
+++ b/mysql-test/t/lowercase_utf8-master.opt
@@ -0,0 +1,4 @@
+--lower-case-table-names=1 --character-set-server=utf8
+
+
+
diff --git a/mysql-test/t/lowercase_utf8.test b/mysql-test/t/lowercase_utf8.test
new file mode 100644
index 00000000000..01b154598fd
--- /dev/null
+++ b/mysql-test/t/lowercase_utf8.test
@@ -0,0 +1,9 @@
+#
+# Bug#25830 SHOW TABLE STATUS behaves differently depending on table name
+#
+set names utf8;
+create table `Ö` (id int);
+show tables from test like 'Ö';
+show tables from test like 'ö';
+drop table `Ö`;
+
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 118f8771f91..5315c91daa6 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -1418,8 +1418,6 @@ TABLE_SCHEMA = 'test' and TABLE_NAME='tm1';
DROP TABLE tm1;
---echo End of 5.1 tests
-
#
# Bug#36006 - Optimizer does table scan for select count(*)
#
@@ -1435,4 +1433,106 @@ EXPLAIN SELECT COUNT(*) FROM t1;
EXPLAIN SELECT COUNT(*) FROM t4;
DROP TABLE t1, t2, t3, t4;
+#
+# BUG#39185 - Cardinality for merge tables calculated incorrectly.
+#
+CREATE TABLE t1(a INT, KEY(a));
+INSERT INTO t1 VALUES(0),(1),(2),(3),(4);
+ANALYZE TABLE t1;
+CREATE TABLE m1(a INT, KEY(a)) ENGINE=MERGE UNION=(t1);
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1';
+DROP TABLE t1, m1;
+
+--echo #
+--echo # Bug #40675 MySQL 5.1 crash with index merge algorithm and Merge tables
+--echo #
+
+--echo # create MYISAM table t1 and insert values into it
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+
+--echo # create MYISAM table t2 and insert values into it
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) 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),(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),(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),(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),(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),
+(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),
+(1,2);
+
+--echo # Create the merge table t3
+CREATE TABLE t3(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b))
+ENGINE=MERGE UNION=(t2) INSERT_METHOD=FIRST;
+
+--echo # Lock tables t1 and t3 for write
+LOCK TABLES t1 WRITE, t3 WRITE;
+
+--echo # Insert values into the merge table t3
+INSERT INTO t3(a,b) VALUES(1,2);
+
+--echo # select from the join of t2 and t3 (The merge table)
+SELECT t3.a FROM t1,t3 WHERE t3.b=2 AND t3.a=1;
+
+--echo # Unlock the tables
+UNLOCK TABLES;
+
+--echo # drop the created tables
+DROP TABLE t1, t2, t3;
+
+#
+# Bug #41305 server crashes when inserting duplicate row into a merge table
+#
+--echo # insert duplicate value in child table while merge table doesn't have key
+create table t1 (
+ col1 int(10),
+ primary key (col1)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+CREATE TABLE m1 (
+ col1 int(10) NOT NULL
+) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(t1);
+
+insert into m1 (col1) values (1);
+--error ER_DUP_ENTRY
+insert into m1 (col1) values (1);
+
+drop table m1, t1;
+
+#
+#Bug #44040 MySQL allows creating a MERGE table upon VIEWs but crashes
+#when using it
+#
+
+CREATE TABLE t1 (
+ col1 INT(10)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+CREATE VIEW v1 as SELECT * FROM t1;
+CREATE TABLE m1 (
+ col1 INT(10)
+)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1);
+
+--echo #Select should detect that the child table is a view and fail.
+--error ER_WRONG_MRG_TABLE
+SELECT * FROM m1;
+
+DROP VIEW v1;
+DROP TABLE m1, t1;
--echo End of 5.1 tests
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 0793ef15faf..fc37fd6a27d 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -25,17 +25,17 @@ let $1 = 100;
while ($1)
{
let $2 = 5;
- eval insert into t1(t) values ('$1');
+ eval insert into t1(t) values ('$1');
while ($2)
{
- eval insert into t2(id2,t) values ($1,'$2');
+ eval insert into t2(id2,t) values ($1,'$2');
let $3 = 10;
while ($3)
{
- eval insert into t3(id3,t) values ($1,'$2');
+ eval insert into t3(id3,t) values ($1,'$2');
dec $3;
}
- dec $2;
+ dec $2;
}
dec $1;
}
@@ -80,11 +80,11 @@ let $1 = 1000;
while ($1)
{
let $2 = 5;
- eval insert into t1 values ($1,'aaaaaaaaaaaaaaaaaaaa');
+ eval insert into t1 values ($1,'aaaaaaaaaaaaaaaaaaaa');
while ($2)
{
- eval insert into t2(id2,t) values ($1,'bbbbbbbbbbbbbbbbb');
- dec $2;
+ eval insert into t2(id2,t) values ($1,'bbbbbbbbbbbbbbbbb');
+ dec $2;
}
dec $1;
}
@@ -318,7 +318,7 @@ update t2, t1 set t2.field=t1.field
delete t1, t2 from t2 inner join t1 on t1.id1=t2.id2
where 0=1;
-delete t1, t2 from t2,t1
+delete t1, t2 from t2,t1
where t1.id1=t2.id2 and 0=1;
drop table t1,t2;
@@ -352,7 +352,7 @@ create table `t2` (`c2_id` int(10) unsigned NULL auto_increment, `c2_p_id` int(1
insert into t1 values (0,'A01-Comp',1);
insert into t1 values (0,'B01-Comp',1);
insert into t2 values (0,1,'A Note',1);
-update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2;
+update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2;
select * from t1;
select * from t2;
drop table t1, t2;
@@ -380,6 +380,9 @@ revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1';
drop database mysqltest;
+connection default;
+disconnect user1;
+disconnect root;
#
# multi delete wrong table check
@@ -394,7 +397,7 @@ drop table t1, t2, t3;
#
# multi* unique updating table check
#
-create table t1 (col1 int);
+create table t1 (col1 int);
create table t2 (col1 int);
-- error ER_UPDATE_TABLE_USED
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
@@ -402,16 +405,16 @@ update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1;
drop table t1,t2;
-# Test for BUG#5837 - delete with outer join and const tables
+# Test for Bug#5837 delete with outer join and const tables
--disable_warnings
create table t1 (
- aclid bigint not null primary key,
- status tinyint(1) not null
+ aclid bigint not null primary key,
+ status tinyint(1) not null
) engine = innodb;
create table t2 (
- refid bigint not null primary key,
- aclid bigint, index idx_acl(aclid)
+ refid bigint not null primary key,
+ aclid bigint, index idx_acl(aclid)
) engine = innodb;
--enable_warnings
insert into t2 values(1,null);
@@ -419,7 +422,7 @@ delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
drop table t1, t2;
#
-# Bug#19225: unchecked error leads to server crash
+# Bug#19225 unchecked error leads to server crash
#
create table t1(a int);
create table t2(a int);
@@ -429,7 +432,7 @@ drop table t1, t2;
# End of 4.1 tests
#
-# Test for bug #1980.
+# Test for Bug#1980.
#
--disable_warnings
create table t1 ( c char(8) not null ) engine=innodb;
@@ -490,11 +493,22 @@ send alter table t1 add column c int default 100 after a;
connect (updater,localhost,root,,test);
connection updater;
-sleep 2;
+# Wait till "alter table t1 ..." of session changer is in work.
+# = There is one session is in state "Locked".
+let $wait_condition= select count(*)= 1 from information_schema.processlist
+ where state= 'Locked';
+--source include/wait_condition.inc
send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
connection locker;
-sleep 2;
+# Wait till
+# - "alter table t1 ..." of session changer and
+# - "update t1, v1 ..." of session updater
+# are in work.
+# = There are two session is in state "Locked".
+let $wait_condition= select count(*)= 2 from information_schema.processlist
+ where state= 'Locked';
+--source include/wait_condition.inc
unlock tables;
connection changer;
@@ -507,6 +521,11 @@ select * from t2;
drop view v1;
drop table t1, t2;
+connection default;
+disconnect locker;
+disconnect changer;
+disconnect updater;
+
#
# Test multi updates and deletes using primary key and without.
#
@@ -538,8 +557,9 @@ select * from t2 order by id;
drop table t1, t2;
#
-# Bug#27716 multi-update did partially and has not binlogged
+# Bug#27716 multi-update did partially and has not binlogged
#
+
CREATE TABLE `t1` (
`a` int(11) NOT NULL auto_increment,
`b` int(11) default NULL,
@@ -561,29 +581,29 @@ set @@session.binlog_format= mixed;
insert into t1 values (1,1),(2,2);
insert into t2 values (1,1),(4,4);
reset master;
-error ER_DUP_ENTRY;
+--error ER_DUP_ENTRY
UPDATE t2,t1 SET t2.a=t1.a+2;
# check
select * from t2 /* must be (3,1), (4,4) */;
show master status /* there must be the UPDATE query event */;
-# B. testing multi_update::send_error() ineffective update
-# (as there is a policy described at mysql_update() still go to binlog)
+# B. testing multi_update::send_error() ineffective update
+# (as there is a policy described at mysql_update() still go to binlog)
delete from t1;
delete from t2;
insert into t1 values (1,2),(3,4),(4,4);
insert into t2 values (1,2),(3,4),(4,4);
reset master;
-error ER_DUP_ENTRY;
+--error ER_DUP_ENTRY
UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
show master status /* there must be the UPDATE query event */;
-# cleanup bug#27716
+# cleanup
drop table t1, t2;
set @@session.binlog_format= @sav_binlog_format;
#
-# Bug #29136 erred multi-delete on trans table does not rollback
+# Bug#29136 erred multi-delete on trans table does not rollback
#
# prepare
@@ -610,7 +630,7 @@ delete t3.* from t2,t3 where t2.a=t3.a;
select count(*) from t1 /* must be 1 */;
select count(*) from t3 /* must be 1 */;
-# cleanup bug#29136
+# cleanup
drop table t1, t2, t3;
#
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 6d7e03b1c28..ba6bc05cfea 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1478,5 +1478,30 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1
DROP TABLE t1;
+#
+# Bug#43737: Select query return bad result
+#
+CREATE TABLE t1 (
+ c INT,
+ d bit(1),
+ e INT,
+ f VARCHAR(1),
+ g BIT(1),
+ h BIT(1),
+ KEY (h, d, e, g)
+);
+INSERT INTO t1 VALUES
+ ( 3, 1, 1, 'a', 0, 0 ),
+ ( 3, 1, 5, 'a', 0, 0 ),
+ ( 10, 1, 2, 'a', 0, 1 ),
+ ( 10, 1, 3, 'a', 0, 1 ),
+ ( 10, 1, 4, 'a', 0, 1 );
+
+SELECT f FROM t1 WHERE d = 1 AND e = 2 AND g = 0 AND h = 1;
+
+SELECT h+0, d + 0, e, g + 0 FROM t1;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/myisam_crash_before_flush_keys-master.opt b/mysql-test/t/myisam_crash_before_flush_keys-master.opt
new file mode 100644
index 00000000000..425fda95086
--- /dev/null
+++ b/mysql-test/t/myisam_crash_before_flush_keys-master.opt
@@ -0,0 +1 @@
+--skip-stack-trace --skip-core-file
diff --git a/mysql-test/t/myisam_crash_before_flush_keys.test b/mysql-test/t/myisam_crash_before_flush_keys.test
new file mode 100644
index 00000000000..d6559f7760d
--- /dev/null
+++ b/mysql-test/t/myisam_crash_before_flush_keys.test
@@ -0,0 +1,49 @@
+--echo #
+--echo # BUG#41330 - Myisam table open count set to zero before index blocks are written.
+--echo #
+--source include/not_embedded.inc
+--echo # Don't test this under valgrind, memory leaks will occur
+--source include/not_valgrind.inc
+
+--echo # Binary must be compiled with debug for crash to occur
+--source include/have_debug.inc
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+SET GLOBAL delay_key_write=ALL;
+CREATE TABLE t1(a INT,
+ b INT,
+ PRIMARY KEY(a , b),
+ KEY(b)) ENGINE=MyISAM DELAY_KEY_WRITE = 1;
+INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6);
+
+--echo # Setup the mysqld to crash at certain point
+SET SESSION debug="d,crash_before_flush_keys";
+
+--echo # Write file to make mysql-test-run.pl expect crash
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+--echo # Run the crashing query
+--error 2013
+FLUSH TABLE t1;
+
+--echo # Run MYISAMCHK tool to check the table t1 and repair
+--replace_result $MYISAMCHK MYISAMCHK $MYSQLD_DATADIR MYSQLD_DATADIR
+--error 255
+--exec $MYISAMCHK -cs $MYSQLD_DATADIR/test/t1 2>&1
+--exec $MYISAMCHK -rs $MYSQLD_DATADIR/test/t1
+
+--echo # Write file to make mysql-test-run.pl start the server
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+--echo # Turn on reconnect
+--enable_reconnect
+
+--echo # Call script that will poll the server waiting for
+--echo # it to be back online again
+--source include/wait_until_connected_again.inc
+
+SHOW CREATE TABLE t1;
+
+SELECT * FROM t1 FORCE INDEX (PRIMARY);
+
+DROP TABLE t1;
diff --git a/mysql-test/t/myisam_debug.test b/mysql-test/t/myisam_debug.test
new file mode 100644
index 00000000000..913668c5f22
--- /dev/null
+++ b/mysql-test/t/myisam_debug.test
@@ -0,0 +1,57 @@
+--source include/have_debug.inc
+
+# We disable this test in embedded mode because of BUG#43733
+--source include/not_embedded.inc
+
+--echo #
+--echo # BUG#40827 - Killing insert-select to MyISAM can cause table corruption
+--echo #
+
+CONNECT (insertConn, localhost, root,,);
+
+CREATE TABLE `t1` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+ KEY(id1), KEY(id)
+) ENGINE=MyISAM;
+
+CREATE TABLE `t2` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+ KEY (id1), KEY(id)
+) ENGINE=MyISAM;
+
+INSERT INTO t2 (id) VALUES (123);
+
+let $i = 10;
+while ($i)
+{
+ INSERT INTO t2 (id) SELECT id FROM t2;
+ dec $i;
+}
+
+--echo # Switch to insert Connection
+CONNECTION insertConn;
+SET SESSION debug='+d,wait_in_enable_indexes';
+--echo # Send insert data
+SEND INSERT INTO t1(id) SELECT id FROM t2;
+
+--echo # Switch to default Connection
+CONNECTION default;
+--echo # Wait for insert data to reach the debug point
+
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+ WHERE STATE = "wait_in_enable_indexes" AND
+ INFO = "INSERT INTO t1(id) SELECT id FROM t2";
+--source include/wait_condition.inc
+
+SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE STATE = 'wait_in_enable_indexes' AND
+INFO = "INSERT INTO t1(id) SELECT id FROM t2"
+INTO @thread_id;
+
+KILL QUERY @thread_id;
+CHECK TABLE t1;
+DROP TABLE t1,t2;
+DISCONNECT insertConn;
diff --git a/mysql-test/t/myisampack.test b/mysql-test/t/myisampack.test
index f554e7d0184..9d27ed53254 100644
--- a/mysql-test/t/myisampack.test
+++ b/mysql-test/t/myisampack.test
@@ -61,3 +61,49 @@ let $MYSQLD_DATADIR= `select @@datadir`;
optimize table t1;
repair table t1;
drop table t1;
+
+--echo #
+--echo # BUG#41541 - Valgrind warnings on packed MyISAM table
+--echo #
+CREATE TABLE t1(f1 VARCHAR(200), f2 TEXT);
+INSERT INTO t1 VALUES ('foo', 'foo1'), ('bar', 'bar1');
+let $i=9;
+--disable_query_log
+while ($i)
+{
+ INSERT INTO t1 SELECT * FROM t1;
+ dec $i;
+}
+--enable_query_log
+FLUSH TABLE t1;
+--echo # Compress the table using MYISAMPACK tool
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYISAMPACK $MYSQLD_DATADIR/test/t1
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #43973 - backup_myisam.test fails on 6.0-bugteam
+--echo #
+CREATE DATABASE mysql_db1;
+CREATE TABLE mysql_db1.t1 (c1 VARCHAR(5), c2 int);
+CREATE INDEX i1 ON mysql_db1.t1 (c1, c2);
+INSERT INTO mysql_db1.t1 VALUES ('A',1);
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+INSERT INTO mysql_db1.t1 SELECT * FROM mysql_db1.t1;
+FLUSH TABLE mysql_db1.t1;
+#
+--echo # Compress the table using MYISAMPACK tool
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYISAMPACK -s $MYSQLD_DATADIR/mysql_db1/t1
+--echo # Run MYISAMCHK tool on the compressed table
+--exec $MYISAMCHK -srq $MYSQLD_DATADIR/mysql_db1/t1
+SELECT COUNT(*) FROM mysql_db1.t1 WHERE c2 < 5;
+#
+DROP TABLE mysql_db1.t1;
+DROP DATABASE mysql_db1;
diff --git a/mysql-test/t/mysql-bug41486.test b/mysql-test/t/mysql-bug41486.test
new file mode 100644
index 00000000000..6e014bca7d1
--- /dev/null
+++ b/mysql-test/t/mysql-bug41486.test
@@ -0,0 +1,50 @@
+#
+# Bug#41486 extra character appears in BLOB for every ~40Mb after
+# mysqldump/import
+#
+# This test consumes a significant amount of resources.
+# Therefore it should be kept separated from other tests.
+# Otherwise we might suffer from problems like
+# Bug#43801 mysql.test takes too long, fails due to expired timeout
+# on debx86-b in PB
+#
+
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Have to change the global variable as the session variable is
+# read-only.
+SET @old_max_allowed_packet= @@global.max_allowed_packet;
+# 2 MB blob length + some space for the rest of INSERT query
+SET @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024;
+
+# Create a new connection since the global max_allowed_packet
+# has no effect for the current connection
+connect (con1, localhost, root,,);
+
+CREATE TABLE t1(data LONGBLOB);
+INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024);
+
+let $outfile= $MYSQLTEST_VARDIR/tmp/bug41486.sql;
+--error 0,1
+remove_file $outfile;
+--exec $MYSQL_DUMP test t1 > $outfile
+SET @old_general_log = @@global.general_log;
+SET @@global.general_log = 0;
+# Check that the mysql client does not insert extra newlines when loading
+# strings longer than client's max_allowed_packet
+--exec $MYSQL --max_allowed_packet=1M test < $outfile 2>&1
+SET @@global.general_log = @old_general_log;
+SELECT LENGTH(data) FROM t1;
+
+DROP TABLE t1;
+
+# Cleanup
+disconnect con1;
+--source include/wait_until_disconnected.inc
+remove_file $outfile;
+connection default;
+SET @@global.max_allowed_packet = @old_max_allowed_packet;
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index a182da5fbea..7e970d5b104 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -98,35 +98,43 @@ drop table t1;
# Bug #20432: mysql client interprets commands in comments
#
+--let $file = $MYSQLTEST_VARDIR/tmp/bug20432.sql
+
# if the client sees the 'use' within the comment, we haven't fixed
---exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec echo "*/" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+--exec echo "/*" > $file
+--exec echo "use" >> $file
+--exec echo "*/" >> $file
+--exec $MYSQL < $file 2>&1
# SQL can have embedded comments => workie
---exec echo "select /*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec echo "*/ 1" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+--exec echo "select /*" > $file
+--exec echo "use" >> $file
+--exec echo "*/ 1" >> $file
+--exec $MYSQL < $file 2>&1
# client commands on the other hand must be at BOL => error
---exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec echo "xxx" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec echo "*/ use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec echo "/*" > $file
+--exec echo "xxx" >> $file
+--exec echo "*/ use" >> $file
--error 1
---exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+--exec $MYSQL < $file 2>&1
# client comment recognized, but parameter missing => error
---exec echo "use" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
---exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+--exec echo "use" > $file
+--exec $MYSQL < $file 2>&1
+
+--remove_file $file
#
# Bug #20328: mysql client interprets commands in comments
#
---exec $MYSQL -e "help" > $MYSQLTEST_VARDIR/tmp/bug20328_1.result
---exec $MYSQL -e "help " > $MYSQLTEST_VARDIR/tmp/bug20328_2.result
---diff_files $MYSQLTEST_VARDIR/tmp/bug20328_1.result $MYSQLTEST_VARDIR/tmp/bug20328_2.result
+--let $file1 = $MYSQLTEST_VARDIR/tmp/bug20328_1.result
+--let $file2 = $MYSQLTEST_VARDIR/tmp/bug20328_2.result
+--exec $MYSQL -e "help" > $file1
+--exec $MYSQL -e "help " > $file2
+--diff_files $file1 $file2
+--remove_file $file1
+--remove_file $file2
#
# Bug #19216: Client crashes on long SELECT
@@ -152,13 +160,15 @@ EOF
#
# Bug #20103: Escaping with backslash does not work
#
---exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
---exec echo "SELECT '\';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
---exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
+--let $file = $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';" > $file
+--exec echo "SELECT '\';" >> $file
+--exec $MYSQL < $file 2>&1
---exec echo "SET SQL_MODE = '';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
---exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
---exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
+--exec echo "SET SQL_MODE = '';" > $file
+--exec echo "SELECT '\';';" >> $file
+--exec $MYSQL < $file 2>&1
+--remove_file $file
#
# Bug#17583: mysql drops connection when stdout is not writable
@@ -315,6 +325,23 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug38158.sql;
#
--exec $MYSQL -e "select @z:='1',@z=database()"
+
+#
+# Bug #31060: MySQL CLI parser bug 2
+#
+
+--write_file $MYSQLTEST_VARDIR/tmp/bug31060.sql
+;DELIMITER DELIMITER
+;
+SELECT 1DELIMITER
+DELIMITER ;
+SELECT 1;
+EOF
+
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug31060.sql 2>&1
+
+remove_file $MYSQLTEST_VARDIR/tmp/bug31060.sql;
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index e0595674cf9..46060649784 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -24,7 +24,7 @@ insert into t2 values ();
# set @a:=1
# insert into t2 values (@a);
-# test for load data and load data distributed among the several
+# test for load data and load data distributed among the several
# files (we need to fill up first binlog)
load data infile '../../std_data/words.dat' into table t1;
load data infile '../../std_data/words.dat' into table t1;
@@ -109,7 +109,7 @@ select "--- --position --" as "";
--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=239 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
-# Bug#7853 (mysqlbinlog does not accept input from stdin)
+# Bug#7853 mysqlbinlog does not accept input from stdin
--disable_query_log
select "--- reading stdin --" as "";
--enable_query_log
@@ -123,7 +123,7 @@ select "--- reading stdin --" as "";
drop table t1,t2;
#
-#BUG#14157: utf8 encoding in binlog without set character_set_client
+# Bug#14157 utf8 encoding in binlog without set character_set_client
#
flush logs;
--write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
@@ -136,8 +136,8 @@ EOF
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
--remove_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
-# resulted binlog, parly consisting of multi-byte utf8 chars,
-# must be digestable for both client and server. In 4.1 the client
+# resulted binlog, parly consisting of multi-byte utf8 chars,
+# 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
@@ -164,7 +164,7 @@ select * from t5 order by c1;
drop table t5;
#
-# Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails
+# Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails
#
--disable_warnings
drop procedure if exists p1;
@@ -180,7 +180,7 @@ delimiter ;//
flush logs;
call p1();
drop procedure p1;
---error 1305
+--error ER_SP_DOES_NOT_EXIST
call p1();
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008
@@ -223,53 +223,73 @@ flush logs;
#
# Bug#28293 missed '#' sign in the hex dump when the dump length
-# is divisible by 16.
+# is divisible by 16.
#
CREATE TABLE t1 (c1 CHAR(10));
# we need this for getting fixed timestamps inside of this test
-flush logs;
+FLUSH LOGS;
INSERT INTO t1 VALUES ('0123456789');
-flush logs;
+FLUSH LOGS;
DROP TABLE t1;
---exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000012 | grep 'Query' | sed 's/[0-9]\{1,\}/REMOVED/g'
+
+# We create a table, patch, and load the output into it
+# By using LINES STARTING BY '#' + SELECT WHERE a LIKE 'Query'
+# We can easily see if a 'Query' line is missing the '#' character
+# as described in the original bug
+
+--disable_query_log
+CREATE TABLE patch (a BLOB);
+--exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000012 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
+eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat'
+ INTO TABLE patch FIELDS TERMINATED BY '' LINES STARTING BY '#';
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
+--enable_query_log
+
+--echo We expect this value to be 1
+--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%';
+DROP TABLE patch;
#
-# Bug #29928: incorrect connection_id() restoring from mysqlbinlog out
+# Bug#29928 incorrect connection_id() restoring from mysqlbinlog out
#
-flush logs;
-create table t1(a int);
-insert into t1 values(connection_id());
-let $a= `select a from t1`;
-flush logs;
---exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000014 > $MYSQLTEST_VARDIR/tmp/bug29928.sql
-drop table t1;
-connect (con1, localhost, root, , test);
+FLUSH LOGS;
+CREATE TABLE t1(a INT);
+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
+DROP TABLE t1;
+connect (con1, localhost, root, , test);
connection con1;
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug29928.sql
---remove_file $MYSQLTEST_VARDIR/tmp/bug29928.sql
-let $b= `select a from t1`;
+--exec $MYSQL test < $outfile
+--remove_file $outfile
+let $b= `SELECT a FROM t1`;
disconnect con1;
connection default;
-let $c= `select $a=$b`;
+let $c= `SELECT $a=$b`;
--echo $c
-drop table t1;
+DROP TABLE t1;
echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql;
error 1;
exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug31793.sql
---echo End of 5.0 tests
#
# Test --disable-force-if-open and --force-if-open
#
-flush logs;
+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
---echo BUG#31611: Security risk with BINLOG statement
+--echo Bug#31611 Security risk with BINLOG statement
SET BINLOG_FORMAT=ROW;
CREATE DATABASE mysqltest1;
@@ -288,6 +308,7 @@ connect (unsecure,localhost,untrusted,,mysqltest1);
echo mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql;
error 1;
exec $MYSQL mysqltest1 -uuntrusted < $MYSQLTEST_VARDIR/tmp/bug31611.sql;
+--remove_file $MYSQLTEST_VARDIR/tmp/bug31611.sql
connection unsecure;
error ER_TABLEACCESS_DENIED_ERROR;
INSERT INTO t1 VALUES (1,USER());
@@ -297,7 +318,7 @@ connection default;
DROP DATABASE mysqltest1;
DROP USER untrusted@localhost;
---echo BUG#32580: mysqlbinlog cannot read binlog event with user variables
+--echo Bug#32580 mysqlbinlog cannot read binlog event with user variables
# Testing that various kinds of events can be read and restored properly.
@@ -324,4 +345,26 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql;
query_vertical SELECT * FROM t1;
DROP TABLE t1;
+#
+# Bug#37313 BINLOG Contains Incorrect server id
+#
+
+let $binlog_file= $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog;
+let $save_server_id= `SELECT @@global.server_id`;
+let $s_id_max= `SELECT (1 << 32) - 1`;
+eval SET @@global.server_id= $s_id_max;
+
+RESET MASTER;
+FLUSH LOGS;
+--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $binlog_file
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval SELECT
+(@a:=LOAD_FILE("$binlog_file"))
+IS NOT NULL;
+let $s_id_unsigned= `SELECT @a LIKE "%server id $s_id_max%" /* must return 1 */`;
+echo *** Unsigned server_id $s_id_max is found: $s_id_unsigned ***;
+
+eval SET @@global.server_id= $save_server_id;
+--remove_file $binlog_file
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/mysqlbinlog_row_big.test b/mysql-test/t/mysqlbinlog_row_big.test
index 14e818e7214..75f3b90269f 100644
--- a/mysql-test/t/mysqlbinlog_row_big.test
+++ b/mysql-test/t/mysqlbinlog_row_big.test
@@ -38,8 +38,26 @@ SET timestamp=1000000000;
--echo #
--echo # We need big packets.
--echo #
+--echo # Capture initial value to reset at the end of the test
+# use let $<var> = query_get_value as FLUSH statements
+# in the test will set @<var> values to NULL
+let $orig_max_allowed_packet =
+query_get_value(SELECT @@global.max_allowed_packet, @@global.max_allowed_packet, 1);
+
+--echo # Now adjust max_allowed_packet
SET @@global.max_allowed_packet= 1024*1024*1024;
+--echo max_allowed_packet is a global variable.
+--echo In order for the preceding change in max_allowed_packets' value
+--echo to be seen and used, we must start a new connection.
+--echo The change does not take effect with the current one.
+--echo For simplicity, we just disconnect / reconnect connection default here.
+--echo Disconnecting default connection...
+disconnect default;
+--echo Reconnecting default connection...
+connect (default, localhost,root,,);
+--echo default connection established, continuing with the test
+
--echo #
--echo # Delete all existing binary logs.
--echo #
@@ -53,34 +71,35 @@ eval CREATE TABLE t1 (
) ENGINE=$engine_type DEFAULT CHARSET latin1;
--echo #
---echo # Show how much rows are affected by each statement.
+--echo # Show how many rows are affected by each statement.
--echo #
--enable_info
--echo #
---echo # Insert a big row.
+--echo # Insert some big rows.
--echo #
-#
-# 256MB
-#INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216));
-#
-# 32MB
+
+--echo 256MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 16777216));
+
+--echo 32MB
INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 2097152));
-#
-# 4MB
-#INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 262144));
-#
-# 512KB
-#INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 32768));
+
+--echo 4MB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 262144));
+
+--echo 512KB
+INSERT INTO t1 VALUES (REPEAT('ManyMegaByteBlck', 32768));
--echo #
--echo # Show what we have in the table.
--echo # Do not display the column value itself, just its length.
--echo #
+--sorted_result
query_vertical SELECT LENGTH(c1) FROM t1;
--echo #
---echo # Grow the row by updating.
+--echo # Grow the rows by updating.
--echo #
UPDATE t1 SET c1 = CONCAT(c1, c1);
@@ -88,15 +107,16 @@ UPDATE t1 SET c1 = CONCAT(c1, c1);
--echo # Show what we have in the table.
--echo # Do not display the column value itself, just its length.
--echo #
+--sorted_result
query_vertical SELECT LENGTH(c1) FROM t1;
--echo #
---echo # Delete the row.
+--echo # Delete the rows.
--echo #
DELETE FROM t1 WHERE c1 >= 'ManyMegaByteBlck';
--echo #
---echo # Hide how much rows are affected by each statement.
+--echo # Hide how many rows are affected by each statement.
--echo #
--disable_info
@@ -113,13 +133,15 @@ FLUSH LOGS;
--echo # at the bottom of the test script.
--echo #
let $MYSQLD_DATADIR= `select @@datadir`;
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/
--exec $MYSQL_BINLOG -v -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/$mysqlbinlog_output
--echo #
--echo # Cleanup.
--echo #
+--echo # reset variable value to pass testcase checks
+eval SET @@global.max_allowed_packet = $orig_max_allowed_packet;
DROP TABLE t1;
--echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output
diff --git a/mysql-test/t/mysqldump-compat.test b/mysql-test/t/mysqldump-compat.test
index 848d66cc728..9a830b16f26 100644
--- a/mysql-test/t/mysqldump-compat.test
+++ b/mysql-test/t/mysqldump-compat.test
@@ -5,9 +5,13 @@
# Bug #30126: semicolon before closing */ in /*!... CREATE DATABASE ;*/
#
+--let $file = $MYSQLTEST_VARDIR/tmp/bug30126.sql
+
CREATE DATABASE mysqldump_30126;
USE mysqldump_30126;
CREATE TABLE t1 (c1 int);
---exec $MYSQL_DUMP --add-drop-database mysqldump_30126 > $MYSQLTEST_VARDIR/tmp/bug30126.sql
---exec $MYSQL mysqldump_30126 < $MYSQLTEST_VARDIR/tmp/bug30126.sql
+--exec $MYSQL_DUMP --add-drop-database mysqldump_30126 > $file
+--exec $MYSQL mysqldump_30126 < $file
DROP DATABASE mysqldump_30126;
+
+--remove_file $file
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index e93c9cbd274..fe89d7bdafa 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -1647,6 +1647,36 @@ DROP TABLE t1,t2;
--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// / on [0-9 :-]+/ on DATE/
--exec $MYSQL_DUMP test
+--echo #
+--echo # Bug #42635: mysqldump includes views that were excluded using
+--echo # the --ignore-table option
+--echo #
+
+create database db42635;
+use db42635;
+create table t1 (id int);
+create view db42635.v1 (c) as select * from db42635.t1;
+create view db42635.v2 (c) as select * from db42635.t1;
+--exec $MYSQL_DUMP --skip-comments --ignore-table=db42635.v1 db42635
+use test;
+drop database db42635;
+
+--echo #
+--echo # Bug#33550 mysqldump 4.0 compatibility broken
+--echo #
+
+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
+DROP TABLE `straße`;
+
+CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ( f1 INT );
+--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --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
+DROP TABLE `כדשגכחךלדגכחשךדגחכךלדגכ`;
+SET NAMES latin1;
--echo #
--echo # End of 5.0 tests
@@ -1920,6 +1950,7 @@ DROP DATABASE mysqldump_test_db;
--echo
# We reset concurrent_inserts value to whatever it was at the start of the test
+# This line must be executed _after_ all test cases.
SET @@GLOBAL.CONCURRENT_INSERT = @OLD_CONCURRENT_INSERT;
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 6c5efba8b5b..55cd041aaf5 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -6,6 +6,9 @@
# This test uses chmod, can't be run with root permissions
-- source include/not_as_root.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
# ============================================================================
#
# Test of mysqltest itself
@@ -50,7 +53,7 @@ select otto from (select 1 as otto) as t1;
# ----------------------------------------------------------------------------
# Negative case(statement):
-# The derived table t1 does not contain a column named 'friedrich' .
+# The derived table t1 does not contain a column named 'friedrich' .
# --> ERROR 42S22: Unknown column 'friedrich' in 'field list and
# --> 1054: Unknown column 'friedrich' in 'field list'
# ----------------------------------------------------------------------------
@@ -62,7 +65,8 @@ select otto from (select 1 as otto) as t1;
--exec echo "select friedrich from (select 1 as otto) as t1;" | $MYSQL_TEST 2>&1
# expectation = response
---error 1054
+--error ER_BAD_FIELD_ERROR
+
select friedrich from (select 1 as otto) as t1;
# The following unmasked unsuccessful statement must give
@@ -120,7 +124,7 @@ select friedrich from (select 1 as otto) as t1;
# $mysql_errno is a builtin variable of mysqltest and contains the return code
# of the last command sent to the server.
#
-# The following test cases often initialize $mysql_errno to 1064 by
+# The following test cases often initialize $mysql_errno to 1064 by
# a command with wrong syntax.
# Example: --error 1064 To prevent the abort after the error.
# garbage ;
@@ -135,14 +139,16 @@ eval select $mysql_errno as "after_successful_stmt_errno" ;
#----------------------------------------------------------------------------
# check mysql_errno = 1064 after statement with wrong syntax
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
eval select $mysql_errno as "after_wrong_syntax_errno" ;
# ----------------------------------------------------------------------------
# check if let $my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
let $my_var= 'abc' ;
eval select $mysql_errno as "after_let_var_equal_value" ;
@@ -150,7 +156,8 @@ eval select $mysql_errno as "after_let_var_equal_value" ;
# ----------------------------------------------------------------------------
# check if set @my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
set @my_var= 'abc' ;
eval select $mysql_errno as "after_set_var_equal_value" ;
@@ -159,7 +166,8 @@ eval select $mysql_errno as "after_set_var_equal_value" ;
# check if the setting of --disable-warnings itself affects $mysql_errno
# (May be --<whatever> modifies $mysql_errno.)
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
--disable_warnings
eval select $mysql_errno as "after_disable_warnings_command" ;
@@ -170,7 +178,8 @@ eval select $mysql_errno as "after_disable_warnings_command" ;
# (May be disabled warnings affect $mysql_errno.)
# ----------------------------------------------------------------------------
drop table if exists t1 ;
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
drop table if exists t1 ;
eval select $mysql_errno as "after_disable_warnings" ;
@@ -179,21 +188,26 @@ eval select $mysql_errno as "after_disable_warnings" ;
# ----------------------------------------------------------------------------
# check if masked errors affect $mysql_errno
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
---error 1146
+--error ER_NO_SUCH_TABLE
+
select 3 from t1 ;
eval select $mysql_errno as "after_minus_masked" ;
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
---error 1146
+--error ER_NO_SUCH_TABLE
+
select 3 from t1 ;
eval select $mysql_errno as "after_!_masked" ;
# ----------------------------------------------------------------------------
# Will manipulations of $mysql_errno be possible and visible ?
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
let $mysql_errno= -1;
eval select $mysql_errno as "after_let_errno_equal_value" ;
@@ -202,50 +216,61 @@ eval select $mysql_errno as "after_let_errno_equal_value" ;
# How affect actions on prepared statements $mysql_errno ?
# ----------------------------------------------------------------------------
# failing prepare
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
---error 1146
+--error ER_NO_SUCH_TABLE
+
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_failing_prepare" ;
create table t1 ( f1 char(10));
# successful prepare
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_successful_prepare" ;
# successful execute
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
execute stmt;
eval select $mysql_errno as "after_successful_execute" ;
# failing execute (table has been dropped)
drop table t1;
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
---error 1146
+--error ER_NO_SUCH_TABLE
+
execute stmt;
eval select $mysql_errno as "after_failing_execute" ;
# failing execute (unknown statement)
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
---error 1243
+--error ER_UNKNOWN_STMT_HANDLER
+
execute __stmt_;
eval select $mysql_errno as "after_failing_execute" ;
# successful deallocate
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
deallocate prepare stmt;
eval select $mysql_errno as "after_successful_deallocate" ;
# failing deallocate ( statement handle does not exist )
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
---error 1243
+--error ER_UNKNOWN_STMT_HANDLER
+
deallocate prepare __stmt_;
eval select $mysql_errno as "after_failing_deallocate" ;
@@ -270,7 +295,8 @@ eval select $mysql_errno as "after_failing_deallocate" ;
# ----------------------------------------------------------------------------
# Switch off the abort on error and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
--disable_abort_on_error
eval select $mysql_errno as "after_--disable_abort_on_error" ;
@@ -284,9 +310,11 @@ select 3 from t1 ;
# masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
---error 1146
+--error ER_NO_SUCH_TABLE
+
select 3 from t1 ;
---error 1146
+--error ER_NO_SUCH_TABLE
+
select 3 from t1 ;
eval select $mysql_errno as "after_!errno_masked_error" ;
# expected error <> response
@@ -300,7 +328,8 @@ eval select $mysql_errno as "after_!errno_masked_error" ;
# ----------------------------------------------------------------------------
# Switch the abort on error on and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
---error 1064
+--error ER_PARSE_ERROR
+
garbage ;
--enable_abort_on_error
eval select $mysql_errno as "after_--enable_abort_on_error" ;
@@ -309,7 +338,8 @@ eval select $mysql_errno as "after_--enable_abort_on_error" ;
# masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
---error 1146
+--error ER_NO_SUCH_TABLE
+
select 3 from t1 ;
# ----------------------------------------------------------------------------
@@ -458,7 +488,7 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqltest.sql;
# Allow trailing # comment
--sleep 1 # Wait for insert delayed to be executed.
---sleep 1 # Wait for insert delayed to be executed.
+--sleep 1 # Wait for insert delayed to be executed.
# ----------------------------------------------------------------------------
# Test error
@@ -573,9 +603,6 @@ echo ;
# Illegal use of exec
--error 1
---exec echo "--exec false" | $MYSQL_TEST 2>&1
-
---error 1
--exec echo "--exec " | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
@@ -683,7 +710,7 @@ echo Not a banana: $cat;
--error 1
--exec echo "let hi;" | $MYSQL_TEST 2>&1
-# More advanced test for bug#17280
+# More advanced test for Bug#17280
let $success= 1;
--echo # Execute: --echo # <whatever> success: \$success
--echo # <whatever> success: $success
@@ -955,8 +982,6 @@ system echo "hej" > /dev/null;
--exec echo "system;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
---error 1
---exec echo "system false;" | $MYSQL_TEST 2>&1
--disable_abort_on_error
system NonExistsinfComamdn 2> /dev/null;
@@ -1364,17 +1389,18 @@ connection default;
# ----------------------------------------------------------------------------
-# TODO Test queries, especially their errormessages... so it's easy to debug
+# TODO Test queries, especially their errormessages... so it's easy to debug
# new scripts and diagnose errors
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
-# Test bug#12386
+# Test Bug#12386
# ----------------------------------------------------------------------------
let $num= 2;
while ($num)
{
- --error 1064
+ --error ER_PARSE_ERROR
+
failing_statement;
dec $num;
@@ -1384,7 +1410,7 @@ SELECT 1 as a;
#
-# Bug #10251: Identifiers containing quotes not handled correctly
+# Bug#10251 Identifiers containing quotes not handled correctly
#
select 1 as `a'b`, 2 as `a"b`;
@@ -1405,7 +1431,7 @@ let $message= `SELECT USER()`;
# The message contains more then 80 characters on multiple lines
# and is kept between double quotes.
-let $message=
+let $message=
"Here comes a very very long message that
- is longer then 80 characters and
- consists of several lines";
@@ -1433,14 +1459,16 @@ select "this will be executed";
#
# Test zero length result file. Should not pass
#
---exec touch $MYSQLTEST_VARDIR/tmp/zero_length_file.result
+--exec echo '' > $MYSQLTEST_VARDIR/tmp/zero_length_file.result
--exec echo "echo ok;" > $MYSQLTEST_VARDIR/tmp/query.sql
--error 1
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
--error 0,1
-remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject;
+remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject;
+--error 0,1
+remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.log;
--error 0,1
remove_file $MYSQL_TEST_DIR/r/zero_length_file.reject;
@@ -1464,8 +1492,8 @@ remove_file $MYSQLTEST_VARDIR/tmp/query.sql;
#--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/result_file.result 2>&1
#
-# Bug #11731 mysqltest in multi-statement queries ignores errors in
-# non-1st queries
+# Bug#11731 mysqltest in multi-statement queries ignores errors in
+# non-1st queries
#
echo Failing multi statement query;
@@ -1486,7 +1514,8 @@ drop table t1;
--error 1
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
# The .out file should be non existent
---exec test ! -s $MYSQLTEST_VARDIR/tmp/bug11731.out
+--error 1
+--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
drop table t1;
@@ -1508,26 +1537,29 @@ drop table t1;
--exec $MYSQL_TEST --record -x $MYSQLTEST_VARDIR/tmp/bug11731.sql -R $MYSQLTEST_VARDIR/tmp/bug11731.out 2>&1
# The .out file should exist
---exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out
+--file_exists $MYSQLTEST_VARDIR/tmp/bug11731.out
drop table t1;
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
#
-# Bug#19890 mysqltest: "query" command is broken
+# Bug#19890 mysqltest "query" command is broken
#
# It should be possible to use the command "query" to force mysqltest to
# send the command to the server although it's a builtin mysqltest command.
---error 1064
+--error ER_PARSE_ERROR
+
query sleep;
---error 1064
+--error ER_PARSE_ERROR
+
--query sleep
# Just an empty query command
---error 1065
+--error ER_EMPTY_QUERY
+
query ;
# test for replace_regex
@@ -1538,7 +1570,7 @@ select "at" as col1, "c" as col2;
select "at" as col1, "AT" as col2, "c" as col3;
--replace_regex /a/b/ /ct/d/
-select "a" as col1, "ct" as col2;
+select "a" as col1, "ct" as col2;
--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
select "strawberry","blueberry","potato";
@@ -1556,7 +1588,7 @@ select "strawberry","blueberry","potato";
--error 1
--exec echo "--replace_regex /a b c" | $MYSQL_TEST 2>&1
--error 1
---exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1
+--exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1
# REQUIREMENT
# replace_regex should replace substitutions from left to right in output
@@ -1921,12 +1953,13 @@ eval $my_stmt;
# 8. Ensure that "sorted_result " does not change the semantics of
# "--error ...." or the protocol output after such an expected failure
--sorted_result
---error 1146
+--error ER_NO_SUCH_TABLE
+
SELECT '2' as "my_col1",2 as "my_col2"
UNION
SELECT '1',1 from t2;
-# 9. Ensure that several result formatting options including "sorted_result"
+# 9. Ensure that several result formatting options including "sorted_result"
# - have all an effect
# - "--sorted_result" does not need to be direct before the statement
# - Row sorting is applied after modification of the column content
@@ -2142,15 +2175,15 @@ remove_file $MYSQLTEST_VARDIR/tmp/testdir/file3.txt;
rmdir $MYSQLTEST_VARDIR/tmp/testdir;
#
-# Bug #36041: mysql-test-run doesn't seem to string match 100% effectively
-# on Windows
+# Bug#36041 mysql-test-run doesn't seem to string match 100% effectively
+# on Windows
#
--replace_result c:\\a.txt z
SELECT 'c:\\a.txt' AS col;
#
-# Bug #32307 mysqltest - does not detect illegal if syntax
+# Bug#32307 mysqltest - does not detect illegal if syntax
#
let $test= 1;
@@ -2184,12 +2217,14 @@ select 1;
# ----------------------------------------------------------------------------
-# BUG#35701: please allow test language variables in connection and sync_slave_with_master
+# BUG#35701 please allow test language variables in connection and sync_slave_with_master
# Test that "connection $variable" works and that $CURRENT_CONNECTION has the right value.
# ----------------------------------------------------------------------------
connect (con1,localhost,root,,);
--echo $CURRENT_CONNECTION
+connect (con2,localhost,root,,);
+--echo $CURRENT_CONNECTION
connection default;
--echo $CURRENT_CONNECTION
@@ -2197,8 +2232,11 @@ connection default;
connection con1;
--echo $CURRENT_CONNECTION
-let $x= default;
-let $y= con1;
+connection con2;
+--echo $CURRENT_CONNECTION
+
+let $x= con1;
+let $y= con2;
connection $x;
--echo $CURRENT_CONNECTION
@@ -2217,3 +2255,6 @@ disconnect $y;
--echo End of tests
+connection default;
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test
index 233ac3edfbb..fa2b659ec57 100644
--- a/mysql-test/t/not_embedded_server.test
+++ b/mysql-test/t/not_embedded_server.test
@@ -36,4 +36,10 @@ select 1;
#execute stmt1;
#deallocate prepare stmt1;
+#
+# Bug#43835: SHOW VARIABLES does not include 0 for slave_skip_errors
+#
+
+SHOW VARIABLES like 'slave_skip_errors';
+
# End of 5.1 tests
diff --git a/mysql-test/t/overflow.test b/mysql-test/t/overflow.test
index a62ef9c4cd2..774c43be658 100644
--- a/mysql-test/t/overflow.test
+++ b/mysql-test/t/overflow.test
@@ -1,6 +1,14 @@
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
connect (con1,localhost,root,,);
connection con1;
--- error 1064,1102,1280
+--error ER_PARSE_ERROR,ER_WRONG_DB_NAME,ER_WRONG_NAME_FOR_INDEX
drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
+connection default;
+disconnect con1;
# End of 4.1 tests
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/packet.test b/mysql-test/t/packet.test
index 93b46766d99..7e08a0f6c3f 100644
--- a/mysql-test/t/packet.test
+++ b/mysql-test/t/packet.test
@@ -4,10 +4,18 @@
# swallowing them and returning an error
--source include/not_windows.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
#
# Check protocol handling
#
+set @max_allowed_packet=@@global.max_allowed_packet;
+set @net_buffer_length=@@global.net_buffer_length;
+
+
# setting values below minimum threshold of 1024 will cause truncating
set global max_allowed_packet=100;
set global net_buffer_length=100;
@@ -22,8 +30,10 @@ select repeat('a',2000);
connect (con1,localhost,root,,);
connection con1;
select @@net_buffer_length, @@max_allowed_packet;
---error 1153
+--error ER_NET_PACKET_TOO_LARGE
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
+connection default;
+disconnect con1;
#
# Reset to default values and reconnect
@@ -34,5 +44,13 @@ connect (con2,localhost,root,,);
connection con2;
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
select length(repeat('a',2000));
+connection default;
+disconnect con2;
+
+set global max_allowed_packet=@max_allowed_packet;
+set global net_buffer_length=@net_buffer_length;
# End of 4.1 tests
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index 7efc519e441..e579e371184 100644
--- a/mysql-test/t/parser.test
+++ b/mysql-test/t/parser.test
@@ -724,3 +724,7 @@ SELECT {fn CONCAT(a1,a2)} FROM t1;
UPDATE t3 SET a4={d '1789-07-14'} WHERE a1=0;
SELECT a1, a4 FROM t2 WHERE a4 LIKE {fn UCASE('1789-07-14')};
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
new file mode 100644
index 00000000000..8ebeb9a8301
--- /dev/null
+++ b/mysql-test/t/parser_not_embedded.test
@@ -0,0 +1,26 @@
+--source include/not_embedded.inc
+
+###########################################################################
+--echo #
+--echo # Bug#39559: dump of stored procedures / functions with C-style
+--echo # comment can't be read back
+--echo #
+
+--write_file $MYSQLTEST_VARDIR/tmp/bug39559.sql
+select 2 as expected, /*!01000/**/*/ 2 as result;
+select 1 as expected, /*!99998/**/*/ 1 as result;
+select 3 as expected, /*!01000 1 + */ 2 as result;
+select 2 as expected, /*!99990 1 + */ 2 as result;
+select 7 as expected, /*!01000 1 + /* 8 + */ 2 + */ 4 as result;
+select 8 as expected, /*!99998 1 + /* 2 + */ 4 + */ 8 as result;
+select 7 as expected, /*!01000 1 + /*!01000 8 + */ 2 + */ 4 as result;
+select 7 as expected, /*!01000 1 + /*!99998 8 + */ 2 + */ 4 as result;
+select 4 as expected, /*!99998 1 + /*!99998 8 + */ 2 + */ 4 as result;
+select 4 as expected, /*!99998 1 + /*!01000 8 + */ 2 + */ 4 as result;
+select 7 as expected, /*!01000 1 + /*!01000 8 + /*!01000 error */ 16 + */ 2 + */ 4 as result;
+select 4 as expected, /* 1 + /*!01000 8 + */ 2 + */ 4;
+EOF
+
+--exec $MYSQL --comment --force --table test <$MYSQLTEST_VARDIR/tmp/bug39559.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/bug39559.sql
+
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 23a300de9e5..ce89609de39 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -17,6 +17,14 @@ drop table if exists t1, t2;
--enable_warnings
#
+# Bug#36001: Partitions: spelling and using some error messages
+#
+--error ER_FOREIGN_KEY_ON_PARTITIONED
+CREATE TABLE t1 (a INT, FOREIGN KEY (a) REFERENCES t0 (a))
+ENGINE=MyISAM
+PARTITION BY HASH (a);
+
+#
# Bug#40954: Crash if range search and order by.
#
CREATE TABLE t1 (
@@ -1914,6 +1922,19 @@ insert into t1 select s1 from t1 where s1=3;
select count(*) from t1;
drop table t1;
+
+--echo #
+--echo # Bug#42944: partition not pruned correctly
+--echo #
+CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
+ (PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN (200),
+ PARTITION p2 VALUES LESS THAN (300),
+ PARTITION p3 VALUES LESS THAN MAXVALUE);
+INSERT INTO t1 VALUES (10), (100), (200), (300), (400);
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a>=200;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index 41b904b876f..49632f95dfb 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -1,5 +1,5 @@
#
-# Simple test for the erroneos create statements using the
+# Simple test for the erroneos statements using the
# partition storage engine
#
-- source include/have_partition.inc
@@ -7,6 +7,19 @@
--disable_warnings
drop table if exists t1;
--enable_warnings
+
+#
+# Bug#38719: Partitioning returns a different error code for a
+# duplicate key error
+CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a));
+-- error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (1),(1);
+DROP TABLE t1;
+CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a))
+PARTITION BY KEY (a) PARTITIONS 2;
+-- error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (1),(1);
+DROP TABLE t1;
#
# Bug#31931: Mix of handlers error message
diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test
index e17edf0a4e5..bf9b5ed174e 100644
--- a/mysql-test/t/partition_mgm.test
+++ b/mysql-test/t/partition_mgm.test
@@ -67,13 +67,14 @@ drop table t1;
#
# Verification tests for bug#14326
#
---error ER_PARSE_ERROR
CREATE TABLE t1 (a INT)
/*!50100 PARTITION BY HASH (a)
/* Test
of multi-line
comment */
PARTITIONS 5 */;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
CREATE TABLE t1 (a INT)
/*!50100 PARTITION BY HASH (a)
-- with a single line comment embedded
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 91cb6eef8ad..db5994d434b 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -230,6 +230,10 @@ drop table t1;
# statements or are correctly created and deleted on each execute
#
+--let $outfile=$MYSQLTEST_VARDIR/tmp/f1.txt
+--error 0,1
+--remove_file $outfile
+
prepare stmt1 from "select 1 into @var";
execute stmt1;
execute stmt1;
@@ -240,11 +244,14 @@ execute stmt1;
prepare stmt1 from "insert into t1 select i from t1";
execute stmt1;
execute stmt1;
-prepare stmt1 from "select * from t1 into outfile 'f1.txt'";
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval prepare stmt1 from "select * from t1 into outfile '$outfile'";
execute stmt1;
deallocate prepare stmt1;
drop table t1;
+--remove_file $outfile
+
#
# BUG#5242 "Prepared statement names are case sensitive"
#
@@ -939,8 +946,13 @@ set global max_prepared_stmt_count=3;
select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
prepare stmt from "select 1";
+
connect (con1,localhost,root,,);
+
+# Switch to connection con1
connection con1;
+let $con1_id=`SELECT CONNECTION_ID()`;
+
prepare stmt from "select 2";
prepare stmt1 from "select 3";
--error ER_MAX_PREPARED_STMT_COUNT_REACHED
@@ -950,18 +962,17 @@ connection default;
prepare stmt2 from "select 4";
select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
+
+# Disconnect connection con1 and switch to default connection
disconnect con1;
connection default;
-# Wait for the connection to die: deal with a possible race
+
+# Wait for the connection con1 to die
+let $wait_condition=SELECT COUNT(*)=0 FROM information_schema.processlist WHERE id=$con1_id;
+--source include/wait_condition.inc
+
deallocate prepare stmt;
-let $query= select variable_value from information_schema.global_status
- where variable_name = 'prepared_stmt_count';
-let $count= `$query`;
-if ($count)
-{
---sleep 1
- let $count= `$query`;
-}
+
select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
#
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index 3ad3f394840..387b3ebdd05 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -70,71 +70,71 @@ prepare stmt1 from ' select 1 as my_col ' ;
# prepare with parameter
prepare stmt1 from ' select ? as my_col ' ;
# prepare must fail (incomplete statements/wrong syntax)
---error 1064
+--error ER_PARSE_ERROR
prepare ;
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 ;
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 from ;
---error 1064
+--error ER_PARSE_ERROR
prepare_garbage stmt1 from ' select 1 ' ;
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 from_garbage ' select 1 ' ;
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 from ' select_garbage 1 ' ;
---error 1064
+--error ER_PARSE_ERROR
prepare from ' select 1 ' ;
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 ' select 1 ' ;
---error 1064
+--error ER_PARSE_ERROR
prepare ? from ' select ? as my_col ' ;
# statement in variable
set @arg00='select 1 as my_col';
prepare stmt1 from @arg00;
# prepare must fail (query variable is empty)
set @arg00='';
---error 1065
+--error ER_EMPTY_QUERY
prepare stmt1 from @arg00;
set @arg00=NULL;
# prepare must fail (query variable is NULL)
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 from @arg01;
prepare stmt1 from ' select * from t1 where a <= 2 ' ;
# prepare must fail (column x does not exist)
---error 1054
+--error ER_BAD_FIELD_ERROR
prepare stmt1 from ' select * from t1 where x <= 2 ' ;
# cases derived from client_test.c: test_null()
# prepare must fail (column x does not exist)
---error 1054
+--error ER_BAD_FIELD_ERROR
prepare stmt1 from ' insert into t1(a,x) values(?,?) ' ;
---error 1054
+--error ER_BAD_FIELD_ERROR
prepare stmt1 from ' insert into t1(x,a) values(?,?) ' ;
--disable_warnings
drop table if exists not_exist ;
--enable_warnings
# prepare must fail (table does not exist)
---error 1146
+--error ER_NO_SUCH_TABLE
prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
# case derived from client_test.c: test_prepare_syntax()
# prepare must fail (incomplete statement)
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 from ' insert into t1 values(? ' ;
---error 1064
+--error ER_PARSE_ERROR
prepare stmt1 from ' select a, b from t1
where a=? and where ' ;
################ EXECUTE ################
# execute must fail (statement never_prepared never prepared)
---error 1243
+--error ER_UNKNOWN_STMT_HANDLER
execute never_prepared ;
# execute must fail (prepare stmt1 just failed,
# but there was a successful prepare of stmt1 before)
prepare stmt1 from ' select * from t1 where a <= 2 ' ;
---error 1146
+--error ER_NO_SUCH_TABLE
prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
---error 1243
+--error ER_UNKNOWN_STMT_HANDLER
execute stmt1 ;
# drop the table between prepare and execute
@@ -149,7 +149,7 @@ prepare stmt2 from ' select * from t5 ' ;
execute stmt2 ;
drop table t5 ;
# execute must fail (table was dropped after prepare)
---error 1146
+--error ER_NO_SUCH_TABLE
execute stmt2 ;
# cases derived from client_test.c: test_select_prepare()
# 1. drop + create table (same column names/types/order)
@@ -230,24 +230,24 @@ set @arg01='two' ;
prepare stmt1 from ' select * from t1 where a <= ? ' ;
execute stmt1 using @arg00;
# execute must fail (too small number of parameters)
---error 1210
+--error ER_WRONG_ARGUMENTS
execute stmt1 ;
# execute must fail (too big number of parameters)
---error 1210
+--error ER_WRONG_ARGUMENTS
execute stmt1 using @arg00, @arg01;
# execute must fail (parameter is not set)
execute stmt1 using @not_set;
################ DEALLOCATE ################
# deallocate must fail (the statement 'never_prepared' was never prepared)
---error 1243
+--error ER_UNKNOWN_STMT_HANDLER
deallocate prepare never_prepared ;
# deallocate must fail (prepare stmt1 just failed,
# but there was a successful prepare before)
prepare stmt1 from ' select * from t1 where a <= 2 ' ;
---error 1146
+--error ER_NO_SUCH_TABLE
prepare stmt1 from ' select * from not_exist where a <= 2 ' ;
---error 1243
+--error ER_UNKNOWN_STMT_HANDLER
deallocate prepare stmt1;
create table t5
(
@@ -345,7 +345,7 @@ drop table if exists t5;
prepare stmt1 from ' drop table if exists t5 ' ;
execute stmt1 ;
prepare stmt1 from ' drop table t5 ' ;
---error 1051
+--error ER_BAD_TABLE_ERROR
execute stmt1 ;
## SELECT @@version
@@ -432,7 +432,7 @@ drop database mysqltest ;
prepare stmt3 from ' describe t2 ';
execute stmt3;
drop table t2 ;
---error 1146
+--error ER_NO_SUCH_TABLE
execute stmt3;
## lock/unlock
--error ER_UNSUPPORTED_PS
@@ -440,18 +440,29 @@ prepare stmt3 from ' lock tables t1 read ' ;
--error ER_UNSUPPORTED_PS
prepare stmt3 from ' unlock tables ' ;
## Load/Unload table contents
+
+--let $datafile = $MYSQLTEST_VARDIR/tmp/data.txt
+--error 0,1
+--remove_file $datafile
+
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
--error ER_UNSUPPORTED_PS
-prepare stmt1 from ' load data infile ''data.txt''
-into table t1 fields terminated by ''\t'' ';
-prepare stmt1 from ' select * into outfile ''data.txt'' from t1 ';
-execute stmt1 ;
+eval prepare stmt1 from ' load data infile ''$datafile''
+ into table t1 fields terminated by ''\t'' ';
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval prepare stmt1 from ' select * into outfile ''$datafile'' from t1 ';
+ execute stmt1 ;
##
prepare stmt1 from ' optimize table t1 ' ;
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
-prepare stmt1 from ' restore table t1 from ''data.txt'' ' ;
+eval prepare stmt1 from ' restore table t1 from ''$datafile'' ' ;
+--remove_file $datafile
+
## handler
--error ER_UNSUPPORTED_PS
prepare stmt1 from ' handler t1 open ';
@@ -566,7 +577,7 @@ drop table if exists new_t2;
--enable_warnings
prepare stmt3 from ' rename table t2 to new_t2 ';
execute stmt3;
---error 1050
+--error ER_TABLE_EXISTS_ERROR
execute stmt3;
rename table new_t2 to t2;
drop table t2;
@@ -577,13 +588,13 @@ create table t5 (a int) ;
# rename must fail, t7 does not exist
# Clean up the filename here because embedded server reports whole path
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ '' t7.frm t7
---error 1017
+--error ER_FILE_NOT_FOUND
execute stmt1 ;
create table t7 (a int) ;
# rename, t5 -> t6 and t7 -> t8
execute stmt1 ;
# rename must fail, t5 and t7 does not exist t6 and t8 already exist
---error 1050
+--error ER_TABLE_EXISTS_ERROR
execute stmt1 ;
rename table t6 to t5, t8 to t7 ;
# rename, t5 -> t6 and t7 -> t8
diff --git a/mysql-test/t/query_cache_28249.test b/mysql-test/t/query_cache_28249.test
index 3cf6c89369e..390a1ce6e3d 100644
--- a/mysql-test/t/query_cache_28249.test
+++ b/mysql-test/t/query_cache_28249.test
@@ -11,6 +11,7 @@
#
--source include/have_query_cache.inc
+--source include/not_embedded.inc
SET @query_cache_type= @@global.query_cache_type;
SET @query_cache_limit= @@global.query_cache_limit;
diff --git a/mysql-test/t/query_cache_debug.test b/mysql-test/t/query_cache_debug.test
index 18dfe487ac3..8cf5e9d4b16 100644
--- a/mysql-test/t/query_cache_debug.test
+++ b/mysql-test/t/query_cache_debug.test
@@ -44,3 +44,71 @@ set global query_cache_size= 0;
use test;
drop table t1;
+#
+# Bug#41098: Query Cache returns wrong result with concurrent insert
+#
+
+SET @old_concurrent_insert= @@GLOBAL.concurrent_insert;
+SET @old_query_cache_size= @@GLOBAL.query_cache_size;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (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 SESSION debug='+d,wait_after_query_cache_invalidate';
+--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
+
+connection con2;
+--echo # Switch to connection con2
+--echo # Send SELECT that shouldn't be cached
+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;
+
+connection con1;
+--echo # Switch to connection con1
+--echo # Gather insert result
+--reap
+SHOW STATUS LIKE "Qcache_queries_in_cache";
+--echo # Test that it's cacheable
+SELECT * FROM t1;
+SHOW STATUS LIKE "Qcache_queries_in_cache";
+
+--echo # Disconnect
+disconnect con1;
+disconnect con2;
+
+connection default;
+--echo # Restore defaults
+RESET QUERY CACHE;
+DROP TABLE t1,t2;
+SET GLOBAL concurrent_insert= DEFAULT;
+SET GLOBAL query_cache_size= DEFAULT;
+SET GLOBAL query_cache_type= DEFAULT;
diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test
index c3889ef0267..095d47f5bdf 100644
--- a/mysql-test/t/query_cache_notembedded.test
+++ b/mysql-test/t/query_cache_notembedded.test
@@ -1,6 +1,10 @@
-- source include/have_query_cache.inc
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+
#
# Tests with query cache
#
@@ -79,7 +83,7 @@ show status like "Qcache_free_blocks";
drop table t1, t2, t3, t11, t21;
#
-# do not use QC if tables locked (BUG#12385)
+# do not use QC if tables locked (Bug#12385)
#
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root;
@@ -96,10 +100,13 @@ SELECT * FROM t1;
connection root;
SELECT * FROM t1;
drop table t1;
+connection default;
+disconnect root;
+disconnect root2;
#
-# query in QC from normal execution and SP (BUG#6897)
-# improved to also test BUG#3583 and BUG#12990
+# query in QC from normal execution and SP (Bug#6897)
+# improved to also test Bug#3583 and Bug#12990
#
flush query cache;
reset query cache;
@@ -181,7 +188,7 @@ drop procedure f4;
drop table t1;
#
-# bug#14767: INSERT in SF + concurrent SELECT with query cache
+# Bug#14767 INSERT in SF + concurrent SELECT with query cache
#
connection default;
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
@@ -257,6 +264,7 @@ SELECT id FROM view1 WHERE id>2;
show status like 'Qcache_queries_in_cache';
connection default;
+USE test;
DROP DATABASE bug30269;
disconnect bug30269;
DROP USER 'bug30269'@'localhost';
@@ -266,3 +274,5 @@ set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size=default;
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test
index fd41a3225a6..abc016bafce 100644
--- a/mysql-test/t/read_only.test
+++ b/mysql-test/t/read_only.test
@@ -2,7 +2,12 @@
# check that it blocks updates unless they are only on temporary tables.
# should work with embedded server after mysqltest is fixed
--- source include/not_embedded.inc
+--source include/not_embedded.inc
+
+set @start_read_only= @@global.read_only;
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3;
@@ -13,12 +18,15 @@ DROP TABLE IF EXISTS t1,t2,t3;
grant CREATE, SELECT, DROP on *.* to test@localhost;
+--echo connect (con1,localhost,test,,test);
connect (con1,localhost,test,,test);
+--echo connection default;
connection default;
set global read_only=0;
+--echo connection con1;
connection con1;
create table t1 (a int);
@@ -27,6 +35,7 @@ insert into t1 values(1);
create table t2 select * from t1;
+--echo connection default;
connection default;
set global read_only=1;
@@ -36,28 +45,29 @@ set global read_only=1;
create table t3 (a int);
drop table t3;
+--echo connection con1;
connection con1;
select @@global.read_only;
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
create table t3 (a int);
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
insert into t1 values(1);
# if a statement, after parse stage, looks like it will update a
# non-temp table, it will be rejected, even if at execution it would
# have turned out that 0 rows would be updated
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
update t1 set a=1 where 1=0;
# multi-update is special (see sql_parse.cc) so we test it
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
update t1,t2 set t1.a=t2.a+1 where t1.a=t2.a;
# check multi-delete to be sure
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
delete t1,t2 from t1,t2 where t1.a=t2.a;
# With temp tables updates should be accepted:
@@ -71,7 +81,7 @@ insert into t3 values(1);
insert into t4 select * from t3;
# a non-temp table updated:
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
# no non-temp table updated (just swapped):
@@ -79,7 +89,7 @@ update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a;
update t4,t3 set t4.a=t3.a+1 where t4.a=t3.a;
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
delete t1 from t1,t3 where t1.a=t3.a;
delete t3 from t1,t3 where t1.a=t3.a;
@@ -98,88 +108,107 @@ delete t1 from t1,t3 where t1.a=t3.a;
drop table t1;
---error 1290
+--error ER_OPTION_PREVENTS_STATEMENT
insert into t1 values(1);
#
-# BUG#11733: COMMITs should not happen if read-only is set
+# Bug#11733 COMMITs should not happen if read-only is set
#
# LOCK TABLE ... WRITE / READ_ONLY
# - is an error in the same connection
# - is ok in a different connection
+--echo connection default;
connection default;
set global read_only=0;
lock table t1 write;
+--echo connection con1;
connection con1;
lock table t2 write;
+--echo connection default;
connection default;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
set global read_only=1;
unlock tables ;
# The following call blocks until con1 releases the write lock.
# Blocking is expected.
+--echo send set global read_only=1;
send set global read_only=1;
+--echo connection con1;
connection con1;
---sleep 1
select @@global.read_only;
unlock tables ;
---sleep 1
+let $wait_condition= SELECT @@global.read_only= 1;
+--source include/wait_condition.inc
select @@global.read_only;
+--echo connection default;
connection default;
+--echo reap;
reap;
# LOCK TABLE ... READ / READ_ONLY
# - is an error in the same connection
# - is ok in a different connection
+--echo connection default;
connection default;
set global read_only=0;
lock table t1 read;
+--echo connection con1;
connection con1;
lock table t2 read;
+--echo connection default;
connection default;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
set global read_only=1;
unlock tables ;
# The following call blocks until con1 releases the read lock.
# Blocking is a limitation, and could be improved.
+--echo send set global read_only=1;
send set global read_only=1;
+--echo connection con1;
connection con1;
---sleep 1
select @@global.read_only;
unlock tables ;
---sleep 1
+let $wait_condition= SELECT @@global.read_only= 1;
+--source include/wait_condition.inc
select @@global.read_only;
+--echo connection default;
connection default;
+--echo reap;
reap;
# pending transaction / READ_ONLY
# - is an error in the same connection
# - is ok in a different connection
+--echo connection default;
connection default;
set global read_only=0;
BEGIN;
+--echo connection con1;
connection con1;
BEGIN;
+--echo connection default;
connection default;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
set global read_only=1;
ROLLBACK;
+
set global read_only=1;
+--echo connection con1;
connection con1;
select @@global.read_only;
ROLLBACK;
@@ -188,26 +217,32 @@ ROLLBACK;
# - in the same SUPER connection
# - in another SUPER connection
+--echo connection default;
connection default;
set global read_only=0;
flush tables with read lock;
set global read_only=1;
unlock tables;
+--echo connect (root2,localhost,root,,test);
connect (root2,localhost,root,,test);
+--echo connection default;
connection default;
set global read_only=0;
flush tables with read lock;
+--echo connection root2;
connection root2;
set global read_only=1;
+--echo connection default;
connection default;
select @@global.read_only;
unlock tables;
+disconnect root2;
-# BUG #22077 "DROP TEMPORARY TABLE fails with wrong error if read_only is set"
+# Bug#22077 DROP TEMPORARY TABLE fails with wrong error if read_only is set
#
# check if DROP TEMPORARY on a non-existing temporary table returns the right
# error
@@ -221,12 +256,15 @@ drop temporary table if exists ttt;
#
# Cleanup
#
+--echo connection default;
connection default;
set global read_only=0;
+disconnect con1;
drop table t1,t2;
drop user test@localhost;
+
--echo #
---echo # Bug #27440 read_only allows create and drop database
+--echo # Bug#27440 read_only allows create and drop database
--echo #
set global read_only= 1;
--disable_warnings
@@ -244,14 +282,18 @@ grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
create database mysqltest_db1;
grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
flush privileges;
+--echo connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,MASTER_MYPORT,);
connect (con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,);
+--echo connection con_bug27440;
connection con_bug27440;
--error ER_OPTION_PREVENTS_STATEMENT
create database mysqltest_db2;
show databases like '%mysqltest_db2%';
--error ER_OPTION_PREVENTS_STATEMENT
drop database mysqltest_db1;
+--echo disconnect con_bug27440;
disconnect con_bug27440;
+--echo connection default;
connection default;
delete from mysql.user where User like 'mysqltest_%';
delete from mysql.db where User like 'mysqltest_%';
@@ -259,4 +301,8 @@ delete from mysql.tables_priv where User like 'mysqltest_%';
delete from mysql.columns_priv where User like 'mysqltest_%';
flush privileges;
drop database mysqltest_db1;
-set global read_only=0;
+set global read_only= @start_read_only;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test
index fce37d8466d..5aa1a51a90f 100644
--- a/mysql-test/t/rename.test
+++ b/mysql-test/t/rename.test
@@ -2,6 +2,8 @@
# Test of rename table
#
+--source include/count_sessions.inc
+
--disable_warnings
drop table if exists t0,t1,t2,t3,t4;
# Clear up from other tests (to ensure that SHOW TABLES below is right)
@@ -19,16 +21,16 @@ rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
select * from t1;
# The following should give errors
---error 1050,1050
+--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t1 to t2;
---error 1050,1050
+--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t1 to t1;
---error 1050,1050
+--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t3 to t4, t2 to t3, t1 to t2, t4 to t2;
show tables like "t_";
---error 1050,1050
+--error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
rename table t3 to t1, t2 to t3, t1 to t2, t4 to t1;
---error 1017,1017
+--error ER_FILE_NOT_FOUND,ER_FILE_NOT_FOUND
rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1;
select * from t1;
@@ -63,7 +65,7 @@ connection con2;
# Wait for the the tables to be renamed
# i.e the query below succeds
let $query= select * from t2, t4;
-source include/wait_for_query_to_suceed.inc;
+source include/wait_for_query_to_succeed.inc;
show tables;
@@ -83,13 +85,15 @@ connection default;
create table t1(f1 int);
create view v1 as select * from t1;
alter table v1 rename to v2;
---error 1146
+--error ER_NO_SUCH_TABLE
alter table v1 rename to v2;
rename table v2 to v1;
---error 1050
+--error ER_TABLE_EXISTS_ERROR
rename table v2 to v1;
drop view v1;
drop table t1;
-
--echo End of 5.0 tests
+
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test
index 1601f7afd0e..fcc4259168b 100644
--- a/mysql-test/t/row.test
+++ b/mysql-test/t/row.test
@@ -237,3 +237,21 @@ SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a;
SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a;
DROP TABLE t1;
+
+#
+# Bug#37601 Cast Is Not Done On Row Comparison
+#
+create table t1 (a varchar(200),
+ b int unsigned not null primary key auto_increment)
+default character set 'utf8';
+
+create table t2 (c varchar(200),
+ d int unsigned not null primary key auto_increment)
+default character set 'latin1';
+
+insert into t1 (a) values('abc');
+insert into t2 (c) values('abc');
+select * from t1,t2 where (a,b) = (c,d);
+
+select host,user from mysql.user where (host,user) = ('localhost','test');
+drop table t1,t2;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index ccdb53ec11f..715bdf0e667 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3726,6 +3726,20 @@ cr.f4 = cr2.f4
GROUP BY a.f3, cr.f4;
drop table t1, t2, t3;
+
+
+#
+# Bug #40925: Equality propagation takes non indexed attribute
+#
+
+CREATE TABLE t1 (a INT KEY, b INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
+
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2;
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests
#
@@ -3769,4 +3783,20 @@ SELECT date_nokey FROM C
DROP TABLE A,C;
+#
+# Bug #42957: no results from
+# select where .. (col=col and col=col) or ... (false expression)
+#
+CREATE TABLE t1 (a INT NOT NULL, b INT);
+INSERT INTO t1 VALUES (1, 1);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
+SELECT * FROM t1 WHERE (a=a AND a=a) OR b > 2;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, c INT NOT NULL);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND c=c) OR b > 20;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND a=a AND b=b) OR b > 20;
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a=a AND b=b AND a=a) OR b > 20;
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysql-test/t/shm.test b/mysql-test/t/shm.test
index 380607d8ebf..88e96ae7b45 100644
--- a/mysql-test/t/shm.test
+++ b/mysql-test/t/shm.test
@@ -16,4 +16,23 @@ if (`SELECT '$shm' != 'ON'`){
#
--exec $MYSQLADMIN --no-defaults --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ping
+#
+# 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;
+SET @net_buffer_length= @@global.net_buffer_length;
+
+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
+
+SET GLOBAL max_allowed_packet= @max_allowed_packet;
+SET GLOBAL net_buffer_length= @net_buffer_length;
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 116298a9c80..0ce807ae73e 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -5,6 +5,9 @@
# 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
#
@@ -195,7 +198,7 @@ show columns from t1;
drop table t1;
#
-# Test for Bug #2593 "SHOW CREATE TABLE doesn't properly double quotes"
+# Test for Bug#2593 SHOW CREATE TABLE doesn't properly double quotes
#
SET @old_sql_mode= @@sql_mode, sql_mode= '';
@@ -223,7 +226,7 @@ CREATE TABLE """a" (i INT);
SHOW CREATE TABLE """a";
DROP TABLE """a";
-#Bug #4374 SHOW TABLE STATUS FROM ignores collation_connection
+# Bug#4374 SHOW TABLE STATUS FROM ignores collation_connection
#set names latin1;
#create database `ä`;
#create table `ä`.`ä` (a int) engine=heap;
@@ -248,7 +251,7 @@ SET sql_quote_show_create= @old_sql_quote_show_create;
SET sql_mode= @old_sql_mode;
#
-# Test for bug #2719 "Heap tables status shows wrong or missing data."
+# Test for Bug#2719 Heap tables status shows wrong or missing data.
#
select @@max_heap_table_size;
@@ -309,7 +312,7 @@ show table status;
drop table t1, t2, t3;
#
-# Test for bug #3342 SHOW CREATE DATABASE seems to require DROP privilege
+# Test for Bug#3342 SHOW CREATE DATABASE seems to require DROP privilege
#
create database mysqltest;
@@ -324,35 +327,38 @@ connect (con1,localhost,mysqltest_1,,mysqltest);
connection con1;
select * from t1;
show create database mysqltest;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
drop table t1;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
drop database mysqltest;
+disconnect con1;
connect (con2,localhost,mysqltest_2,,test);
connection con2;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select * from mysqltest.t1;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
show create database mysqltest;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
drop table mysqltest.t1;
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
drop database mysqltest;
+disconnect con2;
connect (con3,localhost,mysqltest_3,,test);
connection con3;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select * from mysqltest.t1;
show create database mysqltest;
drop table mysqltest.t1;
drop database mysqltest;
+disconnect con3;
connection default;
set names binary;
-delete from mysql.user
+delete from mysql.user
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
-delete from mysql.db
+delete from mysql.db
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
flush privileges;
@@ -366,7 +372,7 @@ flush privileges;
#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)
+# specified during table creation, but not otherwise. (Bug#7235)
CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY;
SHOW CREATE TABLE t1;
DROP TABLE t1;
@@ -397,7 +403,7 @@ ALTER TABLE t1 ENGINE=MEMORY;
SHOW CREATE TABLE t1;
DROP TABLE t1;
-# Test for BUG#9439 "Reporting wrong datatype for sub_part on show index"
+# Test for Bug#9439 Reporting wrong datatype for sub_part on show index
CREATE TABLE t1(
field1 text NOT NULL,
PRIMARY KEY(field1(1000))
@@ -407,7 +413,7 @@ show index from t1;
--disable_metadata
drop table t1;
-# Test for BUG#11635: mysqldump exports TYPE instead of USING for HASH
+# Test for Bug#11635 mysqldump exports TYPE instead of USING for HASH
create table t1 (
c1 int NOT NULL,
c2 int NOT NULL,
@@ -417,7 +423,7 @@ create table t1 (
SHOW CREATE TABLE t1;
DROP TABLE t1;
-# Test for BUG#93: 4.1 protocl crash on corupted frm and SHOW TABLE STATUS
+# Test for Bug#93 4.1 protocl crash on corupted frm and SHOW TABLE STATUS
flush tables;
@@ -426,19 +432,19 @@ let $MYSQLD_DATADIR= `select @@datadir`;
system echo "this is a junk file for test" >> $MYSQLD_DATADIR/test/t1.frm ;
--replace_column 6 # 7 # 8 # 9 #
SHOW TABLE STATUS like 't1';
---error 1033
+--error ER_NOT_FORM_FILE
show create table t1;
drop table if exists t1;
--error 1,0
--remove_file $MYSQLD_DATADIR/test/t1.frm
#
-# BUG 12183 - SHOW OPEN TABLES behavior doesn't match grammar
+# Bug#12183 SHOW OPEN TABLES behavior doesn't match grammar
# First we close all open tables with FLUSH tables and then we open some.
#
--echo
---echo # Bug#12183: SHOW OPEN TABLES behavior doesn't match grammar.
+--echo # Bug#12183 SHOW OPEN TABLES behavior doesn't match grammar.
--echo
# NOTE: SHOW OPEN TABLES does not sort result list by database or table names.
@@ -497,15 +503,15 @@ use test;
--echo
#
-# BUG #12591 (SHOW TABLES FROM dbname produces wrong error message)
+# Bug#12591 SHOW TABLES FROM dbname produces wrong error message
#
---error 1049
+--error ER_BAD_DB_ERROR
SHOW TABLES FROM non_existing_database;
--echo End of 4.1 tests
#
-# Bug#17203: "sql_no_cache sql_cache" in views created from prepared
+# Bug#17203 "sql_no_cache sql_cache" in views created from prepared
# statement
#
# The problem was that initial user setting was forgotten, and current
@@ -585,7 +591,7 @@ SHOW COLUMNS FROM no_such_table;
#
-# Bug #19764: SHOW commands end up in the slow log as table scans
+# Bug#19764 SHOW commands end up in the slow log as table scans
#
flush status;
show status like 'slow_queries';
@@ -597,7 +603,7 @@ select 1 from information_schema.tables limit 1;
show status like 'slow_queries';
create table t1 (a int);
-create trigger tr1 before insert on t1 for each row
+create trigger tr1 before insert on t1 for each row
begin
end;
create view v1 as select a from t1;
@@ -657,9 +663,10 @@ drop table t1;
drop procedure p1;
drop function f1;
drop event e1;
+
#
-# BUG#10491: Server returns data as charset binary SHOW CREATE TABLE or SELECT
-# FROM I_S.
+# Bug#10491 Server returns data as charset binary SHOW CREATE TABLE or SELECT
+# FROM I_S.
#
#
@@ -774,7 +781,7 @@ SHOW TRIGGERS LIKE 't1';
--echo ----------------------------------------------------------------
-SELECT
+SELECT
TRIGGER_CATALOG,
TRIGGER_SCHEMA,
TRIGGER_NAME,
@@ -897,10 +904,12 @@ CREATE TABLE t1(ËÏÌÏÎËÁ1 INT);
# Check:
# - Dump mysqltest1;
+--let $outfile1=$MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
+
--echo
---echo ---> Dumping mysqltest1 to show_check.mysqltest1.sql
+--echo ---> Dumping mysqltest1 to outfile1
---exec $MYSQL_DUMP --default-character-set=latin1 --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
+--exec $MYSQL_DUMP --default-character-set=latin1 --character-sets-dir=$CHARSETSDIR --databases mysqltest1 > $outfile1
# - Clean mysqltest1;
@@ -915,7 +924,8 @@ DROP DATABASE mysqltest1;
--echo
--echo ---> Restoring mysqltest1...
---exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/show_check.mysqltest1.sql
+--exec $MYSQL test < $outfile1
+--remove_file $outfile1
# - Check definition of the table.
@@ -927,7 +937,7 @@ DROP DATABASE mysqltest1;
use test;
#
-# Bug #28808: log_queries_not_using_indexes variable dynamic change is ignored
+# Bug#28808 log_queries_not_using_indexes variable dynamic change is ignored
#
flush status;
show variables like "log_queries_not_using_indexes";
@@ -943,7 +953,7 @@ select 1 from information_schema.tables limit 1;
show status like 'slow_queries';
#
-# Bug #30088: Can't disable myisam-recover by a value of ""
+# Bug#30088 Can't disable myisam-recover by a value of ""
#
show variables like 'myisam_recover_options';
@@ -974,7 +984,8 @@ SHOW AUTHORS;
--enable_result_log
#
-# Test for bug #9785 SELECT privilege for the whole database is needed to do SHOW CREATE DATABASE
+# Bug#9785 SELECT privilege for the whole database is needed to do
+# SHOW CREATE DATABASE
#
create database mysqltest;
show create database mysqltest;
@@ -990,6 +1001,8 @@ 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
@@ -1005,8 +1018,8 @@ show plugins;
--enable_result_log
#
-# Bug #19874: SHOW COLUMNS and SHOW KEYS handle identifiers containing
-# \ incorrectly
+# Bug#19874 SHOW COLUMNS and SHOW KEYS handle identifiers containing
+# \ incorrectly
#
create database `mysqlttest\1`;
create table `mysqlttest\1`.`a\b` (a int);
@@ -1018,7 +1031,7 @@ drop table `mysqlttest\1`.`a\b`;
drop database `mysqlttest\1`;
#
-# Bug#24392: SHOW ENGINE MUTEX STATUS is a synonym for SHOW INNODB STATUS
+# Bug#24392 SHOW ENGINE MUTEX STATUS is a synonym for SHOW INNODB STATUS
#
--error ER_UNKNOWN_STORAGE_ENGINE
@@ -1104,8 +1117,8 @@ DROP PROCEDURE p1;
DEALLOCATE PREPARE stmt1;
#
-# BUG#10491: Server returns data as charset binary SHOW CREATE TABLE or SELECT
-# FROM INFORMATION_SCHEMA.
+# Bug#10491 Server returns data as charset binary SHOW CREATE TABLE or SELECT
+# FROM INFORMATION_SCHEMA.
#
# Before the change performed to fix the bug, the metadata of the output of
# SHOW CREATE statements would always describe the result as 'binary'. That
@@ -1168,17 +1181,17 @@ DROP TABLE t1;
DROP EVENT ev1;
#
-# Bug #30036: SHOW TABLE TYPES causes the debug client to crash
+# Bug#30036 SHOW TABLE TYPES causes the debug client to crash
#
--disable_result_log
SHOW TABLE TYPES;
--enable_result_log
+
#
-# Bug #32710: SHOW INNODB STATUS requires SUPER
+# Bug#32710 SHOW INNODB STATUS requires SUPER
#
-
CREATE USER test_u@localhost;
GRANT PROCESS ON *.* TO test_u@localhost;
@@ -1195,3 +1208,7 @@ DROP USER test_u@localhost;
--echo End of 5.1 tests
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/skip_name_resolve.test b/mysql-test/t/skip_name_resolve.test
index 3f732c8912b..df010d15fa0 100644
--- a/mysql-test/t/skip_name_resolve.test
+++ b/mysql-test/t/skip_name_resolve.test
@@ -1,7 +1,10 @@
# Can't be tested with embedded server
--- source include/not_embedded.inc
+--source include/not_embedded.inc
-# Bug #8471: IP address with mask fail when skip-name-resolve is on
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+# Bug#8471 IP address with mask fail when skip-name-resolve is on
GRANT ALL ON test.* TO mysqltest_1@'127.0.0.1/255.255.255.255';
SHOW GRANTS FOR mysqltest_1@'127.0.0.1/255.255.255.255';
REVOKE ALL ON test.* FROM mysqltest_1@'127.0.0.1/255.255.255.255';
@@ -9,12 +12,20 @@ DROP USER mysqltest_1@'127.0.0.1/255.255.255.255';
# End of 4.1 tests
-# Bug #13407 "Remote connecting crashes server".
+# 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, );
--replace_column 1 #
-select user();
---replace_column 1 <id> 3 <host> 5 <command> 6 <time> 7 <state> 8 <info>
-show processlist;
+SELECT USER();
+# We are only interested in the fact that statement below doesn't
+# crash server.
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
connection default;
+disconnect con1;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index b372c05b6e3..a80fe89082a 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -5,6 +5,9 @@
# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
connect (con1root,localhost,root,,);
connection con1root;
@@ -156,7 +159,7 @@ call db1_secret.stamp(6);
select db1_secret.db();
#
-# BUG#2777
+# Bug#2777 Stored procedure doesn't observe definer's rights
#
connection con1root;
@@ -215,7 +218,7 @@ call q();
select * from t2;
#
-# BUG#6030: Stored procedure has no appropriate DROP privilege
+# Bug#6030 Stored procedure has no appropriate DROP privilege
# (or ALTER for that matter)
# still connection con2user1 in db2
@@ -330,7 +333,7 @@ flush privileges;
drop table t1;
#
-# BUG#9503: reseting correct parameters of thread after error in SP function
+# Bug#9503 reseting correct parameters of thread after error in SP function
#
connect (root,localhost,root,,test);
connection root;
@@ -366,10 +369,12 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
drop function bug_9503;
use test;
drop database mysqltest;
+connection default;
+disconnect root;
#
# correct value from current_user() in function run from "security definer"
-# (BUG#7291)
+# (Bug#7291 Stored procedures: wrong CURRENT_USER value)
#
connection con1root;
use test;
@@ -398,10 +403,10 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
drop user user1@localhost;
#
-# Bug #12318: Wrong error message when accessing an inaccessible stored
+# Bug#12318 Wrong error message when accessing an inaccessible stored
# procedure in another database when the current database is
# information_schema.
-#
+#
--disable_warnings
drop database if exists mysqltest_1;
@@ -438,7 +443,7 @@ revoke usage on *.* from mysqltest_1@localhost;
drop user mysqltest_1@localhost;
#
-# BUG#12812 create view calling a function works without execute right
+# Bug#12812 create view calling a function works without execute right
# on function
delimiter |;
--disable_warnings
@@ -464,7 +469,7 @@ delimiter ;|
#
-# BUG#14834: Server denies to execute Stored Procedure
+# Bug#14834 Server denies to execute Stored Procedure
#
# The problem here was with '_' in the database name.
#
@@ -507,7 +512,7 @@ drop database db_bug14834;
#
-# BUG#14533: 'desc tbl' in stored procedure causes error
+# Bug#14533 'desc tbl' in stored procedure causes error
# ER_TABLEACCESS_DENIED_ERROR
#
create database db_bug14533;
@@ -546,7 +551,7 @@ drop database db_bug14533;
#
-# WL#2897: Complete definer support in the stored routines.
+# WL#2897 Complete definer support in the stored routines.
#
# The following cases are tested:
# 1. check that if DEFINER-clause is not explicitly specified, stored routines
@@ -591,7 +596,7 @@ GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
--echo ---> connection: mysqltest_2_con
--connection mysqltest_2_con
-use mysqltest;
+USE mysqltest;
CREATE PROCEDURE wl2897_p1() SELECT 1;
@@ -603,7 +608,7 @@ CREATE FUNCTION wl2897_f1() RETURNS INT RETURN 1;
--echo ---> connection: mysqltest_1_con
--connection mysqltest_1_con
-use mysqltest;
+USE mysqltest;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
CREATE DEFINER=root@localhost PROCEDURE wl2897_p2() SELECT 2;
@@ -629,7 +634,7 @@ CREATE DEFINER='a @ b @ c'@localhost FUNCTION wl2897_f3() RETURNS INT RETURN 3;
--echo ---> connection: con1root
--connection con1root
-use mysqltest;
+USE mysqltest;
SHOW CREATE PROCEDURE wl2897_p1;
SHOW CREATE PROCEDURE wl2897_p3;
@@ -649,7 +654,7 @@ DROP DATABASE mysqltest;
#
-# BUG#13198: SP executes if definer does not exist
+# Bug#13198 SP executes if definer does not exist
#
# Prepare environment.
@@ -679,7 +684,7 @@ GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
--echo ---> connection: mysqltest_1_con
--connection mysqltest_1_con
-use mysqltest;
+USE mysqltest;
CREATE PROCEDURE bug13198_p1()
SELECT 1;
@@ -697,7 +702,7 @@ SELECT bug13198_f1();
--echo ---> connection: mysqltest_2_con
--connection mysqltest_2_con
-use mysqltest;
+USE mysqltest;
CALL bug13198_p1();
@@ -719,7 +724,7 @@ DROP USER mysqltest_1@localhost;
--echo ---> connection: mysqltest_2_con
--connection mysqltest_2_con
-use mysqltest;
+USE mysqltest;
--error ER_NO_SUCH_USER
CALL bug13198_p1();
@@ -740,8 +745,8 @@ DROP USER mysqltest_2@localhost;
DROP DATABASE mysqltest;
#
-# Bug#19857 - When a user with CREATE ROUTINE priv creates a routine,
-# it results in NULL p/w
+# Bug#19857 When a user with CREATE ROUTINE priv creates a routine,
+# it results in NULL p/w
#
# Can't test with embedded server that doesn't support grants
@@ -756,7 +761,7 @@ SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
--echo ---> connection: mysqltest_2_con
--connection mysqltest_2_con
-use test;
+USE test;
DELIMITER //;
CREATE PROCEDURE sp19857() DETERMINISTIC
@@ -790,8 +795,7 @@ DROP USER user19857@localhost;
use test;
#
-# BUG#18630: Arguments of suid routine calculated in wrong security
-# context
+# Bug#18630 Arguments of suid routine calculated in wrong security context
#
# Arguments of suid routines were calculated in definer's security
# context instead of caller's context thus creating security hole.
@@ -862,3 +866,7 @@ DROP FUNCTION f_suid;
DROP TABLE t1;
--echo End of 5.0 tests.
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/sp-threads.test b/mysql-test/t/sp-threads.test
index d8a8ce5dae7..e1012e2b72d 100644
--- a/mysql-test/t/sp-threads.test
+++ b/mysql-test/t/sp-threads.test
@@ -5,6 +5,9 @@
# except security/privilege tests, they go to sp-security.test
#
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
connect (con1root,localhost,root,,);
connect (con2root,localhost,root,,);
connect (con3root,localhost,root,,);
@@ -17,7 +20,7 @@ drop table if exists t1;
--enable_warnings
create table t1 (s1 int, s2 int, s3 int);
-delimiter //;
+delimiter //;
create procedure bug4934()
begin
insert into t1 values (1,0,1);
@@ -38,7 +41,7 @@ drop table t1;
create table t1 (s1 int, s2 int, s3 int);
drop procedure bug4934;
-delimiter //;
+delimiter //;
create procedure bug4934()
begin
end//
@@ -58,7 +61,7 @@ drop procedure bug4934;
#
-# BUG #9486 "Can't perform multi-update in stored procedure"
+# Bug#9486 Can't perform multi-update in stored procedure
#
--disable_warnings
drop procedure if exists bug9486;
@@ -87,8 +90,9 @@ reap;
drop procedure bug9486;
drop table t1, t2;
+
#
-# BUG#11158: Can't perform multi-delete in stored procedure
+# Bug#11158 Can't perform multi-delete in stored procedure
#
--disable_warnings
drop procedure if exists bug11158;
@@ -114,8 +118,9 @@ connection con1root;
drop procedure bug11158;
drop table t1, t2;
+
#
-# BUG#11554: Server crashes on statement indirectly using non-cached function
+# Bug#11554 Server crashes on statement indirectly using non-cached function
#
--disable_warnings
drop function if exists bug11554;
@@ -134,7 +139,7 @@ drop table t1;
drop view v1;
-# BUG#12228
+# Bug#12228 Crash happens during calling specific SP in multithread environment
--disable_warnings
drop procedure if exists p1;
drop procedure if exists p2;
@@ -168,18 +173,26 @@ connection con2root;
unlock tables;
connection con1root;
-# Crash will be here if we hit BUG#12228
+# Crash will be here if we hit Bug#12228
reap;
drop procedure p1;
drop procedure p2;
drop table t1;
+
#
-# BUG#NNNN: New bug synopsis
+# Bug#NNNN New bug synopsis
#
#--disable_warnings
#drop procedure if exists bugNNNN;
#--enable_warnings
#create procedure bugNNNN...
+connection default;
+disconnect con1root;
+disconnect con2root;
+disconnect con3root;
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index d57fe777953..fdf6ed8f382 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1272,7 +1272,7 @@ select *, f8() from v1|
# Let us test what will happen if function is missing
drop function f1|
---error 1356
+--error ER_VIEW_INVALID
select * from v1|
# And what will happen if we have recursion which involves
@@ -1311,9 +1311,9 @@ select f0()|
select * from v0|
select *, f0() from v0, (select 123) as d1|
# But these should not !
---error 1100
+--error ER_TABLE_NOT_LOCKED
select id, f3() from t1|
---error 1100
+--error ER_TABLE_NOT_LOCKED
select f4()|
unlock tables|
@@ -1323,9 +1323,9 @@ lock tables v2 read, mysql.proc read|
select * from v2|
select * from v1|
# These should not work as we have too little instances of tables locked
---error 1100
+--error ER_TABLE_NOT_LOCKED
select * from v1, t1|
---error 1100
+--error ER_TABLE_NOT_LOCKED
select f4()|
unlock tables|
@@ -5255,19 +5255,31 @@ drop procedure bug5967|
#
# Bug#13012 "SP: REPAIR/BACKUP/RESTORE TABLE crashes the server"
#
+--let $backupdir = $MYSQLTEST_VARDIR/tmp/
+--error 0,1
+--remove_file $backupdir/t1.frm
+--error 0,1
+--remove_file $backupdir/t1.MYD
+
--disable_warnings
drop procedure if exists bug13012|
# Disable warnings also for BACKUP/RESTORE: they are deprecated.
-create procedure bug13012()
-BEGIN
- REPAIR TABLE t1;
- BACKUP TABLE t1 to '../../tmp';
- DROP TABLE t1;
- RESTORE TABLE t1 FROM '../../tmp';
-END|
+--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|
+
create view v1 as select * from t1|
create procedure bug13012()
BEGIN
@@ -8258,6 +8270,33 @@ select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mo
select name from mysql.proc where name = 'p' and sql_mode = @full_mode;
drop procedure p;
+#
+# Bug#43962 "Packets out of order" calling a SHOW TABLE STATUS
+#
+DELIMITER //;
+CREATE DEFINER = 'root'@'localhost' PROCEDURE p1()
+NOT DETERMINISTIC
+CONTAINS SQL
+SQL SECURITY DEFINER
+COMMENT ''
+BEGIN
+ SHOW TABLE STATUS like 't1';
+END;//
+DELIMITER ;//
+
+
+CREATE TABLE t1 (f1 INT);
+--disable_result_log
+let $tab_count= 4;
+while ($tab_count)
+{
+ EVAL CALL p1();
+ dec $tab_count ;
+}
+--enable_result_log
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test
index 16ebb710f25..f540126c405 100644
--- a/mysql-test/t/sp_notembedded.test
+++ b/mysql-test/t/sp_notembedded.test
@@ -4,13 +4,17 @@
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
--disable_warnings
drop table if exists t1,t3;
--enable_warnings
delimiter |;
+
#
-# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
+# Bug#4902 Stored procedure with SHOW WARNINGS leads to packet error
#
# Added tests for show grants command
--disable_warnings
@@ -52,15 +56,14 @@ show warnings|
drop procedure bug4902_2|
#
-# BUG#3583: query cache doesn't work for stored procedures
+# Bug#3583 query cache doesn't work for stored procedures
#
-
--disable_warnings
drop table if exists t1|
--enable_warnings
create table t1 (
- id char(16) not null default '',
- data int not null
+ id char(16) not null default '',
+ data int not null
)|
--disable_warnings
drop procedure if exists bug3583|
@@ -97,8 +100,9 @@ delete from t1|
drop procedure bug3583|
drop table t1|
+
#
-# BUG#6807: Stored procedure crash if CREATE PROCEDURE ... KILL QUERY
+# Bug#6807 Stored procedure crash if CREATE PROCEDURE ... KILL QUERY
#
--disable_warnings
drop procedure if exists bug6807|
@@ -112,16 +116,16 @@ begin
select 'Not reached';
end|
---error 1317
+--error ER_QUERY_INTERRUPTED
call bug6807()|
---error 1317
+--error ER_QUERY_INTERRUPTED
call bug6807()|
drop procedure bug6807|
#
-# BUG#10100: function (and stored procedure?) recursivity problem
+# Bug#10100 function (and stored procedure?) recursivity problem
#
--disable_warnings
drop function if exists bug10100f|
@@ -220,11 +224,11 @@ begin
close c;
end|
-#end of the stack checking
+# end of the stack checking
set @@max_sp_recursion_depth=255|
set @var=1|
-#disable log because error about stack overrun contains numbers which
-#depend on a system
+# disable log because error about stack overrun contains numbers which
+# depend on a system
-- disable_result_log
-- error ER_STACK_OVERRUN_NEED_MORE
call bug10100p(255, @var)|
@@ -253,6 +257,7 @@ drop table t3|
delimiter ;|
+
#
# Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context
#
@@ -269,6 +274,7 @@ call 15298_1();
call 15298_2();
connection default;
+disconnect con1;
drop user mysqltest_1@localhost;
drop procedure 15298_1;
drop procedure 15298_2;
@@ -334,6 +340,7 @@ connection default;
disconnect rl_holder;
disconnect rl_acquirer;
disconnect rl_wait;
+disconnect rl_contender;
drop procedure p1;
drop table t1;
set session low_priority_updates=default;
@@ -343,3 +350,7 @@ set session low_priority_updates=default;
#
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_trans_log.test b/mysql-test/t/sp_trans_log.test
index 447ec19b132..2f2b84a9bef 100644
--- a/mysql-test/t/sp_trans_log.test
+++ b/mysql-test/t/sp_trans_log.test
@@ -8,17 +8,17 @@
delimiter |;
#
-# Bug #13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog
-# Bug #23333 stored function + non-transac table + transac table =
-# breaks stmt-based binlog
-# Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF()
+# Bug#13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog
+# Bug#23333 stored function + non-transac table + transac table =
+# breaks stmt-based binlog
+# Bug#27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF()
#
--disable_warnings
drop function if exists bug23333|
drop table if exists t1,t2|
--enable_warnings
- CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
- CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
+CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM|
+CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
insert into t2 values (1,1)|
diff --git a/mysql-test/t/ssl-big.test b/mysql-test/t/ssl-big.test
index 099c64df08f..91103f1d782 100644
--- a/mysql-test/t/ssl-big.test
+++ b/mysql-test/t/ssl-big.test
@@ -4,12 +4,15 @@
-- source include/have_ssl.inc
-- source include/big_test.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
#
-# Bug #29579 Clients using SSL can hang the server
+# Bug#29579 Clients using SSL can hang the server
#
connect (ssl_con,localhost,root,,,,,SSL);
@@ -18,7 +21,7 @@ create table t1 (a int);
disconnect ssl_con;
-
+
--disable_query_log
--disable_result_log
@@ -26,31 +29,36 @@ let $count= 2000;
while ($count)
{
connect (ssl_con,localhost,root,,,,,SSL);
-
+
eval insert into t1 values ($count);
dec $count;
-
- # This select causes the net buffer to fill as the server sends the results
+
+ # This select causes the net buffer to fill as the server sends the results
# but the client doesn't reap the results. The results are larger each time
# through the loop, so that eventually the buffer is completely full
# at the exact moment the server attempts to the close the connection with
# the lock held.
send select * from t1;
-
+
# now send the quit the command so the server will initiate the shutdown.
- send_quit ssl_con;
-
+ send_quit ssl_con;
+
# if the server is hung, this will hang too:
connect (ssl_con2,localhost,root,,,,,SSL);
-
+
# no hang if we get here, close and retry
disconnect ssl_con2;
disconnect ssl_con;
-}
+}
--enable_query_log
--enable_result_log
connect (ssl_con,localhost,root,,,,,SSL);
drop table t1;
+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.test b/mysql-test/t/ssl.test
index a15f0212fbd..936652eaa3d 100644
--- a/mysql-test/t/ssl.test
+++ b/mysql-test/t/ssl.test
@@ -3,6 +3,9 @@
-- source include/have_ssl.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
connect (ssl_con,localhost,root,,,,,SSL);
# Check ssl turned on
@@ -14,4 +17,9 @@ SHOW STATUS LIKE 'Ssl_cipher';
# Check ssl turned on
SHOW STATUS LIKE 'Ssl_cipher';
+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 23051c0e367..b6e11621bf6 100644
--- a/mysql-test/t/ssl_compress.test
+++ b/mysql-test/t/ssl_compress.test
@@ -4,6 +4,9 @@
-- source include/have_ssl.inc
-- source include/have_compress.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
connect (ssl_compress_con,localhost,root,,,,,SSL COMPRESS);
# Check ssl turned on
@@ -20,3 +23,10 @@ SHOW STATUS LIKE 'Ssl_cipher';
# Check compression turned on
SHOW STATUS LIKE 'Compression';
+
+connection default;
+disconnect ssl_compress_con;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index 69ae56ff9a2..5842f59af5c 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -268,6 +268,7 @@ show status like 'Com%function';
#
connect (root, localhost, root,,test);
connection root;
+let $root_connection_id= `select connection_id()`;
--disable_warnings
create database db37908;
--enable_warnings
@@ -282,6 +283,7 @@ delimiter ;|
connect (user1,localhost,mysqltest_1,,test);
connection user1;
+let $user1_connection_id= `select connection_id()`;
--error ER_TABLEACCESS_DENIED_ERROR
select * from db37908.t1;
@@ -300,8 +302,12 @@ drop procedure proc37908;
drop function func37908;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
DROP USER mysqltest_1@localhost;
-# Wait till we reached the initial number of concurrent sessions
---source include/wait_until_count_sessions.inc
+# Wait till the sessions user1 and root are disconnected
+let $wait_condition =
+ SELECT COUNT(*) = 0
+ FROM information_schema.processlist
+ WHERE id in ('$root_connection_id','$user1_connection_id');
+--source include/wait_condition.inc
#
# Bug#41131 "Questions" fails to increment - ignores statements instead stored procs
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index f2ce045840c..5779ea97bc2 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -1163,11 +1163,11 @@ set @@sql_mode= @org_mode;
# Bug #13934 Silent truncation of table comments
#
set @@sql_mode='traditional';
---error 1105
+--error ER_TOO_LONG_TABLE_COMMENT
create table t1 (i int)
comment '123456789*123456789*123456789*123456789*123456789*
123456789*123456789*123456789*123456789*123456789*';
---error 1105
+--error ER_TOO_LONG_FIELD_COMMENT
create table t1 (
i int comment
'123456789*123456789*123456789*123456789*
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 9dcb645b28d..e82764d6ac4 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -78,9 +78,9 @@ select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
explain extended (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
-select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
-explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
(select * from t2 where a>1) as tt;
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1);
@@ -367,7 +367,7 @@ let $wait_condition= SELECT COUNT(*) <> $row_count_before FROM t1;
--source include/wait_condition.inc
select * from t1;
#
-#TODO: should be uncommented after bug 380 fix pushed
+#TODO: should be uncommented after Bug#380 fix pushed
#INSERT INTO t1 (x) SELECT (SELECT SUM(a)+b FROM t2) from t3;
#select * from t1;
drop table t1, t2, t3;
@@ -536,7 +536,7 @@ do (SELECT a from t1);
-- error ER_NO_SUCH_TABLE
set @a:=(SELECT a from t1);
-CREATE TABLE t1 (a int, KEY(a));
+CREATE TABLE t1 (a int, KEY(a));
HANDLER t1 OPEN;
-- error ER_PARSE_ERROR
HANDLER t1 READ a=((SELECT 1));
@@ -678,7 +678,7 @@ CREATE TABLE t2 (
INSERT INTO t2 VALUES ('AUS','Australia','Oceania','Australia and New Zealand',7741220.00,1901,18886000,79.8,351182.00,392911.00,'Australia','Constitutional Monarchy, Federation','Elisabeth II',135,'AU');
INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,7734000,62.9,4127.00,4100.00,'Azärbaycan','Federal Republic','Heydär Äliyev',144,'AZ');
-select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1.t2 where t1.Population IN (select max(t1.Population) AS Population from t1, t2 where t1.t2 = t2.Code group by Continent);
+select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1.t2 where t1.Population IN (select max(t1.Population) AS Population from t1, t2 where t1.t2 = t2.Code group by Continent);
drop table t1, t2;
@@ -732,9 +732,9 @@ drop table t1,t2;
#
# correct NULL in <CONSTANT> IN (SELECT ...)
#
-create table t1 (a int, unique index indexa (a));
-insert into t1 values (-1), (-4), (-2), (NULL);
-select -10 IN (select a from t1 FORCE INDEX (indexa));
+create table t1 (a int, unique index indexa (a));
+insert into t1 values (-1), (-4), (-2), (NULL);
+select -10 IN (select a from t1 FORCE INDEX (indexa));
drop table t1;
#
@@ -816,7 +816,7 @@ disable_query_log;
let $1 = 10000;
while ($1)
{
- eval insert into t1 values (rand()*100000+200,rand()*100000);
+ eval insert into t1 values (rand()*100000+200,rand()*100000);
dec $1;
}
enable_query_log;
@@ -842,7 +842,7 @@ create table t2 (a int, b int);
create table t3 (a int, b int);
insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10);
insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1);
-insert into t3 values (3,3), (2,2), (1,1);
+insert into t3 values (3,3), (2,2), (1,1);
select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3;
drop table t1,t2,t3;
@@ -1010,7 +1010,7 @@ drop table t1, t2;
#
# unresolved field error
#
-create table t1 (s1 int);
+create table t1 (s1 int);
create table t2 (s1 int);
-- error ER_BAD_FIELD_ERROR
select * from t1 where (select count(*) from t2 where t1.s2) = 1;
@@ -1035,11 +1035,12 @@ INSERT INTO t1 VALUES (1),(1),(1),(1),(1),(2),(3),(4),(5);
SELECT DISTINCT (SELECT a) FROM t1 LIMIT 100;
DROP TABLE t1;
+
#
-# Bug 2198
+# Bug#2198 SELECT INTO OUTFILE (with Sub-Select) Problem
#
-create table t1 (a int, b decimal(13, 3));
+create table t1 (a int, b decimal(13, 3));
insert into t1 values (1, 0.123);
let $outfile_abs= $MYSQLTEST_VARDIR/tmp/subselect.out.file.1;
let $outfile_rel= ../../tmp/subselect.out.file.1;
@@ -1052,8 +1053,9 @@ eval load data infile "$outfile_rel" into table t1;
select * from t1;
drop table t1;
+
#
-# Bug 2479
+# Bug#2479 dependant subquery with limit crash
#
CREATE TABLE `t1` (
@@ -1091,8 +1093,9 @@ select 2 in (select * from t1);
SET SQL_SELECT_LIMIT=default;
drop table t1;
+
#
-# Bug #3118: subselect + order by
+# Bug#3118 subselect + order by
#
CREATE TABLE t1 (a int, b int, INDEX (a));
@@ -1131,8 +1134,9 @@ insert into t1 values (1);
explain select benchmark(1000, (select a from t1 where a=sha(rand())));
drop table t1;
+
#
-# bug 3188
+# Bug#3188 Ambiguous Column in Subselect crashes server
#
create table t1(id int);
create table t2(id int);
@@ -1141,8 +1145,9 @@ create table t3(flag int);
select (select * from t3 where id not null) from t1, t2;
drop table t1,t2,t3;
+
#
-# aggregate functions (Bug #3505)
+# aggregate functions (Bug#3505 Wrong results on use of ORDER BY with subqueries)
#
CREATE TABLE t1 (id INT);
CREATE TABLE t2 (id INT);
@@ -1333,8 +1338,9 @@ select * from t1 up where exists (select * from t1 where t1.a=up.a);
explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a);
drop table t1;
+
#
-# Bug #4102: subselect in HAVING
+# Bug#4102 subselect in HAVING
#
CREATE TABLE t1 (t1_a int);
@@ -1345,8 +1351,10 @@ SELECT * FROM t1, t2 table2 WHERE t1_a = 1 AND table2.t2_a = 1
HAVING table2.t2_b = (SELECT MAX(t2_b) FROM t2 WHERE t2_a = table2.t2_a);
DROP TABLE t1, t2;
+
#
-# Test problem with NULL and derived tables (Bug #4097)
+# Test problem with NULL and derived tables
+# (Bug#4097 JOIN with subquery causes entire column to report NULL)
#
CREATE TABLE t1 (id int(11) default NULL,name varchar(10) default NULL);
@@ -1356,18 +1364,19 @@ INSERT INTO t2 VALUES (1,'Fido'),(2,'Spot'),(3,'Felix');
SELECT a.*, b.* FROM (SELECT * FROM t1) AS a JOIN t2 as b on a.id=b.id;
drop table t1,t2;
+
#
# outer fields resolving in INSERT/REPLACE and CRETE with SELECT
#
CREATE TABLE t1 ( a int, b int );
CREATE TABLE t2 ( c int, d int );
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
-SELECT a AS abc, b FROM t1 outr WHERE b =
+SELECT a AS abc, b FROM t1 outr WHERE b =
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
-INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b =
+INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b =
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t2;
-CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b =
+CREATE TABLE t3 SELECT a AS abc, b FROM t1 outr WHERE b =
(SELECT MIN(b) FROM t1 WHERE a=outr.a);
select * from t3;
prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 outr WHERE b = (SELECT MIN(b) FROM t1 WHERE a=outr.a);";
@@ -1391,19 +1400,21 @@ insert into t2 values (1,2);
select t000.a, count(*) `C` FROM t1 t000 GROUP BY t000.a HAVING count(*) > ALL (SELECT count(*) FROM t2 t001 WHERE t001.a=1);
drop table t1,t2;
+
#
-# BUG#4769 - fulltext in subselect
+# Bug#4769 - fulltext in subselect
#
-create table t1 (a int not null auto_increment primary key, b varchar(40), fulltext(b));
-insert into t1 (b) values ('ball'),('ball games'), ('games'), ('foo'), ('foobar'), ('Serg'), ('Sergei'),('Georg'), ('Patrik'),('Hakan');
-create table t2 (a int);
-insert into t2 values (1),(3),(2),(7);
-select a,b from t1 where match(b) against ('Ball') > 0;
-select a from t2 where a in (select a from t1 where match(b) against ('Ball') > 0);
+create table t1 (a int not null auto_increment primary key, b varchar(40), fulltext(b));
+insert into t1 (b) values ('ball'),('ball games'), ('games'), ('foo'), ('foobar'), ('Serg'), ('Sergei'),('Georg'), ('Patrik'),('Hakan');
+create table t2 (a int);
+insert into t2 values (1),(3),(2),(7);
+select a,b from t1 where match(b) against ('Ball') > 0;
+select a from t2 where a in (select a from t1 where match(b) against ('Ball') > 0);
drop table t1,t2;
+
#
-# BUG#5003 - like in subselect
+# Bug#5003 - like in subselect
#
CREATE TABLE t1(`IZAVORGANG_ID` VARCHAR(11) CHARACTER SET latin1 COLLATE latin1_bin,`KUERZEL` VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_bin,`IZAANALYSEART_ID` VARCHAR(11) CHARACTER SET latin1 COLLATE latin1_bin,`IZAPMKZ_ID` VARCHAR(11) CHARACTER SET latin1 COLLATE latin1_bin);
CREATE INDEX AK01IZAVORGANG ON t1(izaAnalyseart_id,Kuerzel);
@@ -1460,10 +1471,10 @@ SELECT b.sc FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.s
SELECT b.ac FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
drop tables t1,t2;
+
#
-# Test for bug #6462. "Same request on same data returns different
-# results." a.k.a. "Proper cleanup of subqueries is missing for
-# SET and DO statements".
+# Test for Bug#6462 Same request on same data returns different results
+# a.k.a. "Proper cleanup of subqueries is missing for SET and DO statements".
#
create table t1 (a int not null, b int not null, c int, primary key (a,b));
insert into t1 values (1,1,1), (2,2,2), (3,3,3);
@@ -1485,9 +1496,11 @@ drop table t1;
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connection root;
set @got_val= (SELECT 1 FROM (SELECT 'A' as my_col) as T1 ) ;
+connection default;
+disconnect root;
#
-# primary query with temporary table and subquery with groupping
+# primary query with temporary table and subquery with grouping
#
create table t1 (a int, b int);
create table t2 (a int, b int);
@@ -1548,14 +1561,15 @@ INSERT INTO t1 VALUES ('ASM','American Samoa','Oceania','Polynesia',199.00,0,680
INSERT INTO t1 VALUES ('ATF','French Southern territories','Antarctica','Antarctica',7780.00,0,0,NULL,0.00,NULL,'Terres australes françaises','Nonmetropolitan Territory of France','Jacques Chirac',NULL,'TF');
INSERT INTO t1 VALUES ('UMI','United States Minor Outlying Islands','Oceania','Micronesia/Caribbean',16.00,0,0,NULL,0.00,NULL,'United States Minor Outlying Islands','Dependent Territory of the US','George W. Bush',NULL,'UM');
/*!40000 ALTER TABLE t1 ENABLE KEYS */;
-SELECT DISTINCT Continent AS c FROM t1 outr WHERE
- Code <> SOME ( SELECT Code FROM t1 WHERE Continent = outr.Continent AND
+SELECT DISTINCT Continent AS c FROM t1 outr WHERE
+ Code <> SOME ( SELECT Code FROM t1 WHERE Continent = outr.Continent AND
Population < 200);
drop table t1;
+
#
-# Test for BUG#7885: Server crash when 'any' subselect compared to
-# non-existant field.
+# Test for Bug#7885 Server crash when 'any' subselect compared to
+# non-existant field.
#
create table t1 (a1 int);
create table t2 (b1 int);
@@ -1604,8 +1618,9 @@ select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx;
select 1 = ALL (select 1 from t1 where 1 = xx ), 1 as xx from DUAL;
drop table t1;
+
#
-# Test for BUG#8218
+# Test for Bug#8218 Join does not pass string from right table
#
CREATE TABLE t1 (
categoryId int(11) NOT NULL,
@@ -1675,38 +1690,39 @@ select
count(distinct t2.userid) pass,
groupstuff.*,
count(t2.courseid) crse,
- t1.categoryid,
+ t1.categoryid,
t2.courseid,
date_format(date, '%b%y') as colhead
-from t2
-join t1 on t2.courseid=t1.courseid
+from t2
+join t1 on t2.courseid=t1.courseid
join
(
- select
- t5.userid,
- parentid,
- parentgroup,
- childid,
- groupname,
- grouptypeid
- from t5
- join
+ select
+ t5.userid,
+ parentid,
+ parentgroup,
+ childid,
+ groupname,
+ grouptypeid
+ from t5
+ join
(
- select t4.id as parentid,
- t4.name as parentgroup,
- t4.id as childid,
- t4.name as groupname,
- t4.grouptypeid
- from t4
- ) as gin on t5.groupid=gin.childid
-) as groupstuff on t2.userid = groupstuff.userid
-group by
+ select t4.id as parentid,
+ t4.name as parentgroup,
+ t4.id as childid,
+ t4.name as groupname,
+ t4.grouptypeid
+ from t4
+ ) as gin on t5.groupid=gin.childid
+) as groupstuff on t2.userid = groupstuff.userid
+group by
groupstuff.groupname, colhead , t2.courseid;
drop table t1, t2, t3, t4, t5;
+
#
-# Transformation in left expression of subquery (BUG#8888)
+# Transformation in left expression of subquery (Bug#8888)
#
create table t1 (a int);
insert into t1 values (1), (2), (3);
@@ -1751,8 +1767,9 @@ select (1,2,3) = (select * from t1);
select (select * from t1) = (1,2,3);
drop table t1;
+
#
-# Item_int_with_ref check (BUG#10020)
+# Item_int_with_ref check (Bug#10020)
#
CREATE TABLE `t1` (
`itemid` bigint(20) unsigned NOT NULL auto_increment,
@@ -1775,15 +1792,16 @@ INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
drop tables t1,t2;
-# BUG#11821 : Select from subselect using aggregate function on an enum
-# segfaults:
+
+# Bug#11821 Select from subselect using aggregate function on an enum segfaults
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
drop table t1;
+
#
-# Bug #11867: queries with ROW(,elems>) IN (SELECT DISTINCT <cols> FROM ...)
+# Bug#11867 queries with ROW(,elems>) IN (SELECT DISTINCT <cols> FROM ...)
#
CREATE TABLE t1 (one int, two int, flag char(1));
@@ -1813,8 +1831,9 @@ explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FR
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
DROP TABLE t1,t2;
+
#
-# Bug #12392: where cond with IN predicate for rows and NULL values in table
+# Bug#12392 where cond with IN predicate for rows and NULL values in table
#
CREATE TABLE t1 (a char(5), b char(5));
@@ -1824,8 +1843,9 @@ SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb'));
DROP TABLE t1;
+
#
-# Bug #11479: subquery over left join with an empty inner table
+# Bug#11479 subquery over left join with an empty inner table
#
CREATE TABLE t1 (a int);
@@ -1842,9 +1862,10 @@ SELECT * FROM t1
DROP TABLE t1,t2,t3;
+
#
-# Bug#18503: Queries with a quantified subquery returning empty set may
-# return a wrong result.
+# Bug#18503 Queries with a quantified subquery returning empty set may
+# return a wrong result.
#
CREATE TABLE t1 (f1 INT);
CREATE TABLE t2 (f2 INT);
@@ -1856,8 +1877,9 @@ INSERT INTO t2 VALUES (2);
SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE f2=0);
DROP TABLE t1, t2;
+
#
-# Bug#16302: Quantified subquery without any tables gives wrong results
+# Bug#16302 Quantified subquery without any tables gives wrong results
#
select 1 from dual where 1 < any (select 2);
select 1 from dual where 1 < all (select 2);
@@ -1866,7 +1888,8 @@ select 1 from dual where 2 > all (select 1);
select 1 from dual where 1 < any (select 2 from dual);
select 1 from dual where 1 < all (select 2 from dual where 1!=1);
-# BUG#20975 Wrong query results for subqueries within NOT
+
+# Bug#20975 Wrong query results for subqueries within NOT
create table t1 (s1 char);
insert into t1 values (1),(2);
@@ -1883,8 +1906,9 @@ select * from t1 where (s1 = ALL (select s1/s1 from t1));
select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
drop table t1;
+
#
-# Bug #16255: Subquery in where
+# Bug#16255 Subquery in where
#
create table t1 (
retailerID varchar(8) NOT NULL,
@@ -1900,15 +1924,16 @@ INSERT INTO t1 VALUES("0037", "2", "2006-01-06 12:25:53");
INSERT INTO t1 VALUES("0048", "1", "2006-01-06 12:37:50");
INSERT INTO t1 VALUES("0059", "1", "2006-01-06 12:37:50");
-select * from t1 r1
- where (r1.retailerID,(r1.changed)) in
- (SELECT r2.retailerId,(max(changed)) from t1 r2
+select * from t1 r1
+ where (r1.retailerID,(r1.changed)) in
+ (SELECT r2.retailerId,(max(changed)) from t1 r2
group by r2.retailerId);
drop table t1;
+
#
-# Bug #21180: Subselect with index for both WHERE and ORDER BY
-# produces empty result
+# Bug#21180 Subselect with index for both WHERE and ORDER BY
+# produces empty result
#
create table t1(a int, primary key (a));
insert into t1 values (10);
@@ -1916,38 +1941,39 @@ insert into t1 values (10);
create table t2 (a int primary key, b varchar(32), c int, unique key b(c, b));
insert into t2(a, c, b) values (1,10,'359'), (2,10,'35988'), (3,10,'35989');
-explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
- ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
-SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
- ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
-explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
- ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
-SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
- ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
drop table t1,t2;
+
#
-# Bug #21853: assert failure for a grouping query with
-# an ALL/ANY quantified subquery in HAVING
+# Bug#21853 assert failure for a grouping query with
+# an ALL/ANY quantified subquery in HAVING
#
-CREATE TABLE t1 (
- field1 int NOT NULL,
- field2 int NOT NULL,
- field3 int NOT NULL,
- PRIMARY KEY (field1,field2,field3)
+CREATE TABLE t1 (
+ field1 int NOT NULL,
+ field2 int NOT NULL,
+ field3 int NOT NULL,
+ PRIMARY KEY (field1,field2,field3)
+);
+CREATE TABLE t2 (
+ fieldA int NOT NULL,
+ fieldB int NOT NULL,
+ PRIMARY KEY (fieldA,fieldB)
);
-CREATE TABLE t2 (
- fieldA int NOT NULL,
- fieldB int NOT NULL,
- PRIMARY KEY (fieldA,fieldB)
-);
INSERT INTO t1 VALUES
(1,1,1), (1,1,2), (1,2,1), (1,2,2), (1,2,3), (1,3,1);
@@ -1959,19 +1985,20 @@ SELECT field1, field2, COUNT(*)
SELECT field1, field2
FROM t1
GROUP BY field1, field2
- HAVING COUNT(*) >= ALL (SELECT fieldB
+ HAVING COUNT(*) >= ALL (SELECT fieldB
FROM t2 WHERE fieldA = field1);
SELECT field1, field2
FROM t1
GROUP BY field1, field2
- HAVING COUNT(*) < ANY (SELECT fieldB
+ HAVING COUNT(*) < ANY (SELECT fieldB
FROM t2 WHERE fieldA = field1);
DROP TABLE t1, t2;
+
#
-# Bug #23478: not top-level IN subquery returning a non-empty result set
-# with possible NULL values by index access from the outer query
+# Bug#23478 not top-level IN subquery returning a non-empty result set
+# with possible NULL values by index access from the outer query
#
CREATE TABLE t1(a int, INDEX (a));
@@ -1986,24 +2013,26 @@ SELECT a, a IN (SELECT a FROM t1) FROM t2;
DROP TABLE t1,t2;
+
#
-# Bug #11302: getObject() returns a String for a sub-query of type datetime
+# Bug#11302 getObject() returns a String for a sub-query of type datetime
#
CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('1998-09-23'), ('2003-03-25');
-CREATE TABLE t2 AS SELECT
- (SELECT a FROM t1 WHERE a < '2000-01-01') AS sub_a
+CREATE TABLE t2 AS SELECT
+ (SELECT a FROM t1 WHERE a < '2000-01-01') AS sub_a
FROM t1 WHERE a > '2000-01-01';
SHOW CREATE TABLE t2;
-CREATE TABLE t3 AS (SELECT a FROM t1 WHERE a < '2000-01-01') UNION (SELECT a FROM t1 WHERE a > '2000-01-01');
+CREATE TABLE t3 AS (SELECT a FROM t1 WHERE a < '2000-01-01') UNION (SELECT a FROM t1 WHERE a > '2000-01-01');
SHOW CREATE TABLE t3;
DROP TABLE t1,t2,t3;
+
#
-# Bug 24670: subquery witout tables but with a WHERE clause
+# Bug#24670 subquery witout tables but with a WHERE clause
#
CREATE TABLE t1 (a int);
@@ -2015,9 +2044,10 @@ EXPLAIN SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
DROP TABLE t1;
+
#
-# Bug 24653: sorting by expressions containing subselects
-# that return more than one row
+# Bug#24653 sorting by expressions containing subselects
+# that return more than one row
#
CREATE TABLE t1 (a int);
@@ -2100,8 +2130,9 @@ select * from t1;
select min(a) from t1 group by grp;
drop table t1;
+
#
-# Test for bug #9338: lame substitution of c1 instead of c2
+# Test for Bug#9338 lame substitution of c1 instead of c2
#
CREATE table t1 ( c1 integer );
@@ -2121,15 +2152,16 @@ SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
DROP TABLE t1,t2;
+
#
-# Test for bug #9516: wrong evaluation of not_null_tables attribute in SQ
+# Test for Bug#9516 wrong evaluation of not_null_tables attribute in SQ
#
CREATE TABLE t1 ( c1 integer );
INSERT INTO t1 VALUES ( 1 );
INSERT INTO t1 VALUES ( 2 );
INSERT INTO t1 VALUES ( 3 );
-INSERT INTO t1 VALUES ( 6 );
-
+INSERT INTO t1 VALUES ( 6 );
+
CREATE TABLE t2 ( c2 integer );
INSERT INTO t2 VALUES ( 1 );
INSERT INTO t2 VALUES ( 4 );
@@ -2140,13 +2172,14 @@ CREATE TABLE t3 ( c3 integer );
INSERT INTO t3 VALUES ( 7 );
INSERT INTO t3 VALUES ( 8 );
-SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2
+SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2
WHERE EXISTS (SELECT c3 FROM t3 WHERE c2 IS NULL );
DROP TABLE t1,t2,t3;
+
#
-# Item_int_with_ref check (BUG#10020)
+# Item_int_with_ref check (Bug#10020)
#
CREATE TABLE `t1` (
`itemid` bigint(20) unsigned NOT NULL auto_increment,
@@ -2169,9 +2202,10 @@ INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
drop tables t1,t2;
+
#
# Correct building of equal fields list (do not include outer
-# fields) (BUG#6384)
+# fields) (Bug#6384)
#
CREATE TABLE t1 (EMPNUM CHAR(3));
CREATE TABLE t2 (EMPNUM CHAR(3) );
@@ -2185,44 +2219,46 @@ WHERE t1.EMPNUM NOT IN
select * from t1;
DROP TABLE t1,t2;
+
#
-# Test for bug #11487: range access in a subquery
+# Test for Bug#11487 range access in a subquery
#
CREATE TABLE t1(select_id BIGINT, values_id BIGINT);
INSERT INTO t1 VALUES (1, 1);
-CREATE TABLE t2 (select_id BIGINT, values_id BIGINT,
+CREATE TABLE t2 (select_id BIGINT, values_id BIGINT,
PRIMARY KEY(select_id,values_id));
INSERT INTO t2 VALUES (0, 1), (0, 2), (0, 3), (1, 5);
-SELECT values_id FROM t1
+SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id IN (1, 0));
-SELECT values_id FROM t1
+SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id BETWEEN 0 AND 1);
-SELECT values_id FROM t1
+SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id = 0 OR select_id = 1);
DROP TABLE t1, t2;
-# BUG#11821 : Select from subselect using aggregate function on an enum
-# segfaults:
+
+# Bug#11821 Select from subselect using aggregate function on an enum segfaults
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
drop table t1;
+
#
-# Test for bug #11762: subquery with an aggregate function in HAVING
+# Test for Bug#11762 subquery with an aggregate function in HAVING
#
CREATE TABLE t1 (a int, b int);
CREATE TABLE t2 (c int, d int);
CREATE TABLE t3 (e int);
-INSERT INTO t1 VALUES
+INSERT INTO t1 VALUES
(1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40);
INSERT INTO t2 VALUES
(2,10), (2,20), (4,10), (5,10), (3,20), (2,40);
@@ -2252,7 +2288,7 @@ SELECT a FROM t1 GROUP BY a
WHERE EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e < d));
SELECT a FROM t1 GROUP BY a
HAVING a IN (SELECT c FROM t2
- WHERE MIN(b) < d AND
+ WHERE MIN(b) < d AND
EXISTS(SELECT e FROM t3 WHERE MAX(b)=e AND e <= d));
SELECT a, SUM(a) FROM t1 GROUP BY a;
@@ -2280,9 +2316,9 @@ SELECT t1.a FROM t1 GROUP BY t1.a
-- error ER_INVALID_GROUP_FUNC_USE
SELECT t1.a FROM t1 GROUP BY t1.a
HAVING t1.a > ALL(SELECT t2.c FROM t2
- WHERE EXISTS(SELECT t3.e FROM t3
+ WHERE EXISTS(SELECT t3.e FROM t3
WHERE SUM(t1.a+t2.c) < t3.e/4));
--- error ER_INVALID_GROUP_FUNC_USE
+-- error ER_INVALID_GROUP_FUNC_USE
SELECT t1.a from t1 GROUP BY t1.a HAVING AVG(SUM(t1.b)) > 20;
SELECT t1.a FROM t1 GROUP BY t1.a
@@ -2298,9 +2334,10 @@ SELECT t1.a, SUM(b) AS sum FROM t1 GROUP BY t1.a
DROP TABLE t1,t2,t3;
+
#
-# Test for bug #16603: GROUP BY in a row subquery with a quantifier
-# when an index is defined on the grouping field
+# Test for Bug#16603 GROUP BY in a row subquery with a quantifier
+# when an index is defined on the grouping field
CREATE TABLE t1 (a varchar(5), b varchar(10));
INSERT INTO t1 VALUES
@@ -2319,27 +2356,30 @@ SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
DROP TABLE t1;
+
#
-# Bug#17366: Unchecked Item_int results in server crash
+# Bug#17366 Unchecked Item_int results in server crash
#
create table t1( f1 int,f2 int);
insert into t1 values (1,1),(2,2);
select tt.t from (select 'crash1' as t, f2 from t1) as tt left join t1 on tt.t = 'crash2' and tt.f2 = t1.f2 where tt.t = 'crash1';
drop table t1;
+
#
-# Bug #18306: server crash on delete using subquery.
+# Bug#18306 server crash on delete using subquery.
#
-create table t1 (c int, key(c));
+create table t1 (c int, key(c));
insert into t1 values (1142477582), (1142455969);
create table t2 (a int, b int);
insert into t2 values (2, 1), (1, 0);
delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
drop table t1, t2;
+
#
-# Bug #7549: Missing error message for invalid view selection with subquery
+# Bug#7549 Missing error message for invalid view selection with subquery
#
CREATE TABLE t1 (a INT);
@@ -2353,16 +2393,18 @@ SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
DROP TABLE t1;
+
#
-# Bug#19077: A nested materialized derived table is used before being populated.
+# Bug#19077 A nested materialized derived table is used before being populated.
#
create table t1 (i int, j bigint);
insert into t1 values (1, 2), (2, 2), (3, 2);
select * from (select min(i) from t1 where j=(select * from (select min(j) from t1) t2)) t3;
drop table t1;
-#
-# Bug#19700: subselect returning BIGINT always returned it as SIGNED
+
+#
+# Bug#19700 subselect returning BIGINT always returned it as SIGNED
#
CREATE TABLE t1 (i BIGINT UNSIGNED);
INSERT INTO t1 VALUES (10000000000000000000); # > MAX SIGNED BIGINT 9323372036854775807
@@ -2384,8 +2426,9 @@ SELECT t1.i FROM t1 WHERE t1.i = CAST((SELECT MAX(i) FROM t2) AS UNSIGNED);
DROP TABLE t1;
DROP TABLE t2;
-#
-# Bug#20519: subselect with LIMIT M, N
+
+#
+# Bug#20519 subselect with LIMIT M, N
#
CREATE TABLE t1 (
@@ -2402,7 +2445,7 @@ CREATE TABLE t2 (
date date NOT NULL,
PRIMARY KEY (id)
);
-INSERT INTO t2 VALUES
+INSERT INTO t2 VALUES
(1, 1, '2006-03-30'), (2, 2, '2006-04-06'), (3, 3, '2006-04-13'),
(4, 2, '2006-04-20'), (5, 1, '2006-05-01');
@@ -2424,8 +2467,9 @@ SELECT *,
FROM t1;
DROP TABLE t1,t2;
+
#
-# Bug#20869: subselect with range access by DESC
+# Bug#20869 subselect with range access by DESC
#
CREATE TABLE t1 (
@@ -2434,7 +2478,7 @@ CREATE TABLE t1 (
t datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (i1,i2,t)
);
-INSERT INTO t1 VALUES
+INSERT INTO t1 VALUES
(24,1,'2005-03-03 16:31:31'),(24,1,'2005-05-27 12:40:07'),
(24,1,'2005-05-27 12:40:08'),(24,1,'2005-05-27 12:40:10'),
(24,1,'2005-05-27 12:40:25'),(24,1,'2005-05-27 12:40:30'),
@@ -2452,34 +2496,34 @@ INSERT INTO t2 VALUES (24,1,'2006-06-20 12:29:40');
EXPLAIN
SELECT * FROM t1,t2
- WHERE t1.t = (SELECT t1.t FROM t1
+ WHERE t1.t = (SELECT t1.t FROM t1
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
ORDER BY t1.t DESC LIMIT 1);
SELECT * FROM t1,t2
- WHERE t1.t = (SELECT t1.t FROM t1
+ WHERE t1.t = (SELECT t1.t FROM t1
WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
ORDER BY t1.t DESC LIMIT 1);
DROP TABLE t1, t2;
+
#
-# Bug#14654 : Cannot select from the same table twice within a UNION
-# statement
+# Bug#14654 Cannot select from the same table twice within a UNION statement
#
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 sql_no_cache * FROM t1 WHERE NOT EXISTS
(
- (SELECT i FROM t1) UNION
+ (SELECT i FROM t1) UNION
(SELECT i FROM t1)
);
#TODO:not supported
--error ER_PARSE_ERROR
-SELECT * FROM t1
+SELECT * FROM t1
WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
#TODO:not supported
@@ -2489,14 +2533,15 @@ explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
#TODO:not supported
--error ER_PARSE_ERROR
-explain select * from t1 where not exists
+explain select * from t1 where not exists
((select t11.i from t1 t11) union (select t12.i from t1 t12));
DROP TABLE t1;
+
#
-# Bug#21798: memory leak during query execution with subquery in column
-# list using a function
+# Bug#21798 memory leak during query execution with subquery in column
+# list using a function
#
CREATE TABLE t1 (a VARCHAR(250), b INT auto_increment, PRIMARY KEY (b));
insert into t1 (a) values (FLOOR(rand() * 100));
@@ -2514,15 +2559,16 @@ insert into t1 (a) select FLOOR(rand() * 100) from t1;
insert into t1 (a) select FLOOR(rand() * 100) from t1;
insert into t1 (a) select FLOOR(rand() * 100) from t1;
-SELECT a,
- (SELECT REPEAT(' ',250) FROM t1 i1
- WHERE i1.b=t1.a ORDER BY RAND() LIMIT 1) AS a
+SELECT a,
+ (SELECT REPEAT(' ',250) FROM t1 i1
+ WHERE i1.b=t1.a ORDER BY RAND() LIMIT 1) AS a
FROM t1 ORDER BY a LIMIT 5;
DROP TABLE t1;
+
#
-# Bug #21540: Subqueries with no from and aggregate functions return
-# wrong results
+# Bug#21540 Subqueries with no from and aggregate functions return
+# wrong results
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT);
INSERT INTO t2 values (1);
@@ -2531,29 +2577,30 @@ SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a;
SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3)
FROM t1 GROUP BY t1.a;
SELECT COUNT(DISTINCT t1.b), (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a;
-SELECT COUNT(DISTINCT t1.b),
+SELECT COUNT(DISTINCT t1.b),
(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3)
FROM t1 GROUP BY t1.a;
SELECT (
SELECT (
SELECT COUNT(DISTINCT t1.b)
)
-)
+)
FROM t1 GROUP BY t1.a;
SELECT (
SELECT (
SELECT (
SELECT COUNT(DISTINCT t1.b)
)
- )
- FROM t1 GROUP BY t1.a LIMIT 1)
+ )
+ FROM t1 GROUP BY t1.a LIMIT 1)
FROM t1 t2
GROUP BY t2.a;
-DROP TABLE t1,t2;
+DROP TABLE t1,t2;
+
#
-# Bug #21727: Correlated subquery that requires filesort:
-# slow with big sort_buffer_size
+# Bug#21727 Correlated subquery that requires filesort:
+# slow with big sort_buffer_size
#
CREATE TABLE t1 (a int, b int auto_increment, PRIMARY KEY (b));
@@ -2571,26 +2618,27 @@ while ($1)
{
eval INSERT INTO t2(y,z) VALUES(@id,RAND()*1000);
dec $2;
- }
+ }
dec $1;
}
enable_query_log;
SET SESSION sort_buffer_size = 32 * 1024;
-SELECT SQL_NO_CACHE COUNT(*)
+SELECT SQL_NO_CACHE COUNT(*)
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
FROM t1) t;
SET SESSION sort_buffer_size = 8 * 1024 * 1024;
-SELECT SQL_NO_CACHE COUNT(*)
+SELECT SQL_NO_CACHE COUNT(*)
FROM (SELECT a, b, (SELECT x FROM t2 WHERE y=b ORDER BY z DESC LIMIT 1) c
FROM t1) t;
DROP TABLE t1,t2;
+
#
-# Bug #25219: EXIST subquery with UNION over a mix of
-# correlated and uncorrelated selects
+# Bug#25219 EXIST subquery with UNION over a mix of
+# correlated and uncorrelated selects
#
CREATE TABLE t1 (id char(4) PRIMARY KEY, c int);
@@ -2622,10 +2670,11 @@ SELECT * FROM t1
DROP TABLE t1,t2,t3;
-#
-# Bug#23800: Outer fields in correlated subqueries is used in a temporary
-# table created for sorting.
-#
+
+#
+# Bug#23800 Outer fields in correlated subqueries is used in a temporary
+# table created for sorting.
+#
CREATE TABLE t1(f1 int);
CREATE TABLE t2(f2 int, f21 int, f3 timestamp);
INSERT INTO t1 VALUES (1),(1),(2),(2);
@@ -2636,19 +2685,20 @@ PREPARE stmt1 FROM 'SELECT ((SELECT f2 FROM t2 WHERE f21=f1 LIMIT 1) * COUNT(f1)
EXECUTE stmt1;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
-SELECT f2, AVG(f21),
+SELECT f2, AVG(f21),
(SELECT t.f3 FROM t2 AS t WHERE t2.f2=t.f2 AND t.f3=MAX(t2.f3)) AS test
FROM t2 GROUP BY f2;
-DROP TABLE t1,t2;
-CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL);
-INSERT INTO t1 VALUES
- (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),
- (2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'), (3,3,'j'),
- (3,2,'k'), (3,1,'l'), (1,9,'m');
-SELECT a, MAX(b),
- (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) AS test
- FROM t1 GROUP BY a;
-DROP TABLE t1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL);
+INSERT INTO t1 VALUES
+ (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),
+ (2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'), (3,3,'j'),
+ (3,2,'k'), (3,1,'l'), (1,9,'m');
+SELECT a, MAX(b),
+ (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) AS test
+ FROM t1 GROUP BY a;
+DROP TABLE t1;
+
#
# Bug#21904 (parser problem when using IN with a double "(())")
@@ -2749,21 +2799,23 @@ DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t1xt2;
+
+#
+# Bug#26728 derived table with concatanation of literals in select list
#
-# Bug #26728: derived table with concatanation of literals in select list
-#
CREATE TABLE t1 (a int);
-INSERT INTO t1 VALUES (3), (1), (2);
+INSERT INTO t1 VALUES (3), (1), (2);
SELECT 'this is ' 'a test.' AS col1, a AS col2 FROM t1;
SELECT * FROM (SELECT 'this is ' 'a test.' AS col1, a AS t2 FROM t1) t;
DROP table t1;
+
+#
+# Bug#27257 COUNT(*) aggregated in outer query
#
-# Bug #27257: COUNT(*) aggregated in outer query
-#
CREATE TABLE t1 (a int, b int);
CREATE TABLE t2 (m int, n int);
@@ -2778,15 +2830,16 @@ SELECT COUNT(*), a,
(SELECT MIN(m) FROM t2 WHERE m = count(*))
FROM t1 GROUP BY a;
-SELECT COUNT(*), a
+SELECT COUNT(*), a
FROM t1 GROUP BY a
HAVING (SELECT MIN(m) FROM t2 WHERE m = count(*)) > 1;
DROP TABLE t1,t2;
+
+#
+# Bug#27229 GROUP_CONCAT in subselect with COUNT() as an argument
#
-# Bug #27229: GROUP_CONCAT in subselect with COUNT() as an argument
-#
CREATE TABLE t1 (a int, b int);
CREATE TABLE t2 (m int, n int);
@@ -2803,8 +2856,9 @@ SELECT COUNT(*) c, a,
DROP table t1,t2;
+
#
-# Bug#27321: Wrong subquery result in a grouping select
+# Bug#27321 Wrong subquery result in a grouping select
#
CREATE TABLE t1 (a int, b INT, d INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'),
@@ -2812,7 +2866,7 @@ INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'),
(3,2,0,'k'), (3,1,0,'l'), (1,9,0,'m'), (1,0,10,'n'), (2,0,5,'o'), (3,0,7,'p');
SELECT a, MAX(b),
- (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test
+ (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b + 0)) as test
FROM t1 GROUP BY a;
SELECT a x, MAX(b),
(SELECT t.c FROM t1 AS t WHERE x=t.a AND t.b=MAX(t1.b + 0)) as test
@@ -2823,25 +2877,27 @@ SELECT a, AVG(b),
SELECT tt.a,
(SELECT (SELECT c FROM t1 as t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
- LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+ LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
FROM t1 as tt;
SELECT tt.a,
(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
LIMIT 1)
- FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
+ FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
FROM t1 as tt GROUP BY tt.a;
SELECT tt.a, MAX(
(SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
LIMIT 1)
- FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test
+ FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test
FROM t1 as tt GROUP BY tt.a;
DROP TABLE t1;
+
+
+#
+# Bug#27348 SET FUNCTION used in a subquery from WHERE condition
#
-# Bug #27348: SET FUNCTION used in a subquery from WHERE condition
-#
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
@@ -2866,9 +2922,9 @@ SET @@sql_mode=default;
DROP TABLE t1;
+
#
-# Bug #27363: nested aggregates in outer, subquery / sum(select
-# count(outer))
+# Bug#27363 nested aggregates in outer, subquery / sum(select count(outer))
#
CREATE TABLE t1 (a INT); INSERT INTO t1 values (1),(1),(1),(1);
CREATE TABLE t2 (x INT); INSERT INTO t1 values (1000),(1001),(1002);
@@ -2883,28 +2939,30 @@ SELECT COUNT(1) FROM DUAL;
SELECT SUM( (SELECT AVG( (SELECT t1.a FROM t2) ) FROM DUAL) ) FROM t1;
--error ER_INVALID_GROUP_FUNC_USE
-SELECT
+SELECT
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING t1.a < 12) ) FROM t2) )
FROM t1;
--error ER_INVALID_GROUP_FUNC_USE
-SELECT t1.a as XXA,
+SELECT t1.a as XXA,
SUM( (SELECT AVG( (SELECT COUNT(*) FROM t1 t HAVING XXA < 12) ) FROM t2) )
FROM t1;
DROP TABLE t1,t2;
+
#
-# Bug #27807: Server crash when executing subquery with EXPLAIN
-#
-CREATE TABLE t1 (a int, b int, KEY (a));
+# Bug#27807 Server crash when executing subquery with EXPLAIN
+#
+CREATE TABLE t1 (a int, b int, KEY (a));
INSERT INTO t1 VALUES (1,1),(2,1);
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
DROP TABLE t1;
+
+#
+# Bug#28377 grouping query with a correlated subquery in WHERE condition
#
-# Bug #28377: grouping query with a correlated subquery in WHERE condition
-#
CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id));
INSERT INTO t1 VALUES
@@ -2912,24 +2970,25 @@ INSERT INTO t1 VALUES
CREATE TABLE t2 (id int NOT NULL, INDEX idx(id));
INSERT INTO t2 VALUES (7), (5), (1), (3);
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
GROUP BY id;
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
-SELECT id, st FROM t1
+SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
GROUP BY id;
DROP TABLE t1,t2;
+
+#
+# Bug#28728 crash with EXPLAIN EXTENDED for a query with a derived table
+# over a grouping subselect
#
-# Bug #28728: crash with EXPLAIN EXTENDED for a query with a derived table
-# over a grouping subselect
-#
CREATE TABLE t1 (a int);
@@ -2940,10 +2999,11 @@ SELECT * FROM (SELECT count(*) FROM t1 GROUP BY a) as res;
DROP TABLE t1;
+
#
-# Bug #28811: crash for query containing subquery with ORDER BY and LIMIT 1
+# Bug#28811 crash for query containing subquery with ORDER BY and LIMIT 1
#
-
+
CREATE TABLE t1 (
a varchar(255) default NULL,
b timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
@@ -2974,8 +3034,8 @@ DROP TABLE t1,t2;
#
-# Bug #27333: subquery grouped for aggregate of outer query / no aggregate
-# of subquery
+# Bug#27333 subquery grouped for aggregate of outer query / no aggregate
+# of subquery
#
CREATE TABLE t1 (a INTEGER, b INTEGER);
CREATE TABLE t2 (x INTEGER);
@@ -3015,7 +3075,7 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1;
DROP TABLE t1,t2;
#
-# Bug #31884: Assertion + crash in subquery in the SELECT clause.
+# Bug#31884 Assertion + crash in subquery in the SELECT clause.
#
CREATE TABLE t1 (a1 INT, a2 INT);
@@ -3030,7 +3090,7 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1;
DROP TABLE t1, t2;
#
-# Bug #28076: inconsistent binary/varbinary comparison
+# Bug#28076 inconsistent binary/varbinary comparison
#
CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5));
@@ -3071,8 +3131,9 @@ SELECT LEFT(t1.a1,1) FROM t1,t3 WHERE t1.b1=t3.a3;
SELECT a2 FROM t2 WHERE t2.a2 IN (SELECT t1.a1 FROM t1,t3 WHERE t1.b1=t3.a3);
DROP TABLE t1, t2, t3;
+
#
-# Bug #30788: Inconsistent retrieval of char/varchar
+# Bug#30788 Inconsistent retrieval of char/varchar
#
CREATE TABLE t1 (a CHAR(1), b VARCHAR(10));
@@ -3096,16 +3157,16 @@ SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
DROP TABLE t1,t2;
+
#
-# Bug #32400: Complex SELECT query returns correct result only on some
-# occasions
+# Bug#32400 Complex SELECT query returns correct result only on some occasions
#
CREATE TABLE t1(a INT, b INT);
INSERT INTO t1 VALUES (1,1), (1,2), (2,3), (2,4);
--error ER_BAD_FIELD_ERROR
-EXPLAIN
+EXPLAIN
SELECT a AS out_a, MIN(b) FROM t1
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
GROUP BY a;
@@ -3115,7 +3176,7 @@ SELECT a AS out_a, MIN(b) FROM t1
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = out_a)
GROUP BY a;
-EXPLAIN
+EXPLAIN
SELECT a AS out_a, MIN(b) FROM t1 t1_outer
WHERE b > (SELECT MIN(b) FROM t1 WHERE a = t1_outer.a)
GROUP BY a;
@@ -3128,7 +3189,7 @@ DROP TABLE t1;
#
-# Bug #32036: EXISTS within a WHERE clause with a UNION crashes MySQL 5.122
+# Bug#32036 EXISTS within a WHERE clause with a UNION crashes MySQL 5.122
#
CREATE TABLE t1 (a INT);
@@ -3145,14 +3206,15 @@ 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 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
DROP TABLE t1,t2;
+
#
-# Bug#33675: Usage of an uninitialized memory by filesort in a subquery
-# caused server crash.
+# Bug#33675 Usage of an uninitialized memory by filesort in a subquery
+# caused server crash.
#
create table t1(f11 int, f12 int);
create table t2(f21 int unsigned not null, f22 int, f23 varchar(10));
@@ -3168,13 +3230,14 @@ while ($i)
--enable_warnings
--enable_query_log
set session sort_buffer_size= 33*1024;
-select count(*) from t1 where f12 =
+select count(*) from t1 where f12 =
(select f22 from t2 where f22 = f12 order by f21 desc, f22, f23 limit 1);
drop table t1,t2;
+
#
-# BUG#33794 "MySQL crashes executing specific query on specific dump"
+# Bug#33794 "MySQL crashes executing specific query on specific dump"
#
CREATE TABLE t4 (
f7 varchar(32) collate utf8_bin NOT NULL default '',
@@ -3216,24 +3279,25 @@ SELECT
FROM t2 VPC, t4 a2, t2 a3
WHERE
VPC.f4 = a2.f10 AND a3.f2 = a4
- LIMIT 1) IS NULL,
- 0,
+ LIMIT 1) IS NULL,
+ 0,
t3.f5
)
) AS a6
-FROM
+FROM
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
GROUP BY a4;
DROP TABLE t1, t2, t3, t4;
+
#
-# BUG#36139 "float, zerofill, crash with subquery"
+# Bug#36139 "float, zerofill, crash with subquery"
#
create table t1 (a float(5,4) zerofill);
create table t2 (a float(5,4),b float(2,0));
-select t1.a from t1 where
+select t1.a from t1 where
t1.a= (select b from t2 limit 1) and not
t1.a= (select a from t2 limit 1) ;
@@ -3241,8 +3305,8 @@ drop table t1, t2;
#
-# Bug #36011: Server crash with explain extended on query with dependent
-# subqueries
+# Bug#36011 Server crash with explain extended on query with dependent
+# subqueries
#
CREATE TABLE t1 (a INT);
@@ -3254,10 +3318,10 @@ DROP TABLE t1;
--echo End of 5.0 tests.
#
-# Bug #27348: SET FUNCTION used in a subquery from WHERE condition
-#
+# Bug#27348 SET FUNCTION used in a subquery from WHERE condition
+#
-CREATE TABLE t1 (a int, b int);
+CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
@@ -3282,17 +3346,17 @@ DROP TABLE t1;
#
# Bug#20835 (literal string with =any values)
#
-CREATE TABLE t1 (s1 char(1));
+CREATE TABLE t1 (s1 CHAR(1));
INSERT INTO t1 VALUES ('a');
SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1);
DROP TABLE t1;
#
-# Bug #37004: NOT IN subquery with MAX over an empty set
+# Bug#37004 NOT IN subquery with MAX over an empty set
#
-CREATE TABLE t1(c int, KEY(c));
-CREATE TABLE t2(a int, b int);
+CREATE TABLE t1(c INT, KEY(c));
+CREATE TABLE t2(a INT, b INT);
INSERT INTO t2 VALUES (1, 10), (2, NULL);
INSERT INTO t1 VALUES (1), (3);
@@ -3301,30 +3365,30 @@ SELECT * FROM t2 WHERE b NOT IN (SELECT max(t.c) FROM t1, t1 t WHERE t.c>10);
DROP TABLE t1,t2;
#
-# Bug #38191: Server crash with subquery containing DISTINCT and ORDER BY
+# Bug#38191 Server crash with subquery containing DISTINCT and ORDER BY
#
-CREATE TABLE t1(pk int PRIMARY KEY, a int, INDEX idx(a));
+CREATE TABLE t1(pk INT PRIMARY KEY, a INT, INDEX idx(a));
INSERT INTO t1 VALUES (1, 10), (3, 30), (2, 20);
-CREATE TABLE t2(pk int PRIMARY KEY, a int, b int, INDEX idxa(a));
+CREATE TABLE t2(pk INT PRIMARY KEY, a INT, b INT, INDEX idxa(a));
INSERT INTO t2 VALUES (2, 20, 700), (1, 10, 200), (4, 10, 100);
SELECT * FROM t1
WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b);
DROP TABLE t1,t2;
#
-# Bug #37548: result value erronously reported being NULL in certain subqueries
+# Bug#37548 result value erronously reported being NULL in certain subqueries
#
-CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY b (b));
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), KEY b (b));
INSERT INTO t1 VALUES (1,NULL), (9,NULL);
CREATE TABLE t2 (
- a int,
- b int,
- c int,
- d int,
+ a INT,
+ b INT,
+ c INT,
+ d INT,
PRIMARY KEY (a),
UNIQUE KEY b (b,c,d),
KEY b_2 (b),
@@ -3332,7 +3396,7 @@ CREATE TABLE t2 (
KEY d (d)
);
-INSERT INTO t2 VALUES
+INSERT INTO t2 VALUES
(43, 2, 11 ,30),
(44, 2, 12 ,30),
(45, 1, 1 ,10000),
@@ -3340,9 +3404,9 @@ INSERT INTO t2 VALUES
(556,1, 32 ,10000);
CREATE TABLE t3 (
- a int,
- b int,
- c int,
+ a INT,
+ b INT,
+ c INT,
PRIMARY KEY (a),
UNIQUE KEY b (b,c),
KEY c (c),
@@ -3351,7 +3415,7 @@ CREATE TABLE t3 (
INSERT INTO t3 VALUES (1,1,1), (2,32,1);
-explain
+explain
SELECT t1.a, (SELECT 1 FROM t2 WHERE t2.b=t3.c AND t2.c=t1.a ORDER BY t2.d LIMIT 1) AS incorrect FROM t1, t3 WHERE t3.b=t1.a;
SELECT t1.a, (SELECT 1 FROM t2 WHERE t2.b=t3.c AND t2.c=t1.a ORDER BY t2.d LIMIT 1) AS incorrect FROM t1, t3 WHERE t3.b=t1.a;
@@ -3370,22 +3434,22 @@ INSERT INTO t1 (id) VALUES (1);
INSERT INTO t2 (id) VALUES (1);
CREATE VIEW v1 AS
- SELECT t2.c AS c FROM t1, t2
- WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+SELECT t2.c AS c FROM t1, t2
+WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
UPDATE v1 SET c=1;
CREATE VIEW v2 (a,b) AS
- SELECT t2.id, t2.c AS c FROM t1, t2
- WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+SELECT t2.id, t2.c AS c FROM t1, t2
+WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
---error 1369
+--error ER_VIEW_CHECK_FAILED
INSERT INTO v2(a,b) VALUES (2,2);
INSERT INTO v2(a,b) VALUES (1,2);
SELECT * FROM v1;
CREATE VIEW v3 AS
- SELECT t2.c AS c FROM t2
- WHERE 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+SELECT t2.c AS c FROM t2
+WHERE 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
DELETE FROM v3;
@@ -3393,7 +3457,7 @@ DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
--echo #
---echo # BUG#37822: Correlated subquery with IN and IS UNKNOWN provides wrong result
+--echo # Bug#37822 Correlated subquery with IN and IS UNKNOWN provides wrong result
--echo #
create table t1(id integer primary key, g integer, v integer, s char(1));
create table t2(id integer primary key, g integer, v integer, s char(1));
diff --git a/mysql-test/t/synchronization.test b/mysql-test/t/synchronization.test
index 71e13a65ec3..aef06245717 100644
--- a/mysql-test/t/synchronization.test
+++ b/mysql-test/t/synchronization.test
@@ -1,10 +1,13 @@
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
#
-# Test for Bug #2385 CREATE TABLE LIKE lacks locking on source and destination
-# table
+# Test for Bug#2385 CREATE TABLE LIKE lacks locking on source and destination
+# table
#
--disable_warnings
-drop table if exists t1,t2;
+DROP TABLE IF EXISTS t1,t2;
--enable_warnings
connect (con1,localhost,root,,);
@@ -12,12 +15,12 @@ connect (con2,localhost,root,,);
# locking of source:
-CREATE TABLE t1 (x1 int);
+CREATE TABLE t1 (x1 INT);
let $1= 10;
while ($1)
{
connection con1;
- send ALTER TABLE t1 CHANGE x1 x2 int;
+ send ALTER TABLE t1 CHANGE x1 x2 INT;
connection con2;
CREATE TABLE t2 LIKE t1;
replace_result x1 xx x2 xx;
@@ -25,7 +28,7 @@ while ($1)
DROP TABLE t2;
connection con1;
reap;
- send ALTER TABLE t1 CHANGE x2 x1 int;
+ send ALTER TABLE t1 CHANGE x2 x1 INT;
connection con2;
CREATE TABLE t2 LIKE t1;
replace_result x1 xx x2 xx;
@@ -37,4 +40,11 @@ while ($1)
}
DROP TABLE t1;
+connection default;
+disconnect con1;
+disconnect con2;
+
# End of 4.1 tests
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/timezone_grant.test b/mysql-test/t/timezone_grant.test
index 450c1edc47e..8013f2b04ce 100644
--- a/mysql-test/t/timezone_grant.test
+++ b/mysql-test/t/timezone_grant.test
@@ -1,15 +1,18 @@
# Embedded server testing does not support grants
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
--disable_warnings
drop tables if exists t1, t2;
drop view if exists v1;
--enable_warnings
#
-# Test for bug #6116 "SET time_zone := ... requires access to mysql.time_zone
-# tables". We should allow implicit access to time zone description tables
-# even for unprivileged users.
+# Test for Bug#6116 SET time_zone := ... requires access to mysql.time_zone tables
+# We should allow implicit access to time zone description tables even for
+# unprivileged users.
#
# Let us prepare playground
@@ -33,18 +36,20 @@ select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC')
where t1.a = t2.c and t2.d = (select max(d) from t2);
# But still these two statements should not work:
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select * from mysql.time_zone_name;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
+connection default;
+disconnect tzuser;
+
#
-# Test for bug #6765 "Implicit access to time zone description tables
-# requires privileges for them if some table or column level grants
-# present"
+# Bug#6765 Implicit access to time zone description tables requires privileges
+# for them if some table or column level grants present
#
connection default;
-# Let use some table-level grants instead of db-level
+# Let use some table-level grants instead of db-level
# to make life more interesting
delete from mysql.db where user like 'mysqltest\_%';
flush privileges;
@@ -61,14 +66,14 @@ select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC')
where t1.a = t2.c and t2.d = (select max(d) from t2);
# Again these two statements should not work (but with different errors):
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select * from mysql.time_zone_name;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name;
#
-# Bug #9979: Use of CONVERT_TZ in multiple-table UPDATE causes bogus
-# privilege error
+# Bug#9979 Use of CONVERT_TZ in multiple-table UPDATE causes bogus
+# privilege error
#
drop table t1, t2;
create table t1 (a int, b datetime);
@@ -80,6 +85,7 @@ update t1 join t2 on (t1.a = t2.a) set t1.b = convert_tz('2005-01-01 10:00','UTC
# Clean-up
connection default;
+disconnect tzuser2;
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\_%';
@@ -89,10 +95,9 @@ drop table t1, t2;
# End of 4.1 tests
#
-# Additional test for bug #15153: CONVERT_TZ() is not allowed in all
-# places in views.
+# Additional test for Bug#15153 CONVERT_TZ() is not allowed in all places in views.
#
-# Let us check that usage of CONVERT_TZ() function in view does not
+# Let us check that usage of CONVERT_TZ() function in view does not
# require additional privileges.
# Let us rely on that previous tests done proper cleanups
@@ -109,7 +114,11 @@ drop view v1;
--error ER_TABLEACCESS_DENIED_ERROR
create view v1 as select a, convert_tz(b, 'UTC', 'Europe/Moscow') as lb from t1, mysql.time_zone;
connection default;
+disconnect tzuser3;
drop table t1;
drop user mysqltest_1@localhost;
# End of 5.0 tests
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/trigger-compat.test b/mysql-test/t/trigger-compat.test
index bf119cd89e6..2cc86692d0d 100644
--- a/mysql-test/t/trigger-compat.test
+++ b/mysql-test/t/trigger-compat.test
@@ -49,9 +49,7 @@ GRANT CREATE, TRIGGER ON mysqltest_db1.* TO mysqltest_dfn@localhost;
CREATE TABLE t1(num_value INT);
CREATE TABLE t2(user_str TEXT);
-CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1
- FOR EACH ROW
- INSERT INTO t2 VALUES(CURRENT_USER());
+CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES(CURRENT_USER());
#
# Remove definers from TRG file.
@@ -60,9 +58,24 @@ CREATE TRIGGER wl2818_trg1 BEFORE INSERT ON t1
--echo
--echo ---> patching t1.TRG...
-let $MYSQLD_DATADIR= `select @@datadir`;
---exec grep -v 'definers=' $MYSQLD_DATADIR/mysqltest_db1/t1.TRG > $MYSQLTEST_VARDIR/tmp/t1.TRG
---exec mv $MYSQLTEST_VARDIR/tmp/t1.TRG $MYSQLD_DATADIR/mysqltest_db1/t1.TRG
+# Here we remove definers. This is somewhat complex than the original test
+# Previously, the test only used grep -v 'definers=' t1.TRG, but grep is not
+# portable and we have to load the file into a table, exclude the definers line,
+# then load the data to an outfile to accomplish the same effect
+
+--disable_query_log
+--connection default
+CREATE TABLE patch (a blob);
+let $MYSQLD_DATADIR = `select @@datadir`;
+eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/mysqltest_db1/t1.TRG' INTO TABLE patch;
+# remove original t1.TRG file so SELECT INTO OUTFILE won't fail
+--remove_file $MYSQLD_DATADIR/mysqltest_db1/t1.TRG
+eval SELECT SUBSTRING_INDEX(a,'definers=',1) INTO OUTFILE
+ '$MYSQLD_DATADIR/mysqltest_db1/t1.TRG'
+FROM patch;
+DROP TABLE patch;
+--connection wl2818_definer_con
+--enable_query_log
#
# Create a new trigger.
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 6974a4cc5da..9a5556c518d 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -2218,6 +2218,39 @@ select * from t1;
select * from t2;
drop table t1;
drop temporary table t2;
+
+--echo #------------------------------------------------------------------------
+--echo # Bug#39953 Triggers are not working properly with multi table updates
+--echo #------------------------------------------------------------------------
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TRIGGER IF EXISTS t_insert;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (a int, date_insert timestamp, PRIMARY KEY (a));
+INSERT INTO t1 (a) VALUES (2),(5);
+CREATE TABLE t2 (a int, b int, PRIMARY KEY (a));
+DELIMITER |;
+CREATE TRIGGER t_insert AFTER INSERT ON t2 FOR EACH ROW BEGIN UPDATE t1,t2 SET
+date_insert=NOW() WHERE t1.a=t2.b AND t2.a=NEW.a; END |
+DELIMITER ;|
+INSERT INTO t2 (a,b) VALUES (1,2);
+
+DROP TRIGGER t_insert;
+
+DELIMITER |;
+CREATE TRIGGER t_insert AFTER INSERT ON t2 FOR EACH ROW BEGIN UPDATE t1,t2 SET
+date_insert=NOW(),b=b+1 WHERE t1.a=t2.b AND t2.a=NEW.a; END |
+DELIMITER ;|
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+INSERT INTO t2 (a,b) VALUES (3,5);
+
+DROP TABLE t1;
+DROP TRIGGER t_insert;
+DROP TABLE t2;
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test
index 85c9127b2f6..e7e66da8927 100644
--- a/mysql-test/t/type_bit_innodb.test
+++ b/mysql-test/t/type_bit_innodb.test
@@ -40,6 +40,8 @@ drop table t1;
create table t1 (a bit) engine=innodb;
insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001');
select hex(a) from t1;
+# It is not deterministic which duplicate will be seen first
+--replace_regex /(.*Duplicate entry )'.*'( for key.*)/\1''\2/
--error ER_DUP_ENTRY
alter table t1 add unique (a);
drop table t1;
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index eb1b7bde844..d4fa6bed186 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -427,3 +427,22 @@ create table t1 (da date default '1962-03-32 23:33:34', dt datetime default '196
--error 1067
create table t1 (t time default '916:00:00 a');
set @@sql_mode= @org_mode;
+
+#
+# Bug #42146 - DATETIME fractional seconds parse error
+#
+# show we trucate microseconds from the right -- special case: leftmost is 0
+SELECT CAST(CAST('2006-08-10 10:11:12.0123450' AS DATETIME) AS DECIMAL(30,7));
+
+# show that we ignore leading zeroes for all other fields
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.0123450' AS DATETIME) AS DECIMAL(30,7));
+# once more with feeling (but no warnings)
+SELECT CAST(CAST('00000002006-000008-0000010 000010:0000011:00000012.012345' AS DATETIME) AS DECIMAL(30,7));
+
+#
+# Bug #38435 - LONG Microseconds cause MySQL to fail a CAST to DATETIME or DATE
+#
+# show we truncate microseconds from the right
+SELECT CAST(CAST('2008-07-29T10:42:51.1234567' AS DateTime) AS DECIMAL(30,7));
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 53bcf44061d..3b7b30db6f8 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -267,4 +267,13 @@ select u from t1;
drop table t1;
+#
+# Bug #21205: Different number of digits for float/doble/real in --ps-protocol
+#
+
+CREATE TABLE t1 (f1 DOUBLE);
+INSERT INTO t1 VALUES(-1.79769313486231e+308);
+SELECT f1 FROM t1;
+DROP TABLE t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index ad4d57b7128..ece7099f66e 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -105,17 +105,25 @@ SELECT a INTO @v FROM (
SELECT a FROM t1
) alias;
-SELECT a INTO OUTFILE 'union.out.file' FROM (
+--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
-SELECT a INTO DUMPFILE 'union.out.file2' FROM (
+--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.
@@ -126,27 +134,42 @@ SELECT a FROM (
SELECT a INTO @v FROM t1
) alias;
-SELECT a FROM (
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval SELECT a FROM (
SELECT a FROM t1
UNION
- SELECT a INTO OUTFILE 'union.out.file3' FROM t1
+ SELECT a INTO OUTFILE '$outfile' FROM t1
) alias;
+--remove_file $outfile
-SELECT a FROM (
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval SELECT a FROM (
SELECT a FROM t1
UNION
- SELECT a INTO DUMPFILE 'union.out.file4' FROM t1
+ SELECT a INTO DUMPFILE '$outfile' FROM t1
) alias;
+--remove_file $outfile
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;
+
+--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
-SELECT a INTO OUTFILE 'union.out.file7' FROM t1 UNION SELECT a FROM t1;
+eval SELECT a INTO OUTFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
+
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
--error ER_WRONG_USAGE
-SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
+eval SELECT a INTO DUMPFILE '$outfile' FROM t1 UNION SELECT a FROM t1;
DROP TABLE t1;
@@ -1051,4 +1074,19 @@ SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
DESC t6;
DROP TABLE t1, t2, t3, t4, t5, t6;
+
+#
+# Bug #43432: Union on floats does unnecessary rounding
+#
+
+CREATE TABLE t1 (f FLOAT(9,6));
+CREATE TABLE t2 AS SELECT f FROM t1 UNION SELECT f FROM t1;
+SHOW FIELDS FROM t2;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1(d DOUBLE(9,6));
+CREATE TABLE t2 AS SELECT d FROM t1 UNION SELECT d FROM t1;
+SHOW FIELDS FROM t2;
+DROP TABLE t1, t2;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test
index a96d1f47cb2..d571a2efc7c 100644
--- a/mysql-test/t/upgrade.test
+++ b/mysql-test/t/upgrade.test
@@ -48,12 +48,28 @@ select * from `txu#p#p1`;
drop table `txu@0023p@0023p1`;
drop table `txu#p#p1`;
+--echo #
+--echo # Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
+--echo #
+--echo # copy table created using mysql4.0 into the data dir
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/bug37631.frm $MYSQLD_DATADIR/test/t1.frm;
+copy_file std_data/bug37631.MYD $MYSQLD_DATADIR/test/t1.MYD;
+copy_file std_data/bug37631.MYI $MYSQLD_DATADIR/test/t1.MYI;
+--echo # check the table created using mysql 4.0
+CHECK TABLE t1;
+--echo # query the table created using mysql 4.0
+SELECT * FROM t1;
+DROP TABLE t1;
+
#
# Check if old tables work
#
let $MYSQLD_DATADIR= `select @@datadir`;
-system cp $MYSQL_TEST_DIR/std_data/old_table-323.frm $MYSQLD_DATADIR/test/t1.frm;
+--error 0,1
+--remove_file $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/old_table-323.frm $MYSQLD_DATADIR/test/t1.frm
truncate t1;
drop table t1;
@@ -87,3 +103,35 @@ show create table `a-b-c`.`t1`;
drop database `a-b-c`;
drop database `tabc`;
+#
+# Bug#43385 Cannot ALTER DATABASE ... UPGRADE DATA DIRECTORY NAME when Views exist
+#
+let $MYSQLD_DATADIR= `select @@datadir`;
+--mkdir $MYSQLD_DATADIR/a-b-c
+use `#mysql50#a-b-c`;
+create table t1(f1 char(10));
+
+--write_file $MYSQLD_DATADIR/a-b-c/v1.frm
+TYPE=VIEW
+query=select `a`.`f1` AS `f1` from `a-b-c`.`t1` `a` join `information_schema`.`tables` `b` where (convert(`a`.`f1` using utf8) = `b`.`TABLE_NAME`)
+md5=068271f1c657fe115e497856ca0fa493
+updatable=0
+algorithm=0
+definer_user=root
+definer_host=localhost
+suid=2
+with_check_option=0
+timestamp=2009-04-10 11:53:37
+create-version=1
+source=select f1 from `a-b-c`.t1 a, information_schema.tables b\nwhere a.f1 = b.table_name
+EOF
+
+show databases like '%a-b-c%';
+ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
+show databases like '%a-b-c%';
+show create view `a-b-c`.v1;
+--disable_ps_protocol
+select * from `a-b-c`.v1;
+--enable_ps_protocol
+drop database `a-b-c`;
+use test;
diff --git a/mysql-test/t/user_limits.test b/mysql-test/t/user_limits.test
index af0f6545ac4..41af032b97e 100644
--- a/mysql-test/t/user_limits.test
+++ b/mysql-test/t/user_limits.test
@@ -3,9 +3,12 @@
#
# Requires privileges to be enabled
--- source include/not_embedded.inc
+--source include/not_embedded.inc
-# Prepare play-ground
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+# Prepare play-ground
--disable_warnings
drop table if exists t1;
--enable_warnings
@@ -28,11 +31,11 @@ connect (mqph, localhost, mysqltest_1,,);
connection mqph;
select * from t1;
select * from t1;
---error 1226
+--error ER_USER_LIMIT_REACHED
select * from t1;
connect (mqph2, localhost, mysqltest_1,,);
connection mqph2;
---error 1226
+--error ER_USER_LIMIT_REACHED
select * from t1;
# cleanup
connection default;
@@ -50,12 +53,12 @@ select * from t1;
select * from t1;
delete from t1;
delete from t1;
---error 1226
+--error ER_USER_LIMIT_REACHED
delete from t1;
select * from t1;
connect (muph2, localhost, mysqltest_1,,);
connection muph2;
---error 1226
+--error ER_USER_LIMIT_REACHED
delete from t1;
select * from t1;
# Cleanup
@@ -74,7 +77,7 @@ connect (mcph2, localhost, mysqltest_1,,);
connection mcph2;
select * from t1;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
---error 1226
+--error ER_USER_LIMIT_REACHED
connect (mcph3, localhost, mysqltest_1,,);
# Old connection is still ok
select * from t1;
@@ -83,7 +86,7 @@ select * from t1;
disconnect mcph1;
disconnect mcph2;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
---error 1226
+--error ER_USER_LIMIT_REACHED
connect (mcph3, localhost, mysqltest_1,,);
# Cleanup
connection default;
@@ -101,13 +104,13 @@ connect (muc2, localhost, mysqltest_1,,);
connection muc2;
select * from t1;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
---error 1226
+--error ER_USER_LIMIT_REACHED
connect (muc3, localhost, mysqltest_1,,);
# Closing of one of connections should help
disconnect muc1;
connect (muc3, localhost, mysqltest_1,,);
select * from t1;
-# Changing of limit should also help (and immediately)
+# Changing of limit should also help (and immediately)
connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
@@ -115,7 +118,7 @@ connect (muc4, localhost, mysqltest_1,,);
connection muc4;
select * from t1;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
---error 1226
+--error ER_USER_LIMIT_REACHED
connect (muc5, localhost, mysqltest_1,,);
# Clean up
connection default;
@@ -129,10 +132,10 @@ 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 1229
-set session max_user_connections= 2;
+--error ER_GLOBAL_VARIABLE
+set session max_user_connections= 2;
# But it is ok to set global max_user_connections
-set global max_user_connections= 2;
+set global max_user_connections= 2;
select @@session.max_user_connections, @@global.max_user_connections;
# Let us check that global limit works
grant usage on *.* to mysqltest_1@localhost;
@@ -144,7 +147,7 @@ connect (muca2, localhost, mysqltest_1,,);
connection muca2;
select * from t1;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
---error 1203
+--error ER_TOO_MANY_USER_CONNECTIONS
connect (muca3, localhost, mysqltest_1,,);
# Now we are testing that per-account limit prevails over gloabl limit
connection default;
@@ -154,16 +157,20 @@ connect (muca3, localhost, mysqltest_1,,);
connection muca3;
select @@session.max_user_connections, @@global.max_user_connections;
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
---error 1226
+--error ER_USER_LIMIT_REACHED
connect (muca4, localhost, mysqltest_1,,);
# Cleanup
connection default;
disconnect muca1;
disconnect muca2;
disconnect muca3;
-set global max_user_connections= 0;
+set global max_user_connections= 0;
drop user mysqltest_1@localhost;
--enable_ps_protocol
# Final cleanup
drop table t1;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/variables-big.test b/mysql-test/t/variables-big.test
index 43326f3d016..fdb11ffa907 100644
--- a/mysql-test/t/variables-big.test
+++ b/mysql-test/t/variables-big.test
@@ -5,16 +5,51 @@
--source include/big_test.inc
#
-# Bug #27322 failure to allocate transaction_prealloc_size causes crash
+# Bug#27322 failure to allocate transaction_prealloc_size causes crash
#
+#
+# Manual (6.0):
+# Platform Bit Size Range Default
+# 32 1024-4294967295 (4 Gi - 1) 4096
+# 64 1024-18446744073709547520 4096
+#
+# Observation(mleich):
+# 1. - Linux 64 Bit, MySQL 64 Bit, 4 GiB RAM, 8 GiB swap
+# - SET SESSION transaction_prealloc_size=1099511627776;
+# SHOW PROCESSLIST;
+# Id User ... Info
+# <Id> root ... SHOW PROCESSLIST
+# SELECT @@session.transaction_prealloc_size;
+# @@session.transaction_prealloc_size
+# 1099511627776
+# very short runtime in 5.0
+# excessive resource consumption + long runtime in 5.1 and 6.0
+# 2. - Win in VM, slightly older version of this test, MySQL 5.0
+# - testcase timeout after 900s
+# analyze-timeout-mysqld.1.err :
+# Id User ... Time Info
+# 83 root ... 542 set session transaction_prealloc_size=1024*1024*1024*2
+# 84 root ... 1 SHOW PROCESSLIST
+#
+# There is a significant probablitity that this tests fails with testcase
+# timeout if the testing box is not powerful enough.
+#
+
+--disable_warnings
+SET SESSION transaction_prealloc_size=1024*1024*1024*1;
+--replace_column 1 <Id> 6 <Time>
+SHOW PROCESSLIST;
+SET SESSION transaction_prealloc_size=1024*1024*1024*2;
+--replace_column 1 <Id> 6 <Time>
+SHOW PROCESSLIST;
+SET SESSION transaction_prealloc_size=1024*1024*1024*3;
+--replace_column 1 <Id> 6 <Time>
+SHOW PROCESSLIST;
+SET SESSION transaction_prealloc_size=1024*1024*1024*4;
+--replace_column 1 <Id> 6 <Time>
+SHOW PROCESSLIST;
+SET SESSION transaction_prealloc_size=1024*1024*1024*5;
+--replace_column 1 <Id> 6 <Time>
+SHOW PROCESSLIST;
+--enable_warnings
-set session transaction_prealloc_size=1024*1024*1024*1;
-show processlist;
-set session transaction_prealloc_size=1024*1024*1024*2;
-show processlist;
-set session transaction_prealloc_size=1024*1024*1024*3;
-show processlist;
-set session transaction_prealloc_size=1024*1024*1024*4;
-show processlist;
-set session transaction_prealloc_size=1024*1024*1024*5;
-show processlist;
diff --git a/mysql-test/t/variables-notembedded-master.opt b/mysql-test/t/variables-notembedded-master.opt
index a684e591d10..8a173a043ac 100644
--- a/mysql-test/t/variables-notembedded-master.opt
+++ b/mysql-test/t/variables-notembedded-master.opt
@@ -1 +1 @@
---loose-slave-skip-errors=3,100,137,643,1752
+--loose-slave-skip-errors=3,100,137,0,643,1752
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index a54ac497c4c..6da20409639 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -36,6 +36,7 @@ set @my_slow_launch_time =@@global.slow_launch_time;
set @my_storage_engine =@@global.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;
# case insensitivity tests (new in 5.0)
set @`test`=1;
select @test, @`test`, @TEST, @`TEST`, @"teSt";
@@ -173,21 +174,63 @@ select @@timestamp>0;
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select ROUND(RAND(),5);
-show variables like '%alloc%';
-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
-set @@range_alloc_block_size=1024*16;
+
+--echo
+--echo ==+ Testing %alloc% system variables +==
+--echo ==+ NOTE: These values *must* be a multiple of 1024 +==
+--echo ==+ Other values will be rounded down to nearest multiple +==
+--echo
+--echo ==+ Show initial values +==
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
+
+--echo ==+ information_schema data +==
+SELECT * FROM information_schema.session_variables
+WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
+--echo Testing values that are multiples of 1024
+set @@range_alloc_block_size=1024*15+1024;
+set @@query_alloc_block_size=1024*15+1024*2;
+set @@query_prealloc_size=1024*18-1024;
+set @@transaction_alloc_block_size=1024*21-1024*1;
+set @@transaction_prealloc_size=1024*21-2048;
+--echo ==+ Check manipulated values ==+
+select @@query_alloc_block_size;
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
+--echo ==+ information_schema data +==
+SELECT * FROM information_schema.session_variables
+WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
+--echo ==+ Manipulate variable values +==
+--echo Testing values that are not 1024 multiples
+set @@range_alloc_block_size=1024*16+1023;
set @@query_alloc_block_size=1024*17+2;
-set @@query_prealloc_size=1024*18;
+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;
-show variables like '%alloc%';
-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
+--echo ==+ Check manipulated values ==+
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
+--echo ==+ information_schema data +==
+SELECT * FROM information_schema.session_variables
+WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size') ORDER BY 1;
+--echo ==+ Set values back to the default values +==
set @@range_alloc_block_size=default;
set @@query_alloc_block_size=default, @@query_prealloc_size=default;
set transaction_alloc_block_size=default, @@transaction_prealloc_size=default;
-show variables like '%alloc%';
-select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
+--echo ==+ Check the values now that they are reset +==
+SHOW VARIABLES WHERE variable_name IN ('range_alloc_block_size',
+'query_alloc_block_size', 'query_prealloc_size',
+'transaction_alloc_block_size', 'transaction_prealloc_size');
#
# Bug #10904 Illegal mix of collations between
@@ -605,12 +648,14 @@ set @@global.error_count=1;
# Bug #10351: Setting ulong variable to > MAX_ULONG fails on 32-bit platform
#
+--disable_warnings
set @@max_heap_table_size= 4294967296;
select @@max_heap_table_size > 0;
set global max_heap_table_size= 4294967296;
select @@max_heap_table_size > 0;
set @@max_heap_table_size= 4294967296;
select @@max_heap_table_size > 0;
+--enable_warnings
#
# Bug #11775 Variable character_set_system does not exist (sometimes)
@@ -736,6 +781,18 @@ show variables like 'hostname';
--echo End of 5.0 tests
+#
+# Bug#36446: Attempt to set @@join_buffer_size to its minimum value
+# produces spurious warning
+#
+
+# set to 1 so mysqld will correct to minimum (+ warn)
+set join_buffer_size=1;
+# save minimum
+set @save_join_buffer_size=@@join_buffer_size;
+# set minimum
+set join_buffer_size=@save_join_buffer_size;
+
# This is at the very after the versioned tests, since it involves doing
# cleanup
#
@@ -772,6 +829,8 @@ set global slow_launch_time =@my_slow_launch_time;
set global 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;
+
#
# Bug#28580 Repeatation of status variables
#
@@ -1079,3 +1138,67 @@ SET @@session.thread_stack= 7;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@global.thread_stack= 7;
#
+
+#
+# Bug #40657 - assertion with out of range variables and traditional sql_mode
+#
+
+SELECT @@global.expire_logs_days INTO @old_eld;
+
+SET GLOBAL expire_logs_days = -1;
+--echo needs to've been adjusted (0)
+SELECT @@global.expire_logs_days;
+
+SET GLOBAL expire_logs_days = 11;
+SET @old_mode=@@sql_mode;
+SET SESSION sql_mode = 'TRADITIONAL';
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL expire_logs_days = 100;
+--echo needs to be unchanged (11)
+SELECT @@global.expire_logs_days;
+SET SESSION sql_mode = @old_mode;
+
+SET GLOBAL expire_logs_days = 100;
+--echo needs to've been adjusted (99)
+SELECT @@global.expire_logs_days;
+
+SET GLOBAL expire_logs_days = 11;
+SET GLOBAL expire_logs_days = 99;
+--echo needs to pass with no warnings (99)
+SELECT @@global.expire_logs_days;
+
+# cleanup
+SET GLOBAL expire_logs_days = @old_eld;
+
+# show that warning uses underscore (sysvar-name), not hyphens (option-name)
+SET GLOBAL auto_increment_offset=-1;
+SET GLOBAL auto_increment_offset=0;
+
+
+
+#
+# Bug#41030 Wrong meta data (incorrect fieldlen)
+#
+
+--enable_metadata
+select @@storage_engine;
+--disable_metadata
+
+#
+# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id
+#
+
+SET @old_server_id = @@GLOBAL.server_id;
+SET GLOBAL server_id = (1 << 32) - 1;
+SELECT @@GLOBAL.server_id;
+SET GLOBAL server_id = (1 << 32);
+SELECT @@GLOBAL.server_id;
+SET GLOBAL server_id = (1 << 60);
+SELECT @@GLOBAL.server_id;
+SET GLOBAL server_id = 0;
+SELECT @@GLOBAL.server_id;
+SET GLOBAL server_id = -1;
+SELECT @@GLOBAL.server_id;
+SET GLOBAL server_id = @old_server_id;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 9e22006ea67..c9d01266e9e 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -10,12 +10,12 @@ use test;
#
# create view on nonexistent table
--- error 1146
+-- error ER_NO_SUCH_TABLE
create view v1 (c,d) as select a,b from t1;
create temporary table t1 (a int, b int);
# view on temporary table
--- error 1352
+-- error ER_VIEW_SELECT_TMPTABLE
create view v1 (c) as select b+1 from t1;
drop table t1;
@@ -42,18 +42,18 @@ select * from t1;
select c from v1;
show create table v1;
show create view v1;
--- error 1347
+-- error ER_WRONG_OBJECT
show create view t1;
drop table t1;
# try to use fields from underlying table
--- error 1054
+-- error ER_BAD_FIELD_ERROR
select a from v1;
--- error 1054
+-- error ER_BAD_FIELD_ERROR
select v1.a from v1;
--- error 1054
+-- error ER_BAD_FIELD_ERROR
select b from v1;
--- error 1054
+-- error ER_BAD_FIELD_ERROR
select v1.b from v1;
# view with different algorithms (explain output differs)
@@ -64,9 +64,9 @@ select c from v2;
explain extended select c from v2;
# try to use underlying table fields in VIEW creation process
--- error 1054
+-- error ER_BAD_FIELD_ERROR
create view v3 (c) as select a+1 from v1;
--- error 1054
+-- error ER_BAD_FIELD_ERROR
create view v3 (c) as select b+1 from v1;
@@ -104,7 +104,7 @@ select * from v1;
select * from v2;
# try to create VIEW with name of existing VIEW
--- error 1050
+-- error ER_TABLE_EXISTS_ERROR
create view v1 (c,d,e,f) as select a,b, a in (select a+2 from t1), a = all (select a from t1) from t1;
# 'or replace' should work in this case
@@ -112,7 +112,7 @@ create or replace view v1 (c,d,e,f) as select a,b, a in (select a+2 from t1), a
# try to ALTER unexisting VIEW
drop view v2;
--- error 1146
+-- error ER_NO_SUCH_TABLE
alter view v2 as select c, d from v1;
# 'or replace' on unexisting view
@@ -126,15 +126,15 @@ select * from v1;
select * from v2;
# try to drop nonexistent VIEW
--- error 1051
+-- error ER_BAD_TABLE_ERROR
drop view v100;
# try to drop table with DROP VIEW
--- error 1347
+-- error ER_WRONG_OBJECT
drop view t1;
# try to drop VIEW with DROP TABLE
--- error 1051
+-- error ER_BAD_TABLE_ERROR
drop table v1;
# try to drop table with DROP VIEW
@@ -175,7 +175,7 @@ drop table t1;
# syntax compatibility
#
create table t1 (a int);
--- error 1368
+-- error ER_VIEW_NONUPD_CHECK
create view v1 as select distinct a from t1 WITH CHECK OPTION;
create view v1 as select a from t1 WITH CHECK OPTION;
create view v2 as select a from t1 WITH CASCADED CHECK OPTION;
@@ -232,10 +232,10 @@ create algorithm=temptable view v2 (a,c) as select a, b+1 from t1;
select is_updatable from information_schema.views where table_name='v2';
select is_updatable from information_schema.views where table_name='v1';
# try to update expression
--- error 1348
+-- error ER_NONUPDATEABLE_COLUMN
update v1 set c=a+c;
# try to update VIEW with forced TEMPORARY TABLE algorithm
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
update v2 set a=a+c;
# updatable field of updateable view
update v1 set a=a+c;
@@ -254,10 +254,10 @@ insert into t2 values (10), (20);
create view v1 (a,c) as select a, b+1 from t1;
create algorithm=temptable view v2 (a,c) as select a, b+1 from t1;
# try to update expression
--- error 1348
+-- error ER_NONUPDATEABLE_COLUMN
update t2,v1 set v1.c=v1.a+v1.c where t2.x=v1.a;
# try to update VIEW with forced TEMPORARY TABLE algorithm
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
update t2,v2 set v2.a=v2.v2.a+c where t2.x=v2.a;
# updatable field of updateable view
update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.a;
@@ -292,7 +292,7 @@ insert into t1 values (1,2), (2,3), (3,4), (4,5), (5,10);
create view v1 (a,c) as select a, b+1 from t1;
create algorithm=temptable view v2 (a,c) as select a, b+1 from t1;
# try to update VIEW with forced TEMPORARY TABLE algorithm
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
delete from v2 where c < 4;
# updatable field of updateable view
delete from v1 where c < 4;
@@ -311,7 +311,7 @@ insert into t2 values (1), (2), (3), (4);
create view v1 (a,c) as select a, b+1 from t1;
create algorithm=temptable view v2 (a,c) as select a, b+1 from t1;
# try to update VIEW with forced TEMPORARY TABLE algorithm
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
delete v2 from t2,v2 where t2.x=v2.a;
# updatable field of updateable view
delete v1 from t2,v1 where t2.x=v1.a;
@@ -331,7 +331,7 @@ set updatable_views_with_limit=NO;
update v1 set x=x+1;
update v2 set x=x+1;
update v1 set x=x+1 limit 1;
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
update v2 set x=x+1 limit 1;
set updatable_views_with_limit=YES;
update v1 set x=x+1 limit 1;
@@ -424,7 +424,7 @@ create table t1 (a int, primary key(a));
insert into t1 values (1), (2), (3), (200);
create ALGORITHM=TEMPTABLE view v1 (x) as select a from t1;
create view v2 (y) as select x from v1;
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
update v2 set y=10 where y=2;
drop table t1;
drop view v1,v2;
@@ -479,17 +479,17 @@ create table t1 (col1 char(5),col2 char(5));
create view v1 as select * from t1;
drop table t1;
create table t1 (col1 char(5),newcol2 char(5));
--- error 1356
+-- error ER_VIEW_INVALID
insert into v1 values('a','aa');
drop table t1;
--- error 1356
+-- error ER_VIEW_INVALID
select * from v1;
drop view v1;
#
# check of duplication of column names
#
--- error 1060
+-- error ER_DUP_FIELDNAME
create view v1 (a,a) as select 'a','a';
#
@@ -559,7 +559,7 @@ drop table t1;
#
# error on preparation
#
--- error 1096
+-- error ER_NO_TABLES_USED
CREATE VIEW v02 AS SELECT * FROM DUAL;
SHOW TABLES;
@@ -575,7 +575,7 @@ drop view v1;
#
create table t1 (col1 int,col2 char(22));
create view v1 as select * from t1;
--- error 1347
+-- error ER_WRONG_OBJECT
create index i1 on v1 (col1);
drop view v1;
drop table t1;
@@ -735,7 +735,7 @@ create function x1 () returns int return 5;
create table t1 (s1 int);
create view v1 as select x1() from t1;
drop function x1;
--- error 1356
+-- error ER_VIEW_INVALID
select * from v1;
--replace_column 8 # 12 # 13 #
show table status;
@@ -794,10 +794,10 @@ create table t1 (a int);
create view v1 as select a from t1;
create view v3 as select a from t1;
create database mysqltest;
--- error 1450
+-- error ER_FORBID_SCHEMA_CHANGE
rename table v1 to mysqltest.v1;
rename table v1 to v2;
---error 1050
+--error ER_TABLE_EXISTS_ERROR
rename table v3 to v1, v2 to t1;
drop table t1;
drop view v2,v3;
@@ -810,19 +810,19 @@ create view v1 as select 'a',1;
create view v2 as select * from v1 union all select * from v1;
create view v3 as select * from v2 where 1 = (select `1` from v2);
create view v4 as select * from v3;
--- error 1242
+-- error ER_SUBQUERY_NO_1_ROW
select * from v4;
drop view v4, v3, v2, v1;
#
# VIEW over SELECT with prohibited clauses
#
--- error 1350
+-- error ER_VIEW_SELECT_CLAUSE
create view v1 as select 5 into @w;
--- error 1350
+-- error ER_VIEW_SELECT_CLAUSE
create view v1 as select 5 into outfile 'ttt';
create table t1 (a int);
--- error 1350
+-- error ER_VIEW_SELECT_CLAUSE
create view v1 as select a from t1 procedure analyse();
-- error ER_VIEW_SELECT_DERIVED
create view v1 as select 1 from (select 1) as d1;
@@ -848,109 +848,109 @@ create table t3 (col1 datetime not null);
create view v1 as select * from t1;
create view v2 as select * from v1;
create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v2 set col1 = (select max(col1) from v1);
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v2 set col1 = (select max(col1) from t1);
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update v2 set col1 = (select max(col1) from v2);
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v3 set v3.col1 = (select max(col1) from v1);
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v3 set v3.col1 = (select max(col1) from t1);
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update v3 set v3.col1 = (select max(col1) from v2);
--- error 1093
+-- error ER_UPDATE_TABLE_USED
update v3 set v3.col1 = (select max(col1) from v3);
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete from v2 where col1 = (select max(col1) from v1);
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete from v2 where col1 = (select max(col1) from t1);
--- error 1093
+-- error ER_UPDATE_TABLE_USED
delete from v2 where col1 = (select max(col1) from v2);
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1;
--- error 1093
+-- error ER_UPDATE_TABLE_USED
delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into v2 values ((select max(col1) from v1));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into t1 values ((select max(col1) from v1));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into v2 values ((select max(col1) from v1));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into v2 values ((select max(col1) from t1));
--- error 1093
+-- error ER_UPDATE_TABLE_USED
insert into t1 values ((select max(col1) from t1));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into v2 values ((select max(col1) from t1));
--- error 1093
+-- error ER_UPDATE_TABLE_USED
insert into v2 values ((select max(col1) from v2));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into t1 values ((select max(col1) from v2));
--- error 1093
+-- error ER_UPDATE_TABLE_USED
insert into v2 values ((select max(col1) from v2));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into v3 (col1) values ((select max(col1) from v1));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into v3 (col1) values ((select max(col1) from t1));
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
insert into v3 (col1) values ((select max(col1) from v2));
-#check with TZ tables in list
--- error 1443
+# check with TZ tables in list
+-- error ER_VIEW_PREVENT_UPDATE
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2));
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
--- error 1048
+-- error ER_BAD_NULL_ERROR
insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
# temporary table algorithm view should be equal to subquery in the from clause
create algorithm=temptable view v4 as select * from t1;
@@ -966,7 +966,7 @@ drop table t1,t2,t3;
#
create table t1 (s1 int);
create view v1 as select * from t1;
--- error 1347
+-- error ER_WRONG_OBJECT
handler v1 open as xx;
drop view v1;
drop table t1;
@@ -1014,7 +1014,7 @@ create table t2 (a int);
create view v1 as select * from t1;
lock tables t1 read, v1 read;
select * from v1;
--- error 1100
+-- error ER_TABLE_NOT_LOCKED
select * from t2;
drop view v1;
drop table t1, t2;
@@ -1026,7 +1026,7 @@ create table t1 (a int);
create view v1 as select * from t1 where a < 2 with check option;
# simple insert
insert into v1 values(1);
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v1 values(3);
# simple insert with ignore
insert ignore into v1 values (2),(3),(0);
@@ -1035,7 +1035,7 @@ select * from t1;
delete from t1;
# INSERT SELECT test
insert into v1 SELECT 1;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v1 SELECT 3;
# prepare data for next check
create table t2 (a int);
@@ -1043,9 +1043,9 @@ insert into t2 values (2),(3),(0);
# INSERT SELECT with ignore test
insert ignore into v1 SELECT a from t2;
select * from t1 order by a desc;
-#simple UPDATE test
+# simple UPDATE test
update v1 set a=-1 where a=0;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
update v1 set a=2 where a=1;
select * from t1 order by a desc;
# prepare data for next check
@@ -1072,12 +1072,12 @@ create view v2 as select * from v1 where a > 0 with local check option;
create view v3 as select * from v1 where a > 0 with cascaded check option;
insert into v2 values (1);
insert into v3 values (1);
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v2 values (0);
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v3 values (0);
insert into v2 values (2);
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v3 values (2);
select * from t1;
drop view v3,v2,v1;
@@ -1089,7 +1089,7 @@ drop table t1;
create table t1 (a int, primary key (a));
create view v1 as select * from t1 where a < 2 with check option;
insert into v1 values (1) on duplicate key update a=2;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v1 values (1) on duplicate key update a=2;
insert ignore into v1 values (1) on duplicate key update a=2;
select * from t1;
@@ -1102,13 +1102,13 @@ drop table t1;
create table t1 (s1 int);
create view v1 as select * from t1;
create view v2 as select * from v1;
--- error 1146
+-- error ER_NO_SUCH_TABLE
alter view v1 as select * from v2;
--- error 1146
+-- error ER_NO_SUCH_TABLE
alter view v1 as select * from v1;
--- error 1146
+-- error ER_NO_SUCH_TABLE
create or replace view v1 as select * from v2;
--- error 1146
+-- error ER_NO_SUCH_TABLE
create or replace view v1 as select * from v1;
drop view v2,v1;
drop table t1;
@@ -1143,7 +1143,7 @@ select * from t2;
# check it with check option
alter view v2 as select * from t2 where s1 in (select s1 from t1) with check option;
insert into v2 values (5);
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
update v2 set s1 = 1;
insert into t1 values (1);
update v2 set s1 = 1;
@@ -1175,7 +1175,7 @@ drop table t1;
create table t1 (s1 tinyint);
create view v1 as select * from t1 where s1 <> 0 with local check option;
create view v2 as select * from v1 with cascaded check option;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v2 values (0);
drop view v2, v1;
drop table t1;
@@ -1186,7 +1186,7 @@ drop table t1;
create table t1 (s1 int);
create view v1 as select * from t1 where s1 < 5 with check option;
#single value
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert ignore into v1 values (6);
#several values
insert ignore into v1 values (6),(3);
@@ -1200,7 +1200,7 @@ drop table t1;
create table t1 (s1 tinyint);
create trigger t1_bi before insert on t1 for each row set new.s1 = 500;
create view v1 as select * from t1 where s1 <> 127 with check option;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v1 values (0);
select * from v1;
select * from t1;
@@ -1214,7 +1214,7 @@ drop table t1;
create table t1 (s1 tinyint);
create view v1 as select * from t1 where s1 <> 0;
create view v2 as select * from v1 where s1 <> 1 with cascaded check option;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
insert into v2 values (0);
select * from v2;
select * from t1;
@@ -1227,7 +1227,7 @@ drop table t1;
# fixed length fields
create table t1 (a int, b char(10));
create view v1 as select * from t1 where a != 0 with check option;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
load data infile '../../std_data/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
select * from t1;
select * from v1;
@@ -1240,7 +1240,7 @@ drop table t1;
# variable length fields
create table t1 (a text, b text);
create view v1 as select * from t1 where a <> 'Field A' with check option;
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by '''';
select concat('|',a,'|'), concat('|',b,'|') from t1;
select concat('|',a,'|'), concat('|',b,'|') from v1;
@@ -1321,7 +1321,7 @@ select * from t2;
# view without primary key
create view v2 (a,b) as select t1.b as a, t2.a as b from t1, t2;
set updatable_views_with_limit=NO;
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
update v2 set a= 10 where a=200 limit 1;
set updatable_views_with_limit=DEFAULT;
# just view selects
@@ -1349,14 +1349,14 @@ create table t2 (a int, primary key (a), b int);
insert into t2 values (1000, 2000);
create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2;
# inserting into join view without field list
--- error 1394
+-- error ER_VIEW_NO_INSERT_FIELD_LIST
insert into v3 values (1,2);
--- error 1394
+-- error ER_VIEW_NO_INSERT_FIELD_LIST
insert into v3 select * from t2;
# inserting in several tables of join view
--- error 1393
+-- error ER_VIEW_MULTIUPDATE
insert into v3(a,b) values (1,2);
--- error 1393
+-- error ER_VIEW_MULTIUPDATE
insert into v3(a,b) select * from t2;
# correct inserts into join view
insert into v3(a) values (1);
@@ -1367,11 +1367,11 @@ insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a);
select * from t1;
select * from t2;
# try delete from join view
--- error 1395
+-- error ER_VIEW_DELETE_MERGE_VIEW
delete from v3;
--- error 1395
+-- error ER_VIEW_DELETE_MERGE_VIEW
delete v3,t1 from v3,t1;
--- error 1395
+-- error ER_VIEW_DELETE_MERGE_VIEW
delete t1,v3 from t1,v3;
# delete from t1 just to reduce result set size
delete from t1;
@@ -1394,7 +1394,7 @@ drop view v3;
drop tables t1,t2;
#
-# View field names should be case insensitive
+# View field names should be case insensitive
#
create table t1(f1 int);
create view v1 as select f1 from t1;
@@ -1403,7 +1403,7 @@ drop view v1;
drop table t1;
#
-# Resolving view fields in subqueries in VIEW (Bug #6394)
+# Resolving view fields in subqueries in VIEW (Bug#6394)
#
create table t1(c1 int);
create table t2(c2 int);
@@ -1420,7 +1420,7 @@ drop view v2, v1;
drop table t1, t2;
#
-# view over other view setup (BUG#7433)
+# view over other view setup (Bug#7433)
#
CREATE TABLE t1 (C1 INT, C2 INT);
CREATE TABLE t2 (C2 INT);
@@ -1431,10 +1431,10 @@ drop view v2, v1;
drop table t1, t2;
#
-# view and group_concat() (BUG#7116)
+# view and group_concat() (Bug#7116)
#
-create table t1 (col1 char(5),col2 int,col3 int);
-insert into t1 values ('one',10,25), ('two',10,50), ('two',10,50), ('one',20,25), ('one',30,25);
+create table t1 (col1 char(5),col2 int,col3 int);
+insert into t1 values ('one',10,25), ('two',10,50), ('two',10,50), ('one',20,25), ('one',30,25);
create view v1 as select * from t1;
select col1,group_concat(col2,col3) from t1 group by col1;
select col1,group_concat(col2,col3) from v1 group by col1;
@@ -1442,18 +1442,18 @@ drop view v1;
drop table t1;
#
-# Item_ref resolved as view field (BUG#6894)
+# Item_ref resolved as view field (Bug#6894)
#
create table t1 (s1 int, s2 char);
create view v1 as select s1, s2 from t1;
--- error 1054
+-- error ER_BAD_FIELD_ERROR
select s2 from v1 vq1 where 2 = (select count(*) from v1 vq2 having vq1.s2 = vq2.s2);
select s2 from v1 vq1 where 2 = (select count(*) aa from v1 vq2 having vq1.s2 = aa);
drop view v1;
drop table t1;
#
-# Test case for bug #9398 CREATE TABLE with SELECT from a multi-table view
+# Test case for Bug#9398 CREATE TABLE with SELECT from a multi-table view
#
CREATE TABLE t1 (a1 int);
CREATE TABLE t2 (a2 int);
@@ -1469,7 +1469,7 @@ DROP VIEW v1;
DROP TABLE t1,t2,t3;
#
-# Test for BUG#8703 "insert into table select from view crashes"
+# Test for Bug#8703 insert into table select from view crashes
#
create table t1 (a int);
create table t2 like t1;
@@ -1481,84 +1481,84 @@ drop view v1;
drop table t1,t2,t3;
#
-# Test for BUG #6106: query over a view using subquery for the underlying table
-#
-
-CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10));
-INSERT INTO t1 VALUES(1,'trudy');
-INSERT INTO t1 VALUES(2,'peter');
-INSERT INTO t1 VALUES(3,'sanja');
-INSERT INTO t1 VALUES(4,'monty');
-INSERT INTO t1 VALUES(5,'david');
-INSERT INTO t1 VALUES(6,'kent');
-INSERT INTO t1 VALUES(7,'carsten');
-INSERT INTO t1 VALUES(8,'ranger');
-INSERT INTO t1 VALUES(10,'matt');
-CREATE TABLE t2 (col1 int, col2 int, col3 char(1));
-INSERT INTO t2 VALUES (1,1,'y');
-INSERT INTO t2 VALUES (1,2,'y');
-INSERT INTO t2 VALUES (2,1,'n');
-INSERT INTO t2 VALUES (3,1,'n');
-INSERT INTO t2 VALUES (4,1,'y');
-INSERT INTO t2 VALUES (4,2,'n');
-INSERT INTO t2 VALUES (4,3,'n');
-INSERT INTO t2 VALUES (6,1,'n');
+# Test for Bug#6106 query over a view using subquery for the underlying table
+#
+
+CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10));
+INSERT INTO t1 VALUES(1,'trudy');
+INSERT INTO t1 VALUES(2,'peter');
+INSERT INTO t1 VALUES(3,'sanja');
+INSERT INTO t1 VALUES(4,'monty');
+INSERT INTO t1 VALUES(5,'david');
+INSERT INTO t1 VALUES(6,'kent');
+INSERT INTO t1 VALUES(7,'carsten');
+INSERT INTO t1 VALUES(8,'ranger');
+INSERT INTO t1 VALUES(10,'matt');
+CREATE TABLE t2 (col1 int, col2 int, col3 char(1));
+INSERT INTO t2 VALUES (1,1,'y');
+INSERT INTO t2 VALUES (1,2,'y');
+INSERT INTO t2 VALUES (2,1,'n');
+INSERT INTO t2 VALUES (3,1,'n');
+INSERT INTO t2 VALUES (4,1,'y');
+INSERT INTO t2 VALUES (4,2,'n');
+INSERT INTO t2 VALUES (4,3,'n');
+INSERT INTO t2 VALUES (6,1,'n');
INSERT INTO t2 VALUES (8,1,'y');
-
-CREATE VIEW v1 AS SELECT * FROM t1;
-SELECT a.col1,a.col2,b.col2,b.col3
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+SELECT a.col1,a.col2,b.col2,b.col3
FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1
- WHERE b.col2 IS NULL OR
+ WHERE b.col2 IS NULL OR
b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
-SELECT a.col1,a.col2,b.col2,b.col3
+SELECT a.col1,a.col2,b.col2,b.col3
FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1
- WHERE b.col2 IS NULL OR
+ WHERE b.col2 IS NULL OR
b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
-CREATE VIEW v2 AS SELECT * FROM t2;
+CREATE VIEW v2 AS SELECT * FROM t2;
SELECT a.col1,a.col2,b.col2,b.col3
FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1
WHERE b.col2 IS NULL OR
- b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
+ b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
-# Tests from the report for bug #6107
+# Tests from the report for Bug#6107
SELECT a.col1,a.col2,b.col2,b.col3
FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1
WHERE a.col1 IN (1,5,9) AND
(b.col2 IS NULL OR
- b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1));
+ b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1));
CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9);
SELECT a.col1,a.col2,b.col2,b.col3
FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1
WHERE b.col2 IS NULL OR
- b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
-
+ b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
+
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
#
-# BUG#8490 Select from views containing subqueries causes server to hang
-# forever.
+# Bug#8490 Select from views containing subqueries causes server to hang
+# forever.
#
create table t1 as select 1 A union select 2 union select 3;
create table t2 as select * from t1;
create view v1 as select * from t1 where a in (select * from t2);
select * from v1 A, v1 B where A.a = B.a;
create table t3 as select a a,a b from t2;
-create view v2 as select * from t3 where
+create view v2 as select * from t3 where
a in (select * from t1) or b in (select * from t2);
select * from v2 A, v2 B where A.a = B.b;
drop view v1, v2;
drop table t1, t2, t3;
#
-# Test case for bug #8528: select from view over multi-table view
+# Test case for Bug#8528 select from view over multi-table view
#
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int);
@@ -1574,7 +1574,7 @@ DROP VIEW v2,v1;
DROP TABLE t1, t2;
#
-# Correct restoring view name in SP table locking BUG#9758
+# Correct restoring view name in SP table locking Bug#9758
#
create table t1 (a int);
create view v1 as select sum(a) from t1 group by a;
@@ -1603,7 +1603,7 @@ SELECT d, c FROM v1 ORDER BY d,c;
DROP VIEW v1;
DROP TABLE t1, t2;
#
-# using sum(distinct ) & avg(distinct ) in views (BUG#7015)
+# using sum(distinct ) & avg(distinct ) in views (Bug#7015)
#
create table t1 (s1 int);
create view v1 as select sum(distinct s1) from t1;
@@ -1615,14 +1615,14 @@ drop view v1;
drop table t1;
#
-# using cast(... as decimal) in views (BUG#11387);
+# using cast(... as decimal) in views (Bug#11387);
#
create view v1 as select cast(1 as decimal);
select * from v1;
drop view v1;
#
-# Bug#11298 insert into select from VIEW produces incorrect result when
+# Bug#11298 insert into select from VIEW produces incorrect result when
# using ORDER BY
create table t1(f1 int);
create table t2(f2 int);
@@ -1636,7 +1636,7 @@ drop view v1;
drop table t1,t2,t3;
#
-# Generation unique names for columns, and correct names check (BUG#7448)
+# Generation unique names for columns, and correct names check (Bug#7448)
#
# names with ' and \
create view v1 as select '\\','\\shazam';
@@ -1679,24 +1679,24 @@ create view v1 as select 's1', 's1', s1 from t1;
select * from v1;
drop view v1;
# underlying field name conflict with set name
--- error 1060
+-- error ER_DUP_FIELDNAME
create view v1 as select 1 as s1, 's1', s1 from t1;
--- error 1060
+-- error ER_DUP_FIELDNAME
create view v1 as select 's1', s1, 1 as s1 from t1;
drop table t1;
# set names differ by case only
--- error 1060
+-- error ER_DUP_FIELDNAME
create view v1(k, K) as select 1,2;
#
-# using time_format in view (BUG#7521)
+# using time_format in view (Bug#7521)
#
create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;
select * from v1;
drop view v1;
#
-# evaluation constant functions in WHERE (BUG#4663)
+# evaluation constant functions in WHERE (Bug#4663)
#
create table t1 (a timestamp default now());
create table t2 (b timestamp default now());
@@ -1717,7 +1717,7 @@ DROP VIEW v1;
DROP TABLE t1;
#
-# checking views after some view with error (BUG#11337)
+# checking views after some view with error (Bug#11337)
#
CREATE TABLE t1 (col1 time);
CREATE TABLE t2 (col1 time);
@@ -1758,7 +1758,7 @@ drop view v1, v2, v3, v4, v5, v6;
drop table t2,t3;
#
-# bug #11325 Wrong date comparison in views
+# Bug#11325 Wrong date comparison in views
#
create table t1 (f1 date);
insert into t1 values ('2005-01-01'),('2005-02-02');
@@ -1769,7 +1769,7 @@ drop view v1;
drop table t1;
#
-# using encrypt & substring_index in view (BUG#7024)
+# using encrypt & substring_index in view (Bug#7024)
#
CREATE VIEW v1 AS SELECT ENCRYPT("dhgdhgd");
disable_result_log;
@@ -1781,21 +1781,21 @@ SELECT * FROM v1;
drop view v1;
#
-# hide underlying tables names in case of imposibility to update (BUG#10773)
+# hide underlying tables names in case of imposibility to update (Bug#10773)
#
create table t1 (f59 int, f60 int, f61 int);
insert into t1 values (19,41,32);
-create view v1 as select f59, f60 from t1 where f59 in
+create view v1 as select f59, f60 from t1 where f59 in
(select f59 from t1);
--- error 1288
+-- error ER_NON_UPDATABLE_TABLE
update v1 set f60=2345;
--- error 1443
+-- error ER_VIEW_PREVENT_UPDATE
update t1 set f60=(select max(f60) from v1);
drop view v1;
drop table t1;
#
-# Using var_samp with view (BUG#10651)
+# Using var_samp with view (Bug#10651)
#
create table t1 (s1 int);
create view v1 as select var_samp(s1) from t1;
@@ -1803,24 +1803,26 @@ show create view v1;
drop view v1;
drop table t1;
+
#
# Correct inserting data check (absence of default value) for view
-# underlying tables (BUG#6443)
+# underlying tables (Bug#6443)
#
set sql_mode='strict_all_tables';
CREATE TABLE t1 (col1 INT NOT NULL, col2 INT NOT NULL);
CREATE VIEW v1 (vcol1) AS SELECT col1 FROM t1;
CREATE VIEW v2 (vcol1) AS SELECT col1 FROM t1 WHERE col2 > 2;
--- error 1364
+-- error ER_NO_DEFAULT_FOR_FIELD
INSERT INTO t1 (col1) VALUES(12);
--- error 1423
+-- error ER_NO_DEFAULT_FOR_VIEW_FIELD
INSERT INTO v1 (vcol1) VALUES(12);
--- error 1423
+-- error ER_NO_DEFAULT_FOR_VIEW_FIELD
INSERT INTO v2 (vcol1) VALUES(12);
set sql_mode=default;
drop view v2,v1;
drop table t1;
+
#
# Bug#11399 Use an alias in a select statement on a view
#
@@ -1831,8 +1833,9 @@ select f1 as alias from v1;
drop view v1;
drop table t1;
+
#
-# Test for bug #6120: SP cache to be invalidated when altering a view
+# Test for Bug#6120 SP cache to be invalidated when altering a view
#
CREATE TABLE t1 (s1 int, s2 int);
@@ -1851,8 +1854,9 @@ DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Test for bug #11709 View was ordered by wrong column
+# Test for Bug#11709 View was ordered by wrong column
#
create table t1 (f1 int, f2 int);
create view v1 as select f1 as f3, f2 as f1 from t1;
@@ -1861,8 +1865,9 @@ select * from v1 order by f1;
drop view v1;
drop table t1;
+
#
-# Test for bug #11771: wrong query_id in SELECT * FROM <view>
+# Test for Bug#11771 wrong query_id in SELECT * FROM <view>
#
CREATE TABLE t1 (f1 char);
INSERT INTO t1 VALUES ('A');
@@ -1875,8 +1880,9 @@ SELECT * FROM t1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# opening table in correct locking mode (BUG#9597)
+# opening table in correct locking mode (Bug#9597)
#
CREATE TABLE t1 ( bug_table_seq INTEGER NOT NULL);
CREATE OR REPLACE VIEW v1 AS SELECT * from t1;
@@ -1893,8 +1899,9 @@ DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #11760 Typo in Item_func_add_time::print() results in NULLs returned
+# Bug#11760 Typo in Item_func_add_time::print() results in NULLs returned
# subtime() in view
create table t1(f1 datetime);
insert into t1 values('2005.01.01 12:0:0');
@@ -1903,8 +1910,9 @@ select * from v1;
drop view v1;
drop table t1;
+
#
-# Test for bug #11412: query over a multitable view with GROUP_CONCAT
+# Test for Bug#11412 query over a multitable view with GROUP_CONCAT
#
CREATE TABLE t1 (
aid int PRIMARY KEY,
@@ -1920,15 +1928,16 @@ INSERT INTO t2 values (1,1), (2,1), (2,2);
CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid;
-SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2
+SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2
WHERE t1.aid = t2.aid GROUP BY pid;
SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid;
DROP VIEW v1;
DROP TABLE t1,t2;
+
#
-# Test for bug #12382: SELECT * FROM view after INSERT command
+# Test for Bug#12382 SELECT * FROM view after INSERT command
#
CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255));
@@ -1942,9 +1951,10 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Test for bug #12470: crash for a simple select from a view defined
-# as a join over 5 tables
+# Test for Bug#12470 crash for a simple select from a view defined
+# as a join over 5 tables
CREATE TABLE t1 (pk int PRIMARY KEY, b int);
CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
@@ -1961,27 +1971,29 @@ SELECT a FROM v1;
DROP VIEW v1;
DROP TABLE t1,t2,t3,t4,t5;
+
#
-# Bug #12298 Typo in function name results in erroneous view being created.
+# Bug#12298 Typo in function name results in erroneous view being created.
#
create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1;
select * from v1;
drop view v1;
#
-# repeatable CREATE VIEW statement BUG#12468
+# repeatable CREATE VIEW statement Bug#12468
#
create table t1(a int);
create procedure p1() create view v1 as select * from t1;
drop table t1;
--- error 1146
+-- error ER_NO_SUCH_TABLE
call p1();
--- error 1146
+-- error ER_NO_SUCH_TABLE
call p1();
drop procedure p1;
+
#
-# Bug #10624 Views with multiple UNION and UNION ALL produce incorrect results
+# Bug#10624 Views with multiple UNION and UNION ALL produce incorrect results
#
create table t1 (f1 int);
create table t2 (f1 int);
@@ -1991,20 +2003,23 @@ create view v1 as select * from t1 union select * from t2 union all select * fro
select * from v1;
drop view v1;
drop table t1,t2;
+
+
+#
+# Test for Bug#10970 view referring a temporary table indirectly
#
-# Test for bug #10970: view referring a temporary table indirectly
-#
CREATE TEMPORARY TABLE t1 (a int);
CREATE FUNCTION f1 () RETURNS int RETURN (SELECT COUNT(*) FROM t1);
--- error 1352
+-- error ER_VIEW_SELECT_TMPTABLE
CREATE VIEW v1 AS SELECT f1();
DROP FUNCTION f1;
DROP TABLE t1;
+
#
-# BUG #12533 (crash on DESCRIBE <view> after renaming base table column)
+# Bug#12533 (crash on DESCRIBE <view> after renaming base table column)
#
--disable_warnings
DROP TABLE IF EXISTS t1;
@@ -2016,13 +2031,14 @@ CREATE VIEW v1 AS SELECT * FROM t1;
DESCRIBE v1;
ALTER TABLE t1 CHANGE COLUMN f4 f4x CHAR(5);
---error 1356
+--error ER_VIEW_INVALID
DESCRIBE v1;
DROP TABLE t1;
DROP VIEW v1;
-#
-# Bug #12489 wrongly printed strcmp() function results in creation of broken
+
+#
+# Bug#12489 wrongly printed strcmp() function results in creation of broken
# view
create table t1 (f1 char);
create view v1 as select strcmp(f1,'a') from t1;
@@ -2030,8 +2046,9 @@ select * from v1;
drop view v1;
drop table t1;
+
#
-# Bug #12922 if(sum(),...) with group from view returns wrong results
+# Bug#12922 if(sum(),...) with group from view returns wrong results
#
create table t1 (f1 int, f2 int,f3 int);
insert into t1 values (1,10,20),(2,0,0);
@@ -2039,7 +2056,9 @@ create view v1 as select * from t1;
select if(sum(f1)>1,f2,f3) from v1 group by f1;
drop view v1;
drop table t1;
-# BUG#12941
+
+
+# Bug#12941
#
--disable_warnings
create table t1 (
@@ -2049,7 +2068,7 @@ create table t1 (
create table t2 (
r_object_id char(16) NOT NULL,
- i_position int(11) NOT NULL,
+ i_position int(11) NOT NULL,
users_names varchar(32) default NULL
) Engine = InnoDB;
--enable_warnings
@@ -2067,23 +2086,25 @@ insert into t2 values('120001a080000542',-1, 'guser01');
insert into t2 values('120001a080000542',-2, 'guser02');
select v1.r_object_id, v2.users_names from v1, v2
-where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id
+where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id
order by users_names;
drop view v1, v2;
drop table t1, t2;
+
#
-# Bug #6808 - Views: CREATE VIEW v ... FROM t AS v fails
+# Bug#6808 Views: CREATE VIEW v ... FROM t AS v fails
#
-create table t1 (s1 int);
+create table t1 (s1 int);
create view abc as select * from t1 as abc;
drop table t1;
drop view abc;
+
#
-# Bug #12993 View column rename broken in subselect
+# Bug#12993 View column rename broken in subselect
#
create table t1(f1 char(1));
create view v1 as select * from t1;
@@ -2091,15 +2112,17 @@ select * from (select f1 as f2 from v1) v where v.f2='a';
drop view v1;
drop table t1;
+
#
-# Bug #11416 Server crash if using a view that uses function convert_tz
+# Bug#11416 Server crash if using a view that uses function convert_tz
#
create view v1 as SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
select * from v1;
drop view v1;
+
#
-# Bugs #12963, #13000: wrong creation of VIEW with DAYNAME, DAYOFWEEK, and WEEKDAY
+# Bugs#12963, #13000 wrong creation of VIEW with DAYNAME, DAYOFWEEK, and WEEKDAY
#
CREATE TABLE t1 (date DATE NOT NULL);
@@ -2129,8 +2152,9 @@ SELECT * FROM v3;
DROP TABLE t1;
DROP VIEW v1, v2, v3;
+
#
-# Bug #13411: crash when using non-qualified view column in HAVING clause
+# Bug#13411 crash when using non-qualified view column in HAVING clause
#
CREATE TABLE t1 ( a int, b int );
@@ -2142,8 +2166,9 @@ SELECT v1.a FROM v1 GROUP BY v1.a HAVING a > 1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #13410: failed name resolution for qualified view column in HAVING
+# Bug#13410 failed name resolution for qualified view column in HAVING
#
CREATE TABLE t1 ( a int, b int );
@@ -2157,8 +2182,9 @@ SELECT v_1.a FROM v1 AS v_1 GROUP BY v_1.a HAVING v_1.a IN (1,2,3);
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #13327 view wasn't using index for const condition
+# Bug#13327 view wasn't using index for const condition
#
CREATE TABLE t1 (a INT, b INT, INDEX(a,b));
@@ -2175,8 +2201,9 @@ EXPLAIN SELECT * FROM v2 WHERE a=1;
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3;
+
#
-# Bug #13622 Wrong view .frm created if some field's alias contain \n
+# Bug#13622 Wrong view .frm created if some field's alias contain \n
#
create table t1 (f1 int);
create view v1 as select t1.f1 as '123
@@ -2185,7 +2212,8 @@ select * from v1;
drop view v1;
drop table t1;
-# Bug #14466 lost sort order in GROUP_CONCAT() in a view
+
+# Bug#14466 lost sort order in GROUP_CONCAT() in a view
#
create table t1 (f1 int, f2 int);
insert into t1 values(1,1),(1,2),(1,3);
@@ -2196,8 +2224,9 @@ select * from v2;
drop view v1,v2;
drop table t1;
+
#
-# BUG#14026 Crash on second PS execution when using views
+# Bug#14026 Crash on second PS execution when using views
#
create table t1 (x int, y int);
create table t2 (x int, y int, z int);
@@ -2207,8 +2236,8 @@ create table t4 (x int, y int, z int);
create view v1 as
select t1.x
from (
- (t1 join t2 on ((t1.y = t2.y)))
- join
+ (t1 join t2 on ((t1.y = t2.y)))
+ join
(t3 left join t4 on (t3.y = t4.y) and (t3.z = t4.z))
);
@@ -2220,8 +2249,9 @@ execute stmt1 using @parm1;
drop view v1;
drop table t1,t2,t3,t4;
+
#
-# Bug #14540: OPTIMIZE, ANALYZE, REPAIR applied to not a view
+# Bug#14540 OPTIMIZE, ANALYZE, REPAIR applied to not a view
#
CREATE TABLE t1(id INT);
@@ -2240,7 +2270,7 @@ DROP VIEW v1;
#
-# BUG#14719: Views DEFINER grammar is incorrect
+# Bug#14719 Views DEFINER grammar is incorrect
#
create definer = current_user() sql security invoker view v1 as select 1;
@@ -2251,8 +2281,9 @@ create definer = current_user sql security invoker view v1 as select 1;
show create view v1;
drop view v1;
+
#
-# Bug #14816 test_if_order_by_key() expected only Item_fields.
+# Bug#14816 test_if_order_by_key() expected only Item_fields.
#
create table t1 (id INT, primary key(id));
insert into t1 values (1),(2);
@@ -2261,8 +2292,9 @@ explain select id from v1 order by id;
drop view v1;
drop table t1;
+
#
-# Bug #14850 Item_ref's values wasn't updated
+# Bug#14850 Item_ref's values wasn't updated
#
create table t1(f1 int, f2 int);
insert into t1 values (null, 10), (null,2);
@@ -2272,8 +2304,9 @@ select f1, sum(f2) from v1 group by f1;
drop view v1;
drop table t1;
+
#
-# BUG#14885: incorrect SOURCE in view created in a procedure
+# Bug#14885 incorrect SOURCE in view created in a procedure
# TODO: here SOURCE string must be shown when it will be possible
#
--disable_warnings
@@ -2291,8 +2324,9 @@ show create view v1;
drop view v1;
drop procedure p1;
+
#
-# BUG#15096: using function with view for view creation
+# Bug#15096 using function with view for view creation
#
CREATE VIEW v1 AS SELECT 42 AS Meaning;
--disable_warnings
@@ -2312,8 +2346,9 @@ select * from v2;
drop view v2,v1;
drop function f1;
+
#
-# Bug#14861: aliased column names are not preserved.
+# Bug#14861 aliased column names are not preserved.
#
create table t1 (id numeric, warehouse_id numeric);
create view v1 as select id from t1;
@@ -2331,8 +2366,9 @@ order by v2.receipt_id;
drop view v2, v1;
drop table t1;
+
#
-# Bug#16016: MIN/MAX optimization for views
+# Bug#16016 MIN/MAX optimization for views
#
CREATE TABLE t1 (a int PRIMARY KEY, b int);
@@ -2355,9 +2391,10 @@ EXPLAIN SELECT MIN(a) FROM v1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug#16382: grouping name is resolved against a view column name
-# which coincides with a select column name
+# Bug#16382 grouping name is resolved against a view column name
+# which coincides with a select column name
CREATE TABLE t1 (x varchar(10));
INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null);
@@ -2372,21 +2409,23 @@ SELECT IF(x IS NULL, 'blank', 'not blank') AS x FROM v1 GROUP BY x;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# BUG#15943: mysql_next_result hangs on invalid SHOW CREATE VIEW
+# Bug#15943 mysql_next_result hangs on invalid SHOW CREATE VIEW
#
delimiter //;
-drop table if exists t1;
-drop view if exists v1;
-create table t1 (id int);
-create view v1 as select * from t1;
-drop table t1;
-show create view v1;
+drop table if exists t1;
+drop view if exists v1;
+create table t1 (id int);
+create view v1 as select * from t1;
+drop table t1;
+show create view v1;
drop view v1;
//
delimiter ;//
+
#
# Bug#17726 Not checked empty list caused endless loop
#
@@ -2401,9 +2440,10 @@ select * from v2;
drop view v2, v1;
drop table t1;
+
#
-# Bug #18386: select from view over a table with ORDER BY view_col clause
-# given view_col is not an image of any column from the base table
+# Bug#18386 select from view over a table with ORDER BY view_col clause
+# given view_col is not an image of any column from the base table
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2);
@@ -2415,9 +2455,10 @@ SELECT my_sqrt FROM v1 ORDER BY my_sqrt;
DROP VIEW v1;
DROP TABLE t1;
+
+#
+# Bug#18237 invalid count optimization applied to an outer join with a view
#
-# Bug #18237: invalid count optimization applied to an outer join with a view
-#
CREATE TABLE t1 (id int PRIMARY KEY);
CREATE TABLE t2 (id int PRIMARY KEY);
@@ -2436,14 +2477,16 @@ DROP VIEW v2;
DROP TABLE t1, t2;
+
#
-# Bug #16069: VIEW does return the same results as underlying SELECT
-# with WHERE condition containing BETWEEN over dates
+# Bug#16069 VIEW does return the same results as underlying SELECT
+# with WHERE condition containing BETWEEN over dates
# Dates as strings should be casted to date type
+
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY,
td date DEFAULT NULL, KEY idx(td));
-INSERT INTO t1 VALUES
+INSERT INTO t1 VALUES
(1, '2005-01-01'), (2, '2005-01-02'), (3, '2005-01-02'),
(4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'),
(7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06');
@@ -2456,8 +2499,9 @@ SELECT * FROM v1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.0
DROP VIEW v1;
DROP TABLE t1;
+
#
-# BUG#14308: Recursive view definitions
+# Bug#14308 Recursive view definitions
#
# using view only
create table t1 (a int);
@@ -2487,8 +2531,9 @@ select * from v1;
drop function f1;
drop view t1, v1;
+
#
-# Bug #15153: CONVERT_TZ() is not allowed in all places in VIEWs
+# Bug#15153 CONVERT_TZ() is not allowed in all places in VIEWs
#
# Error was reported when one tried to use CONVERT_TZ() function
# select list of view which was processed using MERGE algorithm.
@@ -2499,7 +2544,7 @@ insert into t1 values (20040101000000), (20050101000000), (20060101000000);
create view v1 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from t1;
select * from v1;
drop view v1;
-# And in its where part
+# And in its where part
create view v1 as select * from t1 where convert_tz(dt, 'UTC', 'Europe/Moscow') >= 20050101000000;
select * from v1;
# Other interesting case - a view which uses convert_tz() function
@@ -2514,9 +2559,10 @@ select * from v2;
drop view v1, v2;
drop table t1;
+
#
-# Bug #19490: usage of view specified by a query with GROUP BY
-# an expression containing non-constant interval
+# Bug#19490 usage of view specified by a query with GROUP BY
+# an expression containing non-constant interval
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime);
@@ -2530,8 +2576,9 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug#19077: A nested materialized view is used before being populated.
+# Bug#19077 A nested materialized view is used before being populated.
#
CREATE TABLE t1 (i INT, j BIGINT);
INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
@@ -2541,9 +2588,10 @@ SELECT * FROM v2;
DROP VIEW v2, v1;
DROP TABLE t1;
+
+#
+# Bug#19573 VIEW with HAVING that refers an alias name
#
-# Bug #19573: VIEW with HAVING that refers an alias name
-#
CREATE TABLE t1(
fName varchar(25) NOT NULL,
@@ -2551,7 +2599,7 @@ CREATE TABLE t1(
DOB date NOT NULL,
test_date date NOT NULL,
uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY);
-
+
INSERT INTO t1(fName, lName, DOB, test_date) VALUES
('Hank', 'Hill', '1964-09-29', '2007-01-01'),
('Tom', 'Adams', '1908-02-14', '2007-01-01'),
@@ -2559,8 +2607,8 @@ INSERT INTO t1(fName, lName, DOB, test_date) VALUES
CREATE VIEW v1 AS
SELECT (year(test_date)-year(DOB)) AS Age
- FROM t1 HAVING Age < 75;
-SHOW CREATE VIEW v1;
+ FROM t1 HAVING Age < 75;
+SHOW CREATE VIEW v1;
SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75;
SELECT * FROM v1;
@@ -2568,8 +2616,9 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #19089: wrong inherited dafault values in temp table views
+# Bug#19089 wrong inherited dafault values in temp table views
#
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx');
@@ -2599,8 +2648,9 @@ SELECT * FROM t2;
DROP VIEW v1;
DROP TABLE t1,t2;
+
#
-# Bug#16110: insert permitted into view col w/o default value
+# Bug#16110 insert permitted into view col w/o default value
#
CREATE TABLE t1 (a INT NOT NULL, b INT NULL DEFAULT NULL);
CREATE VIEW v1 AS SELECT a, b FROM t1;
@@ -2608,7 +2658,7 @@ CREATE VIEW v1 AS SELECT a, b FROM t1;
INSERT INTO v1 (b) VALUES (2);
SET SQL_MODE = STRICT_ALL_TABLES;
---error 1423
+--error ER_NO_DEFAULT_FOR_VIEW_FIELD
INSERT INTO v1 (b) VALUES (4);
SET SQL_MODE = '';
@@ -2617,8 +2667,9 @@ SELECT * FROM t1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #18243: expression over a view column that with the REVERSE function
+# Bug#18243 expression over a view column that with the REVERSE function
#
CREATE TABLE t1 (firstname text, surname text);
@@ -2633,21 +2684,23 @@ SELECT CONCAT(LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," ")),
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #19714: wrong type of a view column specified by an expressions over ints
+# Bug#19714 wrong type of a view column specified by an expressions over ints
#
CREATE TABLE t1 (i int, j int);
CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1;
DESCRIBE v1;
-CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1;
+CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1;
DESCRIBE t2;
DROP VIEW v1;
DROP TABLE t1,t2;
+
#
-# Bug #17526: views with TRIM functions
+# Bug#17526 views with TRIM functions
#
CREATE TABLE t1 (s varchar(10));
@@ -2658,20 +2711,21 @@ CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1;
SELECT * FROM v1;
DROP VIEW v1;
-SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+SELECT TRIM(LEADING 'y' FROM s) FROM t1;
CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
SELECT * FROM v1;
DROP VIEW v1;
-SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-#Bug #21080: ALTER VIEW makes user restate SQL SECURITY mode, and ALGORITHM
+# Bug#21080 ALTER VIEW makes user restate SQL SECURITY mode, and ALGORITHM
#
CREATE TABLE t1 (x INT, y INT);
CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
@@ -2682,8 +2736,10 @@ SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP TABLE t1;
-# Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE
-# clause is called
+
+
+# Bug#21086 server crashes when VIEW defined with a SELECT with COLLATE
+# clause is called
#
CREATE TABLE t1 (s1 char);
INSERT INTO t1 VALUES ('Z');
@@ -2700,19 +2756,20 @@ SELECT s1 FROM t1;
DROP VIEW v1, v2;
DROP TABLE t1;
+
#
-# Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
+# Bug#11551 Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
#
CREATE TABLE t1 (id INT);
CREATE VIEW v1 AS SELECT id FROM t1;
SHOW TABLES;
---error 1051
+--error ER_BAD_TABLE_ERROR
DROP VIEW v2,v1;
SHOW TABLES;
CREATE VIEW v1 AS SELECT id FROM t1;
---error 1347
+--error ER_WRONG_OBJECT
DROP VIEW t1,v1;
SHOW TABLES;
@@ -2721,13 +2778,14 @@ DROP TABLE t1;
DROP VIEW IF EXISTS v1;
--enable_warnings
+
#
-# Bug #21261: Wrong access rights was required for an insert to a view
+# Bug#21261 Wrong access rights was required for an insert to a view
#
CREATE DATABASE bug21261DB;
USE bug21261DB;
-CONNECT (root,localhost,root,,bug21261DB);
-CONNECTION root;
+connect (root,localhost,root,,bug21261DB);
+connection root;
CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
@@ -2736,34 +2794,41 @@ GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
CREATE TABLE t2 (y INT);
GRANT SELECT ON t2 TO 'user21261'@'localhost';
-CONNECT (user21261, localhost, user21261,, bug21261DB);
-CONNECTION user21261;
+connect (user21261, localhost, user21261,, bug21261DB);
+connection user21261;
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
-CONNECTION root;
+connection root;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
GRANT SELECT ON t1 TO 'user21261'@'localhost';
-CONNECTION user21261;
+connection user21261;
UPDATE v1,t2 SET x=1 WHERE x=y;
-CONNECTION root;
+connection root;
SELECT * FROM t1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;
+
+connection default;
USE test;
+disconnect root;
+disconnect user21261;
+
#
-# Bug #15950: NOW() optimized away in VIEWs
+# Bug#15950 NOW() optimized away in VIEWs
#
create table t1 (f1 datetime);
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
show create view v1;
drop view v1;
drop table t1;
+
+
#
-# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+# Test for Bug#16899 Possible buffer overflow in handling of DEFINER-clause.
#
# Prepare.
@@ -2790,8 +2855,7 @@ DROP TABLE t1;
#
-# BUG#17591: Updatable view not possible with trigger or stored
-# function
+# Bug#17591 Updatable view not possible with trigger or stored function
#
# During prelocking phase we didn't update lock type of view tables,
# hence READ lock was always requested.
@@ -2835,11 +2899,12 @@ DROP FUNCTION f2;
DROP VIEW v1, v2;
DROP TABLE t1;
+
#
-# Bug #5500: wrong select_type in EXPLAIN output for queries over views
+# Bug#5500 wrong select_type in EXPLAIN output for queries over views
#
-CREATE TABLE t1 (s1 int);
+CREATE TABLE t1 (s1 int);
CREATE VIEW v1 AS SELECT * FROM t1;
EXPLAIN SELECT * FROM t1;
@@ -2847,34 +2912,36 @@ EXPLAIN SELECT * FROM v1;
INSERT INTO t1 VALUES (1), (3), (2);
-EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
-EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #5505: Wrong error message on INSERT into a view
+# Bug#5505 Wrong error message on INSERT into a view
#
create table t1 (s1 int);
create view v1 as select s1 as a, s1 as b from t1;
--error ER_NON_INSERTABLE_TABLE
-insert into v1 values (1,1);
+insert into v1 values (1,1);
update v1 set a = 5;
drop view v1;
drop table t1;
+
#
-# Bug #21646: view qith a subquery in ON expression
+# Bug#21646 view qith a subquery in ON expression
#
-CREATE TABLE t1(pk int PRIMARY KEY);
+CREATE TABLE t1(pk int PRIMARY KEY);
CREATE TABLE t2(pk int PRIMARY KEY, fk int, ver int, org int);
-CREATE ALGORITHM=MERGE VIEW v1 AS
+CREATE ALGORITHM=MERGE VIEW v1 AS
SELECT t1.*
- FROM t1 JOIN t2
- ON t2.fk = t1.pk AND
+ FROM t1 JOIN t2
+ ON t2.fk = t1.pk AND
t2.ver = (SELECT MAX(t.ver) FROM t2 t WHERE t.org = t2.org);
SHOW WARNINGS;
SHOW CREATE VIEW v1;
@@ -2882,9 +2949,9 @@ SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP TABLE t1, t2;
+
#
-# Bug#19111: TRIGGERs selecting from a VIEW on the firing base table
-# fail
+# Bug#19111 TRIGGERs selecting from a VIEW on the firing base table fail
#
# Allow to select from a view on a table being modified in a trigger
# and stored function, since plain select is allowed there.
@@ -2915,22 +2982,24 @@ DROP FUNCTION f1;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE)
+# Bug#16813 (WITH CHECK OPTION doesn't work with UPDATE)
#
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION;
INSERT INTO v1 (val) VALUES (2);
INSERT INTO v1 (val) VALUES (4);
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
INSERT INTO v1 (val) VALUES (6);
--- error 1369
+-- error ER_VIEW_CHECK_FAILED
UPDATE v1 SET val=6 WHERE id=2;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# BUG#22584: last_insert_id not updated after inserting a record
+# Bug#22584 last_insert_id not updated after inserting a record
# through a updatable view
#
# We still do not update LAST_INSERT_ID if AUTO_INCREMENT column is
@@ -2966,8 +3035,9 @@ SELECT * FROM t1;
DROP VIEW v1, v2;
DROP TABLE t1;
+
#
-# Bug #25580: !0 as an operand in a select expression of a view
+# Bug#25580 !0 as an operand in a select expression of a view
#
CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
@@ -2978,8 +3048,9 @@ SELECT * FROM v;
DROP VIEW v;
+
#
-# BUG#24293: '\Z' token is not handled correctly in views
+# Bug#24293 '\Z' token is not handled correctly in views
#
--disable_warnings
@@ -2993,8 +3064,9 @@ SHOW CREATE VIEW v1;
DROP VIEW v1;
+
#
-# Bug #26124: BETWEEN over a view column of the DATETIME type
+# Bug#26124 BETWEEN over a view column of the DATETIME type
#
CREATE TABLE t1 (mydate DATETIME);
@@ -3009,8 +3081,9 @@ SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #25931: update of a multi-table view with check option
+# Bug#25931 update of a multi-table view with check option
#
CREATE TABLE t1 (a int);
@@ -3022,7 +3095,7 @@ CREATE VIEW v1 AS
SELECT t2.b FROM t1,t2 WHERE t1.a = t2.b WITH CHECK OPTION;
SELECT * FROM v1;
---error 1369
+--error ER_VIEW_CHECK_FAILED
UPDATE v1 SET b=3;
SELECT * FROM v1;
SELECT * FROM t1;
@@ -3031,8 +3104,9 @@ SELECT * FROM t2;
DROP VIEW v1;
DROP TABLE t1,t2;
+
#
-# Bug#12122: Views with ORDER BY can't be resolved using MERGE algorithm.
+# Bug#12122 Views with ORDER BY can't be resolved using MERGE algorithm.
#
create table t1(f1 int, f2 int);
insert into t1 values(1,2),(1,3),(1,1),(2,3),(2,1),(2,2);
@@ -3046,7 +3120,7 @@ drop view v1;
drop table t1;
#
-# Bug#26209: queries with GROUP BY and ORDER BY using views
+# Bug#26209 queries with GROUP BY and ORDER BY using views
#
CREATE TABLE t1 (
@@ -3065,9 +3139,9 @@ SELECT code, COUNT(DISTINCT country) FROM v1 GROUP BY code ORDER BY MAX(id);
DROP VIEW v1;
DROP TABLE t1;
+
#
-# BUG#25897: Some queries are no longer possible after a CREATE VIEW
-# fails
+# Bug#25897 Some queries are no longer possible after a CREATE VIEW fails
#
--disable_warnings
DROP VIEW IF EXISTS v1;
@@ -3081,9 +3155,9 @@ eval CREATE VIEW v1 AS $query;
--echo # Previously the following would fail.
eval $query;
+
#
-# Bug#24532: The return data type of IS TRUE is different from similar
-# operations
+# Bug#24532 The return data type of IS TRUE is different from similar operations
#
--disable_warnings
@@ -3168,8 +3242,9 @@ drop view view_24532_a;
drop view view_24532_b;
drop table table_24532;
+
#
-# Bug#26560: view using subquery with a reference to an outer alias
+# Bug#26560 view using subquery with a reference to an outer alias
#
CREATE TABLE t1 (
@@ -3180,7 +3255,7 @@ INSERT INTO t1 (lid, name) VALUES
(1, 'YES'), (2, 'NO');
CREATE TABLE t2 (
- id int NOT NULL PRIMARY KEY,
+ id int NOT NULL PRIMARY KEY,
gid int NOT NULL,
lid int NOT NULL,
dt date
@@ -3208,8 +3283,9 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP table t1,t2;
+
#
-# Bug#27786: Inconsistent Operation Performing UNION On View With ORDER BY
+# Bug#27786 Inconsistent Operation Performing UNION On View With ORDER BY
#
CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3);
CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a;
@@ -3224,8 +3300,9 @@ EXPLAIN SELECT * FROM t1 UNION SELECT * FROM v1 ORDER BY a;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #27921 View ignores precision for CAST()
+# Bug#27921 View ignores precision for CAST()
#
CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col;
SELECT * FROM v1;
@@ -3236,9 +3313,10 @@ CREATE VIEW v1 AS SELECT CAST(1.23456789 AS DECIMAL(8,0)) AS col;
SHOW CREATE VIEW v1;
DROP VIEW v1;
+
#
-# Bug #28716: CHECK OPTION expression is evaluated over expired record buffers
-# when VIEW is updated via temporary tables
+# Bug#28716 CHECK OPTION expression is evaluated over expired record buffers
+# when VIEW is updated via temporary tables
#
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT, c INT DEFAULT 0);
@@ -3252,9 +3330,10 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1,t2;
+
#
-# Bug #28561: update on multi-table view with CHECK OPTION and
-# a subquery in WHERE condition
+# Bug#28561 update on multi-table view with CHECK OPTION and a subquery
+# in WHERE condition
#
CREATE TABLE t1 (id int);
@@ -3262,8 +3341,8 @@ CREATE TABLE t2 (id int, c int DEFAULT 0);
INSERT INTO t1 (id) VALUES (1);
INSERT INTO t2 (id) VALUES (1);
-CREATE VIEW v1 AS
- SELECT t2.c FROM t1, t2
+CREATE VIEW v1 AS
+ SELECT t2.c FROM t1, t2
WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
UPDATE v1 SET c=1;
@@ -3271,9 +3350,10 @@ UPDATE v1 SET c=1;
DROP VIEW v1;
DROP TABLE t1,t2;
+
#
-# Bug #27827: CHECK OPTION ignores ON conditions when updating
-# a multi-table view with CHECK OPTION.
+# Bug#27827 CHECK OPTION ignores ON conditions when updating
+# a multi-table view with CHECK OPTION.
#
CREATE TABLE t1 (a1 INT, c INT DEFAULT 0);
@@ -3289,14 +3369,14 @@ CREATE VIEW v1 AS
SELECT t1.a1, t1.c FROM t1 JOIN t2 ON t1.a1=t2.a2 AND t1.c < 3
WITH CHECK OPTION;
SELECT * FROM v1;
---error 1369
+--error ER_VIEW_CHECK_FAILED
UPDATE v1 SET c=3;
PREPARE t FROM 'UPDATE v1 SET c=3';
---error 1369
+--error ER_VIEW_CHECK_FAILED
EXECUTE t;
---error 1369
+--error ER_VIEW_CHECK_FAILED
EXECUTE t;
---error 1369
+--error ER_VIEW_CHECK_FAILED
INSERT INTO v1(a1, c) VALUES (3, 3);
UPDATE v1 SET c=1 WHERE a1=1;
SELECT * FROM v1;
@@ -3307,14 +3387,14 @@ CREATE VIEW v2 AS SELECT t1.a1, t1.c
JOIN (t3 JOIN t4 ON t3.a3=t4.a4)
ON t2.a2=t3.a3 WITH CHECK OPTION;
SELECT * FROM v2;
---error 1369
+--error ER_VIEW_CHECK_FAILED
UPDATE v2 SET c=3;
PREPARE t FROM 'UPDATE v2 SET c=3';
---error 1369
+--error ER_VIEW_CHECK_FAILED
EXECUTE t;
---error 1369
+--error ER_VIEW_CHECK_FAILED
EXECUTE t;
---error 1369
+--error ER_VIEW_CHECK_FAILED
INSERT INTO v2(a1, c) VALUES (3, 3);
UPDATE v2 SET c=2 WHERE a1=1;
SELECT * FROM v2;
@@ -3323,10 +3403,11 @@ SELECT * FROM t1;
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3,t4;
+
#
-# Bug #29104: assertion abort for a query with a view column reference
-# in the GROUP BY list and a condition requiring the value
-# of another view column to be equal to a constant
+# Bug#29104 assertion abort for a query with a view column reference
+# in the GROUP BY list and a condition requiring the value
+# of another view column to be equal to a constant
#
CREATE TABLE t1 (a int, b int);
@@ -3347,9 +3428,10 @@ EXPLAIN SELECT a, SUM(b) FROM v1 WHERE a=1 GROUP BY a;
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #29392: SELECT over a multi-table view with ORDER BY
-# selecting the same view column with two different aliases
+# Bug#29392 SELECT over a multi-table view with ORDER BY
+# selecting the same view column with two different aliases
#
CREATE TABLE t1 (
@@ -3373,7 +3455,7 @@ CREATE TABLE t3 (
INDEX idx_app_name(app_name)
);
-CREATE VIEW v1 AS
+CREATE VIEW v1 AS
SELECT profile.person_id AS person_id
FROM t1 profile, t2 userrole, t3 role
WHERE userrole.person_id = profile.person_id AND
@@ -3387,35 +3469,37 @@ INSERT INTO t1 VALUES
INSERT INTO t2 VALUES
(1,3,6),(2,4,7),(3,5,8),(4,6,9),(5,1,6),(6,1,7),(7,1,8),(8,1,9),(9,1,10);
-INSERT INTO t3 VALUES
+INSERT INTO t3 VALUES
(1,'NUCANS_APP_USER','NUCANSAPP'),(2,'NUCANS_TRGAPP_USER','NUCANSAPP'),
(3,'IA_INTAKE_COORDINATOR','IACANS'),(4,'IA_SCREENER','IACANS'),
(5,'IA_SUPERVISOR','IACANS'),(6,'IA_READONLY','IACANS'),
(7,'SOC_USER','SOCCANS'),(8,'CAYIT_USER','CAYITCANS'),
(9,'RTOS_DCFSPOS_SUPERVISOR','RTOS');
-
+
EXPLAIN SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6;
SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6;
DROP VIEW v1;
DROP TABLE t1,t2,t3;
+
#
-# Bug#30020: Insufficient check led to a wrong info provided by the
-# information schema table.
+# Bug#30020 Insufficient check led to a wrong info provided by the
+# information schema table.
#
create table t1 (i int);
insert into t1 values (1), (2), (1), (3), (2), (4);
create view v1 as select distinct i from t1;
select * from v1;
-select table_name, is_updatable from information_schema.views
+select table_name, is_updatable from information_schema.views
where table_name = 'v1';
drop view v1;
drop table t1;
+
#
-# Bug #28701: SELECTs from VIEWs completely ignore USE/FORCE KEY, allowing
-# invalid statements
+# Bug#28701 SELECTs from VIEWs completely ignore USE/FORCE KEY, allowing
+# invalid statements
#
CREATE TABLE t1 (a INT);
@@ -3431,8 +3515,9 @@ SELECT * FROM v1 IGNORE KEY(non_existant);
DROP VIEW v1;
DROP TABLE t1;
+
#
-# Bug #28702: VIEWs defined with USE/FORCE KEY ignore that request
+# Bug#28702 VIEWs defined with USE/FORCE KEY ignore that request
#
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0,
PRIMARY KEY(a), KEY (b));
@@ -3452,9 +3537,10 @@ DROP VIEW v2;
DROP VIEW v3;
DROP TABLE t1;
+
--echo #
---echo # Bug#29477: Not all fields of the target table were checked to have
---echo # a default value when inserting into a view.
+--echo # Bug#29477 Not all fields of the target table were checked to have
+--echo # a default value when inserting into a view.
--echo #
create table t1(f1 int, f2 int not null);
create view v1 as select f1 from t1;
@@ -3467,29 +3553,31 @@ set @@sql_mode=@old_mode;
drop view v1;
drop table t1;
+
#
-# Bug #33389: Selecting from a view into a table from within SP or trigger
-# crashes server
+# Bug#33389 Selecting from a view into a table from within SP or trigger
+# crashes server
#
create table t1 (a int, key(a));
create table t2 (c int);
-
+
create view v1 as select a b from t1;
-create view v2 as select 1 a from t2, v1 where c in
+create view v2 as select 1 a from t2, v1 where c in
(select 1 from t1 where b = a);
-
+
insert into t1 values (1), (1);
insert into t2 values (1), (1);
-
+
prepare stmt from "select * from v2 where a = 1";
-execute stmt;
+execute stmt;
drop view v1, v2;
drop table t1, t2;
+
#
-# Bug #33049: Assert while running test-as3ap test(mysql-bench suite)
+# Bug#33049 Assert while running test-as3ap test(mysql-bench suite)
#
CREATE TABLE t1 (a INT);
@@ -3504,7 +3592,7 @@ DROP TABLE t1;
###########################################################################
--echo # -----------------------------------------------------------------
---echo # -- Bug#34337: Server crash when Altering a view using a table name.
+--echo # -- Bug#34337 Server crash when Altering a view using a table name.
--echo # -----------------------------------------------------------------
--echo
@@ -3534,8 +3622,8 @@ DROP TABLE t1;
###########################################################################
--echo # -----------------------------------------------------------------
---echo # -- Bug#35193: VIEW query is rewritten without "FROM DUAL",
---echo # -- causing syntax error
+--echo # -- Bug#35193 VIEW query is rewritten without "FROM DUAL",
+--echo # -- causing syntax error
--echo # -----------------------------------------------------------------
--echo
@@ -3557,15 +3645,16 @@ DROP VIEW v1;
###########################################################################
#
-# Bug#39040: valgrind errors/crash when creating views with binlog logging
-# enabled
+# Bug#39040 valgrind errors/crash when creating views with binlog logging
+# enabled
#
# Bug is visible only when running in valgrind with binary logging.
CREATE VIEW v1 AS SELECT 1;
DROP VIEW v1;
+
#
-# Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws an error
+# Bug#33461 SELECT ... FROM <view> USE INDEX (...) throws an error
#
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, INDEX (c2));
@@ -3616,7 +3705,7 @@ USE test;
--echo
--echo #
---echo # Bug#26676: VIEW using old table schema in a session.
+--echo # Bug#26676 VIEW using old table schema in a session.
--echo #
--echo
@@ -3668,7 +3757,7 @@ DROP TABLE t1;
###########################################################################
--echo # -----------------------------------------------------------------
---echo # -- Bug#32538: View definition picks up character set, but not collation
+--echo # -- Bug#32538 View definition picks up character set, but not collation
--echo # -----------------------------------------------------------------
--echo
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index 4e8d97e4444..824c67d867e 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -1,6 +1,9 @@
# Can't test with embedded server
-- source include/not_embedded.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
--disable_warnings
drop database if exists mysqltest;
drop view if exists v1,v2,v3;
@@ -32,19 +35,19 @@ grant create view,select on test.* to mysqltest_1@localhost;
connect (user1,localhost,mysqltest_1,,test);
connection user1;
--- error ER_SPECIFIC_ACCESS_DENIED_ERROR
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
create definer=root@localhost view v1 as select * from mysqltest.t1;
create view v1 as select * from mysqltest.t1;
# try to modify view without DROP privilege on it
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
alter view v1 as select * from mysqltest.t1;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create or replace view v1 as select * from mysqltest.t1;
# no CRETE VIEW privilege
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create view mysqltest.v2 as select * from mysqltest.t1;
# no SELECT privilege
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create view v2 as select * from mysqltest.t2;
connection root;
@@ -54,7 +57,7 @@ show create view v1;
grant create view,drop,select on test.* to mysqltest_1@localhost;
connection user1;
-# following 'use' command is workaround of bug #9582 and should be removed
+# following 'use' command is workaround of Bug#9582 and should be removed
# when that bug will be fixed
use test;
alter view v1 as select * from mysqltest.t1;
@@ -82,7 +85,7 @@ grant select (c) on mysqltest.v1 to mysqltest_1@localhost;
connection user1;
select c from mysqltest.v1;
# there are no privileges on column 'd'
--- error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
select d from mysqltest.v1;
connection root;
@@ -102,7 +105,7 @@ grant select (c) on mysqltest.v1 to mysqltest_1@localhost;
connection user1;
select c from mysqltest.v1;
# there are no privileges on column 'd'
--- error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
select d from mysqltest.v1;
connection root;
@@ -117,7 +120,7 @@ connection root;
--disable_warnings
create database mysqltest;
--enable_warnings
-#prepare views and tables
+# prepare views and tables
create table mysqltest.t1 (a int, b int);
create table mysqltest.t2 (a int, b int);
create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1;
@@ -139,21 +142,21 @@ select c from mysqltest.v4;
show columns from mysqltest.v1;
show columns from mysqltest.v2;
# but explain/show do not
--- error 1345
+--error ER_VIEW_NO_EXPLAIN
explain select c from mysqltest.v1;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v1;
--- error 1345
+--error ER_VIEW_NO_EXPLAIN
explain select c from mysqltest.v2;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v2;
--- error 1345
+--error ER_VIEW_NO_EXPLAIN
explain select c from mysqltest.v3;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v3;
--- error 1345
+--error ER_VIEW_NO_EXPLAIN
explain select c from mysqltest.v4;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v4;
# allow to see one of underlying table
@@ -162,19 +165,19 @@ grant select on mysqltest.t1 to mysqltest_1@localhost;
connection user1;
# EXPLAIN of view on above table works
explain select c from mysqltest.v1;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v1;
explain select c from mysqltest.v2;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v2;
# but other EXPLAINs do not
--- error 1345
+--error ER_VIEW_NO_EXPLAIN
explain select c from mysqltest.v3;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v3;
--- error 1345
+--error ER_VIEW_NO_EXPLAIN
explain select c from mysqltest.v4;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
show create view mysqltest.v4;
# allow to see any view in mysqltest database
@@ -228,14 +231,14 @@ select * from t1;
update v2 set a=a+c;
select * from t1;
# no rights on column
--- error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c;
--- error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
update v2 set c=a+c;
# no rights for view
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
update v3 set a=a+c;
use test;
@@ -269,9 +272,9 @@ select * from t1;
delete v1 from t2,v1 where t2.x=v1.c;
select * from t1;
# no rights for view
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
delete v2 from t2,v2 where t2.x=v2.c;
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
delete from v2 where c < 4;
use test;
@@ -305,9 +308,9 @@ select * from t1;
insert into v1 select x,y from t2;
select * from t1;
# no rights for view
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
insert into v2 values (5,6);
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
insert into v2 select x,y from t2;
use test;
@@ -335,10 +338,10 @@ connection user1;
create view v1 as select * from mysqltest.t1;
create view v2 as select b from mysqltest.t2;
# There are not rights on mysqltest.v1
--- error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
create view mysqltest.v1 as select * from mysqltest.t1;
# There are not any rights on mysqltest.t2.a
--- error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
create view v3 as select a from mysqltest.t2;
# give CREATE VIEW privileges (without any privileges for result column)
@@ -358,13 +361,13 @@ create view mysqltest.v3 as select b from mysqltest.t2;
# Expression need select privileges
--- error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
create view v4 as select b+1 from mysqltest.t2;
connection root;
grant create view,update,select on test.* to mysqltest_1@localhost;
connection user1;
--- error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
create view v4 as select b+1 from mysqltest.t2;
connection root;
@@ -417,7 +420,7 @@ connection root;
# check view definer information
show create view v1;
revoke select on mysqltest.t1 from mysqltest_1@localhost;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v1;
grant select on mysqltest.t1 to mysqltest_1@localhost;
select * from v1;
@@ -426,7 +429,7 @@ drop view v1;
drop database mysqltest;
#
-# rights on execution of view underlying functiond (BUG#9505)
+# rights on execution of view underlying functiond (Bug#9505)
#
connection root;
--disable_warnings
@@ -459,11 +462,11 @@ connection user1;
use mysqltest;
select * from v1;
select * from v2;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v3;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v4;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v5;
use test;
@@ -511,13 +514,13 @@ use test;
connection root;
create view v5 as select * from v1;
revoke execute on function f2 from mysqltest_1@localhost;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v1;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v2;
select * from v3;
select * from v4;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v5;
drop view v1, v2, v3, v4, v5;
@@ -555,13 +558,13 @@ use test;
connection root;
revoke select on t1 from mysqltest_1@localhost;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v1;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v2;
select * from v3;
select * from v4;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v5;
#drop view v1, v2, v3, v4, v5;
@@ -594,11 +597,11 @@ connection user1;
use mysqltest;
select * from v1;
select * from v2;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v3;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v4;
--- error ER_VIEW_INVALID
+--error ER_VIEW_INVALID
select * from v5;
use test;
@@ -610,7 +613,7 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop database mysqltest;
#
-# BUG#14256: definer in view definition is not fully qualified
+# Bug#14256 definer in view definition is not fully qualified
#
--disable_warnings
drop view if exists v1;
@@ -647,6 +650,7 @@ drop view v1;
select @v1def1, @v1def2, @v1def1=@v1def2;
connection root;
+disconnect test14256;
drop user test14256;
# Restore the anonymous users.
@@ -656,8 +660,8 @@ flush privileges;
drop table t1;
#
-# BUG#14726: freeing stack variable in case of an error of opening
-# a view when we have locked tables with LOCK TABLES statement.
+# Bug#14726 freeing stack variable in case of an error of opening a view when
+# we have locked tables with LOCK TABLES statement.
#
connection root;
--disable_warnings
@@ -674,7 +678,7 @@ connection user1;
use mysqltest;
LOCK TABLES v1 READ;
--- error ER_TABLEACCESS_DENIED_ERROR
+--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE v1;
UNLOCK TABLES;
use test;
@@ -685,7 +689,7 @@ drop user mysqltest_1@localhost;
drop database mysqltest;
#
-# switch to default connaction
+# switch to default connection
#
disconnect user1;
disconnect root;
@@ -702,7 +706,7 @@ drop view v1;
drop view v2;
#
-# Bug#18681: View privileges are broken
+# Bug#18681 View privileges are broken
#
CREATE DATABASE mysqltest1;
CREATE USER readonly@localhost;
@@ -723,54 +727,55 @@ GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost;
GRANT DELETE ON mysqltest1.v_td TO readonly@localhost;
GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost;
-CONNECT (n1,localhost,readonly,,);
-CONNECTION n1;
+connect (n1,localhost,readonly,,);
+connection n1;
---error 1356
+--error ER_VIEW_INVALID
SELECT * FROM mysqltest1.v_t1;
---error 1356
+--error ER_VIEW_INVALID
INSERT INTO mysqltest1.v_t1 VALUES(4);
---error 1356
+--error ER_VIEW_INVALID
DELETE FROM mysqltest1.v_t1 WHERE x = 1;
---error 1356
+--error ER_VIEW_INVALID
UPDATE mysqltest1.v_t1 SET x = 3 WHERE x = 2;
---error 1356
+--error ER_VIEW_INVALID
UPDATE mysqltest1.v_t1 SET x = 3;
---error 1356
+--error ER_VIEW_INVALID
DELETE FROM mysqltest1.v_t1;
---error 1356
+--error ER_VIEW_INVALID
SELECT 1 FROM mysqltest1.v_t1;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM mysqltest1.t1;
SELECT * FROM mysqltest1.v_ts;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM mysqltest1.v_ts, mysqltest1.t1 WHERE mysqltest1.t1.x = mysqltest1.v_ts.x;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM mysqltest1.v_ti;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
INSERT INTO mysqltest1.v_ts VALUES (100);
INSERT INTO mysqltest1.v_ti VALUES (100);
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
UPDATE mysqltest1.v_ts SET x= 200 WHERE x = 100;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
UPDATE mysqltest1.v_ts SET x= 200;
UPDATE mysqltest1.v_tu SET x= 200 WHERE x = 100;
UPDATE mysqltest1.v_tus SET x= 200 WHERE x = 100;
UPDATE mysqltest1.v_tu SET x= 200;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
DELETE FROM mysqltest1.v_ts WHERE x= 200;
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
DELETE FROM mysqltest1.v_ts;
---error 1143
+--error ER_COLUMNACCESS_DENIED_ERROR
DELETE FROM mysqltest1.v_td WHERE x= 200;
DELETE FROM mysqltest1.v_tds WHERE x= 200;
DELETE FROM mysqltest1.v_td;
-CONNECTION default;
+connection default;
+disconnect n1;
DROP VIEW mysqltest1.v_tds;
DROP VIEW mysqltest1.v_td;
DROP VIEW mysqltest1.v_tus;
@@ -783,21 +788,21 @@ DROP USER readonly@localhost;
DROP DATABASE mysqltest1;
#
-# BUG#14875: Bad view DEFINER makes SHOW CREATE VIEW fail
+# Bug#14875 Bad view DEFINER makes SHOW CREATE VIEW fail
#
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE DEFINER = 'no-such-user'@localhost VIEW v AS SELECT a from t1;
-#--warning 1448
+#--warning ER_VIEW_OTHER_USER
SHOW CREATE VIEW v;
---error 1449
+--error ER_NO_SUCH_USER
SELECT * FROM v;
DROP VIEW v;
DROP TABLE t1;
USE test;
#
-# Bug#20363: Create view on just created view is now denied
+# Bug#20363 Create view on just created view is now denied
#
eval CREATE USER mysqltest_db1@localhost identified by 'PWD';
eval GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION;
@@ -828,6 +833,7 @@ SELECT * FROM view2;
SELECT * from view3;
connection default;
+disconnect session1;
DROP VIEW mysqltest_db1.view3;
DROP VIEW mysqltest_db1.view2;
DROP VIEW mysqltest_db1.view1;
@@ -835,8 +841,8 @@ DROP TABLE mysqltest_db1.t1;
DROP SCHEMA mysqltest_db1;
DROP USER mysqltest_db1@localhost;
#
-# BUG#20482: failure on Create join view with sources views/tables
-# in different schemas
+# Bug#20482 failure on Create join view with sources views/tables
+# in different schemas
#
--disable_warnings
CREATE DATABASE test1;
@@ -846,7 +852,7 @@ CREATE DATABASE test2;
CREATE TABLE test1.t0 (a VARCHAR(20));
CREATE TABLE test2.t1 (a VARCHAR(20));
CREATE VIEW test2.t3 AS SELECT * FROM test1.t0;
-CREATE OR REPLACE VIEW test.v1 AS
+CREATE OR REPLACE VIEW test.v1 AS
SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb;
DROP VIEW test.v1;
@@ -857,8 +863,8 @@ DROP DATABASE test1;
#
-# BUG#20570: CURRENT_USER() in a VIEW with SQL SECURITY DEFINER
-# returns invoker name
+# Bug#20570 CURRENT_USER() in a VIEW with SQL SECURITY DEFINER returns
+# invoker name
#
--disable_warnings
DROP VIEW IF EXISTS v1;
@@ -917,7 +923,7 @@ DROP USER mysqltest_u1@localhost;
#
-# Bug#17254: Error for DEFINER security on VIEW provides too much info
+# Bug#17254 Error for DEFINER security on VIEW provides too much info
#
connect (root,localhost,root,,);
connection root;
@@ -941,12 +947,12 @@ DROP USER def_17254@localhost;
connect (inv,localhost,inv_17254,,db17254);
connection inv;
--echo for a user
---error 1142
+--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM v1;
connection root;
--echo for a superuser
---error 1449
+--error ER_NO_SUCH_USER
SELECT * FROM v1;
DROP USER inv_17254@localhost;
DROP DATABASE db17254;
@@ -955,7 +961,7 @@ disconnect inv;
#
-# BUG#24404: strange bug with view+permission+prepared statement
+# Bug#24404 strange bug with view+permission+prepared statement
#
--disable_warnings
DROP DATABASE IF EXISTS mysqltest_db1;
@@ -1023,8 +1029,8 @@ DROP USER mysqltest_u1@localhost;
DROP USER mysqltest_u2@localhost;
#
-# Bug#26813: The SUPER privilege is wrongly required to alter a view created
-# by another user.
+# Bug#26813 The SUPER privilege is wrongly required to alter a view created
+# by another user.
#
connection root;
CREATE DATABASE db26813;
@@ -1056,7 +1062,7 @@ DROP DATABASE db26813;
disconnect u1;
--echo #
---echo # Bug#29908: A user can gain additional access through the ALTER VIEW.
+--echo # Bug#29908 A user can gain additional access through the ALTER VIEW.
--echo #
connection root;
CREATE DATABASE mysqltest_29908;
@@ -1101,7 +1107,7 @@ disconnect u2;
--echo #######################################################################
#
-# BUG#24040: Create View don't succed with "all privileges" on a database.
+# Bug#24040 Create View don't succed with "all privileges" on a database.
#
# Prepare.
@@ -1185,12 +1191,52 @@ SELECT * FROM mysqltest1.t4;
# Cleanup.
--- disconnect bug24040_con
+disconnect bug24040_con;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_u1@localhost;
+
+#
+# Bug#41354 Access control is bypassed when all columns of a view are
+# selected by * wildcard
+
+CREATE DATABASE db1;
+USE db1;
+CREATE TABLE t1(f1 INT, f2 INT);
+CREATE VIEW v1 AS SELECT f1, f2 FROM t1;
+
+GRANT SELECT (f1) ON t1 TO foo;
+GRANT SELECT (f1) ON v1 TO foo;
+
+connect (addconfoo, localhost, foo,,);
+connection addconfoo;
+USE db1;
+
+SELECT f1 FROM t1;
+--error ER_COLUMNACCESS_DENIED_ERROR
+SELECT f2 FROM t1;
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT * FROM t1;
+
+SELECT f1 FROM v1;
+--error ER_COLUMNACCESS_DENIED_ERROR
+SELECT f2 FROM v1;
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT * FROM v1;
+
+connection default;
+disconnect root;
+disconnect addconfoo;
+USE test;
+REVOKE SELECT (f1) ON db1.t1 FROM foo;
+REVOKE SELECT (f1) ON db1.v1 FROM foo;
+DROP USER foo;
+DROP VIEW db1.v1;
+DROP TABLE db1.t1;
+DROP DATABASE db1;
+
--echo End of 5.0 tests.
@@ -1218,6 +1264,44 @@ SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP TABLE t1;
+#
+# Bug#37191: Failed assertion in CREATE VIEW
+#
+CREATE USER mysqluser1@localhost;
+CREATE DATABASE mysqltest1;
+
+USE mysqltest1;
+
+CREATE TABLE t1 ( a INT );
+CREATE TABLE t2 ( b INT );
+
+INSERT INTO t1 VALUES (1), (2);
+INSERT INTO t2 VALUES (1), (2);
+
+GRANT CREATE VIEW ON mysqltest1.* TO mysqluser1@localhost;
+
+GRANT SELECT ON t1 TO mysqluser1@localhost;
+GRANT INSERT ON t2 TO mysqluser1@localhost;
+
+--connect (connection1, localhost, mysqluser1, , mysqltest1)
+
+--echo This would lead to failed assertion.
+CREATE VIEW v1 AS SELECT a, b FROM t1, t2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT * FROM v1;
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT b FROM v1;
+
+--disconnect connection1
+--connection default
+
+DROP TABLE t1, t2;
+DROP VIEW v1;
+DROP DATABASE mysqltest1;
+DROP USER mysqluser1@localhost;
+USE test;
+
--echo End of 5.1 tests.
#
@@ -1254,8 +1338,8 @@ DROP DATABASE mysqltest1;
DROP USER mysqluser1@localhost;
#
-# Bug#35600: Security breach via view, I_S table and prepared
-# statement/stored procedure
+# Bug#35600 Security breach via view, I_S table and prepared
+# statement/stored procedure
#
CREATE USER mysqluser1@localhost;
CREATE DATABASE mysqltest1;
@@ -1296,3 +1380,8 @@ DROP VIEW v1, v2;
DROP DATABASE mysqltest1;
DROP VIEW test.v3;
DROP USER mysqluser1@localhost;
+USE test;
+
+# Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test
index 63809252a01..6947e346675 100644
--- a/mysql-test/t/wait_timeout.test
+++ b/mysql-test/t/wait_timeout.test
@@ -10,8 +10,11 @@
-- source include/not_embedded.inc
-- source include/one_thread_per_connection.inc
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
#
-# Bug#8731: wait_timeout does not work on Mac OS X
+# Bug#8731 wait_timeout does not work on Mac OS X
#
let $start_value= `SELECT @@global.wait_timeout`;
@@ -113,6 +116,7 @@ while (!`select @aborted_clients`)
# the disconnect has reached client
let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist;
--source include/wait_condition.inc
+disconnect wait_con;
--echo connection con1;
connection con1;
@@ -126,8 +130,13 @@ SELECT 2;
SELECT 3;
--replace_result $start_value <start_value>
eval SET @@global.wait_timeout= $start_value;
-# ML: The start value might be changed in future ...
--echo disconnection con1;
disconnect con1;
+# The last connect is to keep tools checking the current test happy.
+connect (default,localhost,root,,test,,);
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test
index 6871caaa756..89cd2ed19e8 100755
--- a/mysql-test/t/windows.test
+++ b/mysql-test/t/windows.test
@@ -35,6 +35,37 @@ CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,1);
EXPLAIN SELECT * FROM t1 WHERE b = (SELECT max(2));
DROP TABLE t1;
+#
+# Bug #33813: Schema names are case-sensitive in DROP FUNCTION
+#
+
+CREATE DATABASE `TESTDB`;
+
+USE `TESTDB`;
+DELIMITER //;
+
+CREATE FUNCTION test_fn() RETURNS INTEGER
+BEGIN
+DECLARE rId bigint;
+RETURN rId;
+END
+//
+
+CREATE FUNCTION test_fn2() RETURNS INTEGER
+BEGIN
+DECLARE rId bigint;
+RETURN rId;
+END
+//
+
+DELIMITER ;//
+
+DROP FUNCTION `TESTDB`.`test_fn`;
+DROP FUNCTION `testdb`.`test_fn2`;
+
+USE test;
+DROP DATABASE `TESTDB`;
+
--echo End of 5.0 tests.
--disable_warnings
diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test
index 591d7ac2c4d..04ecf518577 100644
--- a/mysql-test/t/xa.test
+++ b/mysql-test/t/xa.test
@@ -2,6 +2,10 @@
# WL#1756
#
-- source include/have_innodb.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
@@ -14,10 +18,10 @@ xa rollback 'test1';
select * from t1;
xa start 'test2';
---error 1399
+--error ER_XAER_RMFAIL
xa start 'test-bad';
insert t1 values (20);
---error 1399
+--error ER_XAER_RMFAIL
xa prepare 'test2';
xa end 'test2';
xa prepare 'test2';
@@ -27,22 +31,22 @@ select * from t1;
xa start 'testa','testb';
insert t1 values (30);
---error 1399
+--error ER_XAER_RMFAIL
commit;
xa end 'testa','testb';
---error 1399
+--error ER_XAER_RMFAIL
begin;
---error 1399
+--error ER_XAER_RMFAIL
create table t2 (a int);
connect (con1,localhost,root,,);
connection con1;
---error 1440
+--error ER_XAER_DUPID
xa start 'testa','testb';
---error 1440
+--error ER_XAER_DUPID
xa start 'testa','testb', 123;
# gtrid [ , bqual [ , formatID ] ]
@@ -51,7 +55,7 @@ insert t1 values (40);
xa end 'testb',' 0@P`',11;
xa prepare 'testb',0x2030405060,11;
---error 1399
+--error ER_XAER_RMFAIL
start transaction;
xa recover;
@@ -64,11 +68,11 @@ xa prepare 'testa','testb';
xa recover;
---error 1397
+--error ER_XAER_NOTA
xa commit 'testb',0x2030405060,11;
xa rollback 'testa','testb';
---error 1064
+--error ER_PARSE_ERROR
xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
select * from t1;
@@ -119,3 +123,7 @@ xa start 'a','c';
drop table t1;
--echo End of 5.0 tests
+
+# 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 74bce8dc962..6e7d38cdfca 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -590,4 +590,31 @@ select extractvalue('<a></a>','"b"/a');
--error ER_UNKNOWN_ERROR
select extractvalue('<a></a>','(1)/a');
+#
+# Bug#43183 ExctractValue() brings result list in missorder
+#
+CREATE TABLE IF NOT EXISTS t1 (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ xml text,
+ PRIMARY KEY (id)
+) ENGINE=MyISAM;
+
+INSERT INTO t1 (id, xml) VALUES
+(15, '<?xml version="1.0"?><bla name="blubb"></bla>'),
+(14, '<xml version="kaputt">');
+
+
+SELECT
+extractvalue( xml, '/bla/@name' ),
+extractvalue( xml, '/bla/@name' )
+FROM t1 ORDER BY t1.id;
+
+
+SELECT
+UpdateXML(xml, '/bla/@name', 'test'),
+UpdateXML(xml, '/bla/@name', 'test')
+FROM t1 ORDER BY t1.id;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/mysys/array.c b/mysys/array.c
index f11a327232c..92940717c90 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -371,7 +371,7 @@ void freeze_size(DYNAMIC_ARRAY *array)
int get_index_dynamic(DYNAMIC_ARRAY *array, uchar* element)
{
- uint ret;
+ size_t ret;
if (array->buffer > element)
return -1;
diff --git a/mysys/base64.c b/mysys/base64.c
index 6157dcaa5af..ab66715c929 100644
--- a/mysys/base64.c
+++ b/mysys/base64.c
@@ -223,7 +223,7 @@ base64_decode(const char *src_base, size_t len,
The variable 'i' is set to 'len' when padding has been read, so it
does not actually reflect the number of bytes read from 'src'.
*/
- return i != len ? -1 : d - dst_base;
+ return i != len ? -1 : (int) (d - dst_base);
}
diff --git a/mysys/charset.c b/mysys/charset.c
index 8f47b4027ef..7a7ef0ad3ea 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -328,7 +328,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
{
uchar *buf;
int fd;
- uint len, tmp_len;
+ size_t len, tmp_len;
MY_STAT stat_info;
if (!my_stat(filename, &stat_info, MYF(myflags)) ||
@@ -494,29 +494,40 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
{
char buf[FN_REFLEN];
CHARSET_INFO *cs;
- /*
- To make things thread safe we are not allowing other threads to interfere
- while we may changing the cs_info_table
- */
- pthread_mutex_lock(&THR_LOCK_charset);
+
if ((cs= all_charsets[cs_number]))
{
- if (!(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED))
+ if (cs->state & MY_CS_READY) /* if CS is already initialized */
+ return cs;
+
+ /*
+ To make things thread safe we are not allowing other threads to interfere
+ while we may changing the cs_info_table
+ */
+ pthread_mutex_lock(&THR_LOCK_charset);
+
+ if (!(cs->state & (MY_CS_COMPILED|MY_CS_LOADED))) /* if CS is not in memory */
{
strxmov(get_charsets_dir(buf), cs->csname, ".xml", NullS);
my_read_charset_file(buf,flags);
}
- cs= (cs->state & MY_CS_AVAILABLE) ? cs : NULL;
- }
- if (cs && !(cs->state & MY_CS_READY))
- {
- if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) ||
- (cs->coll->init && cs->coll->init(cs, cs_alloc)))
- cs= NULL;
+
+ if (cs->state & MY_CS_AVAILABLE)
+ {
+ if (!(cs->state & MY_CS_READY))
+ {
+ if ((cs->cset->init && cs->cset->init(cs, cs_alloc)) ||
+ (cs->coll->init && cs->coll->init(cs, cs_alloc)))
+ cs= NULL;
+ else
+ cs->state|= MY_CS_READY;
+ }
+ }
else
- cs->state|= MY_CS_READY;
+ cs= NULL;
+
+ pthread_mutex_unlock(&THR_LOCK_charset);
}
- pthread_mutex_unlock(&THR_LOCK_charset);
return cs;
}
diff --git a/mysys/checksum.c b/mysys/checksum.c
index 4f86f6845f0..1c7c9358d53 100644
--- a/mysys/checksum.c
+++ b/mysys/checksum.c
@@ -36,7 +36,7 @@ ha_checksum my_checksum(ha_checksum crc, const uchar *pos, size_t length)
crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8));
return crc;
#else
- return (ha_checksum)crc32((uint)crc, pos, length);
+ return (ha_checksum)crc32((uint)crc, pos, (uint)length);
#endif
}
diff --git a/mysys/default.c b/mysys/default.c
index 6b2b31d43ec..1c021b4584f 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -144,6 +144,7 @@ static char *remove_end_comment(char *ptr);
RETURN
0 ok
1 given cinf_file doesn't exist
+ 2 out of memory
The global variable 'my_defaults_group_suffix' is updated with value for
--defaults_group_suffix
@@ -151,7 +152,7 @@ static char *remove_end_comment(char *ptr);
int my_search_option_files(const char *conf_file, int *argc, char ***argv,
uint *args_used, Process_option_func func,
- void *func_ctx)
+ void *func_ctx, const char **default_directories)
{
const char **dirs, *forced_default_file, *forced_extra_defaults;
int error= 0;
@@ -182,7 +183,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
/* Handle --defaults-group-suffix= */
uint i;
const char **extra_groups;
- const uint instance_len= strlen(my_defaults_group_suffix);
+ const size_t instance_len= strlen(my_defaults_group_suffix);
struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx;
char *ptr;
TYPELIB *group= ctx->group;
@@ -190,16 +191,16 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
if (!(extra_groups=
(const char**)alloc_root(ctx->alloc,
(2*group->count+1)*sizeof(char*))))
- goto err;
+ DBUG_RETURN(2);
for (i= 0; i < group->count; i++)
{
- uint len;
+ size_t len;
extra_groups[i]= group->type_names[i]; /** copy group */
len= strlen(extra_groups[i]);
- if (!(ptr= alloc_root(ctx->alloc, len+instance_len+1)))
- goto err;
+ if (!(ptr= alloc_root(ctx->alloc, (uint) (len+instance_len+1))))
+ DBUG_RETURN(2);
extra_groups[i+group->count]= ptr;
@@ -254,12 +255,11 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
}
}
- DBUG_RETURN(error);
+ DBUG_RETURN(0);
err:
fprintf(stderr,"Fatal error in defaults handling. Program aborted\n");
- exit(1);
- return 0; /* Keep compiler happy */
+ DBUG_RETURN(1);
}
@@ -359,18 +359,46 @@ int get_defaults_options(int argc, char **argv,
return org_argc - argc;
}
+/*
+ Wrapper around my_load_defaults() for interface compatibility.
+
+ SYNOPSIS
+ load_defaults()
+ conf_file Basename for configuration file to search for.
+ If this is a path, then only this file is read.
+ groups Which [group] entrys to read.
+ Points to an null terminated array of pointers
+ argc Pointer to argc of original program
+ argv Pointer to argv of original program
+
+ NOTES
+
+ This function is NOT thread-safe as it uses a global pointer internally.
+ See also notes for my_load_defaults().
+
+ RETURN
+ 0 ok
+ 1 The given conf_file didn't exists
+*/
+int load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv)
+{
+ return my_load_defaults(conf_file, groups, argc, argv, &default_directories);
+}
/*
Read options from configurations files
SYNOPSIS
- load_defaults()
+ my_load_defaults()
conf_file Basename for configuration file to search for.
If this is a path, then only this file is read.
groups Which [group] entrys to read.
Points to an null terminated array of pointers
argc Pointer to argc of original program
argv Pointer to argv of original program
+ default_directories Pointer to a location where a pointer to the list
+ of default directories will be stored
IMPLEMENTATION
@@ -386,13 +414,18 @@ int get_defaults_options(int argc, char **argv,
that was put in *argv
RETURN
- 0 ok
- 1 The given conf_file didn't exists
+ - If successful, 0 is returned. If 'default_directories' is not NULL,
+ a pointer to the array of default directory paths is stored to a location
+ it points to. That stored value must be passed to my_search_option_files()
+ later.
+
+ - 1 is returned if the given conf_file didn't exist. In this case, the
+ value pointed to by default_directories is undefined.
*/
-int load_defaults(const char *conf_file, const char **groups,
- int *argc, char ***argv)
+int my_load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv, const char ***default_directories)
{
DYNAMIC_ARRAY args;
TYPELIB group;
@@ -402,10 +435,11 @@ int load_defaults(const char *conf_file, const char **groups,
MEM_ROOT alloc;
char *ptr,**res;
struct handle_option_ctx ctx;
+ const char **dirs;
DBUG_ENTER("load_defaults");
init_alloc_root(&alloc,512,0);
- if ((default_directories= init_default_directories(&alloc)) == NULL)
+ if ((dirs= init_default_directories(&alloc)) == NULL)
goto err;
/*
Check if the user doesn't want any default option processing
@@ -426,6 +460,8 @@ int load_defaults(const char *conf_file, const char **groups,
(*argc)--;
*argv=res;
*(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
+ if (default_directories)
+ *default_directories= dirs;
DBUG_RETURN(0);
}
@@ -444,7 +480,8 @@ int load_defaults(const char *conf_file, const char **groups,
ctx.group= &group;
error= my_search_option_files(conf_file, argc, argv, &args_used,
- handle_default_option, (void *) &ctx);
+ handle_default_option, (void *) &ctx,
+ dirs);
/*
Here error contains <> 0 only if we have a fully specified conf_file
or a forced default file
@@ -490,6 +527,10 @@ int load_defaults(const char *conf_file, const char **groups,
puts("");
exit(0);
}
+
+ if (error == 0 && default_directories)
+ *default_directories= dirs;
+
DBUG_RETURN(error);
err:
@@ -895,15 +936,11 @@ void my_print_default_files(const char *conf_file)
fputs(conf_file,stdout);
else
{
- /*
- If default_directories is already initialized, use it. Otherwise,
- use a private MEM_ROOT.
- */
- const char **dirs = default_directories;
+ const char **dirs;
MEM_ROOT alloc;
init_alloc_root(&alloc,512,0);
- if (!dirs && (dirs= init_default_directories(&alloc)) == NULL)
+ if ((dirs= init_default_directories(&alloc)) == NULL)
{
fputs("Internal error initializing default directories list", stdout);
}
@@ -970,7 +1007,7 @@ void print_defaults(const char *conf_file, const char **groups)
static int add_directory(MEM_ROOT *alloc, const char *dir, const char **dirs)
{
char buf[FN_REFLEN];
- uint len;
+ size_t len;
char *p;
my_bool err __attribute__((unused));
@@ -1004,14 +1041,14 @@ static size_t my_get_system_windows_directory(char *buffer, size_t size)
"GetSystemWindowsDirectoryA");
if (func_ptr)
- return func_ptr(buffer, size);
+ return func_ptr(buffer, (uint) size);
/*
Windows NT 4.0 Terminal Server Edition:
To retrieve the shared Windows directory, call GetSystemDirectory and
trim the "System32" element from the end of the returned path.
*/
- count= GetSystemDirectory(buffer, size);
+ count= GetSystemDirectory(buffer, (uint) size);
if (count > 8 && stricmp(buffer+(count-8), "\\System32") == 0)
{
count-= 8;
@@ -1090,7 +1127,7 @@ static const char **init_default_directories(MEM_ROOT *alloc)
errors += add_directory(alloc, "/etc/mysql/", dirs);
#if defined(DEFAULT_SYSCONFDIR)
- if (DEFAULT_SYSCONFDIR != "")
+ if (DEFAULT_SYSCONFDIR[0])
errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
#endif /* DEFAULT_SYSCONFDIR */
diff --git a/mysys/default_modify.c b/mysys/default_modify.c
index 78f6105b071..88df0122da2 100644
--- a/mysys/default_modify.c
+++ b/mysys/default_modify.c
@@ -68,11 +68,9 @@ int modify_defaults_file(const char *file_location, const char *option,
FILE *cnf_file;
MY_STAT file_stat;
char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
- size_t opt_len= 0, optval_len= 0, sect_len;
+ size_t opt_len= 0, optval_len= 0, sect_len, new_opt_len, reserve_extended;
uint nr_newlines= 0, buffer_size;
my_bool in_section= FALSE, opt_applied= 0;
- uint reserve_extended;
- uint new_opt_len;
int reserve_occupied= 0;
DBUG_ENTER("modify_defaults_file");
diff --git a/mysys/errors.c b/mysys/errors.c
index 537a75c6ef3..8d3303cac9f 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -39,7 +39,7 @@ const char * NEAR globerrs[GLOBERRS]=
"Can't change dir to '%s' (Errcode: %d)",
"Warning: '%s' had %d links",
"Warning: %d files and %d streams is left open\n",
- "Disk is full writing '%s' (Errcode: %d). Waiting for someone to free space... Retry in %d secs",
+ "Disk is full writing '%s' (Errcode: %d). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
"Can't create directory '%s' (Errcode: %d)",
"Character set '%s' is not a compiled character set and is not specified in the '%s' file",
"Out of resources when opening file '%s' (Errcode: %d)",
@@ -92,3 +92,17 @@ void init_glob_errs()
EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed";
}
#endif
+
+void wait_for_free_space(const char *filename, int errors)
+{
+ if (errors == 0)
+ my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
+ filename,my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
+ if (!(errors % MY_WAIT_GIVE_USER_A_MESSAGE))
+ my_printf_error(EE_DISK_FULL,
+ "Retry in %d secs. Message reprinted in %d secs",
+ MYF(ME_BELL | ME_NOREFRESH),
+ MY_WAIT_FOR_USER_TO_FIX_PANIC,
+ MY_WAIT_GIVE_USER_A_MESSAGE * MY_WAIT_FOR_USER_TO_FIX_PANIC );
+ VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
+}
diff --git a/mysys/hash.c b/mysys/hash.c
index dd2d589e509..e7b5352af34 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -33,7 +33,7 @@ typedef struct st_hash_info {
uchar *data; /* data for current entry */
} HASH_LINK;
-static uint my_hash_mask(uint hashnr, uint buffmax, uint maxlength);
+static uint my_hash_mask(size_t hashnr, size_t buffmax, size_t maxlength);
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
size_t length);
@@ -157,14 +157,14 @@ my_hash_key(const HASH *hash, const uchar *record, size_t *length,
/* Calculate pos according to keys */
-static uint my_hash_mask(uint hashnr, uint buffmax, uint maxlength)
+static uint my_hash_mask(size_t hashnr, size_t buffmax, size_t maxlength)
{
if ((hashnr & (buffmax-1)) < maxlength) return (hashnr & (buffmax-1));
return (hashnr & ((buffmax >> 1) -1));
}
static uint my_hash_rec_mask(const HASH *hash, HASH_LINK *pos,
- uint buffmax, uint maxlength)
+ size_t buffmax, size_t maxlength)
{
size_t length;
uchar *key= (uchar*) my_hash_key(hash, pos->data, &length, 0);
@@ -309,8 +309,7 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
my_bool my_hash_insert(HASH *info, const uchar *record)
{
int flag;
- size_t idx;
- uint halfbuff,hash_nr,first_index;
+ size_t idx,halfbuff,hash_nr,first_index;
uchar *ptr_to_rec,*ptr_to_rec2;
HASH_LINK *data,*empty,*gpos,*gpos2,*pos;
@@ -539,8 +538,8 @@ exit:
my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
size_t old_key_length)
{
- uint new_index,new_pos_index,blength,records,empty;
- size_t idx;
+ uint new_index,new_pos_index,blength,records;
+ size_t idx,empty;
HASH_LINK org_link,*data,*previous,*pos;
DBUG_ENTER("my_hash_update");
diff --git a/mysys/md5.c b/mysys/md5.c
index 0945f9ce5f4..2388cebedc4 100644
--- a/mysys/md5.c
+++ b/mysys/md5.c
@@ -13,356 +13,313 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
*/
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
-*/
-
-/*
- Changes by Monty:
- Replace of MD5_memset and MD5_memcpy with memset & memcpy
-*/
+/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to
+ not require an integer type which is exactly 32 bits. This work
+ draws on the changes for the same purpose by Tatu Ylonen
+ <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use
+ that code, there is no copyright issue. I hereby disclaim
+ copyright in any changes I have made; this code remains in the
+ public domain. */
#include <my_global.h>
#include <m_string.h>
#include "my_md5.h"
-/* Constants for MD5Transform routine. */
-
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
-
-static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
-static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
-static void Decode PROTO_LIST
- ((UINT4 *, unsigned char *, unsigned int));
-#ifdef OLD_CODE
-static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
-static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
-#else
-#define MD5_memcpy(A,B,C) memcpy((char*) (A),(char*) (B), (C))
-#define MD5_memset(A,B,C) memset((char*) (A),(B), (C))
-#endif
+#include <string.h> /* for memcpy() and memset() */
-static unsigned char PADDING[64] = {
- 0x80, 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
-};
-/* F, G, H and I are basic MD5 functions.
- */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
+static void
+my_MD5Transform (cvs_uint32 buf[4], const unsigned char in[64]);
-/* ROTATE_LEFT rotates x left n bits.
- */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+/* Little-endian byte-swapping routines. Note that these do not
+ depend on the size of datatypes such as uint32, nor do they require
+ us to detect the endianness of the machine we are running on. It
+ is possible they should be macros for speed, but I would be
+ surprised if they were a performance bottleneck for MD5. */
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
-Rotation is separate from addition to prevent recomputation.
- */
-#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-/* MD5 initialization. Begins an MD5 operation, writing a new context.
- */
-void my_MD5Init (my_MD5_CTX *context) /* context */
+static uint32 getu32 (const unsigned char *addr)
{
- context->count[0] = context->count[1] = 0;
- /* Load magic initialization constants.
-*/
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
+ return (((((unsigned long)addr[3] << 8) | addr[2]) << 8)
+ | addr[1]) << 8 | addr[0];
}
-/* MD5 block update operation. Continues an MD5 message-digest
- operation, processing another message block, and updating the
- context.
- */
-
-void my_MD5Update (
-my_MD5_CTX *context, /* context */
-unsigned char *input, /* input block */
-unsigned int inputLen) /* length of input block */
+static void
+putu32 (uint32 data, unsigned char *addr)
{
- unsigned int i, idx, partLen;
-
- /* Compute number of bytes mod 64 */
- idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
-
+ addr[0] = (unsigned char)data;
+ addr[1] = (unsigned char)(data >> 8);
+ addr[2] = (unsigned char)(data >> 16);
+ addr[3] = (unsigned char)(data >> 24);
+}
- /* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((UINT4)inputLen >> 29);
+/*
+ Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
+ initialization constants.
+*/
+void
+my_MD5Init (my_MD5Context *ctx)
+{
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
- partLen = 64 - idx;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
+}
- /* Transform as many times as possible.
+/*
+ Update context to reflect the concatenation of another buffer full
+ of bytes.
*/
- if (inputLen >= partLen) {
- MD5_memcpy((POINTER)&context->buffer[idx], (POINTER)input, partLen);
- MD5Transform(context->state, context->buffer);
+void
+my_MD5Update (my_MD5Context *ctx, unsigned char const *buf, unsigned len)
+{
+ uint32 t;
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform (context->state, &input[i]);
+ /* Update bitcount */
- idx = 0;
- }
- else
- i = 0;
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = (t + ((uint32)len << 3)) & 0xffffffff) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
- /* Buffer remaining input */
- MD5_memcpy((POINTER)&context->buffer[idx], (POINTER)&input[i],
- inputLen-i);
-}
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-/* MD5 finalization. Ends an MD5 message-digest operation, writing the
- the message digest and zeroizing the context.
- */
+ /* Handle any leading odd-sized chunks */
-void my_MD5Final (
-unsigned char digest[16], /* message digest */
-my_MD5_CTX *context) /* context */
-{
- unsigned char bits[8];
- unsigned int idx, padLen;
+ if ( t ) {
+ unsigned char *p = ctx->in + t;
- /* Save number of bits */
- Encode (bits, context->count, 8);
+ t = 64-t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ my_MD5Transform (ctx->buf, ctx->in);
+ buf += t;
+ len -= t;
+ }
- /* Pad out to 56 mod 64.
-*/
- idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (idx < 56) ? (56 - idx) : (120 - idx);
- my_MD5Update (context, PADDING, padLen);
+ /* Process data in 64-byte chunks */
- /* Append length (before padding) */
- my_MD5Update (context, bits, 8);
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ my_MD5Transform (ctx->buf, ctx->in);
+ buf += 64;
+ len -= 64;
+ }
- /* Store state in digest */
- Encode (digest, context->state, 16);
+ /* Handle any remaining bytes of data. */
- /* Zeroize sensitive information.
-*/
- MD5_memset ((POINTER)context, 0, sizeof (*context));
+ memcpy(ctx->in, buf, len);
}
-/* MD5 basic transformation. Transforms state based on block.
- */
-static void MD5Transform (
-UINT4 state[4],
-unsigned char block[64])
-{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode (x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information.
+/*
+ Final wrapup - pad to 64-byte boundary with the bit pattern
+ 1 0* (64-bit count of bits processed, MSB-first)
*/
- MD5_memset ((POINTER)x, 0, sizeof (x));
-}
-
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
- a multiple of 4.
- */
-static void Encode (
-unsigned char *output,
-UINT4 *input,
-unsigned int len)
+void
+my_MD5Final (unsigned char digest[16], my_MD5Context *ctx)
{
- unsigned int i, j;
+ unsigned count;
+ unsigned char *p;
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char)(input[i] & 0xff);
- output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ my_MD5Transform (ctx->buf, ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count-8);
}
+
+ /* Append length in bits and transform */
+ putu32(ctx->bits[0], ctx->in + 56);
+ putu32(ctx->bits[1], ctx->in + 60);
+
+ my_MD5Transform (ctx->buf, ctx->in);
+ putu32(ctx->buf[0], digest);
+ putu32(ctx->buf[1], digest + 4);
+ putu32(ctx->buf[2], digest + 8);
+ putu32(ctx->buf[3], digest + 12);
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
+#ifndef ASM_MD5
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
- a multiple of 4.
- */
-static void Decode (
-UINT4 *output,
-unsigned char *input,
-unsigned int len)
-{
- unsigned int i, j;
+/* The four core functions - F1 is optimized somewhat */
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
- (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
-}
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
-/* Note: Replace "for loop" with standard memcpy if possible.
- */
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+ ( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
-#ifndef MD5_memcpy
-static void MD5_memcpy (output, input, len)
-POINTER output;
-POINTER input;
-unsigned int len;
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data. MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+static void
+my_MD5Transform (uint32 buf[4], const unsigned char inraw[64])
{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- output[i] = input[i];
+ register uint32 a, b, c, d;
+ uint32 in[16];
+ int i;
+
+ for (i = 0; i < 16; ++i)
+ in[i] = getu32 (inraw + 4 * i);
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
#endif
-/* Note: Replace "for loop" with standard memset if possible.
- */
+#ifdef TEST
+/*
+ Simple test program. Can use it to manually run the tests from
+ RFC1321 for example.
+*/
+#include <stdio.h>
-#ifndef MD5_memset
-static void MD5_memset (output, value, len)
-POINTER output;
-int value;
-unsigned int len;
+int
+main (int argc, char **argv)
{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- ((char *)output)[i] = (char)value;
+ my_MD5Context context;
+ unsigned char checksum[16];
+ int i;
+ int j;
+
+ if (argc < 2)
+ {
+ fprintf (stderr, "usage: %s string-to-hash\n", argv[0]);
+ exit (1);
+ }
+ for (j = 1; j < argc; ++j)
+ {
+ printf ("MD5 (\"%s\") = ", argv[j]);
+ my_MD5Init (&context);
+ my_MD5Update (&context, argv[j], strlen (argv[j]));
+ my_MD5Final (checksum, &context);
+ for (i = 0; i < 16; i++)
+ {
+ printf ("%02x", (unsigned int) checksum[i]);
+ }
+ printf ("\n");
+ }
+ return 0;
}
-#endif
+#endif /* TEST */
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 5274509a1d5..a635f796f46 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -2045,13 +2045,15 @@ restart:
}
else
{
+ size_t block_mem_offset;
/* There are some never used blocks, take first of them */
DBUG_ASSERT(keycache->blocks_used <
(ulong) keycache->disk_blocks);
block= &keycache->block_root[keycache->blocks_used];
+ block_mem_offset=
+ ((size_t) keycache->blocks_used) * keycache->key_cache_block_size;
block->buffer= ADD_TO_PTR(keycache->block_mem,
- ((ulong) keycache->blocks_used*
- keycache->key_cache_block_size),
+ block_mem_offset,
uchar*);
keycache->blocks_used++;
DBUG_ASSERT(!block->next_used);
@@ -2405,7 +2407,7 @@ static void read_block(KEY_CACHE *keycache,
BLOCK_LINK *block, uint read_length,
uint min_length, my_bool primary)
{
- uint got_length;
+ size_t got_length;
/* On entry cache_lock is locked */
diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c
index d6492c90965..f41bbab946f 100644
--- a/mysys/mf_tempdir.c
+++ b/mysys/mf_tempdir.c
@@ -47,7 +47,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
}
do
{
- uint length;
+ size_t length;
end=strcend(pathlist, DELIM);
strmake(buff, pathlist, (uint) (end-pathlist));
length= cleanup_dirname(buff, buff);
diff --git a/mysys/my_append.c b/mysys/my_append.c
index 35881a959d5..d8789f95d95 100644
--- a/mysys/my_append.c
+++ b/mysys/my_append.c
@@ -36,7 +36,7 @@ struct utimbuf {
int my_append(const char *from, const char *to, myf MyFlags)
{
- uint Count;
+ size_t Count;
File from_file,to_file;
uchar buff[IO_SIZE];
DBUG_ENTER("my_append");
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index 0d076e77c35..a3d9d56915e 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -67,7 +67,7 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen)
if (!(compbuf= (uchar *) my_malloc(*complen, MYF(MY_WME))))
return 0; /* Not enough memory */
- tmp_complen= *complen;
+ tmp_complen= (uint) *complen;
res= compress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, (uLong) *len);
*complen= tmp_complen;
@@ -118,7 +118,7 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen)
if (!compbuf)
DBUG_RETURN(1); /* Not enough memory */
- tmp_complen= *complen;
+ tmp_complen= (uint) *complen;
error= uncompress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet,
(uLong) len);
*complen= tmp_complen;
diff --git a/mysys/my_conio.c b/mysys/my_conio.c
index b78966446ee..5dbd31193a9 100644
--- a/mysys/my_conio.c
+++ b/mysys/my_conio.c
@@ -172,7 +172,7 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen)
do
{
clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, &plen_res,
+ if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
NULL))
{
result= NULL;
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index cd741b1eb52..5679d13d39d 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -50,7 +50,7 @@ struct utimbuf {
int my_copy(const char *from, const char *to, myf MyFlags)
{
- uint Count;
+ size_t Count;
my_bool new_file_stat= 0; /* 1 if we could stat "to" */
int create_flag;
File from_file,to_file;
diff --git a/mysys/my_error.c b/mysys/my_error.c
index 07656dda979..2cf704d0089 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -252,11 +252,16 @@ const char **my_error_unregister(int first, int last)
void my_error_unregister_all(void)
{
- struct my_err_head *list, *next;
- for (list= my_errmsgs_globerrs.meh_next; list; list= next)
+ struct my_err_head *cursor, *saved_next;
+
+ for (cursor= my_errmsgs_globerrs.meh_next; cursor != NULL; cursor= saved_next)
{
- next= list->meh_next;
- my_free((uchar*) list, MYF(0));
+ /* We need this ptr, but we're about to free its container, so save it. */
+ saved_next= cursor->meh_next;
+
+ my_free((uchar*) cursor, MYF(0));
}
+ my_errmsgs_globerrs.meh_next= NULL; /* Freed in first iteration above. */
+
my_errmsgs_list= &my_errmsgs_globerrs;
}
diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c
index f5fe862937c..f3b5418b906 100644
--- a/mysys/my_fstream.c
+++ b/mysys/my_fstream.c
@@ -131,10 +131,8 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
if ((errno == ENOSPC || errno == EDQUOT) &&
(MyFlags & MY_WAIT_IF_FULL))
{
- if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
- my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
- "[stream]",my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
- VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
+ wait_for_free_space("[stream]", errors);
+ errors++;
VOID(my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0)));
continue;
}
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index f97550d4429..4b74cdbf266 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -100,10 +100,10 @@ static void default_reporter(enum loglevel level,
one. Call function 'get_one_option()' once for each option.
*/
-static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *);
+static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *, int *);
void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint,
- const struct my_option *))
+ const struct my_option *, int *))
{
getopt_get_addr= func_addr;
}
@@ -362,8 +362,12 @@ int handle_options(int *argc, char ***argv,
my_progname, optp->name);
return EXIT_NO_ARGUMENT_ALLOWED;
}
+ error= 0;
value= optp->var_type & GET_ASK_ADDR ?
- (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp) : optp->value;
+ (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp, &error) :
+ optp->value;
+ if (error)
+ return error;
if (optp->arg_type == NO_ARG)
{
@@ -842,7 +846,8 @@ longlong getopt_ll_limit_value(longlong num, const struct my_option *optp,
if (num < optp->min_value)
{
num= optp->min_value;
- adjusted= TRUE;
+ if (old < optp->min_value)
+ adjusted= TRUE;
}
if (fix)
@@ -913,7 +918,8 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
if (num < (ulonglong) optp->min_value)
{
num= (ulonglong) optp->min_value;
- adjusted= TRUE;
+ if (old < (ulonglong) optp->min_value)
+ adjusted= TRUE;
}
if (fix)
@@ -1092,7 +1098,7 @@ static void init_variables(const struct my_option *options,
if (options->value)
init_one_value(options, options->value, options->def_value);
if (options->var_type & GET_ASK_ADDR &&
- (variable= (*getopt_get_addr)("", 0, options)))
+ (variable= (*getopt_get_addr)("", 0, options, 0)))
init_one_value(options, variable, options->def_value);
}
DBUG_VOID_RETURN;
@@ -1196,7 +1202,7 @@ void my_print_variables(const struct my_option *options)
for (optp= options; optp->id; optp++)
{
uchar* *value= (optp->var_type & GET_ASK_ADDR ?
- (*getopt_get_addr)("", 0, optp) : optp->value);
+ (*getopt_get_addr)("", 0, optp, 0) : optp->value);
if (value)
{
printf("%s ", optp->name);
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index cbfebcf2374..e0c5b94b53e 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -55,7 +55,7 @@ int my_getwd(char * buf, size_t size, myf MyFlags)
else
{
#if defined(HAVE_GETCWD)
- if (!getcwd(buf,size-2) && MyFlags & MY_WME)
+ if (!getcwd(buf,(uint) (size-2)) && MyFlags & MY_WME)
{
my_errno=errno;
my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno);
diff --git a/mysys/my_init.c b/mysys/my_init.c
index b330ffac65a..a60927be693 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -136,6 +136,10 @@ void my_end(int infoflag)
*/
FILE *info_file= DBUG_FILE;
my_bool print_info= (info_file != stderr);
+
+ if (!my_init_done)
+ return;
+
/*
We do not use DBUG_ENTER here, as after cleanup DBUG is no longer
operational, so we cannot use DBUG_RETURN.
diff --git a/mysys/my_new.cc b/mysys/my_new.cc
index babfe04d695..7da54ffac87 100644
--- a/mysys/my_new.cc
+++ b/mysys/my_new.cc
@@ -46,8 +46,9 @@ void operator delete[] (void *ptr) throw ()
C_MODE_START
-int __cxa_pure_virtual() {
- assert("Pure virtual method called." == "Aborted");
+int __cxa_pure_virtual()
+{
+ assert(! "Aborted: pure virtual method called.");
return 0;
}
diff --git a/mysys/my_pread.c b/mysys/my_pread.c
index de7a2b611ed..3f62f150c91 100644
--- a/mysys/my_pread.c
+++ b/mysys/my_pread.c
@@ -59,7 +59,7 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
pthread_mutex_lock(&my_file_info[Filedes].mutex);
readbytes= (uint) -1;
error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
- (readbytes= read(Filedes, Buffer, Count)) != Count);
+ (readbytes= read(Filedes, Buffer, (uint) Count)) != Count);
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
#else
if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count)))
@@ -136,7 +136,7 @@ size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count,
writenbytes= (size_t) -1;
pthread_mutex_lock(&my_file_info[Filedes].mutex);
error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 &&
- (writenbytes = write(Filedes, Buffer, Count)) == Count);
+ (writenbytes = write(Filedes, Buffer, (uint) Count)) == Count);
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
if (error)
break;
@@ -161,10 +161,8 @@ size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count,
if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
(MyFlags & MY_WAIT_IF_FULL))
{
- if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
- my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
- my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
- VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
+ wait_for_free_space(my_filename(Filedes), errors);
+ errors++;
continue;
}
if ((writenbytes && writenbytes != (size_t) -1) || my_errno == EINTR)
diff --git a/mysys/my_quick.c b/mysys/my_quick.c
index c19fe08572d..0ba20a5bdee 100644
--- a/mysys/my_quick.c
+++ b/mysys/my_quick.c
@@ -23,7 +23,7 @@ size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags)
{
size_t readbytes;
- if ((readbytes = read(Filedes, Buffer, Count)) != Count)
+ if ((readbytes = read(Filedes, Buffer, (uint) Count)) != Count)
{
#ifndef DBUG_OFF
if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
@@ -50,7 +50,7 @@ size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count)
#ifndef DBUG_OFF
writtenbytes =
#endif
- (size_t) write(Filedes,Buffer,Count)) != Count)
+ (size_t) write(Filedes,Buffer, (uint) Count)) != Count)
{
#ifndef DBUG_OFF
if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR)
diff --git a/mysys/my_read.c b/mysys/my_read.c
index f3e8a4b300e..0c302d5b227 100644
--- a/mysys/my_read.c
+++ b/mysys/my_read.c
@@ -44,7 +44,7 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
for (;;)
{
errno= 0; /* Linux doesn't reset this */
- if ((readbytes= read(Filedes, Buffer, Count)) != Count)
+ if ((readbytes= read(Filedes, Buffer, (uint) Count)) != Count)
{
my_errno= errno ? errno : -1;
DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d",
diff --git a/mysys/my_write.c b/mysys/my_write.c
index c67b1d8f3f2..d7eb390bdd2 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -54,10 +54,8 @@ size_t my_write(int Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
(MyFlags & MY_WAIT_IF_FULL))
{
- if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
- my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
- my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
- VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
+ wait_for_free_space(my_filename(Filedes), errors);
+ errors++;
continue;
}
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
index c484f1d4c54..36d07b475e9 100644
--- a/mysys/safemalloc.c
+++ b/mysys/safemalloc.c
@@ -174,7 +174,7 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags)
data[size + 3]= MAGICEND3;
irem->filename= (char *) filename;
irem->linenum= lineno;
- irem->datasize= size;
+ irem->datasize= (uint32) size;
irem->prev= NULL;
/* Add this remember structure to the linked list */
diff --git a/mysys/string.c b/mysys/string.c
index b234a589406..10a72b8a295 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -25,7 +25,7 @@
my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
size_t init_alloc, size_t alloc_increment)
{
- uint length;
+ size_t length;
DBUG_ENTER("init_dynamic_string");
if (!alloc_increment)
@@ -100,7 +100,7 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
char *new_ptr;
if (str->length+length >= str->max_length)
{
- uint new_length=(str->length+length+str->alloc_increment)/
+ size_t new_length=(str->length+length+str->alloc_increment)/
str->alloc_increment;
new_length*=str->alloc_increment;
if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME))))
@@ -160,12 +160,12 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
/* Search for quote in each string and replace with escaped quote */
while(*(next_pos= strcend(cur_pos, quote_str[0])) != '\0')
{
- ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos);
+ ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos));
ret&= dynstr_append_mem(str ,"\\", 1);
ret&= dynstr_append_mem(str, quote_str, quote_len);
cur_pos= next_pos + 1;
}
- ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos);
+ ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos));
append= va_arg(dirty_text, char *);
}
va_end(dirty_text);
diff --git a/plugin/Makefile.am b/plugin/Makefile.am
index 22f6bfd88b2..68f1f939836 100644
--- a/plugin/Makefile.am
+++ b/plugin/Makefile.am
@@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = fulltext/configure.in
SUBDIRS = @mysql_pg_dirs@
-DIST_SUBDIRS = daemon_example fulltext
+DIST_SUBDIRS = @mysql_pg_distdirs@
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index f73de69f5b3..feff3a9bc16 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -116,10 +116,15 @@ case $PLATFORM in
esac
# Change the distribution to a long descriptive name
+# For the cluster product, concentrate on the second part
+VERSION_NAME=@VERSION@
+case $VERSION_NAME in
+ *-ndb-* ) VERSION_NAME=`echo $VERSION_NAME | sed -e 's/[.0-9]*-ndb-//'` ;;
+esac
if [ x"$SHORT_PRODUCT_TAG" != x"" ] ; then
- NEW_NAME=mysql-$SHORT_PRODUCT_TAG-@VERSION@-$PLATFORM$SUFFIX
+ NEW_NAME=mysql-$SHORT_PRODUCT_TAG-$VERSION_NAME-$PLATFORM$SUFFIX
else
- NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-@VERSION@-$PLATFORM$SUFFIX
+ NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$VERSION_NAME-$PLATFORM$SUFFIX
fi
# ----------------------------------------------------------------------
diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist
index 7419083f262..e93f1999fb7 100755
--- a/scripts/make_win_bin_dist
+++ b/scripts/make_win_bin_dist
@@ -126,7 +126,7 @@ if [ -e $DESTDIR ] ; then
usage
fi
-trap 'echo "Clearning up and exiting..." ; rm -fr $DESTDIR; exit 1' ERR
+trap 'echo "Cleaning up and exiting..." ; rm -fr $DESTDIR; exit 1' ERR
# ----------------------------------------------------------------------
# Adjust target name if needed, release with debug info has another name
diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh
index 1f5509f9955..b1ea26a9b7d 100644
--- a/scripts/mysql_setpermission.sh
+++ b/scripts/mysql_setpermission.sh
@@ -257,7 +257,7 @@ sub addall {
$sth = $dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
} elsif ($todo == 7) {
# all privileges set to N
- $sth = $dbh->do("REVOKE ALL ON *.* FROM \'$user\'\@\'$host\'") || die $dbh->errstr;
+ $sth = $dbh->do("REVOKE ALL ON $db.* FROM \'$user\'\@\'$host\'") || die $dbh->errstr;
}
}
$dbh->do("FLUSH PRIVILEGES") || print STDERR "Can't flush privileges\n";
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index fdab9601129..67e18517915 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -66,7 +66,7 @@ CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL
-- Create general_log if CSV is enabled.
-SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, thread_id INTEGER NOT NULL, server_id INTEGER NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"', 'SET @dummy = 0');
+SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, thread_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, command_type VARCHAR(64) NOT NULL, argument MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="General log"', 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
@@ -74,13 +74,13 @@ DROP PREPARE stmt;
-- Create slow_log if CSV is enabled.
-SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER NOT NULL, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
+SET @str = IF (@@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;
-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','SLAVESIDE_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 '', originator int(10) NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
+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','SLAVESIDE_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 '', originator INTEGER UNSIGNED NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM;
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index a33c4fcb9fa..a6497f57f0a 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -216,6 +216,20 @@ ALTER TABLE func
MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL;
#
+# Modify log tables.
+#
+
+SET @old_log_state = @@global.general_log;
+SET GLOBAL general_log = 'OFF';
+ALTER TABLE general_log MODIFY COLUMN server_id INTEGER UNSIGNED NOT NULL;
+SET GLOBAL general_log = @old_log_state;
+
+SET @old_log_state = @@global.slow_query_log;
+SET GLOBAL slow_query_log = 'OFF';
+ALTER TABLE slow_log MODIFY COLUMN server_id INTEGER UNSIGNED NOT NULL;
+SET GLOBAL slow_query_log = @old_log_state;
+
+#
# Detect whether we had Create_view_priv
#
SET @hadCreateViewPriv:=0;
@@ -471,7 +485,10 @@ ALTER TABLE event MODIFY sql_mode
'PAD_CHAR_TO_FULL_LENGTH'
) DEFAULT '' NOT NULL AFTER on_completion;
ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default '';
-ALTER TABLE event ADD COLUMN originator INT(10) NOT NULL AFTER comment;
+
+ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL;
+ALTER TABLE event ADD COLUMN originator INT UNSIGNED NOT NULL AFTER comment;
+
ALTER TABLE event MODIFY COLUMN status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED';
ALTER TABLE event ADD COLUMN time_zone char(64) CHARACTER SET latin1
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index 631e1e38cc7..3cb4665eb1c 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -293,12 +293,7 @@ sub start_mysqlds()
@groups = &find_groups($groupids);
for ($i = 0; defined($groups[$i]); $i++)
{
- # Defaults are made explicit parameters to server execution...
@options = defaults_for_group($groups[$i]);
- # ...so server MUST NOT try to read again from some config file, especially
- # as the "right" file may be unknown to the server if we are using
- # --defaults-file=... params in here.
- unshift(@options,"--no-defaults");
$mysqld_found= 1; # The default
$mysqld_found= 0 if (!length($mysqld));
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 5e7a177a546..960c3e39bab 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -18,7 +18,7 @@ niceness=0
logging=init
want_syslog=0
syslog_tag=
-user=@MYSQLD_USER@
+user='@MYSQLD_USER@'
pid_file=
err_log=
@@ -64,9 +64,10 @@ my_which ()
{
save_ifs="${IFS-UNSET}"
IFS=:
+ ret=0
for file
do
- for dir in $PATH
+ for dir in "$PATH"
do
if [ -f "$dir/$file" ]
then
@@ -74,15 +75,18 @@ my_which ()
continue 2
fi
done
- return 1 # Failure, didn't find file in path
+
+ ret=1 #signal an error
+ break
done
+
if [ "$save_ifs" = UNSET ]
then
unset IFS
else
IFS="$save_ifs"
fi
- return 0 # Success
+ return $ret # Success
}
log_generic () {
@@ -212,19 +216,30 @@ fi
MY_PWD=`pwd`
# Check for the directories we would expect from a binary release install
-if test -f "$relpkgdata"/english/errmsg.sys -a -x ./bin/mysqld
+if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION"
+then
+ # BASEDIR is already overridden on command line. Do not re-set.
+
+ # Use BASEDIR to discover le.
+ if test -x "$MY_BASEDIR_VERSION/libexec/mysqld"
+ then
+ ledir="$MY_BASEDIR_VERSION/libexec"
+ else
+ ledir="$MY_BASEDIR_VERSION/bin"
+ fi
+elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/bin/mysqld"
then
- MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are
- ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is
+ MY_BASEDIR_VERSION="$MY_PWD" # Where bin, share and data are
+ ledir="$MY_PWD/bin" # Where mysqld is
# Check for the directories we would expect from a source install
-elif test -f "$relpkgdata"/english/errmsg.sys -a -x ./libexec/mysqld
+elif test -f "$relpkgdata"/english/errmsg.sys -a -x "$MY_PWD/libexec/mysqld"
then
- MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are
- ledir=$MY_BASEDIR_VERSION/libexec # Where mysqld is
+ MY_BASEDIR_VERSION="$MY_PWD" # Where libexec, share and var are
+ ledir="$MY_PWD/libexec" # Where mysqld is
# Since we didn't find anything, used the compiled-in defaults
else
- MY_BASEDIR_VERSION=@prefix@
- ledir=@libexecdir@
+ MY_BASEDIR_VERSION='@prefix@'
+ ledir='@libexecdir@'
fi
@@ -274,7 +289,10 @@ export MYSQL_HOME
# Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe]
# and then merge with the command line arguments
-if test -x ./bin/my_print_defaults
+if test -x "$MY_BASEDIR_VERSION/bin/my_print_defaults"
+then
+ print_defaults="$MY_BASEDIR_VERSION/bin/my_print_defaults"
+elif test -x ./bin/my_print_defaults
then
print_defaults="./bin/my_print_defaults"
elif test -x @bindir@/my_print_defaults
@@ -399,7 +417,7 @@ then
MYSQLD=mysqld
fi
-if test ! -x $ledir/$MYSQLD
+if test ! -x "$ledir/$MYSQLD"
then
log_error "The file $ledir/$MYSQLD
does not exist or is not executable. Please cd to the mysql installation
@@ -411,7 +429,7 @@ fi
if test -z "$pid_file"
then
- pid_file=$DATADIR/`@HOSTNAME@`.pid
+ pid_file="$DATADIR/`@HOSTNAME@`.pid"
else
case "$pid_file" in
/* ) ;;
diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh
index 60d972e1c8b..ce2670b2abd 100644
--- a/scripts/mysqldumpslow.sh
+++ b/scripts/mysqldumpslow.sh
@@ -17,9 +17,9 @@ my %opt = (
);
GetOptions(\%opt,
- 'verbose|v+',# verbose
+ 'v|verbose+',# verbose
'help+', # write usage info
- 'debug|d+', # debug
+ 'd|debug+', # debug
's=s', # what to sort by (t, at, l, al, r, ar etc)
'r!', # reverse the sort order (largest last instead of first)
't=i', # just show the top n queries
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
index 4819f512a65..21fca0c0848 100644
--- a/scripts/mysqlhotcopy.sh
+++ b/scripts/mysqlhotcopy.sh
@@ -49,11 +49,11 @@ $0 Ver $VERSION
Usage: $0 db_name[./table_regex/] [new_db_name | directory]
- -?, --help display this helpscreen and exit
+ -?, --help display this help-screen and exit
-u, --user=# user for database login if not current user
-p, --password=# password to use when connecting to server (if not set
in my.cnf, which is recommended)
- -h, --host=# Hostname for local server when connecting over TCP/IP
+ -h, --host=# hostname for local server when connecting over TCP/IP
-P, --port=# port to use when connecting to local server with TCP/IP
-S, --socket=# socket to use when connecting to local server
@@ -86,7 +86,7 @@ sub usage {
# Do not initialize user or password options; that way, any user/password
# options specified in option files will be used. If no values are specified
-# all, the defaults will be used (login name, no password).
+# at all, the defaults will be used (login name, no password).
my %opt = (
noindices => 0,
@@ -95,7 +95,7 @@ my %opt = (
method => "cp",
flushlog => 0,
);
-Getopt::Long::Configure(qw(no_ignore_case)); # disambuguate -p and -P
+Getopt::Long::Configure(qw(no_ignore_case)); # disambiguate -p and -P
GetOptions( \%opt,
"help",
"host|h=s",
@@ -453,7 +453,7 @@ else {
printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet};
$hc_started = time; # count from time lock is granted
- # flush tables to make on-disk copy uptodate
+ # flush tables to make on-disk copy up to date
$start = time;
$dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
@@ -895,7 +895,7 @@ tables and you don't want to have all the tables locked for the
whole duration.
In this situation, I<if> you are happy for groups of tables to be
-backed up separately (and thus possibly not be logically consistant
+backed up separately (and thus possibly not be logically consistent
with one another) then you can run mysqlhotcopy several times on
the same database each with different db_name./table_regex/.
All but the first should use the --addtodest option so the tables
@@ -920,7 +920,7 @@ server in a mutual replication setup.
=item --regexp pattern
-Copy all databases with names matching the pattern
+Copy all databases with names matching the pattern.
=item --regexp /pattern1/./pattern2/
@@ -933,7 +933,7 @@ names begin with 'bar' from all databases which names end with 'foo':
=item db_name./pattern/
Copy only tables matching pattern. Shell metacharacters ( (, ), |, !,
-etc.) have to be escaped (e.g. \). For example, to select all tables
+etc.) have to be escaped (e.g., \). For example, to select all tables
in database db1 whose names begin with 'foo' or 'bar':
mysqlhotcopy --indices --method=cp db1./^\(foo\|bar\)/
@@ -947,19 +947,19 @@ that do not begin with foo nor bar:
=item -?, --help
-Display helpscreen and exit
+Display help-screen and exit.
=item -u, --user=#
-user for database login if not current user
+User for database login if not current user.
=item -p, --password=#
-password to use when connecting to the server. Note that you are strongly
+Password to use when connecting to the server. Note that you are strongly
encouraged *not* to use this option as every user would be able to see the
password in the process list. Instead use the '[mysqlhotcopy]' section in
one of the config files, normally /etc/my.cnf or your personal ~/.my.cnf.
-(See the chapter 'my.cnf Option Files' in the manual)
+(See the chapter 'my.cnf Option Files' in the manual.)
=item -h, -h, --host=#
@@ -968,12 +968,12 @@ different from 'localhost' will trigger mysqlhotcopy to use TCP/IP connection.
=item -P, --port=#
-port to use when connecting to MySQL server with TCP/IP. This is only used
+Port to use when connecting to MySQL server with TCP/IP. This is only used
when using the --host option.
=item -S, --socket=#
-UNIX domain socket to use when connecting to local server
+UNIX domain socket to use when connecting to local server.
=item --noindices
@@ -983,7 +983,7 @@ on the backup.
=item --method=#
-method for copy (only "cp" currently supported). Alpha support for
+Method for copy (only "cp" currently supported). Alpha support for
"scp" was added in November 2000. Your experience with the scp method
will vary with your ability to understand how scp works. 'man scp'
and 'man ssh' are your friends.
@@ -1000,15 +1000,15 @@ scp or rsync the files at your leisure.
=item -q, --quiet
-be silent except for errors
+Be silent except for errors.
=item --debug
-Debug messages are displayed
+Debug messages are displayed.
=item -n, --dryrun
-Display commands without actually doing them
+Display commands without actually doing them.
=back
@@ -1030,18 +1030,18 @@ to be specified on the command line:
mysqlhotcopy db newdb t1 t2 /^foo_/ : t3 /^bar_/ : +
where ":" delimits the subsets, the /^foo_/ indicates all tables
-with names begining with "foo_" and the "+" indicates all tables
+with names beginning with "foo_" and the "+" indicates all tables
not copied by the previous subsets.
-newdb is either another not existing database or a full path to a directory
-where we can create a directory 'db'
+'newdb' is either the name of the new database, or the full path name
+of the new database file. The database should not already exist.
Add option to lock each table in turn for people who don\'t need
cross-table integrity.
Add option to FLUSH STATUS just before UNLOCK TABLES.
-Add support for other copy methods (eg tar to single file?).
+Add support for other copy methods (e.g., tar to single file?).
Add support for forthcoming MySQL ``RAID'' table subdirectory layouts.
@@ -1049,26 +1049,26 @@ Add support for forthcoming MySQL ``RAID'' table subdirectory layouts.
Tim Bunce
-Martin Waite - added checkpoint, flushlog, regexp and dryrun options
+Martin Waite - Added checkpoint, flushlog, regexp and dryrun options.
Fixed cleanup of targets when hotcopy fails.
- Added --record_log_pos.
+ Added --record_log_pos.
RAID tables are now copied (don't know if this works over scp).
-Ralph Corderoy - added synonyms for commands
+Ralph Corderoy - Added synonyms for commands.
-Scott Wiersdorf - added table regex and scp support
+Scott Wiersdorf - Added table regex and scp support.
-Monty - working --noindex (copy only first 2048 bytes of index file)
- Fixes for --method=scp
+Monty - Working --noindex (copy only first 2048 bytes of index file).
+ Fixes for --method=scp.
Ask Bjoern Hansen - Cleanup code to fix a few bugs and enable -w again.
Emil S. Hansen - Added resetslave and resetmaster.
-Jeremy D. Zawodny - Removed depricated DBI calls. Fixed bug which
+Jeremy D. Zawodny - Removed deprecated DBI calls. Fixed bug which
resulted in nothing being copied when a regexp was specified but no
database name(s).
Martin Waite - Fix to handle database name that contains space.
-Paul DuBois - Remove end '/' from directory names
+Paul DuBois - Remove end '/' from directory names.
diff --git a/server-tools/instance-manager/buffer.cc b/server-tools/instance-manager/buffer.cc
index 1c50b11609e..f197f42d009 100644
--- a/server-tools/instance-manager/buffer.cc
+++ b/server-tools/instance-manager/buffer.cc
@@ -100,7 +100,7 @@ err:
int Buffer::get_size()
{
- return buffer_size;
+ return (uint) buffer_size;
}
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index 4a1b658737e..1ad728d40eb 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -163,7 +163,7 @@ static bool start_process(Instance_options *instance_options,
int cmdlen= 0;
for (int i= 0; instance_options->argv[i] != 0; i++)
- cmdlen+= strlen(instance_options->argv[i]) + 3;
+ cmdlen+= (uint) strlen(instance_options->argv[i]) + 3;
cmdlen++; /* make room for the null */
char *cmdline= new char[cmdlen];
diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc
index d7328d51cfe..b137370b50a 100644
--- a/server-tools/instance-manager/instance_map.cc
+++ b/server-tools/instance-manager/instance_map.cc
@@ -536,7 +536,8 @@ int Instance_map::load()
*/
if (my_search_option_files(Options::Main::config_file, &argc,
(char ***) &argv, &args_used,
- process_option, (void*) this))
+ process_option, (void*) this,
+ Options::default_directories))
log_info("Falling back to compiled-in defaults.");
return complete_initialization();
diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc
index 7eba3187dd9..ebca593bb03 100644
--- a/server-tools/instance-manager/options.cc
+++ b/server-tools/instance-manager/options.cc
@@ -86,6 +86,7 @@ const char *Options::Main::bind_address= NULL; /* No default value */
uint Options::Main::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
uint Options::Main::port_number= DEFAULT_PORT;
my_bool Options::Main::mysqld_safe_compatible= FALSE;
+const char **Options::default_directories= NULL;
/* Options::User_management */
@@ -103,7 +104,7 @@ const char *Options::Debug::config_str= "d:t:i:O,im.trace";
#endif
static const char * const ANGEL_PID_FILE_SUFFIX= ".angel.pid";
-static const int ANGEL_PID_FILE_SUFFIX_LEN= strlen(ANGEL_PID_FILE_SUFFIX);
+static const int ANGEL_PID_FILE_SUFFIX_LEN= (uint) strlen(ANGEL_PID_FILE_SUFFIX);
/*
List of options, accepted by the instance manager.
@@ -439,7 +440,8 @@ int Options::load(int argc, char **argv)
log_info("Loading config file '%s'...",
(const char *) Main::config_file);
- load_defaults(Main::config_file, default_groups, &argc, &saved_argv);
+ my_load_defaults(Main::config_file, default_groups, &argc,
+ &saved_argv, &default_directories);
if ((handle_options(&argc, &saved_argv, my_long_options, get_one_option)))
return ERR_INVALID_USAGE;
diff --git a/server-tools/instance-manager/options.h b/server-tools/instance-manager/options.h
index 0202ca271c9..5d4df51faae 100644
--- a/server-tools/instance-manager/options.h
+++ b/server-tools/instance-manager/options.h
@@ -91,6 +91,9 @@ struct Options
#endif
public:
+ /* Array of paths to be passed to my_search_option_files() later */
+ static const char **default_directories;
+
static int load(int argc, char **argv);
static void cleanup();
diff --git a/server-tools/instance-manager/parse.h b/server-tools/instance-manager/parse.h
index 00f7aa237b8..9c50ace5948 100644
--- a/server-tools/instance-manager/parse.h
+++ b/server-tools/instance-manager/parse.h
@@ -206,7 +206,7 @@ inline void get_word(const char **text, size_t *word_len,
break;
}
- *word_len= word_end - *text;
+ *word_len= (uint) (word_end - *text);
}
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_H */
diff --git a/sql-bench/TODO b/sql-bench/TODO
deleted file mode 100644
index 8a103e89199..00000000000
--- a/sql-bench/TODO
+++ /dev/null
@@ -1,21 +0,0 @@
-When comparing with ms-sql:
-
-Check how to get MySQL faster mysql ms-sql
-
-count_distinct (2000) | 89.00| 39.00|
-count_distinct_big (120) | 324.00| 121.00|
-count_distinct_group (1000) | 158.00| 107.00|
-count_distinct_group_on_key (1000) | 49.00| 17.00|
-count_distinct_group_on_key_parts (1| 157.00| 108.00|
-order_by_big (10) | 197.00| 89.00|
-order_by_big_key (10) | 170.00| 82.00|
-order_by_big_key2 (10) | 163.00| 73.00|
-order_by_big_key_desc (10) | 172.00| 84.00|
-order_by_big_key_diff (10) | 193.00| 89.00|
-order_by_big_key_prefix (10) | 165.00| 72.00|
-
-
-Why is the following slow on NT:
- NT Linux
-update_of_primary_key_many_keys (256| 560.00| 65.00|
-
diff --git a/sql-bench/test-create.sh b/sql-bench/test-create.sh
index bc2f17c1f0a..63672519e61 100644
--- a/sql-bench/test-create.sh
+++ b/sql-bench/test-create.sh
@@ -247,7 +247,7 @@ for ($i=2 ; $i <= $keys ; $i++)
$loop_time=new Benchmark;
for ($i=1 ; $i <= $opt_loop_count ; $i++)
{
- do_many($dbh,$server->create("bench_$i", \@fields, \@index));
+ do_many($dbh,$server->create("bench_$i", \@fields, \@keys));
$dbh->do("drop table bench_$i" . $server->{'drop_attr'}) or die $DBI::errstr;
}
diff --git a/sql-common/client.c b/sql-common/client.c
index 63c746a3f5a..d2c7e02551d 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1021,7 +1021,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
argc=1; argv=argv_buff; argv_buff[0]= (char*) "client";
groups[0]= (char*) "client"; groups[1]= (char*) group; groups[2]=0;
- load_defaults(filename, groups, &argc, &argv);
+ my_load_defaults(filename, groups, &argc, &argv, NULL);
if (argc != 1) /* If some default option */
{
char **option=argv;
@@ -3183,7 +3183,7 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name)
if (mysql_get_server_version(mysql) < 40100)
return 0;
sprintf(buff, "SET NAMES %s", cs_name);
- if (!mysql_real_query(mysql, buff, strlen(buff)))
+ if (!mysql_real_query(mysql, buff, (uint) strlen(buff)))
{
mysql->charset= cs;
}
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 155e0237e3c..747c5797ed4 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -264,8 +264,19 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
{
const char *start= str;
ulong tmp_value= (uint) (uchar) (*str++ - '0');
+
+ /*
+ Internal format means no delimiters; every field has a fixed
+ width. Otherwise, we scan until we find a delimiter and discard
+ leading zeroes -- except for the microsecond part, where leading
+ zeroes are significant, and where we never process more than six
+ digits.
+ */
+ my_bool scan_until_delim= !is_internal_format &&
+ ((i != format_position[6]));
+
while (str != end && my_isdigit(&my_charset_latin1,str[0]) &&
- (!is_internal_format || --field_length))
+ (scan_until_delim || --field_length))
{
tmp_value=tmp_value*10 + (ulong) (uchar) (*str - '0');
str++;
diff --git a/sql-common/my_user.c b/sql-common/my_user.c
index d6f2818ad77..0b72e002977 100644
--- a/sql-common/my_user.c
+++ b/sql-common/my_user.c
@@ -44,8 +44,8 @@ void parse_user(const char *user_id_str, size_t user_id_len,
}
else
{
- *user_name_len= p - user_id_str;
- *host_name_len= user_id_len - *user_name_len - 1;
+ *user_name_len= (uint) (p - user_id_str);
+ *host_name_len= (uint) (user_id_len - *user_name_len - 1);
if (*user_name_len > USERNAME_LENGTH)
*user_name_len= USERNAME_LENGTH;
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index ea3c9f17e23..0eba357b632 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -380,7 +380,7 @@ bool
Event_job_data::load_from_row(THD *thd, TABLE *table)
{
char *ptr;
- uint len;
+ size_t len;
LEX_STRING tz_name;
DBUG_ENTER("Event_job_data::load_from_row");
@@ -580,7 +580,7 @@ bool
Event_timed::load_from_row(THD *thd, TABLE *table)
{
char *ptr;
- uint len;
+ size_t len;
DBUG_ENTER("Event_timed::load_from_row");
diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc
index 63ecc3006dd..86905b38627 100644
--- a/sql/event_parse_data.cc
+++ b/sql/event_parse_data.cc
@@ -527,8 +527,8 @@ Event_parse_data::init_definer(THD *thd)
const char *definer_user= thd->lex->definer->user.str;
const char *definer_host= thd->lex->definer->host.str;
- int definer_user_len= thd->lex->definer->user.length;
- int definer_host_len= thd->lex->definer->host.length;
+ size_t definer_user_len= thd->lex->definer->user.length;
+ size_t definer_host_len= thd->lex->definer->host.length;
DBUG_PRINT("info",("init definer_user thd->mem_root: 0x%lx "
"definer_user: 0x%lx", (long) thd->mem_root,
diff --git a/sql/events.cc b/sql/events.cc
index e24d51628c0..ea935e67bd3 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -412,6 +412,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists)))
{
Event_queue_element *new_element;
+ bool dropped= 0;
if (!(new_element= new Event_queue_element()))
ret= TRUE; // OOM
@@ -419,8 +420,9 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
parse_data->name,
new_element)))
{
- db_repository->drop_event(thd, parse_data->dbname, parse_data->name,
- TRUE);
+ if (!db_repository->drop_event(thd, parse_data->dbname, parse_data->name,
+ TRUE))
+ dropped= 1;
delete new_element;
}
else
@@ -429,6 +431,12 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
bool created;
if (event_queue)
event_queue->create_event(thd, new_element, &created);
+ }
+ /*
+ binlog the create event unless it's been successfully dropped
+ */
+ if (!dropped)
+ {
/* Binlog the create event. */
DBUG_ASSERT(thd->query && thd->query_length);
write_bin_log(thd, TRUE, thd->query, thd->query_length);
@@ -694,7 +702,7 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
&sql_mode))
DBUG_RETURN(TRUE);
- field_list.push_back(new Item_empty_string("sql_mode", sql_mode.length));
+ field_list.push_back(new Item_empty_string("sql_mode", (uint) sql_mode.length));
tz_name= et->time_zone->get_name();
diff --git a/sql/field.cc b/sql/field.cc
index 973170223e4..d11b509075b 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -6448,13 +6448,13 @@ int Field_str::store(double nr)
calculate the maximum number of significant digits if the 'f'-format
would be used (+1 for decimal point if the number has a fractional part).
*/
- digits= max(0, (int) max_length - fractional);
+ digits= max(1, (int) max_length - fractional);
/*
If the exponent is negative, decrease digits by the number of leading zeros
after the decimal point that do not count as significant digits.
*/
if (exp < 0)
- digits= max(0, (int) digits + exp);
+ digits= max(1, (int) digits + exp);
/*
'e'-format is used only if the exponent is less than -4 or greater than or
equal to the precision. In this case we need to adjust the number of
@@ -6462,7 +6462,7 @@ int Field_str::store(double nr)
We also have to reserve one additional character if abs(exp) >= 100.
*/
if (exp >= (int) digits || exp < -4)
- digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
+ digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
/* Limit precision to DBL_DIG to avoid garbage past significant digits */
set_if_smaller(digits, DBL_DIG);
@@ -9685,16 +9685,16 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
else if (tmp_length > PRECISION_FOR_FLOAT)
{
sql_type= MYSQL_TYPE_DOUBLE;
- length= DBL_DIG+7; /* -[digits].E+### */
+ length= MAX_DOUBLE_STR_LENGTH;
}
else
- length= FLT_DIG+6; /* -[digits].E+## */
+ length= MAX_FLOAT_STR_LENGTH;
decimals= NOT_FIXED_DEC;
break;
}
if (!fld_length && !fld_decimals)
{
- length= FLT_DIG+6;
+ length= MAX_FLOAT_STR_LENGTH;
decimals= NOT_FIXED_DEC;
}
if (length < decimals &&
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 214ee4c99d2..5a0904f87b9 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -204,7 +204,7 @@ void insert_symbols()
for (cur= symbols; i<array_elements(symbols); cur++, i++){
hash_lex_struct *root=
get_hash_struct_by_len(&root_by_len,cur->length,&max_len);
- insert_into_hash(root,cur->name,0,i,0);
+ insert_into_hash(root,cur->name,0,(uint) i,0);
}
}
@@ -516,7 +516,7 @@ static SYMBOL *get_hash_symbol(const char *s,\n\
res= symbols+ires;\n\
else\n\
res= sql_functions-ires-1;\n\
- register uint count= cur_str-s;\n\
+ register uint count= (uint) (cur_str - s);\n\
return lex_casecmp(cur_str,res->name+count,len-count) ? 0 : res;\n\
}\n\
\n\
@@ -545,7 +545,7 @@ static SYMBOL *get_hash_symbol(const char *s,\n\
register int16 ires= (int16)(cur_struct>>16);\n\
if (ires==array_elements(symbols)) return 0;\n\
register SYMBOL *res= symbols+ires;\n\
- register uint count= cur_str-s;\n\
+ register uint count= (uint) (cur_str - s);\n\
return lex_casecmp(cur_str,res->name+count,len-count)!=0 ? 0 : res;\n\
}\n\
\n\
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 0e36a868b3e..67bc3156260 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -4928,10 +4928,11 @@ int ha_partition::info(uint flag)
This flag is used to get index number of the unique index that
reported duplicate key
We will report the errkey on the last handler used and ignore the rest
+ Note: all engines does not support HA_STATUS_ERRKEY, so set errkey.
*/
+ file->errkey= errkey;
file->info(HA_STATUS_ERRKEY);
- if (file->errkey != (uint) -1)
- errkey= file->errkey;
+ errkey= file->errkey;
}
if (flag & HA_STATUS_TIME)
{
diff --git a/sql/handler.cc b/sql/handler.cc
index d232559ea38..0de7718d113 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -430,14 +430,11 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
MYF(MY_WME | MY_ZEROFILL));
/* Historical Requirement */
plugin->data= hton; // shortcut for the future
- if (plugin->plugin->init)
+ if (plugin->plugin->init && plugin->plugin->init(hton))
{
- if (plugin->plugin->init(hton))
- {
- sql_print_error("Plugin '%s' init function returned error.",
- plugin->name.str);
- goto err;
- }
+ sql_print_error("Plugin '%s' init function returned error.",
+ plugin->name.str);
+ goto err;
}
/*
@@ -464,17 +461,13 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
if (idx == (int) DB_TYPE_DEFAULT)
{
sql_print_warning("Too many storage engines!");
- DBUG_RETURN(1);
+ goto err_deinit;
}
if (hton->db_type != DB_TYPE_UNKNOWN)
sql_print_warning("Storage engine '%s' has conflicting typecode. "
"Assigning value %d.", plugin->plugin->name, idx);
hton->db_type= (enum legacy_db_type) idx;
}
- installed_htons[hton->db_type]= hton;
- tmp= hton->savepoint_offset;
- hton->savepoint_offset= savepoint_alloc_size;
- savepoint_alloc_size+= tmp;
/*
In case a plugin is uninstalled and re-installed later, it should
@@ -495,11 +488,14 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
{
sql_print_error("Too many plugins loaded. Limit is %lu. "
"Failed on '%s'", (ulong) MAX_HA, plugin->name.str);
- goto err;
+ goto err_deinit;
}
hton->slot= total_ha++;
}
-
+ installed_htons[hton->db_type]= hton;
+ tmp= hton->savepoint_offset;
+ hton->savepoint_offset= savepoint_alloc_size;
+ savepoint_alloc_size+= tmp;
hton2plugin[hton->slot]=plugin;
if (hton->prepare)
total_ha_2pc++;
@@ -531,7 +527,18 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
};
DBUG_RETURN(0);
+
+err_deinit:
+ /*
+ Let plugin do its inner deinitialization as plugin->init()
+ was successfully called before.
+ */
+ if (plugin->plugin->deinit)
+ (void) plugin->plugin->deinit(NULL);
+
err:
+ my_free((uchar*) hton, MYF(0));
+ plugin->data= NULL;
DBUG_RETURN(1);
}
@@ -1178,6 +1185,16 @@ end:
if (rw_trans)
start_waiting_global_read_lock(thd);
}
+ else if (all)
+ {
+ /*
+ A COMMIT of an empty transaction. There may be savepoints.
+ Destroy them. If the transaction is not empty
+ savepoints are cleared in ha_commit_one_phase()
+ or ha_rollback_trans().
+ */
+ thd->transaction.cleanup();
+ }
#endif /* USING_TRANSACTIONS */
DBUG_RETURN(error);
}
@@ -1286,11 +1303,11 @@ int ha_rollback_trans(THD *thd, bool all)
thd->transaction.xid_state.xid.null();
}
if (all)
- {
thd->variables.tx_isolation=thd->session_tx_isolation;
- thd->transaction.cleanup();
- }
}
+ /* Always cleanup. Even if there nht==0. There may be savepoints. */
+ if (all)
+ thd->transaction.cleanup();
#endif /* USING_TRANSACTIONS */
if (all)
thd->transaction_rollback_request= FALSE;
@@ -2926,7 +2943,7 @@ uint handler::get_dup_key(int error)
if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY ||
error == HA_ERR_FOUND_DUPP_UNIQUE || error == HA_ERR_NULL_IN_SPATIAL ||
error == HA_ERR_DROP_INDEX_FK)
- info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK);
+ table->file->info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK);
DBUG_RETURN(table->file->errkey);
}
diff --git a/sql/item.cc b/sql/item.cc
index 8356dee0560..d1418b9a137 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1313,7 +1313,10 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref)
my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
return TRUE;
}
- set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info);
+ if (is_autogenerated_name)
+ {
+ set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info);
+ }
collation.set(value_item->collation.collation, DERIVATION_IMPLICIT);
max_length= value_item->max_length;
decimals= value_item->decimals;
@@ -1531,7 +1534,8 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
else
{
// Cannot apply conversion
- set(0, DERIVATION_NONE, 0);
+ set(&my_charset_bin, DERIVATION_NONE,
+ (dt.repertoire|repertoire));
return 1;
}
}
@@ -1614,15 +1618,31 @@ bool agg_item_collations(DTCollation &c, const char *fname,
{
uint i;
Item **arg;
+ bool unknown_cs= 0;
+
c.set(av[0]->collation);
for (i= 1, arg= &av[item_sep]; i < count; i++, arg++)
{
if (c.aggregate((*arg)->collation, flags))
{
+ if (c.derivation == DERIVATION_NONE &&
+ c.collation == &my_charset_bin)
+ {
+ unknown_cs= 1;
+ continue;
+ }
my_coll_agg_error(av, count, fname, item_sep);
return TRUE;
}
}
+
+ if (unknown_cs &&
+ c.derivation != DERIVATION_EXPLICIT)
+ {
+ my_coll_agg_error(av, count, fname, item_sep);
+ return TRUE;
+ }
+
if ((flags & MY_COLL_DISALLOW_NONE) &&
c.derivation == DERIVATION_NONE)
{
@@ -1641,48 +1661,11 @@ bool agg_item_collations_for_comparison(DTCollation &c, const char *fname,
}
-/**
- Collect arguments' character sets together.
-
- We allow to apply automatic character set conversion in some cases.
- The conditions when conversion is possible are:
- - arguments A and B have different charsets
- - A wins according to coercibility rules
- (i.e. a column is stronger than a string constant,
- an explicit COLLATE clause is stronger than a column)
- - character set of A is either superset for character set of B,
- or B is a string constant which can be converted into the
- character set of A without data loss.
-
- If all of the above is true, then it's possible to convert
- B into the character set of A, and then compare according
- to the collation of A.
-
- For functions with more than two arguments:
- @code
- collect(A,B,C) ::= collect(collect(A,B),C)
- @endcode
- Since this function calls THD::change_item_tree() on the passed Item **
- pointers, it is necessary to pass the original Item **'s, not copies.
- Otherwise their values will not be properly restored (see BUG#20769).
- If the items are not consecutive (eg. args[2] and args[5]), use the
- item_sep argument, ie.
- @code
- agg_item_charsets(coll, fname, &args[2], 2, flags, 3)
- @endcode
-*/
-
-bool agg_item_charsets(DTCollation &coll, const char *fname,
- Item **args, uint nargs, uint flags, int item_sep)
+bool agg_item_set_converter(DTCollation &coll, const char *fname,
+ Item **args, uint nargs, uint flags, int item_sep)
{
Item **arg, *safe_args[2];
- LINT_INIT(safe_args[0]);
- LINT_INIT(safe_args[1]);
-
- if (agg_item_collations(coll, fname, args, nargs, flags, item_sep))
- return TRUE;
-
/*
For better error reporting: save the first and the second argument.
We need this only if the the number of args is 3 or 2:
@@ -1762,6 +1745,46 @@ bool agg_item_charsets(DTCollation &coll, const char *fname,
}
+/*
+ Collect arguments' character sets together.
+ We allow to apply automatic character set conversion in some cases.
+ The conditions when conversion is possible are:
+ - arguments A and B have different charsets
+ - A wins according to coercibility rules
+ (i.e. a column is stronger than a string constant,
+ an explicit COLLATE clause is stronger than a column)
+ - character set of A is either superset for character set of B,
+ or B is a string constant which can be converted into the
+ character set of A without data loss.
+
+ If all of the above is true, then it's possible to convert
+ B into the character set of A, and then compare according
+ to the collation of A.
+
+ For functions with more than two arguments:
+
+ collect(A,B,C) ::= collect(collect(A,B),C)
+
+ Since this function calls THD::change_item_tree() on the passed Item **
+ pointers, it is necessary to pass the original Item **'s, not copies.
+ Otherwise their values will not be properly restored (see BUG#20769).
+ If the items are not consecutive (eg. args[2] and args[5]), use the
+ item_sep argument, ie.
+
+ agg_item_charsets(coll, fname, &args[2], 2, flags, 3)
+
+*/
+
+bool agg_item_charsets(DTCollation &coll, const char *fname,
+ Item **args, uint nargs, uint flags, int item_sep)
+{
+ if (agg_item_collations(coll, fname, args, nargs, flags, item_sep))
+ return TRUE;
+
+ return agg_item_set_converter(coll, fname, args, nargs, flags, item_sep);
+}
+
+
void Item_ident_for_show::make_field(Send_field *tmp_field)
{
tmp_field->table_name= tmp_field->org_table_name= table_name;
@@ -3101,7 +3124,7 @@ bool Item_param::convert_str_value(THD *thd)
str_value.set_charset(value.cs_info.final_character_set_of_str_value);
/* Here str_value is guaranteed to be in final_character_set_of_str_value */
- max_length= str_value.length();
+ max_length= str_value.numchars() * str_value.charset()->mbmaxlen;
decimals= 0;
/*
str_value_ptr is returned from val_str(). It must be not alloced
@@ -4445,7 +4468,7 @@ Item *Item_field::replace_equal_field(uchar *arg)
return const_item;
}
Item_field *subst= item_equal->get_first();
- if (subst && !field->eq(subst->field))
+ if (subst && field->table != subst->field->table && !field->eq(subst->field))
return subst;
}
return this;
@@ -7102,18 +7125,26 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
{
if (decimals != NOT_FIXED_DEC)
{
- int delta1= max_length_orig - decimals_orig;
- int delta2= item->max_length - item->decimals;
- max_length= max(delta1, delta2) + decimals;
- if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
- {
- max_length= FLT_DIG + 6;
- decimals= NOT_FIXED_DEC;
- }
- if (fld_type == MYSQL_TYPE_DOUBLE && max_length > DBL_DIG + 2)
+ /*
+ For FLOAT(M,D)/DOUBLE(M,D) do not change precision
+ if both fields have the same M and D
+ */
+ if (item->max_length != max_length_orig ||
+ item->decimals != decimals_orig)
{
- max_length= DBL_DIG + 7;
- decimals= NOT_FIXED_DEC;
+ int delta1= max_length_orig - decimals_orig;
+ int delta2= item->max_length - item->decimals;
+ max_length= max(delta1, delta2) + decimals;
+ if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2)
+ {
+ max_length= MAX_FLOAT_STR_LENGTH;
+ decimals= NOT_FIXED_DEC;
+ }
+ else if (fld_type == MYSQL_TYPE_DOUBLE && max_length > DBL_DIG + 2)
+ {
+ max_length= MAX_DOUBLE_STR_LENGTH;
+ decimals= NOT_FIXED_DEC;
+ }
}
}
else
diff --git a/sql/item.h b/sql/item.h
index be9daf672f0..96a4e9f7a31 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1092,7 +1092,7 @@ inline void Item_sp_variable::make_field(Send_field *field)
if (name)
it->set_name(name, (uint) strlen(name), system_charset_info);
else
- it->set_name(m_name.str, m_name.length, system_charset_info);
+ it->set_name(m_name.str, (uint) m_name.length, system_charset_info);
it->make_field(field);
}
@@ -1303,6 +1303,8 @@ bool agg_item_collations(DTCollation &c, const char *name,
Item **items, uint nitems, uint flags, int item_sep);
bool agg_item_collations_for_comparison(DTCollation &c, const char *name,
Item **items, uint nitems, uint flags);
+bool agg_item_set_converter(DTCollation &coll, const char *fname,
+ Item **args, uint nargs, uint flags, int item_sep);
bool agg_item_charsets(DTCollation &c, const char *name,
Item **items, uint nitems, uint flags, int item_sep);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index bd90dd81365..a9bfea1b806 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -549,7 +549,8 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
my_error(ER_OPERAND_COLUMNS, MYF(0), (*a)->element_index(i)->cols());
return 1;
}
- comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
+ if (comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i)))
+ return 1;
}
break;
}
@@ -894,6 +895,16 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
get_value_func= &get_time_value;
return 0;
}
+ else if (type == STRING_RESULT &&
+ (*a)->result_type() == STRING_RESULT &&
+ (*b)->result_type() == STRING_RESULT)
+ {
+ DTCollation coll;
+ coll.set((*a)->collation.collation);
+ if (agg_item_set_converter(coll, owner_arg->func_name(),
+ b, 1, MY_COLL_CMP_CONV, 1))
+ return 1;
+ }
return set_compare_func(owner_arg, type);
}
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 349c47816ad..bf359b10caa 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -3791,6 +3791,7 @@ Create_func_load_file Create_func_load_file::s_singleton;
Item*
Create_func_load_file::create(THD *thd, Item *arg1)
{
+ thd->lex->set_stmt_unsafe();
thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
return new (thd->mem_root) Item_load_file(arg1);
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 34cb50ee7fa..876aee719a3 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2716,7 +2716,7 @@ longlong Item_func_find_in_set::val_int()
int diff;
if ((diff=buffer->length() - find->length()) >= 0)
{
- my_wc_t wc;
+ my_wc_t wc= 0;
CHARSET_INFO *cs= cmp_collation.collation;
const char *str_begin= buffer->ptr();
const char *str_end= buffer->ptr();
@@ -2739,7 +2739,7 @@ longlong Item_func_find_in_set::val_int()
if (is_last_item && !is_separator)
str_end= substr_end;
if (!my_strnncoll(cs, (const uchar *) str_begin,
- str_end - str_begin,
+ (uint) (str_end - str_begin),
find_str, find_str_len))
return (longlong) position;
else
@@ -4825,7 +4825,7 @@ Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg,
component(*component_arg), cache_present(0)
{
/* set_name() will allocate the name */
- set_name(name_arg, name_len_arg, system_charset_info);
+ set_name(name_arg, (uint) name_len_arg, system_charset_info);
}
@@ -4837,7 +4837,9 @@ bool Item_func_get_system_var::is_written_to_binlog()
void Item_func_get_system_var::fix_length_and_dec()
{
+ char *cptr;
maybe_null=0;
+ max_length= 0;
if (var->check_type(var_type))
{
@@ -4867,8 +4869,14 @@ void Item_func_get_system_var::fix_length_and_dec()
break;
case SHOW_CHAR:
case SHOW_CHAR_PTR:
+ pthread_mutex_lock(&LOCK_global_system_variables);
+ cptr= var->show_type() == SHOW_CHAR_PTR ?
+ *(char**) var->value_ptr(current_thd, var_type, &component) :
+ (char*) var->value_ptr(current_thd, var_type, &component);
+ if (cptr)
+ max_length= strlen(cptr) * system_charset_info->mbmaxlen;
+ pthread_mutex_unlock(&LOCK_global_system_variables);
collation.set(system_charset_info, DERIVATION_SYSCONST);
- max_length= MAX_BLOB_WIDTH;
decimals=NOT_FIXED_DEC;
break;
case SHOW_BOOL:
@@ -5371,7 +5379,10 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
if (item->type() == Item::REF_ITEM)
args[i]= item= *((Item_ref *)item)->ref;
if (item->type() != Item::FIELD_ITEM)
- key=NO_SUCH_KEY;
+ {
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "AGAINST");
+ return TRUE;
+ }
}
/*
Check that all columns come from the same table.
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index ac1b7738a27..24a92c78e9c 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -78,10 +78,17 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String arg_val;
- String *wkb= args[0]->val_str(&arg_val);
+ String *wkb;
Geometry_buffer buffer;
uint32 srid= 0;
+ if (args[0]->field_type() == MYSQL_TYPE_GEOMETRY)
+ {
+ return args[0]->val_str(str);
+ }
+
+ wkb= args[0]->val_str(&arg_val);
+
if ((arg_count == 2) && !args[1]->null_value)
srid= (uint32)args[1]->val_int();
@@ -91,8 +98,8 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
str->length(0);
str->q_append(srid);
if ((null_value=
- (args[0]->null_value ||
- !Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length(), str))))
+ (args[0]->null_value ||
+ !Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length(), str))))
return 0;
return str;
}
@@ -345,14 +352,16 @@ String *Item_func_point::val_str(String *str)
DBUG_ASSERT(fixed == 1);
double x= args[0]->val_real();
double y= args[1]->val_real();
+ uint32 srid= 0;
if ((null_value= (args[0]->null_value ||
args[1]->null_value ||
- str->realloc(1 + 4 + SIZEOF_STORED_DOUBLE*2))))
+ str->realloc(4/*SRID*/ + 1 + 4 + SIZEOF_STORED_DOUBLE*2))))
return 0;
str->set_charset(&my_charset_bin);
str->length(0);
+ str->q_append(srid);
str->q_append((char)Geometry::wkb_ndr);
str->q_append((uint32)Geometry::wkb_point);
str->q_append(x);
@@ -376,12 +385,14 @@ String *Item_func_spatial_collection::val_str(String *str)
DBUG_ASSERT(fixed == 1);
String arg_value;
uint i;
+ uint32 srid= 0;
str->set_charset(&my_charset_bin);
str->length(0);
- if (str->reserve(1 + 4 + 4, 512))
+ if (str->reserve(4/*SRID*/ + 1 + 4 + 4, 512))
goto err;
+ str->q_append(srid);
str->q_append((char) Geometry::wkb_ndr);
str->q_append((uint32) coll_type);
str->q_append((uint32) arg_count);
@@ -399,13 +410,13 @@ String *Item_func_spatial_collection::val_str(String *str)
In the case of GeometryCollection we don't need any checkings
for item types, so just copy them into target collection
*/
- if (str->append(res->ptr(), len, (uint32) 512))
+ if (str->append(res->ptr() + 4/*SRID*/, len - 4/*SRID*/, (uint32) 512))
goto err;
}
else
{
enum Geometry::wkbType wkb_type;
- const char *data= res->ptr() + 1;
+ const char *data= res->ptr() + 4/*SRID*/ + 1;
/*
In the case of named collection we must check that items
@@ -414,7 +425,7 @@ String *Item_func_spatial_collection::val_str(String *str)
wkb_type= (Geometry::wkbType) uint4korr(data);
data+= 4;
- len-= 5;
+ len-= 5 + 4/*SRID*/;
if (wkb_type != item_type)
goto err;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index fc9375e68a5..267036e4a3d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -105,13 +105,10 @@ String *Item_func_md5::val_str(String *str)
str->set_charset(&my_charset_bin);
if (sptr)
{
- my_MD5_CTX context;
uchar digest[16];
null_value=0;
- my_MD5Init (&context);
- my_MD5Update (&context,(uchar *) sptr->ptr(), sptr->length());
- my_MD5Final (digest, &context);
+ MY_MD5_HASH(digest,(uchar *) sptr->ptr(), sptr->length());
if (str->alloc(32)) // Ensure that memory is free
{
null_value=1;
@@ -507,17 +504,21 @@ String *Item_func_des_encrypt::val_str(String *str)
string marking change of string length.
*/
- tail= (8-(res_length) % 8); // 1..8 marking extra length
+ tail= 8 - (res_length % 8); // 1..8 marking extra length
res_length+=tail;
+ tmp_arg.realloc(res_length);
+ tmp_arg.length(0);
+ tmp_arg.append(res->ptr(), res->length());
code= ER_OUT_OF_RESOURCES;
- if (tail && res->append(append_str, tail) || tmp_value.alloc(res_length+1))
+ if (tmp_arg.append(append_str, tail) || tmp_value.alloc(res_length+1))
goto error;
- (*res)[res_length-1]=tail; // save extra length
+ tmp_arg[res_length-1]=tail; // save extra length
+ tmp_value.realloc(res_length+1);
tmp_value.length(res_length+1);
tmp_value[0]=(char) (128 | key_number);
// Real encryption
bzero((char*) &ivec,sizeof(ivec));
- DES_ede3_cbc_encrypt((const uchar*) (res->ptr()),
+ DES_ede3_cbc_encrypt((const uchar*) (tmp_arg.ptr()),
(uchar*) (tmp_value.ptr()+1),
res_length,
&keyschedule.ks1,
@@ -1692,10 +1693,10 @@ String *Item_func_encrypt::val_str(String *str)
String *salt_str=args[1]->val_str(&tmp_value);
if ((null_value= (args[1]->null_value || salt_str->length() < 2)))
return 0;
- salt_ptr= salt_str->c_ptr();
+ salt_ptr= salt_str->c_ptr_safe();
}
pthread_mutex_lock(&LOCK_crypt);
- char *tmp= crypt(res->c_ptr(),salt_ptr);
+ char *tmp= crypt(res->c_ptr_safe(),salt_ptr);
if (!tmp)
{
pthread_mutex_unlock(&LOCK_crypt);
@@ -1741,7 +1742,7 @@ String *Item_func_encode::val_str(String *str)
null_value=0;
res=copy_if_not_alloced(str,res,res->length());
- SQL_CRYPT sql_crypt(password->ptr());
+ SQL_CRYPT sql_crypt(password->ptr(), password->length());
sql_crypt.init();
sql_crypt.encode((char*) res->ptr(),res->length());
res->set_charset(&my_charset_bin);
@@ -1770,7 +1771,7 @@ String *Item_func_decode::val_str(String *str)
null_value=0;
res=copy_if_not_alloced(str,res,res->length());
- SQL_CRYPT sql_crypt(password->ptr());
+ SQL_CRYPT sql_crypt(password->ptr(), password->length());
sql_crypt.init();
sql_crypt.decode((char*) res->ptr(),res->length());
return res;
@@ -1830,17 +1831,17 @@ bool Item_func_user::init(const char *user, const char *host)
if (user)
{
CHARSET_INFO *cs= str_value.charset();
- uint res_length= (strlen(user)+strlen(host)+2) * cs->mbmaxlen;
+ size_t res_length= (strlen(user)+strlen(host)+2) * cs->mbmaxlen;
- if (str_value.alloc(res_length))
+ if (str_value.alloc((uint) res_length))
{
null_value=1;
return TRUE;
}
- res_length=cs->cset->snprintf(cs, (char*)str_value.ptr(), res_length,
+ res_length=cs->cset->snprintf(cs, (char*)str_value.ptr(), (uint) res_length,
"%s@%s", user, host);
- str_value.length(res_length);
+ str_value.length((uint) res_length);
str_value.mark_as_const();
}
return FALSE;
@@ -2544,7 +2545,7 @@ String *Item_func_rpad::val_str(String *str)
memcpy(to,ptr_pad,(size_t) pad_byte_length);
to+= pad_byte_length;
}
- res->length(to- (char*) res->ptr());
+ res->length((uint) (to- (char*) res->ptr()));
return (res);
err:
@@ -2812,7 +2813,7 @@ String *Item_func_charset::val_str(String *str)
CHARSET_INFO *cs= args[0]->collation.collation;
null_value= 0;
- str->copy(cs->csname, strlen(cs->csname),
+ str->copy(cs->csname, (uint) strlen(cs->csname),
&my_charset_latin1, collation.collation, &dummy_errors);
return str;
}
@@ -2824,7 +2825,7 @@ String *Item_func_collation::val_str(String *str)
CHARSET_INFO *cs= args[0]->collation.collation;
null_value= 0;
- str->copy(cs->name, strlen(cs->name),
+ str->copy(cs->name, (uint) strlen(cs->name),
&my_charset_latin1, collation.collation, &dummy_errors);
return str;
}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 81baf9a4c5f..5265f608344 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -293,13 +293,17 @@ public:
class Item_func_des_encrypt :public Item_str_func
{
- String tmp_value;
+ String tmp_value,tmp_arg;
public:
Item_func_des_encrypt(Item *a) :Item_str_func(a) {}
Item_func_des_encrypt(Item *a, Item *b): Item_str_func(a,b) {}
String *val_str(String *);
void fix_length_and_dec()
- { maybe_null=1; max_length = args[0]->max_length+8; }
+ {
+ maybe_null=1;
+ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
+ max_length = args[0]->max_length + 9;
+ }
const char *func_name() const { return "des_encrypt"; }
};
@@ -310,7 +314,12 @@ public:
Item_func_des_decrypt(Item *a) :Item_str_func(a) {}
Item_func_des_decrypt(Item *a, Item *b): Item_str_func(a,b) {}
String *val_str(String *);
- void fix_length_and_dec() { maybe_null=1; max_length = args[0]->max_length; }
+ void fix_length_and_dec()
+ {
+ maybe_null=1;
+ /* 9 = MAX ((8- (arg_len % 8)) + 1) */
+ max_length = args[0]->max_length - 9;
+ }
const char *func_name() const { return "des_decrypt"; }
};
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1821136cc9d..a6d8bb8a52d 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -439,7 +439,8 @@ void Item_sum::make_field(Send_field *tmp_field)
void Item_sum::print(String *str, enum_query_type query_type)
{
- Item **pargs= orig_args;
+ /* orig_args is not filled with valid values until fix_fields() */
+ Item **pargs= fixed ? orig_args : args;
str->append(func_name());
for (uint i=0 ; i < arg_count ; i++)
{
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index ab20ed17cd7..8caff22eab9 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -391,7 +391,7 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
if (tmp - val > 6)
tmp= (char*) val + 6;
l_time->second_part= (int) my_strtoll10(val, &tmp, &error);
- frac_part= 6 - (tmp - val);
+ frac_part= 6 - (uint) (tmp - val);
if (frac_part > 0)
l_time->second_part*= (ulong) log_10_int[frac_part];
val= tmp;
@@ -642,14 +642,14 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
if (!l_time->month)
return 1;
str->append(locale->month_names->type_names[l_time->month-1],
- strlen(locale->month_names->type_names[l_time->month-1]),
+ (uint) strlen(locale->month_names->type_names[l_time->month-1]),
system_charset_info);
break;
case 'b':
if (!l_time->month)
return 1;
str->append(locale->ab_month_names->type_names[l_time->month-1],
- strlen(locale->ab_month_names->type_names[l_time->month-1]),
+ (uint) strlen(locale->ab_month_names->type_names[l_time->month-1]),
system_charset_info);
break;
case 'W':
@@ -658,7 +658,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),0);
str->append(locale->day_names->type_names[weekday],
- strlen(locale->day_names->type_names[weekday]),
+ (uint) strlen(locale->day_names->type_names[weekday]),
system_charset_info);
break;
case 'a':
@@ -667,13 +667,13 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),0);
str->append(locale->ab_day_names->type_names[weekday],
- strlen(locale->ab_day_names->type_names[weekday]),
+ (uint) strlen(locale->ab_day_names->type_names[weekday]),
system_charset_info);
break;
case 'D':
if (type == MYSQL_TIMESTAMP_TIME)
return 1;
- length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
if (l_time->day >= 10 && l_time->day <= 19)
str->append(STRING_WITH_LEN("th"));
@@ -696,62 +696,62 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
}
break;
case 'Y':
- length= int10_to_str(l_time->year, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->year, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 4, '0');
break;
case 'y':
- length= int10_to_str(l_time->year%100, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->year%100, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'm':
- length= int10_to_str(l_time->month, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'c':
- length= int10_to_str(l_time->month, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
case 'd':
- length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'e':
- length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
case 'f':
- length= int10_to_str(l_time->second_part, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->second_part, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 6, '0');
break;
case 'H':
- length= int10_to_str(l_time->hour, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->hour, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'h':
case 'I':
hours_i= (l_time->hour%24 + 11)%12+1;
- length= int10_to_str(hours_i, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(hours_i, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'i': /* minutes */
- length= int10_to_str(l_time->minute, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->minute, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'j':
if (type == MYSQL_TIMESTAMP_TIME)
return 1;
- length= int10_to_str(calc_daynr(l_time->year,l_time->month,
+ length= (uint) (int10_to_str(calc_daynr(l_time->year,l_time->month,
l_time->day) -
- calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff;
+ calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 3, '0');
break;
case 'k':
- length= int10_to_str(l_time->hour, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->hour, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
case 'l':
hours_i= (l_time->hour%24 + 11)%12+1;
- length= int10_to_str(hours_i, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(hours_i, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
case 'p':
@@ -770,7 +770,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
break;
case 'S':
case 's':
- length= int10_to_str(l_time->second, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(l_time->second, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'T':
@@ -788,11 +788,11 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
uint year;
if (type == MYSQL_TIMESTAMP_TIME)
return 1;
- length= int10_to_str(calc_week(l_time,
+ length= (uint) (int10_to_str(calc_week(l_time,
(*ptr) == 'U' ?
WEEK_FIRST_WEEKDAY : WEEK_MONDAY_FIRST,
&year),
- intbuff, 10) - intbuff;
+ intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
}
break;
@@ -802,12 +802,12 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
uint year;
if (type == MYSQL_TIMESTAMP_TIME)
return 1;
- length= int10_to_str(calc_week(l_time,
+ length= (uint) (int10_to_str(calc_week(l_time,
((*ptr) == 'V' ?
(WEEK_YEAR | WEEK_FIRST_WEEKDAY) :
(WEEK_YEAR | WEEK_MONDAY_FIRST)),
&year),
- intbuff, 10) - intbuff;
+ intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 2, '0');
}
break;
@@ -822,7 +822,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
WEEK_YEAR | WEEK_FIRST_WEEKDAY :
WEEK_YEAR | WEEK_MONDAY_FIRST),
&year);
- length= int10_to_str(year, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(year, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 4, '0');
}
break;
@@ -831,7 +831,7 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
return 1;
weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
l_time->day),1);
- length= int10_to_str(weekday, intbuff, 10) - intbuff;
+ length= (uint) (int10_to_str(weekday, intbuff, 10) - intbuff);
str->append_with_prefill(intbuff, length, 1, '0');
break;
@@ -881,7 +881,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs,
value= value*LL(10) + (longlong) (*str - '0');
if (transform_msec && i == count - 1) // microseconds always last
{
- long msec_length= 6 - (str - start);
+ long msec_length= 6 - (uint) (str - start);
if (msec_length > 0)
value*= (long) log_10_int[msec_length];
}
@@ -1060,7 +1060,7 @@ String* Item_func_monthname::val_str(String* str)
}
null_value=0;
month_name= locale->month_names->type_names[month-1];
- str->copy(month_name, strlen(month_name), &my_charset_utf8_bin,
+ str->copy(month_name, (uint) strlen(month_name), &my_charset_utf8_bin,
collation.collation, &err);
return str;
}
@@ -1210,7 +1210,7 @@ String* Item_func_dayname::val_str(String* str)
return (String*) 0;
day_name= locale->day_names->type_names[weekday];
- str->copy(day_name, strlen(day_name), &my_charset_utf8_bin,
+ str->copy(day_name, (uint) strlen(day_name), &my_charset_utf8_bin,
collation.collation, &err);
return str;
}
@@ -3176,14 +3176,14 @@ String *Item_func_get_format::val_str(String *str)
format++)
{
uint format_name_len;
- format_name_len= strlen(format_name);
+ format_name_len= (uint) strlen(format_name);
if (val_len == format_name_len &&
!my_strnncoll(&my_charset_latin1,
(const uchar *) val->ptr(), val_len,
(const uchar *) format_name, val_len))
{
const char *format_str= get_date_time_format_str(format, type);
- str->set(format_str, strlen(format_str), &my_charset_bin);
+ str->set(format_str, (uint) strlen(format_str), &my_charset_bin);
return str;
}
}
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 5601a2b18c6..6320873e4d3 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -2785,6 +2785,7 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf)
String *Item_func_xml_extractvalue::val_str(String *str)
{
String *res;
+ null_value= 0;
if (!nodeset_func ||
!(res= args[0]->val_str(str)) ||
!parse_xml(res, &pxml))
@@ -2801,6 +2802,7 @@ String *Item_func_xml_update::val_str(String *str)
{
String *res, *nodeset, *rep;
+ null_value= 0;
if (!nodeset_func ||
!(res= args[0]->val_str(str)) ||
!(rep= args[2]->val_str(&tmp_value3)) ||
diff --git a/sql/lock.cc b/sql/lock.cc
index f36e8d605d3..322778b89c3 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -461,7 +461,7 @@ void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock)
for (i= 0; i < sql_lock->table_count; i++)
{
TABLE *tbl= *table;
- tbl->lock_position= table - sql_lock->table;
+ tbl->lock_position= (uint) (table - sql_lock->table);
tbl->lock_data_start= found;
found+= tbl->lock_count;
table++;
@@ -862,7 +862,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
{
my_error(ER_OPEN_AS_READONLY,MYF(0),table->alias);
/* Clear the lock type of the lock data that are stored already. */
- sql_lock->lock_count= locks - sql_lock->locks;
+ sql_lock->lock_count= (uint) (locks - sql_lock->locks);
reset_lock_data(sql_lock);
my_free((uchar*) sql_lock,MYF(0));
DBUG_RETURN(0);
diff --git a/sql/log.cc b/sql/log.cc
index 74dc75702ae..ed2eff6625d 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -845,6 +845,7 @@ void LOGGER::cleanup_base()
{
table_log_handler->cleanup();
delete table_log_handler;
+ table_log_handler= NULL;
}
if (file_log_handler)
file_log_handler->cleanup();
@@ -855,7 +856,11 @@ void LOGGER::cleanup_end()
{
DBUG_ASSERT(inited == 1);
if (file_log_handler)
+ {
delete file_log_handler;
+ file_log_handler=NULL;
+ }
+ inited= 0;
}
@@ -4650,10 +4655,14 @@ bool flush_error_log()
uchar buf[IO_SIZE];
freopen(err_temp,"a+",stderr);
+ setbuf(stderr, NULL);
(void) my_delete(err_renamed, MYF(0));
my_rename(log_error_file,err_renamed,MYF(0));
if (freopen(log_error_file,"a+",stdout))
+ {
freopen(log_error_file,"a+",stderr);
+ setbuf(stderr, NULL);
+ }
if ((fd = my_open(err_temp, O_RDONLY, MYF(0))) >= 0)
{
@@ -4669,7 +4678,10 @@ bool flush_error_log()
#else
my_rename(log_error_file,err_renamed,MYF(0));
if (freopen(log_error_file,"a+",stdout))
+ {
freopen(log_error_file,"a+",stderr);
+ setbuf(stderr, NULL);
+ }
else
result= 1;
#endif
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 0e400ac2705..1a8cb8ee4fa 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -277,6 +277,47 @@ static void clear_all_errors(THD *thd, Relay_log_info *rli)
rli->clear_error();
}
+inline int idempotent_error_code(int err_code)
+{
+ int ret= 0;
+
+ switch (err_code)
+ {
+ case 0:
+ ret= 1;
+ break;
+ /*
+ The following list of "idempotent" errors
+ means that an error from the list might happen
+ because of idempotent (more than once)
+ applying of a binlog file.
+ Notice, that binlog has a ddl operation its
+ second applying may cause
+
+ case HA_ERR_TABLE_DEF_CHANGED:
+ case HA_ERR_CANNOT_ADD_FOREIGN:
+
+ which are not included into to the list.
+
+ Note that HA_ERR_RECORD_DELETED is not in the list since
+ do_exec_row() should not return that error code.
+ */
+ case HA_ERR_RECORD_CHANGED:
+ case HA_ERR_KEY_NOT_FOUND:
+ case HA_ERR_END_OF_FILE:
+ case HA_ERR_FOUND_DUPP_KEY:
+ case HA_ERR_FOUND_DUPP_UNIQUE:
+ case HA_ERR_FOREIGN_DUPLICATE_KEY:
+ case HA_ERR_NO_REFERENCED_ROW:
+ case HA_ERR_ROW_IS_REFERENCED:
+ ret= 1;
+ break;
+ default:
+ ret= 0;
+ break;
+ }
+ return (ret);
+}
/**
Ignore error code specified on command line.
@@ -301,14 +342,37 @@ inline int ignored_error_code(int err_code)
return ((err_code == ER_SLAVE_IGNORED_TABLE) ||
(use_slave_mask && bitmap_is_set(&slave_error_mask, err_code)));
}
-#endif
+/*
+ This function converts an engine's error to a server error.
+
+ If the thread does not have an error already reported, it tries to
+ define it by calling the engine's method print_error. However, if a
+ mapping is not found, it uses the ER_UNKNOWN_ERROR and prints out a
+ warning message.
+*/
+int convert_handler_error(int error, THD* thd, TABLE *table)
+{
+ uint actual_error= (thd->is_error() ? thd->main_da.sql_errno() :
+ 0);
+
+ if (actual_error == 0)
+ {
+ table->file->print_error(error, MYF(0));
+ actual_error= (thd->is_error() ? thd->main_da.sql_errno() :
+ ER_UNKNOWN_ERROR);
+ if (actual_error == ER_UNKNOWN_ERROR)
+ if (global_system_variables.log_warnings)
+ sql_print_warning("Unknown error detected %d in handler", error);
+ }
+
+ return (actual_error);
+}
/*
pretty_print_str()
*/
-#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
static char *pretty_print_str(char *packet, const char *str, int len)
{
const char *end= str + len;
@@ -354,7 +418,7 @@ static char *slave_load_file_stem(char *buf, uint file_id,
int event_server_id, const char *ext)
{
char *res;
- fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
+ fn_format(buf,PREFIX_SQL_LOAD,slave_load_tmpdir, "", MY_UNPACK_FILENAME);
to_unix_path(buf);
buf = strend(buf);
@@ -382,7 +446,7 @@ static void cleanup_load_tmpdir()
uint i;
char fname[FN_REFLEN], prefbuf[31], *p;
- if (!(dirp=my_dir(slave_load_tmpdir,MYF(MY_WME))))
+ if (!(dirp=my_dir(slave_load_tmpdir,MYF(0))))
return;
/*
@@ -393,7 +457,7 @@ static void cleanup_load_tmpdir()
we cannot meet Start_log event in the middle of events from one
LOAD DATA.
*/
- p= strmake(prefbuf, STRING_WITH_LEN("SQL_LOAD-"));
+ p= strmake(prefbuf, STRING_WITH_LEN(PREFIX_SQL_LOAD));
p= int10_to_str(::server_id, p, 10);
*(p++)= '-';
*p= 0;
@@ -1258,7 +1322,7 @@ void Log_event::print_header(IO_CACHE* file,
my_b_printf(file, "#");
print_timestamp(file);
- my_b_printf(file, " server id %d end_log_pos %s ", server_id,
+ my_b_printf(file, " server id %lu end_log_pos %s ", (ulong) server_id,
llstr(log_pos,llbuff));
/* mysqlbinlog --hexdump */
@@ -1280,7 +1344,7 @@ void Log_event::print_header(IO_CACHE* file,
char emit_buf[256]; // Enough for storing one line
my_b_printf(file, "# Position Timestamp Type Master ID "
"Size Master Pos Flags \n");
- int const bytes_written=
+ size_t const bytes_written=
my_snprintf(emit_buf, sizeof(emit_buf),
"# %8.8lx %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x "
@@ -1289,7 +1353,6 @@ void Log_event::print_header(IO_CACHE* file,
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6],
ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13],
ptr[14], ptr[15], ptr[16], ptr[17], ptr[18]);
- DBUG_ASSERT(bytes_written >= 0);
DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
my_b_write(file, (uchar*) emit_buf, bytes_written);
ptr += LOG_EVENT_MINIMAL_HEADER_LEN;
@@ -1315,12 +1378,11 @@ void Log_event::print_header(IO_CACHE* file,
TODO: Rewrite my_b_printf() to support full printf() syntax.
*/
char emit_buf[256];
- int const bytes_written=
+ size_t const bytes_written=
my_snprintf(emit_buf, sizeof(emit_buf),
"# %8.8lx %-48.48s |%16s|\n",
(unsigned long) (hexdump_from + (i & 0xfffffff0)),
hex_string, char_string);
- DBUG_ASSERT(bytes_written >= 0);
DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
my_b_write(file, (uchar*) emit_buf, bytes_written);
hex_string[0]= 0;
@@ -1335,12 +1397,11 @@ void Log_event::print_header(IO_CACHE* file,
if (hex_string[0])
{
char emit_buf[256];
- int const bytes_written=
+ size_t const bytes_written=
my_snprintf(emit_buf, sizeof(emit_buf),
"# %8.8lx %-48.48s |%s|\n",
(unsigned long) (hexdump_from + (i & 0xfffffff0)),
hex_string, char_string);
- DBUG_ASSERT(bytes_written >= 0);
DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
my_b_write(file, (uchar*) emit_buf, bytes_written);
}
@@ -1628,7 +1689,7 @@ beg:
case MYSQL_TYPE_DATETIME:
{
- uint d, t;
+ size_t d, t;
uint64 i64= uint8korr(ptr); /* YYYYMMDDhhmmss */
d= i64 / 1000000;
t= i64 % 1000000;
@@ -2295,7 +2356,16 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
(thd_arg->is_error() ? thd_arg->main_da.sql_errno() : 0) :
((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 :
thd_arg->killed_errno());
-
+
+ /* thd_arg->main_da.sql_errno() might be ER_SERVER_SHUTDOWN or
+ ER_QUERY_INTERRUPTED, So here we need to make sure that
+ error_code is not set to these errors when specified NOT_KILLED
+ by the caller
+ */
+ if ((killed_status_arg == THD::NOT_KILLED) &&
+ (error_code == ER_SERVER_SHUTDOWN || error_code == ER_QUERY_INTERRUPTED))
+ error_code= 0;
+
time(&end_time);
exec_time = (ulong) (end_time - thd_arg->start_time);
/**
@@ -4198,7 +4268,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
table_name = fields + field_block_len;
db = table_name + table_name_len + 1;
fname = db + db_len + 1;
- fname_len = strlen(fname);
+ fname_len = (uint) strlen(fname);
// null termination is accomplished by the caller doing buf[event_len]=0
DBUG_RETURN(0);
@@ -5697,7 +5767,7 @@ void Slave_log_event::init_from_mem_pool(int data_size)
master_pos = uint8korr(mem_pool + SL_MASTER_POS_OFFSET);
master_port = uint2korr(mem_pool + SL_MASTER_PORT_OFFSET);
master_host = mem_pool + SL_MASTER_HOST_OFFSET;
- master_host_len = strlen(master_host);
+ master_host_len = (uint) strlen(master_host);
// safety
master_log = master_host + master_host_len + 1;
if (master_log > mem_pool + data_size)
@@ -5705,7 +5775,7 @@ void Slave_log_event::init_from_mem_pool(int data_size)
master_host = 0;
return;
}
- master_log_len = strlen(master_log);
+ master_log_len = (uint) strlen(master_log);
}
@@ -6178,6 +6248,12 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
thd_proc_info(thd, proc_info);
if (get_create_or_append())
{
+ /*
+ Usually lex_start() is called by mysql_parse(), but we need it here
+ as the present method does not call mysql_parse().
+ */
+ lex_start(thd);
+ mysql_reset_thd_for_next_command(thd);
my_delete(fname, MYF(0)); // old copy may exist already
if ((fd= my_create(fname, CREATE_MODE,
O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
@@ -6197,6 +6273,10 @@ int Append_block_log_event::do_apply_event(Relay_log_info const *rli)
get_type_str(), fname);
goto err;
}
+
+ DBUG_EXECUTE_IF("remove_slave_load_file_before_write",
+ my_close(fd,MYF(0)); fd= -1; my_delete(fname, MYF(0)););
+
if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP)))
{
rli->report(ERROR_LEVEL, my_errno,
@@ -6618,7 +6698,7 @@ void Execute_load_query_log_event::print(FILE* file,
my_b_printf(&cache, "\'");
if (dup_handling == LOAD_DUP_REPLACE)
my_b_printf(&cache, " REPLACE");
- my_b_printf(&cache, " INTO");
+ my_b_printf(&cache, " INTO ");
my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end);
my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);
}
@@ -6699,7 +6779,7 @@ Execute_load_query_log_event::do_apply_event(Relay_log_info const *rli)
/* Ordinary load data */
break;
}
- p= strmake(p, STRING_WITH_LEN(" INTO"));
+ p= strmake(p, STRING_WITH_LEN(" INTO "));
p= strmake(p, query+fn_pos_end, q_len-fn_pos_end);
error= Query_log_event::do_apply_event(rli, buf, p-buf);
@@ -6986,8 +7066,8 @@ int Rows_log_event::get_data_size()
{
int const type_code= get_type_code();
- uchar buf[sizeof(m_width)+1];
- uchar *end= net_store_length(buf, (m_width + 7) / 8);
+ uchar buf[sizeof(m_width) + 1];
+ uchar *end= net_store_length(buf, m_width);
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
return 6 + no_bytes_in_map(&m_cols) + (end - buf) +
@@ -6995,12 +7075,12 @@ int Rows_log_event::get_data_size()
(m_rows_cur - m_rows_buf););
int data_size= ROWS_HEADER_LEN;
data_size+= no_bytes_in_map(&m_cols);
- data_size+= end - buf;
+ data_size+= (uint) (end - buf);
if (type_code == UPDATE_ROWS_EVENT)
data_size+= no_bytes_in_map(&m_cols_ai);
- data_size+= (m_rows_cur - m_rows_buf);
+ data_size+= (uint) (m_rows_cur - m_rows_buf);
return data_size;
}
@@ -7114,7 +7194,12 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
*/
lex_start(thd);
mysql_reset_thd_for_next_command(thd);
-
+ /*
+ The current statement is just about to begin and
+ has not yet modified anything. Note, all.modified is reset
+ by mysql_reset_thd_for_next_command.
+ */
+ thd->transaction.stmt.modified_non_trans_table= FALSE;
/*
Check if the slave is set to use SBR. If so, it should switch
to using RBR until the end of the "statement", i.e., next
@@ -7151,7 +7236,9 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
{
/*
Error reporting borrowed from Query_log_event with many excessive
- simplifications (we don't honour --slave-skip-errors)
+ simplifications.
+ We should not honour --slave-skip-errors at this point as we are
+ having severe errors which should not be skiped.
*/
rli->report(ERROR_LEVEL, actual_error,
"Error '%s' on opening tables",
@@ -7177,6 +7264,10 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
{
if (ptr->m_tabledef.compatible_with(rli, ptr->table))
{
+ /*
+ We should not honour --slave-skip-errors at this point as we are
+ having severe errors which should not be skiped.
+ */
mysql_unlock_tables(thd, thd->lock);
thd->lock= 0;
thd->is_slave_error= 1;
@@ -7217,6 +7308,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
if (table)
{
+ bool transactional_table= table->file->has_transactions();
/*
table == NULL means that this table should not be replicated
(this was set up by Table_map_log_event::do_apply_event()
@@ -7284,48 +7376,27 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
DBUG_ASSERT(error != HA_ERR_RECORD_DELETED);
table->in_use = old_thd;
- switch (error)
- {
- case 0:
- break;
- /*
- The following list of "idempotent" errors
- means that an error from the list might happen
- because of idempotent (more than once)
- applying of a binlog file.
- Notice, that binlog has a ddl operation its
- second applying may cause
-
- case HA_ERR_TABLE_DEF_CHANGED:
- case HA_ERR_CANNOT_ADD_FOREIGN:
-
- which are not included into to the list.
- Note that HA_ERR_RECORD_DELETED is not in the list since
- do_exec_row() should not return that error code.
- */
- case HA_ERR_RECORD_CHANGED:
- case HA_ERR_KEY_NOT_FOUND:
- case HA_ERR_END_OF_FILE:
- case HA_ERR_FOUND_DUPP_KEY:
- case HA_ERR_FOUND_DUPP_UNIQUE:
- case HA_ERR_FOREIGN_DUPLICATE_KEY:
- case HA_ERR_NO_REFERENCED_ROW:
- case HA_ERR_ROW_IS_REFERENCED:
-
- if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1)
+ if (error)
+ {
+ int actual_error= convert_handler_error(error, thd, table);
+ bool idempotent_error= (idempotent_error_code(error) &&
+ ((bit_is_set(slave_exec_mode,
+ SLAVE_EXEC_MODE_IDEMPOTENT)) == 1));
+ bool ignored_error= (idempotent_error == 0 ?
+ ignored_error_code(actual_error) : 0);
+
+ if (idempotent_error || ignored_error)
{
if (global_system_variables.log_warnings)
slave_rows_error_report(WARNING_LEVEL, error, rli, thd, table,
get_type_str(),
RPL_LOG_NAME, (ulong) log_pos);
+ clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
error= 0;
+ if (idempotent_error == 0)
+ break;
}
- break;
-
- default:
- thd->is_slave_error= 1;
- break;
}
/*
@@ -7339,7 +7410,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
(ulong) m_curr_row, (ulong) m_curr_row_end, (ulong) m_rows_end));
if (!m_curr_row_end && !error)
- unpack_current_row(rli);
+ error= unpack_current_row(rli);
// at this moment m_curr_row_end should be set
DBUG_ASSERT(error || m_curr_row_end != NULL);
@@ -7348,11 +7419,26 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
m_curr_row= m_curr_row_end;
+ if (error == 0 && !transactional_table)
+ thd->transaction.all.modified_non_trans_table=
+ thd->transaction.stmt.modified_non_trans_table= TRUE;
} // row processing loop
DBUG_EXECUTE_IF("STOP_SLAVE_after_first_Rows_event",
const_cast<Relay_log_info*>(rli)->abort_slave= 1;);
- error= do_after_row_operations(rli, error);
+
+ if ((error= do_after_row_operations(rli, error)) &&
+ ignored_error_code(convert_handler_error(error, thd, table)))
+ {
+
+ if (global_system_variables.log_warnings)
+ slave_rows_error_report(WARNING_LEVEL, error, rli, thd, table,
+ get_type_str(),
+ RPL_LOG_NAME, (ulong) log_pos);
+ clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
+ error= 0;
+ }
+
if (!cache_stmt)
{
DBUG_PRINT("info", ("Marked that we need to keep log"));
@@ -7368,36 +7454,21 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
if (error)
- { /* error has occured during the transaction */
- slave_rows_error_report(ERROR_LEVEL, error, rli, thd, table,
- get_type_str(), RPL_LOG_NAME, (ulong) log_pos);
- }
- if (error)
{
- /*
- If one day we honour --skip-slave-errors in row-based replication, and
- the error should be skipped, then we would clear mappings, rollback,
- close tables, but the slave SQL thread would not stop and then may
- assume the mapping is still available, the tables are still open...
- So then we should clear mappings/rollback/close here only if this is a
- STMT_END_F.
- For now we code, knowing that error is not skippable and so slave SQL
- thread is certainly going to stop.
- rollback at the caller along with sbr.
- */
+ slave_rows_error_report(ERROR_LEVEL, error, rli, thd, table,
+ get_type_str(),
+ RPL_LOG_NAME, (ulong) log_pos);
thd->reset_current_stmt_binlog_row_based();
const_cast<Relay_log_info*>(rli)->cleanup_context(thd, error);
thd->is_slave_error= 1;
- DBUG_RETURN(error);
}
-
/*
This code would ideally be placed in do_update_pos() instead, but
since we have no access to table there, we do the setting of
last_event_start_time here instead.
*/
- if (table && (table->s->primary_key == MAX_KEY) &&
- !cache_stmt && get_flags(STMT_END_F) == RLE_NO_FLAGS)
+ else if (table && (table->s->primary_key == MAX_KEY) &&
+ !cache_stmt && get_flags(STMT_END_F) == RLE_NO_FLAGS)
{
/*
------------ Temporary fix until WL#2975 is implemented ---------
@@ -7418,7 +7489,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
const_cast<Relay_log_info*>(rli)->last_event_start_time= my_time(0);
}
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
Log_event::enum_skip_reason
@@ -7576,7 +7647,7 @@ bool Rows_log_event::write_data_body(IO_CACHE*file)
Note that this should be the number of *bits*, not the number of
bytes.
*/
- uchar sbuf[sizeof(m_width)];
+ uchar sbuf[sizeof(m_width) + 1];
my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf;
bool res= false;
uchar *const sbuf_end= net_store_length(sbuf, (size_t) m_width);
@@ -7738,6 +7809,8 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
m_null_bits(0),
m_meta_memory(NULL)
{
+ uchar cbuf[sizeof(m_colcnt) + 1];
+ uchar *cbuf_end;
DBUG_ASSERT(m_table_id != ~0UL);
/*
In TABLE_SHARE, "db" and "table_name" are 0-terminated (see this comment in
@@ -7754,7 +7827,9 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", m_data_size= 6;);
m_data_size+= m_dblen + 2; // Include length and terminating \0
m_data_size+= m_tbllen + 2; // Include length and terminating \0
- m_data_size+= 1 + m_colcnt; // COLCNT and column types
+ cbuf_end= net_store_length(cbuf, (size_t) m_colcnt);
+ DBUG_ASSERT(static_cast<size_t>(cbuf_end - cbuf) <= sizeof(cbuf));
+ m_data_size+= (cbuf_end - cbuf) + m_colcnt; // COLCNT and column types
/* If malloc fails, caught in is_valid() */
if ((m_memory= (uchar*) my_malloc(m_colcnt, MYF(MY_WME))))
@@ -7893,7 +7968,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
memcpy(m_coltype, ptr_after_colcnt, m_colcnt);
ptr_after_colcnt= ptr_after_colcnt + m_colcnt;
- bytes_read= ptr_after_colcnt - (uchar *)buf;
+ bytes_read= (uint) (ptr_after_colcnt - (uchar *)buf);
DBUG_PRINT("info", ("Bytes read: %d.\n", bytes_read));
if (bytes_read < event_len)
{
@@ -8046,7 +8121,7 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file)
uchar const dbuf[]= { (uchar) m_dblen };
uchar const tbuf[]= { (uchar) m_tbllen };
- uchar cbuf[sizeof(m_colcnt)];
+ uchar cbuf[sizeof(m_colcnt) + 1];
uchar *const cbuf_end= net_store_length(cbuf, (size_t) m_colcnt);
DBUG_ASSERT(static_cast<size_t>(cbuf_end - cbuf) <= sizeof(cbuf));
@@ -9176,7 +9251,7 @@ Incident_log_event::Incident_log_event(const char *buf, uint event_len,
// If the incident is not recognized, this binlog event is
// invalid. If we set incident_number to INCIDENT_NONE, the
// invalidity will be detected by is_valid().
- incident_number= INCIDENT_NONE;
+ m_incident= INCIDENT_NONE;
DBUG_VOID_RETURN;
}
m_incident= static_cast<Incident>(incident_number);
@@ -9268,7 +9343,7 @@ bool
Incident_log_event::write_data_body(IO_CACHE *file)
{
DBUG_ENTER("Incident_log_event::write_data_body");
- DBUG_RETURN(write_str(file, m_message.str, m_message.length));
+ DBUG_RETURN(write_str(file, m_message.str, (uint) m_message.length));
}
diff --git a/sql/log_event.h b/sql/log_event.h
index 1d11d7e2d5f..bda53da8ab0 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -47,6 +47,8 @@
#include "rpl_reporting.h"
#endif
+#define PREFIX_SQL_LOAD "SQL_LOAD-"
+
/**
Either assert or return an error.
@@ -3314,7 +3316,7 @@ public:
virtual Log_event_type get_type_code() { return TABLE_MAP_EVENT; }
virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
- virtual int get_data_size() { return m_data_size; }
+ virtual int get_data_size() { return (uint) m_data_size; }
#ifndef MYSQL_CLIENT
virtual int save_field_metadata();
virtual bool write_data_header(IO_CACHE *file);
@@ -3897,7 +3899,7 @@ public:
return m_incident > INCIDENT_NONE && m_incident < INCIDENT_COUNT;
}
virtual int get_data_size() {
- return INCIDENT_HEADER_LEN + 1 + m_message.length;
+ return INCIDENT_HEADER_LEN + 1 + (uint) m_message.length;
}
private:
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 75aa8722aa9..68cd2bf4673 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1382,9 +1382,9 @@ int Old_rows_log_event::get_data_size()
(m_rows_cur - m_rows_buf););
int data_size= ROWS_HEADER_LEN;
data_size+= no_bytes_in_map(&m_cols);
- data_size+= end - buf;
+ data_size+= (uint) (end - buf);
- data_size+= (m_rows_cur - m_rows_buf);
+ data_size+= (uint) (m_rows_cur - m_rows_buf);
return data_size;
}
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 8671f2189bd..31077c63253 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -282,16 +282,12 @@ protected:
*/
#define TABLE_DEF_CACHE_MIN 256
-/*
- Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
- Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86. (Added
- 100 bytes as reasonable buffer against growth and other environments'
- requirements.)
-
- Feel free to raise this by the smallest amount you can to get the
- "execution_constants" test to pass.
- */
-#define STACK_MIN_SIZE 12000 ///< Abort if less stack during eval.
+/*
+ Stack reservation.
+ Feel free to raise this by the smallest amount you can to get the
+ "execution_constants" test to pass.
+*/
+#define STACK_MIN_SIZE 16000 // Abort if less stack during eval.
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
#define STACK_BUFF_ALLOC 352 ///< For stack overrun checks
@@ -367,6 +363,11 @@ protected:
#define PRECISION_FOR_DOUBLE 53
#define PRECISION_FOR_FLOAT 24
+/* -[digits].E+## */
+#define MAX_FLOAT_STR_LENGTH (FLT_DIG + 6)
+/* -[digits].E+### */
+#define MAX_DOUBLE_STR_LENGTH (DBL_DIG + 7)
+
/*
Default time to wait before aborting a new client connection
that does not respond to "initial server greeting" timely
@@ -527,6 +528,20 @@ protected:
#define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2)
#define MODE_PAD_CHAR_TO_FULL_LENGTH (ULL(1) << 31)
+/* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */
+#define OPTIMIZER_SWITCH_INDEX_MERGE 1
+#define OPTIMIZER_SWITCH_INDEX_MERGE_UNION 2
+#define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION 4
+#define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT 8
+#define OPTIMIZER_SWITCH_LAST 16
+
+/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
+#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
+ OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
+ OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
+ OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT)
+
+
/*
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
use strictly more than 64 bits by adding one more define above, you should
@@ -1831,6 +1846,10 @@ extern enum_field_types agg_field_type(Item **items, uint nitems);
/* strfunc.cc */
ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs,
char **err_pos, uint *err_len, bool *set_warning);
+ulonglong find_set_from_flags(TYPELIB *lib, uint default_name,
+ ulonglong cur_set, ulonglong default_set,
+ const char *str, uint length, CHARSET_INFO *cs,
+ char **err_pos, uint *err_len, bool *set_warning);
uint find_type(const TYPELIB *lib, const char *find, uint length,
bool part_match);
uint find_type2(const TYPELIB *lib, const char *find, uint length,
@@ -2053,6 +2072,9 @@ extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
extern SHOW_COMP_OPTION have_crypt;
extern SHOW_COMP_OPTION have_compress;
+extern int orig_argc;
+extern char **orig_argv;
+extern const char *load_default_groups[];
#ifndef __WIN__
extern pthread_t signal_thread;
@@ -2417,7 +2439,8 @@ extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
void kill_delayed_threads(void);
bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
#else
-#define unireg_abort(exit_code) DBUG_RETURN(exit_code)
+extern "C" void unireg_clear(int exit_code);
+#define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0)
inline void kill_delayed_threads(void) {}
#define check_stack_overrun(A, B, C) 0
#endif
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 01d64358d30..140b7d1490d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -188,39 +188,41 @@ int initgroups(const char *,unsigned int);
#ifdef HAVE_FP_EXCEPT // Fix type conflict
typedef fp_except fp_except_t;
#endif
+#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
+#ifdef HAVE_SYS_FPU_H
+/* for IRIX to use set_fpc_csr() */
+#include <sys/fpu.h>
+#endif
-/**
- We can't handle floating point exceptions with threads, so disable
- this on freebsd.
-*/
-inline void set_proper_floating_point_mode()
+inline void setup_fpu()
{
- /* Don't fall for overflow, underflow,divide-by-zero or loss of precision */
+#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
+ /* We can't handle floating point exceptions with threads, so disable
+ this on freebsd
+ Don't fall for overflow, underflow,divide-by-zero or loss of precision
+ */
#if defined(__i386__)
fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ |
FP_X_IMP));
#else
- fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ |
- FP_X_IMP));
-#endif
-}
-#elif defined(__sgi)
-/* for IRIX to use set_fpc_csr() */
-#include <sys/fpu.h>
+ fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ |
+ FP_X_IMP));
+#endif /* __i386__ */
+#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
-inline void set_proper_floating_point_mode()
-{
+#ifdef HAVE_FESETROUND
+ /* Set FPU rounding mode to "round-to-nearest" */
+ fesetround(FE_TONEAREST);
+#endif /* HAVE_FESETROUND */
+
+#if defined(__sgi) && defined(HAVE_SYS_FPU_H)
/* Enable denormalized DOUBLE values support for IRIX */
- {
- union fpc_csr n;
- n.fc_word = get_fpc_csr();
- n.fc_struct.flush = 0;
- set_fpc_csr(n.fc_word);
- }
+ union fpc_csr n;
+ n.fc_word = get_fpc_csr();
+ n.fc_struct.flush = 0;
+ set_fpc_csr(n.fc_word);
+#endif
}
-#else
-#define set_proper_floating_point_mode()
-#endif /* __FreeBSD__ && HAVE_IEEEFP_H */
} /* cplusplus */
@@ -308,6 +310,25 @@ static const unsigned int sql_mode_names_len[]=
TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"",
sql_mode_names,
(unsigned int *)sql_mode_names_len };
+
+static const char *optimizer_switch_names[]=
+{
+ "index_merge","index_merge_union","index_merge_sort_union",
+ "index_merge_intersection", "default", NullS
+};
+/* Corresponding defines are named OPTIMIZER_SWITCH_XXX */
+static const unsigned int optimizer_switch_names_len[]=
+{
+ sizeof("index_merge") - 1,
+ sizeof("index_merge_union") - 1,
+ sizeof("index_merge_sort_union") - 1,
+ sizeof("index_merge_intersection") - 1,
+ sizeof("default") - 1
+};
+TYPELIB optimizer_switch_typelib= { array_elements(optimizer_switch_names)-1,"",
+ optimizer_switch_names,
+ (unsigned int *)optimizer_switch_names_len };
+
static const char *tc_heuristic_recover_names[]=
{
"COMMIT", "ROLLBACK", NullS
@@ -373,6 +394,10 @@ static ulong max_used_connections;
static ulong my_bind_addr; /**< the address we bind to */
static volatile ulong cached_thread_count= 0;
static const char *sql_mode_str= "OFF";
+/* Text representation for OPTIMIZER_SWITCH_DEFAULT */
+static const char *optimizer_switch_str="index_merge=on,index_merge_union=on,"
+ "index_merge_sort_union=on,"
+ "index_merge_intersection=on";
static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr;
static char *opt_init_slave, *language_ptr, *opt_init_connect;
static char *default_character_set_name;
@@ -658,6 +683,9 @@ static int defaults_argc;
static char **defaults_argv;
static char *opt_bin_logname;
+int orig_argc;
+char **orig_argv;
+
static my_socket unix_sock,ip_sock;
struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
@@ -700,6 +728,8 @@ bool mysqld_embedded=0;
bool mysqld_embedded=1;
#endif
+static my_bool plugins_are_initialized= FALSE;
+
#ifndef DBUG_OFF
static const char* default_dbug_option;
#endif
@@ -752,12 +782,12 @@ uint connection_count= 0;
pthread_handler_t signal_hand(void *arg);
static int mysql_init_variables(void);
-static void get_options(int *argc,char **argv);
+static int get_options(int *argc,char **argv);
extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *);
static void set_server_version(void);
static int init_thread_environment();
static char *get_relative_path(const char *path);
-static void fix_paths(void);
+static int fix_paths(void);
pthread_handler_t handle_connections_sockets(void *arg);
pthread_handler_t kill_server_thread(void *arg);
static void bootstrap(FILE *file);
@@ -771,7 +801,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg);
pthread_handler_t handle_slave(void *arg);
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
- const char *option);
+ const char *option, int *error);
static void clean_up(bool print_message);
static int test_if_case_insensitive(const char *dir_name);
@@ -1184,10 +1214,10 @@ extern "C" void unireg_abort(int exit_code)
{
DBUG_ENTER("unireg_abort");
+ if (opt_help)
+ usage();
if (exit_code)
sql_print_error("Aborting\n");
- else if (opt_help)
- usage();
clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
DBUG_PRINT("quit",("done with cleanup in unireg_abort"));
wait_for_signal_thread_to_end();
@@ -1195,7 +1225,8 @@ extern "C" void unireg_abort(int exit_code)
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
exit(exit_code); /* purecov: inspected */
}
-#endif
+
+#endif /*EMBEDDED_LIBRARY*/
void clean_up(bool print_message)
@@ -2934,18 +2965,16 @@ pthread_handler_t handle_shutdown(void *arg)
}
#endif
-#if !defined(EMBEDDED_LIBRARY)
-static const char *load_default_groups[]= {
+const char *load_default_groups[]= {
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
"mysql_cluster",
#endif
"mysqld","server", MYSQL_BASE_VERSION, 0, 0};
-#if defined(__WIN__)
+#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
static const int load_default_groups_sz=
sizeof(load_default_groups)/sizeof(load_default_groups[0]);
#endif
-#endif /*!EMBEDDED_LIBRARY*/
/**
@@ -3233,10 +3262,13 @@ static int init_common_variables(const char *conf_file_name, int argc,
SQLCOM_END + 8);
#endif
+ orig_argc=argc;
+ orig_argv=argv;
load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv;
defaults_argc=argc;
- get_options(&defaults_argc, defaults_argv);
+ if (get_options(&defaults_argc, defaults_argv))
+ return 1;
set_server_version();
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
@@ -3760,7 +3792,7 @@ static int init_server_components()
query_cache_init();
query_cache_resize(query_cache_size);
randominit(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
- set_proper_floating_point_mode();
+ setup_fpu();
init_thr_lock();
#ifdef HAVE_REPLICATION
init_slave_list();
@@ -3788,7 +3820,10 @@ static int init_server_components()
#ifndef EMBEDDED_LIBRARY
if (freopen(log_error_file, "a+", stdout))
#endif
+ {
freopen(log_error_file, "a+", stderr);
+ setbuf(stderr, NULL);
+ }
}
}
@@ -3934,12 +3969,15 @@ server.");
if (ha_init_errors())
DBUG_RETURN(1);
- if (plugin_init(&defaults_argc, defaults_argv,
- (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
- (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
- {
- sql_print_error("Failed to initialize plugins.");
- unireg_abort(1);
+ {
+ if (plugin_init(&defaults_argc, defaults_argv,
+ (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
+ (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
+ {
+ sql_print_error("Failed to initialize plugins.");
+ unireg_abort(1);
+ }
+ plugins_are_initialized= TRUE; /* Don't separate from init function */
}
if (opt_help)
@@ -3965,6 +4003,7 @@ server.");
if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts,
mysqld_get_one_option)))
unireg_abort(ho_error);
+ my_getopt_skip_unknown= TRUE;
if (defaults_argc)
{
@@ -4413,6 +4452,7 @@ we force server id to 2, but this MySQL server will not act as a slave.");
{
freopen(log_error_file,"a+",stdout);
freopen(log_error_file,"a+",stderr);
+ setbuf(stderr, NULL);
FreeConsole(); // Remove window
}
#endif
@@ -5651,6 +5691,7 @@ enum options_mysqld
OPT_SYSDATE_IS_NOW,
OPT_OPTIMIZER_SEARCH_DEPTH,
OPT_OPTIMIZER_PRUNE_LEVEL,
+ OPT_OPTIMIZER_SWITCH,
OPT_UPDATABLE_VIEWS_WITH_LIMIT,
OPT_SP_AUTOMATIC_PRIVILEGES,
OPT_MAX_SP_RECURSION_DEPTH,
@@ -6333,7 +6374,7 @@ Can't be set to 1 if --log-slave-updates is used.",
GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"server-id", OPT_SERVER_ID,
"Uniquely identifies the server instance in the community of replication partners.",
- (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
+ (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, UINT_MAX32,
0, 0, 0},
{"set-variable", 'O',
"Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.",
@@ -6809,6 +6850,13 @@ The minimum value for this variable is 4096.",
(uchar**) &global_system_variables.optimizer_search_depth,
(uchar**) &max_system_variables.optimizer_search_depth,
0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
+ {"optimizer_switch", OPT_OPTIMIZER_SWITCH,
+ "optimizer_switch=option=val[,option=val...], where option={index_merge, "
+ "index_merge_union, index_merge_sort_union, index_merge_intersection} and "
+ "val={on, off, default}.",
+ (uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG,
+ /*OPTIMIZER_SWITCH_DEFAULT*/0,
+ 0, 0, 0, 0, 0},
{"plugin_dir", OPT_PLUGIN_DIR,
"Directory for plugins.",
(uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0,
@@ -7518,7 +7566,8 @@ static void usage(void)
default_collation_name= (char*) default_charset_info->name;
print_version();
puts("\
-Copyright (C) 2000 MySQL AB, by Monty and others\n\
+Copyright (C) 2000-2008 MySQL AB, by Monty and others\n\
+Copyright (C) 2008 Sun Microsystems, Inc.\n\
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
and you are welcome to modify and redistribute it under the GPL license\n\n\
Starts the MySQL database server\n");
@@ -7548,6 +7597,13 @@ Starts the MySQL database server\n");
/* Print out all the options including plugin supplied options */
my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option));
+ if (! plugins_are_initialized)
+ {
+ puts("\n\
+Plugins have parameters that are not reflected in this list\n\
+because execution stopped before plugins were initialized.");
+ }
+
puts("\n\
To see what values a running MySQL server is using, type\n\
'mysqladmin variables' instead of 'mysqld --verbose --help'.");
@@ -7574,6 +7630,7 @@ To see what values a running MySQL server is using, type\n\
static int mysql_init_variables(void)
{
+ int error;
/* Things reset to zero */
opt_skip_slave_start= opt_reckless_slave = 0;
mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
@@ -7632,7 +7689,10 @@ static int mysql_init_variables(void)
delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
slave_exec_mode_options= 0;
slave_exec_mode_options= (uint)
- find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL);
+ find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL,
+ &error);
+ if (error)
+ return 1;
opt_specialflag= SPECIAL_ENGLISH;
unix_sock= ip_sock= INVALID_SOCKET;
mysql_home_ptr= mysql_home;
@@ -7703,7 +7763,8 @@ static int mysql_init_variables(void)
when collecting index statistics for MyISAM tables.
*/
global_system_variables.myisam_stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
-
+
+ global_system_variables.optimizer_switch= OPTIMIZER_SWITCH_DEFAULT;
/* Variables that depends on compile options */
#ifndef DBUG_OFF
default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
@@ -7810,6 +7871,8 @@ mysqld_get_one_option(int optid,
const struct my_option *opt __attribute__((unused)),
char *argument)
{
+ int error;
+
switch(optid) {
case '#':
#ifndef DBUG_OFF
@@ -7853,7 +7916,9 @@ mysqld_get_one_option(int optid,
break;
case OPT_SLAVE_EXEC_MODE:
slave_exec_mode_options= (uint)
- find_bit_type_or_exit(argument, &slave_exec_mode_typelib, "");
+ find_bit_type_or_exit(argument, &slave_exec_mode_typelib, "", &error);
+ if (error)
+ return 1;
break;
#endif
case OPT_SAFEMALLOC_MEM_LIMIT:
@@ -7921,18 +7986,16 @@ mysqld_get_one_option(int optid,
if (!(p= strstr(argument, "->")))
{
- fprintf(stderr,
- "Bad syntax in replicate-rewrite-db - missing '->'!\n");
- exit(1);
+ sql_print_error("Bad syntax in replicate-rewrite-db - missing '->'!\n");
+ return 1;
}
val= p--;
while (my_isspace(mysqld_charset, *p) && p > argument)
*p-- = 0;
if (p == argument)
{
- fprintf(stderr,
- "Bad syntax in replicate-rewrite-db - empty FROM db!\n");
- exit(1);
+ sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db!\n");
+ return 1;
}
*val= 0;
val+= 2;
@@ -7940,9 +8003,8 @@ mysqld_get_one_option(int optid,
*val++;
if (!*val)
{
- fprintf(stderr,
- "Bad syntax in replicate-rewrite-db - empty TO db!\n");
- exit(1);
+ sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db!\n");
+ return 1;
}
rpl_filter->add_db_rewrite(key, val);
@@ -7970,8 +8032,8 @@ mysqld_get_one_option(int optid,
{
if (rpl_filter->add_do_table(argument))
{
- fprintf(stderr, "Could not add do table rule '%s'!\n", argument);
- exit(1);
+ sql_print_error("Could not add do table rule '%s'!\n", argument);
+ return 1;
}
break;
}
@@ -7979,8 +8041,8 @@ mysqld_get_one_option(int optid,
{
if (rpl_filter->add_wild_do_table(argument))
{
- fprintf(stderr, "Could not add do table rule '%s'!\n", argument);
- exit(1);
+ sql_print_error("Could not add do table rule '%s'!\n", argument);
+ return 1;
}
break;
}
@@ -7988,8 +8050,8 @@ mysqld_get_one_option(int optid,
{
if (rpl_filter->add_wild_ignore_table(argument))
{
- fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument);
- exit(1);
+ sql_print_error("Could not add ignore table rule '%s'!\n", argument);
+ return 1;
}
break;
}
@@ -7997,8 +8059,8 @@ mysqld_get_one_option(int optid,
{
if (rpl_filter->add_ignore_table(argument))
{
- fprintf(stderr, "Could not add ignore table rule '%s'!\n", argument);
- exit(1);
+ sql_print_error("Could not add ignore table rule '%s'!\n", argument);
+ return 1;
}
break;
}
@@ -8019,7 +8081,9 @@ mysqld_get_one_option(int optid,
{
log_output_str= argument;
log_output_options=
- find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
+ find_bit_type_or_exit(argument, &log_output_typelib, opt->name, &error);
+ if (error)
+ return 1;
}
break;
}
@@ -8029,7 +8093,7 @@ mysqld_get_one_option(int optid,
sql_perror("Event scheduler is not supported in embedded build.");
#else
if (Events::set_opt_event_scheduler(argument))
- exit(1);
+ return 1;
#endif
break;
case (int) OPT_SKIP_NEW:
@@ -8068,7 +8132,7 @@ mysqld_get_one_option(int optid,
case (int) OPT_SKIP_NETWORKING:
#if defined(__NETWARE__)
sql_perror("Can't start server: skip-networking option is currently not supported on NetWare");
- exit(1);
+ return 1;
#endif
opt_disable_networking=1;
mysqld_port=0;
@@ -8136,7 +8200,7 @@ mysqld_get_one_option(int optid,
if (!slave_warning_issued) //only show the warning once
{
slave_warning_issued = true;
- WARN_DEPRECATED(NULL, "5.2", "for replication startup options",
+ WARN_DEPRECATED(NULL, "6.0", "for replication startup options",
"'CHANGE MASTER'");
}
break;
@@ -8239,7 +8303,10 @@ mysqld_get_one_option(int optid,
{
myisam_recover_options_str=argument;
myisam_recover_options=
- find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
+ find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name,
+ &error);
+ if (error)
+ return 1;
}
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
break;
@@ -8284,11 +8351,36 @@ mysqld_get_one_option(int optid,
{
sql_mode_str= argument;
global_system_variables.sql_mode=
- find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name);
+ find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name, &error);
+ if (error)
+ return 1;
global_system_variables.sql_mode= fix_sql_mode(global_system_variables.
sql_mode);
break;
}
+ case OPT_OPTIMIZER_SWITCH:
+ {
+ bool not_used;
+ char *error= 0;
+ uint error_len= 0;
+ optimizer_switch_str= argument;
+ global_system_variables.optimizer_switch=
+ (ulong)find_set_from_flags(&optimizer_switch_typelib,
+ optimizer_switch_typelib.count,
+ global_system_variables.optimizer_switch,
+ global_system_variables.optimizer_switch,
+ argument, strlen(argument), NULL,
+ &error, &error_len, &not_used);
+ if (error)
+ {
+ char buf[512];
+ char *cbuf= buf;
+ cbuf += my_snprintf(buf, 512, "Error in parsing optimizer_switch setting near %*s\n", error_len, error);
+ sql_perror(buf);
+ return 1;
+ }
+ break;
+ }
case OPT_ONE_THREAD:
global_system_variables.thread_handling=
SCHEDULER_ONE_THREAD_PER_CONNECTION;
@@ -8323,13 +8415,17 @@ mysqld_get_one_option(int optid,
/** Handle arguments for multiple key caches. */
-extern "C" uchar **mysql_getopt_value(const char *keyname, uint key_length,
- const struct my_option *option);
+extern "C" int mysql_getopt_value(uchar **value,
+ const char *keyname, uint key_length,
+ const struct my_option *option,
+ int *error);
-uchar* *
+static uchar* *
mysql_getopt_value(const char *keyname, uint key_length,
- const struct my_option *option)
+ const struct my_option *option, int *error)
{
+ if (error)
+ *error= 0;
switch (option->id) {
case OPT_KEY_BUFFER_SIZE:
case OPT_KEY_CACHE_BLOCK_SIZE:
@@ -8338,7 +8434,11 @@ mysql_getopt_value(const char *keyname, uint key_length,
{
KEY_CACHE *key_cache;
if (!(key_cache= get_or_create_key_cache(keyname, key_length)))
- exit(1);
+ {
+ if (error)
+ *error= EXIT_OUT_OF_MEMORY;
+ return 0;
+ }
switch (option->id) {
case OPT_KEY_BUFFER_SIZE:
return (uchar**) &key_cache->param_buff_size;
@@ -8376,7 +8476,7 @@ void option_error_reporter(enum loglevel level, const char *format, ...)
@todo
- FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code?
*/
-static void get_options(int *argc,char **argv)
+static int get_options(int *argc,char **argv)
{
int ho_error;
@@ -8390,7 +8490,7 @@ static void get_options(int *argc,char **argv)
if ((ho_error= handle_options(argc, &argv, my_long_options,
mysqld_get_one_option)))
- exit(ho_error);
+ return ho_error;
(*argc)++; /* add back one for the progname handle_options removes */
/* no need to do this for argv as we are discarding it. */
@@ -8429,7 +8529,8 @@ static void get_options(int *argc,char **argv)
max_allowed_packet= global_system_variables.max_allowed_packet;
net_buffer_length= global_system_variables.net_buffer_length;
#endif
- fix_paths();
+ if (fix_paths())
+ return 1;
/*
Set some global variables from the global_system_variables
@@ -8456,7 +8557,7 @@ static void get_options(int *argc,char **argv)
&global_system_variables.time_format) ||
init_global_datetime_format(MYSQL_TIMESTAMP_DATETIME,
&global_system_variables.datetime_format))
- exit(1);
+ return 1;
#ifdef EMBEDDED_LIBRARY
one_thread_scheduler(&thread_scheduler);
@@ -8469,6 +8570,7 @@ static void get_options(int *argc,char **argv)
else
pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */
#endif
+ return 0;
}
@@ -8532,7 +8634,7 @@ fn_format_relative_to_data_home(char * to, const char *name,
}
-static void fix_paths(void)
+static int fix_paths(void)
{
char buff[FN_REFLEN],*pos;
convert_dirname(mysql_home,mysql_home,NullS);
@@ -8579,12 +8681,12 @@ static void fix_paths(void)
charsets_dir=mysql_charsets_dir;
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
- exit(1);
+ return 1;
#ifdef HAVE_REPLICATION
if (!slave_load_tmpdir)
{
if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE))))
- exit(1);
+ return 1;
}
#endif /* HAVE_REPLICATION */
/*
@@ -8597,30 +8699,37 @@ static void fix_paths(void)
my_free(opt_secure_file_priv, MYF(0));
opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
}
+ return 0;
}
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
- const char *option)
+ const char *option, int *error)
{
- ulong res;
-
+ ulong result;
const char **ptr;
- if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0)
+ *error= 0;
+ if ((result= find_bit_type(x, bit_lib)) == ~(ulong) 0)
{
+ char *buff= (char *) my_alloca(2048);
+ char *cbuf;
ptr= bit_lib->type_names;
- if (!*x)
- fprintf(stderr, "No option given to %s\n", option);
- else
- fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x);
- fprintf(stderr, "Alternatives are: '%s'", *ptr);
+ cbuf= buff + ((!*x) ?
+ my_snprintf(buff, 2048, "No option given to %s\n", option) :
+ my_snprintf(buff, 2048, "Wrong option to %s. Option(s) given: %s\n",
+ option, x));
+ cbuf+= my_snprintf(cbuf, 2048 - (cbuf-buff), "Alternatives are: '%s'", *ptr);
while (*++ptr)
- fprintf(stderr, ",'%s'", *ptr);
- fprintf(stderr, "\n");
- exit(1);
+ cbuf+= my_snprintf(cbuf, 2048 - (cbuf-buff), ",'%s'", *ptr);
+ my_snprintf(cbuf, 2048 - (cbuf-buff), "\n");
+ sql_perror(buff);
+ *error= 1;
+ my_afree(buff);
+ return 0;
}
- return res;
+
+ return result;
}
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index ed47e4b9c7b..8ee819bcbda 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -250,7 +250,7 @@ static int net_data_is_ready(my_socket sd)
tv.tv_sec= tv.tv_usec= 0;
- if ((res= select(sd+1, &sfds, NULL, NULL, &tv)) < 0)
+ if ((res= select((int) (sd + 1), &sfds, NULL, NULL, &tv)) < 0)
return 0;
else
return test(res ? FD_ISSET(sd, &sfds) : 0);
@@ -443,7 +443,7 @@ net_write_command(NET *net,uchar command,
const uchar *header, size_t head_len,
const uchar *packet, size_t len)
{
- ulong length=len+1+head_len; /* 1 extra byte for command */
+ size_t length=len+1+head_len; /* 1 extra byte for command */
uchar buff[NET_HEADER_SIZE+1];
uint header_size=NET_HEADER_SIZE+1;
int rc;
@@ -517,7 +517,7 @@ net_write_buff(NET *net, const uchar *packet, ulong len)
{
ulong left_length;
if (net->compress && net->max_packet > MAX_PACKET_LENGTH)
- left_length= MAX_PACKET_LENGTH - (net->write_pos - net->buff);
+ left_length= (ulong) (MAX_PACKET_LENGTH - (net->write_pos - net->buff));
else
left_length= (ulong) (net->buff_end - net->write_pos);
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 9f8f17eb4ba..147874611ce 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2386,7 +2386,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
objects are not allowed so don't use ROR-intersection for
table deletes.
*/
- if ((thd->lex->sql_command != SQLCOM_DELETE))
+ if ((thd->lex->sql_command != SQLCOM_DELETE) &&
+ optimizer_flag(thd, OPTIMIZER_SWITCH_INDEX_MERGE))
{
/*
Get best non-covering ROR-intersection plan and prepare data for
@@ -2410,25 +2411,28 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
}
else
{
- /* Try creating index_merge/ROR-union scan. */
- SEL_IMERGE *imerge;
- TABLE_READ_PLAN *best_conj_trp= NULL, *new_conj_trp;
- LINT_INIT(new_conj_trp); /* no empty index_merge lists possible */
- DBUG_PRINT("info",("No range reads possible,"
- " trying to construct index_merge"));
- List_iterator_fast<SEL_IMERGE> it(tree->merges);
- while ((imerge= it++))
+ if (optimizer_flag(thd, OPTIMIZER_SWITCH_INDEX_MERGE))
{
- new_conj_trp= get_best_disjunct_quick(&param, imerge, best_read_time);
- if (new_conj_trp)
- set_if_smaller(param.table->quick_condition_rows,
- new_conj_trp->records);
- if (!best_conj_trp || (new_conj_trp && new_conj_trp->read_cost <
- best_conj_trp->read_cost))
- best_conj_trp= new_conj_trp;
+ /* Try creating index_merge/ROR-union scan. */
+ SEL_IMERGE *imerge;
+ TABLE_READ_PLAN *best_conj_trp= NULL, *new_conj_trp;
+ LINT_INIT(new_conj_trp); /* no empty index_merge lists possible */
+ DBUG_PRINT("info",("No range reads possible,"
+ " trying to construct index_merge"));
+ List_iterator_fast<SEL_IMERGE> it(tree->merges);
+ while ((imerge= it++))
+ {
+ new_conj_trp= get_best_disjunct_quick(&param, imerge, best_read_time);
+ if (new_conj_trp)
+ set_if_smaller(param.table->quick_condition_rows,
+ new_conj_trp->records);
+ if (!best_conj_trp || (new_conj_trp && new_conj_trp->read_cost <
+ best_conj_trp->read_cost))
+ best_conj_trp= new_conj_trp;
+ }
+ if (best_conj_trp)
+ best_trp= best_conj_trp;
}
- if (best_conj_trp)
- best_trp= best_conj_trp;
}
}
@@ -3767,11 +3771,19 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
"full table scan, bailing out"));
DBUG_RETURN(NULL);
}
- if (all_scans_rors)
+
+ /*
+ If all scans happen to be ROR, proceed to generate a ROR-union plan (it's
+ guaranteed to be cheaper than non-ROR union), unless ROR-unions are
+ disabled in @@optimizer_switch
+ */
+ if (all_scans_rors &&
+ optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_UNION))
{
roru_read_plans= (TABLE_READ_PLAN**)range_scans;
goto skip_to_ror_scan;
}
+
if (cpk_scan)
{
/*
@@ -3785,8 +3797,11 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
imerge_cost += get_sweep_read_cost(param, non_cpk_scan_records);
DBUG_PRINT("info",("index_merge cost with rowid-to-row scan: %g",
imerge_cost));
- if (imerge_cost > read_time)
+ if (imerge_cost > read_time ||
+ !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION))
+ {
goto build_ror_index_merge;
+ }
/* Add Unique operations cost */
unique_calc_buff_size=
@@ -3822,7 +3837,9 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
}
build_ror_index_merge:
- if (!all_scans_ror_able || param->thd->lex->sql_command == SQLCOM_DELETE)
+ if (!all_scans_ror_able ||
+ param->thd->lex->sql_command == SQLCOM_DELETE ||
+ !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_UNION))
DBUG_RETURN(imerge_trp);
/* Ok, it is possible to build a ROR-union, try it. */
@@ -4495,7 +4512,8 @@ TRP_ROR_INTERSECT *get_best_ror_intersect(const PARAM *param, SEL_TREE *tree,
double min_cost= DBL_MAX;
DBUG_ENTER("get_best_ror_intersect");
- if ((tree->n_ror_scans < 2) || !param->table->file->stats.records)
+ if ((tree->n_ror_scans < 2) || !param->table->file->stats.records ||
+ !optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT))
DBUG_RETURN(NULL);
/*
@@ -4685,6 +4703,9 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
ROR_SCAN_INFO **ror_scans_end= tree->ror_scans_end;
DBUG_ENTER("get_best_covering_ror_intersect");
+ if (!optimizer_flag(param->thd, OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT))
+ DBUG_RETURN(NULL);
+
for (ROR_SCAN_INFO **scan= tree->ror_scans; scan != ror_scans_end; ++scan)
(*scan)->key_components=
param->table->key_info[(*scan)->keynr].key_parts;
@@ -9239,32 +9260,37 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/
KEY *cur_index_info= table->key_info;
KEY *cur_index_info_end= cur_index_info + table->s->keys;
- KEY_PART_INFO *cur_part= NULL;
- KEY_PART_INFO *end_part; /* Last part for loops. */
- /* Last index part. */
- KEY_PART_INFO *last_part= NULL;
- KEY_PART_INFO *first_non_group_part= NULL;
- KEY_PART_INFO *first_non_infix_part= NULL;
- uint key_infix_parts= 0;
- uint cur_group_key_parts= 0;
- uint cur_group_prefix_len= 0;
/* Cost-related variables for the best index so far. */
double best_read_cost= DBL_MAX;
ha_rows best_records= 0;
SEL_ARG *best_index_tree= NULL;
ha_rows best_quick_prefix_records= 0;
uint best_param_idx= 0;
- double cur_read_cost= DBL_MAX;
- ha_rows cur_records;
+
+ const uint pk= param->table->s->primary_key;
SEL_ARG *cur_index_tree= NULL;
ha_rows cur_quick_prefix_records= 0;
uint cur_param_idx=MAX_KEY;
- key_map cur_used_key_parts;
- uint pk= param->table->s->primary_key;
for (uint cur_index= 0 ; cur_index_info != cur_index_info_end ;
cur_index_info++, cur_index++)
{
+ KEY_PART_INFO *cur_part;
+ KEY_PART_INFO *end_part; /* Last part for loops. */
+ /* Last index part. */
+ KEY_PART_INFO *last_part;
+ KEY_PART_INFO *first_non_group_part;
+ KEY_PART_INFO *first_non_infix_part;
+ uint key_infix_parts;
+ uint cur_group_key_parts= 0;
+ uint cur_group_prefix_len= 0;
+ double cur_read_cost;
+ ha_rows cur_records;
+ key_map used_key_parts_map;
+ uint cur_key_infix_len= 0;
+ uchar cur_key_infix[MAX_KEY_LENGTH];
+ uint cur_used_key_parts;
+
/* Check (B1) - if current index is covering. */
if (!table->covering_keys.is_set(cur_index))
goto next_index;
@@ -9334,7 +9360,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
else if (join->select_distinct)
{
select_items_it.rewind();
- cur_used_key_parts.clear_all();
+ used_key_parts_map.clear_all();
uint max_key_part= 0;
while ((item= select_items_it++))
{
@@ -9345,13 +9371,13 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
Check if this attribute was already present in the select list.
If it was present, then its corresponding key part was alredy used.
*/
- if (cur_used_key_parts.is_set(key_part_nr))
+ if (used_key_parts_map.is_set(key_part_nr))
continue;
if (key_part_nr < 1 || key_part_nr > join->fields_list.elements)
goto next_index;
cur_part= cur_index_info->key_part + key_part_nr - 1;
cur_group_prefix_len+= cur_part->store_length;
- cur_used_key_parts.set_bit(key_part_nr);
+ used_key_parts_map.set_bit(key_part_nr);
++cur_group_key_parts;
max_key_part= max(max_key_part,key_part_nr);
}
@@ -9363,7 +9389,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/
ulonglong all_parts, cur_parts;
all_parts= (1<<max_key_part) - 1;
- cur_parts= cur_used_key_parts.to_ulonglong() >> 1;
+ cur_parts= used_key_parts_map.to_ulonglong() >> 1;
if (all_parts != cur_parts)
goto next_index;
}
@@ -9413,7 +9439,8 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
&dummy);
if (!get_constant_key_infix(cur_index_info, index_range_tree,
first_non_group_part, min_max_arg_part,
- last_part, thd, key_infix, &key_infix_len,
+ last_part, thd, cur_key_infix,
+ &cur_key_infix_len,
&first_non_infix_part))
goto next_index;
}
@@ -9467,9 +9494,9 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
}
/* If we got to this point, cur_index_info passes the test. */
- key_infix_parts= key_infix_len ?
+ key_infix_parts= cur_key_infix_len ? (uint)
(first_non_infix_part - first_non_group_part) : 0;
- used_key_parts= cur_group_key_parts + key_infix_parts;
+ cur_used_key_parts= cur_group_key_parts + key_infix_parts;
/* Compute the cost of using this index. */
if (tree)
@@ -9481,7 +9508,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
cur_quick_prefix_records= check_quick_select(param, cur_param_idx,
cur_index_tree, TRUE);
}
- cost_group_min_max(table, cur_index_info, used_key_parts,
+ cost_group_min_max(table, cur_index_info, cur_used_key_parts,
cur_group_key_parts, tree, cur_index_tree,
cur_quick_prefix_records, have_min, have_max,
&cur_read_cost, &cur_records);
@@ -9492,7 +9519,6 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
*/
if (cur_read_cost < best_read_cost - (DBL_EPSILON * cur_read_cost))
{
- DBUG_ASSERT(tree != 0 || cur_param_idx == MAX_KEY);
index_info= cur_index_info;
index= cur_index;
best_read_cost= cur_read_cost;
@@ -9502,11 +9528,13 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
best_param_idx= cur_param_idx;
group_key_parts= cur_group_key_parts;
group_prefix_len= cur_group_prefix_len;
+ key_infix_len= cur_key_infix_len;
+ if (key_infix_len)
+ memcpy (key_infix, cur_key_infix, sizeof (key_infix));
+ used_key_parts= cur_used_key_parts;
}
- next_index:
- cur_group_key_parts= 0;
- cur_group_prefix_len= 0;
+ next_index:;
}
if (!index_info) /* No usable index found. */
DBUG_RETURN(NULL);
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 07ea434e8e0..f2dbeba1bbf 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -302,6 +302,7 @@ err_w_file:
@thd thread handler
@param schema name of given schema
@param old_name original file name
+ @param new_db new schema
@param new_name new file name
@retval
@@ -311,14 +312,14 @@ err_w_file:
*/
my_bool rename_in_schema_file(THD *thd,
const char *schema, const char *old_name,
- const char *new_name)
+ const char *new_db, const char *new_name)
{
char old_path[FN_REFLEN], new_path[FN_REFLEN], arc_path[FN_REFLEN];
build_table_filename(old_path, sizeof(old_path) - 1,
schema, old_name, reg_ext, 0);
build_table_filename(new_path, sizeof(new_path) - 1,
- schema, new_name, reg_ext, 0);
+ new_db, new_name, reg_ext, 0);
if (my_rename(old_path, new_path, MYF(MY_WME)))
return 1;
diff --git a/sql/parse_file.h b/sql/parse_file.h
index cfac69cc471..84647e45927 100644
--- a/sql/parse_file.h
+++ b/sql/parse_file.h
@@ -83,7 +83,7 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name,
uchar* base, File_option *parameters);
my_bool rename_in_schema_file(THD *thd,
const char *schema, const char *old_name,
- const char *new_name);
+ const char *new_db, const char *new_name);
class File_parser: public Sql_alloc
{
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 4177cd0054d..16975c68a54 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -573,7 +573,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
else
{
/* With conversion */
- uint max_char_len;
+ ulonglong max_length;
+ uint32 field_length;
int2store(pos, thd_charset->number);
/*
For TEXT/BLOB columns, field_length describes the maximum data
@@ -584,12 +585,22 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
char_count * mbmaxlen, where character count is taken from the
definition of the column. In other words, the maximum number
of characters here is limited by the column definition.
+
+ When one has a LONG TEXT column with a single-byte
+ character set, and the connection character set is multi-byte, the
+ client may get fields longer than UINT_MAX32, due to
+ <character set column> -> <character set connection> conversion.
+ In that case column max length does not fit into the 4 bytes
+ reserved for it in the protocol.
*/
- max_char_len= (field.type >= (int) MYSQL_TYPE_TINY_BLOB &&
- field.type <= (int) MYSQL_TYPE_BLOB) ?
- field.length / item->collation.collation->mbminlen :
- field.length / item->collation.collation->mbmaxlen;
- int4store(pos+2, max_char_len * thd_charset->mbmaxlen);
+ max_length= (field.type >= MYSQL_TYPE_TINY_BLOB &&
+ field.type <= MYSQL_TYPE_BLOB) ?
+ field.length / item->collation.collation->mbminlen :
+ field.length / item->collation.collation->mbmaxlen;
+ max_length*= thd_charset->mbmaxlen;
+ field_length= (max_length > UINT_MAX32) ?
+ UINT_MAX32 : (uint32) max_length;
+ int4store(pos + 2, field_length);
}
pos[6]= field.type;
int2store(pos+7,field.flags);
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index fb609e12dcb..3004a3905e5 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -340,8 +340,7 @@ Rpl_filter::add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec)
e->tbl_name= e->db + (dot - table_spec) + 1;
e->key_len= len;
memcpy(e->db, table_spec, len);
- insert_dynamic(a, (uchar*)&e);
- return 0;
+ return insert_dynamic(a, (uchar*)&e);
}
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index 7c74dcba5a0..14a80cbb4b6 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -297,21 +297,16 @@ unpack_row(Relay_log_info const *rli,
/**
Fills @c table->record[0] with default values.
- First @c empty_record() is called and then, additionally, fields are
- initialized explicitly with a call to @c set_default().
-
- For optimization reasons, the explicit initialization can be skipped for
- first @c skip fields. This is useful if later we are going to fill these
- fields from other source (e.g. from a Rows replication event).
-
- If @c check is true, fields are explicitly initialized only if they have
- default value or can be NULL. Otherwise error is reported.
+ First @c restore_record() is called to restore the default values for
+ record concerning the given table. Then, if @c check is true,
+ a check is performed to see if fields are have default value or can
+ be NULL. Otherwise error is reported.
@param table Table whose record[0] buffer is prepared.
- @param skip Number of columns for which default value initialization
+ @param skip Number of columns for which default/nullable check
should be skipped.
- @param check Indicates if errors should be checked when setting default
- values.
+ @param check Indicates if errors should be raised when checking
+ default/nullable field properties.
@returns 0 on success or a handler level error code
*/
@@ -321,25 +316,28 @@ int prepare_record(TABLE *const table,
DBUG_ENTER("prepare_record");
int error= 0;
- empty_record(table);
+ restore_record(table, s->default_values);
- if (skip >= table->s->fields) // nothing to do
+ /*
+ This skip should be revisited in 6.0, because in 6.0 RBR one
+ can have holes in the row (as the grain of the writeset is
+ the column and not the entire row).
+ */
+ if (skip >= table->s->fields || !check)
DBUG_RETURN(0);
- /* Explicit initialization of fields */
+ /* Checking if exists default/nullable fields in the default values. */
for (Field **field_ptr= table->field+skip ; *field_ptr ; ++field_ptr)
{
uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG;
Field *const f= *field_ptr;
- if (check && ((f->flags & mask) == mask))
+ if (((f->flags & mask) == mask))
{
my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), f->field_name);
error = HA_ERR_ROWS_EVENT_APPLY;
}
- else
- f->set_default();
}
DBUG_RETURN(error);
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 3a0f784d195..e93417374fe 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -104,6 +104,11 @@ int init_relay_log_info(Relay_log_info* rli,
rli->tables_to_lock= 0;
rli->tables_to_lock_count= 0;
+ fn_format(rli->slave_patternload_file, PREFIX_SQL_LOAD, slave_load_tmpdir, "",
+ MY_PACK_FILENAME | MY_UNPACK_FILENAME |
+ MY_RETURN_REAL_PATH);
+ rli->slave_patternload_file_size= strlen(rli->slave_patternload_file);
+
/*
The relay log will now be opened, as a SEQ_READ_APPEND IO_CACHE.
Note that the I/O thread flushes it to disk after writing every
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index e13ea93842c..171778d9675 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -260,6 +260,13 @@ public:
char ign_master_log_name_end[FN_REFLEN];
ulonglong ign_master_log_pos_end;
+ /*
+ Indentifies where the SQL Thread should create temporary files for the
+ LOAD DATA INFILE. This is used for security reasons.
+ */
+ char slave_patternload_file[FN_REFLEN];
+ size_t slave_patternload_file_size;
+
Relay_log_info();
~Relay_log_info();
diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h
index 8e2f4a7374f..1f4ca246ff1 100644
--- a/sql/rpl_utility.h
+++ b/sql/rpl_utility.h
@@ -294,12 +294,14 @@ namespace {
}
#endif
+// NB. number of printed bit values is limited to sizeof(buf) - 1
#define DBUG_PRINT_BITSET(N,FRM,BS) \
do { \
char buf[256]; \
- for (uint i = 0 ; i < (BS)->n_bits ; ++i) \
+ uint i; \
+ for (i = 0 ; i < min(sizeof(buf) - 1, (BS)->n_bits) ; i++) \
buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
- buf[(BS)->n_bits] = '\0'; \
+ buf[i] = '\0'; \
DBUG_PRINT((N), ((FRM), buf)); \
} while (0)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index f14068fcfcb..bc8c91342e6 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -110,6 +110,7 @@ static void sys_default_init_connect(THD*, enum_var_type type);
static bool sys_update_init_slave(THD*, set_var*);
static void sys_default_init_slave(THD*, enum_var_type type);
static bool set_option_bit(THD *thd, set_var *var);
+static bool set_option_log_bin_bit(THD *thd, set_var *var);
static bool set_option_autocommit(THD *thd, set_var *var);
static int check_log_update(THD *thd, set_var *var);
static bool set_log_update(THD *thd, set_var *var);
@@ -134,8 +135,6 @@ static int check_max_delayed_threads(THD *thd, set_var *var);
static void fix_thd_mem_root(THD *thd, enum_var_type type);
static void fix_trans_mem_root(THD *thd, enum_var_type type);
static void fix_server_id(THD *thd, enum_var_type type);
-static ulonglong fix_unsigned(THD *, ulonglong, const struct my_option *);
-static bool get_unsigned(THD *thd, set_var *var);
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
const char *name, longlong val);
static KEY_CACHE *create_key_cache(const char *name, uint length);
@@ -468,6 +467,8 @@ static sys_var_thd_ulong sys_optimizer_prune_level(&vars, "optimizer_prun
&SV::optimizer_prune_level);
static sys_var_thd_ulong sys_optimizer_search_depth(&vars, "optimizer_search_depth",
&SV::optimizer_search_depth);
+static sys_var_thd_optimizer_switch sys_optimizer_switch(&vars, "optimizer_switch",
+ &SV::optimizer_switch);
static sys_var_const sys_pid_file(&vars, "pid_file",
OPT_GLOBAL, SHOW_CHAR,
(uchar*) pidfile_name);
@@ -731,7 +732,7 @@ static sys_var_thd_bit sys_log_update(&vars, "sql_log_update",
OPTION_BIN_LOG);
static sys_var_thd_bit sys_log_binlog(&vars, "sql_log_bin",
check_log_update,
- set_option_bit,
+ set_option_log_bin_bit,
OPTION_BIN_LOG);
static sys_var_thd_bit sys_sql_warnings(&vars, "sql_warnings", 0,
set_option_bit,
@@ -1370,6 +1371,19 @@ static void fix_server_id(THD *thd, enum_var_type type)
}
+/**
+ Throw warning (error in STRICT mode) if value for variable needed bounding.
+ Only call from check(), not update(), because an error in update() would be
+ bad mojo. Plug-in interface also uses this.
+
+ @param thd thread handle
+ @param fixed did we have to correct the value? (throw warn/err if so)
+ @param unsignd is value's type unsigned?
+ @param name variable's name
+ @param val variable's value
+
+ @retval TRUE on error, FALSE otherwise (warning or OK)
+ */
bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
const char *name, longlong val)
{
@@ -1395,26 +1409,128 @@ bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
return FALSE;
}
-static ulonglong fix_unsigned(THD *thd, ulonglong num,
+
+/**
+ check an unsigned user-supplied value for a systemvariable against bounds.
+
+ TODO: This is a wrapper function to call clipping from within an update()
+ function. Calling bounds from within update() is fair game in theory,
+ but we can only send warnings from in there, not errors, and besides,
+ it violates our model of separating check from update phase.
+ To avoid breaking out of the server with an ASSERT() in strict mode,
+ we pretend we're not in strict mode when we go through here. Bug#43233
+ was opened to remind us to replace this kludge with The Right Thing,
+ which of course is to do the check in the actual check phase, and then
+ throw an error or warning accordingly.
+
+ @param thd thread handle
+ @param num the value to limit
+ @param option_limits the bounds-record, or NULL if none
+ */
+static void bound_unsigned(THD *thd, ulonglong *num,
const struct my_option *option_limits)
{
- my_bool fixed= FALSE;
- ulonglong out= getopt_ull_limit_value(num, option_limits, &fixed);
+ if (option_limits)
+ {
+ my_bool fixed = FALSE;
+ ulonglong unadjusted= *num;
+
+ *num= getopt_ull_limit_value(unadjusted, option_limits, &fixed);
- throw_bounds_warning(thd, fixed, TRUE, option_limits->name, (longlong) num);
- return out;
+ if (fixed)
+ {
+ ulong ssm= thd->variables.sql_mode;
+ thd->variables.sql_mode&= ~MODE_STRICT_ALL_TABLES;
+ throw_bounds_warning(thd, fixed, TRUE, option_limits->name, unadjusted);
+ thd->variables.sql_mode= ssm;
+ }
+ }
}
-static bool get_unsigned(THD *thd, set_var *var)
-{
+
+/**
+ Get unsigned system-variable.
+ Negative value does not wrap around, but becomes zero.
+ Check user-supplied value for a systemvariable against bounds.
+ If we needed to adjust the value, throw a warning or error depending
+ on SQL-mode.
+
+ @param thd thread handle
+ @param var the system-variable to get
+ @param user_max a limit given with --maximum-variable-name=... or 0
+ @param var_type function will bound on systems where necessary.
+
+ @retval TRUE on error, FALSE otherwise (warning or OK)
+ */
+static bool get_unsigned(THD *thd, set_var *var, ulonglong user_max,
+ ulong var_type)
+{
+ int warnings= 0;
+ ulonglong unadjusted;
+ const struct my_option *limits= var->var->option_limits;
+ struct my_option fallback;
+
+ /* get_unsigned() */
if (var->value->unsigned_flag)
var->save_result.ulonglong_value= (ulonglong) var->value->val_int();
else
{
longlong v= var->value->val_int();
var->save_result.ulonglong_value= (ulonglong) ((v < 0) ? 0 : v);
+ if (v < 0)
+ {
+ warnings++;
+ if (throw_bounds_warning(thd, TRUE, FALSE, var->var->name, v))
+ return TRUE; /* warning was promoted to error, give up */
+ }
}
- return 0;
+
+ unadjusted= var->save_result.ulonglong_value;
+
+ /* max, if any */
+
+ if ((user_max > 0) && (unadjusted > user_max))
+ {
+ var->save_result.ulonglong_value= user_max;
+
+ if ((warnings == 0) && throw_bounds_warning(thd, TRUE, TRUE,
+ var->var->name,
+ (longlong) unadjusted))
+ return TRUE;
+
+ warnings++;
+ }
+
+ /*
+ if the sysvar doesn't have a proper bounds record but the check
+ function would like bounding to ULONG where its size differs from
+ that of ULONGLONG, we make up a bogus limits record here and let
+ the usual suspects handle the actual limiting.
+ */
+
+ if (!limits && var_type != GET_ULL)
+ {
+ bzero(&fallback, sizeof(fallback));
+ fallback.var_type= var_type;
+ limits= &fallback;
+ }
+
+ /* fix_unsigned() */
+ if (limits)
+ {
+ my_bool fixed;
+
+ var->save_result.ulonglong_value= getopt_ull_limit_value(var->save_result.
+ ulonglong_value,
+ limits, &fixed);
+
+ if ((warnings == 0) && throw_bounds_warning(thd, fixed, TRUE,
+ var->var->name,
+ (longlong) unadjusted))
+ return TRUE;
+ }
+
+ return FALSE;
}
@@ -1428,29 +1544,13 @@ sys_var_long_ptr(sys_var_chain *chain, const char *name_arg, ulong *value_ptr_ar
bool sys_var_long_ptr_global::check(THD *thd, set_var *var)
{
- return get_unsigned(thd, var);
+ return get_unsigned(thd, var, 0, GET_ULONG);
}
bool sys_var_long_ptr_global::update(THD *thd, set_var *var)
{
- ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(guard);
- if (option_limits)
- *value= (ulong) fix_unsigned(thd, tmp, option_limits);
- else
- {
-#if SIZEOF_LONG < SIZEOF_LONG_LONG
- /* Avoid overflows on 32 bit systems */
- if (tmp > ULONG_MAX)
- {
- tmp= ULONG_MAX;
- throw_bounds_warning(thd, TRUE, TRUE, name,
- (longlong) var->save_result.ulonglong_value);
- }
-#endif
- *value= (ulong) tmp;
- }
-
+ *value= (ulong) var->save_result.ulonglong_value;
pthread_mutex_unlock(guard);
return 0;
}
@@ -1470,10 +1570,8 @@ bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var)
{
ulonglong tmp= var->save_result.ulonglong_value;
pthread_mutex_lock(&LOCK_global_system_variables);
- if (option_limits)
- *value= (ulonglong) fix_unsigned(thd, tmp, option_limits);
- else
- *value= (ulonglong) tmp;
+ bound_unsigned(thd, &tmp, option_limits);
+ *value= (ulonglong) tmp;
pthread_mutex_unlock(&LOCK_global_system_variables);
return 0;
}
@@ -1523,36 +1621,18 @@ uchar *sys_var_enum_const::value_ptr(THD *thd, enum_var_type type,
bool sys_var_thd_ulong::check(THD *thd, set_var *var)
{
- return (get_unsigned(thd, var) ||
- (check_func && (*check_func)(thd, var)));
+ if (get_unsigned(thd, var, max_system_variables.*offset, GET_ULONG))
+ return TRUE;
+ DBUG_ASSERT(var->save_result.ulonglong_value <= ULONG_MAX);
+ return ((check_func && (*check_func)(thd, var)));
}
bool sys_var_thd_ulong::update(THD *thd, set_var *var)
{
- ulonglong tmp= var->save_result.ulonglong_value;
-
- /* Don't use bigger value than given with --maximum-variable-name=.. */
- if (tmp > max_system_variables.*offset)
- {
- throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp);
- tmp= max_system_variables.*offset;
- }
-
- if (option_limits)
- tmp= fix_unsigned(thd, tmp, option_limits);
-#if SIZEOF_LONG < SIZEOF_LONG_LONG
- else if (tmp > ULONG_MAX)
- {
- tmp= ULONG_MAX;
- throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) var->save_result.ulonglong_value);
- }
-#endif
-
- DBUG_ASSERT(tmp <= ULONG_MAX);
if (var->type == OPT_GLOBAL)
- global_system_variables.*offset= (ulong) tmp;
+ global_system_variables.*offset= (ulong) var->save_result.ulonglong_value;
else
- thd->variables.*offset= (ulong) tmp;
+ thd->variables.*offset= (ulong) var->save_result.ulonglong_value;
return 0;
}
@@ -1590,8 +1670,8 @@ bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
if ((ha_rows) tmp > max_system_variables.*offset)
tmp= max_system_variables.*offset;
- if (option_limits)
- tmp= (ha_rows) fix_unsigned(thd, tmp, option_limits);
+ bound_unsigned(thd, &tmp, option_limits);
+
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
@@ -1632,27 +1712,21 @@ uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type,
bool sys_var_thd_ulonglong::check(THD *thd, set_var *var)
{
- return get_unsigned(thd, var);
+ return get_unsigned(thd, var, max_system_variables.*offset, GET_ULL);
}
bool sys_var_thd_ulonglong::update(THD *thd, set_var *var)
{
- ulonglong tmp= var->save_result.ulonglong_value;
-
- if (tmp > max_system_variables.*offset)
- tmp= max_system_variables.*offset;
-
- if (option_limits)
- tmp= fix_unsigned(thd, tmp, option_limits);
if (var->type == OPT_GLOBAL)
{
/* Lock is needed to make things safe on 32 bit systems */
pthread_mutex_lock(&LOCK_global_system_variables);
- global_system_variables.*offset= (ulonglong) tmp;
+ global_system_variables.*offset= (ulonglong)
+ var->save_result.ulonglong_value;
pthread_mutex_unlock(&LOCK_global_system_variables);
}
else
- thd->variables.*offset= (ulonglong) tmp;
+ thd->variables.*offset= (ulonglong) var->save_result.ulonglong_value;
return 0;
}
@@ -2284,10 +2358,10 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var)
goto end;
}
- key_cache->param_buff_size=
- (ulonglong) fix_unsigned(thd, tmp, option_limits);
+ bound_unsigned(thd, &tmp, option_limits);
+ key_cache->param_buff_size= (ulonglong) tmp;
- /* If key cache didn't existed initialize it, else resize it */
+ /* If key cache didn't exist initialize it, else resize it */
key_cache->in_init= 1;
pthread_mutex_unlock(&LOCK_global_system_variables);
@@ -2313,7 +2387,7 @@ end:
*/
bool sys_var_key_cache_long::update(THD *thd, set_var *var)
{
- ulong tmp= (ulong) var->value->val_int();
+ ulonglong tmp= var->value->val_int();
LEX_STRING *base_name= &var->base;
bool error= 0;
@@ -2338,8 +2412,8 @@ bool sys_var_key_cache_long::update(THD *thd, set_var *var)
if (key_cache->in_init)
goto end;
- *((ulong*) (((char*) key_cache) + offset))=
- (ulong) fix_unsigned(thd, tmp, option_limits);
+ bound_unsigned(thd, &tmp, option_limits);
+ *((ulong*) (((char*) key_cache) + offset))= (ulong) tmp;
/*
Don't create a new key cache if it didn't exist
@@ -2963,6 +3037,16 @@ static bool set_option_bit(THD *thd, set_var *var)
return 0;
}
+/*
+ Functions to be only used to update thd->options OPTION_BIN_LOG bit
+*/
+static bool set_option_log_bin_bit(THD *thd, set_var *var)
+{
+ set_option_bit(thd, var);
+ if (!thd->in_sub_stmt)
+ thd->sql_log_bin_toplevel= thd->options & OPTION_BIN_LOG;
+ return 0;
+}
static bool set_option_autocommit(THD *thd, set_var *var)
{
@@ -3682,7 +3766,7 @@ bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
void sys_var_thd_table_type::warn_deprecated(THD *thd)
{
- WARN_DEPRECATED(thd, "5.2", "@@table_type", "'@@storage_engine'");
+ WARN_DEPRECATED(thd, "6.0", "@@table_type", "'@@storage_engine'");
}
void sys_var_thd_table_type::set_default(THD *thd, enum_var_type type)
@@ -3837,6 +3921,97 @@ ulong fix_sql_mode(ulong sql_mode)
}
+bool
+sys_var_thd_optimizer_switch::
+symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep)
+{
+ char buff[STRING_BUFFER_USUAL_SIZE*8];
+ String tmp(buff, sizeof(buff), &my_charset_latin1);
+ int i;
+ ulonglong bit;
+ tmp.length(0);
+
+ for (i= 0, bit=1; bit != OPTIMIZER_SWITCH_LAST; i++, bit= bit << 1)
+ {
+ tmp.append(optimizer_switch_typelib.type_names[i],
+ optimizer_switch_typelib.type_lengths[i]);
+ tmp.append('=');
+ tmp.append((val & bit)? "on":"off");
+ tmp.append(',');
+ }
+
+ if (tmp.length())
+ tmp.length(tmp.length() - 1); /* trim the trailing comma */
+
+ rep->str= thd->strmake(tmp.ptr(), tmp.length());
+
+ rep->length= rep->str ? tmp.length() : 0;
+
+ return rep->length != tmp.length();
+}
+
+
+uchar *sys_var_thd_optimizer_switch::value_ptr(THD *thd, enum_var_type type,
+ LEX_STRING *base)
+{
+ LEX_STRING opts;
+ ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
+ thd->variables.*offset);
+ (void) symbolic_mode_representation(thd, val, &opts);
+ return (uchar *) opts.str;
+}
+
+
+/*
+ Check (and actually parse) string representation of @@optimizer_switch.
+*/
+
+bool sys_var_thd_optimizer_switch::check(THD *thd, set_var *var)
+{
+ bool not_used;
+ char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
+ uint error_len= 0;
+ String str(buff, sizeof(buff), system_charset_info), *res;
+
+ if (!(res= var->value->val_str(&str)))
+ {
+ strmov(buff, "NULL");
+ goto err;
+ }
+
+ if (res->length() == 0)
+ {
+ buff[0]= 0;
+ goto err;
+ }
+
+ var->save_result.ulong_value=
+ (ulong)find_set_from_flags(&optimizer_switch_typelib,
+ optimizer_switch_typelib.count,
+ thd->variables.optimizer_switch,
+ global_system_variables.optimizer_switch,
+ res->c_ptr_safe(), res->length(), NULL,
+ &error, &error_len, &not_used);
+ if (error_len)
+ {
+ strmake(buff, error, min(sizeof(buff) - 1, error_len));
+ goto err;
+ }
+ return FALSE;
+err:
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buff);
+ return TRUE;
+}
+
+
+void sys_var_thd_optimizer_switch::set_default(THD *thd, enum_var_type type)
+{
+ if (type == OPT_GLOBAL)
+ global_system_variables.*offset= OPTIMIZER_SWITCH_DEFAULT;
+ else
+ thd->variables.*offset= global_system_variables.*offset;
+}
+
/****************************************************************************
Named list handling
****************************************************************************/
@@ -3944,7 +4119,7 @@ bool process_key_caches(process_key_cache_t func)
void sys_var_trust_routine_creators::warn_deprecated(THD *thd)
{
- WARN_DEPRECATED(thd, "5.2", "@@log_bin_trust_routine_creators",
+ WARN_DEPRECATED(thd, "6.0", "@@log_bin_trust_routine_creators",
"'@@log_bin_trust_function_creators'");
}
diff --git a/sql/set_var.h b/sql/set_var.h
index b6c67d1ab4a..10e6e0f9c35 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -31,7 +31,7 @@ typedef struct system_variables SV;
typedef struct my_locale_st MY_LOCALE;
extern TYPELIB bool_typelib, delay_key_write_typelib, sql_mode_typelib,
- slave_exec_mode_typelib;
+ optimizer_switch_typelib, slave_exec_mode_typelib;
typedef int (*sys_check_func)(THD *, set_var *);
typedef bool (*sys_update_func)(THD *, set_var *);
@@ -532,6 +532,20 @@ public:
};
+class sys_var_thd_optimizer_switch :public sys_var_thd_enum
+{
+public:
+ sys_var_thd_optimizer_switch(sys_var_chain *chain, const char *name_arg,
+ ulong SV::*offset_arg)
+ :sys_var_thd_enum(chain, name_arg, offset_arg, &optimizer_switch_typelib)
+ {}
+ bool check(THD *thd, set_var *var);
+ void set_default(THD *thd, enum_var_type type);
+ uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
+ static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode,
+ LEX_STRING *rep);
+};
+
extern void fix_sql_mode_var(THD *thd, enum_var_type type);
class sys_var_thd_sql_mode :public sys_var_thd_enum
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index befd064e3e3..f9b66990e93 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5614,7 +5614,7 @@ ER_SP_WRONG_NAME 42000
eng "Incorrect routine name '%-.192s'"
ger "Ungültiger Routinenname '%-.192s'"
ER_TABLE_NEEDS_UPGRADE
- eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" to fix it!"
+ eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" or dump/reload to fix it!"
ger "Tabellenaktualisierung erforderlich. Bitte zum Reparieren \"REPAIR TABLE `%-.32s`\" eingeben!"
ER_SP_NO_AGGREGATE 42000
eng "AGGREGATE is not supported for stored functions"
@@ -5775,9 +5775,9 @@ ER_PARTITION_MGMT_ON_NONPARTITIONED
ger "Partitionsverwaltung einer nicht partitionierten Tabelle ist nicht möglich"
swe "Partitioneringskommando på en opartitionerad tabell är inte möjligt"
ER_FOREIGN_KEY_ON_PARTITIONED
- eng "Foreign key condition is not yet supported in conjunction with partitioning"
+ eng "Foreign key clause is not yet supported in conjunction with partitioning"
ger "Fremdschlüssel-Beschränkungen sind im Zusammenhang mit Partitionierung nicht zulässig"
- swe "Foreign key villkor är inte ännu implementerad i kombination med partitionering"
+ swe "Foreign key klausul är inte ännu implementerad i kombination med partitionering"
ER_DROP_PARTITION_NON_EXISTENT
eng "Error in list of partitions to %-.64s"
ger "Fehler in der Partitionsliste bei %-.64s"
@@ -5791,13 +5791,13 @@ ER_COALESCE_ONLY_ON_HASH_PARTITION
ger "COALESCE PARTITION kann nur auf HASH- oder KEY-Partitionen benutzt werden"
swe "COALESCE PARTITION kan bara användas på HASH/KEY partitioner"
ER_REORG_HASH_ONLY_ON_SAME_NO
- eng "REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers"
+ eng "REORGANIZE PARTITION can only be used to reorganize partitions not to change their numbers"
ger "REORGANIZE PARTITION kann nur zur Reorganisation von Partitionen verwendet werden, nicht, um ihre Nummern zu ändern"
- swe "REORGANISE PARTITION kan bara användas för att omorganisera partitioner, inte för att ändra deras antal"
+ swe "REORGANIZE PARTITION kan bara användas för att omorganisera partitioner, inte för att ändra deras antal"
ER_REORG_NO_PARAM_ERROR
- eng "REORGANISE PARTITION without parameters can only be used on auto-partitioned tables using HASH PARTITIONs"
+ eng "REORGANIZE PARTITION without parameters can only be used on auto-partitioned tables using HASH PARTITIONs"
ger "REORGANIZE PARTITION ohne Parameter kann nur für auto-partitionierte Tabellen verwendet werden, die HASH-Partitionierung benutzen"
- swe "REORGANISE PARTITION utan parametrar kan bara användas på auto-partitionerade tabeller som använder HASH partitionering"
+ swe "REORGANIZE PARTITION utan parametrar kan bara användas på auto-partitionerade tabeller som använder HASH partitionering"
ER_ONLY_ON_RANGE_LIST_PARTITION
eng "%-.64s PARTITION can only be used on RANGE/LIST partitions"
ger "%-.64s PARTITION kann nur für RANGE- oder LIST-Partitionen verwendet werden"
@@ -5815,7 +5815,7 @@ ER_COALESCE_PARTITION_NO_PARTITION
ger "Zumindest eine Partition muss mit COALESCE PARTITION zusammengefügt werden"
swe "Åtminstone en partition måste slås ihop vid COALESCE PARTITION"
ER_REORG_PARTITION_NOT_EXIST
- eng "More partitions to reorganise than there are partitions"
+ eng "More partitions to reorganize than there are partitions"
ger "Es wurde versucht, mehr Partitionen als vorhanden zu reorganisieren"
swe "Fler partitioner att reorganisera än det finns partitioner"
ER_SAME_NAME_PARTITION
@@ -5827,7 +5827,7 @@ ER_NO_BINLOG_ERROR
ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten"
swe "Det är inte tillåtet att stänga av binlog på detta kommando"
ER_CONSECUTIVE_REORG_PARTITIONS
- eng "When reorganising a set of partitions they must be in consecutive order"
+ eng "When reorganizing a set of partitions they must be in consecutive order"
ger "Bei der Reorganisation eines Satzes von Partitionen müssen diese in geordneter Reihenfolge vorliegen"
swe "När ett antal partitioner omorganiseras måste de vara i konsekutiv ordning"
ER_REORG_OUTSIDE_RANGE
@@ -6154,3 +6154,26 @@ WARN_PLUGIN_BUSY
ER_VARIABLE_IS_READONLY
eng "%s variable '%s' is read-only. Use SET %s to assign the value"
+
+ER_WARN_ENGINE_TRANSACTION_ROLLBACK
+ eng "Storage engine %s does not support rollback for this statement. Transaction rolled back and must be restarted"
+
+ER_SLAVE_HEARTBEAT_FAILURE
+ eng "Unexpected master's heartbeat data: %s"
+ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
+ eng "The requested value for the heartbeat period %s %s"
+
+ER_NDB_REPLICATION_SCHEMA_ERROR
+ eng "Bad schema for mysql.ndb_replication table. Message: %-.64s"
+ER_CONFLICT_FN_PARSE_ERROR
+ eng "Error in parsing conflict function. Message: %-.64s"
+ER_EXCEPTIONS_WRITE_ERROR
+ eng "Write to exceptions table failed. Message: %-.128s""
+
+ER_TOO_LONG_TABLE_COMMENT
+ eng "Comment for table '%-.64s' is too long (max = %lu)"
+ por "Comentário para a tabela '%-.64s' é longo demais (max = %lu)"
+
+ER_TOO_LONG_FIELD_COMMENT
+ eng "Comment for field '%-.64s' is too long (max = %lu)"
+ por "Comentário para o campo '%-.64s' é longo demais (max = %lu)"
diff --git a/sql/slave.cc b/sql/slave.cc
index 22c61b3ec6c..81c18c5e04b 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -128,6 +128,7 @@ static bool wait_for_relay_log_space(Relay_log_info* rli);
static inline bool io_slave_killed(THD* thd,Master_info* mi);
static inline bool sql_slave_killed(THD* thd,Relay_log_info* rli);
static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type);
+static void print_slave_skip_errors(void);
static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi);
static int safe_reconnect(THD* thd, MYSQL* mysql, Master_info* mi,
bool suppress_warnings);
@@ -142,8 +143,8 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi);
static Log_event* next_event(Relay_log_info* rli);
static int queue_event(Master_info* mi,const char* buf,ulong event_len);
static int terminate_slave_thread(THD *thd,
- pthread_mutex_t* term_lock,
- pthread_cond_t* term_cond,
+ pthread_mutex_t *term_lock,
+ pthread_cond_t *term_cond,
volatile uint *slave_running,
bool skip_lock);
static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info);
@@ -232,6 +233,15 @@ int init_slave()
active_mi= new Master_info;
/*
+ If --slave-skip-errors=... was not used, the string value for the
+ system variable has not been set up yet. Do it now.
+ */
+ if (!use_slave_mask)
+ {
+ print_slave_skip_errors();
+ }
+
+ /*
If master_host is not specified, try to read it from the master_info file.
If master_host is specified, create the master_info file if it doesn't
exists.
@@ -311,7 +321,7 @@ static void print_slave_skip_errors(void)
char *bend= buff + sizeof(slave_skip_error_names);
int errnum;
- for (errnum= 1; errnum < MAX_SLAVE_ERROR; errnum++)
+ for (errnum= 0; errnum < MAX_SLAVE_ERROR; errnum++)
{
if (bitmap_is_set(&slave_error_mask, errnum))
{
@@ -361,6 +371,7 @@ void init_slave_skip_errors(const char* arg)
if (!my_strnncoll(system_charset_info,(uchar*)arg,4,(const uchar*)"all",4))
{
bitmap_set_all(&slave_error_mask);
+ print_slave_skip_errors();
DBUG_VOID_RETURN;
}
for (p= arg ; *p; )
@@ -388,22 +399,22 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
- if ((thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL)))
+ if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))
{
DBUG_PRINT("info",("Terminating IO thread"));
mi->abort_slave=1;
- if ((error=terminate_slave_thread(mi->io_thd,io_lock,
+ if ((error=terminate_slave_thread(mi->io_thd, io_lock,
&mi->stop_cond,
&mi->slave_running,
skip_lock)) &&
!force_all)
DBUG_RETURN(error);
}
- if ((thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL)))
+ if (thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL))
{
DBUG_PRINT("info",("Terminating SQL thread"));
mi->rli.abort_slave=1;
- if ((error=terminate_slave_thread(mi->rli.sql_thd,sql_lock,
+ if ((error=terminate_slave_thread(mi->rli.sql_thd, sql_lock,
&mi->rli.stop_cond,
&mi->rli.slave_running,
skip_lock)) &&
@@ -441,29 +452,44 @@ int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
the condition. In this case, it is assumed that the calling
function acquires the lock before calling this function.
- @retval 0 All OK
+ @retval 0 All OK ER_SLAVE_NOT_RUNNING otherwise.
+
+ @note If the executing thread has to acquire term_lock (skip_lock
+ is false), the negative running status does not represent
+ any issue therefore no error is reported.
+
*/
static int
terminate_slave_thread(THD *thd,
- pthread_mutex_t* term_lock,
- pthread_cond_t* term_cond,
+ pthread_mutex_t *term_lock,
+ pthread_cond_t *term_cond,
volatile uint *slave_running,
bool skip_lock)
{
- int error;
-
DBUG_ENTER("terminate_slave_thread");
-
if (!skip_lock)
+ {
pthread_mutex_lock(term_lock);
-
- safe_mutex_assert_owner(term_lock);
-
+ }
+ else
+ {
+ safe_mutex_assert_owner(term_lock);
+ }
if (!*slave_running)
{
if (!skip_lock)
+ {
+ /*
+ if run_lock (term_lock) is acquired locally then either
+ slave_running status is fine
+ */
pthread_mutex_unlock(term_lock);
- DBUG_RETURN(ER_SLAVE_NOT_RUNNING);
+ DBUG_RETURN(0);
+ }
+ else
+ {
+ DBUG_RETURN(ER_SLAVE_NOT_RUNNING);
+ }
}
DBUG_ASSERT(thd != 0);
THD_CHECK_SENTRY(thd);
@@ -475,6 +501,7 @@ terminate_slave_thread(THD *thd,
while (*slave_running) // Should always be true
{
+ int error;
DBUG_PRINT("loop", ("killing slave thread"));
pthread_mutex_lock(&thd->LOCK_delete);
@@ -616,7 +643,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
&mi->rli.slave_running, &mi->rli.slave_run_id,
mi, 0);
if (error)
- terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0);
+ terminate_slave_threads(mi, thread_mask & SLAVE_IO, !need_slave_mutex);
}
DBUG_RETURN(error);
}
@@ -687,6 +714,9 @@ static bool sql_slave_killed(THD* thd, Relay_log_info* rli)
DBUG_ASSERT(rli->slave_running == 1);// tracking buffer overrun
if (abort_loop || thd->killed || rli->abort_slave)
{
+ if (rli->abort_slave && rli->is_in_group() &&
+ thd->transaction.all.modified_non_trans_table)
+ DBUG_RETURN(0);
/*
If we are in an unsafe situation (stopping could corrupt replication),
we give one minute to the slave SQL thread of grace before really
@@ -2626,12 +2656,48 @@ err:
delete the mi structure leading to a crash! (see BUG#25306 for details)
*/
pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done
+ DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
pthread_mutex_unlock(&mi->run_lock);
my_thread_end();
pthread_exit(0);
DBUG_RETURN(0); // Can't return anything here
}
+/*
+ Check the temporary directory used by commands like
+ LOAD DATA INFILE.
+ */
+static
+int check_temp_dir(char* tmp_dir, char *tmp_file)
+{
+ int fd;
+ MY_DIR *dirp;
+
+ DBUG_ENTER("check_temp_dir");
+
+ /*
+ Check if the directory exists.
+ */
+ if (!(dirp=my_dir(tmp_dir,MYF(MY_WME))))
+ DBUG_RETURN(1);
+ my_dirend(dirp);
+
+ /*
+ Check permissions to create a file.
+ */
+ if ((fd= my_create(tmp_file, CREATE_MODE,
+ O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
+ MYF(MY_WME))) < 0)
+ DBUG_RETURN(1);
+
+ /*
+ Clean up.
+ */
+ my_close(fd, MYF(0));
+ my_delete(tmp_file, MYF(0));
+
+ DBUG_RETURN(0);
+}
/**
Slave SQL thread entry point.
@@ -2678,7 +2744,8 @@ pthread_handler_t handle_slave_sql(void *arg)
*/
pthread_cond_broadcast(&rli->start_cond);
pthread_mutex_unlock(&rli->run_lock);
- sql_print_error("Failed during slave thread initialization");
+ rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ "Failed during slave thread initialization");
goto err;
}
thd->init_for_queries();
@@ -2722,9 +2789,9 @@ pthread_handler_t handle_slave_sql(void *arg)
rli->group_relay_log_pos,
1 /*need data lock*/, &errmsg,
1 /*look for a description_event*/))
- {
- sql_print_error("Error initializing relay log position: %s",
- errmsg);
+ {
+ rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR,
+ "Error initializing relay log position: %s", errmsg);
goto err;
}
THD_CHECK_SENTRY(thd);
@@ -2763,14 +2830,22 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
llstr(rli->group_master_log_pos,llbuff),rli->group_relay_log_name,
llstr(rli->group_relay_log_pos,llbuff1));
+ if (check_temp_dir(slave_load_tmpdir, rli->slave_patternload_file))
+ {
+ rli->report(ERROR_LEVEL, thd->main_da.sql_errno(),
+ "Unable to use slave's temporary directory %s - %s",
+ slave_load_tmpdir, thd->main_da.message());
+ goto err;
+ }
+
/* execute init_slave variable */
if (sys_init_slave.value_length)
{
execute_init_command(thd, &sys_init_slave, &LOCK_sys_init_slave);
if (thd->is_slave_error)
{
- sql_print_error("\
-Slave SQL thread aborted. Can't execute init_slave query");
+ rli->report(ERROR_LEVEL, thd->main_da.sql_errno(),
+ "Slave SQL thread aborted. Can't execute init_slave query");
goto err;
}
}
@@ -2820,10 +2895,20 @@ Slave SQL thread aborted. Can't execute init_slave query");
thd->main_da.sql_errno(), last_errno));
if (last_errno == 0)
{
+ /*
+ This function is reporting an error which was not reported
+ while executing exec_relay_log_event().
+ */
rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), errmsg);
}
else if (last_errno != thd->main_da.sql_errno())
{
+ /*
+ * An error was reported while executing exec_relay_log_event()
+ * however the error code differs from what is in the thread.
+ * This function prints out more information to help finding
+ * what caused the problem.
+ */
sql_print_error("Slave (additional info): %s Error_code: %d",
errmsg, thd->main_da.sql_errno());
}
@@ -2921,6 +3006,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
delete the mi structure leading to a crash! (see BUG#25306 for details)
*/
pthread_cond_broadcast(&rli->stop_cond);
+ DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
pthread_mutex_unlock(&rli->run_lock); // tell the world we are done
my_thread_end();
diff --git a/sql/sp.cc b/sql/sp.cc
index cc545992857..8c8149d0afc 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -936,10 +936,13 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
ret= SP_INTERNAL_ERROR;
goto done;
}
-
+ /* restore sql_mode when binloging */
+ thd->variables.sql_mode= saved_mode;
/* Such a statement can always go directly to binlog, no trans cache */
thd->binlog_query(THD::MYSQL_QUERY_TYPE,
- log_query.c_ptr(), log_query.length(), FALSE, FALSE);
+ log_query.c_ptr(), log_query.length(),
+ FALSE, FALSE, THD::NOT_KILLED);
+ thd->variables.sql_mode= 0;
}
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 34b6c483637..d6984bf5ad0 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -208,6 +208,7 @@ sp_get_flags_for_command(LEX *lex)
case SQLCOM_SHOW_STATUS_PROC:
case SQLCOM_SHOW_STORAGE_ENGINES:
case SQLCOM_SHOW_TABLES:
+ case SQLCOM_SHOW_TABLE_STATUS:
case SQLCOM_SHOW_VARIABLES:
case SQLCOM_SHOW_WARNS:
case SQLCOM_REPAIR:
@@ -957,6 +958,8 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
qbuf.length(0);
cur= query_str->str;
prev_pos= res= 0;
+ thd->query_name_consts= 0;
+
for (Item_splocal **splocal= sp_vars_uses.front();
splocal < sp_vars_uses.back(); splocal++)
{
@@ -990,6 +993,8 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
res|= qbuf.append(')');
if (res)
break;
+
+ thd->query_name_consts++;
}
res|= qbuf.append(cur + prev_pos, query_str->length - prev_pos);
if (res)
@@ -2129,17 +2134,16 @@ sp_head::restore_lex(THD *thd)
/**
Put the instruction on the backpatch list, associated with the label.
*/
-void
+int
sp_head::push_backpatch(sp_instr *i, sp_label_t *lab)
{
bp_t *bp= (bp_t *)sql_alloc(sizeof(bp_t));
- if (bp)
- {
- bp->lab= lab;
- bp->instr= i;
- (void)m_backpatch.push_front(bp);
- }
+ if (!bp)
+ return 1;
+ bp->lab= lab;
+ bp->instr= i;
+ return m_backpatch.push_front(bp);
}
/**
@@ -2214,7 +2218,7 @@ sp_head::fill_field_definition(THD *thd, LEX *lex,
}
-void
+int
sp_head::new_cont_backpatch(sp_instr_opt_meta *i)
{
m_cont_level+= 1;
@@ -2222,15 +2226,17 @@ sp_head::new_cont_backpatch(sp_instr_opt_meta *i)
{
/* Use the cont. destination slot to store the level */
i->m_cont_dest= m_cont_level;
- (void)m_cont_backpatch.push_front(i);
+ if (m_cont_backpatch.push_front(i))
+ return 1;
}
+ return 0;
}
-void
+int
sp_head::add_cont_backpatch(sp_instr_opt_meta *i)
{
i->m_cont_dest= m_cont_level;
- (void)m_cont_backpatch.push_front(i);
+ return m_cont_backpatch.push_front(i);
}
void
@@ -2466,7 +2472,7 @@ sp_head::show_create_routine(THD *thd, int type)
@param instr Instruction
*/
-void sp_head::add_instr(sp_instr *instr)
+int sp_head::add_instr(sp_instr *instr)
{
instr->free_list= m_thd->free_list;
m_thd->free_list= 0;
@@ -2477,7 +2483,7 @@ void sp_head::add_instr(sp_instr *instr)
entire stored procedure, as their life span is equal.
*/
instr->mem_root= &main_mem_root;
- insert_dynamic(&m_instr, (uchar*)&instr);
+ return insert_dynamic(&m_instr, (uchar*)&instr);
}
@@ -2854,6 +2860,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
*nextp= m_ip+1;
thd->query= query;
thd->query_length= query_length;
+ thd->query_name_consts= 0;
if (!thd->is_error())
thd->main_da.reset_diagnostics_area();
diff --git a/sql/sp_head.h b/sql/sp_head.h
index 3d7597e2402..dd11f8693ac 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -308,7 +308,7 @@ public:
bool
show_create_routine(THD *thd, int type);
- void
+ int
add_instr(sp_instr *instr);
inline uint
@@ -344,7 +344,7 @@ public:
restore_lex(THD *thd);
/// Put the instruction on the backpatch list, associated with the label.
- void
+ int
push_backpatch(sp_instr *, struct sp_label *);
/// Update all instruction with this label in the backpatch list to
@@ -353,11 +353,11 @@ public:
backpatch(struct sp_label *);
/// Start a new cont. backpatch level. If 'i' is NULL, the level is just incr.
- void
+ int
new_cont_backpatch(sp_instr_opt_meta *i);
/// Add an instruction to the current level
- void
+ int
add_cont_backpatch(sp_instr_opt_meta *i);
/// Backpatch (and pop) the current level to the current position.
@@ -367,7 +367,7 @@ public:
char *name(uint *lenp = 0) const
{
if (lenp)
- *lenp= m_name.length;
+ *lenp= (uint) m_name.length;
return m_name.str;
}
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 414ea12cd7a..302faf3f681 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -265,8 +265,8 @@ sp_pcontext::push_variable(LEX_STRING *name, enum enum_field_types type,
p->mode= mode;
p->offset= current_var_count();
p->dflt= NULL;
- insert_dynamic(&m_vars, (uchar*)&p);
-
+ if (insert_dynamic(&m_vars, (uchar*)&p))
+ return NULL;
return p;
}
@@ -310,18 +310,17 @@ sp_pcontext::find_label(char *name)
return NULL;
}
-void
+int
sp_pcontext::push_cond(LEX_STRING *name, sp_cond_type_t *val)
{
sp_cond_t *p= (sp_cond_t *)sql_alloc(sizeof(sp_cond_t));
- if (p)
- {
- p->name.str= name->str;
- p->name.length= name->length;
- p->val= val;
- insert_dynamic(&m_conds, (uchar*)&p);
- }
+ if (p == NULL)
+ return 1;
+ p->name.str= name->str;
+ p->name.length= name->length;
+ p->val= val;
+ return insert_dynamic(&m_conds, (uchar *)&p);
}
/*
@@ -384,7 +383,7 @@ sp_pcontext::find_handler(sp_cond_type_t *cond)
return FALSE;
}
-void
+int
sp_pcontext::push_cursor(LEX_STRING *name)
{
LEX_STRING n;
@@ -393,7 +392,7 @@ sp_pcontext::push_cursor(LEX_STRING *name)
m_max_cursor_index+= 1;
n.str= name->str;
n.length= name->length;
- insert_dynamic(&m_cursors, (uchar*)&n);
+ return insert_dynamic(&m_cursors, (uchar *)&n);
}
/*
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h
index aefc501b3b0..3145ba2fea4 100644
--- a/sql/sp_pcontext.h
+++ b/sql/sp_pcontext.h
@@ -323,7 +323,7 @@ public:
// Conditions
//
- void
+ int
push_cond(LEX_STRING *name, sp_cond_type_t *val);
inline void
@@ -365,7 +365,7 @@ public:
// Cursors
//
- void
+ int
push_cursor(LEX_STRING *name);
my_bool
diff --git a/sql/spatial.h b/sql/spatial.h
index 69a1f24506e..dbf5da6665b 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -281,7 +281,7 @@ public:
uint32 len, String *res);
int as_wkt(String *wkt, const char **end)
{
- uint32 len= get_class_info()->m_name.length;
+ uint32 len= (uint) get_class_info()->m_name.length;
if (wkt->reserve(len + 2, 512))
return 1;
wkt->qs_append(get_class_info()->m_name.str, len);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index bd940608a07..b1dbb7031ce 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1647,7 +1647,8 @@ bool change_password(THD *thd, const char *host, const char *user,
acl_user->host.hostname ? acl_user->host.hostname : "",
new_password));
thd->clear_error();
- thd->binlog_query(THD::MYSQL_QUERY_TYPE, buff, query_length, FALSE, FALSE);
+ thd->binlog_query(THD::MYSQL_QUERY_TYPE, buff, query_length,
+ FALSE, FALSE, THD::NOT_KILLED);
}
end:
close_thread_tables(thd);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index d17bf085e3b..0dc29f7e3c2 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1440,7 +1440,8 @@ void close_temporary_tables(THD *thd)
if (!thd->temporary_tables)
return;
- if (!mysql_bin_log.is_open() || thd->current_stmt_binlog_row_based)
+ if (!mysql_bin_log.is_open() ||
+ (thd->current_stmt_binlog_row_based && thd->variables.binlog_format == BINLOG_FORMAT_ROW))
{
TABLE *tmp_next;
for (table= thd->temporary_tables; table; table= tmp_next)
@@ -1540,19 +1541,8 @@ void close_temporary_tables(THD *thd)
thd->variables.character_set_client= system_charset_info;
Query_log_event qinfo(thd, s_query.ptr(),
s_query.length() - 1 /* to remove trailing ',' */,
- 0, FALSE);
+ 0, FALSE, THD::NOT_KILLED);
thd->variables.character_set_client= cs_save;
- /*
- Imagine the thread had created a temp table, then was doing a
- SELECT, and the SELECT was killed. Then it's not clever to
- mark the statement above as "killed", because it's not really
- a statement updating data, and there are 99.99% chances it
- will succeed on slave. If a real update (one updating a
- persistent table) was killed on the master, then this real
- update will be logged with error_code=killed, rightfully
- causing the slave to stop.
- */
- qinfo.error_code= 0;
mysql_bin_log.write(&qinfo);
thd->variables.pseudo_thread_id= save_pseudo_thread_id;
}
@@ -2599,27 +2589,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
{ // Using table locks
TABLE *best_table= 0;
int best_distance= INT_MIN;
- bool check_if_used= thd->prelocked_mode &&
- ((int) table_list->lock_type >=
- (int) TL_WRITE_ALLOW_WRITE);
for (table=thd->open_tables; table ; table=table->next)
{
if (table->s->table_cache_key.length == key_length &&
!memcmp(table->s->table_cache_key.str, key, key_length))
{
- if (check_if_used && table->query_id &&
- table->query_id != thd->query_id)
- {
- /*
- If we are in stored function or trigger we should ensure that
- we won't change table that is already used by calling statement.
- So if we are opening table for writing, we should check that it
- is not already open by some calling stamement.
- */
- my_error(ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG, MYF(0),
- table->s->table_name.str);
- DBUG_RETURN(0);
- }
/*
When looking for a usable TABLE, ignore MERGE children, as they
belong to their parent and cannot be used explicitly.
@@ -2648,13 +2622,13 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
{
best_distance= distance;
best_table= table;
- if (best_distance == 0 && !check_if_used)
+ if (best_distance == 0)
{
/*
- If we have found perfect match and we don't need to check that
- table is not used by one of calling statements (assuming that
- we are inside of function or trigger) we can finish iterating
- through open tables list.
+ We have found a perfect match and can finish iterating
+ through open tables list. Check for table use conflict
+ between calling statement and SP/trigger is done in
+ lock_tables().
*/
break;
}
@@ -3870,6 +3844,16 @@ retry:
if (share->is_view)
{
/*
+ If parent_l of the table_list is non null then a merge table
+ has this view as child table, which is not supported.
+ */
+ if (table_list->parent_l)
+ {
+ my_error(ER_WRONG_MRG_TABLE, MYF(0));
+ goto err;
+ }
+
+ /*
This table is a view. Validate its metadata version: in particular,
that it was a view when the statement was prepared.
*/
@@ -4032,7 +4016,8 @@ retry:
end = strxmov(strmov(query, "DELETE FROM `"),
share->db.str,"`.`",share->table_name.str,"`", NullS);
thd->binlog_query(THD::STMT_QUERY_TYPE,
- query, (ulong)(end-query), FALSE, FALSE);
+ query, (ulong)(end-query),
+ FALSE, FALSE, THD::NOT_KILLED);
my_free(query, MYF(0));
}
else
@@ -4887,9 +4872,9 @@ TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,
lock_flags Flags passed to mysql_lock_table
NOTE
- This function don't do anything like SP/SF/views/triggers analysis done
- in open_tables(). It is intended for opening of only one concrete table.
- And used only in special contexts.
+ This function doesn't do anything like SP/SF/views/triggers analysis done
+ in open_table()/lock_tables(). It is intended for opening of only one
+ concrete table. And used only in special contexts.
RETURN VALUES
table Opened table
@@ -4907,6 +4892,9 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type,
bool refresh;
DBUG_ENTER("open_ltable");
+ /* should not be used in a prelocked_mode context, see NOTE above */
+ DBUG_ASSERT(!thd->prelocked_mode);
+
thd_proc_info(thd, "Opening table");
thd->current_tablenr= 0;
/* open_ltable can be used only for BASIC TABLEs */
@@ -5373,8 +5361,29 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
table && table != first_not_own;
table= table->next_global)
{
- if (!table->placeholder() &&
- check_lock_and_start_stmt(thd, table->table, table->lock_type))
+ if (table->placeholder())
+ continue;
+
+ /*
+ In a stored function or trigger we should ensure that we won't change
+ a table that is already used by the calling statement.
+ */
+ if (thd->prelocked_mode &&
+ table->lock_type >= TL_WRITE_ALLOW_WRITE)
+ {
+ for (TABLE* opentab= thd->open_tables; opentab; opentab= opentab->next)
+ {
+ if (table->table->s == opentab->s && opentab->query_id &&
+ table->table->query_id != opentab->query_id)
+ {
+ my_error(ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG, MYF(0),
+ table->table->s->table_name.str);
+ DBUG_RETURN(-1);
+ }
+ }
+ }
+
+ if (check_lock_and_start_stmt(thd, table->table, table->lock_type))
{
DBUG_RETURN(-1);
}
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index fcea4153eb0..7c104ccc455 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -419,6 +419,43 @@ TYPELIB query_cache_type_typelib=
array_elements(query_cache_type_names)-1,"", query_cache_type_names, NULL
};
+
+/**
+ Helper function for determine if a SELECT statement has a SQL_NO_CACHE
+ directive.
+
+ @param sql A pointer to the first white space character after SELECT
+
+ @return
+ @retval TRUE The character string contains SQL_NO_CACHE
+ @retval FALSE No directive found.
+*/
+
+static bool has_no_cache_directive(char *sql)
+{
+ int i=0;
+ while (sql[i] == ' ')
+ ++i;
+
+ if (my_toupper(system_charset_info, sql[i]) == 'S' &&
+ my_toupper(system_charset_info, sql[i+1]) == 'Q' &&
+ my_toupper(system_charset_info, sql[i+2]) == 'L' &&
+ my_toupper(system_charset_info, sql[i+3]) == '_' &&
+ my_toupper(system_charset_info, sql[i+4]) == 'N' &&
+ my_toupper(system_charset_info, sql[i+5]) == 'O' &&
+ my_toupper(system_charset_info, sql[i+6]) == '_' &&
+ my_toupper(system_charset_info, sql[i+7]) == 'C' &&
+ my_toupper(system_charset_info, sql[i+8]) == 'A' &&
+ my_toupper(system_charset_info, sql[i+9]) == 'C' &&
+ my_toupper(system_charset_info, sql[i+10]) == 'H' &&
+ my_toupper(system_charset_info, sql[i+11]) == 'E' &&
+ my_toupper(system_charset_info, sql[i+12]) == ' ')
+ return TRUE;
+
+ return FALSE;
+}
+
+
/*****************************************************************************
Query_cache_block_table method(s)
*****************************************************************************/
@@ -1079,7 +1116,7 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
{
memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length);
DBUG_PRINT("qcache", ("database: %s length: %u",
- thd->db, thd->db_length));
+ thd->db, (unsigned) thd->db_length));
}
else
{
@@ -1242,6 +1279,16 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
goto err;
}
+
+ if (query_length > 20 && has_no_cache_directive(&sql[i+6]))
+ {
+ /*
+ We do not increase 'refused' statistics here since it will be done
+ later when the query is parsed.
+ */
+ DBUG_PRINT("qcache", ("The statement has a SQL_NO_CACHE directive"));
+ goto err;
+ }
}
STRUCT_LOCK(&structure_guard_mutex);
@@ -1269,7 +1316,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
{
memcpy(sql+query_length+1, thd->db, thd->db_length);
DBUG_PRINT("qcache", ("database: '%s' length: %u",
- thd->db, thd->db_length));
+ thd->db, (unsigned)thd->db_length));
}
else
{
@@ -1529,6 +1576,9 @@ void Query_cache::invalidate(THD *thd, TABLE_LIST *tables_used,
invalidate_table(thd, tables_used);
}
+ DBUG_EXECUTE_IF("wait_after_query_cache_invalidate",
+ debug_wait_for_kill("wait_after_query_cache_invalidate"););
+
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 118dc5af68f..b73822f5a48 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -538,6 +538,7 @@ THD::THD()
Open_tables_state(refresh_version), rli_fake(0),
lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0),
+ sql_log_bin_toplevel(false),
binlog_table_maps(0), binlog_flags(0UL),
table_map_for_update(0),
arg_of_last_insert_id_function(FALSE),
@@ -598,6 +599,7 @@ THD::THD()
one_shot_set= 0;
file_id = 0;
query_id= 0;
+ query_name_consts= 0;
warn_id= 0;
db_charset= global_system_variables.collation_database;
bzero(ha_data, sizeof(ha_data));
@@ -787,6 +789,7 @@ void THD::init(void)
update_charset();
reset_current_stmt_binlog_row_based();
bzero((char *) &status_var, sizeof(status_var));
+ sql_log_bin_toplevel= options & OPTION_BIN_LOG;
}
@@ -1587,6 +1590,11 @@ bool select_send::send_data(List<Item> &items)
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
break;
}
+ /*
+ Reset buffer to its original state, as it may have been altered in
+ Item::send().
+ */
+ buffer.set(buff, sizeof(buff), &my_charset_bin);
}
thd->sent_row_count++;
if (thd->is_error())
@@ -2296,7 +2304,7 @@ void Query_arena::set_query_arena(Query_arena *set)
void Query_arena::cleanup_stmt()
{
- DBUG_ASSERT("Query_arena::cleanup_stmt()" == "not implemented");
+ DBUG_ASSERT(! "Query_arena::cleanup_stmt() not implemented");
}
/*
@@ -2798,6 +2806,14 @@ Security_context::restore_security_context(THD *thd,
}
#endif
+
+bool Security_context::user_matches(Security_context *them)
+{
+ return ((user != NULL) && (them->user != NULL) &&
+ !strcmp(user, them->user));
+}
+
+
/****************************************************************************
Handling of open and locked tables states.
@@ -3657,10 +3673,14 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
If we are in statement mode and trying to log an unsafe statement,
we should print a warning.
*/
- if (lex->is_stmt_unsafe() &&
+ if (sql_log_bin_toplevel && lex->is_stmt_unsafe() &&
variables.binlog_format == BINLOG_FORMAT_STMT)
{
- push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,
+ /*
+ A warning can be elevated a error when STRICT sql mode.
+ But we don't want to elevate binlog warning to error here.
+ */
+ push_warning(this, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_BINLOG_UNSAFE_STATEMENT,
ER(ER_BINLOG_UNSAFE_STATEMENT));
if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED))
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 413e2f5be86..158f4bc27d6 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -321,6 +321,8 @@ struct system_variables
ulong net_write_timeout;
ulong optimizer_prune_level;
ulong optimizer_search_depth;
+ /* A bitmap for switching optimizations on/off */
+ ulong optimizer_switch;
ulong preload_buff_size;
ulong profiling_history_size;
ulong query_cache_type;
@@ -664,7 +666,7 @@ public:
*/
char *db;
- uint db_length;
+ size_t db_length;
public:
@@ -811,6 +813,7 @@ public:
void
restore_security_context(THD *thd, Security_context *backup);
#endif
+ bool user_matches(Security_context *);
};
@@ -1350,6 +1353,8 @@ public:
/* <> 0 if we are inside of trigger or stored function. */
uint in_sub_stmt;
+ /* TRUE when the current top has SQL_LOG_BIN ON */
+ bool sql_log_bin_toplevel;
/* container for handler's private per-connection data */
Ha_data ha_data[MAX_HA];
@@ -1770,6 +1775,9 @@ public:
sp_cache *sp_proc_cache;
sp_cache *sp_func_cache;
+ /** number of name_const() substitutions, see sp_head.cc:subst_spvars() */
+ uint query_name_consts;
+
/*
If we do a purge of binary logs, log index info of the threads
that are currently reading it needs to be adjusted. To do that
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 02c8297d019..06528a27da5 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -55,7 +55,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
USER_RESOURCES *mqh)
{
int return_val= 0;
- uint temp_len, user_len;
+ size_t temp_len, user_len;
char temp_user[USER_HOST_BUFF_SIZE];
struct user_conn *uc;
diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc
index ebd424f00f0..c4f93cc2a33 100644
--- a/sql/sql_crypt.cc
+++ b/sql/sql_crypt.cc
@@ -28,10 +28,10 @@
#include "mysql_priv.h"
-SQL_CRYPT::SQL_CRYPT(const char *password)
+SQL_CRYPT::SQL_CRYPT(const char *password, uint length)
{
ulong rand_nr[2];
- hash_password(rand_nr,password, strlen(password));
+ hash_password(rand_nr,password, length);
crypt_init(rand_nr);
}
diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h
index f3db9adde25..a5a6bee8a58 100644
--- a/sql/sql_crypt.h
+++ b/sql/sql_crypt.h
@@ -25,7 +25,7 @@ class SQL_CRYPT :public Sql_alloc
uint shift;
void crypt_init(ulong *seed);
public:
- SQL_CRYPT(const char *seed);
+ SQL_CRYPT(const char *seed, uint length);
SQL_CRYPT(ulong *seed)
{
crypt_init(seed);
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 72ae664bba1..5a266c3fac9 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -181,7 +181,7 @@ uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length,
static inline void write_to_binlog(THD *thd, char *query, uint q_len,
char *db, uint db_len)
{
- Query_log_event qinfo(thd, query, q_len, 0, 0);
+ Query_log_event qinfo(thd, query, q_len, 0, 0, THD::NOT_KILLED);
qinfo.error_code= 0;
qinfo.db= db;
qinfo.db_len= db_len;
@@ -724,7 +724,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, query, query_length, 0,
- /* suppress_use */ TRUE);
+ /* suppress_use */ TRUE, THD::NOT_KILLED);
/*
Write should use the database being created as the "current
@@ -812,7 +812,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0,
- /* suppress_use */ TRUE);
+ /* suppress_use */ TRUE, THD::NOT_KILLED);
/*
Write should use the database being created as the "current
@@ -959,7 +959,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
if (mysql_bin_log.is_open())
{
Query_log_event qinfo(thd, query, query_length, 0,
- /* suppress_use */ TRUE);
+ /* suppress_use */ TRUE, THD::NOT_KILLED);
/*
Write should use the database being created as the "current
database" and not the threads current database, which is the
@@ -1958,7 +1958,8 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db)
/* Step8: logging */
if (mysql_bin_log.is_open())
{
- Query_log_event qinfo(thd, thd->query, thd->query_length, 0, TRUE);
+ Query_log_event qinfo(thd, thd->query, thd->query_length,
+ 0, TRUE, THD::NOT_KILLED);
thd->clear_error();
mysql_bin_log.write(&qinfo);
}
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index d87eafa3e0c..1b42e522491 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -709,6 +709,8 @@ bool multi_delete::send_data(List<Item> &values)
TABLE_LIST *del_table;
DBUG_ENTER("multi_delete::send_data");
+ bool ignore= thd->lex->current_select->no_error;
+
for (del_table= delete_tables;
del_table;
del_table= del_table->next_local, secure_counter++)
@@ -741,8 +743,12 @@ bool multi_delete::send_data(List<Item> &values)
TRG_ACTION_AFTER, FALSE))
DBUG_RETURN(1);
}
- else
+ else if (!ignore)
{
+ /*
+ If the IGNORE option is used errors caused by ha_delete_row don't
+ have to stop the iteration.
+ */
table->file->print_error(error,MYF(0));
DBUG_RETURN(1);
}
@@ -834,6 +840,11 @@ int multi_delete::do_deletes()
{
int local_error= 0, counter= 0, tmp_error;
bool will_batch;
+ /*
+ If the IGNORE option is used all non fatal errors will be translated
+ to warnings and we should not break the row-by-row iteration
+ */
+ bool ignore= thd->lex->current_select->no_error;
DBUG_ENTER("do_deletes");
DBUG_ASSERT(do_delete);
@@ -872,18 +883,29 @@ int multi_delete::do_deletes()
local_error= 1;
break;
}
- if ((local_error=table->file->ha_delete_row(table->record[0])))
+
+ local_error= table->file->ha_delete_row(table->record[0]);
+ if (local_error && !ignore)
{
- table->file->print_error(local_error,MYF(0));
- break;
+ table->file->print_error(local_error,MYF(0));
+ break;
}
- deleted++;
- if (table->triggers &&
- table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
- TRG_ACTION_AFTER, FALSE))
+
+ /*
+ Increase the reported number of deleted rows only if no error occurred
+ during ha_delete_row.
+ Also, don't execute the AFTER trigger if the row operation failed.
+ */
+ if (!local_error)
{
- local_error= 1;
- break;
+ deleted++;
+ if (table->triggers &&
+ table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
+ TRG_ACTION_AFTER, FALSE))
+ {
+ local_error= 1;
+ break;
+ }
}
}
if (will_batch && (tmp_error= table->file->end_bulk_delete()))
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index bd8f9469571..9ea7facbe41 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -251,7 +251,7 @@ bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
protocol->store(warning_level_names[err->level].str,
warning_level_names[err->level].length, system_charset_info);
protocol->store((uint32) err->code);
- protocol->store(err->msg, strlen(err->msg), system_charset_info);
+ protocol->store(err->msg, (uint) strlen(err->msg), system_charset_info);
if (protocol->write())
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 28a9fb5c78e..16810e29343 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -160,6 +160,9 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables,
table->query_id= thd->query_id;
table->open_by_handler= 0;
}
+
+ /* Mark table as closed, ready for re-open if necessary. */
+ tables->table= NULL;
}
/*
@@ -177,8 +180,7 @@ static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables,
'reopen' is set when a handler table is to be re-opened. In this case,
'tables' is the pointer to the hashed TABLE_LIST object which has been
saved on the original open.
- 'reopen' is also used to suppress the sending of an 'ok' message or
- error messages.
+ 'reopen' is also used to suppress the sending of an 'ok' message.
RETURN
FALSE OK
@@ -197,6 +199,14 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
tables->db, tables->table_name, tables->alias,
(int) reopen));
+ if (tables->schema_table)
+ {
+ my_error(ER_WRONG_USAGE, MYF(0), "HANDLER OPEN",
+ INFORMATION_SCHEMA_NAME.str);
+ DBUG_PRINT("exit",("ERROR"));
+ DBUG_RETURN(TRUE);
+ }
+
if (! hash_inited(&thd->handler_tables_hash))
{
/*
@@ -214,8 +224,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
strlen(tables->alias) + 1))
{
DBUG_PRINT("info",("duplicate '%s'", tables->alias));
- if (! reopen)
- my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias);
+ my_error(ER_NONUNIQ_TABLE, MYF(0), tables->alias);
goto err;
}
}
@@ -259,8 +268,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* There can be only one table in '*tables'. */
if (! (tables->table->file->ha_table_flags() & HA_CAN_SQL_HANDLER))
{
- if (! reopen)
- my_error(ER_ILLEGAL_HA, MYF(0), tables->alias);
+ my_error(ER_ILLEGAL_HA, MYF(0), tables->alias);
goto err;
}
@@ -479,8 +487,7 @@ retry:
if (need_reopen)
{
- mysql_ha_close_table(thd, tables, FALSE);
- hash_tables->table= NULL;
+ mysql_ha_close_table(thd, hash_tables, FALSE);
/*
The lock might have been aborted, we need to manually reset
thd->some_tables_deleted because handler's tables are closed
@@ -761,11 +768,7 @@ void mysql_ha_flush(THD *thd)
{
hash_tables= (TABLE_LIST*) hash_element(&thd->handler_tables_hash, i);
if (hash_tables->table && hash_tables->table->needs_reopen_or_name_lock())
- {
mysql_ha_close_table(thd, hash_tables, TRUE);
- /* Mark table as closed, ready for re-open. */
- hash_tables->table= NULL;
- }
}
DBUG_VOID_RETURN;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 322391b63e8..9eef9d224e6 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -904,20 +904,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
}
DBUG_ASSERT(transactional_table || !changed ||
thd->transaction.stmt.modified_non_trans_table);
-
- if (thd->lock)
- {
- /*
- Invalidate the table in the query cache if something changed
- after unlocking when changes become fisible.
- TODO: this is workaround. right way will be move invalidating in
- the unlock procedure.
- */
- if (lock_type == TL_WRITE_CONCURRENT_INSERT && changed)
- {
- query_cache_invalidate3(thd, table_list, 1);
- }
- }
}
thd_proc_info(thd, "end");
/*
@@ -1668,11 +1654,12 @@ public:
ulong auto_increment_offset;
timestamp_auto_set_type timestamp_field_type;
LEX_STRING query;
+ Time_zone *time_zone;
delayed_row(LEX_STRING const query_arg, enum_duplicates dup_arg,
bool ignore_arg, bool log_query_arg)
: record(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg),
- forced_insert_id(0), query(query_arg)
+ forced_insert_id(0), query(query_arg), time_zone(0)
{}
~delayed_row()
{
@@ -1893,7 +1880,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
pthread_mutex_lock(&LOCK_thread_count);
thread_count++;
pthread_mutex_unlock(&LOCK_thread_count);
- di->thd.set_db(table_list->db, strlen(table_list->db));
+ di->thd.set_db(table_list->db, (uint) strlen(table_list->db));
di->thd.query= my_strdup(table_list->table_name, MYF(MY_WME));
if (di->thd.db == NULL || di->thd.query == NULL)
{
@@ -2161,6 +2148,19 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
thd->first_successful_insert_id_in_prev_stmt;
row->timestamp_field_type= table->timestamp_field_type;
+ /* Add session variable timezone
+ Time_zone object will not be freed even the thread is ended.
+ So we can get time_zone object from thread which handling delayed statement.
+ See the comment of my_tz_find() for detail.
+ */
+ if (thd->time_zone_used)
+ {
+ row->time_zone = thd->variables.time_zone;
+ }
+ else
+ {
+ row->time_zone = NULL;
+ }
/* Copy session variables. */
row->auto_increment_increment= thd->variables.auto_increment_increment;
row->auto_increment_offset= thd->variables.auto_increment_offset;
@@ -2659,6 +2659,14 @@ bool Delayed_insert::handle_inserts(void)
if (log_query && mysql_bin_log.is_open())
{
+ bool backup_time_zone_used = thd.time_zone_used;
+ Time_zone *backup_time_zone = thd.variables.time_zone;
+ if (row->time_zone != NULL)
+ {
+ thd.time_zone_used = true;
+ thd.variables.time_zone = row->time_zone;
+ }
+
/*
If the query has several rows to insert, only the first row will come
here. In row-based binlogging, this means that the first row will be
@@ -2670,6 +2678,9 @@ bool Delayed_insert::handle_inserts(void)
thd.binlog_query(THD::ROW_QUERY_TYPE,
row->query.str, row->query.length,
FALSE, FALSE);
+
+ thd.time_zone_used = backup_time_zone_used;
+ thd.variables.time_zone = backup_time_zone;
}
if (table->s->blob_fields)
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 9619d26893c..b96ac91679b 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -253,7 +253,7 @@ void Lex_input_stream::body_utf8_append_literal(THD *thd,
{
thd->convert_string(&utf_txt,
&my_charset_utf8_general_ci,
- txt->str, txt->length,
+ txt->str, (uint) txt->length,
txt_cs);
}
else
@@ -348,6 +348,7 @@ void lex_start(THD *thd)
lex->nest_level=0 ;
lex->allow_sum_func= 0;
lex->in_sum_func= NULL;
+ lex->protect_against_global_read_lock= FALSE;
/*
ok, there must be a better solution for this, long-term
I tried "bzero" in the sql_yacc.yy code, but that for
@@ -435,7 +436,7 @@ bool is_keyword(const char *name, uint len)
bool is_lex_native_function(const LEX_STRING *name)
{
DBUG_ASSERT(name != NULL);
- return (get_hash_symbol(name->str, name->length, 1) != 0);
+ return (get_hash_symbol(name->str, (uint) name->length, 1) != 0);
}
/* make a copy of token before ptr and set yytoklen */
@@ -712,6 +713,53 @@ static inline uint int_token(const char *str,uint length)
return ((uchar) str[-1] <= (uchar) cmp[-1]) ? smaller : bigger;
}
+
+/**
+ Given a stream that is advanced to the first contained character in
+ an open comment, consume the comment. Optionally, if we are allowed,
+ recurse so that we understand comments within this current comment.
+
+ At this level, we do not support version-condition comments. We might
+ have been called with having just passed one in the stream, though. In
+ that case, we probably want to tolerate mundane comments inside. Thus,
+ the case for recursion.
+
+ @retval Whether EOF reached before comment is closed.
+*/
+bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted)
+{
+ reg1 uchar c;
+ while (! lip->eof())
+ {
+ c= lip->yyGet();
+
+ if (remaining_recursions_permitted > 0)
+ {
+ if ((c == '/') && (lip->yyPeek() == '*'))
+ {
+ lip->yySkip(); /* Eat asterisk */
+ consume_comment(lip, remaining_recursions_permitted-1);
+ continue;
+ }
+ }
+
+ if (c == '*')
+ {
+ if (lip->yyPeek() == '/')
+ {
+ lip->yySkip(); /* Eat slash */
+ return FALSE;
+ }
+ }
+
+ if (c == '\n')
+ lip->yylineno++;
+ }
+
+ return TRUE;
+}
+
+
/*
MYSQLlex remember the following states from the following MYSQLlex()
@@ -1074,7 +1122,7 @@ int MYSQLlex(void *arg, void *yythd)
if (c != '.')
{ // Found complete integer number.
yylval->lex_str=get_token(lip, 0, lip->yyLength());
- return int_token(yylval->lex_str.str,yylval->lex_str.length);
+ return int_token(yylval->lex_str.str, (uint) yylval->lex_str.length);
}
// fall through
case MY_LEX_REAL: // Incomplete real number
@@ -1204,6 +1252,8 @@ int MYSQLlex(void *arg, void *yythd)
/* Reject '/' '*', since we might need to turn off the echo */
lip->yyUnget();
+ lip->save_in_comment_state();
+
if (lip->yyPeekn(2) == '!')
{
lip->in_comment= DISCARD_COMMENT;
@@ -1246,11 +1296,17 @@ int MYSQLlex(void *arg, void *yythd)
/* Expand the content of the special comment as real code */
lip->set_echo(TRUE);
state=MY_LEX_START;
- break;
+ break; /* Do not treat contents as a comment. */
+ }
+ else
+ {
+ comment_closed= ! consume_comment(lip, 1);
+ /* version allowed to have one level of comment inside. */
}
}
else
{
+ /* Not a version comment. */
state=MY_LEX_START;
lip->set_echo(TRUE);
break;
@@ -1261,38 +1317,30 @@ int MYSQLlex(void *arg, void *yythd)
lip->in_comment= PRESERVE_COMMENT;
lip->yySkip(); // Accept /
lip->yySkip(); // Accept *
+ comment_closed= ! consume_comment(lip, 0);
+ /* regular comments can have zero comments inside. */
}
/*
Discard:
- regular '/' '*' comments,
- special comments '/' '*' '!' for a future version,
by scanning until we find a closing '*' '/' marker.
- Note: There is no such thing as nesting comments,
- the first '*' '/' sequence seen will mark the end.
+
+ Nesting regular comments isn't allowed. The first
+ '*' '/' returns the parser to the previous state.
+
+ /#!VERSI oned containing /# regular #/ is allowed #/
+
+ Inside one versioned comment, another versioned comment
+ is treated as a regular discardable comment. It gets
+ no special parsing.
*/
- comment_closed= FALSE;
- while (! lip->eof())
- {
- c= lip->yyGet();
- if (c == '*')
- {
- if (lip->yyPeek() == '/')
- {
- lip->yySkip();
- comment_closed= TRUE;
- state = MY_LEX_START;
- break;
- }
- }
- else if (c == '\n')
- lip->yylineno++;
- }
+
/* Unbalanced comments with a missing '*' '/' are a syntax error */
if (! comment_closed)
return (ABORT_SYM);
state = MY_LEX_START; // Try again
- lip->in_comment= NO_COMMENT;
- lip->set_echo(TRUE);
+ lip->restore_in_comment_state();
break;
case MY_LEX_END_LONG_COMMENT:
if ((lip->in_comment != NO_COMMENT) && lip->yyPeek() == '/')
@@ -1559,6 +1607,7 @@ void st_select_lex::init_query()
exclude_from_table_unique_test= no_wrap_view_item= FALSE;
nest_level= 0;
link_next= 0;
+ lock_option= TL_READ_DEFAULT;
}
void st_select_lex::init_select()
@@ -1977,8 +2026,8 @@ void st_select_lex::print_order(String *str,
if (order->counter_used)
{
char buffer[20];
- uint length= my_snprintf(buffer, 20, "%d", order->counter);
- str->append(buffer, length);
+ size_t length= my_snprintf(buffer, 20, "%d", order->counter);
+ str->append(buffer, (uint) length);
}
else
(*order->item)->print(str, query_type);
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index ed6b9e7d8df..62106a2500b 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -688,6 +688,15 @@ public:
int cur_pos_in_select_list;
List<udf_func> udf_list; /* udf function calls stack */
+
+ /**
+ Per sub-query locking strategy.
+ Note: This variable might interfer with the corresponding statement-level
+ variable Lex::lock_option because on how different parser rules depend
+ on eachother.
+ */
+ thr_lock_type lock_option;
+
/*
This is a copy of the original JOIN USING list that comes from
the parser. The parser :
@@ -1151,6 +1160,18 @@ public:
m_echo= echo;
}
+ void save_in_comment_state()
+ {
+ m_echo_saved= m_echo;
+ in_comment_saved= in_comment;
+ }
+
+ void restore_in_comment_state()
+ {
+ m_echo= m_echo_saved;
+ in_comment= in_comment_saved;
+ }
+
/**
Skip binary from the input stream.
@param n number of bytes to accept.
@@ -1361,7 +1382,7 @@ public:
/** Get the utf8-body length. */
uint get_body_utf8_length()
{
- return m_body_utf8_ptr - m_body_utf8;
+ return (uint) (m_body_utf8_ptr - m_body_utf8);
}
void body_utf8_start(THD *thd, const char *begin_ptr);
@@ -1408,6 +1429,7 @@ private:
/** Echo the parsed stream to the pre-processed buffer. */
bool m_echo;
+ bool m_echo_saved;
/** Pre-processed buffer. */
char *m_cpp_buf;
@@ -1470,6 +1492,7 @@ public:
/** State of the lexical analyser for comments. */
enum_comment_state in_comment;
+ enum_comment_state in_comment_saved;
/**
Starting position of the TEXT_STRING or IDENT in the pre-processed
@@ -1736,6 +1759,22 @@ typedef struct st_lex : public Query_tables_list
bool escape_used;
bool is_lex_started; /* If lex_start() did run. For debugging. */
+ /*
+ Special case for SELECT .. FOR UPDATE and LOCK TABLES .. WRITE.
+
+ Protect from a impending GRL as otherwise the thread might deadlock
+ if it starts waiting for the GRL in mysql_lock_tables.
+
+ The protection is needed because there is a race between setting
+ the global read lock and waiting for all open tables to be closed.
+ The problem is a circular wait where a thread holding "old" open
+ tables will wait for the global read lock to be released while the
+ thread holding the global read lock will wait for all "old" open
+ tables to be closed -- the flush part of flush tables with read
+ lock.
+ */
+ bool protect_against_global_read_lock;
+
st_lex();
virtual ~st_lex()
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 239fb1d49f3..d4f499b8d44 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -15,10 +15,10 @@
/* Copy data from a textfile to table */
-
#include "mysql_priv.h"
#include <my_dir.h>
#include <m_ctype.h>
+#include "rpl_mi.h"
#include "sql_repl.h"
#include "sp_head.h"
#include "sql_trigger.h"
@@ -310,8 +310,31 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
is_fifo = 1;
#endif
- if (opt_secure_file_priv &&
- strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
+ if (thd->slave_thread)
+ {
+#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
+ if (strncmp(active_mi->rli.slave_patternload_file, name,
+ active_mi->rli.slave_patternload_file_size))
+ {
+ /*
+ LOAD DATA INFILE in the slave SQL Thread can only read from
+ --slave-load-tmpdir". This should never happen. Please, report a bug.
+ */
+
+ sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
+ "Please, report a bug.");
+ my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
+ DBUG_RETURN(TRUE);
+ }
+#else
+ /*
+ This is impossible and should never happen.
+ */
+ DBUG_ASSERT(FALSE);
+#endif
+ }
+ else if (opt_secure_file_priv &&
+ strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
{
/* Read only allowed from within dir specified by secure_file_priv */
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
@@ -534,8 +557,8 @@ static bool write_execute_load_query_log_event(THD *thd,
{
Execute_load_query_log_event
e(thd, thd->query, thd->query_length,
- (char*)thd->lex->fname_start - (char*)thd->query,
- (char*)thd->lex->fname_end - (char*)thd->query,
+ (uint) ((char*)thd->lex->fname_start - (char*)thd->query),
+ (uint) ((char*)thd->lex->fname_end - (char*)thd->query),
(duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
(ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
transactional_table, FALSE, killed_err_arg);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6e9bf6650e2..87497b35bd3 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2230,8 +2230,15 @@ mysql_execute_command(THD *thd)
res= check_access(thd,
lex->exchange ? SELECT_ACL | FILE_ACL : SELECT_ACL,
any_db, 0, 0, 0, 0);
- if (!res)
- res= execute_sqlcom_select(thd, all_tables);
+
+ if (res)
+ break;
+
+ if (!thd->locked_tables && lex->protect_against_global_read_lock &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ break;
+
+ res= execute_sqlcom_select(thd, all_tables);
break;
case SQLCOM_PREPARE:
{
@@ -2588,6 +2595,43 @@ mysql_execute_command(THD *thd)
{
select_result *result;
+ /*
+ If:
+ a) we inside an SP and there was NAME_CONST substitution,
+ b) binlogging is on (STMT mode),
+ c) we log the SP as separate statements
+ raise a warning, as it may cause problems
+ (see 'NAME_CONST issues' in 'Binary Logging of Stored Programs')
+ */
+ if (thd->query_name_consts &&
+ mysql_bin_log.is_open() &&
+ thd->variables.binlog_format == BINLOG_FORMAT_STMT &&
+ !mysql_bin_log.is_query_in_union(thd, thd->query_id))
+ {
+ List_iterator_fast<Item> it(select_lex->item_list);
+ Item *item;
+ uint splocal_refs= 0;
+ /* Count SP local vars in the top-level SELECT list */
+ while ((item= it++))
+ {
+ if (item->is_splocal())
+ splocal_refs++;
+ }
+ /*
+ If it differs from number of NAME_CONST substitution applied,
+ we may have a SOME_FUNC(NAME_CONST()) in the SELECT list,
+ that may cause a problem with binary log (see BUG#35383),
+ raise a warning.
+ */
+ if (splocal_refs != thd->query_name_consts)
+ push_warning(thd,
+ MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR,
+"Invoked routine ran a statement that may cause problems with "
+"binary log, see 'NAME_CONST issues' in 'Binary Logging of Stored Programs' "
+"section of the manual.");
+ }
+
select_lex->options|= SELECT_NO_UNLOCK;
unit->set_limit(select_lex);
@@ -3001,6 +3045,9 @@ end_with_restore_list:
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if (update_precheck(thd, all_tables))
break;
+ if (!thd->locked_tables &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
DBUG_ASSERT(select_lex->offset_limit == 0);
unit->set_limit(select_lex);
MYSQL_UPDATE_START(thd->query);
@@ -3031,6 +3078,15 @@ end_with_restore_list:
else
res= 0;
+ /*
+ Protection might have already been risen if its a fall through
+ from the SQLCOM_UPDATE case above.
+ */
+ if (!thd->locked_tables &&
+ lex->sql_command == SQLCOM_UPDATE_MULTI &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
+
res= mysql_multi_update_prepare(thd);
#ifdef HAVE_REPLICATION
@@ -3246,7 +3302,8 @@ end_with_restore_list:
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
-
+ if (!(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
res= mysql_truncate(thd, first_table, 0);
break;
case SQLCOM_DELETE:
@@ -3428,6 +3485,10 @@ end_with_restore_list:
if (check_one_table_access(thd, privilege, all_tables))
goto error;
+ if (!thd->locked_tables &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
+
res= mysql_load(thd, lex->exchange, first_table, lex->field_list,
lex->update_list, lex->value_list, lex->duplicates,
lex->ignore, (bool) lex->local_file);
@@ -3498,6 +3559,9 @@ end_with_restore_list:
if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables,
UINT_MAX, FALSE))
goto error;
+ if (lex->protect_against_global_read_lock &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
thd->in_lock_tables=1;
thd->options|= OPTION_TABLE_LOCK;
@@ -4192,9 +4256,32 @@ end_with_restore_list:
res= (sp_result= lex->sphead->create(thd));
switch (sp_result) {
- case SP_OK:
+ case SP_OK: {
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* only add privileges if really neccessary */
+
+ Security_context security_context;
+ bool restore_backup_context= false;
+ Security_context *backup= NULL;
+ LEX_USER *definer= thd->lex->definer;
+ /*
+ Check if the definer exists on slave,
+ then use definer privilege to insert routine privileges to mysql.procs_priv.
+
+ For current user of SQL thread has GLOBAL_ACL privilege,
+ which doesn't any check routine privileges,
+ so no routine privilege record will insert into mysql.procs_priv.
+ */
+ if (thd->slave_thread && is_acl_user(definer->host.str, definer->user.str))
+ {
+ security_context.change_security_context(thd,
+ &thd->lex->definer->user,
+ &thd->lex->definer->host,
+ &thd->lex->sphead->m_db,
+ &backup);
+ restore_backup_context= true;
+ }
+
if (sp_automatic_privileges && !opt_noacl &&
check_routine_access(thd, DEFAULT_CREATE_PROC_ACLS,
lex->sphead->m_db.str, name,
@@ -4206,8 +4293,19 @@ end_with_restore_list:
ER_PROC_AUTO_GRANT_FAIL,
ER(ER_PROC_AUTO_GRANT_FAIL));
}
+
+ /*
+ Restore current user with GLOBAL_ACL privilege of SQL thread
+ */
+ if (restore_backup_context)
+ {
+ DBUG_ASSERT(thd->slave_thread == 1);
+ thd->security_ctx->restore_security_context(thd, backup);
+ }
+
#endif
break;
+ }
case SP_WRITE_ROW_FAILED:
my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name);
break;
@@ -4490,6 +4588,7 @@ create_sp_error:
case SP_KEY_NOT_FOUND:
if (lex->drop_if_exists)
{
+ write_bin_log(thd, TRUE, thd->query, thd->query_length);
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
SP_COM_STRING(lex), lex->spname->m_name.str);
@@ -5642,6 +5741,14 @@ void mysql_reset_thd_for_next_command(THD *thd)
}
+/**
+ Resets the lex->current_select object.
+ @note It is assumed that lex->current_select != NULL
+
+ This function is a wrapper around select_lex->init_select() with an added
+ check for the special situation when using INTO OUTFILE and LOAD DATA.
+*/
+
void
mysql_init_select(LEX *lex)
{
@@ -5656,6 +5763,18 @@ mysql_init_select(LEX *lex)
}
+/**
+ Used to allocate a new SELECT_LEX object on the current thd mem_root and
+ link it into the relevant lists.
+
+ This function is always followed by mysql_init_select.
+
+ @see mysql_init_select
+
+ @retval TRUE An error occurred
+ @retval FALSE The new SELECT_LEX was successfully allocated.
+*/
+
bool
mysql_new_select(LEX *lex, bool move_down)
{
@@ -6482,7 +6601,6 @@ void st_select_lex::set_lock_for_tables(thr_lock_type lock_type)
DBUG_ENTER("set_lock_for_tables");
DBUG_PRINT("enter", ("lock_type: %d for_update: %d", lock_type,
for_update));
-
for (TABLE_LIST *tables= (TABLE_LIST*) table_list.first;
tables;
tables= tables->next_local)
@@ -6908,8 +7026,26 @@ uint kill_one_thread(THD *thd, ulong id, bool only_kill_query)
VOID(pthread_mutex_unlock(&LOCK_thread_count));
if (tmp)
{
+
+ /*
+ If we're SUPER, we can KILL anything, including system-threads.
+ No further checks.
+
+ KILLer: thd->security_ctx->user could in theory be NULL while
+ we're still in "unauthenticated" state. This is a theoretical
+ case (the code suggests this could happen, so we play it safe).
+
+ KILLee: tmp->security_ctx->user will be NULL for system threads.
+ We need to check so Jane Random User doesn't crash the server
+ when trying to kill a) system threads or b) unauthenticated users'
+ threads (Bug#43748).
+
+ If user of both killer and killee are non-NULL, proceed with
+ slayage if both are string-equal.
+ */
+
if ((thd->security_ctx->master_access & SUPER_ACL) ||
- !strcmp(thd->security_ctx->user, tmp->security_ctx->user))
+ thd->security_ctx->user_matches(tmp->security_ctx))
{
tmp->awake(only_kill_query ? THD::KILL_QUERY : THD::KILL_CONNECTION);
error=0;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index ae55c194c3c..4a50650b6f4 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -2937,7 +2937,8 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
the maximum value is in the current partition.
*/
if (part_func_value > bound ||
- (part_func_value == bound && !part_info->defined_max_value))
+ (part_func_value == bound &&
+ (!part_info->defined_max_value || loc_part_id < max_partition)))
loc_part_id++;
}
else
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 60f205ec8e8..1465b6d2d30 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1139,8 +1139,9 @@ int plugin_init(int *argc, char **argv, int flags)
for (plugin= *builtins; plugin->info; plugin++)
{
if (opt_ignore_builtin_innodb &&
- !my_strcasecmp(&my_charset_latin1, plugin->name, "InnoDB"))
- continue;
+ !my_strnncoll(&my_charset_latin1, (const uchar*) plugin->name,
+ 6, (const uchar*) "InnoDB", 6))
+ continue;
/* by default, ndbcluster and federated are disabled */
def_enabled=
my_strcasecmp(&my_charset_latin1, plugin->name, "NDBCLUSTER") != 0 &&
@@ -1633,8 +1634,8 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl
{
TABLE_LIST tables;
TABLE *table;
- int error, argc;
- char *argv[2];
+ int error, argc=orig_argc;
+ char **argv=orig_argv;
struct st_plugin_int *tmp;
DBUG_ENTER("mysql_install_plugin");
@@ -1650,21 +1651,31 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl
pthread_mutex_lock(&LOCK_plugin);
rw_wrlock(&LOCK_system_variables_hash);
- /* handle_options() assumes arg0 (program name) always exists */
- argv[0]= const_cast<char*>(""); // without a cast gcc emits a warning
- argv[1]= 0;
- argc= 1;
+
+ my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL);
error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER);
+ if (argv)
+ free_defaults(argv);
rw_unlock(&LOCK_system_variables_hash);
if (error || !(tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
goto err;
- if (plugin_initialize(tmp))
+ if (tmp->state == PLUGIN_IS_DISABLED)
{
- my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
- "Plugin initialization function failed.");
- goto deinit;
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_CANT_INITIALIZE_UDF, ER(ER_CANT_INITIALIZE_UDF),
+ name->str, "Plugin is disabled");
+ }
+ else
+ {
+ DBUG_ASSERT(tmp->state == PLUGIN_IS_UNINITIALIZED);
+ if (plugin_initialize(tmp))
+ {
+ my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
+ "Plugin initialization function failed.");
+ goto deinit;
+ }
}
/*
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 0ae902bcd0a..29d948472c7 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -760,13 +760,13 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array,
Item_param *param= *it;
if (param->state != Item_param::LONG_DATA_VALUE)
{
- if (is_param_null(null_array, it - begin))
+ if (is_param_null(null_array, (uint) (it - begin)))
param->set_null();
else
{
if (read_pos >= data_end)
DBUG_RETURN(1);
- param->set_param_func(param, &read_pos, data_end - read_pos);
+ param->set_param_func(param, &read_pos, (uint) (data_end - read_pos));
if (param->state == Item_param::NO_VALUE)
DBUG_RETURN(1);
}
@@ -798,13 +798,13 @@ static bool insert_params(Prepared_statement *stmt, uchar *null_array,
Item_param *param= *it;
if (param->state != Item_param::LONG_DATA_VALUE)
{
- if (is_param_null(null_array, it - begin))
+ if (is_param_null(null_array, (uint) (it - begin)))
param->set_null();
else
{
if (read_pos >= data_end)
DBUG_RETURN(1);
- param->set_param_func(param, &read_pos, data_end - read_pos);
+ param->set_param_func(param, &read_pos, (uint) (data_end - read_pos));
if (param->state == Item_param::NO_VALUE)
DBUG_RETURN(1);
}
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index cb5b3722559..8c9b147089f 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -119,7 +119,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
if (field)
{
field->set_name(field_info->old_name,
- strlen(field_info->old_name),
+ (uint) strlen(field_info->old_name),
system_charset_info);
if (add_item_to_list(thd, field))
return 1;
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index fc87356e452..d4331b12cd4 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -301,12 +301,17 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
}
break;
case FRMTYPE_VIEW:
- /* change of schema is not allowed */
- if (strcmp(ren_table->db, new_db))
+ /*
+ change of schema is not allowed
+ except of ALTER ...UPGRADE DATA DIRECTORY NAME command
+ because a view has valid internal db&table names in this case.
+ */
+ if (thd->lex->sql_command != SQLCOM_ALTER_DB_UPGRADE &&
+ strcmp(ren_table->db, new_db))
my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db,
new_db);
else
- rc= mysql_rename_view(thd, new_alias, ren_table);
+ rc= mysql_rename_view(thd, new_db, new_alias, ren_table);
break;
default:
DBUG_ASSERT(0); // should never happen
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 81db5469891..06c6c022780 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -205,7 +205,7 @@ void adjust_linfo_offsets(my_off_t purge_offset)
bool log_in_use(const char* log_name)
{
- int log_name_len = strlen(log_name) + 1;
+ size_t log_name_len = strlen(log_name) + 1;
THD *tmp;
bool result = 0;
@@ -1026,7 +1026,10 @@ int reset_slave(THD *thd, Master_info* mi)
if ((error= purge_relay_logs(&mi->rli, thd,
1 /* just reset */,
&errmsg)))
+ {
+ sql_errno= ER_RELAY_LOG_FAIL;
goto err;
+ }
/*
Clear master's log coordinates and reset host/user/etc to the values
@@ -1366,8 +1369,8 @@ int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
const char* log_file_name2, ulonglong log_pos2)
{
int res;
- uint log_file_name1_len= strlen(log_file_name1);
- uint log_file_name2_len= strlen(log_file_name2);
+ size_t log_file_name1_len= strlen(log_file_name1);
+ size_t log_file_name2_len= strlen(log_file_name2);
// We assume that both log names match up to '.'
if (log_file_name1_len == log_file_name2_len)
@@ -1687,7 +1690,7 @@ int log_loaded_block(IO_CACHE* file)
lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
DBUG_RETURN(0);
- for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0;
+ for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
buffer += min(block_len, max_event_size),
block_len -= min(block_len, max_event_size))
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9dd72ab55ba..b6cf3848eee 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2463,11 +2463,12 @@ typedef struct st_sargable_param
*/
static bool
-make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
+make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
DYNAMIC_ARRAY *keyuse_array)
{
int error;
TABLE *table;
+ TABLE_LIST *tables= tables_arg;
uint i,table_count,const_count,key;
table_map found_const_table_map, all_table_map, found_ref, refs;
key_map const_ref, eq_part;
@@ -2505,10 +2506,10 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
table_vector[i]=s->table=table=tables->table;
table->pos_in_table_list= tables;
error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
- if(error)
+ if (error)
{
- table->file->print_error(error, MYF(0));
- DBUG_RETURN(1);
+ table->file->print_error(error, MYF(0));
+ goto error;
}
table->quick_keys.clear_all();
table->reginfo.join_tab=s;
@@ -2604,7 +2605,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
{
join->tables=0; // Don't use join->table
my_message(ER_WRONG_OUTER_JOIN, ER(ER_WRONG_OUTER_JOIN), MYF(0));
- DBUG_RETURN(1);
+ goto error;
}
s->key_dependent= s->dependent;
}
@@ -2614,7 +2615,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
if (update_ref_and_keys(join->thd, keyuse_array, stat, join->tables,
conds, join->cond_equal,
~outer_join, join->select_lex, &sargables))
- DBUG_RETURN(1);
+ goto error;
/* Read tables with 0 or 1 rows (system tables) */
join->const_table_map= 0;
@@ -2630,7 +2631,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
if ((tmp=join_read_const_table(s, p_pos)))
{
if (tmp > 0)
- DBUG_RETURN(1); // Fatal error
+ goto error; // Fatal error
}
else
found_const_table_map|= s->table->map;
@@ -2702,7 +2703,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
if ((tmp= join_read_const_table(s, join->positions+const_count-1)))
{
if (tmp > 0)
- DBUG_RETURN(1); // Fatal error
+ goto error; // Fatal error
}
else
found_const_table_map|= table->map;
@@ -2751,12 +2752,12 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
set_position(join,const_count++,s,start_keyuse);
if (create_ref_for_key(join, s, start_keyuse,
found_const_table_map))
- DBUG_RETURN(1);
+ goto error;
if ((tmp=join_read_const_table(s,
join->positions+const_count-1)))
{
if (tmp > 0)
- DBUG_RETURN(1); // Fatal error
+ goto error; // Fatal error
}
else
found_const_table_map|= table->map;
@@ -2833,7 +2834,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
*s->on_expr_ref ? *s->on_expr_ref : conds,
1, &error);
if (!select)
- DBUG_RETURN(1);
+ goto error;
records= get_quick_record_count(join->thd, select, s->table,
&s->const_keys, join->row_limit);
s->quick=select->quick;
@@ -2879,7 +2880,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
{
optimize_keyuse(join, keyuse_array);
if (choose_plan(join, all_table_map & ~join->const_table_map))
- DBUG_RETURN(TRUE);
+ goto error;
}
else
{
@@ -2889,6 +2890,17 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
}
/* Generate an execution plan from the found optimal join order. */
DBUG_RETURN(join->thd->killed || get_best_combination(join));
+
+error:
+ /*
+ Need to clean up join_tab from TABLEs in case of error.
+ They won't get cleaned up by JOIN::cleanup() because JOIN::join_tab
+ may not be assigned yet by this function (which is building join_tab).
+ Dangling TABLE::reginfo.join_tab may cause part_of_refkey to choke.
+ */
+ for (tables= tables_arg; tables; tables= tables->next_leaf)
+ tables->table->reginfo.join_tab= NULL;
+ DBUG_RETURN (1);
}
@@ -3467,14 +3479,6 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
}
}
-/**
- Add all keys with uses 'field' for some keypart.
-
- If field->and_level != and_level then only mark key_part as const_part.
-
- @todo
- ft-keys in non-ft queries. SerG
-*/
static uint
max_part_bit(key_part_map bits)
@@ -3484,7 +3488,16 @@ max_part_bit(key_part_map bits)
return found;
}
-static void
+/*
+ Add all keys with uses 'field' for some keypart
+ If field->and_level != and_level then only mark key_part as const_part
+
+ RETURN
+ 0 - OK
+ 1 - Out of memory.
+*/
+
+static bool
add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
{
Field *field=key_field->field;
@@ -3514,24 +3527,26 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
keyuse.optimize= key_field->optimize & KEY_OPTIMIZE_REF_OR_NULL;
keyuse.null_rejecting= key_field->null_rejecting;
keyuse.cond_guard= key_field->cond_guard;
- VOID(insert_dynamic(keyuse_array,(uchar*) &keyuse));
+ if (insert_dynamic(keyuse_array,(uchar*) &keyuse))
+ return TRUE;
}
}
}
}
+ return FALSE;
}
#define FT_KEYPART (MAX_REF_PARTS+10)
-static void
+static bool
add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
JOIN_TAB *stat,COND *cond,table_map usable_tables)
{
Item_func_match *cond_func=NULL;
if (!cond)
- return;
+ return FALSE;
if (cond->type() == Item::FUNC_ITEM)
{
@@ -3565,13 +3580,16 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
{
Item *item;
while ((item=li++))
- add_ft_keys(keyuse_array,stat,item,usable_tables);
+ {
+ if (add_ft_keys(keyuse_array,stat,item,usable_tables))
+ return TRUE;
+ }
}
}
if (!cond_func || cond_func->key == NO_SUCH_KEY ||
!(usable_tables & cond_func->table->map))
- return;
+ return FALSE;
KEYUSE keyuse;
keyuse.table= cond_func->table;
@@ -3581,7 +3599,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
keyuse.used_tables=cond_func->key_item()->used_tables();
keyuse.optimize= 0;
keyuse.keypart_map= 0;
- VOID(insert_dynamic(keyuse_array,(uchar*) &keyuse));
+ return insert_dynamic(keyuse_array,(uchar*) &keyuse);
}
@@ -3735,7 +3753,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
sargables);
for (; field != end ; field++)
{
- add_key_part(keyuse,field);
+ if (add_key_part(keyuse,field))
+ return TRUE;
/* Mark that we can optimize LEFT JOIN */
if (field->val->type() == Item::NULL_ITEM &&
!field->field->real_maybe_null())
@@ -3773,11 +3792,15 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
/* fill keyuse with found key parts */
for ( ; field != end ; field++)
- add_key_part(keyuse,field);
+ {
+ if (add_key_part(keyuse,field))
+ return TRUE;
+ }
if (select_lex->ftfunc_list->elements)
{
- add_ft_keys(keyuse,join_tab,cond,normal_tables);
+ if (add_ft_keys(keyuse,join_tab,cond,normal_tables))
+ return TRUE;
}
/*
@@ -3798,7 +3821,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
(qsort_cmp) sort_keyuse);
bzero((char*) &key_end,sizeof(key_end)); /* Add for easy testing */
- VOID(insert_dynamic(keyuse,(uchar*) &key_end));
+ if (insert_dynamic(keyuse,(uchar*) &key_end))
+ return TRUE;
use=save_pos=dynamic_element(keyuse,0,KEYUSE*);
prev= &key_end;
@@ -7616,7 +7640,7 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond,
if (and_level)
{
/*
- Retrieve all conjucts of this level detecting the equality
+ Retrieve all conjuncts of this level detecting the equality
that are subject to substitution by multiple equality items and
removing each such predicate from the conjunction after having
found/created a multiple equality whose inference the predicate is.
@@ -7632,6 +7656,15 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond,
li.remove();
}
+ /*
+ Check if we eliminated all the predicates of the level, e.g.
+ (a=a AND b=b AND a=a).
+ */
+ if (!args->elements &&
+ !cond_equal.current_level.elements &&
+ !eq_list.elements)
+ return new Item_int((longlong) 1, 1);
+
List_iterator_fast<Item_equal> it(cond_equal.current_level);
while ((item_equal= it++))
{
@@ -9779,6 +9812,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
table->in_use= thd;
table->quick_keys.init();
table->covering_keys.init();
+ table->merge_keys.init();
table->keys_in_use_for_query.init();
table->s= share;
@@ -13447,6 +13481,7 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
{
select->cleanup(); // filesort did select
tab->select= 0;
+ table->quick_keys.clear_all(); // as far as we cleanup select->quick
}
tab->select_cond=0;
tab->last_inner= 0;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 7d794b71f4d..353c2b1d610 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -729,3 +729,9 @@ bool error_if_full_join(JOIN *join);
int report_error(TABLE *table, int error);
int safe_index_read(JOIN_TAB *tab);
COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
+
+inline bool optimizer_flag(THD *thd, uint flag)
+{
+ return (thd->variables.optimizer_switch & flag);
+}
+
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc
index 13bed8001a3..f8a8dea18ff 100644
--- a/sql/sql_servers.cc
+++ b/sql/sql_servers.cc
@@ -60,7 +60,7 @@ prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options);
/* drop functions */
static int delete_server_record(TABLE *table,
char *server_name,
- int server_name_length);
+ size_t server_name_length);
static int delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options);
/* update functions */
@@ -301,7 +301,7 @@ get_server_from_table_to_cache(TABLE *table)
/* get each field into the server struct ptr */
server->server_name= get_field(&mem, table->field[0]);
- server->server_name_length= strlen(server->server_name);
+ server->server_name_length= (uint) strlen(server->server_name);
ptr= get_field(&mem, table->field[1]);
server->host= ptr ? ptr : blank;
ptr= get_field(&mem, table->field[2]);
@@ -911,7 +911,7 @@ end:
static int
delete_server_record(TABLE *table,
- char *server_name, int server_name_length)
+ char *server_name, size_t server_name_length)
{
int error;
DBUG_ENTER("delete_server_record");
@@ -1271,7 +1271,7 @@ static FOREIGN_SERVER *clone_server(MEM_ROOT *mem, const FOREIGN_SERVER *server,
FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name,
FOREIGN_SERVER *buff)
{
- uint server_name_length;
+ size_t server_name_length;
FOREIGN_SERVER *server;
DBUG_ENTER("get_server_by_name");
DBUG_PRINT("info", ("server_name %s", server_name));
@@ -1290,8 +1290,8 @@ FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name,
(uchar*) server_name,
server_name_length)))
{
- DBUG_PRINT("info", ("server_name %s length %d not found!",
- server_name, server_name_length));
+ DBUG_PRINT("info", ("server_name %s length %u not found!",
+ server_name, (unsigned) server_name_length));
server= (FOREIGN_SERVER *) NULL;
}
/* otherwise, make copy of server */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 3c4dc103ddd..d08b3a248c4 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -287,7 +287,7 @@ static struct show_privileges_st sys_privileges[]=
{"Alter", "Tables", "To alter the table"},
{"Alter routine", "Functions,Procedures", "To alter or drop stored functions/procedures"},
{"Create", "Databases,Tables,Indexes", "To create new databases and tables"},
- {"Create routine","Functions,Procedures","To use CREATE FUNCTION/PROCEDURE"},
+ {"Create routine","Databases","To use CREATE FUNCTION/PROCEDURE"},
{"Create temporary tables","Databases","To use CREATE TEMPORARY TABLE"},
{"Create view", "Tables", "To create new views"},
{"Create user", "Server Admin", "To create new users"},
@@ -468,11 +468,18 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db,
#ifndef NO_EMBEDDED_ACCESS_CHECKS
uint col_access=thd->col_access;
#endif
+ uint wild_length= 0;
TABLE_LIST table_list;
DBUG_ENTER("find_files");
- if (wild && !wild[0])
- wild=0;
+ if (wild)
+ {
+ if (!wild[0])
+ wild= 0;
+ else
+ wild_length= strlen(wild);
+ }
+
bzero((char*) &table_list,sizeof(table_list));
@@ -537,8 +544,11 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db,
{
if (lower_case_table_names)
{
- if (wild_case_compare(files_charset_info, uname, wild))
- continue;
+ if (my_wildcmp(files_charset_info,
+ uname, uname + file_name_len,
+ wild, wild + wild_length,
+ wild_prefix, wild_one,wild_many))
+ continue;
}
else if (wild_compare(uname, wild, 0))
continue;
@@ -1588,21 +1598,25 @@ void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
int
view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
{
+ my_bool compact_view_name= TRUE;
my_bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
MODE_ORACLE |
MODE_MSSQL |
MODE_DB2 |
MODE_MAXDB |
MODE_ANSI)) != 0;
- /*
- Compact output format for view can be used
- - if user has db of this view as current db
- - if this view only references table inside it's own db
- */
+
if (!thd->db || strcmp(thd->db, table->view_db.str))
- table->compact_view_format= FALSE;
+ /*
+ print compact view name if the view belongs to the current database
+ */
+ compact_view_name= table->compact_view_format= FALSE;
else
{
+ /*
+ Compact output format for view body can be used
+ if this view only references table inside it's own db
+ */
TABLE_LIST *tbl;
table->compact_view_format= TRUE;
for (tbl= thd->lex->query_tables;
@@ -1623,7 +1637,7 @@ view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
view_store_options(thd, table, buff);
}
buff->append(STRING_WITH_LEN("VIEW "));
- if (!table->compact_view_format)
+ if (!compact_view_name)
{
append_identifier(thd, buff, table->view_db.str, table->view_db.length);
buff->append('.');
@@ -1690,7 +1704,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN));
field->maybe_null=1;
field_list.push_back(new Item_empty_string("Command",16));
- field_list.push_back(new Item_return_int("Time",7, MYSQL_TYPE_LONG));
+ field_list.push_back(field= new Item_return_int("Time",7, MYSQL_TYPE_LONG));
+ field->unsigned_flag= 0;
field_list.push_back(field=new Item_empty_string("State",30));
field->maybe_null=1;
field_list.push_back(field=new Item_empty_string("Info",max_query_length));
@@ -1783,7 +1798,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
else
protocol->store(command_name[thd_info->command].str, system_charset_info);
if (thd_info->start_time)
- protocol->store((uint32) (now - thd_info->start_time));
+ protocol->store_long ((longlong) (now - thd_info->start_time));
else
protocol->store_null();
protocol->store(thd_info->state_info, system_charset_info);
@@ -1858,8 +1873,8 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
table->field[4]->store(command_name[tmp->command].str,
command_name[tmp->command].length, cs);
/* MYSQL_TIME */
- table->field[5]->store((uint32)(tmp->start_time ?
- now - tmp->start_time : 0), TRUE);
+ table->field[5]->store((longlong)(tmp->start_time ?
+ now - tmp->start_time : 0), FALSE);
/* STATE */
#ifndef EMBEDDED_LIBRARY
val= (char*) (tmp->locked ? "Locked" :
@@ -3782,8 +3797,19 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
cs);
table->field[4]->store((longlong) count, TRUE);
field->sql_type(type);
- table->field[14]->store(type.ptr(), type.length(), cs);
+ table->field[14]->store(type.ptr(), type.length(), cs);
+ /*
+ MySQL column type has the following format:
+ base_type [(dimension)] [unsigned] [zerofill].
+ For DATA_TYPE column we extract only base type.
+ */
tmp_buff= strchr(type.ptr(), '(');
+ if (!tmp_buff)
+ /*
+ if there is no dimention part then check the presence of
+ [unsigned] [zerofill] attributes and cut them of if exist.
+ */
+ tmp_buff= strchr(type.ptr(), ' ');
table->field[7]->store(type.ptr(),
(tmp_buff ? tmp_buff - type.ptr() :
type.length()), cs);
@@ -6533,7 +6559,7 @@ ST_FIELD_INFO processlist_fields_info[]=
SKIP_OPEN_TABLE},
{"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, "Db", SKIP_OPEN_TABLE},
{"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command", SKIP_OPEN_TABLE},
- {"TIME", 7, MYSQL_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE},
+ {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time", SKIP_OPEN_TABLE},
{"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State", SKIP_OPEN_TABLE},
{"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info",
SKIP_OPEN_TABLE},
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 34b310931d6..1dd7b55d136 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -71,25 +71,22 @@ bool String::realloc(uint32 alloc_length)
char *new_ptr;
if (alloced)
{
- if ((new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
- {
- Ptr=new_ptr;
- Alloced_length=len;
- }
- else
- return TRUE; // Signal error
+ if (!(new_ptr= (char*) my_realloc(Ptr,len,MYF(MY_WME))))
+ return TRUE; // Signal error
}
else if ((new_ptr= (char*) my_malloc(len,MYF(MY_WME))))
{
+ if (str_length > len - 1)
+ str_length= 0;
if (str_length) // Avoid bugs in memcpy on AIX
memcpy(new_ptr,Ptr,str_length);
new_ptr[str_length]=0;
- Ptr=new_ptr;
- Alloced_length=len;
alloced=1;
}
else
return TRUE; // Signal error
+ Ptr= new_ptr;
+ Alloced_length= len;
}
Ptr[alloc_length]=0; // This make other funcs shorter
return FALSE;
@@ -115,7 +112,7 @@ bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
- uint32 len= my_sprintf(buff,(buff, "%.14g",num));// Enough for a DATETIME
+ uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
}
#ifdef HAVE_FCONVERT
@@ -458,7 +455,7 @@ bool String::append(const char *s,uint32 arg_length)
bool String::append(const char *s)
{
- return append(s, strlen(s));
+ return append(s, (uint) strlen(s));
}
@@ -667,7 +664,7 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_sprintf(buff, (buff, "%.14g", d));
+ str_length+= my_sprintf(buff, (buff, "%.15g", d));
}
void String::qs_append(double *d)
@@ -1051,7 +1048,7 @@ outp:
}
}
*from_end_pos= from;
- res= to - to_start;
+ res= (uint) (to - to_start);
}
return (uint32) res;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index aa2a5739f17..29d43155778 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -84,7 +84,7 @@ static void wait_for_kill_signal(THD *thd)
uint filename_to_tablename(const char *from, char *to, uint to_length)
{
uint errors;
- uint res;
+ size_t res;
DBUG_ENTER("filename_to_tablename");
DBUG_PRINT("enter", ("from '%s'", from));
@@ -224,7 +224,7 @@ uint build_table_filename(char *buff, size_t bufflen, const char *db,
char *end = buff + bufflen;
/* Don't add FN_ROOTDIR if mysql_data_home already includes it */
char *pos = strnmov(buff, mysql_data_home, bufflen);
- int rootdir_len= strlen(FN_ROOTDIR);
+ size_t rootdir_len= strlen(FN_ROOTDIR);
if (pos - rootdir_len >= buff &&
memcmp(pos - rootdir_len, FN_ROOTDIR, rootdir_len) != 0)
pos= strnmov(pos, FN_ROOTDIR, end - pos);
@@ -273,7 +273,7 @@ uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen)
my_casedn_str(files_charset_info, p);
}
- uint length= unpack_filename(buff, buff);
+ size_t length= unpack_filename(buff, buff);
DBUG_PRINT("exit", ("buff: '%s'", buff));
DBUG_RETURN(length);
}
@@ -1463,7 +1463,7 @@ void write_bin_log(THD *thd, bool clear_error,
if (clear_error)
thd->clear_error();
thd->binlog_query(THD::STMT_QUERY_TYPE,
- query, query_length, FALSE, FALSE);
+ query, query_length, FALSE, FALSE, THD::NOT_KILLED);
}
}
@@ -1991,7 +1991,7 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval,
for (pos= interval->type_names, len= interval->type_lengths;
*pos ; pos++, len++)
{
- uint length= cs->cset->numchars(cs, *pos, *pos + *len);
+ size_t length= cs->cset->numchars(cs, *pos, *pos + *len);
*tot_length+= length;
set_if_bigger(*max_length, (uint32)length);
}
@@ -2320,7 +2320,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_ASSERT(comma_length > 0);
for (uint i= 0; (tmp= int_it++); i++)
{
- uint lengthsp;
+ size_t lengthsp;
if (String::needs_conversion(tmp->length(), tmp->charset(),
cs, &dummy))
{
@@ -3321,7 +3321,7 @@ bool mysql_create_table_no_lock(THD *thd,
if (key->type == Key::FOREIGN_KEY &&
!part_info->is_auto_partitioned)
{
- my_error(ER_CANNOT_ADD_FOREIGN, MYF(0));
+ my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0));
goto err;
}
}
@@ -4236,7 +4236,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
(!(alter_info->flags & ALTER_ALL_PARTITION)))
{
char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
- uint length;
+ size_t length;
DBUG_PRINT("admin", ("sending non existent partition error"));
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
@@ -4297,7 +4297,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
- result_code= HA_ADMIN_CORRUPT;
+ if (thd->main_da.is_error() &&
+ (thd->main_da.sql_errno() == ER_NO_SUCH_TABLE ||
+ thd->main_da.sql_errno() == ER_FILE_NOT_FOUND))
+ /* A missing table is just issued as a failed command */
+ result_code= HA_ADMIN_FAILED;
+ else
+ /* Default failure code is corrupt table */
+ result_code= HA_ADMIN_CORRUPT;
goto send_result;
}
@@ -4318,7 +4325,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
{
/* purecov: begin inspected */
char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
- uint length;
+ size_t length;
DBUG_PRINT("admin", ("sending error message"));
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
@@ -4436,7 +4443,7 @@ send_result_message:
case HA_ADMIN_NOT_IMPLEMENTED:
{
char buf[MYSQL_ERRMSG_SIZE];
- uint length=my_snprintf(buf, sizeof(buf),
+ size_t length=my_snprintf(buf, sizeof(buf),
ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(buf, length, system_charset_info);
@@ -4446,7 +4453,7 @@ send_result_message:
case HA_ADMIN_NOT_BASE_TABLE:
{
char buf[MYSQL_ERRMSG_SIZE];
- uint length= my_snprintf(buf, sizeof(buf),
+ size_t length= my_snprintf(buf, sizeof(buf),
ER(ER_BAD_TABLE_ERROR), table_name);
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(buf, length, system_charset_info);
@@ -4574,7 +4581,7 @@ send_result_message:
case HA_ADMIN_NEEDS_ALTER:
{
char buf[MYSQL_ERRMSG_SIZE];
- uint length;
+ size_t length;
protocol->store(STRING_WITH_LEN("error"), system_charset_info);
length=my_snprintf(buf, sizeof(buf), ER(ER_TABLE_NEEDS_UPGRADE),
@@ -4587,7 +4594,7 @@ send_result_message:
default: // Probably HA_ADMIN_INTERNAL_ERROR
{
char buf[MYSQL_ERRMSG_SIZE];
- uint length=my_snprintf(buf, sizeof(buf),
+ size_t length=my_snprintf(buf, sizeof(buf),
"Unknown - internal error %d during operation",
result_code);
protocol->store(STRING_WITH_LEN("error"), system_charset_info);
@@ -4639,7 +4646,7 @@ err:
bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
{
DBUG_ENTER("mysql_backup_table");
- WARN_DEPRECATED(thd, "5.2", "BACKUP TABLE",
+ WARN_DEPRECATED(thd, "6.0", "BACKUP TABLE",
"MySQL Administrator (mysqldump, mysql)");
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
"backup", TL_READ, 0, 0, 0, 0,
@@ -4650,7 +4657,7 @@ bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
bool mysql_restore_table(THD* thd, TABLE_LIST* table_list)
{
DBUG_ENTER("mysql_restore_table");
- WARN_DEPRECATED(thd, "5.2", "RESTORE TABLE",
+ WARN_DEPRECATED(thd, "6.0", "RESTORE TABLE",
"MySQL Administrator (mysqldump, mysql)");
DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
"restore", TL_WRITE, 1, 1, 0,
@@ -6158,7 +6165,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (mysql_bin_log.is_open())
{
thd->clear_error();
- Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+ Query_log_event qinfo(thd, thd->query, thd->query_length,
+ 0, FALSE, THD::NOT_KILLED);
mysql_bin_log.write(&qinfo);
}
my_ok(thd);
@@ -7481,6 +7489,16 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
{
for (;;)
{
+ if (thd->killed)
+ {
+ /*
+ we've been killed; let handler clean up, and remove the
+ partial current row from the recordset (embedded lib)
+ */
+ t->file->ha_rnd_end();
+ thd->protocol->remove_last_row();
+ goto err;
+ }
ha_checksum row_crc= 0;
int error= t->file->rnd_next(t->record[0]);
if (unlikely(error))
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 78932396efe..eeb9a21b6f5 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -33,18 +33,20 @@
static const char *lock_descriptions[] =
{
- "No lock",
- "Low priority read lock",
- "Shared Read lock",
- "High priority read lock",
- "Read lock without concurrent inserts",
- "Write lock that allows other writers",
- "Write lock, but allow reading",
- "Concurrent insert lock",
- "Lock Used by delayed insert",
- "Low priority write lock",
- "High priority write lock",
- "Highest priority write lock"
+ /* TL_UNLOCK */ "No lock",
+ /* TL_READ_DEFAULT */ NULL,
+ /* TL_READ */ "Low priority read lock",
+ /* TL_READ_WITH_SHARED_LOCKS */ "Shared read lock",
+ /* TL_READ_HIGH_PRIORITY */ "High priority read lock",
+ /* TL_READ_NO_INSERT */ "Read lock without concurrent inserts",
+ /* TL_WRITE_ALLOW_WRITE */ "Write lock that allows other writers",
+ /* TL_WRITE_ALLOW_READ */ "Write lock, but allow reading",
+ /* TL_WRITE_CONCURRENT_INSERT */ "Concurrent insert lock",
+ /* TL_WRITE_DELAYED */ "Lock used by delayed insert",
+ /* TL_WRITE_DEFAULT */ NULL,
+ /* TL_WRITE_LOW_PRIORITY */ "Low priority write lock",
+ /* TL_WRITE */ "High priority write lock",
+ /* TL_WRITE_ONLY */ "Highest priority write lock"
};
@@ -75,6 +77,8 @@ void print_cached_tables(void)
uint idx,count,unused;
TABLE *start_link,*lnk;
+ compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
+
/* purecov: begin tested */
VOID(pthread_mutex_lock(&LOCK_open));
puts("DB Table Version Thread Open Lock");
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 108d5095691..8cab8fff2f3 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -1728,7 +1728,7 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd,
List_iterator_fast<LEX_STRING> it_def(definitions_list);
List_iterator_fast<LEX_STRING> it_on_table_name(on_table_names_list);
List_iterator_fast<ulonglong> it_mode(definition_modes_list);
- uint on_q_table_name_len, before_on_len;
+ size_t on_q_table_name_len, before_on_len;
String buff;
DBUG_ASSERT(definitions_list.elements == on_table_names_list.elements &&
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index ebd183c6803..c60dac42fb8 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -159,7 +159,7 @@ void udf_init()
DBUG_PRINT("info",("init udf record"));
LEX_STRING name;
name.str=get_field(&mem, table->field[0]);
- name.length = strlen(name.str);
+ name.length = (uint) strlen(name.str);
char *dl_name= get_field(&mem, table->field[2]);
bool new_dl=0;
Item_udftype udftype=UDFTYPE_FUNCTION;
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index be66f7c2d80..4f207f78688 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -61,7 +61,8 @@ static void make_unique_view_field_name(Item *target,
char *name= (target->orig_name ?
target->orig_name :
target->name);
- uint name_len, attempt;
+ size_t name_len;
+ uint attempt;
char buff[NAME_LEN+1];
List_iterator_fast<Item> itc(item_list);
@@ -545,7 +546,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
}
while ((item= it++, name= nm++))
{
- item->set_name(name->str, name->length, system_charset_info);
+ item->set_name(name->str, (uint) name->length, system_charset_info);
item->is_autogenerated_name= FALSE;
}
}
@@ -564,24 +565,36 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
fill_effective_table_privileges(thd, &view->grant, view->db,
view->table_name);
+ /*
+ Make sure that the current user does not have more column-level privileges
+ on the newly created view than he/she does on the underlying
+ tables. E.g. it must not be so that the user has UPDATE privileges on a
+ view column of he/she doesn't have it on the underlying table's
+ corresponding column. In that case, return an error for CREATE VIEW.
+ */
{
Item *report_item= NULL;
+ /*
+ This will hold the intersection of the priviliges on all columns in the
+ view.
+ */
uint final_priv= VIEW_ANY_ACL;
-
- for (sl= select_lex; sl; sl= sl->next_select())
- {
- DBUG_ASSERT(view->db); /* Must be set in the parser */
- List_iterator_fast<Item> it(sl->item_list);
- Item *item;
- while ((item= it++))
+
+ for (sl= select_lex; sl; sl= sl->next_select())
{
+ DBUG_ASSERT(view->db); /* Must be set in the parser */
+ List_iterator_fast<Item> it(sl->item_list);
+ Item *item;
+ while ((item= it++))
+ {
Item_field *fld= item->filed_for_view_update();
- uint priv= (get_column_grant(thd, &view->grant, view->db,
- view->table_name, item->name) &
- VIEW_ANY_ACL);
+ uint priv= (get_column_grant(thd, &view->grant, view->db,
+ view->table_name, item->name) &
+ VIEW_ANY_ACL);
if (fld && !fld->field->table->s->tmp_table)
- {
+ {
+
final_priv&= fld->have_privileges;
if (~fld->have_privileges & priv)
@@ -589,17 +602,15 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
}
}
}
-
- if (!final_priv)
- {
- DBUG_ASSERT(report_item);
-
- my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
- "create view", thd->security_ctx->priv_user,
+
+ if (!final_priv && report_item)
+ {
+ my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
+ "create view", thd->security_ctx->priv_user,
thd->security_ctx->priv_host, report_item->name,
- view->table_name);
- res= TRUE;
- goto err;
+ view->table_name);
+ res= TRUE;
+ goto err;
}
}
#endif
@@ -651,7 +662,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
buff.append(views->source.str, views->source.length);
thd->binlog_query(THD::STMT_QUERY_TYPE,
- buff.ptr(), buff.length(), FALSE, FALSE);
+ buff.ptr(), buff.length(), FALSE, FALSE, THD::NOT_KILLED);
}
VOID(pthread_mutex_unlock(&LOCK_open));
@@ -1672,7 +1683,7 @@ frm_type_enum mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt)
{
File file;
uchar header[10]; //"TYPE=VIEW\n" it is 10 characters
- int error;
+ size_t error;
DBUG_ENTER("mysql_frm_type");
*dbt= DB_TYPE_UNKNOWN;
@@ -1901,6 +1912,7 @@ int view_checksum(THD *thd, TABLE_LIST *view)
Parameters:
thd thread handler
+ new_db new name of database
new_name new name of view
view view
@@ -1910,6 +1922,7 @@ int view_checksum(THD *thd, TABLE_LIST *view)
*/
bool
mysql_rename_view(THD *thd,
+ const char *new_db,
const char *new_name,
TABLE_LIST *view)
{
@@ -1948,16 +1961,16 @@ mysql_rename_view(THD *thd,
goto err;
/* rename view and it's backups */
- if (rename_in_schema_file(thd, view->db, view->table_name, new_name))
+ if (rename_in_schema_file(thd, view->db, view->table_name, new_db, new_name))
goto err;
dir.str= dir_buff;
dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1,
- view->db, "", "", 0);
+ new_db, "", "", 0);
pathstr.str= path_buff;
pathstr.length= build_table_filename(path_buff, sizeof(path_buff) - 1,
- view->db, new_name, reg_ext, 0);
+ new_db, new_name, reg_ext, 0);
file.str= pathstr.str + dir.length;
file.length= pathstr.length - dir.length;
@@ -1966,7 +1979,7 @@ mysql_rename_view(THD *thd,
(uchar*)&view_def, view_parameters))
{
/* restore renamed view in case of error */
- rename_in_schema_file(thd, view->db, new_name, view->table_name);
+ rename_in_schema_file(thd, new_db, new_name, view->db, view->table_name);
goto err;
}
} else
diff --git a/sql/sql_view.h b/sql/sql_view.h
index b8138663489..e08c2168e14 100644
--- a/sql/sql_view.h
+++ b/sql/sql_view.h
@@ -37,7 +37,8 @@ int view_checksum(THD *thd, TABLE_LIST *view);
extern TYPELIB updatable_views_with_limit_typelib;
bool check_duplicate_names(List<Item>& item_list, bool gen_unique_view_names);
-bool mysql_rename_view(THD *thd, const char *new_name, TABLE_LIST *view);
+bool mysql_rename_view(THD *thd, const char *new_db, const char *new_name,
+ TABLE_LIST *view);
#define VIEW_ANY_ACL (SELECT_ACL | UPDATE_ACL | INSERT_ACL | DELETE_ACL)
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7df035bbfc3..0b158ff7574 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -280,9 +280,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr)
parsing_ctx, case_expr_id, expr, lex);
sp->add_cont_backpatch(i);
- sp->add_instr(i);
-
- return 0;
+ return sp->add_instr(i);
}
/**
@@ -293,7 +291,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr)
@param simple true for simple cases, false for searched cases
*/
-void case_stmt_action_when(LEX *lex, Item *when, bool simple)
+int case_stmt_action_when(LEX *lex, Item *when, bool simple)
{
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
@@ -325,9 +323,10 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple)
(jump_if_not from instruction 2 to 5, 5 to 8 ... in the example)
*/
- sp->push_backpatch(i, ctx->push_label((char *)"", 0));
- sp->add_cont_backpatch(i);
- sp->add_instr(i);
+ return !test(i) ||
+ sp->push_backpatch(i, ctx->push_label((char *)"", 0)) ||
+ sp->add_cont_backpatch(i) ||
+ sp->add_instr(i);
}
/**
@@ -336,13 +335,14 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple)
@param lex the parser lex context
*/
-void case_stmt_action_then(LEX *lex)
+int case_stmt_action_then(LEX *lex)
{
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
uint ip= sp->instructions();
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
- sp->add_instr(i);
+ if (!test(i) || sp->add_instr(i))
+ return 1;
/*
BACKPATCH: Resolving forward jump from
@@ -358,7 +358,7 @@ void case_stmt_action_then(LEX *lex)
(jump from instruction 4 to 12, 7 to 12 ... in the example)
*/
- sp->push_backpatch(i, ctx->last_label());
+ return sp->push_backpatch(i, ctx->last_label());
}
/**
@@ -2322,10 +2322,9 @@ sp_decl:
var_type,
lex,
(i == num_vars - 1));
- if (is == NULL)
+ if (is == NULL ||
+ lex->sphead->add_instr(is))
MYSQL_YYABORT;
-
- lex->sphead->add_instr(is);
}
pctx->declare_var_boundary(0);
@@ -2339,12 +2338,13 @@ sp_decl:
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
- if (spc->find_cond(&$2, TRUE))
- {
- my_error(ER_SP_DUP_COND, MYF(0), $2.str);
+ if (spc->find_cond(&$2, TRUE))
+ {
+ my_error(ER_SP_DUP_COND, MYF(0), $2.str);
+ MYSQL_YYABORT;
+ }
+ if(YYTHD->lex->spcont->push_cond(&$2, $5))
MYSQL_YYABORT;
- }
- YYTHD->lex->spcont->push_cond(&$2, $5);
$$.vars= $$.hndlrs= $$.curs= 0;
$$.conds= 1;
}
@@ -2358,11 +2358,11 @@ sp_decl:
sp_pcontext *ctx= lex->spcont;
sp_instr_hpush_jump *i=
new sp_instr_hpush_jump(sp->instructions(), ctx, $2,
- ctx->current_var_count());
- if (i == NULL)
+ ctx->current_var_count());
+ if (i == NULL ||
+ sp->add_instr(i) ||
+ sp->push_backpatch(i, ctx->push_label((char *)"", 0)))
MYSQL_YYABORT;
- sp->add_instr(i);
- sp->push_backpatch(i, ctx->push_label((char *)"", 0));
}
sp_hcond_list sp_proc_stmt
{
@@ -2376,17 +2376,17 @@ sp_decl:
{
i= new sp_instr_hreturn(sp->instructions(), ctx,
ctx->current_var_count());
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
else
{ /* EXIT or UNDO handler, just jump to the end of the block */
i= new sp_instr_hreturn(sp->instructions(), ctx, 0);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i) ||
+ sp->push_backpatch(i, lex->spcont->last_label())) /* Block end */
MYSQL_YYABORT;
- sp->add_instr(i);
- sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
}
lex->sphead->backpatch(hlab);
@@ -2412,10 +2412,10 @@ sp_decl:
}
i= new sp_instr_cpush(sp->instructions(), ctx, $5,
ctx->current_cursor_count());
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i) ||
+ ctx->push_cursor(&$2))
MYSQL_YYABORT;
- sp->add_instr(i);
- ctx->push_cursor(&$2);
$$.vars= $$.conds= $$.hndlrs= 0;
$$.curs= 1;
}
@@ -2652,10 +2652,11 @@ sp_proc_stmt_statement:
i->m_query.length= lip->get_ptr() - sp->m_tmp_query;
else
i->m_query.length= lip->get_tok_end() - sp->m_tmp_query;
- i->m_query.str= strmake_root(thd->mem_root,
- sp->m_tmp_query,
- i->m_query.length);
- sp->add_instr(i);
+ if (!(i->m_query.str= strmake_root(thd->mem_root,
+ sp->m_tmp_query,
+ i->m_query.length)) ||
+ sp->add_instr(i))
+ MYSQL_YYABORT;
}
sp->restore_lex(thd);
}
@@ -2680,9 +2681,9 @@ sp_proc_stmt_return:
i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3,
sp->m_return_field_def.sql_type, lex);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
sp->m_flags|= sp_head::HAS_RETURN;
}
sp->restore_lex(YYTHD);
@@ -2779,22 +2780,22 @@ sp_proc_stmt_iterate:
if (n)
{
sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
- if (hpop == NULL)
+ if (hpop == NULL ||
+ sp->add_instr(hpop))
MYSQL_YYABORT;
- sp->add_instr(hpop);
}
n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
{
sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
- if (cpop == NULL)
+ if (cpop == NULL ||
+ sp->add_instr(cpop))
MYSQL_YYABORT;
- sp->add_instr(cpop);
}
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
}
;
@@ -2813,9 +2814,9 @@ sp_proc_stmt_open:
MYSQL_YYABORT;
}
i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
;
@@ -2833,9 +2834,9 @@ sp_proc_stmt_fetch:
MYSQL_YYABORT;
}
i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
sp_fetch_list
{}
@@ -2855,9 +2856,9 @@ sp_proc_stmt_close:
MYSQL_YYABORT;
}
i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
;
@@ -2920,12 +2921,11 @@ sp_if:
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx,
$2, lex);
- if (i == NULL)
+ if (i == NULL ||
+ sp->push_backpatch(i, ctx->push_label((char *)"", 0)) ||
+ sp->add_cont_backpatch(i) ||
+ sp->add_instr(i))
MYSQL_YYABORT;
-
- sp->push_backpatch(i, ctx->push_label((char *)"", 0));
- sp->add_cont_backpatch(i);
- sp->add_instr(i);
sp->restore_lex(YYTHD);
}
sp_proc_stmts1
@@ -2934,10 +2934,9 @@ sp_if:
sp_pcontext *ctx= Lex->spcont;
uint ip= sp->instructions();
sp_instr_jump *i = new sp_instr_jump(ip, ctx);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
-
- sp->add_instr(i);
sp->backpatch(ctx->pop_label());
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
}
@@ -3021,14 +3020,16 @@ simple_when_clause:
/* Simple case: <caseval> = <whenval> */
LEX *lex= Lex;
- case_stmt_action_when(lex, $3, true);
+ if (case_stmt_action_when(lex, $3, true))
+ MYSQL_YYABORT;
lex->sphead->restore_lex(YYTHD); /* For expr $3 */
}
THEN_SYM
sp_proc_stmts1
{
LEX *lex= Lex;
- case_stmt_action_then(lex);
+ if (case_stmt_action_then(lex))
+ MYSQL_YYABORT;
}
;
@@ -3040,14 +3041,16 @@ searched_when_clause:
expr
{
LEX *lex= Lex;
- case_stmt_action_when(lex, $3, false);
+ if (case_stmt_action_when(lex, $3, false))
+ MYSQL_YYABORT;
lex->sphead->restore_lex(YYTHD); /* For expr $3 */
}
THEN_SYM
sp_proc_stmts1
{
LEX *lex= Lex;
- case_stmt_action_then(lex);
+ if (case_stmt_action_then(lex))
+ MYSQL_YYABORT;
}
;
@@ -3059,9 +3062,9 @@ else_clause_opt:
uint ip= sp->instructions();
sp_instr_error *i= new sp_instr_error(ip, lex->spcont,
ER_SP_CASE_NOT_FOUND);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
| ELSE sp_proc_stmts1
;
@@ -3175,16 +3178,16 @@ sp_block_content:
if ($3.hndlrs)
{
i= new sp_instr_hpop(sp->instructions(), ctx, $3.hndlrs);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
if ($3.curs)
{
i= new sp_instr_cpop(sp->instructions(), ctx, $3.curs);
- if (i == NULL)
+ if (i == NULL ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- sp->add_instr(i);
}
lex->spcont= ctx->pop_context();
}
@@ -3198,10 +3201,10 @@ sp_unlabeled_control:
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
- if (i == NULL)
+ if (i == NULL ||
+ lex->sphead->add_instr(i))
MYSQL_YYABORT;
- lex->sphead->add_instr(i);
- }
+ }
| WHILE_SYM
{ Lex->sphead->reset_lex(YYTHD); }
expr DO_SYM
@@ -3211,12 +3214,12 @@ sp_unlabeled_control:
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$3, lex);
- if (i == NULL)
+ if (i == NULL ||
+ /* Jumping forward */
+ sp->push_backpatch(i, lex->spcont->last_label()) ||
+ sp->new_cont_backpatch(i) ||
+ sp->add_instr(i))
MYSQL_YYABORT;
- /* Jumping forward */
- sp->push_backpatch(i, lex->spcont->last_label());
- sp->new_cont_backpatch(i);
- sp->add_instr(i);
sp->restore_lex(YYTHD);
}
sp_proc_stmts1 END WHILE_SYM
@@ -3225,9 +3228,9 @@ sp_unlabeled_control:
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
- if (i == NULL)
+ if (i == NULL ||
+ lex->sphead->add_instr(i))
MYSQL_YYABORT;
- lex->sphead->add_instr(i);
lex->sphead->do_cont_backpatch();
}
| REPEAT_SYM sp_proc_stmts1 UNTIL_SYM
@@ -3240,9 +3243,9 @@ sp_unlabeled_control:
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$5, lab->ip,
lex);
- if (i == NULL)
+ if (i == NULL ||
+ lex->sphead->add_instr(i))
MYSQL_YYABORT;
- lex->sphead->add_instr(i);
lex->sphead->restore_lex(YYTHD);
/* We can shortcut the cont_backpatch here */
i->m_cont_dest= ip+1;
@@ -4392,7 +4395,7 @@ create_table_option:
| TYPE_SYM opt_equal storage_engines
{
Lex->create_info.db_type= $3;
- WARN_DEPRECATED(yythd, "5.2", "TYPE=storage_engine",
+ WARN_DEPRECATED(yythd, "6.0", "TYPE=storage_engine",
"'ENGINE=storage_engine'");
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
}
@@ -6489,7 +6492,8 @@ select_option:
{
if (check_simple_select())
MYSQL_YYABORT;
- Lex->lock_option= TL_READ_HIGH_PRIORITY;
+ Lex->lock_option= TL_READ_HIGH_PRIORITY;
+ Lex->current_select->lock_option= TL_READ_HIGH_PRIORITY;
}
| DISTINCT { Select->options|= SELECT_DISTINCT; }
| SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
@@ -6535,13 +6539,16 @@ select_lock_type:
{
LEX *lex=Lex;
lex->current_select->set_lock_for_tables(TL_WRITE);
+ lex->current_select->lock_option= TL_WRITE;
lex->safe_to_cache_query=0;
+ lex->protect_against_global_read_lock= TRUE;
}
| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
{
LEX *lex=Lex;
lex->current_select->
set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
+ lex->current_select->lock_option= TL_READ_WITH_SHARED_LOCKS;
lex->safe_to_cache_query=0;
}
;
@@ -9261,6 +9268,11 @@ drop:
THD *thd= YYTHD;
LEX *lex= thd->lex;
sp_name *spname;
+ if ($4.str && check_db_name(&$4))
+ {
+ my_error(ER_WRONG_DB_NAME, MYF(0), $4.str);
+ MYSQL_YYABORT;
+ }
if (lex->sphead)
{
my_error(ER_SP_NO_DROP_SP, MYF(0), "FUNCTION");
@@ -9869,7 +9881,7 @@ show_param:
| opt_full PLUGIN_SYM
{
LEX *lex= Lex;
- WARN_DEPRECATED(yythd, "5.2", "SHOW PLUGIN", "'SHOW PLUGINS'");
+ WARN_DEPRECATED(yythd, "6.0", "SHOW PLUGIN", "'SHOW PLUGINS'");
lex->sql_command= SQLCOM_SHOW_PLUGINS;
if (prepare_schema_table(YYTHD, lex, 0, SCH_PLUGINS))
MYSQL_YYABORT;
@@ -9938,7 +9950,7 @@ show_param:
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED(yythd, "5.2", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
+ WARN_DEPRECATED(yythd, "6.0", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
if (prepare_schema_table(YYTHD, lex, 0, SCH_ENGINES))
MYSQL_YYABORT;
}
@@ -9999,7 +10011,7 @@ show_param:
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
MYSQL_YYABORT;
}
- WARN_DEPRECATED(yythd, "5.2", "SHOW INNODB STATUS", "'SHOW ENGINE INNODB STATUS'");
+ WARN_DEPRECATED(yythd, "6.0", "SHOW INNODB STATUS", "'SHOW ENGINE INNODB STATUS'");
}
| MUTEX_SYM STATUS_SYM
{
@@ -10011,7 +10023,7 @@ show_param:
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
MYSQL_YYABORT;
}
- WARN_DEPRECATED(yythd, "5.2", "SHOW MUTEX STATUS", "'SHOW ENGINE INNODB MUTEX'");
+ WARN_DEPRECATED(yythd, "6.0", "SHOW MUTEX STATUS", "'SHOW ENGINE INNODB MUTEX'");
}
| opt_full PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
@@ -10406,7 +10418,7 @@ load:
| LOAD TABLE_SYM table_ident FROM MASTER_SYM
{
LEX *lex=Lex;
- WARN_DEPRECATED(yythd, "5.2", "LOAD TABLE FROM MASTER",
+ WARN_DEPRECATED(yythd, "6.0", "LOAD TABLE FROM MASTER",
"MySQL Administrator (mysqldump, mysql)");
if (lex->sphead)
{
@@ -10453,7 +10465,7 @@ load_data:
| FROM MASTER_SYM
{
Lex->sql_command = SQLCOM_LOAD_MASTER_DATA;
- WARN_DEPRECATED(yythd, "5.2", "LOAD DATA FROM MASTER",
+ WARN_DEPRECATED(yythd, "6.0", "LOAD DATA FROM MASTER",
"mysqldump or future "
"BACKUP/RESTORE DATABASE facility");
}
@@ -11742,7 +11754,8 @@ option_type_value:
qbuff.length);
qbuff.length+= 4;
i->m_query= qbuff;
- sp->add_instr(i);
+ if (sp->add_instr(i))
+ MYSQL_YYABORT;
}
lex->sphead->restore_lex(thd);
}
@@ -11834,7 +11847,8 @@ sys_option_value:
(uchar **) &trg_fld->
next_trg_field);
- lex->sphead->add_instr(sp_fld);
+ if (lex->sphead->add_instr(sp_fld))
+ MYSQL_YYABORT;
}
else if ($2.var)
{ /* System variable */
@@ -11873,9 +11887,9 @@ sys_option_value:
}
sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
spv->offset, it, spv->type, lex, TRUE);
- if (sp_set == NULL)
+ if (sp_set == NULL ||
+ lex->sphead->add_instr(sp_set))
MYSQL_YYABORT;
- lex->sphead->add_instr(sp_set);
}
}
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
@@ -12174,8 +12188,12 @@ table_lock_list:
table_lock:
table_ident opt_table_alias lock_option
{
- if (!Select->add_table_to_list(YYTHD, $1, $2, 0, (thr_lock_type) $3))
+ thr_lock_type lock_type= (thr_lock_type) $3;
+ if (!Select->add_table_to_list(YYTHD, $1, $2, 0, lock_type))
MYSQL_YYABORT;
+ /* If table is to be write locked, protect from a impending GRL. */
+ if (lock_type >= TL_WRITE_ALLOW_WRITE)
+ Lex->protect_against_global_read_lock= TRUE;
}
;
@@ -12904,6 +12922,18 @@ subselect_start:
subselect_end:
{
LEX *lex=Lex;
+ /*
+ Set the required lock level for the tables associated with the
+ current sub-select. This will overwrite previous lock options set
+ using st_select_lex::add_table_to_list in any of the following
+ rules: single_multi, table_wild_one, load_data, table_alias_ref,
+ table_factor.
+ The default lock level is TL_READ_DEFAULT but it can be modified
+ with query options specific for a certain (sub-)SELECT.
+ */
+ lex->current_select->
+ set_lock_for_tables(lex->current_select->lock_option);
+
lex->pop_context();
SELECT_LEX *child= lex->current_select;
lex->current_select = lex->current_select->return_after_parsing();
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index c03365cfc2b..1fb9c1a8451 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -88,6 +88,208 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs,
}
+static const char *on_off_default_names[]=
+{
+ "off","on","default", NullS
+};
+
+static const unsigned int on_off_default_names_len[]=
+{
+ sizeof("off") - 1,
+ sizeof("on") - 1,
+ sizeof("default") - 1
+};
+
+static TYPELIB on_off_default_typelib= {array_elements(on_off_default_names)-1,
+ "", on_off_default_names,
+ (unsigned int *)on_off_default_names_len};
+
+
+/*
+ Parse a TYPELIB name from the buffer
+
+ SYNOPSIS
+ parse_name()
+ lib Set of names to scan for.
+ strpos INOUT Start of the buffer (updated to point to the next
+ character after the name)
+ end End of the buffer
+ cs Charset used in the buffer
+
+ DESCRIPTION
+ Parse a TYPELIB name from the buffer. The buffer is assumed to contain
+ one of the names specified in the TYPELIB, followed by comma, '=', or
+ end of the buffer.
+
+ RETURN
+ 0 No matching name
+ >0 Offset+1 in typelib for matched name
+*/
+
+static uint parse_name(TYPELIB *lib, const char **strpos, const char *end,
+ CHARSET_INFO *cs)
+{
+ const char *pos= *strpos;
+ const char *start= pos;
+
+ /* Find the length */
+ if (cs && cs->mbminlen > 1)
+ {
+ int mblen= 0;
+ for ( ; pos < end; pos+= mblen)
+ {
+ my_wc_t wc;
+ if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) pos,
+ (const uchar *) end)) < 1)
+ mblen= 1; // Not to hang on a wrong multibyte sequence
+ if (wc == (my_wc_t) '=' || wc == (my_wc_t) ',')
+ break;
+ }
+ }
+ else
+ for (; pos != end && *pos != '=' && *pos !=',' ; pos++);
+
+ uint var_len= (uint) (pos - start);
+ /* Determine which flag it is */
+ uint find= cs ? find_type2(lib, start, var_len, cs) :
+ find_type(lib, start, var_len, (bool) 0);
+ *strpos= pos;
+ return find;
+}
+
+
+/* Read next character from the buffer in a charset-aware way */
+
+static my_wc_t get_next_char(const char **pos, const char *end, CHARSET_INFO *cs)
+{
+ my_wc_t wc;
+ if (*pos == end)
+ return (my_wc_t)-1;
+
+ if (cs && cs->mbminlen > 1)
+ {
+ int mblen;
+ if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) *pos,
+ (const uchar *) end)) < 1)
+ mblen= 1; // Not to hang on a wrong multibyte sequence
+ *pos += mblen;
+ return wc;
+ }
+ else
+ return *((*pos)++);
+}
+
+
+/*
+ Parse and apply a set of flag assingments
+
+ SYNOPSIS
+ find_set_from_flags()
+ lib Flag names
+ default_name Number of "default" in the typelib
+ cur_set Current set of flags (start from this state)
+ default_set Default set of flags (use this for assign-default
+ keyword and flag=default assignments)
+ str String to be parsed
+ length Length of the string
+ cs String charset
+ err_pos OUT If error, set to point to start of wrong set string
+ NULL on success
+ err_len OUT If error, set to the length of wrong set string
+ set_warning OUT TRUE <=> Some string in set couldn't be used
+
+ DESCRIPTION
+ Parse a set of flag assignments, that is, parse a string in form:
+
+ param_name1=value1,param_name2=value2,...
+
+ where the names are specified in the TYPELIB, and each value can be
+ either 'on','off', or 'default'. Setting the same name twice is not
+ allowed.
+
+ Besides param=val assignments, we support the "default" keyword (keyword
+ #default_name in the typelib). It can be used one time, if specified it
+ causes us to build the new set over the default_set rather than cur_set
+ value.
+
+ RETURN
+ Parsed set value if (*errpos == NULL)
+ Otherwise undefined
+*/
+
+ulonglong find_set_from_flags(TYPELIB *lib, uint default_name,
+ ulonglong cur_set, ulonglong default_set,
+ const char *str, uint length, CHARSET_INFO *cs,
+ char **err_pos, uint *err_len, bool *set_warning)
+{
+ CHARSET_INFO *strip= cs ? cs : &my_charset_latin1;
+ const char *end= str + strip->cset->lengthsp(strip, str, length);
+ ulonglong flags_to_set= 0, flags_to_clear= 0;
+ bool set_defaults= 0;
+ *err_pos= 0; // No error yet
+ if (str != end)
+ {
+ const char *start= str;
+ for (;;)
+ {
+ const char *pos= start;
+ uint flag_no, value;
+
+ if (!(flag_no= parse_name(lib, &pos, end, cs)))
+ goto err;
+
+ if (flag_no == default_name)
+ {
+ /* Using 'default' twice isn't allowed. */
+ if (set_defaults)
+ goto err;
+ set_defaults= TRUE;
+ }
+ else
+ {
+ ulonglong bit= ((longlong) 1 << (flag_no - 1));
+ /* parse the '=on|off|default' */
+ if ((flags_to_clear | flags_to_set) & bit ||
+ get_next_char(&pos, end, cs) != '=' ||
+ !(value= parse_name(&on_off_default_typelib, &pos, end, cs)))
+ {
+ goto err;
+ }
+
+ if (value == 1) // this is '=off'
+ flags_to_clear|= bit;
+ else if (value == 2) // this is '=on'
+ flags_to_set|= bit;
+ else // this is '=default'
+ {
+ if (default_set & bit)
+ flags_to_set|= bit;
+ else
+ flags_to_clear|= bit;
+ }
+ }
+ if (pos >= end)
+ break;
+
+ if (get_next_char(&pos, end, cs) != ',')
+ goto err;
+
+ start=pos;
+ continue;
+ err:
+ *err_pos= (char*)start;
+ *err_len= end - start;
+ *set_warning= TRUE;
+ break;
+ }
+ }
+ ulonglong res= set_defaults? default_set : cur_set;
+ res|= flags_to_set;
+ res&= ~flags_to_clear;
+ return res;
+}
+
+
/*
Function to find a string in a TYPELIB
(Same format as mysys/typelib.c)
diff --git a/sql/table.cc b/sql/table.cc
index 17454ffb012..d24ee4c6a27 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1652,6 +1652,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
goto err;
outparam->quick_keys.init();
outparam->covering_keys.init();
+ outparam->merge_keys.init();
outparam->keys_in_use_for_query.init();
/* Allocate handler */
@@ -2982,11 +2983,8 @@ void st_table::reset_item_list(List<Item> *item_list) const
void TABLE_LIST::calc_md5(char *buffer)
{
- my_MD5_CTX context;
uchar digest[16];
- my_MD5Init(&context);
- my_MD5Update(&context,(uchar *) select_stmt.str, select_stmt.length);
- my_MD5Final(digest, &context);
+ MY_MD5_HASH(digest, (uchar *) select_stmt.str, select_stmt.length);
sprintf((char *) buffer,
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
digest[0], digest[1], digest[2], digest[3],
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 53870915973..2a94e179600 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -1825,6 +1825,13 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
#ifdef ABBR_ARE_USED
char chars[max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1)))];
#endif
+ /*
+ Used as a temporary tz_info until we decide that we actually want to
+ allocate and keep the tz info and tz name in tz_storage.
+ */
+ TIME_ZONE_INFO tmp_tz_info;
+ memset(&tmp_tz_info, 0, sizeof(TIME_ZONE_INFO));
+
DBUG_ENTER("tz_load_from_open_tables");
/* Prepare tz_info for loading also let us make copy of time zone name */
@@ -1866,7 +1873,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
Most probably user has mistyped time zone name, so no need to bark here
unless we need it for debugging.
*/
- sql_print_error("Can't find description of time zone '%s'", tz_name_buff);
+ sql_print_error("Can't find description of time zone '%.*s'",
+ tz_name->length(), tz_name->ptr());
#endif
goto end;
}
@@ -1895,8 +1903,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
/* If Uses_leap_seconds == 'Y' */
if (table->field[1]->val_int() == 1)
{
- tz_info->leapcnt= tz_leapcnt;
- tz_info->lsis= tz_lsis;
+ tmp_tz_info.leapcnt= tz_leapcnt;
+ tmp_tz_info.lsis= tz_lsis;
}
(void)table->file->ha_index_end();
@@ -1932,18 +1940,18 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
#ifdef ABBR_ARE_USED
// FIXME should we do something with duplicates here ?
table->field[4]->val_str(&abbr, &abbr);
- if (tz_info->charcnt + abbr.length() + 1 > sizeof(chars))
+ if (tmp_tz_info.charcnt + abbr.length() + 1 > sizeof(chars))
{
sql_print_error("Error while loading time zone description from "
"mysql.time_zone_transition_type table: not enough "
"room for abbreviations");
goto end;
}
- ttis[ttid].tt_abbrind= tz_info->charcnt;
- memcpy(chars + tz_info->charcnt, abbr.ptr(), abbr.length());
- tz_info->charcnt+= abbr.length();
- chars[tz_info->charcnt]= 0;
- tz_info->charcnt++;
+ ttis[ttid].tt_abbrind= tmp_tz_info.charcnt;
+ memcpy(chars + tmp_tz_info.charcnt, abbr.ptr(), abbr.length());
+ tmp_tz_info.charcnt+= abbr.length();
+ chars[tmp_tz_info.charcnt]= 0;
+ tmp_tz_info.charcnt++;
DBUG_PRINT("info",
("time_zone_transition_type table: tz_id=%u tt_id=%u tt_gmtoff=%ld "
@@ -1956,9 +1964,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
#endif
/* ttid is increasing because we are reading using index */
- DBUG_ASSERT(ttid >= tz_info->typecnt);
+ DBUG_ASSERT(ttid >= tmp_tz_info.typecnt);
- tz_info->typecnt= ttid + 1;
+ tmp_tz_info.typecnt= ttid + 1;
res= table->file->index_next_same(table->record[0],
table->field[0]->ptr, 4);
@@ -1990,14 +1998,14 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
ttime= (my_time_t)table->field[1]->val_int();
ttid= (uint)table->field[2]->val_int();
- if (tz_info->timecnt + 1 > TZ_MAX_TIMES)
+ if (tmp_tz_info.timecnt + 1 > TZ_MAX_TIMES)
{
sql_print_error("Error while loading time zone description from "
"mysql.time_zone_transition table: "
"too much transitions");
goto end;
}
- if (ttid + 1 > tz_info->typecnt)
+ if (ttid + 1 > tmp_tz_info.typecnt)
{
sql_print_error("Error while loading time zone description from "
"mysql.time_zone_transition table: "
@@ -2005,9 +2013,9 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
goto end;
}
- ats[tz_info->timecnt]= ttime;
- types[tz_info->timecnt]= ttid;
- tz_info->timecnt++;
+ ats[tmp_tz_info.timecnt]= ttime;
+ types[tmp_tz_info.timecnt]= ttid;
+ tmp_tz_info.timecnt++;
DBUG_PRINT("info",
("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u",
@@ -2032,6 +2040,34 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
table= 0;
/*
+ Let us check how correct our time zone description is. We don't check for
+ tz->timecnt < 1 since it is ok for GMT.
+ */
+ if (tmp_tz_info.typecnt < 1)
+ {
+ sql_print_error("loading time zone without transition types");
+ goto end;
+ }
+
+ /* Allocate memory for the timezone info and timezone name in tz_storage. */
+ if (!(alloc_buff= (char*) alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) +
+ tz_name->length() + 1)))
+ {
+ sql_print_error("Out of memory while loading time zone description");
+ return 0;
+ }
+
+ /* Move the temporary tz_info into the allocated area */
+ tz_info= (TIME_ZONE_INFO *)alloc_buff;
+ memcpy(tz_info, &tmp_tz_info, sizeof(TIME_ZONE_INFO));
+ tz_name_buff= alloc_buff + sizeof(TIME_ZONE_INFO);
+ /*
+ By writing zero to the end we guarantee that we can call ptr()
+ instead of c_ptr() for time zone name.
+ */
+ strmake(tz_name_buff, tz_name->ptr(), tz_name->length());
+
+ /*
Now we will allocate memory and init TIME_ZONE_INFO structure.
*/
if (!(alloc_buff= (char*) alloc_root(&tz_storage,
@@ -2062,15 +2098,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables)
tz_info->ttis= (TRAN_TYPE_INFO *)alloc_buff;
memcpy(tz_info->ttis, ttis, tz_info->typecnt * sizeof(TRAN_TYPE_INFO));
- /*
- Let us check how correct our time zone description and build
- reversed map. We don't check for tz->timecnt < 1 since it ok for GMT.
- */
- if (tz_info->typecnt < 1)
- {
- sql_print_error("loading time zone without transition types");
- goto end;
- }
+ /* Build reversed map. */
if (prepare_tz_info(tz_info, &tz_storage))
{
sql_print_error("Unable to build mktime map for time zone");
diff --git a/sql/udf_example.c b/sql/udf_example.c
index a3d149f0971..30d85d95034 100644
--- a/sql/udf_example.c
+++ b/sql/udf_example.c
@@ -1099,7 +1099,7 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
sprintf(result, "not const");
}
*is_null= 0;
- *length= strlen(result);
+ *length= (uint) strlen(result);
return result;
}
@@ -1133,7 +1133,7 @@ char * check_const_len(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
char *is_null, char *error __attribute__((unused)))
{
strmov(result, initid->ptr);
- *length= strlen(result);
+ *length= (uint) strlen(result);
*is_null= 0;
return result;
}
diff --git a/sql/uniques.cc b/sql/uniques.cc
index 0394eee9c6d..858bedb04cd 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -130,7 +130,7 @@ static double get_merge_buffers_cost(uint *buff_elems, uint elem_size,
total_buf_elems+= *pbuf;
*last= total_buf_elems;
- int n_buffers= last - first + 1;
+ size_t n_buffers= last - first + 1;
/* Using log2(n)=log(n)/log(2) formula */
return 2*((double)total_buf_elems*elem_size) / IO_SIZE +
diff --git a/sql/unireg.cc b/sql/unireg.cc
index da018ebec3d..51293184ad8 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -229,16 +229,16 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_info->comment.length, 60);
if (tmp_len < create_info->comment.length)
{
- (void) my_snprintf(buff, sizeof(buff), "Too long comment for table '%s'",
- table);
if ((thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
{
- my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
+ my_error(ER_TOO_LONG_TABLE_COMMENT, MYF(0), table, tmp_len);
goto err;
}
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+ ER_TOO_LONG_TABLE_COMMENT,
+ ER(ER_TOO_LONG_TABLE_COMMENT),
+ table, tmp_len);
create_info->comment.length= tmp_len;
}
@@ -613,17 +613,16 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
255);
if (tmp_len < field->comment.length)
{
- char buff[128];
- (void) my_snprintf(buff,sizeof(buff), "Too long comment for field '%s'",
- field->field_name);
if ((current_thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)))
{
- my_message(ER_UNKNOWN_ERROR, buff, MYF(0));
+ my_error(ER_TOO_LONG_FIELD_COMMENT, MYF(0), field->field_name, tmp_len);
DBUG_RETURN(1);
}
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), buff);
+ ER_TOO_LONG_FIELD_COMMENT,
+ ER(ER_TOO_LONG_FIELD_COMMENT),
+ field->field_name, tmp_len);
field->comment.length= tmp_len;
}
diff --git a/storage/Makefile.am b/storage/Makefile.am
index b978453d29d..4f19be3a361 100644
--- a/storage/Makefile.am
+++ b/storage/Makefile.am
@@ -20,6 +20,7 @@ AUTOMAKE_OPTIONS = foreign
# These are built from source in the Docs directory
EXTRA_DIST =
SUBDIRS = @mysql_se_dirs@
+DIST_SUBDIRS = @mysql_se_distdirs@
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index 59fbe2182ee..916dd8ba59d 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -390,7 +390,7 @@ int destroy (s)
Reads the given number of uncompressed bytes from the compressed file.
azread returns the number of bytes actually read (0 for end of file).
*/
-unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, unsigned int len, int *error)
+unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, size_t len, int *error)
{
Bytef *start = (Bytef*)buf; /* starting point for crc computation */
Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
diff --git a/storage/archive/azlib.h b/storage/archive/azlib.h
index 47772b1c4fe..d7abb40b2ae 100644
--- a/storage/archive/azlib.h
+++ b/storage/archive/azlib.h
@@ -265,7 +265,7 @@ int azdopen(azio_stream *s,File fd, int Flags);
*/
-extern unsigned int azread ( azio_stream *s, voidp buf, unsigned int len, int *error);
+extern unsigned int azread ( azio_stream *s, voidp buf, size_t len, int *error);
/*
Reads the given number of uncompressed bytes from the compressed file.
If the input file was not in gzip format, gzread copies the given number
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index ff59a3eef5c..46e9a99c446 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -1078,16 +1078,18 @@ int ha_archive::unpack_row(azio_stream *file_to_read, uchar *record)
row_len= uint4korr(size_buffer);
DBUG_PRINT("ha_archive",("Unpack row length %u -> %u", row_len,
(unsigned int)table->s->reclength));
- fix_rec_buff(row_len);
+
+ if (fix_rec_buff(row_len))
+ {
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
DBUG_ASSERT(row_len <= record_buffer->length);
read= azread(file_to_read, record_buffer->buffer, row_len, &error);
- DBUG_ASSERT(row_len == read);
-
if (read != row_len || error)
{
- DBUG_RETURN(-1);
+ DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
}
/* Copy null bits */
@@ -1280,7 +1282,7 @@ int ha_archive::repair(THD* thd, HA_CHECK_OPT* check_opt)
int rc= optimize(thd, check_opt);
if (rc)
- DBUG_RETURN(HA_ERR_CRASHED_ON_REPAIR);
+ DBUG_RETURN(HA_ADMIN_CORRUPT);
share->crashed= FALSE;
DBUG_RETURN(0);
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index e40c2db77db..63eb572105c 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -398,12 +398,12 @@ static int free_share(TINA_SHARE *share)
'\r''\n' -- DOS\Windows line ending
*/
-off_t find_eoln_buff(Transparent_file *data_buff, off_t begin,
- off_t end, int *eoln_len)
+my_off_t find_eoln_buff(Transparent_file *data_buff, my_off_t begin,
+ my_off_t end, int *eoln_len)
{
*eoln_len= 0;
- for (off_t x= begin; x < end; x++)
+ for (my_off_t x= begin; x < end; x++)
{
/* Unix (includes Mac OS X) */
if (data_buff->get_value(x) == '\n')
@@ -554,7 +554,7 @@ int ha_tina::chain_append()
/* We set up for the next position */
if ((off_t)(chain_ptr - chain) == (chain_size -1))
{
- off_t location= chain_ptr - chain;
+ my_off_t location= chain_ptr - chain;
chain_size += DEFAULT_CHAIN_LENGTH;
if (chain_alloced)
{
@@ -587,7 +587,7 @@ int ha_tina::chain_append()
*/
int ha_tina::find_current_row(uchar *buf)
{
- off_t end_offset, curr_offset= current_position;
+ my_off_t end_offset, curr_offset= current_position;
int eoln_len;
my_bitmap_map *org_bitmap;
int error;
@@ -837,7 +837,7 @@ int ha_tina::open(const char *name, int mode, uint open_options)
during locking. This is needed to enable concurrent inserts.
*/
thr_lock_data_init(&share->lock, &lock, (void*) this);
- ref_length=sizeof(off_t);
+ ref_length= sizeof(my_off_t);
share->lock.get_status= tina_get_status;
share->lock.update_status= tina_update_status;
@@ -1155,7 +1155,7 @@ int ha_tina::rnd_pos(uchar * buf, uchar *pos)
MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str,
FALSE);
ha_statistic_increment(&SSV::ha_read_rnd_count);
- current_position= (off_t)my_get_ptr(pos,ref_length);
+ current_position= my_get_ptr(pos,ref_length);
rc= find_current_row(buf);
MYSQL_READ_ROW_DONE(rc);
DBUG_RETURN(rc);
@@ -1197,7 +1197,7 @@ int ha_tina::extra(enum ha_extra_function operation)
to the given "hole", stored in the buffer. "Valid" here means,
not listed in the chain of deleted records ("holes").
*/
-bool ha_tina::get_write_pos(off_t *end_pos, tina_set *closest_hole)
+bool ha_tina::get_write_pos(my_off_t *end_pos, tina_set *closest_hole)
{
if (closest_hole == chain_ptr) /* no more chains */
*end_pos= file_buff->end();
@@ -1217,7 +1217,7 @@ bool ha_tina::get_write_pos(off_t *end_pos, tina_set *closest_hole)
int ha_tina::rnd_end()
{
char updated_fname[FN_REFLEN];
- off_t file_buffer_start= 0;
+ my_off_t file_buffer_start= 0;
DBUG_ENTER("ha_tina::rnd_end");
free_root(&blobroot, MYF(0));
@@ -1240,17 +1240,17 @@ int ha_tina::rnd_end()
my_qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set),
(qsort_cmp)sort_set);
- off_t write_begin= 0, write_end;
+ my_off_t write_begin= 0, write_end;
/* create the file to write updated table if it wasn't yet created */
if (open_update_temp_file_if_needed())
DBUG_RETURN(-1);
/* write the file with updated info */
- while ((file_buffer_start != -1)) // while not end of file
+ while ((file_buffer_start != (my_off_t)-1)) // while not end of file
{
bool in_hole= get_write_pos(&write_end, ptr);
- off_t write_length= write_end - write_begin;
+ my_off_t write_length= write_end - write_begin;
/* if there is something to write, write it */
if (write_length)
@@ -1258,14 +1258,15 @@ int ha_tina::rnd_end()
if (my_write(update_temp_file,
(uchar*) (file_buff->ptr() +
(write_begin - file_buff->start())),
- write_length, MYF_RW))
+ (size_t)write_length, MYF_RW))
goto error;
temp_file_length+= write_length;
}
if (in_hole)
{
/* skip hole */
- while (file_buff->end() <= ptr->end && file_buffer_start != -1)
+ while (file_buff->end() <= ptr->end &&
+ file_buffer_start != (my_off_t)-1)
file_buffer_start= file_buff->read_next();
write_begin= ptr->end;
ptr++;
@@ -1365,7 +1366,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
File repair_file;
int rc;
ha_rows rows_repaired= 0;
- off_t write_begin= 0, write_end;
+ my_off_t write_begin= 0, write_end;
DBUG_ENTER("ha_tina::repair");
/* empty file */
@@ -1440,7 +1441,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
write_end= min(file_buff->end(), current_position);
if ((write_end - write_begin) &&
(my_write(repair_file, (uchar*)file_buff->ptr(),
- write_end - write_begin, MYF_RW)))
+ (size_t) (write_end - write_begin), MYF_RW)))
DBUG_RETURN(-1);
write_begin= write_end;
diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h
index 5b4381396fc..02e0700a825 100644
--- a/storage/csv/ha_tina.h
+++ b/storage/csv/ha_tina.h
@@ -40,7 +40,7 @@ typedef struct st_tina_share {
inserts, updates and deletes. The var is initialized along with the
share initialization.
*/
- off_t saved_data_file_length;
+ my_off_t saved_data_file_length;
pthread_mutex_t mutex;
THR_LOCK lock;
bool update_file_opened;
@@ -53,18 +53,18 @@ typedef struct st_tina_share {
} TINA_SHARE;
struct tina_set {
- off_t begin;
- off_t end;
+ my_off_t begin;
+ my_off_t end;
};
class ha_tina: public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
TINA_SHARE *share; /* Shared lock info */
- off_t current_position; /* Current position in the file during a file scan */
- off_t next_position; /* Next position in the file scan */
- off_t local_saved_data_file_length; /* save position for reads */
- off_t temp_file_length;
+ my_off_t current_position; /* Current position in the file during a file scan */
+ my_off_t next_position; /* Next position in the file scan */
+ my_off_t local_saved_data_file_length; /* save position for reads */
+ my_off_t temp_file_length;
uchar byte_buffer[IO_SIZE];
Transparent_file *file_buff;
File data_file; /* File handler for readers */
@@ -85,7 +85,7 @@ class ha_tina: public handler
MEM_ROOT blobroot;
private:
- bool get_write_pos(off_t *end_pos, tina_set *closest_hole);
+ bool get_write_pos(my_off_t *end_pos, tina_set *closest_hole);
int open_update_temp_file_if_needed();
int init_tina_writer();
int init_data_file();
diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc
index a200fa6ac36..841c3efc476 100644
--- a/storage/csv/transparent_file.cc
+++ b/storage/csv/transparent_file.cc
@@ -45,17 +45,17 @@ uchar *Transparent_file::ptr()
return buff;
}
-off_t Transparent_file::start()
+my_off_t Transparent_file::start()
{
return lower_bound;
}
-off_t Transparent_file::end()
+my_off_t Transparent_file::end()
{
return upper_bound;
}
-off_t Transparent_file::read_next()
+my_off_t Transparent_file::read_next()
{
size_t bytes_read;
@@ -64,11 +64,11 @@ off_t Transparent_file::read_next()
always points to upper_bound byte
*/
if ((bytes_read= my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR)
- return (off_t) -1;
+ return (my_off_t) -1;
/* end of file */
if (!bytes_read)
- return (off_t) -1;
+ return (my_off_t) -1;
lower_bound= upper_bound;
upper_bound+= bytes_read;
@@ -77,12 +77,12 @@ off_t Transparent_file::read_next()
}
-char Transparent_file::get_value(off_t offset)
+char Transparent_file::get_value(my_off_t offset)
{
size_t bytes_read;
/* check boundaries */
- if ((lower_bound <= offset) && (offset < upper_bound))
+ if ((lower_bound <= offset) && (((my_off_t) offset) < upper_bound))
return buff[offset - lower_bound];
VOID(my_seek(filedes, offset, MY_SEEK_SET, MYF(0)));
@@ -95,7 +95,7 @@ char Transparent_file::get_value(off_t offset)
upper_bound= lower_bound + bytes_read;
/* end of file */
- if (upper_bound == offset)
+ if (upper_bound == (my_off_t) offset)
return 0;
return buff[0];
diff --git a/storage/csv/transparent_file.h b/storage/csv/transparent_file.h
index 4c0f4cce7e7..0168e271e7d 100644
--- a/storage/csv/transparent_file.h
+++ b/storage/csv/transparent_file.h
@@ -23,8 +23,8 @@ class Transparent_file
File filedes;
uchar *buff; /* in-memory window to the file or mmaped area */
/* current window sizes */
- off_t lower_bound;
- off_t upper_bound;
+ my_off_t lower_bound;
+ my_off_t upper_bound;
uint buff_size;
public:
@@ -34,8 +34,8 @@ public:
void init_buff(File filedes_arg);
uchar *ptr();
- off_t start();
- off_t end();
- char get_value (off_t offset);
- off_t read_next();
+ my_off_t start();
+ my_off_t end();
+ char get_value (my_off_t offset);
+ my_off_t read_next();
};
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index e46379c25c9..e22e342c65e 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -506,7 +506,7 @@ int federated_done(void *p)
in sql_show.cc except that quoting always occurs.
*/
-static bool append_ident(String *string, const char *name, uint length,
+static bool append_ident(String *string, const char *name, size_t length,
const char quote_char)
{
bool result;
@@ -516,7 +516,7 @@ static bool append_ident(String *string, const char *name, uint length,
if (quote_char)
{
- string->reserve(length * 2 + 2);
+ string->reserve((uint) length * 2 + 2);
if ((result= string->append(&quote_char, 1, system_charset_info)))
goto err;
@@ -534,7 +534,7 @@ static bool append_ident(String *string, const char *name, uint length,
result= string->append(&quote_char, 1, system_charset_info);
}
else
- result= string->append(name, length, system_charset_info);
+ result= string->append(name, (uint) length, system_charset_info);
err:
DBUG_RETURN(result);
@@ -544,7 +544,7 @@ err:
static int parse_url_error(FEDERATED_SHARE *share, TABLE *table, int error_num)
{
char buf[FEDERATED_QUERY_BUFFER_SIZE];
- int buf_len;
+ size_t buf_len;
DBUG_ENTER("ha_federated parse_url_error");
buf_len= min(table->s->connect_string.length,
@@ -722,7 +722,7 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATED_SHARE *share, TABLE *table,
{
share->connection_string[share->table_name - share->connection_string]= '\0';
share->table_name++;
- share->table_name_length= strlen(share->table_name);
+ share->table_name_length= (uint) strlen(share->table_name);
DBUG_PRINT("info",
("internal format, parsed table_name share->connection_string \
@@ -1490,7 +1490,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
pthread_mutex_lock(&federated_mutex);
tmp_share.share_key= table_name;
- tmp_share.share_key_length= strlen(table_name);
+ tmp_share.share_key_length= (uint) strlen(table_name);
if (parse_url(&mem_root, &tmp_share, table, 0))
goto error;
@@ -2162,7 +2162,7 @@ int ha_federated::update_row(const uchar *old_data, uchar *new_data)
{
if (bitmap_is_set(table->write_set, (*field)->field_index))
{
- uint field_name_length= strlen((*field)->field_name);
+ size_t field_name_length= strlen((*field)->field_name);
append_ident(&update_string, (*field)->field_name, field_name_length,
ident_quote_char);
update_string.append(STRING_WITH_LEN(" = "));
@@ -2188,7 +2188,7 @@ int ha_federated::update_row(const uchar *old_data, uchar *new_data)
if (bitmap_is_set(table->read_set, (*field)->field_index))
{
- uint field_name_length= strlen((*field)->field_name);
+ size_t field_name_length= strlen((*field)->field_name);
append_ident(&where_string, (*field)->field_name, field_name_length,
ident_quote_char);
if (field_in_record_is_null(table, *field, (char*) old_data))
@@ -3186,7 +3186,7 @@ int ha_federated::real_connect()
}
-int ha_federated::real_query(const char *query, uint length)
+int ha_federated::real_query(const char *query, size_t length)
{
int rc= 0;
DBUG_ENTER("ha_federated::real_query");
@@ -3197,7 +3197,7 @@ int ha_federated::real_query(const char *query, uint length)
if (!query || !length)
goto end;
- rc= mysql_real_query(mysql, query, length);
+ rc= mysql_real_query(mysql, query, (uint) length);
end:
DBUG_RETURN(rc);
diff --git a/storage/federated/ha_federated.h b/storage/federated/ha_federated.h
index 552676b6ae8..ea0a3d2f591 100644
--- a/storage/federated/ha_federated.h
+++ b/storage/federated/ha_federated.h
@@ -70,7 +70,7 @@ typedef struct st_federated_share {
int share_key_length;
ushort port;
- uint table_name_length, server_name_length, connect_string_length, use_count;
+ size_t table_name_length, server_name_length, connect_string_length, use_count;
pthread_mutex_t mutex;
THR_LOCK lock;
} FEDERATED_SHARE;
@@ -113,7 +113,7 @@ private:
uint key_len,
ha_rkey_function find_flag,
MYSQL_RES **result);
- int real_query(const char *query, uint length);
+ int real_query(const char *query, size_t length);
int real_connect();
public:
ha_federated(handlerton *hton, TABLE_SHARE *table_arg);
diff --git a/storage/heap/hp_write.c b/storage/heap/hp_write.c
index 2abef2d9b43..c3dff67d3d5 100644
--- a/storage/heap/hp_write.c
+++ b/storage/heap/hp_write.c
@@ -69,7 +69,7 @@ int heap_write(HP_INFO *info, const uchar *record)
err:
if (my_errno == HA_ERR_FOUND_DUPP_KEY)
DBUG_PRINT("info",("Duplicate key: %d", (int) (keydef - share->keydef)));
- info->errkey= keydef - share->keydef;
+ info->errkey= (int) (keydef - share->keydef);
/*
We don't need to delete non-inserted key from rb-tree. Also, if
we got ENOMEM, the key wasn't inserted, so don't try to delete it
diff --git a/storage/ibmdb2i/CMakeLists.txt b/storage/ibmdb2i/CMakeLists.txt
new file mode 100644
index 00000000000..11cc4300569
--- /dev/null
+++ b/storage/ibmdb2i/CMakeLists.txt
@@ -0,0 +1,25 @@
+# Copyright (C) 2006 MySQL AB
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+ADD_LIBRARY(ibmdb2i ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc
+ db2i_blobCollection.cc db2i_file.cc db2i_charsetSupport.cc
+ db2i_collationSupport.cc db2i_errors.cc db2i_constraints.cc
+ db2i_rir.cc db2i_sqlStatementStream.cc db2i_ioBuffers.cc db2i_myconv.cc)
diff --git a/storage/ibmdb2i/Makefile.am b/storage/ibmdb2i/Makefile.am
new file mode 100644
index 00000000000..768ca15f4cf
--- /dev/null
+++ b/storage/ibmdb2i/Makefile.am
@@ -0,0 +1,54 @@
+#
+# Copyright (c) 2007, 2008, IBM Corporation.
+# All rights reserved.
+#
+#
+
+#called from the top level Makefile
+
+MYSQLDATAdir = $(localstatedir)
+MYSQLSHAREdir = $(pkgdatadir)
+MYSQLBASEdir= $(prefix)
+MYSQLLIBdir= $(pkglibdir)
+pkgplugindir = $(pkglibdir)/plugin
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
+ -I$(top_srcdir)/regex \
+ -I$(top_srcdir)/sql \
+ -I$(srcdir) \
+ -I$ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0f.xpf/cur/cmvc/base.pgm/my.xpf/apis \
+ -I$ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/lg.xpf \
+ -I$ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/tq.xpf
+WRAPLIBS=
+
+LDADD =
+
+DEFS = @DEFS@
+
+noinst_HEADERS = ha_ibmdb2i.h db2i_collationSupport.h db2i_file.h \
+ db2i_ioBuffers.h db2i_blobCollection.h \
+ db2i_global.h db2i_misc.h db2i_charsetSupport.h db2i_errors.h \
+ db2i_iconv.h db2i_myconv.h db2i_safeString.h db2i_sqlStatementStream.h \
+ db2i_ileBridge.h db2i_validatedPointer.h
+
+EXTRA_LTLIBRARIES = ha_ibmdb2i.la
+pkgplugin_LTLIBRARIES = @plugin_ibmdb2i_shared_target@
+ha_ibmdb2i_la_LIBADD = -liconv
+ha_ibmdb2i_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
+ha_ibmdb2i_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_ibmdb2i_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_ibmdb2i_la_SOURCES = ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc \
+ db2i_blobCollection.cc db2i_file.cc db2i_charsetSupport.cc \
+ db2i_collationSupport.cc db2i_errors.cc db2i_constraints.cc \
+ db2i_rir.cc db2i_sqlStatementStream.cc db2i_ioBuffers.cc \
+ db2i_myconv.cc
+
+EXTRA_LIBRARIES = libibmdb2i.a
+noinst_LIBRARIES = @plugin_ibmdb2i_static_target@
+libibmdb2i_a_CXXFLAGS = $(AM_CFLAGS)
+libibmdb2i_a_CFLAGS = $(AM_CFLAGS)
+libibmdb2i_a_SOURCES= $(ha_ibmdb2i_la_SOURCES)
+
+
+EXTRA_DIST = CMakeLists.txt plug.in
+# Don't update the files from bitkeeper
+%::SCCS/s.%
diff --git a/storage/ibmdb2i/db2i_blobCollection.cc b/storage/ibmdb2i/db2i_blobCollection.cc
new file mode 100644
index 00000000000..17101c9c0a4
--- /dev/null
+++ b/storage/ibmdb2i/db2i_blobCollection.cc
@@ -0,0 +1,107 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#include "db2i_blobCollection.h"
+
+/**
+ Return the size to use when allocating space for blob reads.
+
+ @param fieldIndex The field to allocate for
+ @param[out] shouldProtect Indicates whether storage protection should be
+ applied to the space, because the size returned is
+ smaller than the maximum possible size.
+*/
+
+uint32
+BlobCollection::getSizeToAllocate(int fieldIndex, bool& shouldProtect)
+{
+ Field* field = table->getMySQLTable()->field[fieldIndex];
+ uint fieldLength = field->max_display_length();
+
+ if (fieldLength <= MAX_FULL_ALLOCATE_BLOB_LENGTH)
+ {
+ shouldProtect = false;
+ return fieldLength;
+ }
+
+ shouldProtect = true;
+
+ uint curMaxSize = table->getBlobFieldActualSize(fieldIndex);
+
+ uint defaultAllocSize = min(defaultAllocation, fieldLength);
+
+ return max(defaultAllocSize, curMaxSize);
+
+}
+
+void
+BlobCollection::generateBuffer(int fieldIndex)
+{
+ DBUG_ASSERT(table->db2Field(fieldIndex).isBlob());
+
+ bool protect;
+ buffers[table->getBlobIdFromField(fieldIndex)].Malloc(getSizeToAllocate(fieldIndex, protect), protect);
+
+ return;
+}
+
+/**
+ Realloc the read buffer associated with a blob field.
+
+ This is used when the previous allocation for a blob field is found to be
+ too small (this is discovered when QMY_READ trips over the protected boundary
+ page).
+
+ @param fieldIndex The field to be reallocated
+ @param size The size of buffer to allocate for this field.
+*/
+
+ValidatedPointer<char>&
+BlobCollection::reallocBuffer(int fieldIndex, size_t size)
+{
+ ProtectedBuffer& buf = buffers[table->getBlobIdFromField(fieldIndex)];
+ if (size <= buf.allocLen())
+ return buf.ptr();
+
+ table->updateBlobFieldActualSize(fieldIndex, size);
+
+ DBUG_PRINT("BlobCollection::reallocBuffer",("PERF: reallocing %d to %d: ", fieldIndex, size));
+
+ bool protect;
+ buf.Free();
+ buf.Malloc(getSizeToAllocate(fieldIndex, protect), protect);
+ return buf.ptr();
+}
diff --git a/storage/ibmdb2i/db2i_blobCollection.h b/storage/ibmdb2i/db2i_blobCollection.h
new file mode 100644
index 00000000000..6a60394555f
--- /dev/null
+++ b/storage/ibmdb2i/db2i_blobCollection.h
@@ -0,0 +1,151 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_BLOBCOLLECTION_H
+#define DB2I_BLOBCOLLECTION_H
+
+#include "db2i_global.h"
+#include "db2i_file.h"
+
+/**
+ @class ProtectedBuffer
+ @brief Implements memory management for (optionally) protected buffers.
+
+ Buffers created with the protection option will have a guard page set on the
+ page following requested allocation size. The side effect is that the actual
+ allocation is up to 2*4096-1 bytes larger than the size requested by the
+ using code.
+*/
+
+class ProtectedBuffer
+{
+public:
+ ProtectedBuffer() : protectBuf(false)
+ {;}
+
+ void Malloc(size_t size, bool protect = false)
+ {
+ protectBuf = protect;
+ bufptr.alloc(size + (protectBuf ? 0x1fff : 0x0));
+ if ((void*)bufptr != NULL)
+ {
+ len = size;
+ if (protectBuf)
+ mprotect(protectedPage(), 0x1000, PROT_NONE);
+#ifndef DBUG_OFF
+ // Prevents a problem with DBUG_PRINT over-reading in recent versions of
+ // MySQL
+ *((char*)protectedPage()-1) = 0;
+#endif
+ }
+ }
+
+ void Free()
+ {
+ if ((void*)bufptr != NULL)
+ {
+ if (protectBuf)
+ mprotect(protectedPage(), 0x1000, PROT_READ | PROT_WRITE);
+ bufptr.dealloc();
+ }
+ }
+
+ ~ProtectedBuffer()
+ {
+ Free();
+ }
+
+ ValidatedPointer<char>& ptr() {return bufptr;}
+ bool isProtected() const {return protectBuf;}
+ size_t allocLen() const {return len;}
+private:
+ void* protectedPage()
+ {
+ return (void*)(((address64_t)(void*)bufptr + len + 0x1000) & ~0xfff);
+ }
+
+ ValidatedPointer<char> bufptr;
+ size_t len;
+ bool protectBuf;
+
+};
+
+
+/**
+ @class BlobCollection
+ @brief Manages memory allocation for reading blobs associated with a table.
+
+ Allocations are done on-demand and are protected with a guard page if less
+ than the max possible size is allocated.
+*/
+class BlobCollection
+{
+ public:
+ BlobCollection(db2i_table* db2Table, uint32 defaultAllocSize) :
+ defaultAllocation(defaultAllocSize), table(db2Table)
+ {
+ buffers = new ProtectedBuffer[table->getBlobCount()];
+ }
+
+ ~BlobCollection()
+ {
+ delete[] buffers;
+ }
+
+ ValidatedPointer<char>& getBufferPtr(int fieldIndex)
+ {
+ int blobIndex = table->getBlobIdFromField(fieldIndex);
+ if ((char*)buffers[blobIndex].ptr() == NULL)
+ generateBuffer(fieldIndex);
+
+ return buffers[blobIndex].ptr();
+ }
+
+ ValidatedPointer<char>& reallocBuffer(int fieldIndex, size_t size);
+
+
+ private:
+
+ uint32 getSizeToAllocate(int fieldIndex, bool& shouldProtect);
+ void generateBuffer(int fieldIndex);
+
+ db2i_table* table; // The table being read
+ ProtectedBuffer* buffers; // The buffers
+ uint32 defaultAllocation;
+ /* The default size to use when first allocating a buffer */
+};
+
+#endif
diff --git a/storage/ibmdb2i/db2i_charsetSupport.cc b/storage/ibmdb2i/db2i_charsetSupport.cc
new file mode 100644
index 00000000000..2609d42887e
--- /dev/null
+++ b/storage/ibmdb2i/db2i_charsetSupport.cc
@@ -0,0 +1,793 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+
+#include "db2i_charsetSupport.h"
+#include "as400_types.h"
+#include "as400_protos.h"
+#include "db2i_ileBridge.h"
+#include "qlgusr.h"
+#include "db2i_errors.h"
+
+
+/*
+ The following arrays define a mapping between IANA-style text descriptors and
+ IBM i CCSID text descriptors. The mapping is a 1-to-1 correlation between
+ corresponding array slots.
+*/
+#define MAX_IANASTRING 23
+static const char ianaStringType[MAX_IANASTRING][10] =
+{
+ {"ascii"},
+ {"Big5"}, //big5
+ {"cp1250"},
+ {"cp1251"},
+ {"cp1256"},
+ {"cp850"},
+ {"cp852"},
+ {"cp866"},
+ {"IBM943"}, //cp932
+ {"EUC-KR"}, //euckr
+ {"IBM1381"}, //gb2312
+ {"IBM1386"}, //gbk
+ {"greek"},
+ {"hebrew"},
+ {"latin1"},
+ {"latin2"},
+ {"latin5"},
+ {"macce"},
+ {"tis620"},
+ {"Shift_JIS"}, //sjis
+ {"ucs2"},
+ {"EUC-JP"}, //ujis
+ {"utf8"}
+};
+static const char ccsidType[MAX_IANASTRING][6] =
+{
+ {"367"}, //ascii
+ {"950"}, //big5
+ {"1250"}, //cp1250
+ {"1251"}, //cp1251
+ {"1256"}, //cp1256
+ {"850"}, //cp850
+ {"852"}, //cp852
+ {"866"}, //cp866
+ {"943"}, //cp932
+ {"970"}, //euckr
+ {"1381"}, //gb2312
+ {"1386"}, //gbk
+ {"813"}, //greek
+ {"916"}, //hebrew
+ {"923"}, //latin1
+ {"912"}, //latin2
+ {"920"}, //latin5
+ {"1282"}, //macce
+ {"874"}, //tis620
+ {"943"}, //sjis
+ {"13488"},//ucs2
+ {"5050"}, //ujis
+ {"1208"} //utf8
+};
+
+static _ILEpointer *QlgCvtTextDescToDesc_sym;
+
+/* We keep a cache of the mapping for text descriptions obtained via
+ QlgTextDescToDesc. The following structures implement this cache. */
+static HASH textDescMapHash;
+static MEM_ROOT textDescMapMemroot;
+static pthread_mutex_t textDescMapHashMutex;
+struct TextDescMap
+{
+ struct HashKey
+ {
+ int32 inType;
+ int32 outType;
+ char inDesc[Qlg_MaxDescSize];
+ } hashKey;
+ char outDesc[Qlg_MaxDescSize];
+};
+
+/* We keep a cache of the mapping for open iconv descriptors. The following
+ structures implement this cache. */
+static HASH iconvMapHash;
+static MEM_ROOT iconvMapMemroot;
+static pthread_mutex_t iconvMapHashMutex;
+struct IconvMap
+{
+ struct HashKey
+ {
+ uint16 direction; // This is a uint16 instead of a uchar to avoid garbage data in the key from compiler padding
+ uint16 db2CCSID;
+ const CHARSET_INFO* myCharset;
+ } hashKey;
+ iconv_t iconvDesc;
+};
+
+
+/**
+ Initialize the static structures used by this module.
+
+ This must only be called once per plugin instantiation.
+
+ @return 0 if successful. Failure otherwise
+*/
+int32 initCharsetSupport()
+{
+ DBUG_ENTER("initCharsetSupport");
+
+ int actmark = _ILELOAD("QSYS/QLGUSR", ILELOAD_LIBOBJ);
+ if ( actmark == -1 )
+ {
+ DBUG_PRINT("initCharsetSupport", ("conversion srvpgm activation failed"));
+ DBUG_RETURN(1);
+ }
+
+ QlgCvtTextDescToDesc_sym = (ILEpointer*)malloc_aligned(sizeof(ILEpointer));
+ if (_ILESYM(QlgCvtTextDescToDesc_sym, actmark, "QlgCvtTextDescToDesc") == -1)
+ {
+ DBUG_PRINT("initCharsetSupport",
+ ("resolve of QlgCvtTextDescToDesc failed"));
+ DBUG_RETURN(errno);
+ }
+
+ VOID(pthread_mutex_init(&textDescMapHashMutex,MY_MUTEX_INIT_FAST));
+ hash_init(&textDescMapHash, &my_charset_bin, 10, offsetof(TextDescMap, hashKey), sizeof(TextDescMap::hashKey), 0, 0, HASH_UNIQUE);
+
+ VOID(pthread_mutex_init(&iconvMapHashMutex,MY_MUTEX_INIT_FAST));
+ hash_init(&iconvMapHash, &my_charset_bin, 10, offsetof(IconvMap, hashKey), sizeof(IconvMap::hashKey), 0, 0, HASH_UNIQUE);
+
+ init_alloc_root(&textDescMapMemroot, 2048, 0);
+ init_alloc_root(&iconvMapMemroot, 256, 0);
+
+ initMyconv();
+
+ DBUG_RETURN(0);
+}
+
+/**
+ Cleanup the static structures used by this module.
+
+ This must only be called once per plugin instantiation and only if
+ initCharsetSupport() was successful.
+*/
+void doneCharsetSupport()
+{
+ cleanupMyconv();
+
+ free_root(&textDescMapMemroot, 0);
+ free_root(&iconvMapMemroot, 0);
+
+ pthread_mutex_destroy(&textDescMapHashMutex);
+ hash_free(&textDescMapHash);
+ pthread_mutex_destroy(&iconvMapHashMutex);
+ hash_free(&iconvMapHash);
+ free_aligned(QlgCvtTextDescToDesc_sym);
+}
+
+
+/**
+ Convert a text description from one type to another.
+
+ This function is just a wrapper for the IBM i QlgTextDescToDesc function plus
+ some overrides for conversions that the API does not handle correctly and
+ support for caching the computed conversion.
+
+ @param inType The type of descriptor pointed to by "in".
+ @param outType The type of descriptor requested for "out".
+ @param in The descriptor to be convereted.
+ @param[out] out The equivalent descriptor
+ @param hashKey The hash key to be used for caching the conversion result.
+
+ @return 0 if successful. Failure otherwise
+*/
+static int32 getNewTextDesc(const int32 inType,
+ const int32 outType,
+ const char* in,
+ char* out,
+ const TextDescMap::HashKey* hashKey)
+{
+ DBUG_ENTER("db2i_charsetSupport::getNewTextDesc");
+ const arg_type_t signature[] = { ARG_INT32, ARG_INT32, ARG_MEMPTR, ARG_INT32, ARG_MEMPTR, ARG_INT32, ARG_INT32, ARG_END };
+ struct ArgList
+ {
+ ILEarglist_base base;
+ int32 CRDIInType;
+ int32 CRDIOutType;
+ ILEpointer CRDIDesc;
+ int32 CRDIDescSize;
+ ILEpointer CRDODesc;
+ int32 CRDODescSize;
+ int32 CTDCCSID;
+ } *arguments;
+
+ if ((inType == Qlg_TypeIANA) && (outType == Qlg_TypeAix41))
+ {
+ // Override non-standard charsets
+ if (unlikely(strcmp("IBM1381", in) == 0))
+ {
+ strcpy(out, "IBM-1381");
+ DBUG_RETURN(0);
+ }
+ }
+ else if ((inType == Qlg_TypeAS400CCSID) && (outType == Qlg_TypeAix41))
+ {
+ // Override non-standard charsets
+ if (unlikely(strcmp("1148", in) == 0))
+ {
+ strcpy(out, "IBM-1148");
+ DBUG_RETURN(0);
+ }
+ }
+
+ char argBuf[sizeof(ArgList)+15];
+ arguments = (ArgList*)roundToQuadWordBdy(argBuf);
+
+ arguments->CRDIInType = inType;
+ arguments->CRDIOutType = outType;
+ arguments->CRDIDesc.s.addr = (address64_t) in;
+ arguments->CRDIDescSize = Qlg_MaxDescSize;
+ arguments->CRDODesc.s.addr = (address64_t) out;
+ arguments->CRDODescSize = Qlg_MaxDescSize;
+ arguments->CTDCCSID = 819;
+ _ILECALL(QlgCvtTextDescToDesc_sym,
+ &arguments->base,
+ signature,
+ RESULT_INT32);
+ if (unlikely(arguments->base.result.s_int32.r_int32 < 0))
+ {
+ getErrTxt(DB2I_ERR_ILECALL,"QlgCvtTextDescToDesc",arguments->base.result.s_int32.r_int32);
+ DBUG_RETURN(DB2I_ERR_ILECALL);
+ }
+
+ // Store the conversion information into a cache entry
+ TextDescMap* mapping = (TextDescMap*)alloc_root(&textDescMapMemroot, sizeof(TextDescMap));
+ if (unlikely(!mapping))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ memcpy(&(mapping->hashKey), hashKey, sizeof(hashKey));
+ strcpy(mapping->outDesc, out);
+ pthread_mutex_lock(&textDescMapHashMutex);
+ my_hash_insert(&textDescMapHash, (const uchar*)mapping);
+ pthread_mutex_unlock(&textDescMapHashMutex);
+
+ DBUG_RETURN(0);
+}
+
+
+/**
+ Convert a text description from one type to another.
+
+ This function takes a text description in one representation and converts
+ it into another representation. Although the OS provides some facilities for
+ doing this, the support is not complete, nor does MySQL always use standard
+ identifiers. Therefore, there are a lot of hardcoded overrides required.
+ There is probably some room for optimization here, but this should not be
+ called frequently under most circumstances.
+
+ @param inType The type of descriptor pointed to by "in".
+ @param outType The type of descriptor requested for "out".
+ @param in The descriptor to be convereted.
+ @param[out] out The equivalent descriptor
+
+ @return 0 if successful. Failure otherwise
+*/
+static int32 convertTextDesc(const int32 inType, const int32 outType, const char* inDesc, char* outDesc)
+{
+ DBUG_ENTER("db2i_charsetSupport::convertTextDesc");
+ const char* inDescOverride;
+
+ if (inType == Qlg_TypeIANA)
+ {
+ // Override non-standard charsets
+ if (strcmp("big5", inDesc) == 0)
+ inDescOverride = "Big5";
+ else if (strcmp("cp932", inDesc) == 0)
+ inDescOverride = "IBM943";
+ else if (strcmp("euckr", inDesc) == 0)
+ inDescOverride = "EUC-KR";
+ else if (strcmp("gb2312", inDesc) == 0)
+ inDescOverride = "IBM1381";
+ else if (strcmp("gbk", inDesc) == 0)
+ inDescOverride = "IBM1386";
+ else if (strcmp("sjis", inDesc) == 0)
+ inDescOverride = "Shift_JIS";
+ else if (strcmp("ujis", inDesc) == 0)
+ inDescOverride = "EUC-JP";
+ else
+ inDescOverride = inDesc;
+
+ // Hardcode non-standard charsets
+ if (outType == Qlg_TypeAix41)
+ {
+ if (strcmp("Big5", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"big5");
+ DBUG_RETURN(0);
+ }
+ else if (strcmp("IBM1386", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"GBK");
+ DBUG_RETURN(0);
+ }
+ else if (strcmp("Shift_JIS", inDescOverride) == 0 ||
+ strcmp("IBM943", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"IBM-943");
+ DBUG_RETURN(0);
+ }
+ else if (strcmp("tis620", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"TIS-620");
+ DBUG_RETURN(0);
+ }
+ else if (strcmp("ucs2", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"UCS-2");
+ DBUG_RETURN(0);
+ }
+ else if (strcmp("cp1250", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"IBM-1250");
+ DBUG_RETURN(0);
+ }
+ else if (strcmp("cp1251", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"IBM-1251");
+ DBUG_RETURN(0);
+ }
+ else if (strcmp("cp1256", inDescOverride) == 0)
+ {
+ strcpy(outDesc,"IBM-1256");
+ DBUG_RETURN(0);
+ }
+ }
+ else if (outType == Qlg_TypeAS400CCSID)
+ {
+ // See if we can fast path the convert
+ for (int loopCnt = 0; loopCnt < MAX_IANASTRING; ++loopCnt)
+ {
+ if (strcmp((char*)ianaStringType[loopCnt],inDescOverride) == 0)
+ {
+ strcpy(outDesc,ccsidType[loopCnt]);
+ DBUG_RETURN(0);
+ }
+ }
+ }
+ }
+ else
+ inDescOverride = inDesc;
+
+ // We call getNewTextDesc for all other conversions and cache the result.
+ TextDescMap *mapping;
+ TextDescMap::HashKey hashKey;
+ hashKey.inType= inType;
+ hashKey.outType= outType;
+ uint32 len = strlen(inDescOverride);
+ memcpy(hashKey.inDesc, inDescOverride, len);
+ memset(hashKey.inDesc+len, 0, sizeof(hashKey.inDesc) - len);
+
+ if (!(mapping=(TextDescMap *) hash_search(&textDescMapHash,
+ (const uchar*)&hashKey,
+ sizeof(hashKey))))
+ {
+ DBUG_RETURN(getNewTextDesc(inType, outType, inDescOverride, outDesc, &hashKey));
+ }
+ else
+ {
+ strcpy(outDesc, mapping->outDesc);
+ }
+ DBUG_RETURN(0);
+}
+
+
+/**
+ Convert an IANA character set name into a DB2 for i CCSID value.
+
+ @param parmIANADesc An IANA character set name
+ @param[out] db2Ccsid The equivalent CCSID value
+
+ @return 0 if successful. Failure otherwise
+*/
+int32 convertIANAToDb2Ccsid(const char* parmIANADesc, uint16* db2Ccsid)
+{
+ int32 rc;
+ uint16 aixCcsid;
+ char aixCcsidString[Qlg_MaxDescSize];
+ int aixEncodingScheme;
+ int db2EncodingScheme;
+ rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAS400CCSID, parmIANADesc, aixCcsidString);
+ if (rc != 0)
+ return rc;
+ aixCcsid = atoi(aixCcsidString);
+ rc = getEncodingScheme(aixCcsid, aixEncodingScheme);
+ if (rc != 0)
+ return rc;
+ switch(aixEncodingScheme) { // Select on encoding scheme
+ case 0x1100: // EDCDIC SBCS
+ case 0x2100: // ASCII SBCS
+ case 0x4100: // AIX SBCS
+ case 0x4105: // MS Windows
+ case 0x5100: // ISO 7 bit ASCII
+ db2EncodingScheme = 0x1100;
+ break;
+ case 0x1200: // EDCDIC DBCS
+ case 0x2200: // ASCII DBCS
+ db2EncodingScheme = 0x1200;
+ break;
+ case 0x1301: // EDCDIC Mixed
+ case 0x2300: // ASCII Mixed
+ case 0x4403: // EUC (ISO 2022)
+ db2EncodingScheme = 0x1301;
+ break;
+ case 0x7200: // UCS2
+ db2EncodingScheme = 0x7200;
+ break;
+ case 0x7807: // UTF-8
+ db2EncodingScheme = 0x7807;
+ break;
+ case 0x7500: // UTF-32
+ db2EncodingScheme = 0x7500;
+ break;
+ default: // Unknown
+ {
+ getErrTxt(DB2I_ERR_UNKNOWN_ENCODING,aixEncodingScheme);
+ return DB2I_ERR_UNKNOWN_ENCODING;
+ }
+ break;
+ }
+ if (aixEncodingScheme == db2EncodingScheme)
+ {
+ *db2Ccsid = aixCcsid;
+ }
+ else
+ {
+ rc = getAssociatedCCSID(aixCcsid, db2EncodingScheme, db2Ccsid); // EDCDIC SBCS
+ if (rc != 0)
+ return rc;
+ }
+
+ return 0;
+}
+
+
+/**
+ Obtain the encoding scheme of a CCSID.
+
+ @param inCcsid An IBM i CCSID
+ @param[out] outEncodingScheme The associated encoding scheme
+
+ @return 0 if successful. Failure otherwise
+*/
+int32 getEncodingScheme(const uint16 inCcsid, int32& outEncodingScheme)
+{
+ DBUG_ENTER("db2i_charsetSupport::getEncodingScheme");
+
+ static bool ptrInited = FALSE;
+ static char ptrSpace[sizeof(ILEpointer) + 15];
+ static ILEpointer* ptrToPtr = (ILEpointer*)roundToQuadWordBdy(ptrSpace);
+ int rc;
+
+ if (!ptrInited)
+ {
+ rc = _RSLOBJ2(ptrToPtr, RSLOBJ_TS_PGM, "QTQGESP", "QSYS");
+
+ if (rc)
+ {
+ getErrTxt(DB2I_ERR_RESOLVE_OBJ,"QTQGESP","QSYS","*PGM",errno);
+ DBUG_RETURN(DB2I_ERR_RESOLVE_OBJ);
+ }
+ ptrInited = TRUE;
+ }
+
+ DBUG_ASSERT(inCcsid != 0);
+
+ int GESPCCSID = inCcsid;
+ int GESPLen = 32;
+ int GESPNbrVal = 0;
+ int32 GESPES;
+ int GESPCSCPL[32];
+ int GESPFB[3];
+ void* ILEArgv[7];
+ ILEArgv[0] = &GESPCCSID;
+ ILEArgv[1] = &GESPLen;
+ ILEArgv[2] = &GESPNbrVal;
+ ILEArgv[3] = &GESPES;
+ ILEArgv[4] = &GESPCSCPL;
+ ILEArgv[5] = &GESPFB;
+ ILEArgv[6] = NULL;
+
+ rc = _PGMCALL(ptrToPtr, (void**)&ILEArgv, 0);
+
+ if (rc)
+ {
+ getErrTxt(DB2I_ERR_PGMCALL,"QTQGESP","QSYS",rc);
+ DBUG_RETURN(DB2I_ERR_PGMCALL);
+ }
+ if (GESPFB[0] != 0 ||
+ GESPFB[1] != 0 ||
+ GESPFB[2] != 0)
+ {
+ getErrTxt(DB2I_ERR_QTQGESP,GESPFB[0],GESPFB[1],GESPFB[2]);
+ DBUG_RETURN(DB2I_ERR_QTQGESP);
+ }
+ outEncodingScheme = GESPES;
+
+ DBUG_RETURN(0);
+}
+
+
+/**
+ Get the best fit equivalent CCSID. (Wrapper for QTQGRDC API)
+
+ @param inCcsid An IBM i CCSID
+ @param inEncodingScheme The encoding scheme
+ @param[out] outCcsid The equivalent CCSID
+
+ @return 0 if successful. Failure otherwise
+*/
+int32 getAssociatedCCSID(const uint16 inCcsid, const int inEncodingScheme, uint16* outCcsid)
+{
+ DBUG_ENTER("db2i_charsetSupport::getAssociatedCCSID");
+ static bool ptrInited = FALSE;
+ static char ptrSpace[sizeof(ILEpointer) + 15];
+ static ILEpointer* ptrToPtr = (ILEpointer*)roundToQuadWordBdy(ptrSpace);
+ int rc;
+
+ // Override non-standard charsets
+ if ((inCcsid == 923) && (inEncodingScheme == 0x1100))
+ {
+ *outCcsid = 1148;
+ DBUG_RETURN(0);
+ }
+
+ if (!ptrInited)
+ {
+ rc = _RSLOBJ2(ptrToPtr, RSLOBJ_TS_PGM, "QTQGRDC", "QSYS");
+
+ if (rc)
+ {
+ getErrTxt(DB2I_ERR_RESOLVE_OBJ,"QTQGRDC","QSYS","*PGM",errno);
+ DBUG_RETURN(DB2I_ERR_RESOLVE_OBJ);
+ }
+ ptrInited = TRUE;
+ }
+
+ int GRDCCCSID = inCcsid;
+ int GRDCES = inEncodingScheme;
+ int GRDCSel = 0;
+ int GRDCAssCCSID;
+ int GRDCFB[3];
+ void* ILEArgv[7];
+ ILEArgv[0] = &GRDCCCSID;
+ ILEArgv[1] = &GRDCES;
+ ILEArgv[2] = &GRDCSel;
+ ILEArgv[3] = &GRDCAssCCSID;
+ ILEArgv[4] = &GRDCFB;
+ ILEArgv[5] = NULL;
+
+ rc = _PGMCALL(ptrToPtr, (void**)&ILEArgv, 0);
+
+ if (rc)
+ {
+ getErrTxt(DB2I_ERR_PGMCALL,"QTQGRDC","QSYS",rc);
+ DBUG_RETURN(DB2I_ERR_PGMCALL);
+ }
+ if (GRDCFB[0] != 0 ||
+ GRDCFB[1] != 0 ||
+ GRDCFB[2] != 0)
+ {
+ getErrTxt(DB2I_ERR_QTQGRDC,GRDCFB[0],GRDCFB[1],GRDCFB[2]);
+ DBUG_RETURN(DB2I_ERR_QTQGRDC);
+ }
+
+ *outCcsid = GRDCAssCCSID;
+
+ DBUG_RETURN(0);
+}
+
+/**
+ Open an iconv conversion between a MySQL charset and the respective IBM i CCSID
+
+ @param direction The direction of the conversion
+ @param mysqlCSName Name of the MySQL character set
+ @param db2CCSID The IBM i CCSID
+ @param hashKey The key to use for inserting the opened conversion into the cache
+ @param[out] newConversion The iconv descriptor
+
+ @return 0 if successful. Failure otherwise
+*/
+static int32 openNewConversion(enum_conversionDirection direction,
+ const char* mysqlCSName,
+ uint16 db2CCSID,
+ IconvMap::HashKey* hashKey,
+ iconv_t& newConversion)
+{
+ DBUG_ENTER("db2i_charsetSupport::openNewConversion");
+
+ char mysqlAix41Desc[Qlg_MaxDescSize];
+ char db2Aix41Desc[Qlg_MaxDescSize];
+ char db2CcsidString[6] = "";
+ int32 rc;
+
+ /*
+ First we have to convert the MySQL IANA-like name and the DB2 CCSID into
+ there equivalent iconv descriptions.
+ */
+ rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAix41, mysqlCSName, mysqlAix41Desc);
+ if (rc)
+ DBUG_RETURN(rc);
+ CHARSET_INFO *cs= &my_charset_bin;
+ (uint)(cs->cset->long10_to_str)(cs,db2CcsidString,sizeof(db2CcsidString), 10, db2CCSID);
+ rc = convertTextDesc(Qlg_TypeAS400CCSID, Qlg_TypeAix41, db2CcsidString, db2Aix41Desc);
+ if (rc)
+ DBUG_RETURN(rc);
+
+ /* Call iconv to open the conversion. */
+ if (direction == toDB2)
+ {
+ newConversion = iconv_open(db2Aix41Desc, mysqlAix41Desc);
+ if (newConversion == (iconv_t) -1)
+ {
+ getErrTxt(DB2I_ERR_ICONV_OPEN, mysqlAix41Desc, db2Aix41Desc, errno);
+ DBUG_RETURN(DB2I_ERR_ICONV_OPEN);
+ }
+ }
+ else
+ {
+ newConversion = iconv_open(mysqlAix41Desc, db2Aix41Desc);
+ if (newConversion == (iconv_t) -1)
+ {
+ getErrTxt(DB2I_ERR_ICONV_OPEN, db2Aix41Desc, mysqlAix41Desc, errno);
+ DBUG_RETURN(DB2I_ERR_ICONV_OPEN);
+ }
+ }
+
+ /* Insert the new conversion into the cache. */
+ IconvMap* mapping = (IconvMap*)alloc_root(&iconvMapMemroot, sizeof(IconvMap));
+ if (!mapping)
+ {
+ my_error(ER_OUTOFMEMORY, MYF(0), sizeof(IconvMap));
+ DBUG_RETURN( HA_ERR_OUT_OF_MEM);
+ }
+ memcpy(&(mapping->hashKey), hashKey, sizeof(mapping->hashKey));
+ mapping->iconvDesc = newConversion;
+ pthread_mutex_lock(&iconvMapHashMutex);
+ my_hash_insert(&iconvMapHash, (const uchar*)mapping);
+ pthread_mutex_unlock(&iconvMapHashMutex);
+
+ DBUG_RETURN(0);
+}
+
+
+/**
+ Open an iconv conversion between a MySQL charset and the respective IBM i CCSID
+
+ @param direction The direction of the conversion
+ @param cs The MySQL character set
+ @param db2CCSID The IBM i CCSID
+ @param[out] newConversion The iconv descriptor
+
+ @return 0 if successful. Failure otherwise
+*/
+int32 getConversion(enum_conversionDirection direction, const CHARSET_INFO* cs, uint16 db2CCSID, iconv_t& conversion)
+{
+ DBUG_ENTER("db2i_charsetSupport::getConversion");
+
+ int32 rc;
+
+ /* Build the hash key */
+ IconvMap::HashKey hashKey;
+ hashKey.direction= direction;
+ hashKey.myCharset= cs;
+ hashKey.db2CCSID= db2CCSID;
+
+ /* Look for the conversion in the cache and add it if it is not there. */
+ IconvMap *mapping;
+ if (!(mapping= (IconvMap *) hash_search(&iconvMapHash,
+ (const uchar*)&hashKey,
+ sizeof(hashKey))))
+ {
+ DBUG_PRINT("getConversion", ("Hash miss for direction=%d, cs=%s, ccsid=%d", direction, cs->name, db2CCSID));
+ rc= openNewConversion(direction, cs->csname, db2CCSID, &hashKey, conversion);
+ if (rc)
+ DBUG_RETURN(rc);
+ }
+ else
+ {
+ conversion= mapping->iconvDesc;
+ }
+
+ DBUG_RETURN(0);
+}
+
+/**
+ Fast-path conversion from ASCII to EBCDIC for use in converting
+ identifiers to be sent to the QMY APIs.
+
+ @param input ASCII data
+ @param[out] ouput EBCDIC data
+ @param ilen Size of input buffer and output buffer
+*/
+int convToEbcdic(const char* input, char* output, size_t ilen)
+{
+ static bool inited = FALSE;
+ static iconv_t ic;
+
+ if (ilen == 0)
+ return 0;
+
+ if (!inited)
+ {
+ ic = iconv_open( "IBM-037", "ISO8859-1" );
+ inited = TRUE;
+ }
+ size_t substitutedChars;
+ size_t olen = ilen;
+ if (iconv( ic, (char**)&input, &ilen, &output, &olen, &substitutedChars ) == -1)
+ return errno;
+
+ return 0;
+}
+
+
+/**
+ Fast-path conversion from EBCDIC to ASCII for use in converting
+ data received from the QMY APIs.
+
+ @param input EBCDIC data
+ @param[out] ouput ASCII data
+ @param ilen Size of input buffer and output buffer
+*/
+int convFromEbcdic(const char* input, char* output, size_t ilen)
+{
+ static bool inited = FALSE;
+ static iconv_t ic;
+
+ if (ilen == 0)
+ return 0;
+
+ if (!inited)
+ {
+ ic = iconv_open("ISO8859-1", "IBM-037");
+ inited = TRUE;
+ }
+
+ size_t substitutedChars;
+ size_t olen = ilen;
+ if (iconv( ic, (char**)&input, &ilen, &output, &olen, &substitutedChars) == -1)
+ return errno;
+
+ return 0;
+}
diff --git a/storage/ibmdb2i/db2i_charsetSupport.h b/storage/ibmdb2i/db2i_charsetSupport.h
new file mode 100644
index 00000000000..77051e1e0db
--- /dev/null
+++ b/storage/ibmdb2i/db2i_charsetSupport.h
@@ -0,0 +1,65 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_CHARSETSUPPORT_H
+#define DB2I_CHARSETSUPPORT_H
+
+#include "db2i_global.h"
+#include "mysql_priv.h"
+#include <mysql/plugin.h>
+#include "db2i_iconv.h"
+
+/**
+ @enum enum_conversionDirection
+
+ Conversion directions for getConversion()
+*/
+enum enum_conversionDirection
+{
+ toMySQL,
+ toDB2
+};
+
+int initCharsetSupport();
+void doneCharsetSupport();
+int32 convertIANAToDb2Ccsid(const char* parmIANADesc, uint16* db2Ccsid);
+int32 getEncodingScheme(const uint16 inCcsid, int32& outEncodingScheme);
+int32 getAssociatedCCSID(const uint16 inCcsid, const int inEncodingScheme, uint16* outCcsid);
+int convToEbcdic(const char* input, char* output, size_t ilen);
+int convFromEbcdic(const char* input, char* output, size_t ilen);
+int32 getConversion(enum_conversionDirection direction, const CHARSET_INFO* cs, uint16 db2CCSID, iconv_t& conversion);
+
+#endif
diff --git a/storage/ibmdb2i/db2i_collationSupport.cc b/storage/ibmdb2i/db2i_collationSupport.cc
new file mode 100644
index 00000000000..a41f211a689
--- /dev/null
+++ b/storage/ibmdb2i/db2i_collationSupport.cc
@@ -0,0 +1,359 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#include "db2i_collationSupport.h"
+#include "db2i_errors.h"
+
+
+/*
+ The following arrays define a mapping between MySQL collation names and
+ corresponding IBM i sort sequences. The mapping is a 1-to-1 correlation
+ between corresponding array slots but is incomplete without case-sensitivity
+ markers dynamically added to the mySqlSortSequence names.
+*/
+#define MAX_COLLATION 89
+static const char* mySQLCollation[MAX_COLLATION] =
+{
+ {"ascii_general"},
+ {"ascii"},
+ {"big5_chinese"},
+ {"big5"},
+ {"cp1250_croatian"},
+ {"cp1250_czech"},
+ {"cp1250_general"},
+ {"cp1250_polish"},
+ {"cp1250"},
+ {"cp1251_bulgarian"},
+ {"cp1251_general"},
+ {"cp1251"},
+ {"cp1256_general"},
+ {"cp1256"},
+ {"cp850_general"},
+ {"cp850"},
+ {"cp852_general"},
+ {"cp852"},
+ {"cp932_japanese"},
+ {"cp932"},
+ {"euckr_korean"},
+ {"euckr"},
+ {"gb2312_chinese"},
+ {"gb2312"},
+ {"gbk_chinese"},
+ {"gbk"},
+ {"greek_general"},
+ {"greek"},
+ {"hebrew_general"},
+ {"hebrew"},
+ {"latin1_danish"},
+ {"latin1_general"},
+ {"latin1_german1"},
+ {"latin1_spanish"},
+ {"latin1_swedish"},
+ {"latin1"},
+ {"latin2_croatian"},
+ {"latin2_czech"},
+ {"latin2_general"},
+ {"latin2_hungarian"},
+ {"latin2"},
+ {"latin5_turkish"},
+ {"latin5"},
+ {"macce_general"},
+ {"macce"},
+ {"sjis_japanese"},
+ {"sjis"},
+ {"tis620_thai"},
+ {"tis620"},
+ {"ucs2_czech"},
+ {"ucs2_danish"},
+ {"ucs2_esperanto"},
+ {"ucs2_estonian"},
+ {"ucs2_general"},
+ {"ucs2_hungarian"},
+ {"ucs2_icelandic"},
+ {"ucs2_latvian"},
+ {"ucs2_lithuanian"},
+ {"ucs2_persian"},
+ {"ucs2_polish"},
+ {"ucs2_romanian"},
+ {"ucs2_slovak"},
+ {"ucs2_slovenian"},
+ {"ucs2_spanish"},
+ {"ucs2_swedish"},
+ {"ucs2_turkish"},
+ {"ucs2_unicode"},
+ {"ucs2"},
+ {"ujis_japanese"},
+ {"ujis"},
+ {"utf8_czech"},
+ {"utf8_danish"},
+ {"utf8_esperanto"},
+ {"utf8_estonian"},
+ {"utf8_general"},
+ {"utf8_hungarian"},
+ {"utf8_icelandic"},
+ {"utf8_latvian"},
+ {"utf8_lithuanian"},
+ {"utf8_persian"},
+ {"utf8_polish"},
+ {"utf8_romanian"},
+ {"utf8_slovak"},
+ {"utf8_slovenian"},
+ {"utf8_spanish"},
+ {"utf8_swedish"},
+ {"utf8_turkish"},
+ {"utf8_unicode"},
+ {"utf8"}
+};
+
+
+static const char* mySqlSortSequence[MAX_COLLATION] =
+{
+ {"QALA101F4"},
+ {"QBLA101F4"},
+ {"QACHT04B0"},
+ {"QBCHT04B0"},
+ {"QALA20481"},
+ {"QBLA20481"},
+ {"QCLA20481"},
+ {"QDLA20481"},
+ {"QELA20481"},
+ {"QACYR0401"},
+ {"QBCYR0401"},
+ {"QCCYR0401"},
+ {"QAARA01A4"},
+ {"QBARA01A4"},
+ {"QCLA101F4"},
+ {"QDLA101F4"},
+ {"QALA20366"},
+ {"QBLA20366"},
+ {"QAJPN04B0"},
+ {"QBJPN04B0"},
+ {"QAKOR04B0"},
+ {"QBKOR04B0"},
+ {"QACHS04B0"},
+ {"QBCHS04B0"},
+ {"QCCHS04B0"},
+ {"QDCHS04B0"},
+ {"QAELL036B"},
+ {"QBELL036B"},
+ {"QAHEB01A8"},
+ {"QBHEB01A8"},
+ {"QALA1047C"},
+ {"QBLA1047C"},
+ {"QCLA1047C"},
+ {"QDLA1047C"},
+ {"QELA1047C"},
+ {"QFLA1047C"},
+ {"QCLA20366"},
+ {"QDLA20366"},
+ {"QELA20366"},
+ {"QFLA20366"},
+ {"QGLA20366"},
+ {"QATRK0402"},
+ {"QBTRK0402"},
+ {"QHLA20366"},
+ {"QILA20366"},
+ {"QCJPN04B0"},
+ {"QDJPN04B0"},
+ {"QATHA0346"},
+ {"QBTHA0346"},
+ {"ACS"},
+ {"ADA"},
+ {"AEO"},
+ {"AET"},
+ {"QAUCS04B0"},
+ {"AHU"},
+ {"AIS"},
+ {"ALV"},
+ {"ALT"},
+ {"AFA"},
+ {"APL"},
+ {"ARO"},
+ {"ASK"},
+ {"ASL"},
+ {"AES"},
+ {"ASW"},
+ {"ATR"},
+ {"AEN"},
+ {"*HEX"},
+ {"QEJPN04B0"},
+ {"QFJPN04B0"},
+ {"ACS"},
+ {"ADA"},
+ {"AEO"},
+ {"AET"},
+ {"QAUCS04B0"},
+ {"AHU"},
+ {"AIS"},
+ {"ALV"},
+ {"ALT"},
+ {"AFA"},
+ {"APL"},
+ {"ARO"},
+ {"ASK"},
+ {"ASL"},
+ {"AES"},
+ {"ASW"},
+ {"ATR"},
+ {"AEN"},
+ {"*HEX"}
+};
+
+
+/**
+ Get the IBM i sort sequence that corresponds to the given MySQL collation.
+
+ @param fieldCharSet The collated character set
+ @param[out] rtnSortSequence The corresponding sort sequence
+
+ @return 0 if successful. Failure otherwise
+*/
+static int32 getAssociatedSortSequence(const CHARSET_INFO *fieldCharSet, const char** rtnSortSequence)
+{
+ DBUG_ENTER("ha_ibmdb2i::getAssociatedSortSequence");
+
+ if (strcmp(fieldCharSet->csname,"binary") != 0)
+ {
+ int collationSearchLen = strlen(fieldCharSet->name);
+ if (fieldCharSet->state & MY_CS_BINSORT)
+ collationSearchLen -= 4;
+ else
+ collationSearchLen -= 3;
+
+ uint16 loopCnt = 0;
+ for (loopCnt; loopCnt < MAX_COLLATION; ++loopCnt)
+ {
+ if ((strlen(mySQLCollation[loopCnt]) == collationSearchLen) &&
+ (strncmp((char*)mySQLCollation[loopCnt], fieldCharSet->name, collationSearchLen) == 0))
+ break;
+ }
+ if (loopCnt == MAX_COLLATION) // Did not find associated sort sequence
+ {
+ getErrTxt(DB2I_ERR_SRTSEQ);
+ DBUG_RETURN(DB2I_ERR_SRTSEQ);
+ }
+ *rtnSortSequence = mySqlSortSequence[loopCnt];
+ }
+
+ DBUG_RETURN(0);
+}
+
+
+/**
+ Update sort sequence information for a key.
+
+ This function accumulates information about a key as it is called for each
+ field composing the key. The caller should invoke the function for each field
+ and (with the exception of the charset parm) preserve the values for the
+ parms across invocations, until a particular key has been evaluated. Once
+ the last field in the key has been evaluated, the fileSortSequence and
+ fileSortSequenceLibrary parms will contain the correct information for
+ creating the corresponding DB2 key.
+
+ @param charset The character set under consideration
+ @param[in, out] fileSortSequenceType The type of the current key's sort seq
+ @param[in, out] fileSortSequence The IBM i identifier for the DB2 sort sequence
+ that corresponds
+
+ @return 0 if successful. Failure otherwise
+*/
+int32 updateAssociatedSortSequence(const CHARSET_INFO* charset,
+ char* fileSortSequenceType,
+ char* fileSortSequence,
+ char* fileSortSequenceLibrary)
+{
+ DBUG_ENTER("ha_ibmdb2i::updateAssociatedSortSequence");
+ DBUG_ASSERT(charset);
+ if (strcmp(charset->csname,"binary") != 0)
+ {
+ char newSortSequence[11] = "";
+ char newSortSequenceType = ' ';
+ const char* foundSortSequence;
+ int rc = getAssociatedSortSequence(charset, &foundSortSequence);
+ if (rc) DBUG_RETURN (rc);
+ switch(foundSortSequence[0])
+ {
+ case '*': // Binary
+ strcat(newSortSequence,foundSortSequence);
+ newSortSequenceType = 'B';
+ break;
+ case 'Q': // Non-ICU sort sequence
+ strcat(newSortSequence,foundSortSequence);
+ if ((charset->state & MY_CS_BINSORT) != 0)
+ {
+ strcat(newSortSequence,"U");
+ }
+ else if ((charset->state & MY_CS_CSSORT) != 0)
+ {
+ strcat(newSortSequence,"U");
+ }
+ else
+ {
+ strcat(newSortSequence,"S");
+ }
+ newSortSequenceType = 'N';
+ break;
+ default: // ICU sort sequence
+ {
+ if ((charset->state & MY_CS_CSSORT) == 0)
+ {
+ if (osVersion.v >= 6)
+ strcat(newSortSequence,"I34"); // ICU 3.4
+ else
+ strcat(newSortSequence,"I26"); // ICU 2.6.1
+ }
+ strcat(newSortSequence,foundSortSequence);
+ newSortSequenceType = 'I';
+ }
+ break;
+ }
+ if (*fileSortSequenceType == ' ') // If no sort sequence has been set yet
+ {
+ // Set associated sort sequence
+ strcpy(fileSortSequence,newSortSequence);
+ strcpy(fileSortSequenceLibrary,"QSYS");
+ *fileSortSequenceType = newSortSequenceType;
+ }
+ else if (strcmp(fileSortSequence,newSortSequence) != 0)
+ {
+ // Only one sort sequence/collation is supported for each DB2 index.
+ getErrTxt(DB2I_ERR_MIXED_COLLATIONS);
+ DBUG_RETURN(DB2I_ERR_MIXED_COLLATIONS);
+ }
+ }
+
+ DBUG_RETURN(0);
+}
diff --git a/storage/ibmdb2i/db2i_collationSupport.h b/storage/ibmdb2i/db2i_collationSupport.h
new file mode 100644
index 00000000000..b2ce09de1ea
--- /dev/null
+++ b/storage/ibmdb2i/db2i_collationSupport.h
@@ -0,0 +1,48 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_COLLATIONSUPPORT_H
+#define DB2I_COLLATIONSUPPORT_H
+
+#include "db2i_global.h"
+#include "mysql_priv.h"
+
+int32 updateAssociatedSortSequence(const CHARSET_INFO* charset,
+ char* fileSortSequenceType,
+ char* fileSortSequence,
+ char* fileSortSequenceLibrary);
+
+#endif
diff --git a/storage/ibmdb2i/db2i_constraints.cc b/storage/ibmdb2i/db2i_constraints.cc
new file mode 100644
index 00000000000..9a96eda1173
--- /dev/null
+++ b/storage/ibmdb2i/db2i_constraints.cc
@@ -0,0 +1,698 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+
+#include "ha_ibmdb2i.h"
+#include "db2i_safeString.h"
+
+// This function is called when building the CREATE TABLE information for
+// foreign key constraints. It converts a constraint, table, schema, or
+// field name from EBCDIC to ASCII. If the DB2 name is quoted, it removes
+// those quotes. It then adds the appropriate quotes for a MySQL identifier.
+
+static void convNameForCreateInfo(THD *thd, SafeString& info, char* fromName, int len)
+{
+ int quote;
+ char cquote; // Quote character
+ char convName[MAX_DB2_FILENAME_LENGTH]; // Converted name
+
+ memset(convName, 0, sizeof(convName));
+ convFromEbcdic(fromName, convName, len);
+ quote = get_quote_char_for_identifier(thd, convName, len);
+ cquote = (char) quote;
+ if (quote != EOF)
+ info.strcat(cquote);
+ if (convName[0] == '"') // If DB2 name was quoted, remove quotes
+ {
+ if (strstr(convName, "\"\""))
+ stripExtraQuotes(convName+1, len-1);
+ info.strncat((char*)(convName+1), len-2);
+ }
+ else // DB2 name was not quoted
+ info.strncat(convName, len);
+ if (quote != EOF)
+ info.strcat(cquote);
+}
+
+/**
+ Evaluate the parse tree to build foreign key constraint clauses
+
+ @parm lex The parse tree
+ @parm appendHere The DB2 string to receive the constraint clauses
+ @parm path The path to the table under consideration
+ @parm fields Pointer to the table's list of field pointers
+ @parm[in, out] fileSortSequenceType The sort sequence type associated with the table
+ @parm[in, out] fileSortSequence The sort sequence associated with the table
+ @parm[in, out] fileSortSequenceLibrary The sort sequence library associated with the table
+
+ @return 0 if successful; HA_ERR_CANNOT_ADD_FOREIGN otherwise
+*/
+int ha_ibmdb2i::buildDB2ConstraintString(LEX* lex,
+ String& appendHere,
+ const char* path,
+ Field** fields,
+ char* fileSortSequenceType,
+ char* fileSortSequence,
+ char* fileSortSequenceLibrary)
+{
+ List_iterator<Key> keyIter(lex->alter_info.key_list);
+ char colName[MAX_DB2_COLNAME_LENGTH+1];
+
+ Key* curKey;
+
+ while (curKey = keyIter++)
+ {
+ if (curKey->type == Key::FOREIGN_KEY)
+ {
+ appendHere.append(STRING_WITH_LEN(", "));
+
+ Foreign_key* fk = (Foreign_key*)curKey;
+
+ char db2LibName[MAX_DB2_SCHEMANAME_LENGTH+1];
+ if (fk->name)
+ {
+ char db2FKName[MAX_DB2_FILENAME_LENGTH+1];
+ appendHere.append(STRING_WITH_LEN("CONSTRAINT "));
+ if (fk->ref_table->db.str)
+ {
+ convertMySQLNameToDB2Name(fk->ref_table->db.str, db2LibName, sizeof(db2LibName));
+ }
+ else
+ {
+ db2i_table::getDB2LibNameFromPath(path, db2LibName);
+ }
+ if (lower_case_table_names == 1)
+ my_casedn_str(files_charset_info, db2LibName);
+ appendHere.append(db2LibName);
+
+ appendHere.append('.');
+
+ convertMySQLNameToDB2Name(fk->name, db2FKName, sizeof(db2FKName));
+ appendHere.append(db2FKName);
+ }
+
+ appendHere.append(STRING_WITH_LEN(" FOREIGN KEY ("));
+
+ bool firstTime = true;
+
+ List_iterator<Key_part_spec> column(fk->columns);
+ Key_part_spec* curColumn;
+
+ while (curColumn = column++)
+ {
+ if (!firstTime)
+ {
+ appendHere.append(',');
+ }
+ firstTime = false;
+
+ convertMySQLNameToDB2Name(curColumn->field_name, colName, sizeof(colName));
+ appendHere.append(colName);
+
+ // DB2 requires that the sort sequence on the child table match the parent table's
+ // sort sequence. We ensure that happens by updating the sort sequence according
+ // to the constrained fields.
+ Field** field = fields;
+ do
+ {
+ if (strcmp((*field)->field_name, curColumn->field_name) == 0)
+ {
+ int rc = updateAssociatedSortSequence((*field)->charset(),
+ fileSortSequenceType,
+ fileSortSequence,
+ fileSortSequenceLibrary);
+
+ if (unlikely(rc)) return rc;
+ }
+ } while (*(++field));
+ }
+
+ firstTime = true;
+
+ appendHere.append(STRING_WITH_LEN(") REFERENCES "));
+
+ if (fk->ref_table->db.str)
+ {
+ convertMySQLNameToDB2Name(fk->ref_table->db.str, db2LibName, sizeof(db2LibName));
+ }
+ else
+ {
+ db2i_table::getDB2LibNameFromPath(path, db2LibName);
+ }
+ if (lower_case_table_names == 1)
+ my_casedn_str(files_charset_info, db2LibName);
+ appendHere.append(db2LibName);
+ appendHere.append('.');
+
+ char db2FileName[MAX_DB2_FILENAME_LENGTH+1];
+ convertMySQLNameToDB2Name(fk->ref_table->table.str, db2FileName, sizeof(db2FileName));
+ if (lower_case_table_names)
+ my_casedn_str(files_charset_info, db2FileName);
+ appendHere.append(db2FileName);
+
+
+ if (!fk->ref_columns.is_empty())
+ {
+ List_iterator<Key_part_spec> ref(fk->ref_columns);
+ Key_part_spec* curRef;
+ appendHere.append(STRING_WITH_LEN(" ("));
+
+
+ while (curRef = ref++)
+ {
+ if (!firstTime)
+ {
+ appendHere.append(',');
+ }
+ firstTime = false;
+
+ convertMySQLNameToDB2Name(curRef->field_name, colName, sizeof(colName));
+ appendHere.append(colName);
+ }
+
+ appendHere.append(STRING_WITH_LEN(") "));
+ }
+
+ if (fk->delete_opt != Foreign_key::FK_OPTION_UNDEF)
+ {
+ appendHere.append(STRING_WITH_LEN("ON DELETE "));
+ switch (fk->delete_opt)
+ {
+ case Foreign_key::FK_OPTION_RESTRICT:
+ appendHere.append(STRING_WITH_LEN("RESTRICT ")); break;
+ case Foreign_key::FK_OPTION_CASCADE:
+ appendHere.append(STRING_WITH_LEN("CASCADE ")); break;
+ case Foreign_key::FK_OPTION_SET_NULL:
+ appendHere.append(STRING_WITH_LEN("SET NULL ")); break;
+ case Foreign_key::FK_OPTION_NO_ACTION:
+ appendHere.append(STRING_WITH_LEN("NO ACTION ")); break;
+ case Foreign_key::FK_OPTION_DEFAULT:
+ appendHere.append(STRING_WITH_LEN("SET DEFAULT ")); break;
+ default:
+ return HA_ERR_CANNOT_ADD_FOREIGN; break;
+ }
+ }
+
+ if (fk->update_opt != Foreign_key::FK_OPTION_UNDEF)
+ {
+ appendHere.append(STRING_WITH_LEN("ON UPDATE "));
+ switch (fk->update_opt)
+ {
+ case Foreign_key::FK_OPTION_RESTRICT:
+ appendHere.append(STRING_WITH_LEN("RESTRICT ")); break;
+ case Foreign_key::FK_OPTION_NO_ACTION:
+ appendHere.append(STRING_WITH_LEN("NO ACTION ")); break;
+ default:
+ return HA_ERR_CANNOT_ADD_FOREIGN; break;
+ }
+ }
+
+ }
+
+ }
+
+ return 0;
+}
+
+
+/***********************************************************************
+Get the foreign key information in the form of a character string so
+that it can be inserted into a CREATE TABLE statement. This is used by
+the SHOW CREATE TABLE statement. The string will later be freed by the
+free_foreign_key_create_info() method.
+************************************************************************/
+
+char* ha_ibmdb2i::get_foreign_key_create_info(void)
+{
+ DBUG_ENTER("ha_ibmdb2i::get_foreign_key_create_info");
+ int rc = 0;
+ char* infoBuffer = NULL; // Pointer to string returned to MySQL
+ uint32 constraintSpaceLength;// Length of space passed to DB2
+ ValidatedPointer<char> constraintSpace; // Space pointer passed to DB2
+ uint32 neededLen; // Length returned from DB2
+ uint32 cstCnt; // Number of foreign key constraints from DB2
+ uint32 fld; //
+ constraint_hdr* cstHdr; // Pointer to constraint header structure
+ FK_constraint* FKCstDef; // Pointer to constraint definition structure
+ cst_name* fieldName; // Pointer to field name structure
+ char* tempPtr; // Temp pointer for traversing constraint space
+ char convName[128];
+
+ /* Allocate space to retrieve the DB2 constraint information. */
+
+ if (!(share = get_share(table_share->path.str, table)))
+ DBUG_RETURN(NULL);
+
+ constraintSpaceLength = 5000; // Try allocating 5000 bytes and see if enough.
+
+ initBridge();
+
+ constraintSpace.alloc(constraintSpaceLength);
+ rc = bridge()->expectErrors(QMY_ERR_NEED_MORE_SPACE)
+ ->constraints(db2Table->dataFile()->getMasterDefnHandle(),
+ constraintSpace,
+ constraintSpaceLength,
+ &neededLen,
+ &cstCnt);
+
+ if (unlikely(rc == QMY_ERR_NEED_MORE_SPACE))
+ {
+ constraintSpaceLength = neededLen; // Get length of space that's needed
+ constraintSpace.realloc(constraintSpaceLength);
+ rc = bridge()->expectErrors(QMY_ERR_NEED_MORE_SPACE)
+ ->constraints(db2Table->dataFile()->getMasterDefnHandle(),
+ constraintSpace,
+ constraintSpaceLength,
+ &neededLen,
+ &cstCnt);
+ }
+
+ /* If constraint information was returned by DB2, build a text string */
+ /* to return to MySQL. */
+
+ if ((rc == 0) && (cstCnt > 0))
+ {
+ THD* thd = ha_thd();
+ infoBuffer = (char*) my_malloc(MAX_FOREIGN_LEN + 1, MYF(MY_WME));
+ if (infoBuffer == NULL)
+ {
+ free_share(share);
+ DBUG_RETURN(NULL);
+ }
+
+ SafeString info(infoBuffer, MAX_FOREIGN_LEN + 1);
+
+ /* Loop through the DB2 constraints and build a text string for each foreign */
+ /* key constraint that is found. */
+
+ tempPtr = constraintSpace;
+ cstHdr = (constraint_hdr_t*)(void*)constraintSpace; // Address first constraint definition
+ for (int i = 0; i < cstCnt && !info.overflowed(); ++i)
+ {
+ if (cstHdr->CstType[0] == QMY_CST_FK) // If this is a foreign key constraint
+ {
+ tempPtr = (char*)(tempPtr + cstHdr->CstDefOff);
+ FKCstDef = (FK_constraint_t*)tempPtr;
+
+ /* Process the constraint name. */
+
+ info.strncat(STRING_WITH_LEN(" CONSTRAINT "));
+ convNameForCreateInfo(thd, info,
+ FKCstDef->CstName.Name, FKCstDef->CstName.Len);
+
+ /* Process the names of the foreign keys. */
+
+ info.strncat(STRING_WITH_LEN(" FOREIGN KEY ("));
+ tempPtr = (char*)(tempPtr + FKCstDef->KeyColOff);
+ fieldName= (cst_name_t*)tempPtr;
+ for (fld = 0; fld < FKCstDef->KeyCnt; ++fld)
+ {
+ convNameForCreateInfo(thd, info, fieldName->Name, fieldName->Len);
+ if ((fld + 1) < FKCstDef->KeyCnt)
+ {
+ info.strncat(STRING_WITH_LEN(", "));
+ fieldName = fieldName + 1;
+ }
+ }
+
+ /* Process the schema-name and name of the referenced table. */
+
+ info.strncat(STRING_WITH_LEN(") REFERENCES "));
+ convNameForCreateInfo(thd, info,
+ FKCstDef->RefSchema.Name, FKCstDef->RefSchema.Len);
+ info.strcat('.');
+ convNameForCreateInfo(thd, info,
+ FKCstDef->RefTable.Name, FKCstDef->RefTable.Len);
+ info.strncat(STRING_WITH_LEN(" ("));
+
+ /* Process the names of the referenced keys. */
+
+ tempPtr = (char*)FKCstDef;
+ tempPtr = (char*)(tempPtr + FKCstDef->RefColOff);
+ fieldName= (cst_name_t*)tempPtr;
+ for (fld = 0; fld < FKCstDef->RefCnt; ++fld)
+ {
+ convNameForCreateInfo(thd, info, fieldName->Name, fieldName->Len);
+ if ((fld + 1) < FKCstDef->RefCnt)
+ {
+ info.strncat(STRING_WITH_LEN(", "));
+ fieldName = fieldName + 1;
+ }
+ }
+
+ /* Process the ON UPDATE and ON DELETE rules. */
+
+ info.strncat(STRING_WITH_LEN(") ON UPDATE "));
+ switch(FKCstDef->UpdMethod)
+ {
+ case QMY_NOACTION: info.strncat(STRING_WITH_LEN("NO ACTION")); break;
+ case QMY_RESTRICT: info.strncat(STRING_WITH_LEN("RESTRICT")); break;
+ default: break;
+ }
+ info.strncat(STRING_WITH_LEN(" ON DELETE "));
+ switch(FKCstDef->DltMethod)
+ {
+ case QMY_CASCADE: info.strncat(STRING_WITH_LEN("CASCADE")); break;
+ case QMY_SETDFT: info.strncat(STRING_WITH_LEN("SET DEFAULT")); break;
+ case QMY_SETNULL: info.strncat(STRING_WITH_LEN("SET NULL")); break;
+ case QMY_NOACTION: info.strncat(STRING_WITH_LEN("NO ACTION")); break;
+ case QMY_RESTRICT: info.strncat(STRING_WITH_LEN("RESTRICT")); break;
+ default: break;
+ }
+ }
+
+ /* Address the next constraint, if any. */
+
+ if ((i+1) < cstCnt)
+ {
+ info.strcat(',');
+ tempPtr = (char*)cstHdr + cstHdr->CstLen;
+ cstHdr = (constraint_hdr_t*)(tempPtr);
+ }
+ }
+ }
+
+ /* Cleanup and return */
+ free_share(share);
+
+ DBUG_RETURN(infoBuffer);
+}
+
+/***********************************************************************
+Free the foreign key create info (for a table) that was acquired by the
+get_foreign_key_create_info() method.
+***********************************************************************/
+
+void ha_ibmdb2i::free_foreign_key_create_info(char* info)
+{
+ DBUG_ENTER("ha_ibmdb2i::free_foreign_key_create_info");
+
+ if (info)
+ {
+ my_free(info, MYF(0));
+ }
+ DBUG_VOID_RETURN;
+}
+
+/***********************************************************************
+This method returns to MySQL a list, with one entry in the list describing
+each foreign key constraint.
+***********************************************************************/
+
+int ha_ibmdb2i::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
+{
+ DBUG_ENTER("ha_ibmdb2i::get_foreign_key_list");
+ int rc = 0;
+ uint32 constraintSpaceLength; // Length of space passed to DB2
+ ValidatedPointer<char> constraintSpace; // Space pointer passed to DB2
+ uint16 rtnCode; // Return code from DB2
+ uint32 neededLen; // Bytes needed to contain DB2 constraint info
+ uint32 cstCnt; // Number of constraints returned by DB2
+ uint32 fld;
+ constraint_hdr* cstHdr; // Pointer to a cst header structure
+ FK_constraint* FKCstDef; // Pointer to definition of foreign key constraint
+ cst_name* fieldName; // Pointer to field name structure
+ const char *method;
+ ulong methodLen;
+ char* tempPtr; // Temp pointer for traversing constraint space
+ char convName[128];
+
+ if (!(share = get_share(table_share->path.str, table)))
+ DBUG_RETURN(0);
+
+ // Allocate space to retrieve the DB2 constraint information.
+ constraintSpaceLength = 5000; // Try allocating 5000 bytes and see if enough.
+
+ constraintSpace.alloc(constraintSpaceLength);
+ rc = bridge()->expectErrors(QMY_ERR_NEED_MORE_SPACE)
+ ->constraints(db2Table->dataFile()->getMasterDefnHandle(),
+ constraintSpace,
+ constraintSpaceLength,
+ &neededLen,
+ &cstCnt);
+
+ if (unlikely(rc == QMY_ERR_NEED_MORE_SPACE))
+ {
+ constraintSpaceLength = neededLen; // Get length of space that's needed
+ constraintSpace.realloc(constraintSpaceLength);
+ rc = bridge()->expectErrors(QMY_ERR_NEED_MORE_SPACE)
+ ->constraints(db2Table->dataFile()->getMasterDefnHandle(),
+ constraintSpace,
+ constraintSpaceLength,
+ &neededLen,
+ &cstCnt);
+ }
+
+ /* If constraint information was returned by DB2, build a text string */
+ /* to return to MySQL. */
+ if ((rc == 0) && (cstCnt > 0))
+ {
+ tempPtr = constraintSpace;
+ cstHdr = (constraint_hdr_t*)(void*)constraintSpace; // Address first constraint definition
+ for (int i = 0; i < cstCnt; ++i)
+ {
+ if (cstHdr->CstType[0] == QMY_CST_FK) // If this is a foreign key constraint
+ {
+ FOREIGN_KEY_INFO f_key_info;
+ LEX_STRING *name= 0;
+ tempPtr = (char*)(tempPtr + cstHdr->CstDefOff);
+ FKCstDef = (FK_constraint_t*)tempPtr;
+
+ /* Process the constraint name. */
+
+ convFromEbcdic(FKCstDef->CstName.Name, convName,FKCstDef->CstName.Len);
+ if (convName[0] == '"') // If quoted, exclude quotes.
+ f_key_info.forein_id = thd_make_lex_string(thd, 0,
+ convName + 1, (uint) (FKCstDef->CstName.Len - 2), 1);
+ else // Not quoted
+ f_key_info.forein_id = thd_make_lex_string(thd, 0,
+ convName, (uint) FKCstDef->CstName.Len, 1);
+
+ /* Process the names of the foreign keys. */
+
+
+ tempPtr = (char*)(tempPtr + FKCstDef->KeyColOff);
+ fieldName = (cst_name_t*)tempPtr;
+ for (fld = 0; fld < FKCstDef->KeyCnt; ++fld)
+ {
+ convFromEbcdic(fieldName->Name, convName, fieldName->Len);
+ if (convName[0] == '"') // If quoted, exclude quotes.
+ name = thd_make_lex_string(thd, name,
+ convName + 1, (uint) (fieldName->Len - 2), 1);
+ else
+ name = thd_make_lex_string(thd, name, convName, (uint) fieldName->Len, 1);
+ f_key_info.foreign_fields.push_back(name);
+ if ((fld + 1) < FKCstDef->KeyCnt)
+ fieldName = fieldName + 1;
+ }
+
+ /* Process the schema and name of the referenced table. */
+
+ convFromEbcdic(FKCstDef->RefSchema.Name, convName, FKCstDef->RefSchema.Len);
+ if (convName[0] == '"') // If quoted, exclude quotes.
+ f_key_info.referenced_db = thd_make_lex_string(thd, 0,
+ convName + 1, (uint) (FKCstDef->RefSchema.Len -2), 1);
+ else
+ f_key_info.referenced_db = thd_make_lex_string(thd, 0,
+ convName, (uint) FKCstDef->RefSchema.Len, 1);
+ convFromEbcdic(FKCstDef->RefTable.Name, convName, FKCstDef->RefTable.Len);
+ if (convName[0] == '"') // If quoted, exclude quotes.
+ f_key_info.referenced_table = thd_make_lex_string(thd, 0,
+ convName +1, (uint) (FKCstDef->RefTable.Len -2), 1);
+ else
+ f_key_info.referenced_table = thd_make_lex_string(thd, 0,
+ convName, (uint) FKCstDef->RefTable.Len, 1);
+
+ /* Process the names of the referenced keys. */
+
+ tempPtr = (char*)FKCstDef;
+ tempPtr = (char*)(tempPtr + FKCstDef->RefColOff);
+ fieldName= (cst_name_t*)tempPtr;
+ for (fld = 0; fld < FKCstDef->RefCnt; ++fld)
+ {
+ convFromEbcdic(fieldName->Name, convName, fieldName->Len);
+ if (convName[0] == '"') // If quoted, exclude quotes.
+ name = thd_make_lex_string(thd, name,
+ convName + 1, (uint) (fieldName->Len -2), 1);
+ else
+ name = thd_make_lex_string(thd, name, convName, (uint) fieldName->Len, 1);
+ f_key_info.referenced_fields.push_back(name);
+ if ((fld + 1) < FKCstDef->RefCnt)
+ fieldName = fieldName + 1;
+ }
+
+ /* Process the ON UPDATE and ON DELETE rules. */
+
+ switch(FKCstDef->UpdMethod)
+ {
+ case QMY_NOACTION:
+ {
+ method = "NO ACTION";
+ methodLen=9;
+ }
+ break;
+ case QMY_RESTRICT:
+ {
+ method = "RESTRICT";
+ methodLen = 8;
+ }
+ break;
+ default: break;
+ }
+ f_key_info.update_method = thd_make_lex_string(
+ thd, f_key_info.update_method, method, methodLen, 1);
+ switch(FKCstDef->DltMethod)
+ {
+ case QMY_CASCADE:
+ {
+ method = "CASCADE";
+ methodLen = 7;
+ }
+ break;
+ case QMY_SETDFT:
+ {
+ method = "SET DEFAULT";
+ methodLen = 11;
+ }
+ break;
+ case QMY_SETNULL:
+ {
+ method = "SET NULL";
+ methodLen = 8;
+ }
+ break;
+ case QMY_NOACTION:
+ {
+ method = "NO ACTION";
+ methodLen = 9;
+ }
+ break;
+ case QMY_RESTRICT:
+ {
+ method = "RESTRICT";
+ methodLen = 8;
+ }
+ break;
+ default: break;
+ }
+ f_key_info.delete_method = thd_make_lex_string(
+ thd, f_key_info.delete_method, method, methodLen, 1);
+ f_key_info.referenced_key_name= thd_make_lex_string(thd, 0, (char *)"", 1, 1);
+ FOREIGN_KEY_INFO *pf_key_info = (FOREIGN_KEY_INFO *)
+ thd_memdup(thd, &f_key_info, sizeof(FOREIGN_KEY_INFO));
+ f_key_list->push_back(pf_key_info);
+ }
+
+ /* Address the next constraint, if any. */
+
+ if ((i+1) < cstCnt)
+ {
+ tempPtr = (char*)cstHdr + cstHdr->CstLen;
+ cstHdr = (constraint_hdr_t*)(tempPtr);
+ }
+ }
+ }
+
+ /* Cleanup and return. */
+
+ free_share(share);
+ DBUG_RETURN(0);
+}
+
+/***********************************************************************
+Checks if the table is referenced by a foreign key.
+Returns: 0 if not referenced (or error occurs),
+ > 0 if is referenced
+***********************************************************************/
+
+uint ha_ibmdb2i::referenced_by_foreign_key(void)
+{
+ DBUG_ENTER("ha_ibmdb2i::referenced_by_foreign_key");
+
+ int rc = 0;
+ FILE_HANDLE queryFile = 0;
+ uint32 resultRowLen;
+ uint32 count = 0;
+
+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
+
+ String query(128);
+ query.append(STRING_WITH_LEN(" SELECT COUNT(*) FROM SYSIBM.SQLFOREIGNKEYS WHERE PKTABLE_SCHEM = '"));
+ query.append(libName+1, strlen(libName)-2); // parent library name
+ query.append(STRING_WITH_LEN("' AND PKTABLE_NAME = '"));
+ query.append(fileName+1, strlen(fileName)-2); // parent file name
+ query.append(STRING_WITH_LEN("'"));
+
+ SqlStatementStream sqlStream(query);
+
+ rc = bridge()->prepOpen(sqlStream.getPtrToData(),
+ &queryFile,
+ &resultRowLen);
+ if (rc == 0)
+ {
+ IOReadBuffer rowBuffer(1, resultRowLen);
+ rc = bridge()->read(queryFile, rowBuffer.ptr(), QMY_READ_ONLY, QMY_NONE, QMY_FIRST);
+ if (!rc) count = *((uint32*)rowBuffer.getRowN(0));
+ bridge()->deallocateFile(queryFile);
+ }
+ DBUG_RETURN(count);
+}
+
+
+bool ha_ibmdb2i::check_if_incompatible_data(HA_CREATE_INFO *info,
+ uint table_changes)
+{
+ DBUG_ENTER("ha_ibmdb2i::check_if_incompatible_data");
+ uint i;
+ /* Check that auto_increment value and field definitions were
+ not changed. */
+ if ((info->used_fields & HA_CREATE_USED_AUTO &&
+ info->auto_increment_value != 0) ||
+ table_changes != IS_EQUAL_YES)
+ DBUG_RETURN(COMPATIBLE_DATA_NO);
+ /* Check if any fields were renamed. */
+ for (i= 0; i < table->s->fields; i++)
+ {
+ Field *field= table->field[i];
+ if (field->flags & FIELD_IS_RENAMED)
+ {
+ DBUG_PRINT("info", ("Field has been renamed, copy table"));
+ DBUG_RETURN(COMPATIBLE_DATA_NO);
+ }
+ }
+ DBUG_RETURN(COMPATIBLE_DATA_YES);
+}
diff --git a/storage/ibmdb2i/db2i_conversion.cc b/storage/ibmdb2i/db2i_conversion.cc
new file mode 100644
index 00000000000..f746be6ab50
--- /dev/null
+++ b/storage/ibmdb2i/db2i_conversion.cc
@@ -0,0 +1,1446 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+
+#include "db2i_ileBridge.h"
+#include "mysql_priv.h"
+#include "db2i_charsetSupport.h"
+#include "ctype.h"
+#include "ha_ibmdb2i.h"
+#include "db2i_errors.h"
+#include "wchar.h"
+
+const char ZERO_DATETIME_VALUE[] = "0000-00-00 00:00:00";
+const char ZERO_DATETIME_VALUE_SUBST[] = "0001-01-01 00:00:00";
+const char ZERO_DATE_VALUE[] = "0000-00-00";
+const char ZERO_DATE_VALUE_SUBST[] = "0001-01-01";
+
+
+/**
+ Put a BCD digit into a BCD string.
+
+ @param[out] bcdString The BCD string to be modified
+ @param pos The position within the string to be updated.
+ @param val The value to be assigned into the string at pos.
+*/
+static inline void bcdAssign(char* bcdString, uint pos, uint val)
+{
+ bcdString[pos/2] |= val << ((pos % 2) ? 0 : 4);
+}
+
+/**
+ Read a BCD digit from a BCD string.
+
+ @param[out] bcdString The BCD string to be read
+ @param pos The position within the string to be read.
+
+ @return bcdGet The value of the BCD digit at pos.
+*/
+static inline uint bcdGet(const char* bcdString, uint pos)
+{
+ return (bcdString[pos/2] >> ((pos % 2) ? 0 : 4)) & 0xf;
+}
+
+/**
+ In-place convert a number in ASCII represenation to EBCDIC representation.
+
+ @param string The string of ASCII characters
+ @param len The length of string
+*/
+static inline void convertNumericToEbcdicFast(char* string, int len)
+{
+ for (int i = 0; i < len; ++i, ++string)
+ {
+ switch(*string)
+ {
+ case '-':
+ *string = 0x60; break;
+ case ':':
+ *string = 0x7A; break;
+ case '.':
+ *string = 0x4B; break;
+ default:
+ DBUG_ASSERT(isdigit(*string));
+ *string += 0xF0 - '0';
+ break;
+ }
+ }
+}
+
+
+/**
+ atoi()-like function for a 4-character EBCDIC string.
+
+ @param string The EBCDIC string
+ @return a4toi_ebcdic The decimal value of the EBCDIC string
+*/
+static inline uint16 a4toi_ebcdic(const uchar* string)
+{
+ return ((string[0]-0xF0) * 1000 +
+ (string[1]-0xF0) * 100 +
+ (string[2]-0xF0) * 10 +
+ (string[3]-0xF0));
+};
+
+
+/**
+ atoi()-like function for a 4-character EBCDIC string.
+
+ @param string The EBCDIC string
+ @return a4toi_ebcdic The decimal value of the EBCDIC string
+*/
+static inline uint8 a2toi_ebcdic(const uchar* string)
+{
+ return ((string[0]-0xF0) * 10 +
+ (string[1]-0xF0));
+};
+
+/**
+ Perform character conversion for textual field data.
+*/
+int ha_ibmdb2i::convertFieldChars(enum_conversionDirection direction,
+ uint16 fieldID,
+ const char* input,
+ char* output,
+ size_t ilen,
+ size_t olen,
+ size_t* outDataLen)
+{
+ DBUG_PRINT("ha_ibmdb2i::convertFieldChars",("Direction: %d; length = %d", direction, ilen));
+
+ if (unlikely(ilen == 0))
+ {
+ if (outDataLen) *outDataLen = 0;
+ return (0);
+ }
+
+ iconv_t& conversion = db2Table->getConversionDefinition(direction, fieldID);
+
+ if (unlikely(conversion == (iconv_t)(-1)))
+ {
+ return (DB2I_ERR_ICONV_OPEN);
+ }
+
+ size_t initOLen= olen;
+ size_t substitutedChars = 0;
+ int rc = iconv(conversion, (char**)&input, &ilen, &output, &olen, &substitutedChars );
+ if (unlikely(rc < 0))
+ {
+ int er = errno;
+ if (er == EILSEQ)
+ {
+ getErrTxt(DB2I_ERR_ILL_CHAR, table->field[fieldID]->field_name);
+ return (DB2I_ERR_ILL_CHAR);
+ }
+ else
+ {
+ getErrTxt(DB2I_ERR_ICONV,er);
+ return (DB2I_ERR_ICONV);
+ }
+ }
+ if (unlikely(substitutedChars))
+ {
+ warning(ha_thd(), DB2I_ERR_SUB_CHARS, table->field[fieldID]->field_name);
+ }
+
+ if (outDataLen) *outDataLen = initOLen - olen;
+
+ return (0);
+}
+
+/**
+ Append the appropriate default value clause onto a CREATE TABLE definition
+
+ This was inspired by get_field_default_value in sql/sql_show.cc.
+
+ @param field The field whose value is to be obtained
+ @param statement The string to receive the DEFAULT clause
+ @param quoteIt Does the data type require single quotes around the value?
+ @param ccsid The ccsid of the field value (if a string type); 0 if no conversion needed
+*/
+static void get_field_default_value(Field *field,
+ String &statement,
+ bool quoteIt,
+ uint32 ccsid,
+ bool substituteZeroDates)
+{
+ if ((field->type() != FIELD_TYPE_BLOB &&
+ !(field->flags & NO_DEFAULT_VALUE_FLAG) &&
+ field->unireg_check != Field::NEXT_NUMBER))
+ {
+ my_ptrdiff_t old_ptr= (my_ptrdiff_t) (field->table->s->default_values - field->table->record[0]);
+ field->move_field_offset(old_ptr);
+
+ String defaultClause(64);
+ defaultClause.length(0);
+ defaultClause.append(" DEFAULT ");
+ if (!field->is_null())
+ {
+ my_bitmap_map *old_map = tmp_use_all_columns(field->table, field->table->read_set);
+ char tmp[MAX_FIELD_WIDTH];
+
+ if (field->real_type() == MYSQL_TYPE_ENUM ||
+ field->real_type() == MYSQL_TYPE_SET)
+ {
+ CHARSET_INFO *cs= &my_charset_bin;
+ uint len = (uint)(cs->cset->longlong10_to_str)(cs,tmp,sizeof(tmp), 10, field->val_int());
+ tmp[len]=0;
+ defaultClause.append(tmp);
+ }
+ else
+ {
+ String type(tmp, sizeof(tmp), field->charset());
+ field->val_str(&type);
+ if (type.length())
+ {
+ if (field->type() == MYSQL_TYPE_DATE &&
+ memcmp(type.ptr(), STRING_WITH_LEN(ZERO_DATE_VALUE)) == 0)
+ {
+ if (substituteZeroDates)
+ type.set(STRING_WITH_LEN(ZERO_DATE_VALUE_SUBST), field->charset());
+ else
+ {
+ warning(current_thd, DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ return;
+ }
+ }
+ else if ((field->type() == MYSQL_TYPE_DATETIME ||
+ field->type() == MYSQL_TYPE_TIMESTAMP) &&
+ memcmp(type.ptr(), STRING_WITH_LEN(ZERO_DATETIME_VALUE)) == 0)
+ {
+ if (substituteZeroDates)
+ type.set(STRING_WITH_LEN(ZERO_DATETIME_VALUE_SUBST), field->charset());
+ else
+ {
+ warning(current_thd, DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ return;
+ }
+ }
+
+
+ if (field->type() != MYSQL_TYPE_STRING &&
+ field->type() != MYSQL_TYPE_VARCHAR &&
+ field->type() != MYSQL_TYPE_BLOB &&
+ field->type() != MYSQL_TYPE_BIT)
+ {
+ if (quoteIt)
+ defaultClause.append('\'');
+ defaultClause.append(type);
+ if (quoteIt)
+ defaultClause.append('\'');
+ }
+ else
+ {
+ int length;
+ char* out;
+
+ // If a ccsid is specified, we need to make sure that the DEFAULT
+ // string is converted to that encoding.
+ if (ccsid != 0)
+ {
+ iconv_t iconvD;
+ if (getConversion(toDB2, field->charset(), ccsid, iconvD))
+ {
+ warning(current_thd, DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ return;
+ }
+
+ size_t ilen = type.length();
+ size_t olen = 6 * ilen;
+ size_t origOlen = olen;
+ const char* in = type.ptr();
+ const char* tempIn = in;
+ out = (char*)my_malloc(olen, MYF(MY_WME));
+ char* tempOut = out;
+ size_t substitutedChars;
+
+ if (iconv(iconvD, (char**)&tempIn, &ilen, &tempOut, &olen, &substitutedChars) < 0)
+ {
+ warning(current_thd, DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ my_free(out, MYF(0));
+ return;
+ }
+ // Now we process the converted string to represent it as
+ // hexadecimal values.
+
+ length = origOlen - olen;
+ }
+ else
+ {
+ length = type.length();
+ out = (char*)my_malloc(length*2, MYF(MY_WME));
+ memcpy(out, (char*)type.ptr(), length);
+ }
+
+ if (length > 16370)
+ {
+ warning(current_thd, DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ my_free(out, MYF(0));
+ return;
+ }
+
+ if (ccsid == 1200)
+ defaultClause.append("ux'");
+ else if (ccsid == 13488)
+ defaultClause.append("gx'");
+ else if (field->charset() == &my_charset_bin)
+ defaultClause.append("binary(x'");
+ else
+ defaultClause.append("x'");
+
+ const char hexMap[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+ for (int c = length-1; c >= 0; --c)
+ {
+ out[c*2+1] = hexMap[out[c] & 0xF];
+ out[c*2] = hexMap[out[c] >> 4];
+ }
+
+ defaultClause.append(out, length*2);
+ defaultClause.append('\'');
+ if (field->charset() == &my_charset_bin)
+ defaultClause.append(")");
+
+ my_free(out, MYF(0));
+ }
+ }
+ else
+ defaultClause.length(0);
+ }
+ tmp_restore_column_map(field->table->read_set, old_map);
+ }
+ else if (field->maybe_null())
+ defaultClause.append(STRING_WITH_LEN("NULL"));
+
+ if (old_ptr)
+ field->move_field_offset(-old_ptr);
+
+ statement.append(defaultClause);
+ }
+}
+
+
+
+
+/**
+ Convert a MySQL field definition into its corresponding DB2 type.
+
+ The result will be appended to mapping as a DB2 SQL phrase.
+
+ @param field The MySQL field to be evaluated
+ @param[out] mapping The receiver for the DB2 SQL syntax
+ @param timeFormat The format to be used for mapping the TIME type
+*/
+int ha_ibmdb2i::getFieldTypeMapping(Field* field,
+ String& mapping,
+ enum_TimeFormat timeFormat,
+ enum_BlobMapping blobMapping,
+ enum_ZeroDate zeroDateHandling,
+ bool propagateDefaults,
+ enum_YearFormat yearFormat)
+{
+ char stringBuildBuffer[257];
+ uint32 fieldLength;
+ bool defaultNeedsQuotes = false;
+ uint16 db2Ccsid = 0;
+
+ CHARSET_INFO* fieldCharSet = field->charset();
+ switch (field->type())
+ {
+ case MYSQL_TYPE_NEWDECIMAL:
+ {
+ uint precision= ((Field_new_decimal*)field)->precision;
+ uint scale= field->decimals();
+
+ if (precision <= MAX_DEC_PRECISION)
+ {
+ sprintf(stringBuildBuffer,"DECIMAL(%d, %d)",precision,scale);
+ }
+ else
+ {
+ if (scale > precision - MAX_DEC_PRECISION)
+ {
+ scale = scale - (precision - MAX_DEC_PRECISION);
+ precision = MAX_DEC_PRECISION;
+ sprintf(stringBuildBuffer,"DECIMAL(%d, %d)",precision,scale);
+ }
+ else
+ {
+ return HA_ERR_UNSUPPORTED;
+ }
+ warning(ha_thd(), DB2I_ERR_PRECISION);
+ }
+
+ mapping.append(stringBuildBuffer);
+ }
+ break;
+ case MYSQL_TYPE_TINY:
+ mapping.append(STRING_WITH_LEN("SMALLINT"));
+ break;
+ case MYSQL_TYPE_SHORT:
+ if (((Field_num*)field)->unsigned_flag)
+ mapping.append(STRING_WITH_LEN("INT"));
+ else
+ mapping.append(STRING_WITH_LEN("SMALLINT"));
+ break;
+ case MYSQL_TYPE_LONG:
+ if (((Field_num*)field)->unsigned_flag)
+ mapping.append(STRING_WITH_LEN("BIGINT"));
+ else
+ mapping.append(STRING_WITH_LEN("INT"));
+ break;
+ case MYSQL_TYPE_FLOAT:
+ mapping.append(STRING_WITH_LEN("REAL"));
+ break;
+ case MYSQL_TYPE_DOUBLE:
+ mapping.append(STRING_WITH_LEN("DOUBLE"));
+ break;
+ case MYSQL_TYPE_LONGLONG:
+ if (((Field_num*)field)->unsigned_flag)
+ mapping.append(STRING_WITH_LEN("DECIMAL(20,0)"));
+ else
+ mapping.append(STRING_WITH_LEN("BIGINT"));
+ break;
+ case MYSQL_TYPE_INT24:
+ mapping.append(STRING_WITH_LEN("INTEGER"));
+ break;
+ case MYSQL_TYPE_DATE:
+ case MYSQL_TYPE_NEWDATE:
+ mapping.append(STRING_WITH_LEN("DATE"));
+ defaultNeedsQuotes = true;
+ break;
+ case MYSQL_TYPE_TIME:
+ if (timeFormat == TIME_OF_DAY)
+ {
+ mapping.append(STRING_WITH_LEN("TIME"));
+ defaultNeedsQuotes = true;
+ }
+ else
+ mapping.append(STRING_WITH_LEN("INTEGER"));
+ break;
+ case MYSQL_TYPE_DATETIME:
+ mapping.append(STRING_WITH_LEN("TIMESTAMP"));
+ defaultNeedsQuotes = true;
+ break;
+ case MYSQL_TYPE_TIMESTAMP:
+ mapping.append(STRING_WITH_LEN("TIMESTAMP"));
+
+ if (table_share->timestamp_field == field && propagateDefaults)
+ {
+ switch (((Field_timestamp*)field)->get_auto_set_type())
+ {
+ case TIMESTAMP_NO_AUTO_SET:
+ break;
+ case TIMESTAMP_AUTO_SET_ON_INSERT:
+ mapping.append(STRING_WITH_LEN(" DEFAULT CURRENT_TIMESTAMP"));
+ break;
+ case TIMESTAMP_AUTO_SET_ON_UPDATE:
+ if (osVersion.v >= 6 &&
+ !field->is_null())
+ {
+ mapping.append(STRING_WITH_LEN(" GENERATED BY DEFAULT FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP"));
+ warning(ha_thd(), DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ }
+ else
+ warning(ha_thd(), DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ break;
+ case TIMESTAMP_AUTO_SET_ON_BOTH:
+ if (osVersion.v >= 6 &&
+ !field->is_null())
+ mapping.append(STRING_WITH_LEN(" GENERATED BY DEFAULT FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP"));
+ else
+ {
+ mapping.append(STRING_WITH_LEN(" DEFAULT CURRENT_TIMESTAMP"));
+ warning(ha_thd(), DB2I_ERR_WARN_COL_ATTRS, field->field_name);
+ }
+ break;
+ }
+ }
+ else
+ defaultNeedsQuotes = true;
+ break;
+ case MYSQL_TYPE_YEAR:
+ if (yearFormat == CHAR4)
+ {
+ mapping.append(STRING_WITH_LEN("CHAR(4) CCSID 1208"));
+ defaultNeedsQuotes = true;
+ }
+ else
+ {
+ mapping.append(STRING_WITH_LEN("SMALLINT"));
+ defaultNeedsQuotes = false;
+ }
+ break;
+ case MYSQL_TYPE_BIT:
+ sprintf(stringBuildBuffer, "BINARY(%d)", (field->max_display_length() / 8) + 1);
+ mapping.append(stringBuildBuffer);
+ break;
+ case MYSQL_TYPE_BLOB:
+ case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_STRING:
+ {
+ if (field->real_type() == MYSQL_TYPE_ENUM ||
+ field->real_type() == MYSQL_TYPE_SET)
+ {
+ mapping.append(STRING_WITH_LEN("BIGINT"));
+ }
+ else
+ {
+ defaultNeedsQuotes = true;
+
+ fieldLength = field->max_display_length(); // Get field byte length
+
+ if (fieldCharSet == &my_charset_bin)
+ {
+ if (field->type() == MYSQL_TYPE_STRING)
+ {
+ sprintf(stringBuildBuffer, "BINARY(%d)", max(fieldLength, 1));
+ }
+ else
+ {
+ if (fieldLength <= MAX_VARCHAR_LENGTH)
+ {
+ sprintf(stringBuildBuffer, "VARBINARY(%d)", max(fieldLength, 1));
+ }
+ else if (blobMapping == AS_VARCHAR &&
+ (field->flags & PART_KEY_FLAG))
+ {
+ sprintf(stringBuildBuffer, "LONG VARBINARY ");
+ }
+ else
+ {
+ fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
+ sprintf(stringBuildBuffer, "BLOB(%d)", max(fieldLength, 1));
+ }
+ }
+ mapping.append(stringBuildBuffer);
+ }
+ else
+ {
+ if (field->type() == MYSQL_TYPE_STRING)
+ {
+ if (fieldLength > MAX_CHAR_LENGTH)
+ return 1;
+ if (fieldCharSet->mbmaxlen > 1)
+ {
+ if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ {
+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
+ db2Ccsid = 13488;
+ }
+ else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
+ {
+ sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1)); // Number of bytes
+ db2Ccsid = 1208;
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "GRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
+ db2Ccsid = 1200;
+ }
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "CHAR(%d)", max(fieldLength, 1));
+ }
+ mapping.append(stringBuildBuffer);
+ }
+ else
+ {
+ if (fieldLength <= MAX_VARCHAR_LENGTH)
+ {
+ if (fieldCharSet->mbmaxlen > 1)
+ {
+ if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ {
+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
+ db2Ccsid = 13488;
+ }
+ else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
+ {
+ sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1)); // Number of bytes
+ db2Ccsid = 1208;
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "VARGRAPHIC(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
+ db2Ccsid = 1200;
+ }
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "VARCHAR(%d)", max(fieldLength, 1));
+ }
+ }
+ else if (blobMapping == AS_VARCHAR &&
+ (field->flags & PART_KEY_FLAG))
+ {
+ if (fieldCharSet->mbmaxlen > 1)
+ {
+ if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ {
+ sprintf(stringBuildBuffer, "LONG VARGRAPHIC ");
+ db2Ccsid = 13488;
+ }
+ else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
+ {
+ sprintf(stringBuildBuffer, "LONG VARCHAR ");
+ db2Ccsid = 1208;
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "LONG VARGRAPHIC ");
+ db2Ccsid = 1200;
+ }
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "LONG VARCHAR ");
+ }
+ }
+ else
+ {
+ fieldLength = min(MAX_BLOB_LENGTH, fieldLength);
+
+ if (fieldCharSet->mbmaxlen > 1)
+ {
+ if (strncmp(fieldCharSet->name, "ucs2_", sizeof("ucs2_")) == 0 ) // UCS2
+ {
+ sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
+ db2Ccsid = 13488;
+ }
+ else if (strncmp(fieldCharSet->name, "utf8_", sizeof("utf8_")) == 0 &&
+ strcmp(fieldCharSet->name, "utf8_general_ci") != 0)
+ {
+ sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of bytes
+ db2Ccsid = 1208;
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "DBCLOB(%d)", max(fieldLength / fieldCharSet->mbmaxlen, 1)); // Number of characters
+ db2Ccsid = 1200;
+ }
+ }
+ else
+ {
+ sprintf(stringBuildBuffer, "CLOB(%d)", max(fieldLength, 1)); // Number of characters
+ }
+ }
+
+ mapping.append(stringBuildBuffer);
+ }
+ if (db2Ccsid == 0) // If not overriding CCSID
+ {
+ int32 rtnCode = convertIANAToDb2Ccsid(fieldCharSet->csname, &db2Ccsid);
+ if (rtnCode)
+ return rtnCode;
+ }
+ sprintf(stringBuildBuffer, " CCSID %d ", db2Ccsid);
+ mapping.append(stringBuildBuffer);
+ }
+ }
+ }
+ break;
+
+ }
+
+ if (propagateDefaults)
+ get_field_default_value(field,
+ mapping,
+ defaultNeedsQuotes,
+ db2Ccsid,
+ (zeroDateHandling==SUBSTITUTE_0001_01_01));
+
+ return 0;
+}
+
+
+/**
+ Convert MySQL field data into the equivalent DB2 format
+
+ @param field The MySQL field to be converted
+ @param db2Field The corresponding DB2 field definition
+ @param db2Buf The buffer to receive the converted data
+ @param data NULL if field points to the correct data; otherwise,
+ the data to be converted (for use with keys)
+*/
+int32 ha_ibmdb2i::convertMySQLtoDB2(Field* field, const DB2Field& db2Field, char* db2Buf, const uchar* data)
+{
+ enum_field_types fieldType = field->type();
+ switch (fieldType)
+ {
+ case MYSQL_TYPE_NEWDECIMAL:
+ {
+ uint precision= ((Field_new_decimal*)field)->precision;
+ uint scale= field->decimals();
+ uint db2Precision = min(precision, MAX_DEC_PRECISION);
+ uint truncationAmount = precision - db2Precision;
+
+ if (scale >= truncationAmount)
+ {
+ String tempString(precision+2);
+
+ if (data == NULL)
+ {
+ field->val_str((String*)&tempString, (String*)(NULL));
+ }
+ else
+ {
+ field->val_str(&tempString, data);
+ }
+ const char* temp = tempString.ptr();
+ char packed[32];
+ memset(&packed, 0, sizeof(packed));
+
+ int bcdPos = db2Precision - (db2Precision % 2 ? 1 : 0);
+ bcdAssign(packed, bcdPos+1, (temp[0] == '-' ? 0xD : 0xF));
+
+ int strPos=tempString.length() - 1 - truncationAmount;
+
+ for (;strPos >= 0 && bcdPos >= 0; strPos--)
+ {
+ if (my_isdigit(&my_charset_latin1, temp[strPos]))
+ {
+ bcdAssign(packed, bcdPos, temp[strPos]-'0');
+ --bcdPos;
+ }
+ }
+ memcpy(db2Buf, &packed, (db2Precision/2)+1);
+ }
+
+ }
+ break;
+ case MYSQL_TYPE_TINY:
+ {
+ int16 temp = (data == NULL ? field->val_int() : field->val_int(data));
+ memcpy(db2Buf , &temp, sizeof(temp));
+ }
+ break;
+ case MYSQL_TYPE_SHORT:
+ {
+ if (((Field_num*)field)->unsigned_flag)
+ {
+ memset(db2Buf, 0, 2);
+ memcpy(db2Buf+2, (data == NULL ? field->ptr : data), 2);
+ }
+ else
+ {
+ memcpy(db2Buf, (data == NULL ? field->ptr : data), 2);
+ }
+ }
+ break;
+ case MYSQL_TYPE_LONG:
+ {
+ if (((Field_num*)field)->unsigned_flag)
+ {
+ memset(db2Buf, 0, 4);
+ memcpy(db2Buf+4, (data == NULL ? field->ptr : data), 4);
+ }
+ else
+ {
+ memcpy(db2Buf, (data == NULL ? field->ptr : data), 4);
+ }
+ }
+ break;
+ case MYSQL_TYPE_FLOAT:
+ {
+ memcpy(db2Buf, (data == NULL ? field->ptr : data), 4);
+ }
+ break;
+ case MYSQL_TYPE_DOUBLE:
+ {
+ memcpy(db2Buf, (data == NULL ? field->ptr : data), 8);
+ }
+ break;
+ case MYSQL_TYPE_TIMESTAMP:
+ case MYSQL_TYPE_DATETIME:
+ {
+ String tempString(27);
+ if (data == NULL)
+ {
+ field->val_str(&tempString, &tempString);
+ }
+ else
+ {
+ field->val_str(&tempString, data);
+ }
+ memset(db2Buf, '0', 26);
+ memcpy(db2Buf, tempString.ptr(), tempString.length());
+ if (strncmp(db2Buf,ZERO_DATETIME_VALUE,strlen(ZERO_DATETIME_VALUE)) == 0)
+ {
+ if (cachedZeroDateOption == SUBSTITUTE_0001_01_01)
+ memcpy(db2Buf, ZERO_DATETIME_VALUE_SUBST, sizeof(ZERO_DATETIME_VALUE_SUBST));
+ else
+ {
+ getErrTxt(DB2I_ERR_INVALID_COL_VALUE, field->field_name);
+ return(DB2I_ERR_INVALID_COL_VALUE);
+ }
+ }
+ (db2Buf)[10] = '-';
+ (db2Buf)[13] = (db2Buf)[16] = (db2Buf)[19] = '.';
+
+ convertNumericToEbcdicFast(db2Buf, 26);
+ }
+ break;
+ case MYSQL_TYPE_LONGLONG:
+ {
+ if (((Field_num*)field)->unsigned_flag)
+ {
+ char temp[23];
+ String tempString(temp, sizeof(temp), &my_charset_latin1);
+
+ if (data == NULL)
+ {
+ field->val_str((String*)&tempString, (String*)(NULL));
+ }
+ else
+ {
+ field->val_str(&tempString, data);
+ }
+ char packed[11];
+ memset(packed, 0, sizeof(packed));
+ bcdAssign(packed, 21, (temp[0] == '-' ? 0xD : 0xF));
+ int strPos=tempString.length()-1;
+ int bcdPos=20;
+
+ for (;strPos >= 0; strPos--)
+ {
+ if (my_isdigit(&my_charset_latin1, temp[strPos]))
+ {
+ bcdAssign(packed, bcdPos, temp[strPos]-'0');
+ --bcdPos;
+ }
+ }
+ memcpy(db2Buf, &packed, 11);
+ }
+ else
+ {
+ *(uint64*)db2Buf = *(uint64*)(data == NULL ? field->ptr : data);
+ }
+ }
+ break;
+ case MYSQL_TYPE_INT24:
+ {
+ int32 temp= (data == NULL ? field->val_int() : field->val_int(data));
+ memcpy(db2Buf , &temp, sizeof(temp));
+ }
+ break;
+ case MYSQL_TYPE_DATE:
+ case MYSQL_TYPE_NEWDATE:
+ {
+ String tempString(11);
+ if (data == NULL)
+ {
+ field->val_str(&tempString, (String*)NULL);
+ }
+ else
+ {
+ field->val_str(&tempString, data);
+ }
+ memcpy(db2Buf, tempString.ptr(), 10);
+ if (strncmp(db2Buf,ZERO_DATE_VALUE,strlen(ZERO_DATE_VALUE)) == 0)
+ {
+ if (cachedZeroDateOption == SUBSTITUTE_0001_01_01)
+ memcpy(db2Buf, ZERO_DATE_VALUE_SUBST, sizeof(ZERO_DATE_VALUE_SUBST));
+ else
+ {
+ getErrTxt(DB2I_ERR_INVALID_COL_VALUE,field->field_name);
+ return(DB2I_ERR_INVALID_COL_VALUE);
+ }
+ }
+
+ convertNumericToEbcdicFast(db2Buf,10);
+ }
+ break;
+ case MYSQL_TYPE_TIME:
+ {
+ if (db2Field.getType() == QMY_TIME)
+ {
+ String tempString(10);
+ if (data == NULL)
+ {
+ field->val_str(&tempString, (String*)NULL);
+ }
+ else
+ {
+ field->val_str(&tempString, data);
+ }
+ memcpy(db2Buf, tempString.ptr(), 8);
+ (db2Buf)[2]=(db2Buf)[5] = '.';
+
+ convertNumericToEbcdicFast(db2Buf, 8);
+ }
+ else
+ {
+ int32 temp = sint3korr(data == NULL ? field->ptr : data);
+ memcpy(db2Buf, &temp, sizeof(temp));
+ }
+ }
+ break;
+ case MYSQL_TYPE_YEAR:
+ {
+ String tempString(5);
+ if (db2Field.getType() == QMY_CHAR)
+ {
+ if (data == NULL)
+ {
+ field->val_str(&tempString, (String*)NULL);
+ }
+ else
+ {
+ field->val_str(&tempString, data);
+ }
+ memcpy(db2Buf, tempString.ptr(), 4);
+ }
+ else
+ {
+ uint8 temp = *(uint8*)(data == NULL ? field->ptr : data);
+ *(uint16*)(db2Buf) = (temp ? temp + 1900 : 0);
+ }
+ }
+ break;
+ case MYSQL_TYPE_BIT:
+ {
+ int bytesToCopy = db2Field.getByteLengthInRecord();
+
+ if (data == NULL)
+ {
+ uint64 temp = field->val_int();
+ memcpy(db2Buf,
+ ((char*)&temp) + (sizeof(temp) - bytesToCopy),
+ bytesToCopy);
+ }
+ else
+ {
+ memcpy(db2Buf,
+ data,
+ bytesToCopy);
+ }
+ }
+ break;
+ case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_BLOB:
+ {
+ if (field->real_type() == MYSQL_TYPE_ENUM ||
+ field->real_type() == MYSQL_TYPE_SET)
+ {
+ int64 temp= (data == NULL ? field->val_int() : field->val_int(data));
+ *(int64*)db2Buf = temp;
+ }
+ else
+ {
+ const uchar* dataToStore;
+ uint32 bytesToStore;
+ uint32 bytesToPad = 0;
+ CHARSET_INFO* fieldCharSet = field->charset();
+ uint32 maxDisplayLength = field->max_display_length();
+ switch (fieldType)
+ {
+ case MYSQL_TYPE_STRING:
+ {
+ bytesToStore = maxDisplayLength;
+ if (data == NULL)
+ dataToStore = field->ptr;
+ else
+ dataToStore = data;
+ }
+ break;
+ case MYSQL_TYPE_VARCHAR:
+ {
+
+ if (data == NULL)
+ {
+ bytesToStore = field->data_length();
+ dataToStore = field->ptr + ((Field_varstring*)field)->length_bytes;
+ }
+ else
+ {
+ // Key lens are stored little-endian
+ bytesToStore = *(uint8*)data + ((*(uint8*)(data+1)) << 8);
+ dataToStore = data + 2;
+ }
+ bytesToPad = maxDisplayLength - bytesToStore;
+ }
+ break;
+ case MYSQL_TYPE_BLOB:
+ {
+ if (data == NULL)
+ {
+ bytesToStore = ((Field_blob*)field)->get_length();
+ bytesToPad = maxDisplayLength - bytesToStore;
+ ((Field_blob*)field)->get_ptr((uchar**)&dataToStore);
+ }
+ else
+ {
+ // Key lens are stored little-endian
+ bytesToStore = *(uint8*)data + ((*(uint8*)(data+1)) << 8);
+ dataToStore = data + 2;
+ }
+ }
+ break;
+ }
+
+ int32 rc;
+ uint16 db2FieldType = db2Field.getType();
+ switch(db2FieldType)
+ {
+ case QMY_CHAR:
+ if (maxDisplayLength == 0)
+ bytesToPad = 1;
+ case QMY_VARCHAR:
+ if (db2FieldType == QMY_VARCHAR)
+ {
+ db2Buf += sizeof(uint16);
+ bytesToPad = 0;
+ }
+
+ if (bytesToStore > db2Field.getDataLengthInRecord())
+ {
+ bytesToStore = db2Field.getDataLengthInRecord();
+ field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
+ }
+
+ if (fieldCharSet == &my_charset_bin) // If binary
+ {
+ if (bytesToStore)
+ memcpy(db2Buf, dataToStore, bytesToStore);
+ if (bytesToPad)
+ memset(db2Buf + bytesToStore, 0x00, bytesToPad);
+ }
+ else if (db2Field.getCCSID() == 1208) // utf8
+ {
+ if (bytesToStore)
+ memcpy(db2Buf, dataToStore, bytesToStore);
+ if (bytesToPad)
+ memset(db2Buf + bytesToStore, ' ', bytesToPad);
+ }
+ else // single-byte ASCII to EBCDIC
+ {
+ DBUG_ASSERT(fieldCharSet->mbmaxlen == 1);
+ if (bytesToStore)
+ {
+ rc = convertFieldChars(toDB2, field->field_index, (char*)dataToStore, db2Buf, bytesToStore, bytesToStore, NULL);
+ if (rc)
+ return rc;
+ }
+ if (bytesToPad)
+ memset(db2Buf + bytesToStore, 0x40, bytesToPad);
+ }
+
+ if (db2FieldType == QMY_VARCHAR)
+ *(uint16*)(db2Buf - sizeof(uint16)) = bytesToStore;
+ break;
+ case QMY_VARGRAPHIC:
+ db2Buf += sizeof(uint16);
+ bytesToPad = 0;
+ case QMY_GRAPHIC:
+ if (maxDisplayLength == 0 && db2FieldType == QMY_GRAPHIC)
+ bytesToPad = 2;
+
+ if (db2Field.getCCSID() == 13488)
+ {
+ if (bytesToStore)
+ memcpy(db2Buf, dataToStore, bytesToStore);
+ if (bytesToPad)
+ wmemset((wchar_t*)(db2Buf + bytesToStore), 0x0020, bytesToPad/2);
+ }
+ else
+ {
+ size_t db2BytesToStore;
+ size_t maxDb2BytesToStore;
+
+ if (maxDisplayLength == 0 && db2FieldType == QMY_GRAPHIC)
+ maxDb2BytesToStore = 2;
+ else
+ maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
+ ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
+
+ if (bytesToStore == 0)
+ db2BytesToStore = 0;
+ else
+ {
+ rc = convertFieldChars(toDB2, field->field_index, (char*)dataToStore, db2Buf, bytesToStore, maxDb2BytesToStore, &db2BytesToStore);
+ if (rc)
+ return rc;
+ bytesToStore = db2BytesToStore;
+ }
+ if (db2BytesToStore < maxDb2BytesToStore) // If need to pad
+ wmemset((wchar_t*)(db2Buf + db2BytesToStore), 0x0020, (maxDb2BytesToStore - db2BytesToStore)/2);
+ }
+
+ if (db2FieldType == QMY_VARGRAPHIC)
+ *(uint16*)(db2Buf-sizeof(uint16)) = bytesToStore/2;
+ break;
+ case QMY_BLOBCLOB:
+ case QMY_DBCLOB:
+ {
+ DBUG_ASSERT(data == NULL);
+ DB2LobField* lobField = (DB2LobField*)(db2Buf + db2Field.calcBlobPad());
+
+ if ((fieldCharSet == &my_charset_bin) || // binary or
+ (db2Field.getCCSID()==13488) ||
+ (db2Field.getCCSID()==1208)) // binary UTF8
+ {
+ }
+ else
+ {
+ char* temp;
+ int32 rc;
+ size_t db2BytesToStore;
+ if (fieldCharSet->mbmaxlen == 1) // single-byte ASCII to EBCDIC
+ {
+ temp = getCharacterConversionBuffer(field->field_index, bytesToStore);
+ rc = convertFieldChars(toDB2, field->field_index, (char*)dataToStore,temp,bytesToStore, bytesToStore, NULL);
+ if (rc)
+ return (rc);
+ }
+ else // Else Far East, special UTF8 or non-special UTF8/UCS2
+ {
+ size_t maxDb2BytesToStore;
+ maxDb2BytesToStore = min(((bytesToStore * 2) / fieldCharSet->mbminlen),
+ ((maxDisplayLength * 2) / fieldCharSet->mbmaxlen));
+ temp = getCharacterConversionBuffer(field->field_index, maxDb2BytesToStore);
+ rc = convertFieldChars(toDB2, field->field_index, (char*)dataToStore,temp,bytesToStore, maxDb2BytesToStore, &db2BytesToStore);
+ if (rc)
+ return (rc);
+ bytesToStore = db2BytesToStore;
+ }
+ dataToStore = (uchar*)temp;
+ }
+
+ uint16 blobID = db2Table->getBlobIdFromField(field->field_index);
+ if (blobWriteBuffers[blobID] != (char*)dataToStore)
+ blobWriteBuffers[blobID].reassign((char*)dataToStore);
+ if ((void*)blobWriteBuffers[blobID])
+ lobField->dataHandle = (ILEMemHandle)blobWriteBuffers[blobID];
+ else
+ lobField->dataHandle = 0;
+ lobField->length = bytesToStore / (db2FieldType == QMY_DBCLOB ? 2 : 1);
+ }
+ break;
+ }
+ }
+ }
+ break;
+ default:
+ DBUG_ASSERT(0);
+ break;
+ }
+
+ return (ha_thd()->is_error());
+}
+
+
+/**
+ Convert DB2 field data into the equivalent MySQL format
+
+ @param db2Field The DB2 field definition
+ @param field The MySQL field to receive the converted data
+ @param buf The DB2 data to be converted
+*/
+int32 ha_ibmdb2i::convertDB2toMySQL(const DB2Field& db2Field, Field* field, const char* buf)
+{
+ int32 storeRC = 0; // Result of the field->store() operation
+
+ const char* bufPtr = buf + db2Field.getBufferOffset();
+
+ switch (field->type())
+ {
+ case MYSQL_TYPE_NEWDECIMAL:
+ {
+ uint precision= ((Field_new_decimal*)field)->precision;
+ uint scale= field->decimals();
+ uint db2Precision = min(precision, MAX_DEC_PRECISION);
+ uint decimalPlace = precision-scale+1;
+ char temp[80];
+
+ if (precision <= MAX_DEC_PRECISION ||
+ scale > precision - MAX_DEC_PRECISION)
+ {
+ uint numNibbles = db2Precision + (db2Precision % 2 ? 0 : 1);
+
+ temp[0] = (bcdGet(bufPtr, numNibbles) == 0xD ? '-' : ' ');
+ int strPos=1;
+ int bcdPos=(db2Precision % 2 ? 0 : 1);
+
+ for (;bcdPos < numNibbles; bcdPos++, strPos++)
+ {
+ if (strPos == decimalPlace)
+ {
+ temp[strPos] = '.';
+ strPos++;
+ }
+
+ temp[strPos] = bcdGet(bufPtr, bcdPos) + '0';
+ }
+
+ temp[strPos] = 0;
+
+ storeRC = field->store(temp, strPos, &my_charset_latin1);
+ }
+ }
+ break;
+ case MYSQL_TYPE_TINY:
+ {
+ storeRC = field->store(*(int16*)bufPtr, ((Field_num*)field)->unsigned_flag);
+ }
+ break;
+ case MYSQL_TYPE_SHORT:
+ {
+ if (((Field_num*)field)->unsigned_flag)
+ {
+ storeRC = field->store(*(int32*)bufPtr, TRUE);
+ }
+ else
+ {
+ storeRC = field->store(*(int16*)bufPtr, FALSE);
+ }
+ }
+ break;
+ case MYSQL_TYPE_LONG:
+ {
+ if (((Field_num*)field)->unsigned_flag)
+ {
+ storeRC = field->store(*(int64*)bufPtr, TRUE);
+ }
+ else
+ {
+ storeRC = field->store(*(int32*)bufPtr, FALSE);
+ }
+ }
+ break;
+ case MYSQL_TYPE_FLOAT:
+ {
+ storeRC = field->store(*(float*)bufPtr);
+ }
+ break;
+ case MYSQL_TYPE_DOUBLE:
+ {
+ storeRC = field->store(*(double*)bufPtr);
+ }
+ break;
+ case MYSQL_TYPE_LONGLONG:
+ {
+ char temp[23];
+ if (((Field_num*)field)->unsigned_flag)
+ {
+ temp[0] = (bcdGet(bufPtr, 21) == 0xD ? '-' : ' ');
+ int strPos=1;
+ int bcdPos=0;
+
+ for (;bcdPos <= 20; bcdPos++, strPos++)
+ {
+ temp[strPos] = bcdGet(bufPtr, bcdPos) + '0';
+ }
+
+ temp[strPos] = 0;
+
+ storeRC = field->store(temp, strPos, &my_charset_latin1);
+ }
+ else
+ {
+ storeRC = field->store(*(int64*)bufPtr, FALSE);
+ }
+ }
+ break;
+ case MYSQL_TYPE_INT24:
+ {
+ storeRC = field->store(*(int32*)bufPtr, ((Field_num*)field)->unsigned_flag);
+ }
+ break;
+ case MYSQL_TYPE_DATE:
+ case MYSQL_TYPE_NEWDATE:
+ {
+ longlong value= a4toi_ebcdic((uchar*)bufPtr) * 10000 +
+ a2toi_ebcdic((uchar*)bufPtr+5) * 100 +
+ a2toi_ebcdic((uchar*)bufPtr+8);
+
+ if (cachedZeroDateOption == SUBSTITUTE_0001_01_01 &&
+ value == (10000 + 100 + 1))
+ value = 0;
+
+ storeRC = field->store(value);
+ }
+ break;
+ case MYSQL_TYPE_TIME:
+ {
+ if (db2Field.getType() == QMY_TIME)
+ {
+ longlong value= a2toi_ebcdic((uchar*)bufPtr) * 10000 +
+ a2toi_ebcdic((uchar*)bufPtr+3) * 100 +
+ a2toi_ebcdic((uchar*)bufPtr+6);
+
+ storeRC = field->store(value);
+ }
+ else
+ storeRC = field->store(*((int32*)bufPtr));
+ }
+ break;
+ case MYSQL_TYPE_TIMESTAMP:
+ case MYSQL_TYPE_DATETIME:
+ {
+ longlong value= (a4toi_ebcdic((uchar*)bufPtr) * 10000 +
+ a2toi_ebcdic((uchar*)bufPtr+5) * 100 +
+ a2toi_ebcdic((uchar*)bufPtr+8)) * 1000000LL +
+ (a2toi_ebcdic((uchar*)bufPtr+11) * 10000 +
+ a2toi_ebcdic((uchar*)bufPtr+14) * 100 +
+ a2toi_ebcdic((uchar*)bufPtr+17));
+
+ if (cachedZeroDateOption == SUBSTITUTE_0001_01_01 &&
+ value == (10000 + 100 + 1) * 1000000LL)
+ value = 0;
+
+ storeRC = field->store(value);
+ }
+ break;
+ case MYSQL_TYPE_YEAR:
+ {
+ if (db2Field.getType() == QMY_CHAR)
+ {
+ storeRC = field->store(bufPtr, 4, &my_charset_bin);
+ }
+ else
+ {
+ storeRC = field->store(*((uint16*)bufPtr));
+ }
+ }
+ break;
+ case MYSQL_TYPE_BIT:
+ {
+ uint64 temp= 0;
+ int bytesToCopy= db2Field.getByteLengthInRecord();
+ memcpy(((char*)&temp) + (sizeof(temp) - bytesToCopy), bufPtr, bytesToCopy);
+ storeRC = field->store(temp, TRUE);
+ }
+ break;
+ case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_STRING:
+ case MYSQL_TYPE_BLOB:
+ {
+ if (field->real_type() == MYSQL_TYPE_ENUM ||
+ field->real_type() == MYSQL_TYPE_SET)
+ {
+ storeRC = field->store(*(int64*)bufPtr);
+ }
+ else
+ {
+
+ const char* dataToStore = NULL;
+ uint32 bytesToStore = 0;
+ CHARSET_INFO* fieldCharSet = field->charset();
+ switch(db2Field.getType())
+ {
+ case QMY_CHAR:
+ case QMY_GRAPHIC:
+ {
+ bytesToStore = db2Field.getByteLengthInRecord();
+ if (bytesToStore == 0)
+ bytesToStore = 1;
+ dataToStore = bufPtr;
+ }
+ break;
+ case QMY_VARCHAR:
+ {
+ bytesToStore = *(uint16*)bufPtr;
+ dataToStore = bufPtr+sizeof(uint16);
+ }
+ break;
+ case QMY_VARGRAPHIC:
+ {
+ /* For VARGRAPHIC, convert the number of double-byte characters
+ to the number of bytes. */
+ bytesToStore = (*(uint16*)bufPtr)*2;
+ dataToStore = bufPtr+sizeof(uint16);
+ }
+ break;
+ case QMY_DBCLOB:
+ case QMY_BLOBCLOB:
+ {
+ DB2LobField* lobField = (DB2LobField* )(bufPtr + db2Field.calcBlobPad());
+ bytesToStore = lobField->length * (db2Field.getType() == QMY_DBCLOB ? 2 : 1);
+ dataToStore = (char*)blobReadBuffers->getBufferPtr(field->field_index);
+ }
+ break;
+
+ }
+
+ if ((fieldCharSet != &my_charset_bin) && // not binary &
+ (db2Field.getCCSID() != 13488) && // not UCS2 &
+ (db2Field.getCCSID() != 1208))
+ {
+ char* temp;
+ size_t db2BytesToStore;
+ int rc;
+ if (fieldCharSet->mbmaxlen > 1)
+ {
+ size_t maxDb2BytesToStore = ((bytesToStore / 2) * fieldCharSet->mbmaxlen); // Worst case for number of bytes
+ temp = getCharacterConversionBuffer(field->field_index, maxDb2BytesToStore);
+ rc = convertFieldChars(toMySQL, field->field_index, dataToStore, temp, bytesToStore, maxDb2BytesToStore, &db2BytesToStore);
+ bytesToStore = db2BytesToStore;
+ }
+ else // single-byte ASCII to EBCDIC
+ {
+ temp = getCharacterConversionBuffer(field->field_index, bytesToStore);
+ rc = convertFieldChars(toMySQL, field->field_index, dataToStore, temp, bytesToStore, bytesToStore, NULL);
+ }
+ if (rc)
+ return (rc);
+ dataToStore = temp;
+ }
+
+ if ((field)->flags & BLOB_FLAG)
+ ((Field_blob*)(field))->set_ptr(bytesToStore, (uchar*)dataToStore);
+ else
+ storeRC = field->store(dataToStore, bytesToStore, &my_charset_bin);
+ }
+ }
+ break;
+ default:
+ DBUG_ASSERT(0);
+ break;
+
+ }
+
+ if (storeRC)
+ {
+ invalidDataFound = true;
+ }
+
+ return 0;
+}
diff --git a/storage/ibmdb2i/db2i_errors.cc b/storage/ibmdb2i/db2i_errors.cc
new file mode 100644
index 00000000000..43dd539447f
--- /dev/null
+++ b/storage/ibmdb2i/db2i_errors.cc
@@ -0,0 +1,297 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#include "db2i_errors.h"
+#include "db2i_ileBridge.h"
+#include "db2i_charsetSupport.h"
+#include "mysql_priv.h"
+#include "stdarg.h"
+
+#define MAX_MSGSTRING 109
+
+/*
+ The following strings are associated with errors that can be produced
+ within the storage engine proper.
+*/
+static const char* engineErrors[MAX_MSGSTRING] =
+{
+ {""},
+ {"Error opening codeset conversion from %.64s to %.64s (errno = %d)"},
+ {"Invalid %-.10s name '%-.128s'"},
+ {"Unsupported move from '%-.128s' to '%-.128s' on RENAME TABLE statement"},
+ {"Unsupported schema '%-.128s' specified on RENAME TABLE statement"},
+ {"Auto_increment is not allowed for a partitioned table"},
+ {"Character set conversion error due to unknown encoding scheme %d"},
+ {""},
+ {"Table '%-.128s' was not found by the storage engine"},
+ {"Could not resolve to %-.128s in library %-.10s type %-.10s (errno = %d)"},
+ {"Error on _PGMCALL for program %-.10s in library %-.10s (error = %d)"},
+ {"Error on _ILECALL for API '%.128s' (error = %d)"},
+ {"Error in iconv() function during character set conversion (errno = %d)"},
+ {"Error from Get Encoding Scheme (QTQGESP) API: %d, %d, %d"},
+ {"Error from Get Related Default CCSID (QTQGRDC) API: %d, %d, %d"},
+ {"Data out of range for column '%.192s'"},
+ {"Schema name '%.128s' exceeds maximum length of %d characters"},
+ {"Multiple collations not supported in a single index or constraint"},
+ {"Sort sequence was not found"},
+ {"One or more characters in column %.128s were substituted during conversion"},
+ {"A decimal column exceeded the maximum precision. Data may be truncated."},
+ {"Some data returned by DB2 for table %s could not be converted for MySQL"},
+ {""},
+ {"Column %.128s contains characters that cannot be converted"},
+ {"An invalid name was specified for ibmdb2i_rdb_name."},
+ {"A duplicate key was encountered for index '%.128s'"},
+ {"A table with the same name exists but has incompatible column definitions."},
+ {"The created table was discovered as an existing DB2 object."},
+ {"Some attribute(s) defined for column '%.128s' may not be honored by accesses from DB2."},
+};
+
+/*
+ The following strings are associated with errors that can be returned
+ by the operating system via the QMY_* APIs. Most are very uncommon and
+ indicate a bug somewhere.
+*/
+static const char* systemErrors[MAX_MSGSTRING] =
+{
+ {"Thread ID is too long"},
+ {"Error creating a SPACE memory object"},
+ {"Error creating a FILE memory object"},
+ {"Error creating a SPACE synchronization token"},
+ {"Error creating a FILE synchronization token"},
+ {"See message %-.7s in joblog for job %-.6s/%-.10s/%-.10s."},
+ {"Error unlocking a synchronization token when closing a connection"},
+ {"Invalid action specified for an 'object lock' request"},
+ {"Invalid action specified for a savepoint request"},
+ {"Partial keys are not supported with an ICU sort sequence"},
+ {"Error retrieving an ICU sort key"},
+ {"Error converting single-byte sort sequence to UCS-2"},
+ {"An unsupported collation was specified"},
+ {"Validation failed for referenced table of foreign key constraint"},
+ {"Error extracting table for constraint information"},
+ {"Error extracting referenced table for constraint information"},
+ {"Invalid action specified for a 'commitment control' request"},
+ {"Invalid commitment control isolation level specified on 'open' request"},
+ {"Invalid file handle"},
+ {" "},
+ {"Invalid option specified for returning data on 'read' request"},
+ {"Invalid orientation specified for 'read' request"},
+ {"Invalid option type specified for 'read' request"},
+ {"Invalid isolation level for starting commitment control"},
+ {"Error unlocking a synchronization token in module QMYALC"},
+ {"Length of space for returned format is not long enough"},
+ {"SQL XA transactions are currently unsupported by this interface"},
+ {"The associated QSQSRVR job was killed or ended unexpectedly."},
+ {"Error unlocking a synchronization token in module QMYSEI"},
+ {"Error unlocking a synchronization token in module QMYSPO"},
+ {"Error converting input CCSID from short form to long form"},
+ {" "},
+ {"Error getting associated CCSID for CCSID conversion"},
+ {"Error converting a string from one CCSID to another"},
+ {"Error unlocking a synchronization token"},
+ {"Error destroying a synchronization token"},
+ {"Error locking a synchronization token"},
+ {"Error recreating a synchronization token"},
+ {"A space handle was not specified for a constraint request"},
+ {"An SQL cursor was specified for a delete request"},
+ {" "},
+ {"Error on delete request because current UFCB for connection is not open"},
+ {"An SQL cursor was specified for an object initialization request"},
+ {"An SQL cursor was specified for an object override request"},
+ {"A space handle was not specified for an object override request"},
+ {"An SQL cursor was specified for an information request"},
+ {"An SQL cursor was specified for an object lock request"},
+ {"An SQL cursor was specified for an optimize request"},
+ {"A data handle was not specified for a read request"},
+ {"A row number handle was not specified for a read request"},
+ {"A key handle was not specified for a read request"},
+ {"An SQL cursor was specified for an row estimation request"},
+ {"A space handle was not specified for a row estimation request"},
+ {"An SQL cursor was specified for a release record request"},
+ {"A statement handle was not specified for an 'execute immediate' request"},
+ {"A statement handle was not specified for a 'prepare open' request"},
+ {"An SQL cursor was specified for an update request"},
+ {"The UFCB was not open for read"},
+ {"Error on update request because current UFCB for connection is not open"},
+ {"A data handle was not specified for an update request"},
+ {"An SQL cursor was specified for a write request"},
+ {"A data handle was not specified for a write request"},
+ {"An unknown function was specified on a process request"},
+ {"A share definition was not specified for an 'allocate share' request"},
+ {"A share handle was not specified for an 'allocate share' request"},
+ {"A use count handle was not specified for an 'allocate share' request"},
+ {"A 'records per key' handle was not specified for an information request"},
+ {"Error resolving LOB addresss"},
+ {"Length of a LOB space is too small"},
+ {"An unknown function was specified for a server request"},
+ {"Object authorization failed. See message %-.7s in joblog for job %-.6s/%-.10s/%-.10s. for more information."},
+ {" "},
+ {"Error locking mutex on server"},
+ {"Error unlocking mutex on server"},
+ {"Error checking for RDB name in RDB Directory"},
+ {"Error creating mutex on server"},
+ {"A table with that name already exists"},
+ {" "},
+ {"Error unlocking mutex"},
+ {"Error connecting to server job"},
+ {"Error connecting to server job"},
+ {" "},
+ {"Function check occurred while registering parameter spaces. See joblog."},
+ {" "},
+ {" "},
+ {"End of block"},
+ {"The file has changed and might not be compatible with the MySQL table definition"},
+ {"Error giving pipe to server job"},
+ {"There are open object locks when attempting to deallocate"},
+ {"There is no open lock"},
+ {" "},
+ {" "},
+ {"The maximum value for the auto_increment data type was exceeded"},
+ {"Error occurred closing the pipe "},
+ {"Error occurred taking a descriptor for the pipe"},
+ {"Error writing to pipe "},
+ {"Server was interrupted "},
+ {"No pipe descriptor exists for reuse "},
+ {"Error occurred during an SQL prepare statement "},
+ {"Error occurred during an SQL open "},
+ {" "},
+ {" "},
+ {" "},
+ {" "},
+ {" "},
+ {" "},
+ {"An unspecified error was returned from the system."},
+ {" "}
+};
+
+/**
+ This function builds the text string for an error code, and substitutes
+ a variable number of replacement variables into the string.
+*/
+void getErrTxt(int errCode, ...)
+{
+ va_list args;
+ va_start(args,errCode);
+ char* buffer = db2i_ileBridge::getBridgeForThread()->getErrorStorage();
+ const char* msg;
+
+ if (errCode >= QMY_ERR_MIN && errCode <= QMY_ERR_SQ_OPEN)
+ msg = systemErrors[errCode - QMY_ERR_MIN];
+ else
+ {
+ DBUG_ASSERT(errCode >= DB2I_FIRST_ERR && errCode <= DB2I_LAST_ERR);
+ msg = engineErrors[errCode - DB2I_FIRST_ERR];
+ }
+
+ (void) my_vsnprintf (buffer, MYSQL_ERRMSG_SIZE, msg, args);
+ va_end(args);
+ fprintf(stderr,"ibmdb2i error %d: %s\n",errCode,buffer);
+ DBUG_PRINT("error", ("ibmdb2i error %d: %s",errCode,buffer));
+}
+
+static inline void trimSpace(char* str)
+{
+ char* end = strchr(str, ' ');
+ if (end) *end = 0;
+}
+
+
+/**
+ Generate the error text specific to an API error returned by a QMY_* API.
+
+ @parm errCode The error value
+ @parm errInfo The structure containing the message and job identifiers.
+*/
+void reportSystemAPIError(int errCode, const Qmy_Error_output *errInfo)
+{
+ if (errCode >= QMY_ERR_MIN && errCode <= QMY_ERR_SQ_OPEN)
+ {
+ switch(errCode)
+ {
+ case QMY_ERR_MSGID:
+ case QMY_ERR_NOT_AUTH:
+ {
+ DBUG_ASSERT(errInfo);
+ char jMsg[8]; // Error message ID
+ char jName[11]; // Job name
+ char jUser[11]; // Job user
+ char jNbr[7]; // Job number
+ memset(jMsg, 0, sizeof(jMsg));
+ memset(jName, 0, sizeof(jMsg));
+ memset(jUser, 0, sizeof(jMsg));
+ memset(jMsg, 0, sizeof(jMsg));
+
+ convFromEbcdic(errInfo->MsgId,jMsg,sizeof(jMsg)-1);
+ convFromEbcdic(errInfo->JobName,jName,sizeof(jName)-1);
+ trimSpace(jName);
+ convFromEbcdic(errInfo->JobUser,jUser,sizeof(jUser)-1);
+ trimSpace(jUser);
+ convFromEbcdic(errInfo->JobNbr,jNbr,sizeof(jNbr)-1);
+ getErrTxt(errCode,jMsg,jNbr,jUser,jName);
+ }
+ break;
+ case QMY_ERR_RTNFMT:
+ {
+ getErrTxt(QMY_ERR_LVLID_MISMATCH);
+ }
+ break;
+ default:
+ getErrTxt(errCode);
+ break;
+ }
+ }
+}
+
+
+/**
+ Generate a warning for the specified error.
+*/
+void warning(THD *thd, int errCode, ...)
+{
+ va_list args;
+ va_start(args,errCode);
+ char buffer[MYSQL_ERRMSG_SIZE];
+ const char* msg;
+
+ DBUG_ASSERT(errCode >= DB2I_FIRST_ERR && errCode <= DB2I_LAST_ERR);
+ msg = engineErrors[errCode - DB2I_FIRST_ERR];
+
+ (void) my_vsnprintf (buffer, MYSQL_ERRMSG_SIZE, msg, args);
+ va_end(args);
+ DBUG_PRINT("warning", ("ibmdb2i warning %d: %s",errCode,buffer));
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, errCode, buffer);
+}
+
+
diff --git a/storage/ibmdb2i/db2i_errors.h b/storage/ibmdb2i/db2i_errors.h
new file mode 100644
index 00000000000..0f6fbef33f6
--- /dev/null
+++ b/storage/ibmdb2i/db2i_errors.h
@@ -0,0 +1,93 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_ERRORS_H
+#define DB2I_ERRORS_H
+
+#include "qmyse.h"
+class THD;
+
+/**
+ @enum DB2I_errors
+
+ @brief These are the errors that can be returned by the storage engine proper
+ and that are specific to the engine. Refer to db2i_errors.cc for text
+ descriptions of the errors.
+*/
+
+enum DB2I_errors
+{
+ DB2I_FIRST_ERR = 2500,
+ DB2I_ERR_ICONV_OPEN,
+ DB2I_ERR_INVALID_NAME,
+ DB2I_ERR_RENAME_MOVE,
+ DB2I_ERR_RENAME_QTEMP,
+ DB2I_ERR_PART_AUTOINC,
+ DB2I_ERR_UNKNOWN_ENCODING,
+ DB2I_ERR_RESERVED,
+ DB2I_ERR_TABLE_NOT_FOUND,
+ DB2I_ERR_RESOLVE_OBJ,
+ DB2I_ERR_PGMCALL,
+ DB2I_ERR_ILECALL,
+ DB2I_ERR_ICONV,
+ DB2I_ERR_QTQGESP,
+ DB2I_ERR_QTQGRDC,
+ DB2I_ERR_INVALID_COL_VALUE,
+ DB2I_ERR_TOO_LONG_SCHEMA,
+ DB2I_ERR_MIXED_COLLATIONS,
+ DB2I_ERR_SRTSEQ,
+ DB2I_ERR_SUB_CHARS,
+ DB2I_ERR_PRECISION,
+ DB2I_ERR_INVALID_DATA,
+ DB2I_ERR_RESERVED2,
+ DB2I_ERR_ILL_CHAR,
+ DB2I_ERR_BAD_RDB_NAME,
+ DB2I_ERR_UNKNOWN_IDX,
+ DB2I_ERR_DISCOVERY_MISMATCH,
+ DB2I_ERR_WARN_CREATE_DISCOVER,
+ DB2I_ERR_WARN_COL_ATTRS,
+ DB2I_LAST_ERR = DB2I_ERR_WARN_COL_ATTRS
+};
+
+void getErrTxt(int errcode, ...);
+void reportSystemAPIError(int errCode, const Qmy_Error_output *errInfo);
+void warning(THD *thd, int errCode, ...);
+
+const char* DB2I_SQL0350 = "\xE2\xD8\xD3\xF0\xF3\xF5\xF0"; // SQL0350 in EBCDIC
+const char* DB2I_CPF503A = "\xC3\xD7\xC6\xF5\xF0\xF3\xC1"; // CPF503A in EBCDIC
+const char* DB2I_SQL0538 = "\xE2\xD8\xD3\xF0\xF5\xF3\xF8"; // SQL0538 in EBCDIC
+
+#endif
diff --git a/storage/ibmdb2i/db2i_file.cc b/storage/ibmdb2i/db2i_file.cc
new file mode 100644
index 00000000000..a16aa927527
--- /dev/null
+++ b/storage/ibmdb2i/db2i_file.cc
@@ -0,0 +1,556 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+
+#include "db2i_file.h"
+#include "db2i_charsetSupport.h"
+#include "db2i_collationSupport.h"
+#include "db2i_misc.h"
+#include "db2i_errors.h"
+#include "my_dir.h"
+
+db2i_table::db2i_table(const TABLE_SHARE* myTable, const char* path) :
+ mysqlTable(myTable),
+ db2StartId(0),
+ blobFieldCount(0),
+ blobFields(NULL),
+ blobFieldActualSizes(NULL),
+ logicalFiles(NULL),
+ physicalFile(NULL),
+ db2TableNameSQLAscii(NULL),
+ db2LibNameSQLAscii(NULL)
+{
+ char asciiLibName[MAX_DB2_SCHEMANAME_LENGTH + 1];
+ getDB2LibNameFromPath(path, asciiLibName, ASCII_NATIVE);
+
+ char asciiFileName[MAX_DB2_FILENAME_LENGTH + 1];
+ getDB2FileNameFromPath(path, asciiFileName, ASCII_NATIVE);
+
+ size_t libNameLen = strlen(asciiLibName);
+ size_t fileNameLen = strlen(asciiFileName);
+
+ db2LibNameEbcdic=(char *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &db2LibNameEbcdic, libNameLen+1,
+ &db2LibNameAscii, libNameLen+1,
+ &db2LibNameSQLAscii, libNameLen*2 + 1,
+ &db2TableNameEbcdic, fileNameLen+1,
+ &db2TableNameAscii, fileNameLen+1,
+ &db2TableNameSQLAscii, fileNameLen*2 + 1,
+ NullS);
+
+ if (likely(db2LibNameEbcdic))
+ {
+ memcpy(db2LibNameAscii, asciiLibName, libNameLen);
+ convertNativeToSQLName(db2LibNameAscii, db2LibNameSQLAscii);
+ convToEbcdic(db2LibNameAscii, db2LibNameEbcdic, libNameLen);
+ memcpy(db2TableNameAscii, asciiFileName, fileNameLen);
+ convertNativeToSQLName(db2TableNameAscii, db2TableNameSQLAscii);
+ convToEbcdic(db2TableNameAscii, db2TableNameEbcdic, fileNameLen);
+ }
+
+ conversionDefinitions[toMySQL] = NULL;
+ conversionDefinitions[toDB2] = NULL;
+
+ isTemporaryTable = (strstr(mysqlTable->path.str, mysql_tmpdir) == mysqlTable->path.str);
+}
+
+
+int32 db2i_table::initDB2Objects(const char* path)
+{
+ uint fileObjects = 1 + mysqlTable->keys;
+ ValidatedPointer<ShrDef> fileDefnSpace(sizeof(ShrDef) * fileObjects);
+
+ physicalFile = new db2i_file(this);
+ physicalFile->fillILEDefn(&fileDefnSpace[0], true);
+
+ logicalFileCount = mysqlTable->keys;
+ if (logicalFileCount > 0)
+ {
+ logicalFiles = new db2i_file*[logicalFileCount];
+ for (int k = 0; k < logicalFileCount; k++)
+ {
+ logicalFiles[k] = new db2i_file(this, k);
+ logicalFiles[k]->fillILEDefn(&fileDefnSpace[k+1], false);
+ }
+ }
+
+ ValidatedPointer<FILE_HANDLE> fileDefnHandles(sizeof(FILE_HANDLE) * fileObjects);
+ size_t formatSpaceLen = sizeof(format_hdr_t) + mysqlTable->fields * sizeof(DB2Field);
+ formatSpace.alloc(formatSpaceLen);
+
+ int rc = db2i_ileBridge::getBridgeForThread()->
+ expectErrors(QMY_ERR_RTNFMT)->
+ allocateFileDefn(fileDefnSpace,
+ fileDefnHandles,
+ fileObjects,
+ db2LibNameEbcdic,
+ strlen(db2LibNameEbcdic),
+ formatSpace,
+ formatSpaceLen);
+
+ if (rc)
+ {
+ // We have to handle a format space error as a special case of a FID
+ // mismatch. We should only get the space error if columns have been added
+ // to the DB2 table without MySQL's knowledge, which is effectively a
+ // FID problem.
+ if (rc == QMY_ERR_RTNFMT)
+ {
+ rc = QMY_ERR_LVLID_MISMATCH;
+ getErrTxt(rc);
+ }
+ return rc;
+ }
+
+ convFromEbcdic(((format_hdr_t*)formatSpace)->FilLvlId, fileLevelID, sizeof(fileLevelID));
+
+ if (!doFileIDsMatch(path))
+ {
+ getErrTxt(QMY_ERR_LVLID_MISMATCH);
+ return QMY_ERR_LVLID_MISMATCH;
+ }
+
+ physicalFile->setMasterDefnHandle(fileDefnHandles[0]);
+ for (int k = 0; k < mysqlTable->keys; k++)
+ {
+ logicalFiles[k]->setMasterDefnHandle(fileDefnHandles[k+1]);
+ }
+
+ db2StartId = (uint64)(((format_hdr_t*)formatSpace)->StartIdVal);
+ db2Fields = (DB2Field*)((char*)(void*)formatSpace + ((format_hdr_t*)formatSpace)->ColDefOff);
+
+ uint fields = mysqlTable->fields;
+ for (int i = 0; i < fields; ++i)
+ {
+ if (db2Field(i).isBlob())
+ {
+ blobFieldCount++;
+ }
+ }
+
+ if (blobFieldCount)
+ {
+ blobFieldActualSizes = (uint*)my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &blobFieldActualSizes, blobFieldCount * sizeof(uint),
+ &blobFields, blobFieldCount * sizeof(uint16),
+ NullS);
+
+ int b = 0;
+ for (int i = 0; i < fields; ++i)
+ {
+ if (db2Field(i).isBlob())
+ {
+ blobFields[b++] = i;
+ }
+ }
+ }
+
+ my_multi_malloc(MYF(MY_WME),
+ &conversionDefinitions[toMySQL], fields * sizeof(iconv_t),
+ &conversionDefinitions[toDB2], fields * sizeof(iconv_t),
+ NullS);
+ for (int i = 0; i < fields; ++i)
+ {
+ conversionDefinitions[toMySQL][i] = (iconv_t)(-1);
+ conversionDefinitions[toDB2][i] = (iconv_t)(-1);
+ }
+
+ return 0;
+}
+
+int db2i_table::fastInitForCreate(const char* path)
+{
+ ValidatedPointer<ShrDef> fileDefnSpace(sizeof(ShrDef));
+
+ physicalFile = new db2i_file(this);
+ physicalFile->fillILEDefn(fileDefnSpace, true);
+
+ ValidatedPointer<FILE_HANDLE> fileDefnHandles(sizeof(FILE_HANDLE));
+
+ size_t formatSpaceLen = sizeof(format_hdr_t) +
+ mysqlTable->fields * sizeof(DB2Field);
+ formatSpace.alloc(formatSpaceLen);
+
+ int rc = db2i_ileBridge::getBridgeForThread()->allocateFileDefn(fileDefnSpace,
+ fileDefnHandles,
+ 1,
+ db2LibNameEbcdic,
+ strlen(db2LibNameEbcdic),
+ formatSpace,
+ formatSpaceLen);
+
+ if (rc)
+ return rc;
+
+ convFromEbcdic(((format_hdr_t*)formatSpace)->FilLvlId, fileLevelID, sizeof(fileLevelID));
+ doFileIDsMatch(path);
+
+ return 0;
+}
+
+bool db2i_table::doFileIDsMatch(const char* path)
+{
+ char name_buff[FN_REFLEN];
+
+ fn_format(name_buff, path, "", FID_EXT, (MY_REPLACE_EXT | MY_UNPACK_FILENAME));
+
+ File fd = my_open(name_buff, O_RDONLY, MYF(0));
+
+ if (fd == -1)
+ {
+ if (errno == ENOENT)
+ {
+ fd = my_create(name_buff, 0, O_WRONLY, MYF(MY_WME));
+
+ if (fd == -1)
+ {
+ // TODO: Report errno here
+ return false;
+ }
+ my_write(fd, (uchar*)fileLevelID, sizeof(fileLevelID), MYF(MY_WME));
+ my_close(fd, MYF(0));
+ return true;
+ }
+ else
+ {
+ // TODO: Report errno here
+ return false;
+ }
+ }
+
+ char diskFID[sizeof(fileLevelID)];
+
+ bool match = false;
+
+ if (my_read(fd, (uchar*)diskFID, sizeof(diskFID), MYF(MY_WME)) == sizeof(diskFID) &&
+ (memcmp(diskFID, fileLevelID, sizeof(diskFID)) == 0))
+ match = true;
+
+ my_close(fd, MYF(0));
+
+ return match;
+}
+
+void db2i_table::deleteAssocFiles(const char* name)
+{
+ char name_buff[FN_REFLEN];
+ fn_format(name_buff, name, "", FID_EXT, (MY_REPLACE_EXT | MY_UNPACK_FILENAME));
+ my_delete(name_buff, MYF(0));
+}
+
+void db2i_table::renameAssocFiles(const char* from, const char* to)
+{
+ rename_file_ext(from, to, FID_EXT);
+}
+
+
+db2i_table::~db2i_table()
+{
+ if (blobFieldActualSizes)
+ my_free(blobFieldActualSizes, MYF(0));
+
+ if (conversionDefinitions[toMySQL])
+ my_free(conversionDefinitions[toMySQL], MYF(0));
+
+ if (logicalFiles)
+ {
+ for (int k = 0; k < logicalFileCount; ++k)
+ {
+ delete logicalFiles[k];
+ }
+
+ delete[] logicalFiles;
+ }
+ delete physicalFile;
+
+ my_free(db2LibNameEbcdic, 0);
+}
+
+void db2i_table::getDB2QualifiedName(char* to)
+{
+ strcat(to, getDB2LibName(ASCII_SQL));
+ strcat(to, ".");
+ strcat(to, getDB2TableName(ASCII_SQL));
+}
+
+
+void db2i_table::getDB2QualifiedNameFromPath(const char* path, char* to)
+{
+ getDB2LibNameFromPath(path, to);
+ strcat(to, ".");
+ getDB2FileNameFromPath(path, strend(to));
+}
+
+
+size_t db2i_table::smartFilenameToTableName(const char *in, char* out, size_t outlen)
+{
+ if (strchr(in, '@') == NULL)
+ {
+ return filename_to_tablename(in, out, outlen);
+ }
+
+ char* test = (char*) my_malloc(outlen, MYF(MY_WME));
+
+ filename_to_tablename(in, test, outlen);
+
+ char* cur = test;
+
+ while (*cur)
+ {
+ if ((*cur <= 0x20) || (*cur >= 0x80))
+ {
+ strncpy(out, in, outlen);
+ my_free(test, MYF(0));
+ return min(outlen, strlen(out));
+ }
+ ++cur;
+ }
+
+ strncpy(out, test, outlen);
+ my_free(test, MYF(0));
+ return min(outlen, strlen(out));
+}
+
+void db2i_table::filenameToTablename(const char* in, char* out, size_t outlen)
+{
+ if (strchr(in, '#') == NULL)
+ {
+ smartFilenameToTableName(in, out, outlen);
+ return;
+ }
+
+ char* temp = (char*)sql_alloc(outlen);
+
+ const char* part1, *part2, *part3, *part4;
+ part1 = in;
+ part2 = strstr(part1, "#P#");
+ if (part2);
+ {
+ part3 = part2 + 3;
+ part4 = strchr(part3, '#');
+ if (!part4)
+ part4 = strend(in);
+ }
+
+ memcpy(temp, part1, min(outlen, part2 - part1));
+ temp[min(outlen-1, part2-part1)] = 0;
+
+ int32 accumLen = smartFilenameToTableName(temp, out, outlen);
+
+ if (part2 && (accumLen + 4 < outlen))
+ {
+ strcat(out, "#P#");
+ accumLen += 4;
+
+ memset(temp, 0, min(outlen, part2-part1));
+ memcpy(temp, part3, min(outlen, part4-part3));
+ temp[min(outlen-1, part4-part3)] = 0;
+
+ accumLen += smartFilenameToTableName(temp, strend(out), outlen-accumLen);
+
+ if (part4 && (accumLen + (strend(in) - part4 + 1) < outlen))
+ {
+ strcat(out, part4);
+ }
+ }
+}
+
+void db2i_table::getDB2LibNameFromPath(const char* path, char* lib, NameFormatFlags format)
+{
+ if (strstr(path, mysql_tmpdir) == path)
+ {
+ strcpy(lib, DB2I_TEMP_TABLE_SCHEMA);
+ }
+ else
+ {
+ const char* c = strend(path) - 1;
+ while (c > path && *c != '\\' && *c != '/')
+ --c;
+
+ if (c != path)
+ {
+ const char* dbEnd = c;
+ do {
+ --c;
+ } while (c >= path && *c != '\\' && *c != '/');
+
+ if (c >= path)
+ {
+ const char* dbStart = c+1;
+ char fileName[FN_REFLEN];
+ memcpy(fileName, dbStart, dbEnd - dbStart);
+ fileName[dbEnd-dbStart] = 0;
+
+ char dbName[MAX_DB2_SCHEMANAME_LENGTH+1];
+ filenameToTablename(fileName, dbName , sizeof(dbName));
+
+ convertMySQLNameToDB2Name(dbName, lib, sizeof(dbName), true, (format==ASCII_SQL) );
+ }
+ else
+ DBUG_ASSERT(0); // This should never happen!
+ }
+ }
+}
+
+void db2i_table::getDB2FileNameFromPath(const char* path, char* file, NameFormatFlags format)
+{
+ const char* fileEnd = strend(path);
+ const char* c = fileEnd;
+ while (c > path && *c != '\\' && *c != '/')
+ --c;
+
+ if (c != path)
+ {
+ const char* fileStart = c+1;
+ char fileName[FN_REFLEN];
+ memcpy(fileName, fileStart, fileEnd - fileStart);
+ fileName[fileEnd - fileStart] = 0;
+ char db2Name[MAX_DB2_FILENAME_LENGTH+1];
+ filenameToTablename(fileName, db2Name, sizeof(db2Name));
+ convertMySQLNameToDB2Name(db2Name, file, sizeof(db2Name), true, (format==ASCII_SQL) );
+ }
+}
+
+// Generates the DB2 index name when given the MySQL index and table names.
+int32 db2i_table::appendQualifiedIndexFileName(const char* indexName,
+ const char* tableName,
+ String& to,
+ NameFormatFlags format,
+ enum_DB2I_INDEX_TYPE type)
+{
+ char generatedName[MAX_DB2_FILENAME_LENGTH+1];
+ strncpy(generatedName, indexName, DB2I_INDEX_NAME_LENGTH_TO_PRESERVE);
+ generatedName[DB2I_INDEX_NAME_LENGTH_TO_PRESERVE] = 0;
+ char* endOfGeneratedName;
+
+ if (type == typeDefault)
+ {
+ strcat(generatedName, DB2I_DEFAULT_INDEX_NAME_DELIMITER);
+ endOfGeneratedName = strend(generatedName);
+ }
+ else if (type != typeNone)
+ {
+ strcat(generatedName, DB2I_ADDL_INDEX_NAME_DELIMITER);
+ endOfGeneratedName = strend(generatedName);
+ *(endOfGeneratedName-2) = char(type);
+ }
+
+ uint lenWithoutFile = endOfGeneratedName - generatedName;
+
+ char strippedTableName[MAX_DB2_FILENAME_LENGTH+1];
+ if (format == ASCII_SQL)
+ {
+ strcpy(strippedTableName, tableName);
+ stripExtraQuotes(strippedTableName+1, sizeof(strippedTableName));
+ tableName = strippedTableName;
+ }
+
+ if (strlen(tableName) > (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))
+ return -1;
+
+ strncat(generatedName,
+ tableName+1,
+ min(strlen(tableName), (MAX_DB2_FILENAME_LENGTH-lenWithoutFile))-2 );
+
+ char finalName[MAX_DB2_FILENAME_LENGTH+1];
+ convertMySQLNameToDB2Name(generatedName, finalName, sizeof(finalName), true, (format==ASCII_SQL));
+ to.append(finalName);
+
+ return 0;
+}
+
+
+void db2i_table::findConversionDefinition(enum_conversionDirection direction, uint16 fieldID)
+{
+ getConversion(direction,
+ mysqlTable->field[fieldID]->charset(),
+ db2Field(fieldID).getCCSID(),
+ conversionDefinitions[direction][fieldID]);
+}
+
+
+db2i_file::db2i_file(db2i_table* table) : db2Table(table)
+{
+ commonCtorInit();
+
+ DBUG_ASSERT(table->getMySQLTable()->table_name.length <= MAX_DB2_FILENAME_LENGTH-2);
+
+ db2FileName = (char*)table->getDB2TableName(db2i_table::EBCDIC_NATIVE);
+}
+
+db2i_file::db2i_file(db2i_table* table, int index) : db2Table(table)
+{
+ commonCtorInit();
+
+ if ((index == table->getMySQLTable()->primary_key) && !table->isTemporary())
+ {
+ db2FileName = (char*)table->getDB2TableName(db2i_table::EBCDIC_NATIVE);
+ }
+ else
+ {
+ // Generate the index name (in index___table form); quote and EBCDICize it.
+ String qualifiedPath;
+ qualifiedPath.length(0);
+
+ const char* asciiFileName = table->getDB2TableName(db2i_table::ASCII_NATIVE);
+
+ db2i_table::appendQualifiedIndexFileName(table->getMySQLTable()->key_info[index].name,
+ asciiFileName,
+ qualifiedPath,
+ db2i_table::ASCII_NATIVE,
+ typeDefault);
+
+ db2FileName = (char*)my_malloc(qualifiedPath.length()+1, MYF(MY_WME | MY_ZEROFILL));
+ convToEbcdic(qualifiedPath.ptr(), db2FileName, qualifiedPath.length());
+ }
+}
+
+void db2i_file::commonCtorInit()
+{
+ masterDefn = 0;
+ memset(&formats, 0, maxRowFormats*sizeof(RowFormat));
+}
+
+
+void db2i_file::fillILEDefn(ShrDef* defn, bool readInArrivalSeq)
+{
+ defn->ObjNamLen = strlen(db2FileName);
+ DBUG_ASSERT(defn->ObjNamLen <= sizeof(defn->ObjNam));
+ memcpy(defn->ObjNam, db2FileName, defn->ObjNamLen);
+ defn->ArrSeq[0] = (readInArrivalSeq ? QMY_YES : QMY_NO);
+}
+
diff --git a/storage/ibmdb2i/db2i_file.h b/storage/ibmdb2i/db2i_file.h
new file mode 100644
index 00000000000..ff35a473b05
--- /dev/null
+++ b/storage/ibmdb2i/db2i_file.h
@@ -0,0 +1,446 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_FILE_H
+#define DB2I_FILE_H
+
+#include "db2i_global.h"
+#include "db2i_ileBridge.h"
+#include "db2i_validatedPointer.h"
+#include "my_atomic.h"
+#include "db2i_iconv.h"
+#include "db2i_charsetSupport.h"
+
+const char FID_EXT[] = ".FID";
+
+class db2i_file;
+
+#pragma pack(1)
+struct DB2LobField
+{
+ char reserved1;
+ uint32 length;
+ char reserved2[4];
+ uint32 ordinal;
+ ILEMemHandle dataHandle;
+ char reserved3[8];
+};
+#pragma pack(pop)
+
+class DB2Field
+{
+ public:
+ uint16 getType() const { return *(uint16*)(&definition.ColType); }
+ uint16 getByteLengthInRecord() const { return definition.ColLen; }
+ uint16 getDataLengthInRecord() const
+ {
+ return (getType() == QMY_VARCHAR || getType() == QMY_VARGRAPHIC ? definition.ColLen - 2 : definition.ColLen);
+ }
+ uint16 getCCSID() const { return *(uint16*)(&definition.ColCCSID); }
+ bool isBlob() const
+ {
+ uint16 type = getType();
+ return (type == QMY_BLOBCLOB || type == QMY_DBCLOB);
+ }
+ uint16 getBufferOffset() const { return definition.ColBufOff; }
+ uint16 calcBlobPad() const
+ {
+ DBUG_ASSERT(isBlob());
+ return getByteLengthInRecord() - sizeof (DB2LobField);
+ }
+ DB2LobField* asBlobField(char* buf) const
+ {
+ DBUG_ASSERT(isBlob());
+ return (DB2LobField*)(buf + getBufferOffset() + calcBlobPad());
+ }
+ private:
+ col_def_t definition;
+};
+
+
+/**
+ @class db2i_table
+
+ @details
+ This class describes the logical SQL table provided by DB2.
+ It stores "table-scoped" information such as the name of the
+ DB2 schema, BLOB descriptions, and the corresponding MySQL table definition.
+ Only one instance exists per SQL table.
+*/
+class db2i_table
+{
+ public:
+ enum NameFormatFlags
+ {
+ ASCII_SQL,
+ ASCII_NATIVE,
+ EBCDIC_NATIVE
+ };
+
+ db2i_table(const TABLE_SHARE* myTable, const char* path = NULL);
+
+ ~db2i_table();
+
+ int32 initDB2Objects(const char* path);
+
+ const TABLE_SHARE* getMySQLTable() const
+ {
+ return mysqlTable;
+ }
+
+ uint64 getStartId() const
+ {
+ return db2StartId;
+ }
+
+ void updateStartId(uint64 newStartId)
+ {
+ db2StartId = newStartId;
+ }
+
+ bool hasBlobs() const
+ {
+ return (blobFieldCount > 0);
+ }
+
+ uint16 getBlobCount() const
+ {
+ return blobFieldCount;
+ }
+
+ uint getBlobFieldActualSize(uint fieldIndex) const
+ {
+ return blobFieldActualSizes[getBlobIdFromField(fieldIndex)];
+ }
+
+ void updateBlobFieldActualSize(uint fieldIndex, uint32 newSize)
+ {
+ // It's OK that this isn't threadsafe, since this is just an advisory
+ // value. If a race condition causes the lesser of two values to be stored,
+ // that's OK.
+ uint16 blobID = getBlobIdFromField(fieldIndex);
+ DBUG_ASSERT(blobID < blobFieldCount);
+
+ if (blobFieldActualSizes[blobID] < newSize)
+ {
+ blobFieldActualSizes[blobID] = newSize;
+ }
+ }
+
+
+
+ const char* getDB2LibName(NameFormatFlags format = EBCDIC_NATIVE)
+ {
+ switch (format)
+ {
+ case EBCDIC_NATIVE:
+ return db2LibNameEbcdic; break;
+ case ASCII_NATIVE:
+ return db2LibNameAscii; break;
+ case ASCII_SQL:
+ return db2LibNameSQLAscii; break;
+ default:
+ DBUG_ASSERT(0);
+ }
+ return NULL;
+ }
+
+ const char* getDB2TableName(NameFormatFlags format = EBCDIC_NATIVE) const
+ {
+ switch (format)
+ {
+ case EBCDIC_NATIVE:
+ return db2TableNameEbcdic; break;
+ case ASCII_NATIVE:
+ return db2TableNameAscii; break;
+ case ASCII_SQL:
+ return db2TableNameAscii; break;
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+ return NULL;
+ }
+
+ DB2Field& db2Field(int fieldID) const { return db2Fields[fieldID]; }
+ DB2Field& db2Field(const Field* field) const { return db2Field(field->field_index); }
+
+ void processFormatSpace();
+
+ void* getFormatSpace(size_t& spaceNeeded)
+ {
+ DBUG_ASSERT(formatSpace == NULL);
+ spaceNeeded = sizeof(format_hdr_t) + mysqlTable->fields * sizeof(DB2Field);
+ formatSpace.alloc(spaceNeeded);
+ return (void*)formatSpace;
+ }
+
+ bool isTemporary() const
+ {
+ return isTemporaryTable;
+ }
+
+ void getDB2QualifiedName(char* to);
+ static void getDB2LibNameFromPath(const char* path, char* lib, NameFormatFlags format=ASCII_SQL);
+ static void getDB2FileNameFromPath(const char* path, char* file, NameFormatFlags format=ASCII_SQL);
+ static void getDB2QualifiedNameFromPath(const char* path, char* to);
+ static int32 appendQualifiedIndexFileName(const char* indexName,
+ const char* tableName,
+ String& to,
+ NameFormatFlags format=ASCII_SQL,
+ enum_DB2I_INDEX_TYPE type=typeDefault);
+
+ uint16 getBlobIdFromField(uint16 fieldID) const
+ {
+ for (int i = 0; i < blobFieldCount; ++i)
+ {
+ if (blobFields[i] == fieldID)
+ return i;
+ }
+ DBUG_ASSERT(0);
+ return 0;
+ }
+
+ iconv_t& getConversionDefinition(enum_conversionDirection direction,
+ uint16 fieldID)
+ {
+ if (conversionDefinitions[direction][fieldID] == (iconv_t)(-1))
+ findConversionDefinition(direction, fieldID);
+
+ return conversionDefinitions[direction][fieldID];
+ }
+
+ const db2i_file* dataFile() const
+ {
+ return physicalFile;
+ }
+
+ const db2i_file* indexFile(uint idx) const
+ {
+ return logicalFiles[idx];
+ }
+
+ const char* getFileLevelID() const
+ {
+ return fileLevelID;
+ }
+
+ static void deleteAssocFiles(const char* name);
+ static void renameAssocFiles(const char* from, const char* to);
+
+ int fastInitForCreate(const char* path);
+ int initDiscoveredTable(const char* path);
+
+ uint16* blobFields;
+
+private:
+
+ void findConversionDefinition(enum_conversionDirection direction, uint16 fieldID);
+ static void filenameToTablename(const char* in, char* out, size_t outlen);
+ static size_t smartFilenameToTableName(const char *in, char* out, size_t outlen);
+ void convertNativeToSQLName(const char* input,
+ char* output)
+ {
+
+ output[0] = input[0];
+
+ uint o = 1;
+ uint i = 1;
+ do
+ {
+ output[o++] = input[i];
+ if (input[i] == '"' && input[i+1])
+ output[o++] = '"';
+ } while (input[++i]);
+
+ output[o] = 0; // This isn't the most user-friendly way to handle overflows,
+ // but at least its safe.
+ }
+
+ bool doFileIDsMatch(const char* path);
+
+ ValidatedPointer<format_hdr_t> formatSpace;
+ DB2Field* db2Fields;
+ uint64 db2StartId; // Starting value for identity column
+ uint16 blobFieldCount; // Count of LOB fields in the DB2 table
+ uint* blobFieldActualSizes; // Array of LOB field lengths (actual vs. allocated).
+ // This is updated as LOBs are read and will contain
+ // the length of the longest known LOB in that field.
+ iconv_t* conversionDefinitions[2];
+
+ const TABLE_SHARE* mysqlTable;
+ uint16 logicalFileCount;
+ char* db2LibNameEbcdic; // Quoted and in EBCDIC
+ char* db2LibNameAscii;
+ char* db2TableNameEbcdic;
+ char* db2TableNameAscii;
+ char* db2TableNameSQLAscii;
+ char* db2LibNameSQLAscii;
+
+ db2i_file* physicalFile;
+ db2i_file** logicalFiles;
+
+ bool isTemporaryTable;
+ char fileLevelID[13];
+};
+
+/**
+ @class db2i_file
+
+ @details This class describes a file object underlaying a particular SQL
+ table. Both "physical files" (data) and "logical files" (indices) are
+ described by this class. Only one instance of the class exists per DB2 file
+ object. The single instance is responsible for de/allocating the multiple
+ handles used by the handlers.
+*/
+class db2i_file
+{
+
+public:
+ struct RowFormat
+ {
+ uint16 readRowLen;
+ uint16 readRowNullOffset;
+ uint16 writeRowLen;
+ uint16 writeRowNullOffset;
+ char inited;
+ };
+
+public:
+
+ // Construct an instance for a physical file.
+ db2i_file(db2i_table* table);
+
+ // Construct an instance for a logical file.
+ db2i_file(db2i_table* table, int index);
+
+ ~db2i_file()
+ {
+ if (masterDefn)
+ db2i_ileBridge::getBridgeForThread()->deallocateFile(masterDefn);
+
+ if (db2FileName != (char*)db2Table->getDB2TableName(db2i_table::EBCDIC_NATIVE))
+ my_free(db2FileName, MYF(0));
+ }
+
+ // This is roughly equivalent to an "open". It tells ILE to allocate a descriptor
+ // for the file. The associated handle is returned to the caller.
+ int allocateNewInstance(FILE_HANDLE* newHandle, ILEMemHandle inuseSpace) const
+ {
+ int rc;
+
+ rc = db2i_ileBridge::getBridgeForThread()->allocateFileInstance(masterDefn,
+ inuseSpace,
+ newHandle);
+
+ if (rc) *newHandle = 0;
+
+ return rc;
+ }
+
+ // This obtains the row layout associated with a particular access intent for
+ // an open instance of the file.
+ int obtainRowFormat(FILE_HANDLE instanceHandle,
+ char intent,
+ char commitLevel,
+ const RowFormat** activeFormat) const
+ {
+ DBUG_ENTER("db2i_file::obtainRowFormat");
+ RowFormat* rowFormat;
+
+ if (intent == QMY_UPDATABLE)
+ rowFormat = &(formats[readWrite]);
+ else if (intent == QMY_READ_ONLY)
+ rowFormat = &(formats[readOnly]);
+
+ if (unlikely(!rowFormat->inited))
+ {
+ int rc = db2i_ileBridge::getBridgeForThread()->
+ initFileForIO(instanceHandle,
+ intent,
+ commitLevel,
+ &(rowFormat->writeRowLen),
+ &(rowFormat->writeRowNullOffset),
+ &(rowFormat->readRowLen),
+ &(rowFormat->readRowNullOffset));
+ if (rc) DBUG_RETURN(rc);
+ rowFormat->inited = 1;
+ }
+
+ *activeFormat = rowFormat;
+ DBUG_RETURN(0);
+ }
+
+ const char* getDB2FileName() const
+ {
+ return db2FileName;
+ }
+
+ void fillILEDefn(ShrDef* defn, bool readInArrivalSeq);
+
+ void setMasterDefnHandle(FILE_HANDLE handle)
+ {
+ masterDefn = handle;
+ }
+
+ FILE_HANDLE getMasterDefnHandle() const
+ {
+ return masterDefn;
+ }
+
+private:
+ enum RowFormats
+ {
+ readOnly = 0,
+ readWrite,
+ maxRowFormats
+ };
+
+ mutable RowFormat formats[maxRowFormats];
+
+ void commonCtorInit();
+
+ char* db2FileName; // Quoted and in EBCDIC
+
+ db2i_table* db2Table; // The logical SQL table contained by this file.
+
+ bool db2CanSort;
+
+ FILE_HANDLE masterDefn;
+};
+
+
+#endif
diff --git a/storage/ibmdb2i/db2i_global.h b/storage/ibmdb2i/db2i_global.h
new file mode 100644
index 00000000000..d201fbd8124
--- /dev/null
+++ b/storage/ibmdb2i/db2i_global.h
@@ -0,0 +1,138 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_GLOBAL_H
+#define DB2I_GLOBAL_H
+
+#define MYSQL_SERVER 1
+
+#include "my_global.h"
+#include "my_sys.h"
+
+const uint MAX_DB2_KEY_PARTS=120;
+const int MAX_DB2_V5R4_LIBNAME_LENGTH = 10;
+const int MAX_DB2_V6R1_LIBNAME_LENGTH = 30;
+const int MAX_DB2_SCHEMANAME_LENGTH=258;
+const int MAX_DB2_FILENAME_LENGTH=258;
+const int MAX_DB2_COLNAME_LENGTH=128;
+const int MAX_DB2_SAVEPOINTNAME_LENGTH=128;
+const int MAX_DB2_QUALIFIEDNAME_LENGTH=MAX_DB2_V6R1_LIBNAME_LENGTH + 1 + MAX_DB2_FILENAME_LENGTH;
+const uint32 MAX_CHAR_LENGTH = 32765;
+const uint32 MAX_VARCHAR_LENGTH = 32739;
+const uint32 MAX_DEC_PRECISION = 63;
+const uint32 MAX_BLOB_LENGTH = 2147483646;
+const uint32 MAX_BINARY_LENGTH = MAX_CHAR_LENGTH;
+const uint32 MAX_VARBINARY_LENGTH = MAX_VARCHAR_LENGTH;
+const uint32 MAX_FULL_ALLOCATE_BLOB_LENGTH = 65536;
+const uint32 MAX_FOREIGN_LEN = 64000;
+const char* DB2I_TEMP_TABLE_SCHEMA = "QTEMP";
+const char DB2I_ADDL_INDEX_NAME_DELIMITER[5] = {'_','_','_','_','_'};
+const char DB2I_DEFAULT_INDEX_NAME_DELIMITER[3] = {'_','_','_'};
+const int DB2I_INDEX_NAME_LENGTH_TO_PRESERVE = 110;
+
+enum enum_DB2I_INDEX_TYPE
+{
+ typeNone = 0,
+ typeDefault = 'D',
+ typeHex = 'H',
+ typeAscii = 'A'
+};
+
+void* roundToQuadWordBdy(void* ptr)
+{
+ return (void*)(((uint64)(ptr)+0xf) & ~0xf);
+}
+
+typedef uint64_t ILEMemHandle;
+
+struct OSVersion
+{
+ uint8 v;
+ uint8 r;
+};
+extern OSVersion osVersion;
+
+
+/**
+ Allocate 16-byte aligned space using the MySQL heap allocator
+
+ @details Many of the spaces used by the QMY_* APIS are required to be
+ aligned on 16 byte boundaries. The standard system malloc will do this
+ alignment by default. However, in order to use the heap debug and tracking
+ features of the mysql allocator, we chose to implement an aligning wrapper
+ around my_malloc. Essentially, we overallocate the storage space, find the
+ first aligned address in the space, store a pointer to the true malloc
+ allocation in the bytes immediately preceding the aligned address, and return
+ the aligned address to the caller.
+
+ @parm size The size of heap storage needed
+
+ @return A 16-byte aligned pointer to the storage requested.
+*/
+void* malloc_aligned(size_t size)
+{
+ char* p;
+ char* base;
+ base = (char*)my_malloc(size + sizeof(void*) + 15, MYF(MY_WME));
+ if (likely(base))
+ {
+ p = (char*)roundToQuadWordBdy(base + sizeof(void*));
+ char** p2 = (char**)(p - sizeof(void*));
+ *p2 = base;
+ }
+ else
+ p = NULL;
+
+ return p;
+}
+
+/**
+ Free a 16-byte aligned space alloced by malloc_aligned
+
+ @details We know that a pointer to the true malloced storage immediately
+ precedes the aligned address, so we pull that out and call my_free().
+
+ @parm p A 16-byte aligned pointer generated by malloc_aligned
+*/
+void free_aligned(void* p)
+{
+ if (likely(p))
+ {
+ my_free(*(char**)((char*)p-sizeof(void*)), MYF(0));
+ }
+}
+
+#endif
diff --git a/storage/ibmdb2i/db2i_iconv.h b/storage/ibmdb2i/db2i_iconv.h
new file mode 100644
index 00000000000..9fc6e4ed636
--- /dev/null
+++ b/storage/ibmdb2i/db2i_iconv.h
@@ -0,0 +1,51 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+/**
+ @file
+
+ @brief Used to redefine iconv symbols to the optimized "myconv" ones
+*/
+
+#ifndef DB2I_ICONV_H
+#define DB2I_ICONV_H
+
+#include "db2i_myconv.h"
+#define iconv_open(A, B) myconv_open(A, B, CONVERTER_DMAP)
+#define iconv_close myconv_close
+#define iconv myconv_dmap
+#define iconv_t myconv_t
+
+#endif
diff --git a/storage/ibmdb2i/db2i_ileBridge.cc b/storage/ibmdb2i/db2i_ileBridge.cc
new file mode 100644
index 00000000000..68ae2c2bb72
--- /dev/null
+++ b/storage/ibmdb2i/db2i_ileBridge.cc
@@ -0,0 +1,1342 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+
+#include "db2i_ileBridge.h"
+#include "my_dbug.h"
+#include "db2i_global.h"
+#include "db2i_charsetSupport.h"
+#include "db2i_errors.h"
+
+
+// static class member data
+ILEpointer* db2i_ileBridge::functionSymbols;
+db2i_ileBridge* db2i_ileBridge::globalBridge;
+#ifndef DBUG_OFF
+uint32 db2i_ileBridge::registeredPtrs;
+#endif
+
+pthread_key(IleParms*, THR_ILEPARMS);
+
+static void ileParmsDtor(void* parmsToFree)
+{
+ if (parmsToFree)
+ {
+ free_aligned(parmsToFree);
+ DBUG_PRINT("db2i_ileBridge", ("Freeing space for parms"));
+ }
+}
+
+
+/**
+ Convert a timestamp in ILE time format into a unix time_t
+*/
+static inline time_t convertILEtime(const ILE_time_t& input)
+{
+ tm temp;
+
+ temp.tm_sec = input.Second;
+ temp.tm_min = input.Minute;
+ temp.tm_hour = input.Hour;
+ temp.tm_mday = input.Day;
+ temp.tm_mon = input.Month-1;
+ temp.tm_year = input.Year - 1900;
+ temp.tm_isdst = -1;
+
+ return mktime(&temp);
+}
+
+/**
+ Allocate and intialize a new bridge structure
+*/
+db2i_ileBridge* db2i_ileBridge::createNewBridge(CONNECTION_HANDLE connID)
+{
+ DBUG_PRINT("db2i_ileBridge::createNewBridge",("Building new bridge..."));
+ db2i_ileBridge* newBridge = (db2i_ileBridge*)my_malloc(sizeof(db2i_ileBridge), MYF(MY_WME));
+
+ if (unlikely(newBridge == NULL))
+ return NULL;
+
+ newBridge->stmtTxActive = false;
+ newBridge->connErrText = NULL;
+ newBridge->pendingLockedHandles.head = NULL;
+ newBridge->cachedConnectionID = connID;
+
+ return newBridge;
+}
+
+
+void db2i_ileBridge::destroyBridge(db2i_ileBridge* bridge)
+{
+ bridge->freeErrorStorage();
+ my_free(bridge, MYF(0));
+}
+
+
+void db2i_ileBridge::destroyBridgeForThread(const THD* thd)
+{
+ void* thdData = *thd_ha_data(thd, ibmdb2i_hton);
+ if (thdData != NULL)
+ {
+ destroyBridge((db2i_ileBridge*)thdData);
+ }
+}
+
+
+void db2i_ileBridge::registerPtr(const void* ptr, ILEMemHandle* receiver)
+{
+ static const arg_type_t ileSignature[] = { ARG_MEMPTR, ARG_END };
+
+ if (unlikely(ptr == NULL))
+ {
+ *receiver = 0;
+ return;
+ }
+
+ struct ArgList
+ {
+ ILEarglist_base base;
+ ILEpointer ptr;
+ } *arguments;
+
+ char argBuf[sizeof(ArgList)+15];
+ arguments = (ArgList*)roundToQuadWordBdy(argBuf);
+
+ arguments->ptr.s.addr = (address64_t)(ptr);
+
+ _ILECALL(&functionSymbols[funcRegisterSpace],
+ &arguments->base,
+ ileSignature,
+ RESULT_INT64);
+
+#ifndef DBUG_OFF
+ uint32 truncHandle = arguments->base.result.r_uint64;
+ DBUG_PRINT("db2i_ileBridge::registerPtr",("Register 0x%p with handle %d", ptr, truncHandle));
+ getBridgeForThread()->registeredPtrs++;
+#endif
+
+ *receiver = arguments->base.result.r_uint64;
+ return;
+}
+
+void db2i_ileBridge::unregisterPtr(ILEMemHandle handle)
+{
+ static const arg_type_t ileSignature[] = { ARG_UINT64, ARG_END };
+
+ if (unlikely(handle == NULL))
+ return;
+
+ struct ArgList
+ {
+ ILEarglist_base base;
+ uint64 handle;
+ } *arguments;
+
+ char argBuf[sizeof(ArgList)+15];
+ arguments = (ArgList*)roundToQuadWordBdy(argBuf);
+
+ arguments->handle = (uint64)(handle);
+
+ _ILECALL(&functionSymbols[funcUnregisterSpace],
+ &arguments->base,
+ ileSignature,
+ RESULT_VOID);
+
+#ifndef DBUG_OFF
+ DBUG_PRINT("db2i_ileBridge::unregisterPtr",("Unregister handle %d", (uint32)handle));
+ getBridgeForThread()->registeredPtrs--;
+#endif
+}
+
+
+
+/**
+ Initialize the bridge component
+
+ @details Resolves srvpgm and function names of the APIs. If this fails,
+ the approrpiate operating system support (PTFs) is probably not installed.
+
+ WARNING:
+ Must be called before any other functions in this class are used!!!!
+ Can only be called by a single thread!
+*/
+int db2i_ileBridge::setup()
+{
+ static const char funcNames[db2i_ileBridge::funcListEnd][32] =
+ {
+ {"QmyRegisterParameterSpaces"},
+ {"QmyRegisterSpace"},
+ {"QmyUnregisterSpace"},
+ {"QmyProcessRequest"}
+ };
+
+ DBUG_ENTER("db2i_ileBridge::setup");
+
+ int actmark = _ILELOAD("QSYS/QMYSE", ILELOAD_LIBOBJ);
+ if ( actmark == -1 )
+ {
+ DBUG_PRINT("db2i_ileBridge::setup", ("srvpgm activation failed"));
+ DBUG_RETURN(1);
+ }
+
+ functionSymbols = (ILEpointer*)malloc_aligned(sizeof(ILEpointer) * db2i_ileBridge::funcListEnd);
+
+ for (int i = 0; i < db2i_ileBridge::funcListEnd; i++)
+ {
+ if (_ILESYM(&functionSymbols[i], actmark, funcNames[i]) == -1)
+ {
+ DBUG_PRINT("db2i_ileBridge::setup",
+ ("resolve of %s failed", funcNames[i]));
+ DBUG_RETURN(errno);
+ }
+ }
+
+ pthread_key_create(&THR_ILEPARMS, &ileParmsDtor);
+
+#ifndef DBUG_OFF
+ registeredPtrs = 0;
+#endif
+
+ globalBridge = createNewBridge(0);
+
+ DBUG_RETURN(0);
+}
+
+/**
+ Cleanup any resources before shutting down plug-in
+*/
+void db2i_ileBridge::takedown()
+{
+ if (globalBridge)
+ destroyBridge(globalBridge);
+ free_aligned(functionSymbols);
+}
+
+/**
+ Call off to QmyProcessRequest to perform the API that the caller prepared
+*/
+inline int32 db2i_ileBridge::doIt()
+{
+ static const arg_type_t ileSignature[] = {ARG_END};
+
+ struct ArgList
+ {
+ ILEarglist_base base;
+ } *arguments;
+
+ char argBuf[sizeof(ArgList)+15];
+ arguments = (ArgList*)roundToQuadWordBdy(argBuf);
+
+ _ILECALL(&functionSymbols[funcProcessRequest],
+ &arguments->base,
+ ileSignature,
+ RESULT_INT32);
+
+ return translateErrorCode(arguments->base.result.s_int32.r_int32);
+}
+
+/**
+ Call off to QmyProcessRequest to perform the API that the caller prepared and
+ log any errors that may occur.
+*/
+inline int32 db2i_ileBridge::doItWithLog()
+{
+ int32 rc = doIt();
+
+ if (unlikely(rc))
+ {
+ // Only report errors that we weren't expecting
+ if (rc != tacitErrors[0] &&
+ rc != tacitErrors[1] &&
+ rc != QMY_ERR_END_OF_BLOCK)
+ reportSystemAPIError(rc, (Qmy_Error_output_t*)parms()->outParms);
+ }
+ memset(tacitErrors, 0, sizeof(tacitErrors));
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_ALLOCATE_SHARE API
+
+ See QMY_ALLOCATE_SHARE documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::allocateFileDefn(ILEMemHandle definitionSpace,
+ ILEMemHandle handleSpace,
+ uint16 fileCount,
+ const char* schemaName,
+ uint16 schemaNameLength,
+ ILEMemHandle formatSpace,
+ uint32 formatSpaceLen)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+
+ IleParms* parmBlock = parms();
+ Qmy_MAOS0100 *input = (Qmy_MAOS0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_ALLOCATE_SHARE;
+ input->ShrDefSpcHnd = definitionSpace;
+ input->ShrHndSpcHnd = handleSpace;
+ input->ShrDefCnt = fileCount;
+ input->FmtSpcHnd = formatSpace;
+ input->FmtSpcLen = formatSpaceLen;
+
+ if (schemaNameLength > sizeof(input->SchNam))
+ {
+ // This should never happen!
+ DBUG_ASSERT(0);
+ return HA_ERR_GENERIC;
+ }
+
+ memcpy(input->SchNam, schemaName, schemaNameLength);
+ input->SchNamLen = schemaNameLength;
+
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_ALLOCATE_INSTANCE API
+
+ See QMY_ALLOCATE_INSTANCE documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::allocateFileInstance(FILE_HANDLE defnHandle,
+ ILEMemHandle inuseSpace,
+ FILE_HANDLE* instance)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+
+ IleParms* parmBlock = parms();
+ Qmy_MAOI0100 *input = (Qmy_MAOI0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_ALLOCATE_INSTANCE;
+ input->ShrHnd = defnHandle;
+ input->CnnHnd = cachedConnectionID;
+ input->UseSpcHnd = inuseSpace;
+
+ int32 rc = doItWithLog();
+
+ if (likely(rc == 0))
+ {
+ Qmy_MAOI0100_output* output = (Qmy_MAOI0100_output*)parmBlock->outParms;
+ DBUG_ASSERT(instance);
+ *instance = output->ObjHnd;
+ }
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_DEALLOCATE_OBJECT API
+
+ See QMY_DEALLOCATE_OBJECT documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::deallocateFile(FILE_HANDLE rfileHandle,
+ bool postDropTable)
+{
+ IleParms* parmBlock = parms();
+ Qmy_MDLC0100 *input = (Qmy_MDLC0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_DEALLOCATE_OBJECT;
+ input->ObjHnd = rfileHandle;
+ input->ObjDrp[0] = (postDropTable ? QMY_YES : QMY_NO);
+
+ DBUG_PRINT("db2i_ileBridge::deallocateFile", ("Deallocating %d", (uint32)rfileHandle));
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_OBJECT_INITIALIZATION API
+
+ See QMY_OBJECT_INITIALIZATION documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::initFileForIO(FILE_HANDLE rfileHandle,
+ char accessIntent,
+ char commitLevel,
+ uint16* inRecSize,
+ uint16* inRecNullOffset,
+ uint16* outRecSize,
+ uint16* outRecNullOffset)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MOIX0100 *input = (Qmy_MOIX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_OBJECT_INITIALIZATION;
+ input->CmtLvl[0] = commitLevel;
+ input->Intent[0] = accessIntent;
+ input->ObjHnd = rfileHandle;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ if (likely(rc == 0))
+ {
+ Qmy_MOIX0100_output* output = (Qmy_MOIX0100_output*)parmBlock->outParms;
+ *inRecSize = output->InNxtRowOff;
+ *inRecNullOffset = output->InNullMapOff;
+ *outRecSize = output->OutNxtRowOff;
+ *outRecNullOffset = output->OutNullMapOff;
+ }
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_READ_ROWS API for reading a row with a specific RRN.
+
+ See QMY_READ_ROWS documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::readByRRN(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ uint32 inRRN,
+ char accessIntent,
+ char commitLevel)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MRDX0100 *input = (Qmy_MRDX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_READ_ROWS;
+ input->CmtLvl[0] = commitLevel;
+ input->ObjHnd = rfileHandle;
+ input->Intent[0] = accessIntent;
+ input->OutSpcHnd = (uint64)buf;
+ input->RelRowNbr = inRRN;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ if (rc == QMY_ERR_END_OF_BLOCK)
+ {
+ rc = 0;
+ DBUG_PRINT("db2i_ileBridge::readByRRN", ("End of block signalled"));
+ }
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_WRITE_ROWS API.
+
+ See QMY_WRITE_ROWS documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::writeRows(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ char commitLevel,
+ int64* outIdVal,
+ bool* outIdGen,
+ uint32* dupKeyRRN,
+ char** dupKeyName,
+ uint32* dupKeyNameLen,
+ uint32* outIdIncrement)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MWRT0100 *input = (Qmy_MWRT0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_WRITE_ROWS;
+ input->CmtLvl[0] = commitLevel;
+
+ input->ObjHnd = rfileHandle;
+ input->InSpcHnd = (uint64_t) buf;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ Qmy_MWRT0100_output_t* output = (Qmy_MWRT0100_output_t*)parmBlock->outParms;
+ if (likely(rc == 0 || rc == HA_ERR_FOUND_DUPP_KEY))
+ {
+ DBUG_ASSERT(dupKeyRRN && dupKeyName && dupKeyNameLen && outIdGen && outIdIncrement && outIdVal);
+ *dupKeyRRN = output->DupRRN;
+ *dupKeyName = (char*)parmBlock->outParms + output->DupObjNamOff;
+ *dupKeyNameLen = output->DupObjNamLen;
+ *outIdGen = (output->NewIdGen[0] == QMY_YES ? TRUE : FALSE);
+ if (*outIdGen == TRUE)
+ {
+ *outIdIncrement = output->IdIncrement;
+ *outIdVal = output->NewIdVal;
+ }
+ }
+
+ return rc;
+
+}
+
+/**
+ Interface to QMY_EXECUTE_IMMEDIATE API.
+
+ See QMY_EXECUTE_IMMEDIATE documentation for more information about
+ parameters and return codes.
+*/
+uint32 db2i_ileBridge::execSQL(const char* statement,
+ uint32 statementCount,
+ uint8 commitLevel,
+ bool autoCreateSchema,
+ bool dropSchema,
+ bool noCommit,
+ FILE_HANDLE fileHandle)
+
+{
+ IleParms* parmBlock = parms();
+ Qmy_MSEI0100 *input = (Qmy_MSEI0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_EXECUTE_IMMEDIATE;
+
+ registerPtr(statement, &input->StmtsSpcHnd);
+
+ input->NbrStmts = statementCount;
+ *(uint16*)(&input->StmtCCSID) = 850;
+ input->AutoCrtSchema[0] = (autoCreateSchema == TRUE ? QMY_YES : QMY_NO);
+ input->DropSchema[0] = (dropSchema == TRUE ? QMY_YES : QMY_NO);
+ input->CmtLvl[0] = commitLevel;
+ if ((commitLevel == QMY_NONE && statementCount == 1) || noCommit)
+ {
+ input->CmtBefore[0] = QMY_NO;
+ input->CmtAfter[0] = QMY_NO;
+ }
+ else
+ {
+ input->CmtBefore[0] = QMY_YES;
+ input->CmtAfter[0] = QMY_YES;
+ }
+ input->CnnHnd = current_thd->thread_id;
+ input->ObjHnd = fileHandle;
+
+ int32 rc = doItWithLog();
+
+ unregisterPtr(input->StmtsSpcHnd);
+
+ return rc;
+}
+
+/**
+ Interface to QMY_PREPARE_OPEN_CURSOR API.
+
+ See QMY_PREPARE_OPEN_CURSOR documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::prepOpen(const char* statement,
+ FILE_HANDLE* rfileHandle,
+ uint32* recLength)
+{
+ IleParms* parmBlock = parms();
+ Qmy_MSPO0100 *input = (Qmy_MSPO0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_PREPARE_OPEN_CURSOR;
+
+ registerPtr(statement, &input->StmtsSpcHnd );
+ *(uint16*)(&input->StmtCCSID) = 850;
+ input->CnnHnd = current_thd->thread_id;
+
+ int32 rc = doItWithLog();
+
+ if (likely(rc == 0))
+ {
+ Qmy_MSPO0100_output* output = (Qmy_MSPO0100_output*)parmBlock->outParms;
+ *rfileHandle = output->ObjHnd;
+ *recLength = max(output->InNxtRowOff, output->OutNxtRowOff);
+ }
+
+
+ unregisterPtr(input->StmtsSpcHnd);
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_DELETE_ROW API.
+
+ See QMY_DELETE_ROW documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::deleteRow(FILE_HANDLE rfileHandle,
+ uint32 rrn)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MDLT0100 *input = (Qmy_MDLT0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_DELETE_ROW;
+ input->ObjHnd = rfileHandle;
+ input->RelRowNbr = rrn;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_UPDATE_ROW API.
+
+ See QMY_UPDATE_ROW documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::updateRow(FILE_HANDLE rfileHandle,
+ uint32 rrn,
+ ILEMemHandle buf,
+ uint32* dupKeyRRN,
+ char** dupKeyName,
+ uint32* dupKeyNameLen)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MUPD0100 *input = (Qmy_MUPD0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_UPDATE_ROW;
+ input->ObjHnd = rfileHandle;
+ input->InSpcHnd = (uint64)buf;
+ input->RelRowNbr = rrn;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ if (rc == HA_ERR_FOUND_DUPP_KEY)
+ {
+ Qmy_MUPD0100_output* output = (Qmy_MUPD0100_output*)parmBlock->outParms;
+ DBUG_ASSERT(dupKeyRRN && dupKeyName && dupKeyNameLen);
+ *dupKeyRRN = output->DupRRN;
+ *dupKeyName = (char*)parmBlock->outParms + output->DupObjNamOff;
+ *dupKeyNameLen = output->DupObjNamLen;
+ }
+
+ return rc;
+}
+
+/**
+ Interface to QMY_DESCRIBE_RANGE API.
+
+ See QMY_DESCRIBE_RANGE documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::recordsInRange(FILE_HANDLE defnHandle,
+ ILEMemHandle inSpc,
+ uint32 inKeyCnt,
+ uint32 inLiteralCnt,
+ uint32 inBoundsOff,
+ uint32 inLitDefOff,
+ uint32 inLiteralsOff,
+ uint32 inCutoff,
+ uint32 inSpcLen,
+ uint16 inEndByte,
+ uint64* outRecCnt,
+ uint16* outRtnCode)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+
+ IleParms* parmBlock = parms();
+ Qmy_MDRG0100 *input = (Qmy_MDRG0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_DESCRIBE_RANGE;
+ input->ShrHnd = defnHandle;
+ input->SpcHnd = (uint64)inSpc;
+ input->KeyCnt = inKeyCnt;
+ input->LiteralCnt = inLiteralCnt;
+ input->BoundsOff = inBoundsOff;
+ input->LitDefOff = inLitDefOff;
+ input->LiteralsOff = inLiteralsOff;
+ input->Cutoff = inCutoff;
+ input->SpcLen = inSpcLen;
+ input->EndByte = inEndByte;
+ input->CnnHnd = cachedConnectionID;
+
+ int rc = doItWithLog();
+
+ if (likely(rc == 0))
+ {
+ Qmy_MDRG0100_output* output = (Qmy_MDRG0100_output*)parmBlock->outParms;
+ DBUG_ASSERT(outRecCnt && outRtnCode);
+ *outRecCnt = output->RecCnt;
+ *outRtnCode = output->RtnCode;
+ }
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_RELEASE_ROW API.
+
+ See QMY_RELEASE_ROW documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::rrlslck(FILE_HANDLE rfileHandle, char accessIntent)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+
+ IleParms* parmBlock = parms();
+ Qmy_MRRX0100 *input = (Qmy_MRRX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_RELEASE_ROW;
+
+ input->ObjHnd = rfileHandle;
+ input->CnnHnd = cachedConnectionID;
+ input->Intent[0] = accessIntent;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+/**
+ Interface to QMY_LOCK_OBJECT API.
+
+ See QMY_LOCK_OBJECT documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::lockObj(FILE_HANDLE defnHandle,
+ uint64 lockVal,
+ char lockAction,
+ char lockType,
+ char lockTimeout)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MOLX0100 *input = (Qmy_MOLX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_LOCK_OBJECT;
+ input->ShrHnd = defnHandle;
+ input->LckTimeoutVal = lockVal;
+ input->Action[0] = lockAction;
+ input->LckTyp[0] = lockType;
+ input->LckTimeout[0] = lockTimeout;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+/**
+ Interface to QMY_DESCRIBE_CONSTRAINTS API.
+
+ See QMY_DESCRIBE_CONSTRAINTS documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::constraints(FILE_HANDLE defnHandle,
+ ILEMemHandle inSpc,
+ uint32 inSpcLen,
+ uint32* outLen,
+ uint32* outCnt)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MDCT0100 *input = (Qmy_MDCT0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_DESCRIBE_CONSTRAINTS;
+ input->ShrHnd = defnHandle;
+ input->CstSpcHnd = (uint64)inSpc;
+ input->CstSpcLen = inSpcLen;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ if (likely(rc == 0))
+ {
+ Qmy_MDCT0100_output* output = (Qmy_MDCT0100_output*)parmBlock->outParms;
+ DBUG_ASSERT(outLen && outCnt);
+ *outLen = output->NeededLen;
+ *outCnt = output->CstCnt;
+ }
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_REORGANIZE_TABLE API.
+
+ See QMY_REORGANIZE_TABLE documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::optimizeTable(FILE_HANDLE defnHandle)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MRGX0100 *input = (Qmy_MRGX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_REORGANIZE_TABLE;
+ input->ShrHnd = defnHandle;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_PROCESS_COMMITMENT_CONTROL API.
+
+ See QMY_PROCESS_COMMITMENT_CONTROL documentation for more information about
+ parameters and return codes.
+*/
+int32 db2i_ileBridge::commitmentControl(uint8 function)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MCCX0100 *input = (Qmy_MCCX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_PROCESS_COMMITMENT_CONTROL;
+ input->Function[0] = function;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_PROCESS_SAVEPOINT API.
+
+ See QMY_PROCESS_SAVEPOINT documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::savepoint(uint8 function,
+ const char* savepointName)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ DBUG_PRINT("db2i_ileBridge::savepoint",("%d %s", (uint32)function, savepointName));
+
+ IleParms* parmBlock = parms();
+ Qmy_MSPX0100 *input = (Qmy_MSPX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ char* savPtNam = (char*)(input+1);
+
+ input->Format = QMY_PROCESS_SAVEPOINT;
+
+ if (strlen(savepointName) > MAX_DB2_SAVEPOINTNAME_LENGTH)
+ {
+ DBUG_ASSERT(0);
+ return HA_ERR_GENERIC;
+ }
+ strcpy(savPtNam, savepointName);
+
+ input->Function[0] = function;
+ input->SavPtNamOff = savPtNam - (char*)(input);
+ input->SavPtNamLen = strlen(savepointName);
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+static ILEMemHandle traceSpcHandle;
+/**
+ Do initialization for the QMY_* APIs.
+
+ @parm aspName The name of the relational database to use for all
+ connections.
+
+ @return 0 if successful; error otherwise
+*/
+int32 db2i_ileBridge::initILE(const char* aspName,
+ uint16* traceCtlPtr)
+{
+ // We forego the typical thread-based parms space because MySQL doesn't
+ // allow us to clean it up before checking for memory leaks. As a result
+ // we get a complaint about leaked memory on server shutdown.
+ int32 rc;
+ char inParms[db2i_ileBridge_MAX_INPARM_SIZE];
+ char outParms[db2i_ileBridge_MAX_OUTPARM_SIZE];
+ if (rc = registerParmSpace(inParms, outParms))
+ {
+ reportSystemAPIError(rc, NULL);
+ return rc;
+ }
+
+ registerPtr(traceCtlPtr, &traceSpcHandle);
+
+ struct ParmBlock
+ {
+ Qmy_MINI0100 parms;
+ } *parmBlock = (ParmBlock*)inParms;
+
+ memset(inParms, 0, sizeof(ParmBlock));
+
+ parmBlock->parms.Format = QMY_INITIALIZATION;
+
+ char paddedName[18];
+ if (strlen(aspName) > sizeof(paddedName))
+ {
+ getErrTxt(DB2I_ERR_BAD_RDB_NAME);
+ return DB2I_ERR_BAD_RDB_NAME;
+ }
+
+ memset(paddedName, ' ', sizeof(paddedName));
+ memcpy(paddedName, aspName, strlen(aspName));
+ convToEbcdic(paddedName, parmBlock->parms.RDBName, strlen(paddedName));
+
+ parmBlock->parms.RDBNamLen = strlen(paddedName);
+ parmBlock->parms.TrcSpcHnd = traceSpcHandle;
+
+ rc = doIt();
+
+ if (rc)
+ {
+ reportSystemAPIError(rc, (Qmy_Error_output_t*)outParms);
+ }
+
+ return rc;
+}
+
+/**
+ Signal to the QMY_ APIs to perform any cleanup they need to do.
+*/
+int32 db2i_ileBridge::exitILE()
+{
+ IleParms* parmBlock = parms();
+ Qmy_MCLN0100 *input = (Qmy_MCLN0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_CLEANUP;
+
+ int32 rc = doIt();
+
+ if (rc)
+ {
+ reportSystemAPIError(rc, (Qmy_Error_output_t*)parmBlock->outParms);
+ }
+
+ unregisterPtr(traceSpcHandle);
+
+ DBUG_PRINT("db2i_ileBridge::exitILE", ("Registered ptrs remaining: %d", registeredPtrs));
+#ifndef DBUG_OFF
+ if (registeredPtrs != 0)
+ printf("Oh no! IBMDB2I left some pointers registered. Count was %d.\n", registeredPtrs);
+#endif
+
+ // This is needed to prevent SAFE_MALLOC from complaining at process termination.
+ my_pthread_setspecific_ptr(THR_ILEPARMS, NULL);
+ free_aligned(parmBlock);
+
+ return rc;
+
+}
+
+
+/**
+ Designate the specified addresses as parameter passing buffers.
+
+ @parm in Input to the API will go here; format is defined by the individual API
+ @parm out Output from the API will be; format is defined by the individual API
+
+ @return 0 if success; error otherwise
+*/
+int db2i_ileBridge::registerParmSpace(char* in, char* out)
+{
+ static const arg_type_t ileSignature[] = { ARG_MEMPTR, ARG_MEMPTR, ARG_END };
+
+ struct ArgList
+ {
+ ILEarglist_base base;
+ ILEpointer input;
+ ILEpointer output;
+ } *arguments;
+
+ char argBuf[sizeof(ArgList)+15];
+ arguments = (ArgList*)roundToQuadWordBdy(argBuf);
+
+ arguments->input.s.addr = (address64_t)(in);
+ arguments->output.s.addr = (address64_t)(out);
+
+ _ILECALL(&functionSymbols[funcRegisterParameterSpaces],
+ &arguments->base,
+ ileSignature,
+ RESULT_INT32);
+
+ return arguments->base.result.s_int32.r_int32;
+}
+
+
+/**
+ Interface to QMY_OBJECT_OVERRIDE API.
+
+ See QMY_OBJECT_OVERRIDE documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::objectOverride(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ uint32 recordWidth)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MOOX0100 *input = (Qmy_MOOX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_OBJECT_OVERRIDE;
+ input->ObjHnd = rfileHandle;
+ input->OutSpcHnd = (uint64)buf;
+ input->NxtRowOff = recordWidth;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+/**
+ Interface to QMY_DESCRIBE_OBJECT API for obtaining table stats.
+
+ See QMY_DESCRIBE_OBJECT documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::retrieveTableInfo(FILE_HANDLE defnHandle,
+ uint16 dataRequested,
+ ha_statistics& stats,
+ ILEMemHandle inSpc)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MDSO0100 *input = (Qmy_MDSO0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_DESCRIBE_OBJECT;
+ input->ShrHnd = defnHandle;
+ input->CnnHnd = cachedConnectionID;
+
+ if (dataRequested & objLength)
+ input->RtnObjLen[0] = QMY_YES;
+ if (dataRequested & rowCount)
+ input->RtnRowCnt[0] = QMY_YES;
+ if (dataRequested & deletedRowCount)
+ input->RtnDltRowCnt[0] = QMY_YES;
+ if (dataRequested & rowsPerKey)
+ {
+ input->RowKeyHnd = (uint64)inSpc;
+ input->RtnRowKey[0] = QMY_YES;
+ }
+ if (dataRequested & meanRowLen)
+ input->RtnMeanRowLen[0] = QMY_YES;
+ if (dataRequested & lastModTime)
+ input->RtnModTim[0] = QMY_YES;
+ if (dataRequested & createTime)
+ input->RtnCrtTim[0] = QMY_YES;
+ if (dataRequested & ioCount)
+ input->RtnEstIoCnt[0] = QMY_YES;
+
+ int32 rc = doItWithLog();
+
+ if (likely(rc == 0))
+ {
+ Qmy_MDSO0100_output* output = (Qmy_MDSO0100_output*)parmBlock->outParms;
+ if (dataRequested & objLength)
+ stats.data_file_length = output->ObjLen;
+ if (dataRequested & rowCount)
+ stats.records= output->RowCnt;
+ if (dataRequested & deletedRowCount)
+ stats.deleted = output->DltRowCnt;
+ if (dataRequested & meanRowLen)
+ stats.mean_rec_length = output->MeanRowLen;
+ if (dataRequested & lastModTime)
+ stats.update_time = convertILEtime(output->ModTim);
+ if (dataRequested & createTime)
+ stats.create_time = convertILEtime(output->CrtTim);
+ if (dataRequested & ioCount)
+ stats.data_file_length = output->EstIoCnt;
+ }
+
+ return rc;
+}
+
+/**
+ Interface to QMY_DESCRIBE_OBJECT API for finding index size.
+
+ See QMY_DESCRIBE_OBJECT documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::retrieveIndexInfo(FILE_HANDLE defnHandle,
+ uint64* outPageCnt)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MDSO0100 *input = (Qmy_MDSO0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_DESCRIBE_OBJECT;
+ input->ShrHnd = defnHandle;
+ input->CnnHnd = cachedConnectionID;
+ input->RtnPageCnt[0] = QMY_YES;
+
+ int32 rc = doItWithLog();
+
+ if (likely(rc == 0))
+ {
+ Qmy_MDSO0100_output* output = (Qmy_MDSO0100_output*)parmBlock->outParms;
+ *outPageCnt = output->PageCnt;
+ }
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_CLOSE_CONNECTION API
+
+ See QMY_CLOSE_CONNECTION documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::closeConnection(CONNECTION_HANDLE conn)
+{
+ IleParms* parmBlock = parms();
+ Qmy_MCCN0100 *input = (Qmy_MCCN0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_CLOSE_CONNECTION;
+ input->CnnHnd = conn;
+
+ int32 rc = doItWithLog();
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_INTERRUPT API
+
+ See QMY_INTERRUPT documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::readInterrupt(FILE_HANDLE fileHandle)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MINT0100 *input = (Qmy_MINT0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_INTERRUPT;
+ input->CnnHnd = cachedConnectionID;
+ input->ObjHnd = fileHandle;
+
+ int32 rc = doItWithLog();
+
+ if (rc == QMY_ERR_END_OF_BLOCK)
+ {
+ rc = 0;
+ DBUG_PRINT("db2i_ileBridge::readInterrupt", ("End of block signalled"));
+ }
+
+ return rc;
+}
+
+/**
+ Interface to QMY_READ_ROWS API
+
+ See QMY_READ_ROWS documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::read(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ char accessIntent,
+ char commitLevel,
+ char orientation,
+ bool asyncRead,
+ ILEMemHandle rrn,
+ ILEMemHandle key,
+ uint32 keylen,
+ uint16 keyParts,
+ int pipeFD)
+{
+ DBUG_ASSERT(cachedStateIsCoherent());
+ IleParms* parmBlock = parms();
+ Qmy_MRDX0100 *input = (Qmy_MRDX0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_READ_ROWS;
+ input->CmtLvl[0] = commitLevel;
+
+ input->ObjHnd = rfileHandle;
+ input->Intent[0] = accessIntent;
+ input->OutSpcHnd = (uint64)buf;
+ input->OutRRNSpcHnd = (uint64)rrn;
+ input->RtnData[0] = QMY_RETURN_DATA;
+
+ if (key)
+ {
+ input->KeySpcHnd = (uint64)key;
+ input->KeyColsLen = keylen;
+ input->KeyColsNbr = keyParts;
+ }
+
+ input->Async[0] = (asyncRead ? QMY_YES : QMY_NO);
+ input->PipeDesc = pipeFD;
+ input->Orientation[0] = orientation;
+ input->CnnHnd = cachedConnectionID;
+
+ int32 rc = doItWithLog();
+
+ // QMY_ERR_END_OF_BLOCK is informational only, so we ignore it.
+ if (rc == QMY_ERR_END_OF_BLOCK)
+ {
+ rc = 0;
+ DBUG_PRINT("db2i_ileBridge::read", ("End of block signalled"));
+ }
+
+ return rc;
+}
+
+
+/**
+ Interface to QMY_QUIESCE_OBJECT API
+
+ See QMY_QUIESCE_OBJECT documentation for more information about parameters and
+ return codes.
+*/
+int32 db2i_ileBridge::quiesceFileInstance(FILE_HANDLE rfileHandle)
+{
+ IleParms* parmBlock = parms();
+ Qmy_MQSC0100 *input = (Qmy_MQSC0100*)&(parmBlock->inParms);
+ memset(input, 0, sizeof(*input));
+
+ input->Format = QMY_QUIESCE_OBJECT;
+ input->ObjHnd = rfileHandle;
+
+ int32 rc = doItWithLog();
+
+#ifndef DBUG_OFF
+ if (unlikely(rc))
+ {
+ DBUG_ASSERT(0);
+ }
+#endif
+
+ return rc;
+}
+
+void db2i_ileBridge::PreservedHandleList::add(const char* newname, FILE_HANDLE newhandle, IBMDB2I_SHARE* share)
+{
+ NameHandlePair *newPair = (NameHandlePair*)my_malloc(sizeof(NameHandlePair), MYF(MY_WME));
+
+ newPair->next = head;
+ head = newPair;
+
+ strcpy(newPair->name, newname);
+ newPair->handle = newhandle;
+ newPair->share = share;
+ DBUG_PRINT("db2i_ileBridge", ("Added handle %d for %s", uint32(newhandle), newname));
+}
+
+
+FILE_HANDLE db2i_ileBridge::PreservedHandleList::findAndRemove(const char* fileName, IBMDB2I_SHARE** share)
+{
+ NameHandlePair* current = head;
+ NameHandlePair* prev = NULL;
+
+ while (current)
+ {
+ NameHandlePair* next = current->next;
+ if (strcmp(fileName, current->name) == 0)
+ {
+ FILE_HANDLE tmp = current->handle;
+ *share = current->share;
+ if (prev)
+ prev->next = next;
+ if (current == head)
+ head = next;
+ my_free(current, MYF(0));
+ DBUG_PRINT("db2i_ileBridge", ("Found handle %d for %s", uint32(tmp), fileName));
+ return tmp;
+ }
+ prev = current;
+ current = next;
+ }
+
+ return 0;
+}
+
+
+IleParms* db2i_ileBridge::initParmsForThread()
+{
+
+ IleParms* p = (IleParms*)malloc_aligned(sizeof(IleParms));
+ DBUG_ASSERT((uint64)(&(p->outParms))% 16 == 0); // Guarantee that outParms are aligned correctly
+
+ if (likely(p))
+ {
+ int32 rc = registerParmSpace((p->inParms), (p->outParms));
+ if (likely(rc == 0))
+ {
+ my_pthread_setspecific_ptr(THR_ILEPARMS, p);
+ DBUG_PRINT("db2i_ileBridge", ("Inited space for parms"));
+ return p;
+ }
+ else
+ reportSystemAPIError(rc, NULL);
+ }
+
+ return NULL;
+}
+
diff --git a/storage/ibmdb2i/db2i_ileBridge.h b/storage/ibmdb2i/db2i_ileBridge.h
new file mode 100644
index 00000000000..10b9820d983
--- /dev/null
+++ b/storage/ibmdb2i/db2i_ileBridge.h
@@ -0,0 +1,499 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_ILEBRIDGE_H
+#define DB2I_ILEBRIDGE_H
+
+#include "db2i_global.h"
+#include "mysql_priv.h"
+#include "as400_types.h"
+#include "as400_protos.h"
+#include "qmyse.h"
+#include "db2i_errors.h"
+
+typedef uint64_t FILE_HANDLE;
+typedef my_thread_id CONNECTION_HANDLE;
+const char SAVEPOINT_NAME[] = {0xD4,0xE2,0xD7,0xC9,0xD5,0xE3,0xC5,0xD9,0xD5,0x0};
+const uint32 TACIT_ERRORS_SIZE=2;
+
+enum db2i_InfoRequestSpec
+{
+ objLength = 1,
+ rowCount = 2,
+ deletedRowCount = 4,
+ rowsPerKey = 8,
+ meanRowLen = 16,
+ lastModTime = 32,
+ createTime = 64,
+ ioCount = 128
+};
+
+extern handlerton *ibmdb2i_hton;
+struct IBMDB2I_SHARE;
+
+const uint32 db2i_ileBridge_MAX_INPARM_SIZE = 512;
+const uint32 db2i_ileBridge_MAX_OUTPARM_SIZE = 512;
+
+extern pthread_key(IleParms*, THR_ILEPARMS);
+struct IleParms
+{
+ char inParms[db2i_ileBridge_MAX_INPARM_SIZE];
+ char outParms[db2i_ileBridge_MAX_OUTPARM_SIZE];
+};
+
+/**
+ @class db2i_ileBridge
+
+ Implements a connection-based interface to the QMY_* APIs
+
+ @details Each client connection that touches an IBMDB2I table has a "bridge"
+ associated with it. This bridge is constructed on first use and provides a
+ more C-like interface to the APIs. As well, it is reponsible for tracking
+ connection scoped information such as statement transaction state and error
+ message text. The bridge is destroyed when the connection ends.
+*/
+class db2i_ileBridge
+{
+ enum ileFuncs
+ {
+ funcRegisterParameterSpaces,
+ funcRegisterSpace,
+ funcUnregisterSpace,
+ funcProcessRequest,
+ funcListEnd
+ };
+
+ static db2i_ileBridge* globalBridge;
+public:
+
+
+ static int setup();
+ static void takedown();
+
+ /**
+ Obtain a pointer to the bridge for the current connection.
+
+ If a MySQL client connection is on the stack, we get the associated brideg.
+ Otherwise, we use the globalBridge.
+ */
+ static db2i_ileBridge* getBridgeForThread()
+ {
+ THD* thd = current_thd;
+ if (likely(thd))
+ return getBridgeForThread(thd);
+
+ return globalBridge;
+ }
+
+ /**
+ Obtain a pointer to the bridge for the specified connection.
+
+ If a bridge exists already, we return it immediately. Otherwise, prepare
+ a new bridge for the connection.
+ */
+ static db2i_ileBridge* getBridgeForThread(const THD* thd)
+ {
+ void* thdData = *thd_ha_data(thd, ibmdb2i_hton);
+ if (likely(thdData != NULL))
+ return (db2i_ileBridge*)(thdData);
+
+ db2i_ileBridge* newBridge = createNewBridge(thd->thread_id);
+ *thd_ha_data(thd, ibmdb2i_hton) = (void*)newBridge;
+ return newBridge;
+ }
+
+ static void destroyBridgeForThread(const THD* thd);
+ static void registerPtr(const void* ptr, ILEMemHandle* receiver);
+ static void unregisterPtr(ILEMemHandle handle);
+ int32 allocateFileDefn(ILEMemHandle definitionSpace,
+ ILEMemHandle handleSpace,
+ uint16 fileCount,
+ const char* schemaName,
+ uint16 schemaNameLength,
+ ILEMemHandle formatSpace,
+ uint32 formatSpaceLen);
+ int32 allocateFileInstance(FILE_HANDLE defnHandle,
+ ILEMemHandle inuseSpace,
+ FILE_HANDLE* instance);
+ int32 deallocateFile(FILE_HANDLE fileHandle,
+ bool postDropTable=FALSE);
+ int32 read(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ char accessIntent,
+ char commitLevel,
+ char orientation,
+ bool asyncRead = FALSE,
+ ILEMemHandle rrn = 0,
+ ILEMemHandle key = 0,
+ uint32 keylen = 0,
+ uint16 keyParts = 0,
+ int pipeFD = -1);
+ int32 readByRRN(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ uint32 inRRN,
+ char accessIntent,
+ char commitLevel);
+ int32 writeRows(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ char commitLevel,
+ int64* outIdVal,
+ bool* outIdGen,
+ uint32* dupKeyRRN,
+ char** dupKeyName,
+ uint32* dupKeyNameLen,
+ uint32* outIdIncrement);
+ uint32 execSQL(const char* statement,
+ uint32 statementCount,
+ uint8 commitLevel,
+ bool autoCreateSchema = FALSE,
+ bool dropSchema = FALSE,
+ bool noCommit = FALSE,
+ FILE_HANDLE fileHandle = 0);
+ int32 prepOpen(const char* statement,
+ FILE_HANDLE* rfileHandle,
+ uint32* recLength);
+ int32 deleteRow(FILE_HANDLE rfileHandle,
+ uint32 rrn);
+ int32 updateRow(FILE_HANDLE rfileHandle,
+ uint32 rrn,
+ ILEMemHandle buf,
+ uint32* dupKeyRRN,
+ char** dupKeyName,
+ uint32* dupKeyNameLen);
+ int32 commitmentControl(uint8 function);
+ int32 savepoint(uint8 function,
+ const char* savepointName);
+ int32 recordsInRange(FILE_HANDLE rfileHandle,
+ ILEMemHandle inSpc,
+ uint32 inKeyCnt,
+ uint32 inLiteralCnt,
+ uint32 inBoundsOff,
+ uint32 inLitDefOff,
+ uint32 inLiteralsOff,
+ uint32 inCutoff,
+ uint32 inSpcLen,
+ uint16 inEndByte,
+ uint64* outRecCnt,
+ uint16* outRtnCode);
+ int32 rrlslck(FILE_HANDLE rfileHandle,
+ char accessIntent);
+ int32 lockObj(FILE_HANDLE rfileHandle,
+ uint64 inTimeoutVal,
+ char inAction,
+ char inLockType,
+ char inTimeout);
+ int32 constraints(FILE_HANDLE rfileHandle,
+ ILEMemHandle inSpc,
+ uint32 inSpcLen,
+ uint32* outLen,
+ uint32* outCnt);
+ int32 optimizeTable(FILE_HANDLE rfileHandle);
+ static int32 initILE(const char* aspName,
+ uint16* traceCtlPtr);
+ int32 initFileForIO(FILE_HANDLE rfileHandle,
+ char accessIntent,
+ char commitLevel,
+ uint16* inRecSize,
+ uint16* inRecNullOffset,
+ uint16* outRecSize,
+ uint16* outRecNullOffset);
+ int32 readInterrupt(FILE_HANDLE fileHandle);
+ static int32 exitILE();
+
+ int32 objectOverride(FILE_HANDLE rfileHandle,
+ ILEMemHandle buf,
+ uint32 recordWidth = 0);
+
+ int32 retrieveTableInfo(FILE_HANDLE rfileHandle,
+ uint16 dataRequested,
+ ha_statistics& stats,
+ ILEMemHandle inSpc = NULL);
+
+ int32 retrieveIndexInfo(FILE_HANDLE rfileHandle,
+ uint64* outPageCnt);
+
+ int32 closeConnection(CONNECTION_HANDLE conn);
+ int32 quiesceFileInstance(FILE_HANDLE rfileHandle);
+
+ /**
+ Mark the beginning of a "statement transaction"
+
+ @detail MySQL "statement transactions" (see sql/handler.cc) are implemented
+ as DB2 savepoints having a predefined name.
+
+ @return 0 if successful; error otherwise
+ */
+ uint32 beginStmtTx()
+ {
+ DBUG_ENTER("db2i_ileBridge::beginStmtTx");
+ if (stmtTxActive)
+ DBUG_RETURN(0);
+
+ stmtTxActive = true;
+
+ DBUG_RETURN(savepoint(QMY_SET_SAVEPOINT, SAVEPOINT_NAME));
+ }
+
+ /**
+ Commit a "statement transaction"
+
+ @return 0 if successful; error otherwise
+ */
+ uint32 commitStmtTx()
+ {
+ DBUG_ENTER("db2i_ileBridge::commitStmtTx");
+ DBUG_ASSERT(stmtTxActive);
+ stmtTxActive = false;
+ DBUG_RETURN(savepoint(QMY_RELEASE_SAVEPOINT, SAVEPOINT_NAME));
+ }
+
+ /**
+ Roll back a "statement transaction"
+
+ @return 0 if successful; error otherwise
+ */
+ uint32 rollbackStmtTx()
+ {
+ DBUG_ENTER("db2i_ileBridge::rollbackStmtTx");
+ DBUG_ASSERT(stmtTxActive);
+ stmtTxActive = false;
+ DBUG_RETURN(savepoint(QMY_ROLLBACK_SAVEPOINT, SAVEPOINT_NAME));
+ }
+
+
+ /**
+ Provide storage for generating error messages.
+
+ This storage must persist until the error message is retrieved from the
+ handler instance. It is for this reason that we associate it with the bridge.
+
+ @return Pointer to heap storage of MYSQL_ERRMSG_SIZE bytes
+ */
+ char* getErrorStorage()
+ {
+ if (!connErrText)
+ {
+ connErrText = (char*)my_malloc(MYSQL_ERRMSG_SIZE, MYF(MY_WME));
+ if (connErrText) connErrText[0] = 0;
+ }
+
+ return connErrText;
+ }
+
+ /**
+ Free storage for generating error messages.
+ */
+ void freeErrorStorage()
+ {
+ if (likely(connErrText))
+ {
+ my_free(connErrText, MYF(0));
+ connErrText = NULL;
+ }
+ }
+
+
+ /**
+ Store a file handle for later retrieval.
+
+ If deallocateFile encounters a lock when trying to perform its operation,
+ the file remains allocated but must be deallocated later. This function
+ provides a way for the connection to "remember" that this deallocation is
+ still needed.
+
+ @param newname The name of the file to be added
+ @param newhandle The handle associated with newname
+
+ */
+ void preserveHandle(const char* newname, FILE_HANDLE newhandle, IBMDB2I_SHARE* share)
+ {
+ pendingLockedHandles.add(newname, newhandle, share);
+ }
+
+ /**
+ Retrieve a file handle stored by preserveHandle().
+
+ @param name The name of the file to be retrieved.
+
+ @return The handle associated with name
+ */
+ FILE_HANDLE findAndRemovePreservedHandle(const char* name, IBMDB2I_SHARE** share)
+ {
+ FILE_HANDLE hdl = pendingLockedHandles.findAndRemove(name, share);
+ return hdl;
+ }
+
+ /**
+ Indicate which error messages should be suppressed on the next API call
+
+ These functions are useful for ensuring that the provided error numbers
+ are returned if a failure occurs but do not cause a spurious error message
+ to be returned.
+
+ @return A pointer to this instance
+ */
+ db2i_ileBridge* expectErrors(int32 er1)
+ {
+ tacitErrors[0]=er1;
+ return this;
+ }
+
+ db2i_ileBridge* expectErrors(int32 er1, int32 er2)
+ {
+ tacitErrors[0]=er1;
+ tacitErrors[1]=er2;
+ return this;
+ }
+
+ /**
+ Obtain the IBM i system message that accompanied the last API failure.
+
+ @return A pointer to the 7 character message ID.
+ */
+ static const char* getErrorMsgID()
+ {
+ return ((Qmy_Error_output_t*)parms()->outParms)->MsgId;
+ }
+
+ /**
+ Convert an API error code into the equivalent MySQL error code (if any)
+
+ @param rc The QMYSE API error code
+
+ @return If an equivalent exists, the MySQL error code; else rc
+ */
+ static int32 translateErrorCode(int32 rc)
+ {
+ if (likely(rc == 0))
+ return 0;
+
+ switch (rc)
+ {
+ case QMY_ERR_KEY_NOT_FOUND:
+ return HA_ERR_KEY_NOT_FOUND;
+ case QMY_ERR_DUP_KEY:
+ return HA_ERR_FOUND_DUPP_KEY;
+ case QMY_ERR_END_OF_FILE:
+ return HA_ERR_END_OF_FILE;
+ case QMY_ERR_LOCK_TIMEOUT:
+ return HA_ERR_LOCK_WAIT_TIMEOUT;
+ case QMY_ERR_CST_VIOLATION:
+ return HA_ERR_NO_REFERENCED_ROW;
+ case QMY_ERR_TABLE_NOT_FOUND:
+ return HA_ERR_NO_SUCH_TABLE;
+ case QMY_ERR_NON_UNIQUE_KEY:
+ return ER_DUP_ENTRY;
+ case QMY_ERR_MSGID:
+ {
+ if (memcmp(getErrorMsgID(), DB2I_CPF503A, 7) == 0)
+ return HA_ERR_ROW_IS_REFERENCED;
+ if (memcmp(getErrorMsgID(), DB2I_SQL0538, 7) == 0)
+ return HA_ERR_CANNOT_ADD_FOREIGN;
+ }
+ }
+ return rc;
+ }
+
+private:
+
+ static db2i_ileBridge* createNewBridge(CONNECTION_HANDLE connID);
+ static void destroyBridge(db2i_ileBridge* bridge);
+ static int registerParmSpace(char* in, char* out);
+ static int32 doIt();
+ int32 doItWithLog();
+
+ static _ILEpointer *functionSymbols; ///< Array of ILE function pointers
+ CONNECTION_HANDLE cachedConnectionID; ///< The associated connection
+ bool stmtTxActive; ///< Inside statement transaction
+ char *connErrText; ///< Storage for error message
+ int32 tacitErrors[TACIT_ERRORS_SIZE]; ///< List of errors to be suppressed
+
+ static IleParms* initParmsForThread();
+
+ /**
+ Get space for passing parameters to the QMY_* APIs
+
+ @details A fixed-length parameter passing space is associated with each
+ pthread. This space is allocated and registered by initParmsForThread()
+ the first time a pthread works with a bridge. The space is cached away
+ and remains available until the pthread ends. It became necessary to
+ disassociate the parameter space from the bridge in order to support
+ future enhancements to MySQL that sever the one-to-one relationship between
+ pthreads and user connections. The QMY_* APIs scope a registered parameter
+ space to the thread that executes the register operation.
+ */
+ static IleParms* parms()
+ {
+ IleParms* p = my_pthread_getspecific_ptr(IleParms*, THR_ILEPARMS);
+ if (likely(p))
+ return p;
+
+ return initParmsForThread();
+ }
+
+ class PreservedHandleList
+ {
+ friend db2i_ileBridge* db2i_ileBridge::createNewBridge(CONNECTION_HANDLE);
+ public:
+ void add(const char* newname, FILE_HANDLE newhandle, IBMDB2I_SHARE* share);
+ FILE_HANDLE findAndRemove(const char* fileName, IBMDB2I_SHARE** share);
+
+ private:
+ struct NameHandlePair
+ {
+ char name[FN_REFLEN];
+ FILE_HANDLE handle;
+ IBMDB2I_SHARE* share;
+ NameHandlePair* next;
+ }* head;
+ } pendingLockedHandles;
+
+
+#ifndef DBUG_OFF
+ bool cachedStateIsCoherent()
+ {
+ return (current_thd->thread_id == cachedConnectionID);
+ }
+
+ friend void db2i_ileBridge::unregisterPtr(ILEMemHandle);
+ friend void db2i_ileBridge::registerPtr(const void*, ILEMemHandle*);
+ static uint32 registeredPtrs;
+#endif
+};
+
+
+
+#endif
diff --git a/storage/ibmdb2i/db2i_ioBuffers.cc b/storage/ibmdb2i/db2i_ioBuffers.cc
new file mode 100644
index 00000000000..9525a6e34b5
--- /dev/null
+++ b/storage/ibmdb2i/db2i_ioBuffers.cc
@@ -0,0 +1,332 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#include "db2i_ioBuffers.h"
+
+/**
+ Request another block of rows
+
+ Request the next set of rows from DB2. This must only be called after
+ newReadRequest().
+
+ @param orientation The direction to use when reading through the table.
+*/
+void IOAsyncReadBuffer::loadNewRows(char orientation)
+{
+ rewind();
+ maxRows() = rowsToBlock;
+
+ DBUG_PRINT("db2i_ioBuffers::loadNewRows", ("Requesting %d rows, async = %d", rowsToBlock, readIsAsync));
+
+ rc = getBridge()->expectErrors(QMY_ERR_END_OF_BLOCK, QMY_ERR_LOB_SPACE_TOO_SMALL)
+ ->read(file,
+ ptr(),
+ accessIntent,
+ commitLevel,
+ orientation,
+ readIsAsync,
+ rrnList,
+ 0,
+ 0,
+ 0);
+
+ DBUG_PRINT("db2i_ioBuffers::loadNewRows", ("recordsRead: %d, rc: %d", (uint32)rowCount(), rc));
+
+
+ *releaseRowNeeded = true;
+
+ if (rc == QMY_ERR_END_OF_BLOCK)
+ {
+ // This is really just an informational error, so we ignore it.
+ rc = 0;
+ DBUG_PRINT("db2i_ioBuffers::loadNewRows", ("End of block signalled"));
+ }
+ else if (rc == QMY_ERR_END_OF_FILE)
+ {
+ // If we reach EOF or end-of-key, DB2 guarantees that no rows will be locked.
+ rc = HA_ERR_END_OF_FILE;
+ *releaseRowNeeded = false;
+ }
+ else if (rc == QMY_ERR_KEY_NOT_FOUND)
+ {
+ rc = HA_ERR_KEY_NOT_FOUND;
+ *releaseRowNeeded = false;
+ }
+
+ if (rc) closePipe();
+}
+
+
+/**
+ Empty the message pipe to prepare for another read.
+*/
+void IOAsyncReadBuffer::drainPipe()
+{
+ DBUG_ASSERT(pipeState == PendingFullBufferMsg);
+ PipeRpy_t msg[32];
+ int bytes;
+ PipeRpy_t* lastMsg;
+ while ((bytes = read(msgPipe, msg, sizeof(msg))) > 0)
+ {
+ DBUG_PRINT("db2i_ioBuffers::drainPipe",("Pipe returned %d bytes", bytes));
+ lastMsg = &msg[bytes / (sizeof(msg[0]))-1];
+ if (lastMsg->CumRowCnt == maxRows() ||
+ lastMsg->RtnCod != 0)
+ {
+ pipeState = ConsumedFullBufferMsg;
+ break;
+ }
+
+ }
+ DBUG_PRINT("db2i_ioBuffers::drainPipe",("rc = %d, rows = %d, max = %d", lastMsg->RtnCod, lastMsg->CumRowCnt, (uint32)maxRows()));
+}
+
+
+/**
+ Poll the message pipe for async read messages
+
+ Only valid in async
+
+ @param orientation The direction to use when reading through the table.
+*/
+void IOAsyncReadBuffer::pollNextRow(char orientation)
+{
+ DBUG_ASSERT(readIsAsync);
+
+ // Handle the case in which the buffer is full.
+ if (rowCount() == maxRows())
+ {
+ // If we haven't read to the end, exit here.
+ if (readCursor < rowCount())
+ return;
+
+ if (pipeState == PendingFullBufferMsg)
+ drainPipe();
+ if (pipeState == ConsumedFullBufferMsg)
+ loadNewRows(orientation);
+ }
+
+ if (!rc)
+ {
+ PipeRpy_t* lastMsg = NULL;
+ while (true)
+ {
+ PipeRpy_t msg[32];
+ int bytes = read(msgPipe, msg, sizeof(msg));
+ DBUG_PRINT("db2i_ioBuffers::pollNextRow",("Pipe returned %d bytes", bytes));
+
+ if (unlikely(bytes < 0))
+ {
+ DBUG_PRINT("db2i_ioBuffers::pollNextRow", ("Error"));
+ rc = errno;
+ break;
+ }
+ else if (bytes == 0)
+ break;
+
+ DBUG_ASSERT(bytes % sizeof(msg[0]) == 0);
+ lastMsg = &msg[bytes / (sizeof(msg[0]))-1];
+
+ if (lastMsg->RtnCod || (lastMsg->CumRowCnt == usedRows()))
+ {
+ rc = lastMsg->RtnCod;
+ break;
+ }
+ }
+
+ *releaseRowNeeded = true;
+
+ if (rc == QMY_ERR_END_OF_BLOCK)
+ rc = 0;
+ else if (rc == QMY_ERR_END_OF_FILE)
+ {
+ // If we reach EOF or end-of-key, DB2 guarantees that no rows will be locked.
+ rc = HA_ERR_END_OF_FILE;
+ *releaseRowNeeded = false;
+ }
+ else if (rc == QMY_ERR_KEY_NOT_FOUND)
+ {
+ rc = HA_ERR_KEY_NOT_FOUND;
+ *releaseRowNeeded = false;
+ }
+
+ if (lastMsg)
+ DBUG_PRINT("db2i_ioBuffers::pollNextRow", ("Good data: rc=%d; rows=%d; usedRows=%d", lastMsg->RtnCod, lastMsg->CumRowCnt, (uint32)usedRows()));
+ if (lastMsg && likely(!rc))
+ {
+ if (lastMsg->CumRowCnt < maxRows())
+ pipeState = PendingFullBufferMsg;
+ else
+ pipeState = ConsumedFullBufferMsg;
+
+ DBUG_ASSERT(lastMsg->CumRowCnt <= usedRows());
+
+ }
+ DBUG_ASSERT(rowCount() <= getRowCapacity());
+ }
+ DBUG_PRINT("db2i_ioBuffers::pollNextRow", ("filledRows: %d, rc: %d", rowCount(), rc));
+ if (rc) closePipe();
+}
+
+
+/**
+ Prepare for the destruction of the row buffer storage.
+*/
+void IOAsyncReadBuffer::prepForFree()
+{
+ interruptRead();
+ rewind();
+ IORowBuffer::prepForFree();
+}
+
+
+/**
+ Initialize the newly allocated storage.
+
+ @param sizeChanged Indicates whether the storage capacity is being changed.
+*/
+void IOAsyncReadBuffer::initAfterAllocate(bool sizeChanged)
+{
+ rewind();
+
+ if (sizeChanged || ((void*)rrnList == NULL))
+ rrnList.realloc(getRowCapacity() * sizeof(uint32));
+}
+
+
+/**
+ Send an initial read request
+
+ @param infile The file (table/index) being read from
+ @param orientation The orientation to use for this read request
+ @param rowsToBuffer The number of rows to request each time
+ @param useAsync Whether reads should be performed asynchronously.
+ @param key The key to use (if any)
+ @param keyLength The length of key (if any)
+ @param keyParts The number of columns in the key (if any)
+
+*/
+void IOAsyncReadBuffer::newReadRequest(FILE_HANDLE infile,
+ char orientation,
+ uint32 rowsToBuffer,
+ bool useAsync,
+ ILEMemHandle key,
+ int keyLength,
+ int keyParts)
+{
+ DBUG_ENTER("db2i_ioBuffers::newReadRequest");
+ DBUG_ASSERT(rowsToBuffer <= getRowCapacity());
+#ifndef DBUG_OFF
+ if (readCursor < rowCount())
+ DBUG_PRINT("PERF:",("Wasting %d buffered rows!\n", rowCount() - readCursor));
+#endif
+
+ int fildes[2];
+ int ileDescriptor = QMY_REUSE;
+
+ interruptRead();
+
+ if (likely(useAsync))
+ {
+ if (rowsToBuffer == 1)
+ {
+ // Async provides little or no benefit for single row reads, so we turn it off
+ DBUG_PRINT("db2i_ioBuffers::newReadRequest", ("Disabling async"));
+ useAsync = false;
+ }
+ else
+ {
+ rc = pipe(fildes);
+ if (rc) DBUG_VOID_RETURN;
+
+ // Translate the pipe write descriptor into the equivalent ILE descriptor
+ rc = fstatx(fildes[1], (struct stat*)&ileDescriptor, sizeof(ileDescriptor), STX_XPFFD_PASE);
+ if (rc)
+ {
+ close(fildes[0]);
+ close(fildes[1]);
+ DBUG_VOID_RETURN;
+ }
+ pipeState = Untouched;
+ msgPipe = fildes[0];
+
+ DBUG_PRINT("db2i_ioBuffers::newReadRequest", ("Opened pipe %d", fildes[0]));
+ }
+ }
+
+ file = infile;
+ readIsAsync = useAsync;
+ rowsToBlock = rowsToBuffer;
+
+ rewind();
+ maxRows() = 1;
+ rc = getBridge()->expectErrors(QMY_ERR_END_OF_BLOCK, QMY_ERR_LOB_SPACE_TOO_SMALL)
+ ->read(file,
+ ptr(),
+ accessIntent,
+ commitLevel,
+ orientation,
+ useAsync,
+ rrnList,
+ key,
+ keyLength,
+ keyParts,
+ ileDescriptor);
+
+ // Having shared the pipe with ILE, we relinquish our claim on the write end
+ // of the pipe.
+ if (useAsync)
+ close(fildes[1]);
+
+ // If we reach EOF or end-of-key, DB2 guarantees that no rows will be locked.
+ if (rc == QMY_ERR_END_OF_FILE)
+ {
+ rc = HA_ERR_END_OF_FILE;
+ *releaseRowNeeded = false;
+ }
+ else if (rc == QMY_ERR_KEY_NOT_FOUND)
+ {
+ if (rowCount())
+ rc = HA_ERR_END_OF_FILE;
+ else
+ rc = HA_ERR_KEY_NOT_FOUND;
+ *releaseRowNeeded = false;
+ }
+ else
+ *releaseRowNeeded = true;
+
+ DBUG_VOID_RETURN;
+}
diff --git a/storage/ibmdb2i/db2i_ioBuffers.h b/storage/ibmdb2i/db2i_ioBuffers.h
new file mode 100644
index 00000000000..350d854f055
--- /dev/null
+++ b/storage/ibmdb2i/db2i_ioBuffers.h
@@ -0,0 +1,416 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+/**
+ @file db2i_ioBuffers.h
+
+ @brief Buffer classes used for interacting with QMYSE read/write buffers.
+
+*/
+
+
+#include "db2i_validatedPointer.h"
+#include "mysql_priv.h"
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <as400_types.h>
+
+// Needed for compilers which do not include fstatx in standard headers.
+extern "C" int fstatx(int, struct stat *, int, int);
+
+/**
+ Basic row buffer
+
+ Provides the basic structure and methods needed for communicating
+ with QMYSE I/O APIs.
+
+ @details All QMYSE I/O apis use a buffer that is structured as two integer
+ row counts (max and used) and storage for some number of rows. The row counts
+ are both input and output for the API, and their usage depends on the
+ particular API invoked. This class encapsulates that buffer definition.
+*/
+class IORowBuffer
+{
+ public:
+ IORowBuffer() : allocSize(0), rowLength(0) {;}
+ ~IORowBuffer() { freeBuf(); }
+ ValidatedPointer<char>& ptr() { return data; }
+
+ /**
+ Sets up the buffer to hold the size indicated.
+
+ @param rowLen length of the rows that will be stored in this buffer
+ @param nullMapOffset position of null map within each row
+ @param size buffer size requested
+ */
+ void allocBuf(uint32 rowLen, uint16 nullMapOffset, uint32 size)
+ {
+ nullOffset = nullMapOffset;
+ uint32 newSize = size + sizeof(BufferHdr_t);
+ // If the internal structure of the row is changing, we need to
+ // remember this and notify the subclasses via initAfterAllocate();
+ bool formatChanged = ((size/rowLen) != rowCapacity);
+
+ if (newSize > allocSize)
+ {
+ this->freeBuf();
+ data.alloc(newSize);
+ if (likely((void*)data))
+ allocSize = newSize;
+ }
+
+ if (likely((void*)data))
+ {
+ DBUG_ASSERT((uint64)(void*)data % 16 == 0);
+ rowLength = rowLen;
+ rowCapacity = size / rowLength;
+ initAfterAllocate(formatChanged);
+ }
+ else
+ {
+ allocSize = 0;
+ rowCapacity = 0;
+ }
+
+ DBUG_PRINT("db2i_ioBuffers::allocBuf",("rowCapacity = %d", rowCapacity));
+ }
+
+ void zeroBuf()
+ {
+ memset(data, 0, allocSize);
+ }
+
+ void freeBuf()
+ {
+ if (likely(allocSize))
+ {
+ prepForFree();
+ DBUG_PRINT("IORowBuffer::freeBuf",("Freeing 0x%p", (char*)data));
+ data.dealloc();
+ }
+ }
+
+ char* getRowN(uint32 n)
+ {
+ if (unlikely(n >= getRowCapacity()))
+ return NULL;
+ return (char*)data + sizeof(BufferHdr_t) + (rowLength * n);
+ };
+
+ uint32 getRowCapacity() const {return rowCapacity;}
+ uint32 getRowNullOffset() const {return nullOffset;}
+ uint32 getRowLength() const {return rowLength;}
+
+ protected:
+ /**
+ Called prior to freeing buffer storage so that subclasses can do
+ any required cleanup
+ */
+ virtual void prepForFree()
+ {
+ allocSize = 0;
+ rowCapacity = 0;
+ }
+
+ /**
+ Called after buffer storage so that subclasses can do any required setup.
+ */
+ virtual void initAfterAllocate(bool sizeChanged) { return;}
+
+ ValidatedPointer<char> data;
+ uint32 allocSize;
+ uint32 rowCapacity;
+ uint32 rowLength;
+ uint16 nullOffset;
+ uint32& usedRows() const { return ((BufferHdr_t*)(char*)data)->UsedRowCnt; }
+ uint32& maxRows() const {return ((BufferHdr_t*)(char*)data)->MaxRowCnt; }
+};
+
+
+/**
+ Write buffer
+
+ Implements methods for inserting data into a row buffer for use with the
+ QMY_WRITE and QMY_UPDATE APIs.
+
+ @details The max row count defines how many rows are in the buffer. The used
+ row count is updated by QMYSE to indicate how many rows have been
+ successfully written.
+*/
+class IOWriteBuffer : public IORowBuffer
+{
+ public:
+ bool endOfBuffer() const {return (maxRows() == getRowCapacity());}
+
+ char* addRow()
+ {
+ return getRowN(maxRows()++);
+ }
+
+ void resetAfterWrite()
+ {
+ maxRows() = 0;
+ }
+
+ void deleteRow()
+ {
+ --maxRows();
+ }
+
+ uint32 rowCount() const {return maxRows();}
+
+ uint32 rowsWritten() const {return usedRows()-1;}
+
+ private:
+ void initAfterAllocate(bool sizeChanged) {maxRows() = 0; usedRows() = 0;}
+};
+
+
+/**
+ Read buffer
+
+ Implements methods for reading data from and managing a row buffer for use
+ with the QMY_READ APIs. This is primarily for use with metainformation queries.
+*/
+class IOReadBuffer : public IORowBuffer
+{
+ public:
+
+ IOReadBuffer() {;}
+ IOReadBuffer(uint32 rows, uint32 rowLength)
+ {
+ allocBuf(rows, 0, rows * rowLength);
+ maxRows() = rows;
+ }
+
+ uint32 rowCount() {return usedRows();}
+ void setRowsToProcess(uint32 rows) { maxRows() = rows; }
+};
+
+
+/**
+ Read buffer
+
+ Implements methods for reading data from and managing a row buffer for use
+ with the QMY_READ APIs.
+
+ @details This class supports both sync and async read modes. The max row
+ count defines the number of rows that are requested to be read. The used row
+ count defines how many rows have been read. Sync mode is reasonably
+ straightforward, but async mode has a complex system of communicating with
+ QMYSE that is optimized for low latency. In async mode, the used row count is
+ updated continuously by QMYSE as rows are read. At the same time, messages are
+ sent to the associated pipe indicating that a row has been read. As long as
+ the internal read cursor lags behind the used row count, the pipe is never
+ consulted. But if the internal read cursor "catches up to" the used row count,
+ then we block on the pipe until we find a message indicating that a new row
+ has been read or that an error has occurred.
+*/
+class IOAsyncReadBuffer : public IOReadBuffer
+{
+ public:
+ IOAsyncReadBuffer() :
+ file(0), readIsAsync(false), msgPipe(QMY_REUSE), bridge(NULL)
+ {
+ }
+
+ ~IOAsyncReadBuffer()
+ {
+ interruptRead();
+ rrnList.dealloc();
+ }
+
+
+ /**
+ Signal read operation complete
+
+ Indicates that the storage engine requires no more data from the table.
+ Must be called between calls to newReadRequest().
+ */
+ void endRead()
+ {
+#ifndef DBUG_OFF
+ if (readCursor < rowCount())
+ DBUG_PRINT("PERF:",("Wasting %d buffered rows!\n", rowCount() - readCursor));
+#endif
+ interruptRead();
+
+ file = 0;
+ bridge = NULL;
+ }
+
+ /**
+ Update data that may change on each read operation
+ */
+ void update(char newAccessIntent,
+ bool* newReleaseRowNeeded,
+ char commitLvl)
+ {
+ accessIntent = newAccessIntent;
+ releaseRowNeeded = newReleaseRowNeeded;
+ commitLevel = commitLvl;
+ }
+
+ /**
+ Read the next row in the table.
+
+ Return a pointer to the next row in the table, where "next" is defined
+ by the orientation.
+
+ @param orientaton
+ @param[out] rrn The relative record number of the row returned. Not reliable
+ if NULL is returned by this function.
+
+ @return Pointer to the row. Null if no more rows are available or an error
+ occurred.
+ */
+ char* readNextRow(char orientation, uint32& rrn)
+ {
+ DBUG_PRINT("db2i_ioBuffers::readNextRow", ("readCursor: %d, filledRows: %d, rc: %d", readCursor, rowCount(), rc));
+
+ while (readCursor >= rowCount() && !rc)
+ {
+ if (!readIsAsync)
+ loadNewRows(orientation);
+ else
+ pollNextRow(orientation);
+ }
+
+ if (readCursor >= rowCount())
+ return NULL;
+
+ rrn = rrnList[readCursor];
+ return getRowN(readCursor++);
+ }
+
+ /**
+ Retrieve the return code generated by the last operation.
+
+ @return The return code, translated to the appropriate HA_ERR_*
+ value if possible.
+ */
+ int32 lastrc()
+ {
+ return db2i_ileBridge::translateErrorCode(rc);
+ }
+
+ void rewind()
+ {
+ readCursor = 0;
+ rc = 0;
+ usedRows() = 0;
+ }
+
+ bool reachedEOD() { return EOD; }
+
+ void newReadRequest(FILE_HANDLE infile,
+ char orientation,
+ uint32 rowsToBuffer,
+ bool useAsync,
+ ILEMemHandle key,
+ int keyLength,
+ int keyParts);
+
+ private:
+
+ /**
+ End any running async read operation.
+ */
+ void interruptRead()
+ {
+ closePipe();
+ if (file && readIsAsync && (rc == 0) && (rowCount() < getRowCapacity()))
+ {
+ DBUG_PRINT("IOReadBuffer::interruptRead", ("PERF: Interrupting %d", (uint32)file));
+ getBridge()->readInterrupt(file);
+ }
+ }
+
+ void closePipe()
+ {
+ if (msgPipe != QMY_REUSE)
+ {
+ DBUG_PRINT("db2i_ioBuffers::closePipe", ("Closing pipe %d", msgPipe));
+ close(msgPipe);
+ msgPipe = QMY_REUSE;
+ }
+ }
+
+ /**
+ Get a pointer to the active ILE bridge.
+
+ Getting the bridge pointer is (relatively) expensive, so we cache
+ it off for each operation.
+ */
+ db2i_ileBridge* getBridge()
+ {
+ if (unlikely(bridge == NULL))
+ {
+ bridge = db2i_ileBridge::getBridgeForThread();
+ }
+ return bridge;
+ }
+
+ void drainPipe();
+ void pollNextRow(char orientation);
+ void prepForFree();
+ void initAfterAllocate(bool sizeChanged);
+ void loadNewRows(char orientation);
+
+
+ uint32 readCursor; // Read position within buffer
+ int32 rc; // Last return code received
+ ValidatedPointer<uint32> rrnList; // Receiver for list of rrns
+ char accessIntent; // The access intent for this read
+ char commitLevel; // What isolation level should be used
+ char EOD; // Whether end-of-data was hit
+ char readIsAsync; // Are reads to be done asynchronously?
+ bool* releaseRowNeeded;
+ /* Does the caller need to release the current row when finished reading */
+ FILE_HANDLE file; // The file to be read
+ int msgPipe;
+ /* The read descriptor of the pipe used to pass messages during async reads */
+ db2i_ileBridge* bridge; // Cached pointer to bridge
+ uint32 rowsToBlock; // Number of rows to request
+ enum
+ {
+ ConsumedFullBufferMsg,
+ PendingFullBufferMsg,
+ Untouched
+ } pipeState;
+ /* The state of the async read message pipe */
+};
+
diff --git a/storage/ibmdb2i/db2i_misc.h b/storage/ibmdb2i/db2i_misc.h
new file mode 100644
index 00000000000..9e20f01208b
--- /dev/null
+++ b/storage/ibmdb2i/db2i_misc.h
@@ -0,0 +1,113 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+#ifndef DB2I_MISC_H
+#define DB2I_MISC_H
+
+/**
+ Undelimit quote-delimited DB2 names in-place
+*/
+void stripExtraQuotes(char* name, uint maxLen)
+{
+ char* oldName = (char*)sql_strdup(name);
+ uint i = 0;
+ uint j = 0;
+ do
+ {
+ name[j] = oldName[i];
+ if (oldName[i] == '"' && oldName[i+1] == '"')
+ ++i;
+ } while (++j < maxLen && oldName[++i]);
+
+ if (j == maxLen)
+ --j;
+ name[j] = 0;
+}
+
+/**
+ Convert a MySQL identifier name into a DB2 compatible format
+
+ @parm input The MySQL name
+ @parm output The DB2 name
+ @parm outlen The amount of space allocated for output
+ @parm delimit Should delimiting quotes be placed around the converted name?
+ @parm delimitQuotes Should quotes in the MySQL be delimited with additional quotes?
+
+ @return FALSE if output was too small and name was truncated; TRUE otherwise
+*/
+bool convertMySQLNameToDB2Name(const char* input,
+ char* output,
+ size_t outlen,
+ bool delimit = true,
+ bool delimitQuotes = true)
+{
+ uint o = 0;
+ if (delimit)
+ output[o++] = '"';
+
+ uint i = 0;
+ do
+ {
+ output[o] = input[i];
+ if (delimitQuotes && input[i] == '"')
+ output[++o] = '"';
+ } while (++o < outlen-2 && input[++i]);
+
+ if (delimit)
+ output[o++] = '"';
+ output[min(o, outlen-1)] = 0; // This isn't the most user-friendly way to handle overflows,
+ // but at least its safe.
+ return (o <= outlen-1);
+}
+
+bool isOrdinaryIdentifier(const char* s)
+{
+ while (*s)
+ {
+ if (my_isupper(system_charset_info, *s) ||
+ my_isdigit(system_charset_info, *s) ||
+ (*s == '_') ||
+ (*s == '@') ||
+ (*s == '$') ||
+ (*s == '#') ||
+ (*s == '"'))
+ ++s;
+ else
+ return false;
+ }
+ return true;
+}
+
+#endif
diff --git a/storage/ibmdb2i/db2i_myconv.cc b/storage/ibmdb2i/db2i_myconv.cc
new file mode 100644
index 00000000000..7be6e1236cd
--- /dev/null
+++ b/storage/ibmdb2i/db2i_myconv.cc
@@ -0,0 +1,1498 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+/**
+ @file
+
+ @brief A direct map optimization of iconv and related functions
+ This was show to significantly reduce character conversion cost
+ for short strings when compared to calling iconv system code.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <errno.h>
+#include <iconv.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <string.h>
+#include <as400_protos.h>
+
+#include "db2i_myconv.h"
+#include "db2i_global.h"
+
+int32_t myconvDebug=0;
+
+static char szGetTimeString[20];
+static char * GetTimeString(time_t now)
+{
+ struct tm * tm;
+
+ now = time(&now);
+ tm = (struct tm *) localtime(&now);
+ sprintf(szGetTimeString, "%04d/%02d/%02d %02d:%02d:%02d",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+ return szGetTimeString;
+}
+
+static MEM_ROOT dmapMemRoot;
+
+void initMyconv()
+{
+ init_alloc_root(&dmapMemRoot, 0x200, 0);
+}
+
+void cleanupMyconv()
+{
+ free_root(&dmapMemRoot,0);
+}
+
+
+#ifdef DEBUG
+/* type: */
+#define STDOUT_WITH_TIME -1 /* to stdout with time */
+#define STDERR_WITH_TIME -2 /* to stderr with time */
+#define STDOUT_WO_TIME 1 /* : to stdout */
+#define STDERR_WO_TIME 2 /* : to stderr */
+
+
+static void MyPrintf(long type,
+ char * fmt, ...)
+{
+ char StdoutFN[256];
+ va_list ap;
+ char * p;
+ time_t now;
+ FILE * fd=stderr;
+
+ if (type < 0)
+ {
+ now = time(&now);
+ fprintf(fd, "%s ", GetTimeString(now));
+ }
+ va_start(ap, fmt);
+ vfprintf(fd, fmt, ap);
+ va_end(ap);
+}
+#endif
+
+
+
+
+#define MAX_CONVERTER 128
+
+mycstoccsid(const char* pname)
+{
+ if (strcmp(pname, "UTF-16")==0)
+ return 1200;
+ else if (strcmp(pname, "big5")==0)
+ return 950;
+ else
+ return cstoccsid(pname);
+}
+#define cstoccsid mycstoccsid
+
+static struct __myconv_rec myconv_rec [MAX_CONVERTER];
+static struct __dmap_rec dmap_rec [MAX_CONVERTER];
+
+static int dmap_open(const char * to,
+ const char * from,
+ const int32_t idx)
+{
+ if (myconvIsSBCS(from) && myconvIsSBCS(to)) {
+ dmap_rec[idx].codingSchema = DMAP_S2S;
+ if ((dmap_rec[idx].dmapS2S = (uchar *) alloc_root(&dmapMemRoot, 0x100)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_S2S, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapS2S, 0x00, 0x100);
+ myconv_rec[idx].allocatedSize=0x100;
+
+ {
+ char dmapSrc[0x100];
+ iconv_t cd;
+ int32_t i;
+ size_t inBytesLeft=0x100;
+ size_t outBytesLeft=0x100;
+ size_t len;
+ char * inBuf=dmapSrc;
+ char * outBuf=(char *) dmap_rec[idx].dmapS2S;
+
+ if ((cd = iconv_open(to, from)) == (iconv_t) -1) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ inBytesLeft = 0x100;
+ for (i = 0; i < inBytesLeft; ++i)
+ dmapSrc[i]=i;
+
+ do {
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d: iconv() returns %d, errno = %d in %s at %d\n",
+ to, from, idx, DMAP_S2S, len, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WITH_TIME,
+ "inBytesLeft = %d, inBuf - dmapSrc = %d\n", inBytesLeft, inBuf-dmapSrc);
+ MyPrintf(STDERR_WITH_TIME,
+ "outBytesLeft = %d, outBuf - dmapS2S = %d\n", outBytesLeft, outBuf-(char *) dmap_rec[idx].dmapS2S);
+ }
+ if ((inBytesLeft == 86 || inBytesLeft == 64 || inBytesLeft == 1) &&
+ memcmp(from, "IBM-1256", 9) == 0 &&
+ memcmp(to, "IBM-420", 8) == 0) {
+ /* Known problem for IBM-1256_IBM-420 */
+ --inBytesLeft;
+ ++inBuf;
+ *outBuf=0x00;
+ ++outBuf;
+ --outBytesLeft;
+ continue;
+ } else if ((inBytesLeft == 173 || inBytesLeft == 172 ||
+ inBytesLeft == 74 || inBytesLeft == 73 ||
+ inBytesLeft == 52 || inBytesLeft == 50 ||
+ inBytesLeft == 31 || inBytesLeft == 20 ||
+ inBytesLeft == 6) &&
+ memcmp(to, "IBM-1256", 9) == 0 &&
+ memcmp(from, "IBM-420", 8) == 0) {
+ /* Known problem for IBM-420_IBM-1256 */
+ --inBytesLeft;
+ ++inBuf;
+ *outBuf=0x00;
+ ++outBuf;
+ --outBytesLeft;
+ continue;
+ } else if ((128 >= inBytesLeft) &&
+ memcmp(to, "IBM-037", 8) == 0 &&
+ memcmp(from, "IBM-367", 8) == 0) {
+ /* Known problem for IBM-367_IBM-037 */
+ --inBytesLeft;
+ ++inBuf;
+ *outBuf=0x00;
+ ++outBuf;
+ --outBytesLeft;
+ continue;
+ } else if (((1 <= inBytesLeft && inBytesLeft <= 4) || (97 <= inBytesLeft && inBytesLeft <= 128)) &&
+ memcmp(to, "IBM-838", 8) == 0 &&
+ memcmp(from, "TIS-620", 8) == 0) {
+ /* Known problem for TIS-620_IBM-838 */
+ --inBytesLeft;
+ ++inBuf;
+ *outBuf=0x00;
+ ++outBuf;
+ --outBytesLeft;
+ continue;
+ }
+ iconv_close(cd);
+ return -1;
+#else
+ /* Tolerant to undefined conversions for any converter */
+ --inBytesLeft;
+ ++inBuf;
+ *outBuf=0x00;
+ ++outBuf;
+ --outBytesLeft;
+ continue;
+#endif
+ }
+ } while (inBytesLeft > 0);
+
+ if (myconvIsISO(to))
+ myconv_rec[idx].subS=0x1A;
+ else if (myconvIsASCII(to))
+ myconv_rec[idx].subS=0x7F;
+ else if (myconvIsEBCDIC(to))
+ myconv_rec[idx].subS=0x3F;
+
+ if (myconvIsISO(from))
+ myconv_rec[idx].srcSubS=0x1A;
+ else if (myconvIsASCII(from))
+ myconv_rec[idx].srcSubS=0x7F;
+ else if (myconvIsEBCDIC(from))
+ myconv_rec[idx].srcSubS=0x3F;
+
+ iconv_close(cd);
+ }
+ } else if (((myconvIsSBCS(from) && myconvIsUnicode2(to)) && (dmap_rec[idx].codingSchema = DMAP_S2U)) ||
+ ((myconvIsSBCS(from) && myconvIsUTF8(to)) && (dmap_rec[idx].codingSchema = DMAP_S28))) {
+ int i;
+
+ /* single byte mapping */
+ if ((dmap_rec[idx].dmapD12U = (UniChar *) alloc_root(&dmapMemRoot, 0x100 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_S2U, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapD12U, 0x00, 0x100 * 2);
+ myconv_rec[idx].allocatedSize=0x100 * 2;
+
+
+ {
+ char dmapSrc[2];
+ iconv_t cd;
+ int32_t i;
+ size_t inBytesLeft;
+ size_t outBytesLeft;
+ size_t len;
+ char * inBuf;
+ char * outBuf;
+ char SS=0x1A;
+#ifdef support_surrogate
+ if ((cd = iconv_open("UTF-16", from)) == (iconv_t) -1) {
+#else
+ if ((cd = iconv_open("UCS-2", from)) == (iconv_t) -1) {
+#endif
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ for (i = 0; i < 0x100; ++i) {
+ dmapSrc[0]=i;
+ inBuf=dmapSrc;
+ inBytesLeft=1;
+ outBuf=(char *) &(dmap_rec[idx].dmapD12U[i]);
+ outBytesLeft=2;
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if ((errno == EILSEQ || errno == EINVAL) &&
+ inBytesLeft == 1 &&
+ outBytesLeft == 2) {
+ continue;
+ } else {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(cd,%02x,%d,%02x%02x,%d), errno = %d in %s at %d\n",
+ to, from, idx, dmapSrc[0], 1,
+ (&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1], 2,
+ errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WITH_TIME,
+ "inBytesLeft=%d, outBytesLeft=%d, %02x%02x\n",
+ inBytesLeft, outBytesLeft,
+ (&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1]);
+ }
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ dmap_rec[idx].dmapD12U[i]=0x0000;
+ }
+ if (dmap_rec[idx].dmapE02U[i] == 0x001A && /* pick the first one */
+ myconv_rec[idx].srcSubS == 0x00) {
+ myconv_rec[idx].srcSubS=i;
+ }
+ }
+ iconv_close(cd);
+ }
+ myconv_rec[idx].subS=0x1A;
+ myconv_rec[idx].subD=0xFFFD;
+
+
+ } else if (((myconvIsUCS2(from) && myconvIsSBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_U2S)) ||
+ ((myconvIsUTF16(from) && myconvIsSBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_T2S)) ||
+ ((myconvIsUTF8(from) && myconvIsSBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_82S))) {
+ /* UTF-16 -> SBCS, the direct map a bit of waste of space,
+ * binary search may be reasonable alternative
+ */
+ if ((dmap_rec[idx].dmapU2S = (uchar *) alloc_root(&dmapMemRoot, 0x10000 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_U2S, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapU2S, 0x00, 0x10000);
+ myconv_rec[idx].allocatedSize=(0x10000 * 2);
+
+ {
+ iconv_t cd;
+ int32_t i;
+
+#ifdef support_surrogate
+ if ((cd = iconv_open(to, "UTF-16")) == (iconv_t) -1) {
+#else
+ if ((cd = iconv_open(to, "UCS-2")) == (iconv_t) -1) {
+#endif
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ for (i = 0; i < 0x100; ++i) {
+ UniChar dmapSrc[0x100];
+ int32_t j;
+ for (j = 0; j < 0x100; ++j) {
+ dmapSrc[j]=i * 0x100 + j;
+ }
+ char * inBuf=(char *) dmapSrc;
+ char * outBuf=(char *) &(dmap_rec[idx].dmapU2S[i*0x100]);
+ size_t inBytesLeft=sizeof(dmapSrc);
+ size_t outBytesLeft=0x100;
+ size_t len;
+
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if (inBytesLeft == 0 && outBytesLeft == 0) { /* a number of substitution returns */
+ continue;
+ }
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ from, to, idx, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WITH_TIME,
+ "iconv() retuns %d, errno=%d, InBytesLeft=%d, OutBytesLeft=%d\n",
+ len, errno, inBytesLeft, outBytesLeft, __FILE__,__LINE__);
+ }
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ }
+ iconv_close(cd);
+
+ myconv_rec[idx].subS = dmap_rec[idx].dmapU2S[0x1A];
+ myconv_rec[idx].subD = dmap_rec[idx].dmapU2S[0xFFFD];
+ myconv_rec[idx].srcSubS = 0x1A;
+ myconv_rec[idx].srcSubD = 0xFFFD;
+ }
+
+
+
+ } else if (((myconvIsDBCS(from) && myconvIsUnicode2(to)) && (dmap_rec[idx].codingSchema = DMAP_D2U)) ||
+ ((myconvIsDBCS(from) && myconvIsUTF8(to)) && (dmap_rec[idx].codingSchema = DMAP_D28))) {
+ int i;
+ /* single byte mapping */
+ if ((dmap_rec[idx].dmapD12U = (UniChar *) alloc_root(&dmapMemRoot, 0x100 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_D2U, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapD12U, 0x00, 0x100 * 2);
+
+ /* double byte mapping, assume 7 bit ASCII is not use as the first byte of DBCS. */
+ if ((dmap_rec[idx].dmapD22U = (UniChar *) alloc_root(&dmapMemRoot, 0x8000 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_D2U, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapD22U, 0x00, 0x8000 * 2);
+
+ myconv_rec[idx].allocatedSize=(0x100 + 0x8000) * 2;
+
+
+ {
+ char dmapSrc[2];
+ iconv_t cd;
+ int32_t i;
+ size_t inBytesLeft;
+ size_t outBytesLeft;
+ size_t len;
+ char * inBuf;
+ char * outBuf;
+ char SS=0x1A;
+
+#ifdef support_surrogate
+ if ((cd = iconv_open("UTF-16", from)) == (iconv_t) -1) {
+#else
+ if ((cd = iconv_open("UCS-2", from)) == (iconv_t) -1) {
+#endif
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ for (i = 0; i < 0x100; ++i) {
+ dmapSrc[0]=i;
+ inBuf=dmapSrc;
+ inBytesLeft=1;
+ outBuf=(char *) (&dmap_rec[idx].dmapD12U[i]);
+ outBytesLeft=2;
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if ((errno == EILSEQ || errno == EINVAL) &&
+ inBytesLeft == 1 &&
+ outBytesLeft == 2) {
+ continue;
+ } else {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(cd,%02x,%d,%02x%02x,%d), errno = %d in %s at %d\n",
+ to, from, idx, dmapSrc[0], 1,
+ (&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1], 2,
+ errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WITH_TIME,
+ "inBytesLeft=%d, outBytesLeft=%d, %02x%02x\n",
+ inBytesLeft, outBytesLeft,
+ (&dmap_rec[idx].dmapD12U[i])[0],(&dmap_rec[idx].dmapD12U[i])[1]);
+ }
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ dmap_rec[idx].dmapD12U[i]=0x0000;
+ }
+ if (dmap_rec[idx].dmapD12U[i] == 0x001A && /* pick the first one */
+ myconv_rec[idx].srcSubS == 0x00) {
+ myconv_rec[idx].srcSubS=i;
+ }
+ }
+
+
+ for (i = 0x80; i < 0x100; ++i) {
+ int j;
+ if (dmap_rec[idx].dmapD12U[i] != 0x0000)
+ continue;
+ for (j = 0x01; j < 0x100; ++j) {
+ dmapSrc[0]=i;
+ dmapSrc[1]=j;
+ int offset = i-0x80;
+ offset<<=8;
+ offset+=j;
+
+ inBuf=dmapSrc;
+ inBytesLeft=2;
+ outBuf=(char *) &(dmap_rec[idx].dmapD22U[offset]);
+ outBytesLeft=2;
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if (inBytesLeft == 2 && outBytesLeft == 2 && (errno == EILSEQ || errno == EINVAL)) {
+ ; /* invalid DBCS character, dmapDD2U[offset] remains 0x0000 */
+ } else {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(cd,%p,2,%p,2), errno = %d in %s at %d\n",
+ to, from, idx,
+ dmapSrc, &(dmap_rec[idx].dmapD22U[offset]),
+ errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WO_TIME,
+ "iconv(cd,0x%02x%02x,2,0x%04x,2) returns %d, inBytesLeft=%d, outBytesLeft=%d\n",
+ dmapSrc[0], dmapSrc[1],
+ dmap_rec[idx].dmapD22U[offset],
+ len, inBytesLeft, outBytesLeft);
+ }
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ } else {
+#ifdef TRACE_DMAP
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), rc=%d, errno=%d in %s at %d\n",
+ to, from, idx, len, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WITH_TIME,
+ "%04X: src=%04X%04X, inBuf=0x%02X%02X, inBytesLeft=%d, outBuf=%02X%02X%02X, outBytesLeft=%d\n",
+ i, dmapSrc[0], dmapSrc[1], inBuf[0], inBuf[1],
+ inBytesLeft, outBuf[-2], outBuf[-1], outBuf[0], outBytesLeft);
+ MyPrintf(STDERR_WITH_TIME,
+ "&dmapSrc=%p, inBuf=%p, %p, outBuf=%p\n",
+ dmapSrc, inBuf, dmap_rec[idx].dmapU2M3 + (i - 0x80) * 2, outBuf);
+ }
+#endif
+ }
+ }
+ if (dmap_rec[idx].dmapD12U[i] == 0xFFFD) { /* pick the last one */
+ myconv_rec[idx].srcSubD=i* 0x100 + j;
+ }
+ }
+ iconv_close(cd);
+ }
+
+ myconv_rec[idx].subS=0x1A;
+ myconv_rec[idx].subD=0xFFFD;
+ myconv_rec[idx].srcSubD=0xFCFC;
+
+
+ } else if (((myconvIsUCS2(from) && myconvIsDBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_U2D)) ||
+ ((myconvIsUTF16(from) && myconvIsDBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_T2D)) ||
+ ((myconvIsUTF8(from) && myconvIsDBCS(to)) && (dmap_rec[idx].codingSchema = DMAP_82D))) {
+ /* UTF-16 -> DBCS single/double byte */
+ /* A single table will cover all characters, assuming no second byte is 0x00. */
+ if ((dmap_rec[idx].dmapU2D = (uchar *) alloc_root(&dmapMemRoot, 0x10000 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_U2D, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ memset(dmap_rec[idx].dmapU2D, 0x00, 0x10000 * 2);
+ myconv_rec[idx].allocatedSize=(0x10000 * 2);
+
+ {
+ UniChar dmapSrc[1];
+ iconv_t cd;
+ int32_t i;
+ size_t inBytesLeft;
+ size_t outBytesLeft;
+ size_t len;
+ char * inBuf;
+ char * outBuf;
+
+#ifdef support_surrogate
+ if ((cd = iconv_open(to, "UTF-16")) == (iconv_t) -1) {
+#else
+ if ((cd = iconv_open(to, "UCS-2")) == (iconv_t) -1) {
+#endif
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ /* easy implementation, convert 1 Unicode character at one time. */
+ /* If the open performance is an issue, convert a chunk such as 128 chracters. */
+ /* if the converted length is not the same as the original, convert one by one. */
+ (dmap_rec[idx].dmapU2D)[0x0000]=0x00;
+ for (i = 1; i < 0x10000; ++i) {
+ dmapSrc[0]=i;
+ inBuf=(char *) dmapSrc;
+ inBytesLeft=2;
+ outBuf=(char *) &((dmap_rec[idx].dmapU2D)[2*i]);
+ outBytesLeft=2;
+ do {
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if (len == 1 && inBytesLeft == 0 && outBytesLeft == 1 && (dmap_rec[idx].dmapU2D)[2*i] == 0x1A) {
+ /* UCS-2_TIS-620:0x0080 => 0x1A, converted to SBCS replacement character */
+ (dmap_rec[idx].dmapU2D)[2*i+1]=0x00;
+ break;
+ } else if (len == 1 && inBytesLeft == 0 && outBytesLeft == 0) {
+ break;
+ }
+ if (errno == EILSEQ || errno == EINVAL) {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WO_TIME,
+ "iconv(cd,%04x,2,%02x%02x,2) returns inBytesLeft=%d, outBytesLeft=%d\n",
+ dmapSrc[0],
+ (dmap_rec[idx].dmapU2D)[2*i], (dmap_rec[idx].dmapU2D)[2*i+1],
+ inBytesLeft, outBytesLeft);
+ if (outBuf - (char *) dmap_rec[idx].dmapU2M2 > 1)
+ MyPrintf(STDERR_WO_TIME, "outBuf[-2..2]=%02X%02X%02X%02X%02X\n", outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
+ else
+ MyPrintf(STDERR_WO_TIME, "outBuf[0..2]=%02X%02X%02X\n", outBuf[0],outBuf[1],outBuf[2]);
+ }
+#endif
+ inBuf+=2;
+ inBytesLeft-=2;
+ memcpy(outBuf, (char *) &(myconv_rec[idx].subD), 2);
+ outBuf+=2;
+ outBytesLeft-=2;
+ } else {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "[%d] dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ i, to, from, idx, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WO_TIME,
+ "iconv(cd,%04x,2,%02x%02x,2) returns %d inBytesLeft=%d, outBytesLeft=%d\n",
+ dmapSrc[0],
+ (dmap_rec[idx].dmapU2D)[2*i],
+ (dmap_rec[idx].dmapU2D)[2*i+1],
+ len, inBytesLeft,outBytesLeft);
+ if (i == 1) {
+ MyPrintf(STDERR_WO_TIME,
+ " inBuf [-1..2]=%02x%02x%02x%02x\n",
+ inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
+ MyPrintf(STDERR_WO_TIME,
+ " outBuf [-1..2]=%02x%02x%02x%02x\n",
+ outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
+ } else {
+ MyPrintf(STDERR_WO_TIME,
+ " inBuf [-2..2]=%02x%02x%02x%02x%02x\n",
+ inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
+ MyPrintf(STDERR_WO_TIME,
+ " outBuf [-2..2]=%02x%02x%02x%02x%02x\n",
+ outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
+ }
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ if (len == 0 && inBytesLeft == 0 && outBytesLeft == 1) { /* converted to SBCS */
+ (dmap_rec[idx].dmapU2D)[2*i+1]=0x00;
+ break;
+ }
+ }
+ } while (inBytesLeft > 0);
+ }
+ iconv_close(cd);
+ myconv_rec[idx].subS = dmap_rec[idx].dmapU2D[2*0x1A];
+ myconv_rec[idx].subD = dmap_rec[idx].dmapU2D[2*0xFFFD] * 0x100
+ + dmap_rec[idx].dmapU2D[2*0xFFFD+1];
+ myconv_rec[idx].srcSubS = 0x1A;
+ myconv_rec[idx].srcSubD = 0xFFFD;
+ }
+
+
+ } else if (((myconvIsEUC(from) && myconvIsUnicode2(to)) && (dmap_rec[idx].codingSchema = DMAP_E2U)) ||
+ ((myconvIsEUC(from) && myconvIsUTF8(to)) && (dmap_rec[idx].codingSchema = DMAP_E28))) {
+ int i;
+ /* S0: 0x00 - 0x7F */
+ if ((dmap_rec[idx].dmapE02U = (UniChar *) alloc_root(&dmapMemRoot, 0x100 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapE02U, 0x00, 0x100 * 2);
+
+ /* S1: 0xA0 - 0xFF, 0xA0 - 0xFF */
+ if ((dmap_rec[idx].dmapE12U = (UniChar *) alloc_root(&dmapMemRoot, 0x60 * 0x60 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapE12U, 0x00, 0x60 * 0x60 * 2);
+
+ /* SS2: 0x8E + 0xA0 - 0xFF, 0xA0 - 0xFF */
+ if ((dmap_rec[idx].dmapE22U = (UniChar *) alloc_root(&dmapMemRoot, 0x60 * 0x61 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapE22U, 0x00, 0x60 * 0x61 * 2);
+
+ /* SS3: 0x8F + 0xA0 - 0xFF, 0xA0 - 0xFF */
+ if ((dmap_rec[idx].dmapE32U = (UniChar *) alloc_root(&dmapMemRoot, 0x60 * 0x61 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_E2U, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapE32U, 0x00, 0x60 * 0x61 * 2);
+
+ myconv_rec[idx].allocatedSize=(0x100 + 0x60 * 0x60 + 0x60 * 0x61* 2) * 2;
+
+
+ {
+ char dmapSrc[0x60 * 0x60 * 3];
+ iconv_t cd;
+ int32_t i;
+ size_t inBytesLeft;
+ size_t outBytesLeft;
+ size_t len;
+ char * inBuf;
+ char * outBuf;
+ char SS=0x8E;
+
+#ifdef support_surrogate
+ if ((cd = iconv_open("UTF-16", from)) == (iconv_t) -1) {
+#else
+ if ((cd = iconv_open("UCS-2", from)) == (iconv_t) -1) {
+#endif
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ for (i = 0; i < 0x100; ++i) {
+ dmapSrc[0]=i;
+ inBuf=dmapSrc;
+ inBytesLeft=1;
+ outBuf=(char *) (&dmap_rec[idx].dmapE02U[i]);
+ outBytesLeft=2;
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+ }
+#endif
+ dmap_rec[idx].dmapE02U[i]=0x0000;
+ }
+ if (dmap_rec[idx].dmapE02U[i] == 0x001A && /* pick the first one */
+ myconv_rec[idx].srcSubS == 0x00) {
+ myconv_rec[idx].srcSubS=i;
+ }
+ }
+
+
+ inBuf=dmapSrc;
+ for (i = 0; i < 0x60; ++i) {
+ int j;
+ for (j = 0; j < 0x60; ++j) {
+ *inBuf=i+0xA0;
+ ++inBuf;
+ *inBuf=j+0xA0;
+ ++inBuf;
+ }
+ }
+ inBuf=dmapSrc;
+ inBytesLeft=0x60 * 0x60 * 2;
+ outBuf=(char *) dmap_rec[idx].dmapE12U;
+ outBytesLeft=0x60 * 0x60 * 2;
+ do {
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if (errno == EILSEQ) {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WO_TIME, "inBytesLeft=%d, outBytesLeft=%d\n", inBytesLeft, outBytesLeft);
+ if (inBuf - dmapSrc > 1 && inBuf - dmapSrc <= sizeof(dmapSrc) - 2)
+ MyPrintf(STDERR_WO_TIME, "inBuf[-2..2]=%02X%02X%02X%02X%02X\n", inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
+ else
+ MyPrintf(STDERR_WO_TIME, "inBuf[0..2]=%02X%02X%02X\n", inBuf[0],inBuf[1],inBuf[2]);
+ if (outBuf - (char *) dmap_rec[idx].dmapE12U > 1)
+ MyPrintf(STDERR_WO_TIME, "outBuf[-2..2]=%02X%02X%02X%02X%02X\n", outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
+ else
+ MyPrintf(STDERR_WO_TIME, "outBuf[0..2]=%02X%02X%02X\n", outBuf[0],outBuf[1],outBuf[2]);
+ }
+#endif
+ inBuf+=2;
+ inBytesLeft-=2;
+ outBuf[0]=0x00;
+ outBuf[1]=0x00;
+ outBuf+=2;
+ outBytesLeft-=2;
+ } else {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ }
+ } while (inBytesLeft > 0);
+
+ /* SS2: 0x8E + 1 or 2 bytes */
+ /* SS3: 0x8E + 1 or 2 bytes */
+ while (SS != 0x00) {
+ int32_t numSuccess=0;
+ for (i = 0; i < 0x60; ++i) {
+ inBuf=dmapSrc;
+ inBuf[0]=SS;
+ inBuf[1]=i+0xA0;
+ inBytesLeft=2;
+ if (SS == 0x8E)
+ outBuf=(char *) &(dmap_rec[idx].dmapE22U[i]);
+ else
+ outBuf=(char *) &(dmap_rec[idx].dmapE32U[i]);
+ outBytesLeft=2;
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if (SS == 0x8E)
+ dmap_rec[idx].dmapE22U[i]=0x0000;
+ else
+ dmap_rec[idx].dmapE32U[i]=0x0000;
+ } else {
+ ++numSuccess;
+ }
+ }
+ if (numSuccess == 0) { /* SS2 is 2 bytes */
+ inBuf=dmapSrc;
+ for (i = 0; i < 0x60; ++i) {
+ int j;
+ for (j = 0; j < 0x60; ++j) {
+ *inBuf=SS;
+ ++inBuf;
+ *inBuf=i+0xA0;
+ ++inBuf;
+ *inBuf=j+0xA0;
+ ++inBuf;
+ }
+ }
+ inBuf=dmapSrc;
+ inBytesLeft=0x60 * 0x60 * 3;
+ if (SS == 0x8E)
+ outBuf=(char *) &(dmap_rec[idx].dmapE22U[0x60]);
+ else
+ outBuf=(char *) &(dmap_rec[idx].dmapE32U[0x60]);
+ outBytesLeft=0x60 * 0x60 * 2;
+ do {
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "%02X:dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ SS, to, from, idx, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WO_TIME, "inBytesLeft=%d, outBytesLeft=%d\n", inBytesLeft, outBytesLeft);
+ if (inBuf - dmapSrc > 1 && inBuf - dmapSrc <= sizeof(dmapSrc) - 2)
+ MyPrintf(STDERR_WO_TIME, "inBuf[-2..2]=%02X%02X%02X%02X%02X\n", inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
+ else
+ MyPrintf(STDERR_WO_TIME, "inBuf[0..2]=%02X%02X%02X\n", inBuf[0],inBuf[1],inBuf[2]);
+ }
+#endif
+ if (errno == EILSEQ || errno == EINVAL) {
+ inBuf+=3;
+ inBytesLeft-=3;
+ outBuf[0]=0x00;
+ outBuf[1]=0x00;
+ outBuf+=2;
+ outBytesLeft-=2;
+ } else {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "%02X:dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ SS, to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ }
+ } while (inBytesLeft > 0);
+ }
+ if (SS == 0x8E)
+ SS=0x8F;
+ else
+ SS = 0x00;
+ }
+ iconv_close(cd);
+
+ myconv_rec[idx].subS=0x1A;
+ myconv_rec[idx].subD=0xFFFD;
+ for (i = 0; i < 0x80; ++i) {
+ if (dmap_rec[idx].dmapE02U[i] == 0x001A) {
+ myconv_rec[idx].srcSubS=i; /* pick the first one */
+ break;
+ }
+ }
+
+ for (i = 0; i < 0x60 * 0x60; ++i) {
+ if (dmap_rec[idx].dmapE12U[i] == 0xFFFD) {
+ uchar byte1=i / 0x60;
+ uchar byte2=i % 0x60;
+ myconv_rec[idx].srcSubD=(byte1 + 0xA0) * 0x100 + (byte2 + 0xA0); /* pick the last one */
+ }
+ }
+
+ }
+
+ } else if (((myconvIsUCS2(from) && myconvIsEUC(to)) && (dmap_rec[idx].codingSchema = DMAP_U2E)) ||
+ ((myconvIsUTF16(from) && myconvIsEUC(to)) && (dmap_rec[idx].codingSchema = DMAP_T2E)) ||
+ ((myconvIsUTF8(from) && myconvIsEUC(to)) && (dmap_rec[idx].codingSchema = DMAP_82E))) {
+ /* S0: 0x00 - 0xFF */
+ if ((dmap_rec[idx].dmapU2S = (uchar *) alloc_root(&dmapMemRoot, 0x100)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_U2E, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapU2S, 0x00, 0x100);
+
+ /* U0080 - UFFFF -> S1: 0xA0 - 0xFF, 0xA0 - 0xFF */
+ if ((dmap_rec[idx].dmapU2M2 = (uchar *) alloc_root(&dmapMemRoot, 0xFF80 * 2)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_U2E, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapU2M2, 0x00, 0xFF80 * 2);
+
+ /* U0080 - UFFFF -> SS2: 0x8E + 0xA0 - 0xFF, 0xA0 - 0xFF
+ * SS3: 0x8F + 0xA0 - 0xFF, 0xA0 - 0xFF */
+ if ((dmap_rec[idx].dmapU2M3 = (uchar *) alloc_root(&dmapMemRoot, 0xFF80 * 3)) == NULL) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d), CS=%d failed with malloc(), errno = %d in %s at %d\n",
+ to, from, idx, DMAP_U2E, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+ memset(dmap_rec[idx].dmapU2M3, 0x00, 0xFF80 * 3);
+ myconv_rec[idx].allocatedSize=(0x100 + 0xFF80 * 2 + 0xFF80 * 3);
+
+ {
+ UniChar dmapSrc[0x80];
+ iconv_t cd;
+ int32_t i;
+ size_t inBytesLeft;
+ size_t outBytesLeft;
+ size_t len;
+ char * inBuf;
+ char * outBuf;
+
+#ifdef support_surrogate
+ if ((cd = iconv_open(to, "UTF-16")) == (iconv_t) -1) {
+#else
+ if ((cd = iconv_open(to, "UCS-2")) == (iconv_t) -1) {
+#endif
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed with iconv_open(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ return -1;
+ }
+
+ for (i = 0; i < 0x80; ++i)
+ dmapSrc[i]=i;
+ inBuf=(char *) dmapSrc;
+ inBytesLeft=0x80 * 2;
+ outBuf=(char *) dmap_rec[idx].dmapU2S;
+ outBytesLeft=0x80;
+ do {
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+#ifdef DEBUG
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ } while (inBytesLeft > 0);
+
+ myconv_rec[idx].srcSubS = 0x1A;
+ myconv_rec[idx].srcSubD = 0xFFFD;
+ myconv_rec[idx].subS = dmap_rec[idx].dmapU2S[0x1A];
+
+ outBuf=(char *) &(myconv_rec[idx].subD);
+ dmapSrc[0]=0xFFFD;
+ inBuf=(char *) dmapSrc;
+ inBytesLeft=2;
+ outBytesLeft=2;
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), rc=%d, errno=%d in %s at %d\n",
+ to, from, idx, len, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WO_TIME, "iconv(0x1A,1,%p,1) returns outBuf=%p, outBytesLeft=%d\n",
+ dmapSrc, outBuf, outBytesLeft);
+ }
+#endif
+ if (outBytesLeft == 0) {
+ /* UCS-2_IBM-eucKR returns error.
+ myconv(iconv) rc=1, error=0, InBytesLeft=0, OutBytesLeft=18
+ myconv(iconvRev) rc=-1, error=116, InBytesLeft=2, OutBytesLeft=20
+ iconv: 0xFFFD => 0xAFFE => 0x rc=1,-1 sub=0,0
+ */
+ ;
+ } else {
+ iconv_close(cd);
+ return -1;
+ }
+ }
+
+ for (i = 0x80; i < 0xFFFF; ++i) {
+ uchar eucBuf[3];
+ dmapSrc[0]=i;
+ inBuf=(char *) dmapSrc;
+ inBytesLeft=2;
+ outBuf=(char *) eucBuf;
+ outBytesLeft=sizeof(eucBuf);
+ errno=0;
+ if ((len = iconv(cd, &inBuf, &inBytesLeft, &outBuf, &outBytesLeft)) != (size_t) 0) {
+ if (len == 1 && errno == 0 && inBytesLeft == 0 && outBytesLeft == 1) { /* substitution occurred. */ continue;
+ }
+
+ if (errno == EILSEQ) {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), errno = %d in %s at %d\n",
+ to, from, idx, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WO_TIME, "inBytesLeft=%d, outBytesLeft=%d\n", inBytesLeft, outBytesLeft);
+ if (inBuf - (char *) dmapSrc > 1 && inBuf - (char *) dmapSrc <= sizeof(dmapSrc) - 2)
+ MyPrintf(STDERR_WO_TIME, "inBuf[-2..2]=%02X%02X%02X%02X%02X\n", inBuf[-2],inBuf[-1],inBuf[0],inBuf[1],inBuf[2]);
+ else
+ MyPrintf(STDERR_WO_TIME, "inBuf[0..2]=%02X%02X%02X\n", inBuf[0],inBuf[1],inBuf[2]);
+ if (outBuf - (char *) dmap_rec[idx].dmapU2M2 > 1)
+ MyPrintf(STDERR_WO_TIME, "outBuf[-2..2]=%02X%02X%02X%02X%02X\n", outBuf[-2],outBuf[-1],outBuf[0],outBuf[1],outBuf[2]);
+ else
+ MyPrintf(STDERR_WO_TIME, "outBuf[0..2]=%02X%02X%02X\n", outBuf[0],outBuf[1],outBuf[2]);
+ }
+#endif
+ inBuf+=2;
+ inBytesLeft-=2;
+ memcpy(outBuf, (char *) &(myconv_rec[idx].subD), 2);
+ outBuf+=2;
+ outBytesLeft-=2;
+ } else {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), rc = %d, errno = %d in %s at %d\n",
+ to, from, idx, len, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WITH_TIME,
+ "%04X: src=%04X%04X, inBuf=0x%02X%02X, inBytesLeft=%d, outBuf[-2..0]=%02X%02X%02X, outBytesLeft=%d\n",
+ i, dmapSrc[0], dmapSrc[1], inBuf[0], inBuf[1],
+ inBytesLeft, outBuf[-2], outBuf[-1], outBuf[0], outBytesLeft);
+ MyPrintf(STDERR_WITH_TIME,
+ "&dmapSrc=%p, inBuf=%p, dmapU2M2 + %d = %p, outBuf=%p\n",
+ dmapSrc, inBuf, (i - 0x80) * 2, dmap_rec[idx].dmapU2M2 + (i - 0x80) * 2, outBuf);
+ }
+#endif
+ iconv_close(cd);
+ return -1;
+ }
+ }
+ if (sizeof(eucBuf) - outBytesLeft == 1) {
+ if (i < 0x100) {
+ (dmap_rec[idx].dmapU2S)[i]=eucBuf[0];
+ } else {
+ dmap_rec[idx].dmapU2M2[(i - 0x80) * 2] = eucBuf[0];
+ dmap_rec[idx].dmapU2M2[(i - 0x80) * 2 + 1] = 0x00;
+ }
+ } else if (sizeof(eucBuf) - outBytesLeft == 2) { /* 2 bytes */
+ dmap_rec[idx].dmapU2M2[(i - 0x80) * 2] = eucBuf[0];
+ dmap_rec[idx].dmapU2M2[(i - 0x80) * 2 + 1] = eucBuf[1];
+ } else if (sizeof(eucBuf) - outBytesLeft == 3) { /* 3 byte SS2/SS3 */
+ dmap_rec[idx].dmapU2M3[(i - 0x80) * 3] = eucBuf[0];
+ dmap_rec[idx].dmapU2M3[(i - 0x80) * 3 + 1] = eucBuf[1];
+ dmap_rec[idx].dmapU2M3[(i - 0x80) * 3 + 2] = eucBuf[2];
+ } else {
+#ifdef DEBUG
+ if (myconvDebug) {
+ MyPrintf(STDERR_WITH_TIME,
+ "dmap_open(%s,%s,%d) failed to initialize with iconv(), rc=%d, errno=%d in %s at %d\n",
+ to, from, idx, len, errno, __FILE__,__LINE__);
+ MyPrintf(STDERR_WITH_TIME,
+ "%04X: src=%04X%04X, inBuf=0x%02X%02X, inBytesLeft=%d, outBuf=%02X%02X%02X, outBytesLeft=%d\n",
+ i, dmapSrc[0], dmapSrc[1], inBuf[0], inBuf[1],
+ inBytesLeft, outBuf[-2], outBuf[-1], outBuf[0], outBytesLeft);
+ MyPrintf(STDERR_WITH_TIME,
+ "&dmapSrc=%p, inBuf=%p, %p, outBuf=%p\n",
+ dmapSrc, inBuf, dmap_rec[idx].dmapU2M3 + (i - 0x80) * 2, outBuf);
+ }
+#endif
+ return -1;
+ }
+
+ }
+ iconv_close(cd);
+ }
+
+ } else if (myconvIsUTF16(from) && myconvIsUTF8(to)) {
+ dmap_rec[idx].codingSchema = DMAP_T28;
+
+ } else if (myconvIsUCS2(from) && myconvIsUTF8(to)) {
+ dmap_rec[idx].codingSchema = DMAP_U28;
+
+ } else if (myconvIsUTF8(from) && myconvIsUnicode2(to)) {
+ dmap_rec[idx].codingSchema = DMAP_82U;
+
+ } else if (myconvIsUnicode2(from) && myconvIsUnicode2(to)) {
+ dmap_rec[idx].codingSchema = DMAP_U2U;
+
+ } else {
+
+ return -1;
+ }
+ myconv_rec[idx].cnv_dmap=&(dmap_rec[idx]);
+ return 0;
+}
+
+
+
+static int bins_open(const char * to,
+ const char * from,
+ const int32_t idx)
+{
+ return -1;
+}
+
+
+
+static int32_t dmap_close(const int32_t idx)
+{
+ if (dmap_rec[idx].codingSchema == DMAP_S2S) {
+ if (dmap_rec[idx].dmapS2S != NULL) {
+ dmap_rec[idx].dmapS2S=NULL;
+ }
+ } else if (dmap_rec[idx].codingSchema = DMAP_E2U) {
+ if (dmap_rec[idx].dmapE02U != NULL) {
+ dmap_rec[idx].dmapE02U=NULL;
+ }
+ if (dmap_rec[idx].dmapE12U != NULL) {
+ dmap_rec[idx].dmapE12U=NULL;
+ }
+ if (dmap_rec[idx].dmapE22U != NULL) {
+ dmap_rec[idx].dmapE22U=NULL;
+ }
+ if (dmap_rec[idx].dmapE32U != NULL) {
+ dmap_rec[idx].dmapE32U=NULL;
+ }
+ }
+
+ return 0;
+}
+
+
+static int32_t bins_close(const int32_t idx)
+{
+ return 0;
+}
+
+
+myconv_t myconv_open(const char * toCode,
+ const char * fromCode,
+ int32_t converter)
+{
+ int32 i;
+ for (i = 0; i < MAX_CONVERTER; ++i) {
+ if (myconv_rec[i].converterType == 0)
+ break;
+ }
+ if (i >= MAX_CONVERTER)
+ return ((myconv_t) -1);
+
+ myconv_rec[i].converterType = converter;
+ myconv_rec[i].index=i;
+ myconv_rec[i].fromCcsid=cstoccsid(fromCode);
+ if (myconv_rec[i].fromCcsid == 0 && memcmp(fromCode, "big5",5) == 0)
+ myconv_rec[i].fromCcsid=950;
+ myconv_rec[i].toCcsid=cstoccsid(toCode);
+ if (myconv_rec[i].toCcsid == 0 && memcmp(toCode, "big5",5) == 0)
+ myconv_rec[i].toCcsid=950;
+ strncpy(myconv_rec[i].from, fromCode, sizeof(myconv_rec[i].from)-1);
+ strncpy(myconv_rec[i].to, toCode, sizeof(myconv_rec[i].to)-1);
+
+ if (converter == CONVERTER_ICONV) {
+ if ((myconv_rec[i].cnv_iconv=iconv_open(toCode, fromCode)) == (iconv_t) -1) {
+ return ((myconv_t) -1);
+ }
+ myconv_rec[i].allocatedSize = -1;
+ myconv_rec[i].srcSubS=myconvGetSubS(fromCode);
+ myconv_rec[i].srcSubD=myconvGetSubD(fromCode);
+ myconv_rec[i].subS=myconvGetSubS(toCode);
+ myconv_rec[i].subD=myconvGetSubD(toCode);
+ return &(myconv_rec[i]);
+ } else if (converter == CONVERTER_DMAP &&
+ dmap_open(toCode, fromCode, i) != -1) {
+ return &(myconv_rec[i]);
+ }
+ return ((myconv_t) -1);
+}
+
+
+
+int32_t myconv_close(myconv_t cd)
+{
+ int32_t ret=0;
+
+ if (cd->converterType == CONVERTER_ICONV) {
+ ret=iconv_close(cd->cnv_iconv);
+ } else if (cd->converterType == CONVERTER_DMAP) {
+ ret=dmap_close(cd->index);
+ }
+ memset(&(myconv_rec[cd->index]), 0x00, sizeof(myconv_rec[cd->index]));
+ return ret;
+}
+
+
+
+
+/* reference: http://www-306.ibm.com/software/globalization/other/es.jsp */
+/* systemCL would be expensive, and myconvIsXXXXX is called frequently.
+ need to cache entries */
+#define MAX_CCSID 256
+static int ccsidList [MAX_CCSID];
+static int esList [MAX_CCSID];
+int32 getEncodingScheme(const uint16 inCcsid, int32& outEncodingScheme);
+EXTERN int myconvGetES(CCSID ccsid)
+{
+ /* call QtqValidateCCSID in ILE to get encoding schema */
+ /* return QtqValidateCCSID(ccsid); */
+ int i;
+ for (i = 0; i < MAX_CCSID; ++i) {
+ if (ccsidList[i] == ccsid)
+ return esList[i];
+ if (ccsidList[i] == 0x00)
+ break;
+ }
+
+ if (i >= MAX_CCSID) {
+ i=MAX_CCSID-1;
+ }
+
+ {
+ ccsidList[i]=ccsid;
+ getEncodingScheme(ccsid, esList[i]);
+#ifdef DEBUG_PASE
+ if (myconvDebug) {
+ fprintf(stderr, "CCSID=%d, ES=0x%04X\n", ccsid, esList[i]);
+ }
+#endif
+ return esList[i];
+ }
+ return 0;
+}
+
+
+EXTERN int myconvIsEBCDIC(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x1100 ||
+ es == 0x1200 ||
+ es == 0x6100 ||
+ es == 0x6200 ||
+ es == 0x1301 ) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsISO(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x4100 ||
+ es == 0x4105 ||
+ es == 0x4155 ||
+ es == 0x5100 ||
+ es == 0x5150 ||
+ es == 0x5200 ||
+ es == 0x5404 ||
+ es == 0x5409 ||
+ es == 0x540A ||
+ es == 0x5700) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsASCII(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x2100 ||
+ es == 0x3100 ||
+ es == 0x8100 ||
+ es == 0x2200 ||
+ es == 0x3200 ||
+ es == 0x9200 ||
+ es == 0x2300 ||
+ es == 0x2305 ||
+ es == 0x3300 ||
+ es == 0x2900 ||
+ es == 0x2A00) {
+ return TRUE;
+ } else if (memcmp(pName, "big5", 5) == 0) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+
+EXTERN int myconvIsUCS2(const char * pName)
+{
+ if (cstoccsid(pName) == 13488) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsUTF16(const char * pName)
+{
+ if (cstoccsid(pName) == 1200) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsUnicode2(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x7200 ||
+ es == 0x720B ||
+ es == 0x720F) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsUTF8(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x7807) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsUnicode(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x7200 ||
+ es == 0x720B ||
+ es == 0x720F ||
+ es == 0x7807) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsEUC(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x4403) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsDBCS(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x1200 ||
+ es == 0x2200 ||
+ es == 0x2300 ||
+ es == 0x2305 ||
+ es == 0x2A00 ||
+ es == 0x3200 ||
+ es == 0x3300 ||
+ es == 0x5200 ||
+ es == 0x6200 ||
+ es == 0x9200) {
+ return TRUE;
+ } else if (memcmp(pName, "big5", 5) == 0) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+EXTERN int myconvIsSBCS(const char * pName)
+{
+ int es = myconvGetES(cstoccsid(pName));
+ if (es == 0x1100 ||
+ es == 0x2100 ||
+ es == 0x3100 ||
+ es == 0x4100 ||
+ es == 0x4105 ||
+ es == 0x5100 ||
+ es == 0x5150 ||
+ es == 0x6100 ||
+ es == 0x8100) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+
+EXTERN char myconvGetSubS(const char * code)
+{
+ if (myconvIsEBCDIC(code)) {
+ return 0x3F;
+ } else if (myconvIsASCII(code)) {
+ return 0x1A;
+ } else if (myconvIsISO(code)) {
+ return 0x1A;
+ } else if (myconvIsEUC(code)) {
+ return 0x1A;
+ } else if (myconvIsUCS2(code)) {
+ return 0x00;
+ } else if (myconvIsUTF8(code)) {
+ return 0x1A;
+ }
+ return 0x00;
+}
+
+
+EXTERN UniChar myconvGetSubD(const char * code)
+{
+ if (myconvIsEBCDIC(code)) {
+ return 0xFDFD;
+ } else if (myconvIsASCII(code)) {
+ return 0xFCFC;
+ } else if (myconvIsISO(code)) {
+ return 0x00;
+ } else if (myconvIsEUC(code)) {
+ return 0x00;
+ } else if (myconvIsUCS2(code)) {
+ return 0xFFFD;
+ } else if (myconvIsUTF8(code)) {
+ return 0x00;
+ }
+ return 0x00;
+}
+
diff --git a/storage/ibmdb2i/db2i_myconv.h b/storage/ibmdb2i/db2i_myconv.h
new file mode 100644
index 00000000000..a9e87474505
--- /dev/null
+++ b/storage/ibmdb2i/db2i_myconv.h
@@ -0,0 +1,3200 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+/**
+ @file
+
+ @brief A direct map optimization of iconv and related functions
+ This was show to significantly reduce character conversion cost
+ for short strings when compared to calling iconv system code.
+*/
+
+#ifndef DB2I_MYCONV_H
+#define DB2I_MYCONV_H
+
+
+#include <sys/time.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <errno.h>
+#include <iconv.h>
+#include <ctype.h>
+#include <time.h>
+#include <stdarg.h>
+#include <string.h>
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifdef __cplusplus
+#define INTERN inline
+#define EXTERN extern "C"
+#else
+#define INTERN static
+#define EXTERN extern
+#endif
+
+
+/* ANSI integer data types */
+#if defined(__OS400_TGTVRM__)
+/* for DTAMDL(*P128), datamodel(P128): int/long/pointer=4/4/16 */
+/* LLP64:4/4/8 is used for teraspace ?? */
+typedef short int16_t;
+typedef unsigned short uint16_t;
+typedef int int32_t;
+typedef unsigned int uint32_t;
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+#elif defined(PASE)
+/* PASE uses IPL32: int/long/pointer=4/4/4 + long long */
+#elif defined(__64BIT__)
+/* AIX 64 bit uses LP64: int/long/pointer=4/8/8 */
+#endif
+
+#define CONVERTER_ICONV 1
+#define CONVERTER_DMAP 2
+
+#define DMAP_S2S 10
+#define DMAP_S2U 20
+#define DMAP_D2U 30
+#define DMAP_E2U 40
+#define DMAP_U2S 120
+#define DMAP_T2S 125
+#define DMAP_U2D 130
+#define DMAP_T2D 135
+#define DMAP_U2E 140
+#define DMAP_T2E 145
+#define DMAP_S28 220
+#define DMAP_D28 230
+#define DMAP_E28 240
+#define DMAP_82S 310
+#define DMAP_82D 320
+#define DMAP_82E 330
+#define DMAP_U28 410
+#define DMAP_82U 420
+#define DMAP_T28 425
+#define DMAP_U2U 510
+
+
+typedef struct __dmap_rec *dmap_t;
+
+struct __dmap_rec
+{
+ uint32_t codingSchema;
+ unsigned char * dmapS2S; /* SBCS -> SBCS */
+ /* The following conversion needs be followed by conversion from UCS-2/UTF-16 to UTF-8 */
+ UniChar * dmapD12U; /* DBCS(non-EUC) -> UCS-2/UTF-16 */
+ UniChar * dmapD22U; /* DBCS(non-EUC) -> UCS-2/UTF-16 */
+ UniChar * dmapE02U; /* EUC/SS0 -> UCS-2/UTF-16 */
+ UniChar * dmapE12U; /* EUC/SS1 -> UCS-2/UTF-16 */
+ UniChar * dmapE22U; /* EUC/0x8E + SS2 -> UCS-2/UTF-16 */
+ UniChar * dmapE32U; /* EUC/0x8F + SS3 -> UCS-2/UTF-16 */
+ uchar * dmapU2D; /* UCS-2 -> DBCS */
+ uchar * dmapU2S; /* UCS-2 -> EUC SS0 */
+ uchar * dmapU2M2; /* UCS-2 -> EUC SS1 */
+ uchar * dmapU2M3; /* UCS-2 -> EUC SS2/SS3 */
+ /* All of these pointers/tables are not used at the same time.
+ * You may be able save some space if you consolidate them.
+ */
+ uchar * dmapS28; /* SBCS -> UTF-8 */
+ uchar * dmapD28; /* DBCS -> UTF-8 */
+};
+
+typedef struct __myconv_rec *myconv_t;
+struct __myconv_rec
+{
+ uint32_t converterType;
+ uint32_t index; /* for close */
+ union {
+ iconv_t cnv_iconv;
+ dmap_t cnv_dmap;
+ };
+ int32_t allocatedSize;
+ int32_t fromCcsid;
+ int32_t toCcsid;
+ UniChar subD; /* DBCS substitution char */
+ char subS; /* SBCS substitution char */
+ UniChar srcSubD; /* DBCS substitution char of src codepage */
+ char srcSubS; /* SBCS substitution char of src codepage */
+ char from [41+1]; /* codepage name is up to 41 bytes */
+ char to [41+1]; /* codepage name is up to 41 bytes */
+#ifdef __64BIT__
+ char reserved[10]; /* align 128 */
+#else
+ char reserved[14]; /* align 128 */
+#endif
+};
+
+
+EXTERN int32_t myconvDebug;
+
+
+
+EXTERN int myconvGetES(CCSID);
+EXTERN int myconvIsEBCDIC(const char *);
+EXTERN int myconvIsASCII(const char *);
+EXTERN int myconvIsUnicode(const char *); /* UTF-8, UTF-16, or UCS-2 */
+EXTERN int myconvIsUnicode2(const char *); /* 2 byte Unicode */
+EXTERN int myconvIsUCS2(const char *);
+EXTERN int myconvIsUTF16(const char *);
+EXTERN int myconvIsUTF8(const char *);
+EXTERN int myconvIsEUC(const char *);
+EXTERN int myconvIsISO(const char *);
+EXTERN int myconvIsSBCS(const char *);
+EXTERN int myconvIsDBCS(const char *);
+EXTERN char myconvGetSubS(const char *);
+EXTERN UniChar myconvGetSubD(const char *);
+
+
+EXTERN myconv_t myconv_open(const char*, const char*, int32_t);
+EXTERN int myconv_close(myconv_t);
+
+INTERN size_t myconv_iconv(myconv_t cd ,
+ char** inBuf,
+ size_t* inBytesLeft,
+ char** outBuf,
+ size_t* outBytesLeft,
+ size_t* numSub)
+{
+ return iconv(cd->cnv_iconv, inBuf, inBytesLeft, outBuf, outBytesLeft);
+}
+
+INTERN size_t myconv_dmap(myconv_t cd,
+ char** inBuf,
+ size_t* inBytesLeft,
+ char** outBuf,
+ size_t* outBytesLeft,
+ size_t* numSub)
+{
+ if (cd->cnv_dmap->codingSchema == DMAP_S2S) {
+ register unsigned char * dmapS2S=cd->cnv_dmap->dmapS2S;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register size_t numS=0;
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ } else {
+ *pOut=dmapS2S[*pIn];
+ if (*pOut == 0x00) {
+ *outBytesLeft-=(*inBytesLeft-inLen);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ if (*pOut == subS) {
+ if ((*pOut=dmapS2S[*pIn]) == subS) {
+ if (*pIn != cd->srcSubS)
+ ++numS;
+ }
+ }
+ }
+ ++pIn;
+ --inLen;
+ ++pOut;
+ }
+ *outBytesLeft-=(*inBytesLeft-inLen);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_E2U) {
+ /* use uchar * instead of UniChar to avoid memcpy */
+ register uchar * dmapE02U=(uchar *) (cd->cnv_dmap->dmapE02U);
+ register uchar * dmapE12U=(uchar *) (cd->cnv_dmap->dmapE12U);
+ register uchar * dmapE22U=(uchar *) (cd->cnv_dmap->dmapE22U);
+ register uchar * dmapE32U=(uchar *) (cd->cnv_dmap->dmapE32U);
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register int offset;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register size_t numS=0;
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ ++pOut;
+ *pOut=0x00;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else {
+ if (*pIn == 0x8E) { /* SS2 */
+ if (inLen < 2) {
+ if (cd->fromCcsid == 33722 || /* IBM-eucJP */
+ cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ ++pIn;
+ if (*pIn < 0xA0) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE22U[offset] == 0x00 &&
+ dmapE22U[offset+1] == 0x00) { /* 2 bytes */
+ if (inLen < 3) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0) * 0x60 + 0x60;
+ ++pIn;
+ if (*pIn < 0xA0) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ offset+=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE22U[offset] == 0x00 &&
+ dmapE22U[offset+1] == 0x00) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ *pOut=dmapE22U[offset];
+ ++pOut;
+ *pOut=dmapE22U[offset+1];
+ ++pOut;
+ if (dmapE22U[offset] == 0xFF &&
+ dmapE22U[offset+1] == 0xFD) {
+ if (pIn[-2] * 0x100 + pIn[-1] != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=3;
+ } else { /* 1 bytes */
+ *pOut=dmapE22U[offset];
+ ++pOut;
+ *pOut=dmapE22U[offset+1];
+ ++pOut;
+ ++pIn;
+ inLen-=2;
+ }
+ } else if (*pIn == 0x8F) { /* SS3 */
+ if (inLen < 2) {
+ if (cd->fromCcsid == 33722) /* IBM-eucJP */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ ++pIn;
+ if (*pIn < 0xA0) {
+ if (cd->fromCcsid == 970 || /* IBM-eucKR */
+ cd->fromCcsid == 964 || /* IBM-eucTW */
+ cd->fromCcsid == 1383 || /* IBM-eucCN */
+ (cd->fromCcsid == 33722 && 3 <= inLen)) /* IBM-eucJP */
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE32U[offset] == 0x00 &&
+ dmapE32U[offset+1] == 0x00) { /* 0x8F + 2 bytes */
+ if (inLen < 3) {
+ if (cd->fromCcsid == 33722)
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0) * 0x60 + 0x60;
+ ++pIn;
+ if (*pIn < 0xA0) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ offset+=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE32U[offset] == 0x00 &&
+ dmapE32U[offset+1] == 0x00) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ *pOut=dmapE32U[offset];
+ ++pOut;
+ *pOut=dmapE32U[offset+1];
+ ++pOut;
+ if (dmapE32U[offset] == 0xFF &&
+ dmapE32U[offset+1] == 0xFD) {
+ if (pIn[-2] * 0x100 + pIn[-1] != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=3;
+ } else { /* 0x8F + 1 bytes */
+ *pOut=dmapE32U[offset];
+ ++pOut;
+ *pOut=dmapE32U[offset+1];
+ ++pOut;
+ ++pIn;
+ inLen-=2;
+ }
+
+ } else {
+ offset=*pIn;
+ offset<<=1;
+ if (dmapE02U[offset] == 0x00 &&
+ dmapE02U[offset+1] == 0x00) { /* SS1 */
+ if (inLen < 2) {
+ if ((cd->fromCcsid == 33722 && (*pIn == 0xA0 || (0xA9 <= *pIn && *pIn <= 0xAF) || *pIn == 0xFF)) ||
+ (cd->fromCcsid == 970 && (*pIn == 0xA0 || *pIn == 0xAD || *pIn == 0xAE || *pIn == 0xAF || *pIn == 0xFF)) ||
+ (cd->fromCcsid == 964 && (*pIn == 0xA0 || (0xAA <= *pIn && *pIn <= 0xC1) || *pIn == 0xC3 || *pIn == 0xFE || *pIn == 0xFF)) ||
+ (cd->fromCcsid == 1383 && (*pIn == 0xA0 || *pIn == 0xFF)))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ if (*pIn < 0xA0) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ offset=(*pIn - 0xA0) * 0x60;
+ ++pIn;
+ if (*pIn < 0xA0) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset+=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE12U[offset] == 0x00 &&
+ dmapE12U[offset+1] == 0x00) { /* undefined mapping */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ *pOut=dmapE12U[offset];
+ ++pOut;
+ *pOut=dmapE12U[offset+1];
+ ++pOut;
+ if (dmapE12U[offset] == 0xFF &&
+ dmapE12U[offset+1] == 0xFD) {
+ if (pIn[-1] * 0x100 + pIn[0] != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=2;
+ } else {
+ *pOut=dmapE02U[offset];
+ ++pOut;
+ *pOut=dmapE02U[offset+1];
+ ++pOut;
+ if (dmapE02U[offset] == 0x00 &&
+ dmapE02U[offset+1] == 0x1A) {
+ if (*pIn != cd->srcSubS)
+ ++numS;
+ }
+ ++pIn;
+ --inLen;
+ }
+ }
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_E28) {
+ /* use uchar * instead of UniChar to avoid memcpy */
+ register uchar * dmapE02U=(uchar *) (cd->cnv_dmap->dmapE02U);
+ register uchar * dmapE12U=(uchar *) (cd->cnv_dmap->dmapE12U);
+ register uchar * dmapE22U=(uchar *) (cd->cnv_dmap->dmapE22U);
+ register uchar * dmapE32U=(uchar *) (cd->cnv_dmap->dmapE32U);
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register int offset;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register size_t numS=0;
+ register UniChar in; /* copy part of U28 */
+ register UniChar ucs2;
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else {
+ if (*pIn == 0x8E) { /* SS2 */
+ if (inLen < 2) {
+ if (cd->fromCcsid == 33722 || /* IBM-eucJP */
+ cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ ++pIn;
+ if (*pIn < 0xA0) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE22U[offset] == 0x00 &&
+ dmapE22U[offset+1] == 0x00) { /* 2 bytes */
+ if (inLen < 3) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0) * 0x60 + 0x60;
+ ++pIn;
+ if (*pIn < 0xA0) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ offset+=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE22U[offset] == 0x00 &&
+ dmapE22U[offset+1] == 0x00) {
+ if (cd->fromCcsid == 964) /* IBM-eucTW */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ in=dmapE22U[offset];
+ in<<=8;
+ in+=dmapE22U[offset+1];
+ if (dmapE22U[offset] == 0xFF &&
+ dmapE22U[offset+1] == 0xFD) {
+ if (pIn[-2] * 0x100 + pIn[-1] != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=3;
+ } else { /* 1 bytes */
+ in=dmapE22U[offset];
+ in<<=8;
+ in+=dmapE22U[offset+1];
+ ++pIn;
+ inLen-=2;
+ }
+ } else if (*pIn == 0x8F) { /* SS3 */
+ if (inLen < 2) {
+ if (cd->fromCcsid == 33722) /* IBM-eucJP */
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ ++pIn;
+ if (*pIn < 0xA0) {
+ if (cd->fromCcsid == 970 || /* IBM-eucKR */
+ cd->fromCcsid == 964 || /* IBM-eucTW */
+ cd->fromCcsid == 1383 || /* IBM-eucCN */
+ (cd->fromCcsid == 33722 && 3 <= inLen)) /* IBM-eucJP */
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE32U[offset] == 0x00 &&
+ dmapE32U[offset+1] == 0x00) { /* 0x8F + 2 bytes */
+ if (inLen < 3) {
+ if (cd->fromCcsid == 33722)
+ errno=EINVAL; /* 22 */
+ else
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset=(*pIn - 0xA0) * 0x60 + 0x60;
+ ++pIn;
+ if (*pIn < 0xA0) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ offset+=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE32U[offset] == 0x00 &&
+ dmapE32U[offset+1] == 0x00) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ return -1;
+ }
+ in=dmapE32U[offset];
+ in<<=8;
+ in+=dmapE32U[offset+1];
+ if (dmapE32U[offset] == 0xFF &&
+ dmapE32U[offset+1] == 0xFD) {
+ if (pIn[-2] * 0x100 + pIn[-1] != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=3;
+ } else { /* 0x8F + 1 bytes */
+ in=dmapE32U[offset];
+ in<<=8;
+ in+=dmapE32U[offset+1];
+ ++pIn;
+ inLen-=2;
+ }
+
+ } else {
+ offset=*pIn;
+ offset<<=1;
+ if (dmapE02U[offset] == 0x00 &&
+ dmapE02U[offset+1] == 0x00) { /* SS1 */
+ if (inLen < 2) {
+ if ((cd->fromCcsid == 33722 && (*pIn == 0xA0 || (0xA9 <= *pIn && *pIn <= 0xAF) || *pIn == 0xFF)) ||
+ (cd->fromCcsid == 970 && (*pIn == 0xA0 || *pIn == 0xAD || *pIn == 0xAE || *pIn == 0xAF || *pIn == 0xFF)) ||
+ (cd->fromCcsid == 964 && (*pIn == 0xA0 || (0xAA <= *pIn && *pIn <= 0xC1) || *pIn == 0xC3 || *pIn == 0xFE || *pIn == 0xFF)) ||
+ (cd->fromCcsid == 1383 && (*pIn == 0xA0 || *pIn == 0xFF)))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ if (*pIn < 0xA0) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ offset=(*pIn - 0xA0) * 0x60;
+ ++pIn;
+ if (*pIn < 0xA0) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ offset+=(*pIn - 0xA0);
+ offset<<=1;
+ if (dmapE12U[offset] == 0x00 &&
+ dmapE12U[offset+1] == 0x00) { /* undefined mapping */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ in=dmapE12U[offset];
+ in<<=8;
+ in+=dmapE12U[offset+1];
+ if (dmapE12U[offset] == 0xFF &&
+ dmapE12U[offset+1] == 0xFD) {
+ if (pIn[-1] * 0x100 + pIn[0] != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=2;
+ } else {
+ in=dmapE02U[offset];
+ in<<=8;
+ in+=dmapE02U[offset+1];
+ if (dmapE02U[offset] == 0x00 &&
+ dmapE02U[offset+1] == 0x1A) {
+ if (*pIn != cd->srcSubS)
+ ++numS;
+ }
+ ++pIn;
+ --inLen;
+ }
+ }
+ ucs2=in;
+ if ((in & 0xFF80) == 0x0000) { /* U28: in & 0b1111111110000000 == 0x0000 */
+ *pOut=in;
+ ++pOut;
+ } else if ((in & 0xF800) == 0x0000) { /* in & 0b1111100000000000 == 0x0000 */
+ register uchar byte;
+ in>>=6;
+ in&=0x001F; /* 0b0000000000011111 */
+ in|=0x00C0; /* 0b0000000011000000 */
+ *pOut=in;
+ ++pOut;
+ byte=ucs2; /* dmapD12U[offset+1]; */
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ } else if ((in & 0xFC00) == 0xD800) {
+ *pOut=0xEF;
+ ++pOut;
+ *pOut=0xBF;
+ ++pOut;
+ *pOut=0xBD;
+ ++pOut;
+ } else {
+ register uchar byte;
+ register uchar work;
+ byte=(ucs2>>8); /* dmapD12U[offset]; */
+ byte>>=4;
+ byte|=0xE0; /* 0b11100000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=(ucs2>>8); /* dmapD12U[offset]; */
+ byte<<=2;
+ work=ucs2; /* dmapD12U[offset+1]; */
+ work>>=6;
+ byte|=work;
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=ucs2; /* dmapD12U[offset+1]; */
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ }
+ /* end of U28 */
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_U2E) {
+ register uchar * dmapU2S=cd->cnv_dmap->dmapU2S;
+ register uchar * dmapU2M2=cd->cnv_dmap->dmapU2M2 - 0x80 * 2;
+ register uchar * dmapU2M3=cd->cnv_dmap->dmapU2M3 - 0x80 * 3;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register char * pSubD=(char *) &(cd->subD);
+ register size_t numS=0;
+ register size_t rc=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else if (in < 0x100 && dmapU2S[in] != 0x0000) {
+ if ((*pOut=dmapU2S[in]) == subS) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ ++pOut;
+ } else {
+ in<<=1;
+ if (dmapU2M2[in] == 0x00) { /* not found in dmapU2M2 */
+ in*=1.5;
+ if (dmapU2M3[in] == 0x00) { /* not found in dmapU2M3*/
+ *pOut=pSubD[0];
+ ++pOut;
+ *pOut=pSubD[1];
+ ++pOut;
+ ++numS;
+ ++rc;
+ } else {
+ *pOut=dmapU2M3[in];
+ ++pOut;
+ *pOut=dmapU2M3[1+in];
+ ++pOut;
+ *pOut=dmapU2M3[2+in];
+ ++pOut;
+ }
+ } else {
+ *pOut=dmapU2M2[in];
+ ++pOut;
+ if (dmapU2M2[1+in] == 0x00) {
+ if (*pOut == subS) {
+ in>>=1;
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ } else {
+ *pOut=dmapU2M2[1+in];
+ ++pOut;
+ if (memcmp(pOut-2, pSubD, 2) == 0) {
+ in>>=1;
+ if (in != cd->srcSubD) {
+ ++numS;
+ ++rc;
+ }
+ }
+ }
+ }
+ }
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return rc; /* compatibility to iconv() */
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_T2E) {
+ register uchar * dmapU2S=cd->cnv_dmap->dmapU2S;
+ register uchar * dmapU2M2=cd->cnv_dmap->dmapU2M2 - 0x80 * 2;
+ register uchar * dmapU2M3=cd->cnv_dmap->dmapU2M3 - 0x80 * 3;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register char * pSubD=(char *) &(cd->subD);
+ register size_t numS=0;
+ register size_t rc=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen-1;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ ++numS;
+ *numSub+=numS;
+ return 0;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else if (0xD800 <= in && in <= 0xDBFF) { /* first byte of surrogate */
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-2;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn+2;
+ ++numS;
+ *numSub+=numS;
+ return -1;
+
+ } else if (0xDC00 <= in && in <= 0xDFFF) { /* second byte of surrogate */
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ ++numS;
+ *numSub+=numS;
+ return -1;
+
+ } else if (in < 0x100 && dmapU2S[in] != 0x0000) {
+ if ((*pOut=dmapU2S[in]) == subS) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ ++pOut;
+ } else {
+ in<<=1;
+ if (dmapU2M2[in] == 0x00) { /* not found in dmapU2M2 */
+ in*=1.5;
+ if (dmapU2M3[in] == 0x00) { /* not found in dmapU2M3*/
+ *pOut=pSubD[0];
+ ++pOut;
+ *pOut=pSubD[1];
+ ++pOut;
+ ++numS;
+ ++rc;
+ } else {
+ *pOut=dmapU2M3[in];
+ ++pOut;
+ *pOut=dmapU2M3[1+in];
+ ++pOut;
+ *pOut=dmapU2M3[2+in];
+ ++pOut;
+ }
+ } else {
+ *pOut=dmapU2M2[in];
+ ++pOut;
+ if (dmapU2M2[1+in] == 0x00) {
+ if (*pOut == subS) {
+ in>>=1;
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ } else {
+ *pOut=dmapU2M2[1+in];
+ ++pOut;
+ if (memcmp(pOut-2, pSubD, 2) == 0) {
+ in>>=1;
+ if (in != cd->srcSubD) {
+ ++numS;
+ ++rc;
+ }
+ }
+ }
+ }
+ }
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_82E) {
+ register uchar * dmapU2S=cd->cnv_dmap->dmapU2S;
+ register uchar * dmapU2M2=cd->cnv_dmap->dmapU2M2 - 0x80 * 2;
+ register uchar * dmapU2M3=cd->cnv_dmap->dmapU2M3 - 0x80 * 3;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register char * pSubD=(char *) &(cd->subD);
+ register size_t numS=0;
+ register size_t rc=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ uint32_t in2;
+ if (pLastOutBuf < pOut)
+ break;
+ /* convert from UTF-8 to UCS-2 */
+ if (*pIn == 0x00) {
+ in=0x0000;
+ ++pIn;
+ --inLen;
+ } else { /* 82U: */
+ register uchar byte1=*pIn;
+ if ((byte1 & 0x80) == 0x00) { /* if (byte1 & 0b10000000 == 0b00000000) { */
+ /* 1 bytes sequence: 0xxxxxxx => 00000000 0xxxxxxx*/
+ in=byte1;
+ ++pIn;
+ --inLen;
+ } else if ((byte1 & 0xE0) == 0xC0) { /* (byte1 & 0b11100000 == 0b11000000) { */
+ if (inLen < 2) {
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ if (byte1 == 0xC0 || byte1 == 0xC1) { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ /* 2 bytes sequence:
+ 110yyyyy 10xxxxxx => 00000yyy yyxxxxxx */
+ register uchar byte2;
+ ++pIn;
+ byte2=*pIn;
+ if ((byte2 & 0xC0) == 0x80) { /* byte2 & 0b11000000 == 0b10000000) { */
+ register uchar work=byte1;
+ work<<=6;
+ byte2&=0x3F; /* 0b00111111; */
+ byte2|=work;
+
+ byte1&=0x1F; /* 0b00011111; */
+ byte1>>=2;
+ in=byte1;
+ in<<=8;
+ in+=byte2;
+ inLen-=2;
+ ++pIn;
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if ((byte1 & 0xF0) == 0xE0) { /* byte1 & 0b11110000 == 0b11100000 */
+ /* 3 bytes sequence:
+ 1110zzzz 10yyyyyy 10xxxxxx => zzzzyyyy yyxxxxxx */
+ register uchar byte2;
+ register uchar byte3;
+ if (inLen < 3) {
+ if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ if ((byte2 & 0xC0) != 0x80 ||
+ (byte3 & 0xC0) != 0x80 ||
+ (byte1 == 0xE0 && byte2 < 0xA0)) { /* invalid sequence, only 0xA0-0xBF allowed after 0xE0 */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ *numSub+=numS;
+ return -1;
+ }
+ {
+ register uchar work=byte2;
+ work<<=6;
+ byte3&=0x3F; /* 0b00111111; */
+ byte3|=work;
+
+ byte2&=0x3F; /* 0b00111111; */
+ byte2>>=2;
+
+ byte1<<=4;
+ in=byte1 | byte2;;
+ in<<=8;
+ in+=byte3;
+ inLen-=3;
+ ++pIn;
+ }
+ } else if ((0xF0 <= byte1 && byte1 <= 0xF4)) { /* (bytes1 & 11111000) == 0x1110000 */
+ /* 4 bytes sequence
+ 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx => 110110ww wwzzzzyy 110111yy yyxxxxxx
+ where uuuuu = wwww + 1 */
+ register uchar byte2;
+ register uchar byte3;
+ register uchar byte4;
+ if (inLen < 4) {
+ if ((inLen >= 2 && (pIn[1] & 0xC0) != 0x80) ||
+ (inLen >= 3 && (pIn[2] & 0xC0) != 0x80) ||
+ (cd->toCcsid == 13488) )
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ ++pIn;
+ byte4=*pIn;
+ if ((byte2 & 0xC0) == 0x80 && /* byte2 & 0b11000000 == 0b10000000 */
+ (byte3 & 0xC0) == 0x80 && /* byte3 & 0b11000000 == 0b10000000 */
+ (byte4 & 0xC0) == 0x80) { /* byte4 & 0b11000000 == 0b10000000 */
+ register uchar work=byte2;
+ if (byte1 == 0xF0 && byte2 < 0x90) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ /* iconv() returns 0 for 0xF4908080 and convert to 0x00
+ } else if (byte1 == 0xF4 && byte2 > 0x8F) {
+ errno=EINVAL;
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ */
+ }
+
+ work&=0x30; /* 0b00110000; */
+ work>>=4;
+ byte1&=0x07; /* 0b00000111; */
+ byte1<<=2;
+ byte1+=work; /* uuuuu */
+ --byte1; /* wwww */
+
+ work=byte1 & 0x0F;
+ work>>=2;
+ work+=0xD8; /* 0b11011011; */
+ in=work;
+ in<<=8;
+
+ byte1<<=6;
+ byte2<<=2;
+ byte2&=0x3C; /* 0b00111100; */
+ work=byte3;
+ work>>=4;
+ work&=0x03; /* 0b00000011; */
+ work|=byte1;
+ work|=byte2;
+ in+=work;
+
+ work=byte3;
+ work>>=2;
+ work&=0x03; /* 0b00000011; */
+ work|=0xDC; /* 0b110111xx; */
+ in2=work;
+ in2<<=8;
+
+ byte3<<=6;
+ byte4&=0x3F; /* 0b00111111; */
+ byte4|=byte3;
+ in2+=byte4;
+ inLen-=4;
+ ++pIn;
+#ifdef match_with_GBK
+ if ((0xD800 == in && in2 < 0xDC80) ||
+ (0xD840 == in && in2 < 0xDC80) ||
+ (0xD880 == in && in2 < 0xDC80) ||
+ (0xD8C0 == in && in2 < 0xDC80) ||
+ (0xD900 == in && in2 < 0xDC80) ||
+ (0xD940 == in && in2 < 0xDC80) ||
+ (0xD980 == in && in2 < 0xDC80) ||
+ (0xD9C0 == in && in2 < 0xDC80) ||
+ (0xDA00 == in && in2 < 0xDC80) ||
+ (0xDA40 == in && in2 < 0xDC80) ||
+ (0xDA80 == in && in2 < 0xDC80) ||
+ (0xDAC0 == in && in2 < 0xDC80) ||
+ (0xDB00 == in && in2 < 0xDC80) ||
+ (0xDB40 == in && in2 < 0xDC80) ||
+ (0xDB80 == in && in2 < 0xDC80) ||
+ (0xDBC0 == in && in2 < 0xDC80)) {
+#else
+ if ((0xD800 <= in && in <= 0xDBFF) &&
+ (0xDC00 <= in2 && in2 <= 0xDFFF)) {
+#endif
+ *pOut=subS;
+ ++pOut;
+ ++numS;
+ continue;
+ }
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if (0xF5 <= byte1 && byte1 <= 0xFF) { /* minic iconv() behavior */
+ if (inLen < 4 ||
+ (inLen >= 4 && byte1 == 0xF8 && pIn[1] < 0x90) ||
+ pIn[1] < 0x80 || 0xBF < pIn[1] ||
+ pIn[2] < 0x80 || 0xBF < pIn[2] ||
+ pIn[3] < 0x80 || 0xBF < pIn[3] ) {
+ if (inLen == 1)
+ errno=EINVAL; /* 22 */
+ else if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else if (inLen == 3 && ((pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else if (inLen >= 4 && (byte1 == 0xF8 || (pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80 || (pIn[3] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ } else if ((pIn[1] == 0x80 || pIn[1] == 0x90 || pIn[1] == 0xA0 || pIn[1] == 0xB0) &&
+ pIn[2] < 0x82) {
+ *pOut=subS; /* Though returns replacement character, which iconv() does not return. */
+ ++pOut;
+ ++numS;
+ pIn+=4;
+ inLen-=4;
+ continue;
+ } else {
+ *pOut=pSubD[0]; /* Though returns replacement character, which iconv() does not return. */
+ ++pOut;
+ *pOut=pSubD[1];
+ ++pOut;
+ ++numS;
+ pIn+=4;
+ inLen-=4;
+ continue;
+ /* iconv() returns 0 with strange 1 byte converted values */
+ }
+
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ }
+ /* end of UTF-8 to UCS-2 */
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else if (in < 0x100 && dmapU2S[in] != 0x0000) {
+ if ((*pOut=dmapU2S[in]) == subS) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ ++pOut;
+ } else {
+ in<<=1;
+ if (dmapU2M2[in] == 0x00) { /* not found in dmapU2M2 */
+ in*=1.5;
+ if (dmapU2M3[in] == 0x00) { /* not found in dmapU2M3*/
+ *pOut=pSubD[0];
+ ++pOut;
+ *pOut=pSubD[1];
+ ++pOut;
+ ++numS;
+ ++rc;
+ } else {
+ *pOut=dmapU2M3[in];
+ ++pOut;
+ *pOut=dmapU2M3[1+in];
+ ++pOut;
+ *pOut=dmapU2M3[2+in];
+ ++pOut;
+ }
+ } else {
+ *pOut=dmapU2M2[in];
+ ++pOut;
+ if (dmapU2M2[1+in] == 0x00) {
+ if (*pOut == subS) {
+ in>>=1;
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ } else {
+ *pOut=dmapU2M2[1+in];
+ ++pOut;
+ if (memcmp(pOut-2, pSubD, 2) == 0) {
+ in>>=1;
+ if (in != cd->srcSubD) {
+ ++numS;
+ ++rc;
+ }
+ }
+ }
+ }
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_S2U) {
+ /* use uchar * instead of UniChar to avoid memcpy */
+ register uchar * dmapD12U=(uchar *) (cd->cnv_dmap->dmapD12U);
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register int offset;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register size_t numS=0;
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ ++pOut;
+ *pOut=0x00;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else {
+ offset=*pIn;
+ offset<<=1;
+ *pOut=dmapD12U[offset];
+ ++pOut;
+ *pOut=dmapD12U[offset+1];
+ ++pOut;
+ if (dmapD12U[offset] == 0x00) {
+ if (dmapD12U[offset+1] == 0x1A) {
+ if (*pIn != cd->srcSubS)
+ ++numS;
+ } else if (dmapD12U[offset+1] == 0x00) {
+ pOut-=2;
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ }
+ ++pIn;
+ --inLen;
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_S28) {
+ /* use uchar * instead of UniChar to avoid memcpy */
+ register uchar * dmapD12U=(uchar *) (cd->cnv_dmap->dmapD12U);
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register int offset;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register size_t numS=0;
+ register UniChar in; /* copy part of U28 */
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else {
+ offset=*pIn;
+ offset<<=1;
+ in=dmapD12U[offset];
+ in<<=8;
+ in+=dmapD12U[offset+1];
+ if ((in & 0xFF80) == 0x0000) { /* U28: in & 0b1111111110000000 == 0x0000 */
+ if (in == 0x000) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ *pOut=in;
+ ++pOut;
+ } else if ((in & 0xF800) == 0x0000) { /* in & 0b1111100000000000 == 0x0000 */
+ register uchar byte;
+ in>>=6;
+ in&=0x001F; /* 0b0000000000011111 */
+ in|=0x00C0; /* 0b0000000011000000 */
+ *pOut=in;
+ ++pOut;
+ byte=dmapD12U[offset+1];
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ } else if ((in & 0xFC00) == 0xD800) { /* There should not be no surrogate character in SBCS. */
+ *pOut=0xEF;
+ ++pOut;
+ *pOut=0xBF;
+ ++pOut;
+ *pOut=0xBD;
+ ++pOut;
+ } else {
+ register uchar byte;
+ register uchar work;
+ byte=dmapD12U[offset];
+ byte>>=4;
+ byte|=0xE0; /* 0b11100000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=dmapD12U[offset];
+ byte<<=2;
+ work=dmapD12U[offset+1];
+ work>>=6;
+ byte|=work;
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=dmapD12U[offset+1];
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ }
+ /* end of U28 */
+ if (dmapD12U[offset] == 0x00) {
+ if (dmapD12U[offset+1] == 0x1A) {
+ if (*pIn != cd->srcSubS)
+ ++numS;
+ }
+ }
+ ++pIn;
+ --inLen;
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_U2S) {
+ register uchar * dmapU2S=cd->cnv_dmap->dmapU2S;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+
+ *inBytesLeft=inLen;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+ } else {
+ if ((*pOut=dmapU2S[in]) == 0x00) {
+ *pOut=subS;
+ ++numS;
+ errno=EINVAL; /* 22 */
+ } else if (*pOut == subS) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ }
+ ++pOut;
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return numS;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_T2S) {
+ register uchar * dmapU2S=cd->cnv_dmap->dmapU2S;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ ++numS;
+ *numSub+=numS;
+ return 0;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+
+ } else if (0xD800 <= in && in <= 0xDFFF) { /* 0xD800-0xDFFF, surrogate first and second values */
+ if (0xDC00 <= in ) {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+
+ } else if (inLen < 4) {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-2;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn+2;
+ return -1;
+
+ } else {
+ register uint32_t in2;
+ in2=pIn[2];
+ in2<<=8;
+ in2+=pIn[3];
+ if (0xDC00 <= in2 && in2 <= 0xDFFF) { /* second surrogate character =0xDC00 - 0xDFFF*/
+ *pOut=subS;
+ ++numS;
+ pIn+=4;
+ } else {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ }
+ } else {
+ if ((*pOut=dmapU2S[in]) == 0x00) {
+ *pOut=subS;
+ ++numS;
+ errno=EINVAL; /* 22 */
+ } else if (*pOut == subS) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ }
+ ++pOut;
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_82S) {
+ register uchar * dmapU2S=cd->cnv_dmap->dmapU2S;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ uint32_t in2; /* The second surrogate value */
+ if (pLastOutBuf < pOut)
+ break;
+ /* convert from UTF-8 to UCS-2 */
+ if (*pIn == 0x00) {
+ in=0x0000;
+ ++pIn;
+ --inLen;
+ } else { /* 82U: */
+ register uchar byte1=*pIn;
+ if ((byte1 & 0x80) == 0x00) { /* if (byte1 & 0b10000000 == 0b00000000) { */
+ /* 1 bytes sequence: 0xxxxxxx => 00000000 0xxxxxxx*/
+ in=byte1;
+ ++pIn;
+ --inLen;
+ } else if ((byte1 & 0xE0) == 0xC0) { /* (byte1 & 0b11100000 == 0b11000000) { */
+ if (inLen < 2) {
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ if (byte1 == 0xC0 || byte1 == 0xC1) { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ /* 2 bytes sequence:
+ 110yyyyy 10xxxxxx => 00000yyy yyxxxxxx */
+ register uchar byte2;
+ ++pIn;
+ byte2=*pIn;
+ if ((byte2 & 0xC0) == 0x80) { /* byte2 & 0b11000000 == 0b10000000) { */
+ register uchar work=byte1;
+ work<<=6;
+ byte2&=0x3F; /* 0b00111111; */
+ byte2|=work;
+
+ byte1&=0x1F; /* 0b00011111; */
+ byte1>>=2;
+ in=byte1;
+ in<<=8;
+ in+=byte2;
+ inLen-=2;
+ ++pIn;
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if ((byte1 & 0xF0) == 0xE0) { /* byte1 & 0b11110000 == 0b11100000 */
+ /* 3 bytes sequence:
+ 1110zzzz 10yyyyyy 10xxxxxx => zzzzyyyy yyxxxxxx */
+ register uchar byte2;
+ register uchar byte3;
+ if (inLen < 3) {
+ if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ if ((byte2 & 0xC0) != 0x80 ||
+ (byte3 & 0xC0) != 0x80 ||
+ (byte1 == 0xE0 && byte2 < 0xA0)) { /* invalid sequence, only 0xA0-0xBF allowed after 0xE0 */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ *numSub+=numS;
+ return -1;
+ }
+ {
+ register uchar work=byte2;
+ work<<=6;
+ byte3&=0x3F; /* 0b00111111; */
+ byte3|=work;
+
+ byte2&=0x3F; /* 0b00111111; */
+ byte2>>=2;
+
+ byte1<<=4;
+ in=byte1 | byte2;;
+ in<<=8;
+ in+=byte3;
+ inLen-=3;
+ ++pIn;
+ }
+ } else if ((0xF0 <= byte1 && byte1 <= 0xF4) || /* (bytes1 & 11111000) == 0x1110000 */
+ ((byte1&=0xF7) && 0xF0 <= byte1 && byte1 <= 0xF4)) { /* minic iconv() behavior */
+ /* 4 bytes sequence
+ 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx => 110110ww wwzzzzyy 110111yy yyxxxxxx
+ where uuuuu = wwww + 1 */
+ register uchar byte2;
+ register uchar byte3;
+ register uchar byte4;
+ if (inLen < 4) {
+ if ((inLen >= 2 && (pIn[1] & 0xC0) != 0x80) ||
+ (inLen >= 3 && (pIn[2] & 0xC0) != 0x80) ||
+ (cd->toCcsid == 13488) )
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ ++pIn;
+ byte4=*pIn;
+ if ((byte2 & 0xC0) == 0x80 && /* byte2 & 0b11000000 == 0b10000000 */
+ (byte3 & 0xC0) == 0x80 && /* byte3 & 0b11000000 == 0b10000000 */
+ (byte4 & 0xC0) == 0x80) { /* byte4 & 0b11000000 == 0b10000000 */
+ register uchar work=byte2;
+ if (byte1 == 0xF0 && byte2 < 0x90) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ /* iconv() returns 0 for 0xF4908080 and convert to 0x00
+ } else if (byte1 == 0xF4 && byte2 > 0x8F) {
+ errno=EINVAL;
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ */
+ }
+
+ work&=0x30; /* 0b00110000; */
+ work>>=4;
+ byte1&=0x07; /* 0b00000111; */
+ byte1<<=2;
+ byte1+=work; /* uuuuu */
+ --byte1; /* wwww */
+
+ work=byte1 & 0x0F;
+ work>>=2;
+ work+=0xD8; /* 0b11011011; */
+ in=work;
+ in<<=8;
+
+ byte1<<=6;
+ byte2<<=2;
+ byte2&=0x3C; /* 0b00111100; */
+ work=byte3;
+ work>>=4;
+ work&=0x03; /* 0b00000011; */
+ work|=byte1;
+ work|=byte2;
+ in+=work;
+
+ work=byte3;
+ work>>=2;
+ work&=0x03; /* 0b00000011; */
+ work|=0xDC; /* 0b110111xx; */
+ in2=work;
+ in2<<=8;
+
+ byte3<<=6;
+ byte4&=0x3F; /* 0b00111111; */
+ byte4|=byte3;
+ in2+=byte4;
+ inLen-=4;
+ ++pIn;
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if ((byte1 & 0xF0) == 0xF0) { /* minic iconv() behavior */
+ if (inLen < 4 ||
+ pIn[1] < 0x80 || 0xBF < pIn[1] ||
+ pIn[2] < 0x80 || 0xBF < pIn[2] ||
+ pIn[3] < 0x80 || 0xBF < pIn[3] ) {
+ if (inLen == 1)
+ errno=EINVAL; /* 22 */
+ else if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else if (inLen == 3 && ((pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else if (inLen >= 4 && ((pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80 || (pIn[3] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ } else {
+ *pOut=subS; /* Though returns replacement character, which iconv() does not return. */
+ ++pOut;
+ ++numS;
+ pIn+=4;
+ inLen-=4;
+ /* UTF-8_IBM-850 0xF0908080 : converted value does not match, iconv=0x00, dmap=0x7F
+ UTF-8_IBM-850 0xF0908081 : converted value does not match, iconv=0x01, dmap=0x7F
+ UTF-8_IBM-850 0xF0908082 : converted value does not match, iconv=0x02, dmap=0x7F
+ UTF-8_IBM-850 0xF0908083 : converted value does not match, iconv=0x03, dmap=0x7F
+ ....
+ UTF-8_IBM-850 0xF09081BE : converted value does not match, iconv=0x7E, dmap=0x7F
+ UTF-8_IBM-850 0xF09081BF : converted value does not match, iconv=0x1C, dmap=0x7F
+ UTF-8_IBM-850 0xF09082A0 : converted value does not match, iconv=0xFF, dmap=0x7F
+ UTF-8_IBM-850 0xF09082A1 : converted value does not match, iconv=0xAD, dmap=0x7F
+ ....
+ */
+ continue;
+ /* iconv() returns 0 with strange 1 byte converted values */
+ }
+
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ }
+ /* end of UTF-8 to UCS-2 */
+ if (in == 0x0000) {
+ *pOut=0x00;
+ } else {
+ if ((*pOut=dmapU2S[in]) == 0x00) {
+ *pOut=subS;
+ ++numS;
+ errno=EINVAL; /* 22 */
+ } else if (*pOut == subS) {
+ if (in != cd->srcSubS) {
+ ++numS;
+ }
+ }
+ }
+ ++pOut;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_D2U) {
+ /* use uchar * instead of UniChar to avoid memcpy */
+ register uchar * dmapD12U=(uchar *) (cd->cnv_dmap->dmapD12U);
+ register uchar * dmapD22U=(uchar *) (cd->cnv_dmap->dmapD22U);
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register int offset;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register size_t numS=0;
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ ++pOut;
+ *pOut=0x00;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else {
+ offset=*pIn;
+ offset<<=1;
+ if (dmapD12U[offset] == 0x00 &&
+ dmapD12U[offset+1] == 0x00) { /* DBCS */
+ if (inLen < 2) {
+ if (*pIn == 0x80 || *pIn == 0xFF ||
+ (cd->fromCcsid == 943 && (*pIn == 0x85 || *pIn == 0x86 || *pIn == 0xA0 || *pIn == 0xEB || *pIn == 0xEC || *pIn == 0xEF || *pIn == 0xFD || *pIn == 0xFE)) ||
+ (cd->fromCcsid == 932 && (*pIn == 0x85 || *pIn == 0x86 || *pIn == 0x87 || *pIn == 0xEB || *pIn == 0xEC || *pIn == 0xED || *pIn == 0xEE || *pIn == 0xEF)) ||
+ (cd->fromCcsid == 1381 && ((0x85 <= *pIn && *pIn <= 0x8B) || (0xAA <= *pIn && *pIn <= 0xAF) || (0xF8 <= *pIn && *pIn <= 0xFE))))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ offset-=0x100;
+ ++pIn;
+ offset<<=8;
+ offset+=(*pIn * 2);
+ if (dmapD22U[offset] == 0x00 &&
+ dmapD22U[offset+1] == 0x00) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ *pOut=dmapD22U[offset];
+ ++pOut;
+ *pOut=dmapD22U[offset+1];
+ ++pOut;
+ if (dmapD22U[offset] == 0xFF &&
+ dmapD22U[offset+1] == 0xFD) {
+ if (pIn[-1] * 0x100 + pIn[0] != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=2;
+ } else { /* SBCS */
+ *pOut=dmapD12U[offset];
+ ++pOut;
+ *pOut=dmapD12U[offset+1];
+ ++pOut;
+ if (dmapD12U[offset] == 0x00 &&
+ dmapD12U[offset+1] == 0x1A) {
+ if (*pIn != cd->srcSubS)
+ ++numS;
+ }
+ ++pIn;
+ --inLen;
+ }
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_D28) {
+ /* use uchar * instead of UniChar to avoid memcpy */
+ register uchar * dmapD12U=(uchar *) (cd->cnv_dmap->dmapD12U);
+ register uchar * dmapD22U=(uchar *) (cd->cnv_dmap->dmapD22U);
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register int offset;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register size_t numS=0;
+ register UniChar in; /* copy part of U28 */
+ register UniChar ucs2;
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else {
+ offset=*pIn;
+ offset<<=1;
+ if (dmapD12U[offset] == 0x00 &&
+ dmapD12U[offset+1] == 0x00) { /* DBCS */
+ if (inLen < 2) {
+ if (*pIn == 0x80 || *pIn == 0xFF ||
+ (cd->fromCcsid == 943 && (*pIn == 0x85 || *pIn == 0x86 || *pIn == 0xA0 || *pIn == 0xEB || *pIn == 0xEC || *pIn == 0xEF || *pIn == 0xFD || *pIn == 0xFE)) ||
+ (cd->fromCcsid == 932 && (*pIn == 0x85 || *pIn == 0x86 || *pIn == 0x87 || *pIn == 0xEB || *pIn == 0xEC || *pIn == 0xED || *pIn == 0xEE || *pIn == 0xEF)) ||
+ (cd->fromCcsid == 1381 && ((0x85 <= *pIn && *pIn <= 0x8B) || (0xAA <= *pIn && *pIn <= 0xAF) || (0xF8 <= *pIn && *pIn <= 0xFE))))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ offset-=0x100;
+ ++pIn;
+ offset<<=8;
+ offset+=(*pIn * 2);
+ if (dmapD22U[offset] == 0x00 &&
+ dmapD22U[offset+1] == 0x00) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ return -1;
+ }
+ in=dmapD22U[offset];
+ in<<=8;
+ in+=dmapD22U[offset+1];
+ ucs2=in;
+ if (dmapD22U[offset] == 0xFF &&
+ dmapD22U[offset+1] == 0xFD) {
+ if (in != cd->srcSubD)
+ ++numS;
+ }
+ ++pIn;
+ inLen-=2;
+ } else { /* SBCS */
+ in=dmapD12U[offset];
+ in<<=8;
+ in+=dmapD12U[offset+1];
+ ucs2=in;
+ if (dmapD12U[offset] == 0x00 &&
+ dmapD12U[offset+1] == 0x1A) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ ++pIn;
+ --inLen;
+ }
+ if ((in & 0xFF80) == 0x0000) { /* U28: in & 0b1111111110000000 == 0x0000 */
+ *pOut=in;
+ ++pOut;
+ } else if ((in & 0xF800) == 0x0000) { /* in & 0b1111100000000000 == 0x0000 */
+ register uchar byte;
+ in>>=6;
+ in&=0x001F; /* 0b0000000000011111 */
+ in|=0x00C0; /* 0b0000000011000000 */
+ *pOut=in;
+ ++pOut;
+ byte=ucs2; /* dmapD12U[offset+1]; */
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ } else if ((in & 0xFC00) == 0xD800) { /* There should not be no surrogate character in SBCS. */
+ *pOut=0xEF;
+ ++pOut;
+ *pOut=0xBF;
+ ++pOut;
+ *pOut=0xBD;
+ ++pOut;
+ } else {
+ register uchar byte;
+ register uchar work;
+ byte=(ucs2>>8); /* dmapD12U[offset]; */
+ byte>>=4;
+ byte|=0xE0; /* 0b11100000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=(ucs2>>8); /* dmapD12U[offset]; */
+ byte<<=2;
+ work=ucs2; /* dmapD12U[offset+1]; */
+ work>>=6;
+ byte|=work;
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=ucs2; /* dmapD12U[offset+1]; */
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ }
+ /* end of U28 */
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_U2D) {
+ register uchar * dmapU2D=cd->cnv_dmap->dmapU2D;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register char * pSubD=(char *) &(cd->subD);
+ register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+
+ *inBytesLeft=inLen;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else {
+ in<<=1;
+ *pOut=dmapU2D[in];
+ ++pOut;
+ if (dmapU2D[in+1] == 0x00) { /* SBCS */
+ if (*pOut == subS) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ } else {
+ *pOut=dmapU2D[in+1];
+ ++pOut;
+ if (dmapU2D[in] == pSubD[0] &&
+ dmapU2D[in+1] == pSubD[1]) {
+ in>>=1;
+ if (in != cd->srcSubD)
+ ++numS;
+ }
+ }
+ }
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return numS; /* to minic iconv() behavior */
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_T2D) {
+ register uchar * dmapU2D=cd->cnv_dmap->dmapU2D;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register char * pSubD=(char *) &(cd->subD);
+ register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ ++numS;
+ *numSub+=numS;
+ return 0;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else if (0xD800 <= in && in <= 0xDBFF) { /* first byte of surrogate */
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-2;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn+2;
+ ++numS;
+ *numSub+=numS;
+ return -1;
+
+ } else if (0xDC00 <= in && in <= 0xDFFF) { /* second byte of surrogate */
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ ++numS;
+ *numSub+=numS;
+ return -1;
+
+ } else {
+ in<<=1;
+ *pOut=dmapU2D[in];
+ ++pOut;
+ if (dmapU2D[in+1] == 0x00) { /* SBCS */
+ if (*pOut == subS) {
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ } else {
+ *pOut=dmapU2D[in+1];
+ ++pOut;
+ if (dmapU2D[in] == pSubD[0] &&
+ dmapU2D[in+1] == pSubD[1]) {
+ in>>=1;
+ if (in != cd->srcSubD)
+ ++numS;
+ }
+ }
+ }
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0; /* to minic iconv() behavior */
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_82D) {
+ register uchar * dmapU2D=cd->cnv_dmap->dmapU2D;
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register char subS=cd->subS;
+ register char * pSubD=(char *) &(cd->subD);
+ register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ uint32_t in2;
+ if (pLastOutBuf < pOut)
+ break;
+ /* convert from UTF-8 to UCS-2 */
+ if (*pIn == 0x00) {
+ in=0x0000;
+ ++pIn;
+ --inLen;
+ } else { /* 82U: */
+ register uchar byte1=*pIn;
+ if ((byte1 & 0x80) == 0x00) { /* if (byte1 & 0b10000000 == 0b00000000) { */
+ /* 1 bytes sequence: 0xxxxxxx => 00000000 0xxxxxxx*/
+ in=byte1;
+ ++pIn;
+ --inLen;
+ } else if ((byte1 & 0xE0) == 0xC0) { /* (byte1 & 0b11100000 == 0b11000000) { */
+ if (inLen < 2) {
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ if (byte1 == 0xC0 || byte1 == 0xC1) { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ /* 2 bytes sequence:
+ 110yyyyy 10xxxxxx => 00000yyy yyxxxxxx */
+ register uchar byte2;
+ ++pIn;
+ byte2=*pIn;
+ if ((byte2 & 0xC0) == 0x80) { /* byte2 & 0b11000000 == 0b10000000) { */
+ register uchar work=byte1;
+ work<<=6;
+ byte2&=0x3F; /* 0b00111111; */
+ byte2|=work;
+
+ byte1&=0x1F; /* 0b00011111; */
+ byte1>>=2;
+ in=byte1;
+ in<<=8;
+ in+=byte2;
+ inLen-=2;
+ ++pIn;
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if ((byte1 & 0xF0) == 0xE0) { /* byte1 & 0b11110000 == 0b11100000 */
+ /* 3 bytes sequence:
+ 1110zzzz 10yyyyyy 10xxxxxx => zzzzyyyy yyxxxxxx */
+ register uchar byte2;
+ register uchar byte3;
+ if (inLen < 3) {
+ if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ if ((byte2 & 0xC0) != 0x80 ||
+ (byte3 & 0xC0) != 0x80 ||
+ (byte1 == 0xE0 && byte2 < 0xA0)) { /* invalid sequence, only 0xA0-0xBF allowed after 0xE0 */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ *numSub+=numS;
+ return -1;
+ }
+ {
+ register uchar work=byte2;
+ work<<=6;
+ byte3&=0x3F; /* 0b00111111; */
+ byte3|=work;
+
+ byte2&=0x3F; /* 0b00111111; */
+ byte2>>=2;
+
+ byte1<<=4;
+ in=byte1 | byte2;;
+ in<<=8;
+ in+=byte3;
+ inLen-=3;
+ ++pIn;
+ }
+ } else if ((0xF0 <= byte1 && byte1 <= 0xF4)) { /* (bytes1 & 11111000) == 0x1110000 */
+ /* 4 bytes sequence
+ 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx => 110110ww wwzzzzyy 110111yy yyxxxxxx
+ where uuuuu = wwww + 1 */
+ register uchar byte2;
+ register uchar byte3;
+ register uchar byte4;
+ if (inLen < 4) {
+ if ((inLen >= 2 && (pIn[1] & 0xC0) != 0x80) ||
+ (inLen >= 3 && (pIn[2] & 0xC0) != 0x80) ||
+ (cd->toCcsid == 13488) )
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ ++pIn;
+ byte4=*pIn;
+ if ((byte2 & 0xC0) == 0x80 && /* byte2 & 0b11000000 == 0b10000000 */
+ (byte3 & 0xC0) == 0x80 && /* byte3 & 0b11000000 == 0b10000000 */
+ (byte4 & 0xC0) == 0x80) { /* byte4 & 0b11000000 == 0b10000000 */
+ register uchar work=byte2;
+ if (byte1 == 0xF0 && byte2 < 0x90) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ /* iconv() returns 0 for 0xF4908080 and convert to 0x00
+ } else if (byte1 == 0xF4 && byte2 > 0x8F) {
+ errno=EINVAL;
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ */
+ }
+
+ work&=0x30; /* 0b00110000; */
+ work>>=4;
+ byte1&=0x07; /* 0b00000111; */
+ byte1<<=2;
+ byte1+=work; /* uuuuu */
+ --byte1; /* wwww */
+
+ work=byte1 & 0x0F;
+ work>>=2;
+ work+=0xD8; /* 0b11011011; */
+ in=work;
+ in<<=8;
+
+ byte1<<=6;
+ byte2<<=2;
+ byte2&=0x3C; /* 0b00111100; */
+ work=byte3;
+ work>>=4;
+ work&=0x03; /* 0b00000011; */
+ work|=byte1;
+ work|=byte2;
+ in+=work;
+
+ work=byte3;
+ work>>=2;
+ work&=0x03; /* 0b00000011; */
+ work|=0xDC; /* 0b110111xx; */
+ in2=work;
+ in2<<=8;
+
+ byte3<<=6;
+ byte4&=0x3F; /* 0b00111111; */
+ byte4|=byte3;
+ in2+=byte4;
+ inLen-=4;
+ ++pIn;
+#ifdef match_with_GBK
+ if ((0xD800 == in && in2 < 0xDC80) ||
+ (0xD840 == in && in2 < 0xDC80) ||
+ (0xD880 == in && in2 < 0xDC80) ||
+ (0xD8C0 == in && in2 < 0xDC80) ||
+ (0xD900 == in && in2 < 0xDC80) ||
+ (0xD940 == in && in2 < 0xDC80) ||
+ (0xD980 == in && in2 < 0xDC80) ||
+ (0xD9C0 == in && in2 < 0xDC80) ||
+ (0xDA00 == in && in2 < 0xDC80) ||
+ (0xDA40 == in && in2 < 0xDC80) ||
+ (0xDA80 == in && in2 < 0xDC80) ||
+ (0xDAC0 == in && in2 < 0xDC80) ||
+ (0xDB00 == in && in2 < 0xDC80) ||
+ (0xDB40 == in && in2 < 0xDC80) ||
+ (0xDB80 == in && in2 < 0xDC80) ||
+ (0xDBC0 == in && in2 < 0xDC80)) {
+#else
+ if ((0xD800 <= in && in <= 0xDBFF) &&
+ (0xDC00 <= in2 && in2 <= 0xDFFF)) {
+#endif
+ *pOut=subS;
+ ++pOut;
+ ++numS;
+ continue;
+ }
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if (0xF5 <= byte1 && byte1 <= 0xFF) { /* minic iconv() behavior */
+ if (inLen < 4 ||
+ (inLen >= 4 && byte1 == 0xF8 && pIn[1] < 0x90) ||
+ pIn[1] < 0x80 || 0xBF < pIn[1] ||
+ pIn[2] < 0x80 || 0xBF < pIn[2] ||
+ pIn[3] < 0x80 || 0xBF < pIn[3] ) {
+ if (inLen == 1)
+ errno=EINVAL; /* 22 */
+ else if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else if (inLen == 3 && ((pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else if (inLen >= 4 && (byte1 == 0xF8 || (pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80 || (pIn[3] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ } else if ((pIn[1] == 0x80 || pIn[1] == 0x90 || pIn[1] == 0xA0 || pIn[1] == 0xB0) &&
+ pIn[2] < 0x82) {
+ *pOut=subS; /* Though returns replacement character, which iconv() does not return. */
+ ++pOut;
+ ++numS;
+ pIn+=4;
+ inLen-=4;
+ continue;
+ } else {
+ *pOut=pSubD[0]; /* Though returns replacement character, which iconv() does not return. */
+ ++pOut;
+ *pOut=pSubD[1];
+ ++pOut;
+ ++numS;
+ pIn+=4;
+ inLen-=4;
+ continue;
+ /* iconv() returns 0 with strange 1 byte converted values */
+ }
+
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ }
+ /* end of UTF-8 to UCS-2 */
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else {
+ in<<=1;
+ *pOut=dmapU2D[in];
+ ++pOut;
+ if (dmapU2D[in+1] == 0x00) { /* SBCS */
+ if (dmapU2D[in] == subS) {
+ in>>=1;
+ if (in != cd->srcSubS)
+ ++numS;
+ }
+ } else {
+ *pOut=dmapU2D[in+1];
+ ++pOut;
+ if (dmapU2D[in] == pSubD[0] &&
+ dmapU2D[in+1] == pSubD[1]) {
+ in>>=1;
+ if (in != cd->srcSubD)
+ ++numS;
+ }
+ }
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_82U) {
+ /* See http://unicode.org/versions/corrigendum1.html */
+ /* convert from UTF-8 to UTF-16 can cover all conversion from UTF-8 to UCS-2 */
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ register size_t numS=0;
+ while (0 < inLen) {
+ if (pLastOutBuf < pOut)
+ break;
+ if (*pIn == 0x00) {
+ *pOut=0x00;
+ ++pOut;
+ *pOut=0x00;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else { /* 82U: */
+ register uchar byte1=*pIn;
+ if ((byte1 & 0x80) == 0x00) { /* if (byte1 & 0b10000000 == 0b00000000) { */
+ /* 1 bytes sequence: 0xxxxxxx => 00000000 0xxxxxxx*/
+ *pOut=0x00;
+ ++pOut;
+ *pOut=byte1;
+ ++pOut;
+ ++pIn;
+ --inLen;
+ } else if ((byte1 & 0xE0) == 0xC0) { /* (byte1 & 0b11100000 == 0b11000000) { */
+ if (inLen < 2) {
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ if (byte1 == 0xC0 || byte1 == 0xC1) { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ /* 2 bytes sequence:
+ 110yyyyy 10xxxxxx => 00000yyy yyxxxxxx */
+ register uchar byte2;
+ ++pIn;
+ byte2=*pIn;
+ if ((byte2 & 0xC0) == 0x80) { /* byte2 & 0b11000000 == 0b10000000) { */
+ register uchar work=byte1;
+ work<<=6;
+ byte2&=0x3F; /* 0b00111111; */
+ byte2|=work;
+
+ byte1&=0x1F; /* 0b00011111; */
+ byte1>>=2;
+ *pOut=byte1;
+ ++pOut;
+ *pOut=byte2;
+ ++pOut;
+ inLen-=2;
+ ++pIn;
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-1;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if ((byte1 & 0xF0) == 0xE0) { /* byte1 & 0b11110000 == 0b11100000 */
+ /* 3 bytes sequence:
+ 1110zzzz 10yyyyyy 10xxxxxx => zzzzyyyy yyxxxxxx */
+ register uchar byte2;
+ register uchar byte3;
+ if (inLen < 3) {
+ if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ if ((byte2 & 0xC0) != 0x80 ||
+ (byte3 & 0xC0) != 0x80 ||
+ (byte1 == 0xE0 && byte2 < 0xA0)) { /* invalid sequence, only 0xA0-0xBF allowed after 0xE0 */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-2;
+ *numSub+=numS;
+ return -1;
+ }
+ {
+ register uchar work=byte2;
+ work<<=6;
+ byte3&=0x3F; /* 0b00111111; */
+ byte3|=work;
+
+ byte2&=0x3F; /* 0b00111111; */
+ byte2>>=2;
+
+ byte1<<=4;
+ *pOut=byte1 | byte2;;
+ ++pOut;
+ *pOut=byte3;
+ ++pOut;
+ inLen-=3;
+ ++pIn;
+ }
+ } else if ((0xF0 <= byte1 && byte1 <= 0xF4) || /* (bytes1 & 11111000) == 0x1110000 */
+ ((byte1&=0xF7) && 0xF0 <= byte1 && byte1 <= 0xF4)) { /* minic iconv() behavior */
+ /* 4 bytes sequence
+ 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx => 110110ww wwzzzzyy 110111yy yyxxxxxx
+ where uuuuu = wwww + 1 */
+ register uchar byte2;
+ register uchar byte3;
+ register uchar byte4;
+ if (inLen < 4 || cd->toCcsid == 13488) {
+ if ((inLen >= 2 && (pIn[1] & 0xC0) != 0x80) ||
+ (inLen >= 3 && (pIn[2] & 0xC0) != 0x80) ||
+ (cd->toCcsid == 13488) )
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ ++pIn;
+ byte2=*pIn;
+ ++pIn;
+ byte3=*pIn;
+ ++pIn;
+ byte4=*pIn;
+ if ((byte2 & 0xC0) == 0x80 && /* byte2 & 0b11000000 == 0b10000000 */
+ (byte3 & 0xC0) == 0x80 && /* byte3 & 0b11000000 == 0b10000000 */
+ (byte4 & 0xC0) == 0x80) { /* byte4 & 0b11000000 == 0b10000000 */
+ register uchar work=byte2;
+ if (byte1 == 0xF0 && byte2 < 0x90) {
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ } else if (byte1 == 0xF4 && byte2 > 0x8F) {
+ errno=EINVAL; /* 22 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ }
+
+ work&=0x30; /* 0b00110000; */
+ work>>=4;
+ byte1&=0x07; /* 0b00000111; */
+ byte1<<=2;
+ byte1+=work; /* uuuuu */
+ --byte1; /* wwww */
+
+ work=byte1 & 0x0F;
+ work>>=2;
+ work+=0xD8; /* 0b11011011; */
+ *pOut=work;
+ ++pOut;
+
+ byte1<<=6;
+ byte2<<=2;
+ byte2&=0x3C; /* 0b00111100; */
+ work=byte3;
+ work>>=4;
+ work&=0x03; /* 0b00000011; */
+ work|=byte1;
+ work|=byte2;
+ *pOut=work;
+ ++pOut;
+
+ work=byte3;
+ work>>=2;
+ work&=0x03; /* 0b00000011; */
+ work|=0xDC; /* 0b110111xx; */
+ *pOut=work;
+ ++pOut;
+
+ byte3<<=6;
+ byte4&=0x3F; /* 0b00111111; */
+ byte4|=byte3;
+ *pOut=byte4;
+ ++pOut;
+ inLen-=4;
+ ++pIn;
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn-3;
+ *numSub+=numS;
+ return -1;
+ }
+ } else if ((byte1 & 0xF0) == 0xF0) {
+ if (cd->toCcsid == 13488) {
+ errno=EILSEQ; /* 116 */
+ } else {
+ if (inLen == 1)
+ errno=EINVAL; /* 22 */
+ else if (inLen == 2 && (pIn[1] & 0xC0) != 0x80)
+ errno=EILSEQ; /* 116 */
+ else if (inLen == 3 && ((pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else if (inLen >= 4 && ((pIn[1] & 0xC0) != 0x80 || (pIn[2] & 0xC0) != 0x80 || (pIn[3] & 0xC0) != 0x80))
+ errno=EILSEQ; /* 116 */
+ else
+ errno=EINVAL; /* 22 */
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+
+ } else { /* invalid sequence */
+ errno=EILSEQ; /* 116 */
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return -1;
+ }
+ }
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ *numSub+=numS;
+ return 0;
+ } else if (cd->cnv_dmap->codingSchema == DMAP_U28) {
+ /* See http://unicode.org/versions/corrigendum1.html */
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ // register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else if ((in & 0xFF80) == 0x0000) { /* U28: in & 0b1111111110000000 == 0x0000 */
+ *pOut=in;
+ ++pOut;
+ } else if ((in & 0xF800) == 0x0000) { /* in & 0b1111100000000000 == 0x0000 */
+ register uchar byte;
+ in>>=6;
+ in&=0x001F; /* 0b0000000000011111 */
+ in|=0x00C0; /* 0b0000000011000000 */
+ *pOut=in;
+ ++pOut;
+ byte=pIn[1];
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ } else {
+ register uchar byte;
+ register uchar work;
+ byte=pIn[0];
+ byte>>=4;
+ byte|=0xE0; /* 0b11100000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=pIn[0];
+ byte<<=2;
+ work=pIn[1];
+ work>>=6;
+ byte|=work;
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=pIn[1];
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ }
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ // *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_T28) { /* UTF-16_UTF-8 */
+ /* See http://unicode.org/versions/corrigendum1.html */
+ register int inLen=*inBytesLeft;
+ register char * pOut=*outBuf;
+ register char * pIn=*inBuf;
+ register char * pLastOutBuf = *outBuf + *outBytesLeft - 1;
+ // register size_t numS=0;
+ while (0 < inLen) {
+ register uint32_t in;
+ if (inLen == 1) {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=0;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return 0;
+ }
+ if (pLastOutBuf < pOut)
+ break;
+ in=pIn[0];
+ in<<=8;
+ in+=pIn[1];
+ if (in == 0x0000) {
+ *pOut=0x00;
+ ++pOut;
+ } else if ((in & 0xFF80) == 0x0000) { /* U28: in & 0b1111111110000000 == 0x0000 */
+ *pOut=in;
+ ++pOut;
+ } else if ((in & 0xF800) == 0x0000) { /* in & 0b1111100000000000 == 0x0000 */
+ register uchar byte;
+ in>>=6;
+ in&=0x001F; /* 0b0000000000011111 */
+ in|=0x00C0; /* 0b0000000011000000 */
+ *pOut=in;
+ ++pOut;
+ byte=pIn[1];
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ } else if ((in & 0xFC00) == 0xD800) { /* in & 0b1111110000000000 == 0b1101100000000000, first surrogate character */
+ if (0xDC00 <= in ) {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+
+ } else if (inLen < 4) {
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-2;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn+2;
+ return -1;
+
+ } else if ((pIn[2] & 0xFC) != 0xDC) { /* pIn[2] & 0b11111100 == 0b11011100, second surrogate character */
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-2;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn+2;
+ return -1;
+
+ } else {
+ register uchar byte;
+ register uchar work;
+ in>>=6;
+ in&=0x000F; /* 0b0000000000001111 */
+ byte=in; /* wwww */
+ ++byte; /* uuuuu */
+ work=byte; /* save uuuuu */
+ byte>>=2;
+ byte|=0xF0; /* 0b11110000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=work;
+ byte&=0x03; /* 0b00000011; */
+ byte<<=4;
+ byte|=0x80; /* 0b10000000; */
+ work=pIn[1];
+ work&=0x3C; /* 0b00111100; */
+ work>>=2;
+ byte|=work;
+ *pOut=byte;
+ ++pOut;
+
+ byte=pIn[1];
+ byte&=0x03; /* 0b00000011; */
+ byte<<=4;
+ byte|=0x80; /* 0b10000000; */
+ work=pIn[2];
+ work&=0x03; /* 0b00000011; */
+ work<<=2;
+ byte|=work;
+ work=pIn[3];
+ work>>=6;
+ byte|=work;
+ *pOut=byte;
+ ++pOut;
+
+ byte=pIn[3];
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ pIn+=2;
+ inLen-=2;
+ }
+ } else if ((in & 0xFC00) == 0xDC00) { /* in & 0b11111100 == 0b11011100, second surrogate character */
+ errno=EINVAL; /* 22 */
+ *inBytesLeft=inLen-1;
+ *outBytesLeft-=(pOut-*outBuf);
+ *outBuf=pOut;
+ *inBuf=pIn;
+ return -1;
+
+ } else {
+ register uchar byte;
+ register uchar work;
+ byte=pIn[0];
+ byte>>=4;
+ byte|=0xE0; /* 0b11100000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=pIn[0];
+ byte<<=2;
+ work=pIn[1];
+ work>>=6;
+ byte|=work;
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+
+ byte=pIn[1];
+ byte&=0x3F; /* 0b00111111; */
+ byte|=0x80; /* 0b10000000; */
+ *pOut=byte;
+ ++pOut;
+ }
+ pIn+=2;
+ inLen-=2;
+ }
+ *outBytesLeft-=(pOut-*outBuf);
+ *inBytesLeft=inLen;
+ *outBuf=pOut;
+ *inBuf=pIn;
+ // *numSub+=numS;
+ return 0;
+
+ } else if (cd->cnv_dmap->codingSchema == DMAP_U2U) { /* UTF-16_UCS-2 */
+ register int inLen=*inBytesLeft;
+ register int outLen=*outBytesLeft;
+ if (inLen <= outLen) {
+ memcpy(*outBuf, *inBuf, inLen);
+ (*outBytesLeft)-=inLen;
+ (*inBuf)+=inLen;
+ (*outBuf)+=inLen;
+ *inBytesLeft=0;
+ return 0;
+ }
+ memcpy(*outBuf, *inBuf, outLen);
+ (*outBytesLeft)=0;
+ (*inBuf)+=outLen;
+ (*outBuf)+=outLen;
+ *inBytesLeft-=outLen;
+ return (*inBytesLeft);
+
+ } else {
+ return -1;
+ }
+ return 0;
+}
+
+
+#ifdef DEBUG
+inline size_t myconv(myconv_t cd ,
+ char** inBuf,
+ size_t* inBytesLeft,
+ char** outBuf,
+ size_t* outBytesLeft,
+ size_t* numSub)
+{
+ if (cd->converterType == CONVERTER_ICONV) {
+ return myconv_iconv(cd,inBuf,inBytesLeft,outBuf,outBytesLeft,numSub);
+ } else if (cd->converterType == CONVERTER_DMAP) {
+ return myconv_dmap(cd,inBuf,inBytesLeft,outBuf,outBytesLeft,numSub);
+ }
+ return -1;
+}
+
+inline char * converterName(int32_t type)
+{
+ if (type == CONVERTER_ICONV)
+ return "iconv";
+ else if (type == CONVERTER_DMAP)
+ return "dmap";
+
+ return "?????";
+}
+#else
+#define myconv(a,b,c,d,e,f) \
+(((a)->converterType == CONVERTER_ICONV)? myconv_iconv((a),(b),(c),(d),(e),(f)): (((a)->converterType == CONVERTER_DMAP)? myconv_dmap((a),(b),(c),(d),(e),(f)): -1))
+
+
+#define converterName(a) \
+(((a) == CONVERTER_ICONV)? "iconv": ((a) == CONVERTER_DMAP)? "dmap": "?????")
+#endif
+
+void initMyconv();
+void cleanupMyconv();
+
+#endif
diff --git a/storage/ibmdb2i/db2i_rir.cc b/storage/ibmdb2i/db2i_rir.cc
new file mode 100644
index 00000000000..a80a181c9ac
--- /dev/null
+++ b/storage/ibmdb2i/db2i_rir.cc
@@ -0,0 +1,465 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#include "ha_ibmdb2i.h"
+
+/* Helper function for records_in_range.
+ Input: Bitmap of used key parts.
+ Output: Number of used key parts. */
+
+static inline int getKeyCntFromMap(key_part_map keypart_map)
+{
+ int cnt = 0;
+ while (keypart_map)
+ {
+ keypart_map = keypart_map >> 1;
+ cnt++;
+ }
+ return (cnt);
+}
+
+
+/**
+ @brief
+ Given a starting key and an ending key, estimate the number of rows that
+ will exist between the two keys.
+
+ INPUT
+ inx Index to use
+ min_key Min key. Is NULL if no min range
+ max_key Max key. Is NULL if no max range
+
+ NOTES
+ min_key.flag can have one of the following values:
+ HA_READ_KEY_EXACT Include the key in the range
+ HA_READ_AFTER_KEY Don't include key in range
+
+ max_key.flag can have one of the following values:
+ HA_READ_BEFORE_KEY Don't include key in range
+ HA_READ_AFTER_KEY Include all 'end_key' values in the range
+
+ RETURN
+ HA_POS_ERROR Error or the storage engine cannot estimate the number of rows
+ 1 There are no matching keys in the given range
+ n > 0 There are approximately n rows in the range
+*/
+ha_rows ha_ibmdb2i::records_in_range(uint inx,
+ key_range *min_key,
+ key_range *max_key)
+{
+ DBUG_ENTER("ha_ibmdb2i::records_in_range");
+ int rc = 0; // Return code
+ ha_rows rows = 0; // Row count returned to caller of this method
+ uint32 spcLen; // Length of space passed to DB2
+ uint32 keyCnt; // Number of fields in the key composite
+ uint32 literalCnt = 0; // Number of literals
+ uint32 boundsOff; // Offset from beginning of space to range bounds
+ uint32 litDefOff; // Offset from beginning of space to literal definitions
+ uint32 literalsOff; // Offset from beginning of space to literal values
+ uint32 cutoff = 0; // Early exit cutoff (currently not used)
+ uint64 recCnt; // Row count from DB2
+ uint16 rtnCode; // Return code from DB2
+ Bounds* boundsPtr; // Pointer to a pair of range bounds
+ Bound* boundPtr; // Pointer to a single (high or low) range bound
+ LitDef* litDefPtr; // Pointer to a literal definition
+ char* literalsPtr; // Pointer to the start of all literal values
+ char* literalPtr; // Pointer to the start of this literal value
+ char* tempPtr; // Temporary pointer
+ char* tempMinPtr; // Temporary pointer into min_key
+ int minKeyCnt = 0; // Number of fields in the min_key composite
+ int maxKeyCnt = 0; // Number of fields in the max_key composite
+ size_t tempLen = 0; // Temporary length
+ uint16 DB2FieldWidth = 0; // DB2 field width
+ uint32 workFieldLen = 0; // Length of workarea needed for CCSID conversions
+ bool overrideInclusion; // Indicator for inclusion/exclusion
+ char* endOfLiteralPtr; // Pointer to the end of this literal
+ char* endOfMinPtr; // Pointer to end of min_key
+ uint16 endByte = 0; // End byte of char or graphic literal (padding not included)
+ bool reuseLiteral; // Indicator that hi and lo bounds use same literal
+ char* minPtr = NULL; // Work pointer for traversing min_key
+ char* maxPtr = NULL; // Work pointer for traversing max_key
+ /*
+ Handle the special case of 'x < null' anywhere in the key range. There are
+ no values less than null, but return 1 so that MySQL does not assume
+ the empty set for the query.
+ */
+ if (min_key != NULL && max_key != NULL &&
+ min_key->flag == HA_READ_AFTER_KEY && max_key->flag == HA_READ_BEFORE_KEY &&
+ min_key->length == max_key->length &&
+ (memcmp((uchar*)min_key->key,(uchar*)max_key->key,min_key->length)==0))
+ {
+ DBUG_PRINT("ha_ibmdb2i::records_in_range",("Estimate 1 row for key %d; special case: < null", inx));
+ DBUG_RETURN((ha_rows) 1 );
+ }
+ /*
+ Determine the number of fields in the key composite.
+ */
+
+ if (min_key)
+ {
+ minKeyCnt = getKeyCntFromMap(min_key->keypart_map);
+ minPtr = (char*)min_key->key;
+ }
+ if (max_key)
+ {
+ maxKeyCnt = getKeyCntFromMap(max_key->keypart_map);
+ maxPtr = (char*)max_key->key;
+ }
+ keyCnt = maxKeyCnt >= minKeyCnt ? maxKeyCnt : minKeyCnt;
+
+ /*
+ Handle the special case where MySQL does not pass either a min or max
+ key range. In this case, set the key count to 1 (knowing that there
+ is at least one key field) to flow through and create one bounds structure.
+ When both the min and max key ranges are nil, the bounds structure will
+ specify positive and negative infinity and DB2 will estimate the total
+ number of rows. */
+
+ if (keyCnt == 0)
+ keyCnt = 1;
+
+ /*
+ Allocate the space needed to pass range information to DB2. The
+ space must be large enough to store the following:
+ - one pair of bounds (high and low) per field in the key composite
+ - one literal definition per literal value
+ - the literal values
+ - work area for literal CCSID conversions
+ Since we don't know yet how many of these structures are needed,
+ allocate enough space for the maximum that we will possibly need.
+ The workarea for the literal conversion must be big enough to hold the
+ largest of the DB2 key fields.
+ */
+ KEY& curKey = table->key_info[inx];
+
+ for (int i = 0; i < keyCnt; i++)
+ {
+ DB2FieldWidth =
+ db2Table->db2Field(curKey.key_part[i].field->field_index).getByteLengthInRecord();
+ if (DB2FieldWidth > workFieldLen)
+ workFieldLen = DB2FieldWidth; // Get length of largest DB2 field
+ tempLen = tempLen + DB2FieldWidth; // Tally the DB2 field lengths
+ }
+ spcLen = (sizeof(Bounds)*keyCnt) + (sizeof(LitDef)*keyCnt*2) + (tempLen*2) + workFieldLen;
+
+ ValidatedPointer<char> spcPtr(spcLen); // Pointer to space passed to DB2
+ memset(spcPtr, 0, spcLen); // Clear the allocated space
+ /*
+ Set addressability to the various sections of the DB2 interface space.
+ */
+ boundsOff = 0; // Range bounds are at the start of the space
+ litDefOff = sizeof(Bounds) * keyCnt; // Literal defs follow all the range bounds
+ literalsOff = litDefOff + (sizeof(LitDef) * keyCnt * 2); // Literal values are last
+ boundsPtr = (Bounds_t*)(void*)spcPtr; // Address first bounds structure
+ tempPtr = (char*)((char*)spcPtr + litDefOff);
+ litDefPtr = (LitDef_t*)tempPtr; // Address first literal definition
+ tempPtr = (char*)((char*)spcPtr + literalsOff);
+ literalsPtr = (char*)tempPtr; // Address start of literal values
+ literalPtr = literalsPtr; // Address first literal value
+ /*
+ For each key part, build the low (min) and high (max) DB2 range bounds.
+ If literals are specified in the MySQL range, build DB2 literal
+ definitions and store the literal values for access by DB2.
+
+ If no value is specified for a key part, assume infinity. Negative
+ infinity will cause processing to start at the first index entry.
+ Positive infinity will cause processing to end at the last index entry.
+ When infinity is specified in a bound, inclusion/exclusion and position
+ are ignored, and there is no literal definition or literal value for
+ the bound.
+
+ If the keypart value is null, the null indicator is set in the range
+ bound and the other fields in the bound are ignored. When the bound is
+ null, only index entries with the null value will be included in the
+ estimate. If one bound is null, both bounds must be null. When the bound
+ is not null, the data offset and length must be set, and the literal
+ value stored for access by DB2.
+ */
+ for (int partsInUse = 0; partsInUse < keyCnt; ++partsInUse)
+ {
+ Field *field= curKey.key_part[partsInUse].field;
+ overrideInclusion = false;
+ reuseLiteral = false;
+ endOfLiteralPtr = NULL;
+ /*
+ Build the low bound for the key range.
+ */
+ if ((partsInUse + 1) > minKeyCnt) // if no min_key info for this part
+ boundsPtr->LoBound.Infinity[0] = QMY_NEG_INFINITY; // select...where 3 between x and y
+ else
+ {
+ if ((curKey.key_part[partsInUse].null_bit) && (char*)minPtr[0])
+ { // min_key is null
+ if (max_key == NULL ||
+ ((partsInUse + 1) > maxKeyCnt)) // select...where x='ab' and y=null and z != 'c'
+ boundsPtr->LoBound.Infinity[0] = QMY_NEG_INFINITY; // select...where x not null or
+ // select...where x > null
+ else // max_key is not null
+ {
+ if (min_key->flag == HA_READ_KEY_EXACT)
+ boundsPtr->LoBound.IsNull[0] = QMY_YES; // select...where x is null
+ else
+ {
+ if ((char*)maxPtr[0])
+ boundsPtr->LoBound.IsNull[0] = QMY_YES; // select...where a = null and b < 5 (max-before)
+ // select...where a='a' and b is null and c !='a' (max-after)
+ else
+ boundsPtr->LoBound.Infinity[0] = QMY_NEG_INFINITY; // select...where x < y
+ }
+ } // end min_key is null
+ }
+ else // min_key is not null
+ {
+ if (literalCnt) litDefPtr = litDefPtr + 1;
+ literalCnt = literalCnt + 1;
+ boundsPtr->LoBound.Position = literalCnt;
+ /*
+ Determine inclusion or exclusion.
+ */
+ if (min_key->flag == HA_READ_KEY_EXACT || //select...where a like 'this%'
+
+ /* An example for the following conditions is 'select...where a = 5 and b > null'. */
+
+ (max_key &&
+ (memcmp((uchar*)minPtr,(uchar*)maxPtr,
+ curKey.key_part[partsInUse].store_length)==0)))
+
+ {
+ if ((min_key->flag != HA_READ_KEY_EXACT) ||
+ (max_key &&
+ (memcmp((uchar*)minPtr,(uchar*)maxPtr,
+ curKey.key_part[partsInUse].store_length)==0)))
+ overrideInclusion = true; // Need inclusion for both min and max
+ }
+ else
+ boundsPtr->LoBound.Embodiment[0] = QMY_EXCLUSION;
+ litDefPtr->FieldNbr = field->field_index + 1;
+ DB2Field& db2Field = db2Table->db2Field(field->field_index);
+ litDefPtr->DataType = db2Field.getType();
+ /*
+ Convert the literal to DB2 format.
+ */
+ rc = convertMySQLtoDB2(field,
+ db2Field,
+ literalPtr,
+ (uchar*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
+ if (rc != 0) break;
+ litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
+ litDefPtr->Length = db2Field.getByteLengthInRecord();
+ tempLen = litDefPtr->Length;
+ /*
+ Do additional conversion of a character or graphic value.
+ */
+ CHARSET_INFO* fieldCharSet = field->charset();
+ if ((field->type() != MYSQL_TYPE_BIT) && // Don't do conversion on BIT data
+ (field->charset() != &my_charset_bin) && // Don't do conversion on BINARY data
+ (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC))
+ {
+ if (litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_VARGRAPHIC)
+ tempPtr = literalPtr + sizeof(uint16);
+ else
+ tempPtr = literalPtr;
+ /* The following code checks to determine if MySQL is passing a
+ partial key. DB2 will accept a partial field value, but only
+ in the last field position of the key composite (and only if
+ there is no ICU sort sequence on the index). */
+ tempMinPtr = (char*)minPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0);
+ if (field->type() == MYSQL_TYPE_VARCHAR)
+ {
+ /* MySQL always stores key lengths as 2 bytes, little-endian. */
+ tempLen = *(uint8*)tempMinPtr + ((*(uint8*)(tempMinPtr+1)) << 8);
+ tempMinPtr = (char*)((char*)tempMinPtr + 2);
+ }
+ else
+ tempLen = field->field_length;
+
+ /* Determine if we are dealing with a partial key and if so, find the end of the partial key. */
+ if (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR )
+ { /* Char or varchar. If UTF8, no conversion is done to DB2 graphic.) */
+ endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen);
+ if (endOfMinPtr)
+ endOfLiteralPtr = tempPtr + ((uint32_t)(endOfMinPtr - tempMinPtr));
+ }
+ else
+ {
+ if (strncmp(fieldCharSet->csname, "utf8", sizeof("utf8")) == 0)
+ { /* The MySQL charset is UTF8 but we are converting to graphic on DB2. Divide number of UTF8 bytes
+ by 3 to get the number of characters, then multiple by 2 for double-byte graphic.*/
+ endOfMinPtr = (char*)memchr(tempMinPtr,field->charset()->min_sort_char,tempLen);
+ if (endOfMinPtr)
+ endOfLiteralPtr = tempPtr + (((uint32_t)((endOfMinPtr - tempMinPtr)) / 3) * 2);
+ }
+ else
+ { /* The DB2 data type is graphic or vargraphic, and we are not converting from UTF8 to graphic. */
+ endOfMinPtr = (char*)wmemchr((wchar_t*)tempMinPtr,field->charset()->min_sort_char,tempLen/2);
+ if (endOfMinPtr)
+ endOfLiteralPtr = tempPtr + (endOfMinPtr - tempMinPtr);
+ }
+ }
+ /* Enforce here that a partial is only allowed on the last field position
+ of the key composite */
+ if (endOfLiteralPtr)
+ {
+ if ((partsInUse + 1) < minKeyCnt)
+ {
+ rc = HA_POS_ERROR;
+ break;
+ }
+ endByte = endOfLiteralPtr - tempPtr;
+ /* We're making an assumption that if MySQL gives us a partial key,
+ the length of the partial is the same for both the min_key and max_key. */
+ }
+ }
+ literalPtr = literalPtr + litDefPtr->Length; // Bump pointer for next literal
+ }
+ /* If there is a max_key value for this field, and if the max_key value is
+ the same as the min_key value, then the low bound literal can be reused
+ for the high bound literal. This eliminates the overhead of copying and
+ converting the same value twice. */
+ if (max_key && ((partsInUse + 1) <= maxKeyCnt) &&
+ (memcmp((uchar*)minPtr,(uchar*)maxPtr,
+ curKey.key_part[partsInUse].store_length)==0 || endOfLiteralPtr))
+ reuseLiteral = true;
+ minPtr += curKey.key_part[partsInUse].store_length;
+ }
+ /*
+ Build the high bound for the key range.
+ */
+ if (max_key == NULL || ((partsInUse + 1) > maxKeyCnt))
+ boundsPtr->HiBound.Infinity[0] = QMY_POS_INFINITY;
+ else
+ {
+ if ((curKey.key_part[partsInUse].null_bit) && (char*)maxPtr[0])
+ {
+ if (min_key == NULL)
+ boundsPtr->HiBound.Infinity[0] = QMY_POS_INFINITY;
+ else
+ boundsPtr->HiBound.IsNull[0] = QMY_YES; // select...where x is null
+ }
+ else // max_key field is not null
+ {
+ if (boundsPtr->LoBound.IsNull[0] == QMY_YES) // select where x < 10 or x is null
+ {
+ rc = HA_POS_ERROR;
+ break;
+ }
+ if (!reuseLiteral)
+ {
+ if (literalCnt)
+ litDefPtr = litDefPtr + 1;
+ literalCnt = literalCnt + 1;
+ litDefPtr->FieldNbr = field->field_index + 1;
+ DB2Field& db2Field = db2Table->db2Field(field->field_index);
+ litDefPtr->DataType = db2Field.getType();
+ /*
+ Convert the literal to DB2 format
+ */
+ rc = convertMySQLtoDB2(field,
+ db2Field,
+ literalPtr,
+ (uchar*)maxPtr+((curKey.key_part[partsInUse].null_bit)? 1 : 0));
+ if (rc != 0) break;
+ litDefPtr->Offset = (uint32_t)(literalPtr - literalsPtr);
+ litDefPtr->Length = db2Field.getByteLengthInRecord();
+ tempLen = litDefPtr->Length;
+ /*
+ Now convert a character or graphic value.
+ */
+ if ((field->type() != MYSQL_TYPE_BIT) &&
+ (litDefPtr->DataType == QMY_CHAR || litDefPtr->DataType == QMY_VARCHAR ||
+ litDefPtr->DataType == QMY_GRAPHIC || litDefPtr->DataType == QMY_VARGRAPHIC))
+ {
+ if (litDefPtr->DataType == QMY_VARCHAR || litDefPtr->DataType == QMY_VARGRAPHIC)
+ {
+ tempPtr = literalPtr + sizeof(uint16);
+ }
+ else
+ tempPtr = literalPtr;
+ }
+ literalPtr = literalPtr + litDefPtr->Length; // Bump pointer for next literal
+ }
+ boundsPtr->HiBound.Position = literalCnt;
+ if (max_key->flag == HA_READ_BEFORE_KEY && !overrideInclusion)
+ boundsPtr->HiBound.Embodiment[0] = QMY_EXCLUSION;
+ }
+ maxPtr += curKey.key_part[partsInUse].store_length;
+ }
+ /*
+ Bump to the next field in the key composite.
+ */
+
+ if ((partsInUse+1) < keyCnt)
+ boundsPtr = boundsPtr + 1;
+ }
+
+ /*
+ Call DB2 to estimate the number of rows in the key range.
+ */
+ if (rc == 0)
+ {
+ rc = db2i_ileBridge::getBridgeForThread()->recordsInRange((indexHandles[inx] ? indexHandles[inx] : db2Table->indexFile(inx)->getMasterDefnHandle()),
+ spcPtr,
+ keyCnt,
+ literalCnt,
+ boundsOff,
+ litDefOff,
+ literalsOff,
+ cutoff,
+ (uint32_t)(literalPtr - (char*)spcPtr),
+ endByte,
+ &recCnt,
+ &rtnCode);
+ }
+ /*
+ Set the row count and return.
+ Beware that if this method returns a zero row count, MySQL assumes the
+ result set for the query is zero; never return a zero row count.
+ */
+ if ((rc == 0) && (rtnCode == QMY_SUCCESS || rtnCode == QMY_EARLY_EXIT))
+ {
+ rows = recCnt ? (ha_rows)recCnt : 1;
+ }
+
+ rows = (rows > 0 ? rows : HA_POS_ERROR);
+
+ setIndexReadEstimate(inx, rows);
+
+ DBUG_PRINT("ha_ibmdb2i::recordsInRange",("Estimate %d rows for key %d", uint32(rows), inx));
+
+ DBUG_RETURN(rows);
+}
diff --git a/storage/ibmdb2i/db2i_safeString.h b/storage/ibmdb2i/db2i_safeString.h
new file mode 100644
index 00000000000..e353316c8fc
--- /dev/null
+++ b/storage/ibmdb2i/db2i_safeString.h
@@ -0,0 +1,98 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+
+#ifndef DB2I_SAFESTRING_H
+#define DB2I_SAFESTRING_H
+
+
+#include <my_global.h>
+#include <string.h>
+
+/**
+ @class SafeString
+
+ This class was designed to provide safe, but lightweight, concatenation
+ operations C strings inside pre-allocated buffers.
+*/
+class SafeString
+{
+public:
+ SafeString(char* buffer, size_t size) :
+ allocSize(size), curPos(0), buf(buffer)
+ {
+ DBUG_ASSERT(size > 0);
+ buf[allocSize - 1] = 0xFF; // Set an overflow indicator
+ }
+
+ char* ptr() { return buf; }
+ operator char*() { return buf; }
+
+ SafeString& strcat(const char* str)
+ {
+ return this->strncat(str, strlen(str));
+ }
+
+ SafeString& strcat(char one)
+ {
+ if (curPos < allocSize - 2)
+ {
+ buf[curPos++] = one;
+ }
+ buf[curPos] = 0;
+
+ return *this;
+ }
+
+ SafeString& strncat(const char* str, size_t len)
+ {
+ uint64 amountToCopy = min((allocSize-1) - curPos, len);
+ memcpy(buf + curPos, str, amountToCopy);
+ curPos += amountToCopy;
+ buf[curPos] = 0;
+ return *this;
+ }
+
+ bool overflowed() const { return (buf[allocSize - 1] == 0);}
+
+private:
+ char* buf;
+ uint64 curPos;
+ size_t allocSize;
+};
+
+
+#endif
diff --git a/storage/ibmdb2i/db2i_sqlStatementStream.cc b/storage/ibmdb2i/db2i_sqlStatementStream.cc
new file mode 100644
index 00000000000..92a8b03fd00
--- /dev/null
+++ b/storage/ibmdb2i/db2i_sqlStatementStream.cc
@@ -0,0 +1,86 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#include "db2i_sqlStatementStream.h"
+#include "as400_types.h"
+
+/**
+ Add a statement to the statement stream, allocating additional memory as needed.
+
+ @parm stmt The statement text
+ @parm length The length of the statement text
+ @parm fileSortSequence The DB2 sort sequence identifier, in EBCDIC
+ @parm fileSortSequenceLibrary The DB2 sort sequence library, in EBCDIC
+
+ @return Reference to this object
+*/
+SqlStatementStream& SqlStatementStream::addStatementInternal(const char* stmt,
+ uint32 length,
+ const char* fileSortSequence,
+ const char* fileSortSequenceLibrary)
+{
+ uint32 storageNeeded = length + sizeof(StmtHdr_t);
+ storageNeeded = (storageNeeded + 3) & ~3; // We have to be 4-byte aligned.
+ if (storageNeeded > storageRemaining())
+ {
+ // We overallocate new storage to reduce number of times reallocation is
+ // needed.
+ int newSize = curSize + 2 * storageNeeded;
+ DBUG_PRINT("SqlStatementStream::addStatementInternal",
+ ("PERF: Had to realloc! Old size=%d. New size=%d", curSize, newSize));
+ char* old_space = block;
+ char* new_space = (char*)getNewSpace(newSize);
+ memcpy(new_space, old_space, curSize);
+ ptr = new_space + (ptr - old_space);
+ curSize = newSize;
+ }
+
+ DBUG_ASSERT((address64_t)ptr % 4 == 0);
+
+ memcpy(((StmtHdr_t*)ptr)->SrtSeqNam,
+ fileSortSequence,
+ sizeof(((StmtHdr_t*)ptr)->SrtSeqNam));
+ memcpy(((StmtHdr_t*)ptr)->SrtSeqSch,
+ fileSortSequenceLibrary,
+ sizeof(((StmtHdr_t*)ptr)->SrtSeqSch));
+ ((StmtHdr_t*)ptr)->Length = length;
+ memcpy(ptr + sizeof(StmtHdr_t), stmt, length);
+
+ ptr += storageNeeded;
+ ++statements;
+
+ return *this;
+}
diff --git a/storage/ibmdb2i/db2i_sqlStatementStream.h b/storage/ibmdb2i/db2i_sqlStatementStream.h
new file mode 100644
index 00000000000..11db41a6c5d
--- /dev/null
+++ b/storage/ibmdb2i/db2i_sqlStatementStream.h
@@ -0,0 +1,151 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+#ifndef DB2I_SQLSTATEMENTSTREAM_H
+#define DB2I_SQLSTATEMENTSTREAM_H
+
+#include "db2i_charsetSupport.h"
+#include "qmyse.h"
+
+/**
+ @class SqlStatementStream
+
+ This class handles building the stream of SQL statements expected by the
+ QMY_EXECUTE_IMMEDIATE and QMY_PREPARE_OPEN_CURSOR APIs.
+ Memory allocation is handled internally.
+*/
+class SqlStatementStream
+{
+ public:
+ /**
+ ctor to be used when multiple strings may be appended.
+ */
+ SqlStatementStream(uint32 firstStringSize) : statements(0)
+ {
+ curSize = firstStringSize + sizeof(StmtHdr_t);
+ curSize = (curSize + 3) & ~3;
+ ptr = (char*) getNewSpace(curSize);
+ if (ptr == NULL)
+ curSize = 0;
+ }
+
+ /**
+ ctor to be used when only a single statement will be executed.
+ */
+ SqlStatementStream(const String& statement) : statements(0), block(NULL), curSize(0), ptr(0)
+ {
+ addStatement(statement);
+ }
+
+ /**
+ ctor to be used when only a single statement will be executed.
+ */
+ SqlStatementStream(const char* statement) : statements(0), block(NULL), curSize(0), ptr(0)
+ {
+ addStatement(statement);
+ }
+
+ /**
+ Append an SQL statement, specifiying the DB2 sort sequence under which
+ the statement should be executed. This is important for CREATE TABLE
+ and CREATE INDEX statements.
+ */
+ SqlStatementStream& addStatement(const String& append, const char* fileSortSequence, const char* fileSortSequenceLibrary)
+ {
+ char sortSeqEbcdic[10];
+ char sortSeqLibEbcdic[10];
+
+ DBUG_ASSERT(strlen(fileSortSequence) <= 10 &&
+ strlen(fileSortSequenceLibrary) <= 10);
+ memset(sortSeqEbcdic, 0x40, 10);
+ memset(sortSeqLibEbcdic, 0x40, 10);
+ convToEbcdic(fileSortSequence, sortSeqEbcdic, strlen(fileSortSequence));
+ convToEbcdic(fileSortSequenceLibrary, sortSeqLibEbcdic, strlen(fileSortSequenceLibrary));
+
+ return addStatementInternal(append.ptr(), append.length(), sortSeqEbcdic, sortSeqLibEbcdic);
+ }
+
+ /**
+ Append an SQL statement using default (*HEX) sort sequence.
+ */
+ SqlStatementStream& addStatement(const String& append)
+ {
+ const char splatHEX[] = {0x5C, 0xC8, 0xC5, 0xE7, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}; // *HEX
+ const char blanks[] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}; //
+
+ return addStatementInternal(append.ptr(), append.length(), splatHEX, blanks);
+ }
+
+ /**
+ Append an SQL statement using default (*HEX) sort sequence.
+ */
+ SqlStatementStream& addStatement(const char* stmt)
+ {
+ const char splatHEX[] = {0x5C, 0xC8, 0xC5, 0xE7, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}; // *HEX
+ const char blanks[] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}; //
+
+ return addStatementInternal(stmt, strlen(stmt), splatHEX, blanks);
+ }
+
+ char* getPtrToData() const { return block; }
+ uint32 getStatementCount() const { return statements; }
+ private:
+ SqlStatementStream& addStatementInternal(const char* stmt,
+ uint32 length,
+ const char* fileSortSequence,
+ const char* fileSortSequenceLibrary);
+
+ uint32 storageRemaining() const
+ {
+ return (block == NULL ? 0 : curSize - (ptr - block));
+ }
+
+ char* getNewSpace(size_t size)
+ {
+ allocBase = (char*)sql_alloc(size + 15);
+ block = (char*)roundToQuadWordBdy(allocBase);
+ return block;
+ }
+
+ uint32 curSize; // The size of the usable memory.
+ char* allocBase; // The allocated memory (with padding for aligment)
+ char* block; // The usable memory chunck (aligned for ILE)
+ char* ptr; // The current position within block.
+ uint32 statements; // The number of statements that have been appended.
+};
+
+#endif
+
diff --git a/storage/ibmdb2i/db2i_validatedPointer.h b/storage/ibmdb2i/db2i_validatedPointer.h
new file mode 100644
index 00000000000..c4e31d1f11b
--- /dev/null
+++ b/storage/ibmdb2i/db2i_validatedPointer.h
@@ -0,0 +1,162 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+#ifndef DB2I_VALIDATEDPOINTER_H
+#define DB2I_VALIDATEDPOINTER_H
+
+#include "db2i_ileBridge.h"
+
+/**
+ @class ValidatedPointer
+ @brief Encapsulates a pointer registered for usage by the QMYSE APIs
+
+ @details As a performance optimization, to prevent pointer validation each
+ time a particular pointer is thunked across to ILE, QMYSE allows us to
+ "register" a pointer such that it is validated once and then subsequently
+ referenced on QMYSE APIs by means of a handle value. This class should be
+ used to manage memory allocation/registration/unregistration of these
+ pointers. Using the alloc function guarantees that the resulting storage is
+ 16-byte aligned, a requirement for many pointers passed to QMYSE.
+*/
+template <class T>
+class ValidatedPointer
+{
+public:
+ ValidatedPointer<T>() : address(NULL), handle(NULL) {;}
+
+ ValidatedPointer<T>(size_t size)
+ {
+ alloc(size);
+ }
+
+ ValidatedPointer<T>(T* ptr)
+ {
+ assign(ptr);
+ }
+
+ operator T*()
+ {
+ return address;
+ };
+
+ operator T*() const
+ {
+ return address;
+ };
+
+ operator void*()
+ {
+ return address;
+ };
+
+ operator ILEMemHandle()
+ {
+ return handle;
+ }
+
+ void alloc(size_t size)
+ {
+ address = (T*)malloc_aligned(size);
+ if (address)
+ db2i_ileBridge::registerPtr(address, &handle);
+ mallocedHere = 1;
+ }
+
+ void assign(T* ptr)
+ {
+ address = ptr;
+ db2i_ileBridge::registerPtr((void*)ptr, &handle);
+ mallocedHere = 0;
+ }
+
+ void realloc(size_t size)
+ {
+ dealloc();
+ alloc(size);
+ }
+
+ void reassign(T* ptr)
+ {
+ dealloc();
+ assign(ptr);
+ }
+
+ void dealloc()
+ {
+ if (address)
+ {
+ db2i_ileBridge::unregisterPtr(handle);
+
+ if (mallocedHere)
+ free_aligned((void*)address);
+ }
+ address = NULL;
+ handle = 0;
+ }
+
+ ~ValidatedPointer()
+ {
+ dealloc();
+ }
+
+private:
+ // Disable copy ctor and assignment operator, as these would break
+ // the registration guarantees provided by the class.
+ ValidatedPointer& operator= (const ValidatedPointer newVal);
+ ValidatedPointer(ValidatedPointer& newCopy);
+
+ ILEMemHandle handle;
+ T* address;
+ char mallocedHere;
+};
+
+
+/**
+ @class ValidatedObject
+ @brief This class allows users to instantiate and register a particular
+ object in a single step.
+*/
+template<class T>
+class ValidatedObject : public ValidatedPointer<T>
+{
+ public:
+ ValidatedObject<T>() : ValidatedPointer<T>(&value) {;}
+
+ T& operator= (const T newVal) { value = newVal; return value; }
+
+ private:
+ T value;
+};
+#endif
diff --git a/storage/ibmdb2i/ha_ibmdb2i.cc b/storage/ibmdb2i/ha_ibmdb2i.cc
new file mode 100644
index 00000000000..46c84de4aee
--- /dev/null
+++ b/storage/ibmdb2i/ha_ibmdb2i.cc
@@ -0,0 +1,3291 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+
+/**
+ @file ha_ibmdb2i.cc
+
+ @brief
+ The ha_ibmdb2i storage engine provides an interface from MySQL to IBM DB2 for i.
+
+*/
+
+#ifdef USE_PRAGMA_IMPLEMENTATION
+#pragma implementation // gcc: Class implementation
+#endif
+
+#include "ha_ibmdb2i.h"
+#include "mysql_priv.h"
+#include <mysql/plugin.h>
+#include "db2i_ileBridge.h"
+#include "db2i_charsetSupport.h"
+#include <sys/utsname.h>
+#include "db2i_safeString.h"
+
+static const char __NOT_NULL_VALUE_EBCDIC = 0xF0; // '0'
+static const char __NULL_VALUE_EBCDIC = 0xF1; // '1'
+static const char __DEFAULT_VALUE_EBCDIC = 0xC4; // 'D'
+static const char BlankASPName[19] = " ";
+static const int DEFAULT_MAX_ROWS_TO_BUFFER = 4096;
+
+static const char SAVEPOINT_PREFIX[] = {0xD4, 0xE8, 0xE2, 0xD7}; // MYSP (in EBCDIC)
+
+OSVersion osVersion;
+
+
+// ================================================================
+// ================================================================
+// System variables
+static char* ibmdb2i_rdb_name;
+static MYSQL_SYSVAR_STR(rdb_name, ibmdb2i_rdb_name,
+ PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY,
+ "The name of the RDB to use",
+ NULL,
+ NULL,
+ BlankASPName);
+
+static MYSQL_THDVAR_BOOL(transaction_unsafe,
+ 0,
+ "Disable support for commitment control",
+ NULL,
+ NULL,
+ FALSE);
+
+static MYSQL_THDVAR_UINT(lob_alloc_size,
+ 0,
+ "Baseline allocation for lob read buffer",
+ NULL,
+ NULL,
+ 2*1024*1024,
+ 64*1024,
+ 128*1024*1024,
+ 1);
+
+static MYSQL_THDVAR_UINT(max_read_buffer_size,
+ 0,
+ "Maximum size of buffers used for read-ahead.",
+ NULL,
+ NULL,
+ 1*1024*1024,
+ 32*1024,
+ 16*1024*1024,
+ 1);
+
+static MYSQL_THDVAR_UINT(max_write_buffer_size,
+ 0,
+ "Maximum size of buffers used for bulk writes.",
+ NULL,
+ NULL,
+ 8*1024*1024,
+ 32*1024,
+ 64*1024*1024,
+ 1);
+
+static MYSQL_THDVAR_BOOL(compat_opt_time_as_duration,
+ 0,
+ "Control how new TIME columns should be defined in DB2. 0=time-of-day (default), 1=duration.",
+ NULL,
+ NULL,
+ FALSE);
+
+static MYSQL_THDVAR_UINT(compat_opt_year_as_int,
+ 0,
+ "Control how new YEAR columns should be defined in DB2. 0=CHAR(4) (default), 1=SMALLINT.",
+ NULL,
+ NULL,
+ 0,
+ 0,
+ 1,
+ 1);
+
+static MYSQL_THDVAR_UINT(compat_opt_blob_cols,
+ 0,
+ "Control how new TEXT and BLOB columns should be defined in DB2. 0=CLOB/BLOB (default), 1=VARCHAR/VARBINARY",
+ NULL,
+ NULL,
+ 0,
+ 0,
+ 1,
+ 1);
+
+static MYSQL_THDVAR_UINT(compat_opt_allow_zero_date_vals,
+ 0,
+ "Allow substitute values to be used when storing a column with a 0000-00-00 date component. 0=No substitution (default), 1=Substitute '0001-01-01'",
+ NULL,
+ NULL,
+ 0,
+ 0,
+ 1,
+ 1);
+
+static MYSQL_THDVAR_BOOL(propagate_default_col_vals,
+ 0,
+ "Should DEFAULT column values be propagated to the DB2 table definition.",
+ NULL,
+ NULL,
+ TRUE);
+
+static my_bool ibmdb2i_assume_exclusive_use;
+static MYSQL_SYSVAR_BOOL(assume_exclusive_use, ibmdb2i_assume_exclusive_use,
+ 0,
+ "Can MySQL assume that this process is the only one modifying the DB2 tables. ",
+ NULL,
+ NULL,
+ FALSE);
+
+static MYSQL_THDVAR_BOOL(async_enabled,
+ 0,
+ "Should reads be done asynchronously when possible",
+ NULL,
+ NULL,
+ TRUE);
+
+static MYSQL_THDVAR_UINT(create_index_option,
+ 0,
+ "Control whether additional indexes are created. 0=No (default), 1=Create additional *HEX-based index",
+ NULL,
+ NULL,
+ 0,
+ 0,
+ 1,
+ 1);
+
+/* static MYSQL_THDVAR_UINT(discovery_mode,
+ 0,
+ "Unsupported",
+ NULL,
+ NULL,
+ 0,
+ 0,
+ 1,
+ 1); */
+
+static uint32 ibmdb2i_system_trace;
+static MYSQL_SYSVAR_UINT(system_trace_level, ibmdb2i_system_trace,
+ 0,
+ "Set system tracing level",
+ NULL,
+ NULL,
+ 0,
+ 0,
+ 63,
+ 1);
+
+
+inline uint8 ha_ibmdb2i::getCommitLevel(THD* thd)
+{
+ if (!THDVAR(thd, transaction_unsafe))
+ {
+ switch (thd_tx_isolation(thd))
+ {
+ case ISO_READ_UNCOMMITTED:
+ return (accessIntent == QMY_READ_ONLY ? QMY_READ_UNCOMMITTED : QMY_REPEATABLE_READ);
+ case ISO_READ_COMMITTED:
+ return (accessIntent == QMY_READ_ONLY ? QMY_READ_COMMITTED : QMY_REPEATABLE_READ);
+ case ISO_REPEATABLE_READ:
+ return QMY_REPEATABLE_READ;
+ case ISO_SERIALIZABLE:
+ return QMY_SERIALIZABLE;
+ }
+ }
+
+ return QMY_NONE;
+}
+
+inline uint8 ha_ibmdb2i::getCommitLevel()
+{
+ return getCommitLevel(ha_thd());
+}
+
+//=====================================================================
+
+static handler *ibmdb2i_create_handler(handlerton *hton,
+ TABLE_SHARE *table,
+ MEM_ROOT *mem_root);
+static void ibmdb2i_drop_database(handlerton *hton, char* path);
+static int ibmdb2i_savepoint_set(handlerton *hton, THD* thd, void *sv);
+static int ibmdb2i_savepoint_rollback(handlerton *hton, THD* thd, void *sv);
+static int ibmdb2i_savepoint_release(handlerton *hton, THD* thd, void *sv);
+static uint ibmdb2i_alter_table_flags(uint flags);
+
+handlerton *ibmdb2i_hton;
+static bool was_ILE_inited;
+
+/* Tracks the number of open tables */
+static HASH ibmdb2i_open_tables;
+
+/* Mutex used to synchronize initialization of the hash */
+static pthread_mutex_t ibmdb2i_mutex;
+
+
+/**
+ Create hash key for tracking open tables.
+*/
+
+static uchar* ibmdb2i_get_key(IBMDB2I_SHARE *share,size_t *length,
+ bool not_used __attribute__((unused)))
+{
+ *length=share->table_name_length;
+ return (uchar*) share->table_name;
+}
+
+
+int ibmdb2i_close_connection(handlerton* hton, THD *thd)
+{
+ DBUG_PRINT("ha_ibmdb2i::close_connection", ("Closing %d", thd->thread_id));
+ db2i_ileBridge::getBridgeForThread(thd)->closeConnection(thd->thread_id);
+ db2i_ileBridge::destroyBridgeForThread(thd);
+
+ return 0;
+}
+
+
+static int ibmdb2i_init_func(void *p)
+{
+ DBUG_ENTER("ibmdb2i_init_func");
+
+ utsname tempName;
+ uname(&tempName);
+ osVersion.v = atoi(tempName.version);
+ osVersion.r = atoi(tempName.release);
+
+ was_ILE_inited = false;
+ ibmdb2i_hton= (handlerton *)p;
+ VOID(pthread_mutex_init(&ibmdb2i_mutex,MY_MUTEX_INIT_FAST));
+ (void) hash_init(&ibmdb2i_open_tables,system_charset_info,32,0,0,
+ (hash_get_key) ibmdb2i_get_key,0,0);
+
+ ibmdb2i_hton->state= SHOW_OPTION_YES;
+ ibmdb2i_hton->create= ibmdb2i_create_handler;
+ ibmdb2i_hton->drop_database= ibmdb2i_drop_database;
+ ibmdb2i_hton->commit= ha_ibmdb2i::doCommit;
+ ibmdb2i_hton->rollback= ha_ibmdb2i::doRollback;
+ ibmdb2i_hton->savepoint_offset= 0;
+ ibmdb2i_hton->savepoint_set= ibmdb2i_savepoint_set;
+ ibmdb2i_hton->savepoint_rollback= ibmdb2i_savepoint_rollback;
+ ibmdb2i_hton->savepoint_release= ibmdb2i_savepoint_release;
+ ibmdb2i_hton->alter_table_flags=ibmdb2i_alter_table_flags;
+ ibmdb2i_hton->close_connection=ibmdb2i_close_connection;
+
+ int rc;
+
+ rc = initCharsetSupport();
+
+ if (!rc)
+ rc = db2i_ileBridge::setup();
+
+ if (!rc)
+ {
+ int nameLen = strlen(ibmdb2i_rdb_name);
+ for (int i = 0; i < nameLen; ++i)
+ {
+ ibmdb2i_rdb_name[i] = my_toupper(system_charset_info, (uchar)ibmdb2i_rdb_name[i]);
+ }
+
+ rc = db2i_ileBridge::initILE(ibmdb2i_rdb_name, (uint16*)(((char*)&ibmdb2i_system_trace)+2));
+ if (rc == 0)
+ {
+ was_ILE_inited = true;
+ }
+ }
+
+ DBUG_RETURN(rc);
+}
+
+
+static int ibmdb2i_done_func(void *p)
+{
+ int error= 0;
+ DBUG_ENTER("ibmdb2i_done_func");
+
+ if (ibmdb2i_open_tables.records)
+ error= 1;
+
+ if (was_ILE_inited)
+ db2i_ileBridge::exitILE();
+
+ db2i_ileBridge::takedown();
+
+ doneCharsetSupport();
+
+ hash_free(&ibmdb2i_open_tables);
+ pthread_mutex_destroy(&ibmdb2i_mutex);
+
+ DBUG_RETURN(0);
+}
+
+
+IBMDB2I_SHARE *ha_ibmdb2i::get_share(const char *table_name, TABLE *table)
+{
+ IBMDB2I_SHARE *share;
+ uint length;
+ char *tmp_name;
+
+ pthread_mutex_lock(&ibmdb2i_mutex);
+ length=(uint) strlen(table_name);
+
+ if (!(share=(IBMDB2I_SHARE*) hash_search(&ibmdb2i_open_tables,
+ (uchar*)table_name,
+ length)))
+ {
+ if (!(share=(IBMDB2I_SHARE *)
+ my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
+ &share, sizeof(*share),
+ &tmp_name, length+1,
+ NullS)))
+ {
+ pthread_mutex_unlock(&ibmdb2i_mutex);
+ return NULL;
+ }
+
+ share->use_count=0;
+ share->table_name_length=length;
+ share->table_name=tmp_name;
+ strmov(share->table_name,table_name);
+ if (my_hash_insert(&ibmdb2i_open_tables, (uchar*) share))
+ goto error;
+ thr_lock_init(&share->lock);
+ pthread_mutexattr_t mutexattr = MY_MUTEX_INIT_FAST;
+ pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&share->mutex, &mutexattr);
+
+ share->db2Table = new db2i_table(table->s, table_name);
+ int32 rc = share->db2Table->initDB2Objects(table_name);
+
+ if (rc)
+ {
+ delete share->db2Table;
+ hash_delete(&ibmdb2i_open_tables, (uchar*) share);
+ thr_lock_delete(&share->lock);
+ my_errno = rc;
+ goto error;
+ }
+
+ memset(&share->cachedStats, 0, sizeof(share->cachedStats));
+ }
+ share->use_count++;
+ pthread_mutex_unlock(&ibmdb2i_mutex);
+
+ db2Table = share->db2Table;
+
+ return share;
+
+error:
+ pthread_mutex_destroy(&share->mutex);
+ my_free((uchar*) share, MYF(0));
+ pthread_mutex_unlock(&ibmdb2i_mutex);
+
+ return NULL;
+}
+
+
+
+int ha_ibmdb2i::free_share(IBMDB2I_SHARE *share)
+{
+ pthread_mutex_lock(&ibmdb2i_mutex);
+ if (!--share->use_count)
+ {
+ delete share->db2Table;
+ db2Table = NULL;
+
+ hash_delete(&ibmdb2i_open_tables, (uchar*) share);
+ thr_lock_delete(&share->lock);
+ pthread_mutex_destroy(&share->mutex);
+ my_free(share, MYF(0));
+ pthread_mutex_unlock(&ibmdb2i_mutex);
+ return 1;
+ }
+ pthread_mutex_unlock(&ibmdb2i_mutex);
+
+ return 0;
+}
+
+static handler* ibmdb2i_create_handler(handlerton *hton,
+ TABLE_SHARE *table,
+ MEM_ROOT *mem_root)
+{
+ return new (mem_root) ha_ibmdb2i(hton, table);
+}
+
+static void ibmdb2i_drop_database(handlerton *hton, char* path)
+{
+ DBUG_ENTER("ha_ibmdb2i::ibmdb2i_drop_database");
+ int rc = 0;
+ char queryBuffer[200];
+ String query(queryBuffer, sizeof(queryBuffer), system_charset_info);
+ query.length(0);
+ query.append(STRING_WITH_LEN(" DROP SCHEMA \""));
+ query.append(path+2, strchr(path+2, '/')-(path+2));
+ query.append('"');
+
+ SqlStatementStream sqlStream(query);
+
+ rc = db2i_ileBridge::getBridgeForThread()->execSQL(sqlStream.getPtrToData(),
+ sqlStream.getStatementCount(),
+ QMY_NONE,
+ FALSE,
+ TRUE);
+ DBUG_VOID_RETURN;
+}
+
+inline static void genSavepointName(const void* sv, char* out)
+{
+ *(uint32*)out = *(uint32*)SAVEPOINT_PREFIX;
+ DBUG_ASSERT(sizeof(SAVEPOINT_PREFIX) == 4);
+ out += sizeof(SAVEPOINT_PREFIX);
+
+ longlong2str((longlong)sv, out, 10);
+ while (*out)
+ {
+ out += 0xF0;
+ ++out;
+ }
+}
+
+
+/*********************************************************************
+Sets a transaction savepoint. */
+static int ibmdb2i_savepoint_set(handlerton* hton, THD* thd, void* sv)
+{
+ DBUG_ENTER("ibmdb2i_savepoint_set");
+ int rc = 0;
+ if (!THDVAR(thd ,transaction_unsafe))
+ {
+ char name[64];
+ genSavepointName(sv, name);
+ DBUG_PRINT("ibmdb2i_savepoint_set",("Setting %s", name));
+ rc = ha_ibmdb2i::doSavepointSet(thd, name);
+ }
+ DBUG_RETURN(rc);
+}
+
+
+/*********************************************************************
+Rollback a savepoint. */
+static int ibmdb2i_savepoint_rollback(handlerton* hton, THD* thd, void* sv)
+{
+ DBUG_ENTER("ibmdb2i_savepoint_rollback");
+ int rc = 0;
+ if (!THDVAR(thd,transaction_unsafe))
+ {
+ char name[64];
+ genSavepointName(sv, name);
+ DBUG_PRINT("ibmdb2i_savepoint_rollback",("Rolling back %s", name));
+ rc = ha_ibmdb2i::doSavepointRollback(thd, name);
+ }
+ DBUG_RETURN(rc);
+}
+
+
+/*********************************************************************
+Release a savepoint. */
+static int ibmdb2i_savepoint_release(handlerton* hton, THD* thd, void* sv)
+{
+ DBUG_ENTER("ibmdb2i_savepoint_release");
+ int rc = 0;
+ if (!THDVAR(thd,transaction_unsafe))
+ {
+ char name[64];
+ genSavepointName(sv, name);
+ DBUG_PRINT("ibmdb2i_savepoint_release",("Releasing %s", name));
+ rc = ha_ibmdb2i::doSavepointRelease(thd, name);
+ }
+ DBUG_RETURN(rc);
+}
+
+/* Thse flags allow for the online add and drop of an index via the CREATE INDEX,
+ DROP INDEX, and ALTER TABLE statements. These flags indicate that MySQL is not
+ required to lock the table before calling the storage engine to add or drop the
+ index(s). */
+static uint ibmdb2i_alter_table_flags(uint flags)
+{
+ return (HA_ONLINE_ADD_INDEX | HA_ONLINE_DROP_INDEX |
+ HA_ONLINE_ADD_UNIQUE_INDEX | HA_ONLINE_DROP_UNIQUE_INDEX |
+ HA_ONLINE_ADD_PK_INDEX | HA_ONLINE_DROP_PK_INDEX);
+}
+
+ha_ibmdb2i::ha_ibmdb2i(handlerton *hton, TABLE_SHARE *table_arg)
+ :share(NULL), handler(hton, table_arg),
+ activeHandle(0), dataHandle(0),
+ activeReadBuf(NULL), activeWriteBuf(NULL),
+ blobReadBuffers(NULL), accessIntent(QMY_UPDATABLE), currentRRN(0),
+ releaseRowNeeded(FALSE),
+ indexReadSizeEstimates(NULL),
+ outstanding_start_bulk_insert(false),
+ last_rnd_init_rc(0),
+ last_index_init_rc(0),
+ last_start_bulk_insert_rc(0),
+ autoIncLockAcquired(false),
+ got_auto_inc_values(false),
+ next_identity_value(0),
+ indexHandles(0),
+ returnDupKeysImmediately(false),
+ onDupUpdate(false),
+ blobWriteBuffers(NULL),
+ forceSingleRowRead(false)
+ {
+ activeReferences = 0;
+ ref_length = sizeof(currentRRN);
+ if (table_share && table_share->keys > 0)
+ {
+ indexHandles = (FILE_HANDLE*)my_malloc(table_share->keys * sizeof(FILE_HANDLE), MYF(MY_WME | MY_ZEROFILL));
+ }
+ clear_alloc_root(&conversionBufferMemroot);
+ }
+
+
+ha_ibmdb2i::~ha_ibmdb2i()
+{
+ DBUG_ASSERT(activeReferences == 0 || outstanding_start_bulk_insert);
+
+ if (indexHandles)
+ my_free(indexHandles, MYF(0));
+ if (indexReadSizeEstimates)
+ my_free(indexReadSizeEstimates, MYF(0));
+
+ cleanupBuffers();
+}
+
+
+static const char *ha_ibmdb2i_exts[] = {
+ FID_EXT,
+ NullS
+};
+
+const char **ha_ibmdb2i::bas_ext() const
+{
+ return ha_ibmdb2i_exts;
+}
+
+
+int ha_ibmdb2i::open(const char *name, int mode, uint test_if_locked)
+{
+ DBUG_ENTER("ha_ibmdb2i::open");
+
+ initBridge();
+
+ dataHandle = bridge()->findAndRemovePreservedHandle(name, &share);
+
+ if (share)
+ db2Table = share->db2Table;
+
+ if (!share && (!(share = get_share(name, table))))
+ DBUG_RETURN(my_errno);
+ thr_lock_data_init(&share->lock,&lock,NULL);
+
+ info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
+
+
+ DBUG_RETURN(0);
+}
+
+
+
+
+int ha_ibmdb2i::close(void)
+{
+ DBUG_ENTER("ha_ibmdb2i::close");
+ int32 rc = 0;
+ bool preserveShare = false;
+
+ db2i_ileBridge* bridge = db2i_ileBridge::getBridgeForThread();
+
+ if (dataHandle)
+ {
+ if (bridge->expectErrors(QMY_ERR_PEND_LOCKS)->deallocateFile(dataHandle, FALSE) == QMY_ERR_PEND_LOCKS)
+ {
+ bridge->preserveHandle(share->table_name, dataHandle, share);
+ preserveShare = true;
+ }
+ dataHandle = 0;
+ }
+
+ for (int idx = 0; idx < table_share->keys; ++idx)
+ {
+ if (indexHandles[idx] != 0)
+ {
+ bridge->deallocateFile(indexHandles[idx], FALSE);
+ }
+ }
+
+ cleanupBuffers();
+
+ if (!preserveShare)
+ {
+ if (free_share(share))
+ share = NULL;
+ }
+
+ DBUG_RETURN(rc);
+}
+
+
+
+int ha_ibmdb2i::write_row(uchar * buf)
+{
+
+ DBUG_ENTER("ha_ibmdb2i::write_row");
+
+ if (last_start_bulk_insert_rc)
+ DBUG_RETURN( last_start_bulk_insert_rc );
+
+ ha_statistic_increment(&SSV::ha_write_count);
+ int rc = 0;
+
+ bool fileHandleNeedsRelease = false;
+
+ if (!activeHandle)
+ {
+ rc = useDataFile();
+ if (rc) DBUG_RETURN(rc);
+ fileHandleNeedsRelease = true;
+ }
+
+ if (!outstanding_start_bulk_insert)
+ rc = prepWriteBuffer(1, getFileForActiveHandle());
+
+ if (!rc)
+ {
+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
+ table->timestamp_field->set_time();
+
+ char* writeBuffer = activeWriteBuf->addRow();
+ rc = prepareRowForWrite(writeBuffer,
+ writeBuffer+activeWriteBuf->getRowNullOffset(),
+ true);
+ if (rc == 0)
+ {
+ // If we are doing block inserts, if the MI is supposed to generate an auto_increment
+ // (i.e. identity column) value for this record, and if this is not the first record in
+ // the block, then store the value (that the MI will generate for the identity column)
+ // into the MySQL write buffer. We can predetermine the value because the file is locked.
+
+ if ((autoIncLockAcquired) && (default_identity_value) && (got_auto_inc_values))
+ {
+ if (unlikely((next_identity_value - 1) ==
+ maxValueForField(table->next_number_field)))
+ {
+ rc = QMY_ERR_MAXVALUE;
+ }
+ else
+ {
+ rc = table->next_number_field->store((longlong) next_identity_value, TRUE);
+ next_identity_value = next_identity_value + incrementByValue;
+ }
+ }
+ // If the buffer is full, or if we locked the file and this is the first or last row
+ // of a blocked insert, then flush the buffer.
+ if (!rc && (activeWriteBuf->endOfBuffer()) ||
+ ((autoIncLockAcquired) &&
+ ((!got_auto_inc_values))) ||
+ (returnDupKeysImmediately))
+ rc = flushWrite(activeHandle, buf);
+ }
+ else
+ activeWriteBuf->deleteRow();
+ }
+
+ if (fileHandleNeedsRelease)
+ releaseActiveHandle();
+
+ DBUG_RETURN(rc);
+}
+
+/**
+ @brief
+ Helper function used by write_row and update_row to prepare the MySQL
+ row for insertion into DB2.
+*/
+int ha_ibmdb2i::prepareRowForWrite(char* data, char* nulls, bool honorIdentCols)
+{
+ int rc = 0;
+
+ // set null map all to non nulls
+ memset(nulls,__NOT_NULL_VALUE_EBCDIC, table->s->fields);
+ default_identity_value = FALSE;
+
+ ulong sql_mode = ha_thd()->variables.sql_mode;
+
+ my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
+ for (Field **field = table->field; *field && !rc; ++field)
+ {
+ int fieldIndex = (*field)->field_index;
+ if ((*field)->Field::is_null())
+ {
+ nulls[fieldIndex] = __NULL_VALUE_EBCDIC;
+ }
+ if (honorIdentCols && ((*field)->flags & AUTO_INCREMENT_FLAG) &&
+ *field == table->next_number_field)
+// && ((!autoIncLockAcquired) || (!got_auto_inc_values)))
+ {
+ if (sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)
+ {
+ if (!table->auto_increment_field_not_null)
+ {
+ nulls[fieldIndex] = __DEFAULT_VALUE_EBCDIC;
+ default_identity_value = TRUE;
+ }
+ }
+ else if ((*field)->val_int() == 0)
+ {
+ nulls[fieldIndex] = __DEFAULT_VALUE_EBCDIC;
+ default_identity_value = TRUE;
+ }
+ }
+
+ DB2Field& db2Field = db2Table->db2Field(fieldIndex);
+ if (nulls[fieldIndex] == __NOT_NULL_VALUE_EBCDIC ||
+ db2Field.isBlob())
+ {
+ rc = convertMySQLtoDB2(*field, db2Field, data + db2Field.getBufferOffset());
+ }
+ }
+
+ if (!rc && db2Table->hasBlobs())
+ rc = db2i_ileBridge::getBridgeForThread()->objectOverride(activeHandle,
+ activeWriteBuf->ptr());
+
+ dbug_tmp_restore_column_map(table->read_set, old_map);
+
+ return rc;
+}
+
+
+
+int ha_ibmdb2i::update_row(const uchar * old_data, uchar * new_data)
+{
+ DBUG_ENTER("ha_ibmdb2i::update_row");
+ ha_statistic_increment(&SSV::ha_update_count);
+ int rc;
+
+ bool fileHandleNeedsRelease = false;
+
+ if (!activeHandle)
+ {
+ rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);
+ if (rc) DBUG_RETURN(rc);
+ fileHandleNeedsRelease = true;
+ }
+
+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
+ table->timestamp_field->set_time();
+
+ char* writeBuf = activeWriteBuf->addRow();
+ rc = prepareRowForWrite(writeBuf,
+ writeBuf+activeWriteBuf->getRowNullOffset(),
+ onDupUpdate);
+
+ char* lastDupKeyNamePtr = NULL;
+ uint32 lastDupKeyNameLen = 0;
+
+ if (!rc)
+ {
+ rc = db2i_ileBridge::getBridgeForThread()->updateRow(activeHandle,
+ currentRRN,
+ activeWriteBuf->ptr(),
+ &lastDupKeyRRN,
+ &lastDupKeyNamePtr,
+ &lastDupKeyNameLen);
+ }
+
+ if (lastDupKeyNameLen)
+ {
+ lastDupKeyID = getKeyFromName(lastDupKeyNamePtr, lastDupKeyNameLen);
+ rrnAssocHandle = activeHandle;
+ }
+
+ if (fileHandleNeedsRelease)
+ releaseActiveHandle();
+
+ activeWriteBuf->resetAfterWrite();
+
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::delete_row(const uchar * buf)
+{
+ DBUG_ENTER("ha_ibmdb2i::delete_row");
+ ha_statistic_increment(&SSV::ha_delete_count);
+
+ bool needReleaseFile = false;
+ int rc = 0;
+
+ if (!activeHandle) // In some circumstances, MySQL comes here after
+ { // closing the active handle. We need to re-open.
+ rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);
+ needReleaseFile = true;
+ }
+
+ if (likely(!rc))
+ {
+ rc = db2i_ileBridge::getBridgeForThread()->deleteRow(activeHandle,
+ currentRRN);
+ invalidateCachedStats();
+ if (needReleaseFile)
+ releaseActiveHandle();
+ }
+
+ DBUG_RETURN(rc);
+}
+
+
+
+int ha_ibmdb2i::index_init(uint idx, bool sorted)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_init");
+
+ int& rc = last_index_init_rc;
+ rc = 0;
+
+ invalidDataFound=false;
+ tweakReadSet();
+
+ active_index=idx;
+
+ rc = useIndexFile(idx);
+
+ if (!rc)
+ {
+// THD* thd = ha_thd();
+// if (accessIntent == QMY_UPDATABLE &&
+// thd_tx_isolation(thd) == ISO_REPEATABLE_READ &&
+// !THDVAR(thd, transaction_unsafe))
+// {
+// readAccessIntent = QMY_READ_ONLY;
+// }
+// else
+// {
+ readAccessIntent = accessIntent;
+// }
+
+ if (!rc && accessIntent != QMY_READ_ONLY)
+ rc = prepWriteBuffer(1, db2Table->indexFile(idx));
+
+ if (rc)
+ releaseIndexFile(idx);
+ }
+
+ rrnAssocHandle= 0;
+
+ DBUG_RETURN(rc);
+}
+
+
+
+int ha_ibmdb2i::index_read(uchar * buf, const uchar * key,
+ uint key_len,
+ enum ha_rkey_function find_flag)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_read");
+
+ if (unlikely(last_index_init_rc)) DBUG_RETURN(last_index_init_rc);
+
+ int rc;
+
+ ha_rows estimatedRows = getIndexReadEstimate(active_index);
+ rc = prepReadBuffer(estimatedRows, db2Table->indexFile(active_index), readAccessIntent);
+ if (unlikely(rc)) DBUG_RETURN(rc);
+
+ DBUG_ASSERT(activeReadBuf);
+
+ keyBuf.allocBuf(activeReadBuf->getRowLength(),
+ activeReadBuf->getRowNullOffset(),
+ activeReadBuf->getRowLength());
+ keyBuf.zeroBuf();
+
+ char* db2KeyBufPtr = keyBuf.ptr();
+ char* nullKeyMap = db2KeyBufPtr + activeReadBuf->getRowNullOffset();
+
+ const uchar* keyBegin = key;
+ int partsInUse;
+
+ KEY& curKey = table->key_info[active_index];
+
+ for (partsInUse = 0; partsInUse < curKey.key_parts, key - keyBegin < key_len; ++partsInUse)
+ {
+ Field* field = curKey.key_part[partsInUse].field;
+ if ((curKey.key_part[partsInUse].null_bit) &&
+ (char*)key[0])
+ {
+ if (field->flags & AUTO_INCREMENT_FLAG)
+ {
+ table->status = STATUS_NOT_FOUND;
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
+ else
+ {
+ nullKeyMap[partsInUse] = __NULL_VALUE_EBCDIC;
+ }
+ }
+ else
+ {
+ nullKeyMap[partsInUse] = __NOT_NULL_VALUE_EBCDIC;
+ convertMySQLtoDB2(field,
+ db2Table->db2Field(field->field_index),
+ db2KeyBufPtr,
+ (uchar*)key+((curKey.key_part[partsInUse].null_bit)? 1 : 0) ); // + (curKey.key_parts+7) / 8);
+ }
+
+ db2KeyBufPtr += db2Table->db2Field(field->field_index).getByteLengthInRecord();
+ key += curKey.key_part[partsInUse].store_length;
+ }
+
+ keyLen = db2KeyBufPtr - (char*)keyBuf.ptr();
+
+ DBUG_PRINT("ha_ibmdb2i::index_read", ("find_flag: %d", find_flag));
+
+ char readDirection = QMY_NEXT;
+
+ switch (find_flag)
+ {
+ case HA_READ_AFTER_KEY:
+ doInitialRead(QMY_AFTER_EQUAL, estimatedRows,
+ keyBuf.ptr(), keyLen, partsInUse);
+ break;
+ case HA_READ_BEFORE_KEY:
+ doInitialRead(QMY_BEFORE_EQUAL, estimatedRows,
+ keyBuf.ptr(), keyLen, partsInUse);
+ break;
+ case HA_READ_KEY_OR_NEXT:
+ doInitialRead(QMY_AFTER_OR_EQUAL, estimatedRows,
+ keyBuf.ptr(), keyLen, partsInUse);
+ break;
+ case HA_READ_KEY_OR_PREV:
+ DBUG_ASSERT(0); // This function is unused
+ doInitialRead(QMY_BEFORE_OR_EQUAL, estimatedRows,
+ keyBuf.ptr(), keyLen, partsInUse);
+ break;
+ case HA_READ_PREFIX_LAST_OR_PREV:
+ doInitialRead(QMY_LAST_PREVIOUS, estimatedRows,
+ keyBuf.ptr(), keyLen, partsInUse);
+ readDirection = QMY_PREVIOUS;
+ break;
+ case HA_READ_PREFIX_LAST:
+ doInitialRead(QMY_PREFIX_LAST, estimatedRows,
+ keyBuf.ptr(), keyLen, partsInUse);
+ readDirection = QMY_PREVIOUS;
+ break;
+ case HA_READ_KEY_EXACT:
+ doInitialRead(QMY_EQUAL, estimatedRows, keyBuf.ptr(), keyLen, partsInUse);
+ break;
+ default:
+ DBUG_ASSERT(0);
+ return HA_ERR_GENERIC;
+ break;
+ }
+
+ ha_statistic_increment(&SSV::ha_read_key_count);
+ rc = readFromBuffer(buf, readDirection);
+
+ table->status= (rc ? STATUS_NOT_FOUND: 0);
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::index_next(uchar * buf)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_next");
+ ha_statistic_increment(&SSV::ha_read_next_count);
+
+ int rc = readFromBuffer(buf, QMY_NEXT);
+
+ table->status= (rc ? STATUS_NOT_FOUND: 0);
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::index_next_same(uchar *buf, const uchar *key, uint keylen)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_next_same");
+ ha_statistic_increment(&SSV::ha_read_next_count);
+
+ int rc = readFromBuffer(buf, QMY_NEXT_EQUAL);
+
+ if (rc == HA_ERR_KEY_NOT_FOUND)
+ {
+ rc = HA_ERR_END_OF_FILE;
+ }
+
+ table->status= (rc ? STATUS_NOT_FOUND: 0);
+ DBUG_RETURN(rc);
+}
+
+int ha_ibmdb2i::index_read_last(uchar * buf, const uchar * key, uint key_len)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_read_last");
+ DBUG_RETURN(index_read(buf, key, key_len, HA_READ_PREFIX_LAST));
+}
+
+
+
+int ha_ibmdb2i::index_prev(uchar * buf)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_prev");
+ ha_statistic_increment(&SSV::ha_read_prev_count);
+
+ int rc = readFromBuffer(buf, QMY_PREVIOUS);
+
+ table->status= (rc ? STATUS_NOT_FOUND: 0);
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::index_first(uchar * buf)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_first");
+
+ if (unlikely(last_index_init_rc)) DBUG_RETURN(last_index_init_rc);
+
+ int rc = prepReadBuffer(DEFAULT_MAX_ROWS_TO_BUFFER,
+ db2Table->indexFile(active_index),
+ readAccessIntent);
+
+ if (rc == 0)
+ {
+ doInitialRead(QMY_FIRST, DEFAULT_MAX_ROWS_TO_BUFFER);
+ ha_statistic_increment(&SSV::ha_read_first_count);
+ rc = readFromBuffer(buf, QMY_NEXT);
+ }
+
+ table->status= (rc ? STATUS_NOT_FOUND: 0);
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::index_last(uchar * buf)
+{
+ DBUG_ENTER("ha_ibmdb2i::index_last");
+
+ if (unlikely(last_index_init_rc)) DBUG_RETURN(last_index_init_rc);
+
+ int rc = prepReadBuffer(DEFAULT_MAX_ROWS_TO_BUFFER,
+ db2Table->indexFile(active_index),
+ readAccessIntent);
+
+ if (rc == 0)
+ {
+ doInitialRead(QMY_LAST, DEFAULT_MAX_ROWS_TO_BUFFER);
+ ha_statistic_increment(&SSV::ha_read_last_count);
+ rc = readFromBuffer(buf, QMY_PREVIOUS);
+ }
+
+ table->status= (rc ? STATUS_NOT_FOUND: 0);
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::rnd_init(bool scan)
+{
+ DBUG_ENTER("ha_ibmdb2i::rnd_init");
+
+ int& rc = last_rnd_init_rc;
+ rc = 0;
+
+ tweakReadSet();
+ invalidDataFound=false;
+
+ uint32 rowsToBlockOnRead;
+
+ if (!scan)
+ {
+ rowsToBlockOnRead = 1;
+ }
+ else
+ {
+ rowsToBlockOnRead = DEFAULT_MAX_ROWS_TO_BUFFER;
+ }
+
+ rc = useDataFile();
+
+ if (!rc)
+ {
+// THD* thd = ha_thd();
+// if (accessIntent == QMY_UPDATABLE &&
+// thd_tx_isolation(thd) == ISO_REPEATABLE_READ &&
+// !THDVAR(thd, transaction_unsafe))
+// {
+// readAccessIntent = QMY_READ_ONLY;
+// }
+// else
+// {
+ readAccessIntent = accessIntent;
+// }
+
+ rc = prepReadBuffer(rowsToBlockOnRead, db2Table->dataFile(), readAccessIntent);
+
+ if (!rc && accessIntent != QMY_READ_ONLY)
+ rc = prepWriteBuffer(1, db2Table->dataFile());
+
+ if (!rc && scan)
+ doInitialRead(QMY_FIRST, rowsToBlockOnRead);
+
+ if (rc)
+ releaseDataFile();
+ }
+
+ rrnAssocHandle= 0;
+
+ DBUG_RETURN(0); // MySQL sometimes does not check the return code, causing
+ // an assert in ha_rnd_end later on if we return a non-zero
+ // value here.
+}
+
+int ha_ibmdb2i::rnd_end()
+{
+ DBUG_ENTER("ha_ibmdb2i::rnd_end");
+
+ warnIfInvalidData();
+ if (likely(activeReadBuf))
+ activeReadBuf->endRead();
+ if (last_rnd_init_rc == 0)
+ releaseActiveHandle();
+ last_rnd_init_rc = 0;
+ DBUG_RETURN(0);
+}
+
+
+int32 ha_ibmdb2i::mungeDB2row(uchar* record, const char* dataPtr, const char* nullMapPtr, bool skipLOBs)
+{
+ DBUG_ASSERT(dataPtr);
+
+ my_bitmap_map *old_write_map= dbug_tmp_use_all_columns(table, table->write_set);
+ my_bitmap_map *old_read_map;
+
+ if (unlikely(readAllColumns))
+ old_read_map = tmp_use_all_columns(table, table->read_set);
+
+ resetCharacterConversionBuffers();
+
+ my_ptrdiff_t old_ptr= (my_ptrdiff_t) (record - table->record[0]);
+ int fieldIndex = 0;
+ for (Field **field = table->field; *field; ++field, ++fieldIndex)
+ {
+ if (unlikely(old_ptr))
+ (*field)->move_field_offset(old_ptr);
+ if (nullMapPtr[fieldIndex] == __NULL_VALUE_EBCDIC ||
+ (!bitmap_is_set(table->read_set, fieldIndex)) ||
+ (skipLOBs && db2Table->db2Field(fieldIndex).isBlob()))
+ {
+ (*field)->set_null();
+ }
+ else
+ {
+ (*field)->set_notnull();
+ convertDB2toMySQL(db2Table->db2Field(fieldIndex), *field, dataPtr);
+ }
+ if (unlikely(old_ptr))
+ (*field)->move_field_offset(-old_ptr);
+
+ }
+
+ if (unlikely(readAllColumns))
+ tmp_restore_column_map(table->read_set, old_read_map);
+ dbug_tmp_restore_column_map(table->write_set, old_write_map);
+
+ return 0;
+}
+
+
+int ha_ibmdb2i::rnd_next(uchar *buf)
+{
+ DBUG_ENTER("ha_ibmdb2i::rnd_next");
+
+ if (unlikely(last_rnd_init_rc)) DBUG_RETURN(last_rnd_init_rc);
+ ha_statistic_increment(&SSV::ha_read_rnd_next_count);
+
+ int rc;
+
+ rc = readFromBuffer(buf, QMY_NEXT);
+
+ table->status= (rc ? STATUS_NOT_FOUND: 0);
+ DBUG_RETURN(rc);
+}
+
+
+void ha_ibmdb2i::position(const uchar *record)
+{
+ DBUG_ENTER("ha_ibmdb2i::position");
+ my_store_ptr(ref, ref_length, currentRRN);
+ DBUG_VOID_RETURN;
+}
+
+
+int ha_ibmdb2i::rnd_pos(uchar * buf, uchar *pos)
+{
+ DBUG_ENTER("ha_ibmdb2i::rnd_pos");
+ if (unlikely(last_rnd_init_rc)) DBUG_RETURN( last_rnd_init_rc);
+ ha_statistic_increment(&SSV::ha_read_rnd_count);
+
+ currentRRN = my_get_ptr(pos, ref_length);
+
+ tweakReadSet();
+
+ int rc = 0;
+
+ if (rrnAssocHandle &&
+ (activeHandle != rrnAssocHandle))
+ {
+ if (activeHandle) releaseActiveHandle();
+ rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);
+ }
+
+ if (likely(rc == 0))
+ {
+ rc = prepReadBuffer(1, getFileForActiveHandle(), accessIntent);
+
+ if (likely(rc == 0) && accessIntent == QMY_UPDATABLE)
+ rc = prepWriteBuffer(1, getFileForActiveHandle());
+
+ if (likely(rc == 0))
+ {
+ rc = db2i_ileBridge::getBridgeForThread()->readByRRN(activeHandle,
+ activeReadBuf->ptr(),
+ currentRRN,
+ accessIntent,
+ getCommitLevel());
+
+ if (likely(rc == 0))
+ {
+ rrnAssocHandle = activeHandle;
+ const char* readBuf = activeReadBuf->getRowN(0);
+ rc = mungeDB2row(buf, readBuf, readBuf + activeReadBuf->getRowNullOffset(), false);
+ releaseRowNeeded = TRUE;
+ }
+ }
+ }
+
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::info(uint flag)
+{
+ DBUG_ENTER("ha_ibmdb2i::info");
+
+ uint16 infoRequested = 0;
+ ValidatedPointer<char> rowKeySpcPtr; // Space pointer passed to DB2
+ uint32 rowKeySpcLen; // Length of space passed to DB2
+ THD* thd = ha_thd();
+ int command = thd_sql_command(thd);
+
+ if (flag & HA_STATUS_AUTO)
+ stats.auto_increment_value = (ulonglong) 0;
+
+ if (flag & HA_STATUS_ERRKEY)
+ {
+ errkey = lastDupKeyID;
+ my_store_ptr(dup_ref, ref_length, lastDupKeyRRN);
+ }
+
+ if (flag & HA_STATUS_TIME)
+ {
+ if ((flag & HA_STATUS_NO_LOCK) &&
+ ibmdb2i_assume_exclusive_use &&
+ share &&
+ (share->cachedStats.isInited(lastModTime)))
+ stats.update_time = share->cachedStats.getUpdateTime();
+ else
+ infoRequested |= lastModTime;
+ }
+
+ if (flag & HA_STATUS_CONST)
+ {
+ stats.block_size=4096;
+ infoRequested |= createTime;
+
+ if (table->s->keys)
+ {
+ infoRequested |= rowsPerKey;
+ rowKeySpcLen = (table->s->keys) * MAX_DB2_KEY_PARTS * sizeof(uint64);
+ rowKeySpcPtr.alloc(rowKeySpcLen);
+ memset(rowKeySpcPtr, 0, rowKeySpcLen); // Clear the allocated space
+ }
+ }
+
+ if (flag & HA_STATUS_VARIABLE)
+ {
+ if ((flag & HA_STATUS_NO_LOCK) &&
+ (command != SQLCOM_SHOW_TABLE_STATUS) &&
+ ibmdb2i_assume_exclusive_use &&
+ share &&
+ (share->cachedStats.isInited(rowCount | deletedRowCount | meanRowLen | ioCount)) &&
+ (share->cachedStats.getRowCount() >= 2))
+ {
+ stats.records = share->cachedStats.getRowCount();
+ stats.deleted = share->cachedStats.getDelRowCount();
+ stats.mean_rec_length = share->cachedStats.getMeanLength();
+ stats.data_file_length = share->cachedStats.getAugmentedDataLength();
+ }
+ else
+ {
+ infoRequested |= rowCount | deletedRowCount | meanRowLen;
+ if (command == SQLCOM_SHOW_TABLE_STATUS)
+ infoRequested |= objLength;
+ else
+ infoRequested |= ioCount;
+ }
+ }
+
+ int rc = 0;
+
+ if (infoRequested)
+ {
+ DBUG_PRINT("ha_ibmdb2i::info",("Retrieving fresh stats %d", flag));
+
+ initBridge(thd);
+ rc = bridge()->retrieveTableInfo((dataHandle ? dataHandle : db2Table->dataFile()->getMasterDefnHandle()),
+ infoRequested,
+ stats,
+ rowKeySpcPtr);
+
+ if (!rc)
+ {
+ if ((flag & HA_STATUS_VARIABLE) &&
+ (command != SQLCOM_SHOW_TABLE_STATUS))
+ stats.data_file_length = stats.data_file_length * IO_SIZE;
+
+ if ((ibmdb2i_assume_exclusive_use) &&
+ (share) &&
+ (command != SQLCOM_SHOW_TABLE_STATUS))
+ {
+ if (flag & HA_STATUS_VARIABLE)
+ {
+ share->cachedStats.cacheRowCount(stats.records);
+ share->cachedStats.cacheDelRowCount(stats.deleted);
+ share->cachedStats.cacheMeanLength(stats.mean_rec_length);
+ share->cachedStats.cacheAugmentedDataLength(stats.data_file_length);
+ }
+
+ if (flag & HA_STATUS_TIME)
+ {
+ share->cachedStats.cacheUpdateTime(stats.update_time);
+ }
+ }
+
+ if (flag & HA_STATUS_CONST)
+ {
+ ulong i; // Loop counter for indexes
+ ulong j; // Loop counter for key parts
+ RowKey* rowKeyPtr; // Pointer to 'number of unique rows' array for this index
+
+ rowKeyPtr = (RowKey_t*)(void*)rowKeySpcPtr; // Address first array of DB2 row counts
+ for (i = 0; i < table->s->keys; i++) // Do for each index, including primary
+ {
+ for (j = 0; j < table->key_info[i].key_parts; j++)
+ {
+ table->key_info[i].rec_per_key[j]= rowKeyPtr->RowKeyArray[j];
+ }
+ rowKeyPtr = rowKeyPtr + 1; // Address next array of DB2 row counts
+ }
+ }
+ }
+ else if (rc == HA_ERR_LOCK_WAIT_TIMEOUT && share)
+ {
+ // If we couldn't retrieve the info because the object was locked,
+ // we'll do our best by returning the most recently cached data.
+ if ((infoRequested & rowCount) &&
+ share->cachedStats.isInited(rowCount))
+ stats.records = share->cachedStats.getRowCount();
+ if ((infoRequested & deletedRowCount) &&
+ share->cachedStats.isInited(deletedRowCount))
+ stats.deleted = share->cachedStats.getDelRowCount();
+ if ((infoRequested & meanRowLen) &&
+ share->cachedStats.isInited(meanRowLen))
+ stats.mean_rec_length = share->cachedStats.getMeanLength();
+ if ((infoRequested & lastModTime) &&
+ share->cachedStats.isInited(lastModTime))
+ stats.update_time = share->cachedStats.getUpdateTime();
+
+ rc = 0;
+ }
+ }
+
+ DBUG_RETURN(rc);
+}
+
+
+ha_rows ha_ibmdb2i::records()
+{
+ DBUG_ENTER("ha_ibmdb2i::records");
+ int rc;
+ rc = bridge()->retrieveTableInfo((dataHandle ? dataHandle : db2Table->dataFile()->getMasterDefnHandle()),
+ rowCount,
+ stats);
+
+ if (unlikely(rc))
+ {
+ if (rc == HA_ERR_LOCK_WAIT_TIMEOUT &&
+ share &&
+ (share->cachedStats.isInited(rowCount)))
+ DBUG_RETURN(share->cachedStats.getRowCount());
+ else
+ DBUG_RETURN(HA_POS_ERROR);
+ }
+ else if (share)
+ {
+ share->cachedStats.cacheRowCount(stats.records);
+ }
+
+ DBUG_RETURN(stats.records);
+}
+
+
+int ha_ibmdb2i::extra(enum ha_extra_function operation)
+{
+ DBUG_ENTER("ha_ibmdb2i::extra");
+
+ switch(operation)
+ {
+ // Can these first five flags be replaced by attending to HA_EXTRA_WRITE_CACHE?
+ case HA_EXTRA_NO_IGNORE_DUP_KEY:
+ case HA_EXTRA_WRITE_CANNOT_REPLACE:
+ {
+ returnDupKeysImmediately = false;
+ onDupUpdate = false;
+ }
+ break;
+ case HA_EXTRA_INSERT_WITH_UPDATE:
+ {
+ returnDupKeysImmediately = true;
+ onDupUpdate = true;
+ }
+ break;
+ case HA_EXTRA_IGNORE_DUP_KEY:
+ case HA_EXTRA_WRITE_CAN_REPLACE:
+ returnDupKeysImmediately = true;
+ break;
+ case HA_EXTRA_FLUSH_CACHE:
+ if (outstanding_start_bulk_insert)
+ finishBulkInsert();
+ break;
+ }
+
+
+ DBUG_RETURN(0);
+}
+
+/**
+ @brief
+ The DB2 storage engine will ignore a MySQL generated value and will generate
+ a new value in SLIC. We arbitrarily set first_value to 1, and set the
+ interval to infinity for better performance on multi-row inserts.
+*/
+void ha_ibmdb2i::get_auto_increment(ulonglong offset, ulonglong increment,
+ ulonglong nb_desired_values,
+ ulonglong *first_value,
+ ulonglong *nb_reserved_values)
+{
+ DBUG_ENTER("ha_ibmdb2i::get_auto_increment");
+ *first_value= 1;
+ *nb_reserved_values= ULONGLONG_MAX;
+}
+
+
+
+void ha_ibmdb2i::update_create_info(HA_CREATE_INFO *create_info)
+{
+ DBUG_ENTER("ha_ibmdb2i::update_create_info");
+
+ if ((!(create_info->used_fields & HA_CREATE_USED_AUTO)) &&
+ (table->found_next_number_field != NULL))
+ {
+ initBridge();
+
+ create_info->auto_increment_value= 1;
+
+ ha_rows rowCount = records();
+
+ if (rowCount == 0)
+ {
+ create_info->auto_increment_value = db2Table->getStartId();
+ DBUG_VOID_RETURN;
+ }
+ else if (rowCount == HA_POS_ERROR)
+ {
+ DBUG_VOID_RETURN;
+ }
+
+ getNextIdVal(&create_info->auto_increment_value);
+ }
+ DBUG_VOID_RETURN;
+}
+
+
+int ha_ibmdb2i::getNextIdVal(ulonglong *value)
+{
+ DBUG_ENTER("ha_ibmdb2i::getNextIdVal");
+
+ char queryBuffer[MAX_DB2_COLNAME_LENGTH + MAX_DB2_QUALIFIEDNAME_LENGTH + 64];
+ strcpy(queryBuffer, " SELECT CAST(MAX( ");
+ convertMySQLNameToDB2Name(table->found_next_number_field->field_name,
+ strend(queryBuffer),
+ MAX_DB2_COLNAME_LENGTH+1);
+ strcat(queryBuffer, ") AS BIGINT) FROM ");
+ db2Table->getDB2QualifiedName(strend(queryBuffer));
+ DBUG_ASSERT(strlen(queryBuffer) < sizeof(queryBuffer));
+
+ SqlStatementStream sqlStream(queryBuffer);
+ DBUG_PRINT("ha_ibmdb2i::getNextIdVal", ("Sent to DB2: %s",queryBuffer));
+
+ int rc = 0;
+ FILE_HANDLE fileHandle2;
+ uint32 db2RowDataLen2;
+ rc = bridge()->prepOpen(sqlStream.getPtrToData(),
+ &fileHandle2,
+ &db2RowDataLen2);
+ if (likely(rc == 0))
+ {
+ IOReadBuffer rowBuffer(1, db2RowDataLen2);
+ rc = bridge()->read(fileHandle2,
+ rowBuffer.ptr(),
+ QMY_READ_ONLY,
+ QMY_NONE,
+ QMY_FIRST);
+
+ if (likely(rc == 0))
+ {
+ /* This check is here for the case where the table is not empty,
+ but the auto_increment starting value has been changed since
+ the last record was written. */
+
+ longlong maxIdVal = *(longlong*)(rowBuffer.getRowN(0));
+ if ((maxIdVal + 1) > db2Table->getStartId())
+ *value = maxIdVal + 1;
+ else
+ *value = db2Table->getStartId();
+ }
+
+ bridge()->deallocateFile(fileHandle2);
+ }
+ DBUG_RETURN(rc);
+}
+
+
+/*
+ Updates index cardinalities.
+*/
+int ha_ibmdb2i::analyze(THD* thd, HA_CHECK_OPT *check_opt)
+{
+ DBUG_ENTER("ha_ibmdb2i::analyze");
+ info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
+ DBUG_RETURN(0);
+}
+
+int ha_ibmdb2i::optimize(THD* thd, HA_CHECK_OPT *check_opt)
+{
+ DBUG_ENTER("ha_ibmdb2i::optimize");
+
+ initBridge(thd);
+
+ if (unlikely(records() == 0))
+ DBUG_RETURN(0); // DB2 doesn't like to reorganize a table with no data.
+
+ quiesceAllFileHandles();
+
+ int32 rc = bridge()->optimizeTable(db2Table->dataFile()->getMasterDefnHandle());
+ info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
+
+ DBUG_RETURN(rc);
+}
+
+
+/**
+ @brief
+ Determines if an ALTER TABLE is allowed to switch the storage engine
+ for this table. If the table has a foreign key or is referenced by a
+ foreign key, then it cannot be switched.
+*/
+bool ha_ibmdb2i::can_switch_engines(void)
+/*=================================*/
+{
+ DBUG_ENTER("ha_ibmdb2i::can_switch_engines");
+
+ int rc = 0;
+ FILE_HANDLE queryFile = 0;
+ uint32 resultRowLen;
+ uint count = 0;
+ bool can_switch = FALSE; // 1 if changing storage engine is allowed
+
+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
+
+ String query(256);
+ query.append(STRING_WITH_LEN(" SELECT COUNT(*) FROM SYSIBM.SQLFOREIGNKEYS WHERE ((PKTABLE_SCHEM = '"));
+ query.append(libName+1, strlen(libName)-2); // Remove quotes from parent schema name
+ query.append(STRING_WITH_LEN("' AND PKTABLE_NAME = '"));
+ query.append(fileName+1,strlen(fileName)-2); // Remove quotes from file name
+ query.append(STRING_WITH_LEN("') OR (FKTABLE_SCHEM = '"));
+ query.append(libName+1,strlen(libName)-2); // Remove quotes from child schema
+ query.append(STRING_WITH_LEN("' AND FKTABLE_NAME = '"));
+ query.append(fileName+1,strlen(fileName)-2); // Remove quotes from child name
+ query.append(STRING_WITH_LEN("'))"));
+
+ SqlStatementStream sqlStream(query);
+
+ rc = bridge()->prepOpen(sqlStream.getPtrToData(),
+ &queryFile,
+ &resultRowLen);
+ if (rc == 0)
+ {
+ IOReadBuffer rowBuffer(1, resultRowLen);
+
+ rc = bridge()->read(queryFile,
+ rowBuffer.ptr(),
+ QMY_READ_ONLY,
+ QMY_NONE,
+ QMY_FIRST);
+ if (!rc)
+ {
+ count = *(uint*)(rowBuffer.getRowN(0));
+ if (count == 0)
+ can_switch = TRUE;
+ }
+
+ bridge()->deallocateFile(queryFile);
+ }
+ DBUG_RETURN(can_switch);
+}
+
+
+
+bool ha_ibmdb2i::check_if_incompatible_data(HA_CREATE_INFO *info,
+ uint table_changes)
+{
+ DBUG_ENTER("ha_ibmdb2i::check_if_incompatible_data");
+ uint i;
+ /* Check that auto_increment value and field definitions were
+ not changed. */
+ if ((info->used_fields & HA_CREATE_USED_AUTO &&
+ info->auto_increment_value != 0) ||
+ table_changes != IS_EQUAL_YES)
+ DBUG_RETURN(COMPATIBLE_DATA_NO);
+ /* Check if any fields were renamed. */
+ for (i= 0; i < table->s->fields; i++)
+ {
+ Field *field= table->field[i];
+ if (field->flags & FIELD_IS_RENAMED)
+ {
+ DBUG_PRINT("info", ("Field has been renamed, copy table"));
+ DBUG_RETURN(COMPATIBLE_DATA_NO);
+ }
+ }
+ DBUG_RETURN(COMPATIBLE_DATA_YES);
+}
+
+int ha_ibmdb2i::reset_auto_increment(ulonglong value)
+ {
+ DBUG_ENTER("ha_ibmdb2i::reset_auto_increment");
+
+ int rc = 0;
+
+ quiesceAllFileHandles();
+
+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
+
+ String query(512);
+ query.append(STRING_WITH_LEN(" ALTER TABLE "));
+ query.append(libName);
+ query.append('.');
+ query.append(fileName);
+ query.append(STRING_WITH_LEN(" ALTER COLUMN "));
+ char colName[MAX_DB2_COLNAME_LENGTH+1];
+ convertMySQLNameToDB2Name(table->found_next_number_field->field_name,
+ colName,
+ sizeof(colName));
+ query.append(colName);
+
+ char restart_value[22];
+ CHARSET_INFO *cs= &my_charset_bin;
+ uint len = (uint)(cs->cset->longlong10_to_str)(cs,restart_value,sizeof(restart_value), 10, value);
+ restart_value[len] = 0;
+
+ query.append(STRING_WITH_LEN(" RESTART WITH "));
+ query.append(restart_value);
+
+ SqlStatementStream sqlStream(query);
+ DBUG_PRINT("ha_ibmdb2i::reset_auto_increment", ("Sent to DB2: %s",query.c_ptr()));
+
+ rc = db2i_ileBridge::getBridgeForThread()->execSQL(sqlStream.getPtrToData(),
+ sqlStream.getStatementCount(),
+ QMY_NONE, //getCommitLevel(),
+ FALSE,
+ FALSE,
+ TRUE, //FALSE,
+ dataHandle);
+ if (rc == 0)
+ db2Table->updateStartId(value);
+
+ DBUG_RETURN(rc);
+}
+
+
+/**
+ @brief
+ This function receives an error code that was previously set by the handler.
+ It returns to MySQL the error string associated with that error.
+*/
+bool ha_ibmdb2i::get_error_message(int error, String *buf)
+{
+ DBUG_ENTER("ha_ibmdb2i::get_error_message");
+ if ((error >= DB2I_FIRST_ERR && error <= DB2I_LAST_ERR) ||
+ (error >= QMY_ERR_MIN && error <= QMY_ERR_MAX))
+ {
+ db2i_ileBridge* bridge = db2i_ileBridge::getBridgeForThread(ha_thd());
+ char* errMsg = bridge->getErrorStorage();
+ buf->copy(errMsg, strlen(errMsg),system_charset_info);
+ bridge->freeErrorStorage();
+ }
+ DBUG_RETURN(FALSE);
+}
+
+
+int ha_ibmdb2i::delete_all_rows()
+{
+ DBUG_ENTER("ha_ibmdb2i::delete_all_rows");
+ int rc = 0;
+ char queryBuffer[MAX_DB2_QUALIFIEDNAME_LENGTH + 64];
+ strcpy(queryBuffer, " DELETE FROM ");
+ db2Table->getDB2QualifiedName(strend(queryBuffer));
+ DBUG_ASSERT(strlen(queryBuffer) < sizeof(queryBuffer));
+
+ SqlStatementStream sqlStream(queryBuffer);
+ DBUG_PRINT("ha_ibmdb2i::delete_all_rows", ("Sent to DB2: %s",queryBuffer));
+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
+ sqlStream.getStatementCount(),
+ getCommitLevel(),
+ false,
+ false,
+ true,
+ dataHandle);
+
+ /* If this method was called on behalf of a TRUNCATE TABLE statement, and if */
+ /* the table has an auto_increment field, then reset the starting value for */
+ /* the auto_increment field to 1.
+ */
+ if (rc == 0 && thd_sql_command(ha_thd()) == SQLCOM_TRUNCATE &&
+ table->found_next_number_field )
+ rc = reset_auto_increment(1);
+
+ invalidateCachedStats();
+
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::external_lock(THD *thd, int lock_type)
+{
+ int rc = 0;
+
+ DBUG_ENTER("ha_ibmdb2i::external_lock");
+ DBUG_PRINT("ha_ibmdb2i::external_lock",("Lock type: %d", lock_type));
+
+ if (lock_type == F_RDLCK)
+ accessIntent = QMY_READ_ONLY;
+ else if (lock_type == F_WRLCK)
+ accessIntent = QMY_UPDATABLE;
+
+ initBridge(thd);
+ int command = thd_sql_command(thd);
+
+ if (!THDVAR(thd,transaction_unsafe))
+ {
+ if (lock_type != F_UNLCK)
+ {
+ if (autoCommitIsOn(thd) == QMY_YES)
+ {
+ trans_register_ha(thd, FALSE, ibmdb2i_hton);
+ }
+ else
+ {
+ trans_register_ha(thd, TRUE, ibmdb2i_hton);
+ if (likely(command != SQLCOM_CREATE_TABLE))
+ {
+ trans_register_ha(thd, FALSE, ibmdb2i_hton);
+ bridge()->beginStmtTx();
+ }
+ }
+ }
+ }
+
+ if (command == SQLCOM_LOCK_TABLES ||
+ command == SQLCOM_ALTER_TABLE ||
+ command == SQLCOM_UNLOCK_TABLES ||
+ (accessIntent == QMY_UPDATABLE &&
+ (command == SQLCOM_UPDATE ||
+ command == SQLCOM_UPDATE_MULTI ||
+ command == SQLCOM_DELETE ||
+ command == SQLCOM_DELETE_MULTI ||
+ command == SQLCOM_REPLACE ||
+ command == SQLCOM_REPLACE_SELECT) &&
+ getCommitLevel(thd) == QMY_NONE))
+ {
+ char action;
+ char type;
+ if (lock_type == F_UNLCK)
+ {
+ action = QMY_UNLOCK;
+ type = accessIntent == QMY_READ_ONLY ? QMY_LSRD : QMY_LENR;
+ }
+ else
+ {
+ action = QMY_LOCK;
+ type = lock_type == F_RDLCK ? QMY_LSRD : QMY_LENR;
+ }
+
+ DBUG_PRINT("ha_ibmdb2i::external_lock",("%socking table", action==QMY_LOCK ? "L" : "Unl"));
+
+ if (!dataHandle)
+ rc = db2Table->dataFile()->allocateNewInstance(&dataHandle, curConnection);
+
+ rc = bridge()->lockObj(dataHandle,
+ 0,
+ action,
+ type,
+ (command == SQLCOM_LOCK_TABLES ? QMY_NO : QMY_YES));
+
+ }
+
+ // Cache this away so we don't have to access it on each row operation
+ cachedZeroDateOption = (enum_ZeroDate)THDVAR(thd, compat_opt_allow_zero_date_vals);
+
+ DBUG_RETURN(rc);
+}
+
+
+THR_LOCK_DATA **ha_ibmdb2i::store_lock(THD *thd,
+ THR_LOCK_DATA **to,
+ enum thr_lock_type lock_type)
+{
+ if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
+ {
+ if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
+ lock_type <= TL_WRITE) && !(thd->in_lock_tables && thd_sql_command(thd) == SQLCOM_LOCK_TABLES))
+ lock_type= TL_WRITE_ALLOW_WRITE;
+ lock.type=lock_type;
+ }
+ *to++= &lock;
+ return to;
+}
+
+
+int ha_ibmdb2i::delete_table(const char *name)
+{
+ DBUG_ENTER("ha_ibmdb2i::delete_table");
+ THD* thd = ha_thd();
+ db2i_ileBridge* bridge = db2i_ileBridge::getBridgeForThread(thd);
+
+ char db2Name[MAX_DB2_QUALIFIEDNAME_LENGTH];
+ db2i_table::getDB2QualifiedNameFromPath(name, db2Name);
+
+ String query(128);
+ query.append(STRING_WITH_LEN(" DROP TABLE "));
+ query.append(db2Name);
+
+ if (thd_sql_command(thd) == SQLCOM_DROP_TABLE &&
+ thd->lex->drop_mode == DROP_RESTRICT)
+ query.append(STRING_WITH_LEN(" RESTRICT "));
+ DBUG_PRINT("ha_ibmdb2i::delete_table", ("Sent to DB2: %s",query.c_ptr()));
+
+ SqlStatementStream sqlStream(query);
+
+ db2i_table::getDB2LibNameFromPath(name, db2Name);
+ bool isTemporary = (strcmp(db2Name, DB2I_TEMP_TABLE_SCHEMA) == 0 ? TRUE : FALSE);
+
+ int rc = bridge->execSQL(sqlStream.getPtrToData(),
+ sqlStream.getStatementCount(),
+ (isTemporary ? QMY_NONE : getCommitLevel(thd)),
+ FALSE,
+ FALSE,
+ isTemporary);
+
+ if (rc == HA_ERR_NO_SUCH_TABLE)
+ {
+ warning(thd, DB2I_ERR_TABLE_NOT_FOUND, name);
+ rc = 0;
+ }
+
+ if (rc == 0)
+ {
+ db2i_table::deleteAssocFiles(name);
+ }
+
+ FILE_HANDLE savedHandle = bridge->findAndRemovePreservedHandle(name, &share);
+ while (savedHandle)
+ {
+ bridge->deallocateFile(savedHandle, TRUE);
+ DBUG_ASSERT(share);
+ if (free_share(share))
+ share = NULL;
+ savedHandle = bridge->findAndRemovePreservedHandle(name, &share);
+ }
+
+ my_errno = rc;
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::rename_table(const char * from, const char * to)
+{
+ DBUG_ENTER("ha_ibmdb2i::rename_table ");
+
+ char db2FromFileName[MAX_DB2_FILENAME_LENGTH + 1];
+ char db2ToFileName[MAX_DB2_FILENAME_LENGTH+1];
+ char db2FromLibName[MAX_DB2_SCHEMANAME_LENGTH+1];
+ char db2ToLibName[MAX_DB2_SCHEMANAME_LENGTH+1];
+
+ db2i_table::getDB2LibNameFromPath(from, db2FromLibName);
+ db2i_table::getDB2LibNameFromPath(to, db2ToLibName);
+
+ if (strcmp(db2FromLibName, db2ToLibName) != 0 )
+ {
+ getErrTxt(DB2I_ERR_RENAME_MOVE,from,to);
+ DBUG_RETURN(DB2I_ERR_RENAME_MOVE);
+ }
+
+ db2i_table::getDB2FileNameFromPath(from, db2FromFileName, db2i_table::ASCII_NATIVE);
+ db2i_table::getDB2FileNameFromPath(to, db2ToFileName);
+
+ char escapedFromFileName[2 * MAX_DB2_FILENAME_LENGTH + 1];
+
+ uint o = 0;
+ uint i = 1;
+ do
+ {
+ escapedFromFileName[o++] = db2FromFileName[i];
+ if (db2FromFileName[i] == '+')
+ escapedFromFileName[o++] = '+';
+ } while (db2FromFileName[++i]);
+ escapedFromFileName[o-1] = 0;
+
+
+ int rc = 0;
+
+ char queryBuffer[sizeof(db2FromLibName) + 2 * sizeof(db2FromFileName) + 256];
+ SafeString selectQuery(queryBuffer, sizeof(queryBuffer));
+ selectQuery.strncat(STRING_WITH_LEN("SELECT CAST(INDEX_NAME AS VARCHAR(128) CCSID 1208) FROM QSYS2.SYSINDEXES WHERE INDEX_NAME LIKE '%+_+_+_%"));
+ selectQuery.strcat(escapedFromFileName);
+ selectQuery.strncat(STRING_WITH_LEN("' ESCAPE '+' AND TABLE_NAME='"));
+ selectQuery.strncat(db2FromFileName+1, strlen(db2FromFileName)-2);
+ selectQuery.strncat(STRING_WITH_LEN("' AND TABLE_SCHEMA='"));
+ selectQuery.strncat(db2FromLibName+1, strlen(db2FromLibName)-2);
+ selectQuery.strcat('\'');
+ DBUG_ASSERT(!selectQuery.overflowed());
+
+ SqlStatementStream indexQuery(selectQuery.ptr());
+
+ FILE_HANDLE queryFile = 0;
+ uint32 resultRowLen;
+
+ initBridge();
+ rc = bridge()->prepOpen(indexQuery.getPtrToData(),
+ &queryFile,
+ &resultRowLen);
+
+ if (unlikely(rc))
+ DBUG_RETURN(rc);
+
+ IOReadBuffer rowBuffer(1, resultRowLen);
+
+ int tableNameLen = strlen(db2FromFileName) - 2;
+
+ SqlStatementStream renameQuery(64);
+ String query;
+ while (rc == 0)
+ {
+ query.length(0);
+
+ rc = bridge()->read(queryFile,
+ rowBuffer.ptr(),
+ QMY_READ_ONLY,
+ QMY_NONE,
+ QMY_NEXT);
+
+ if (!rc)
+ {
+ const char* rowData = rowBuffer.getRowN(0);
+ char indexFileName[MAX_DB2_FILENAME_LENGTH];
+ memset(indexFileName, 0, sizeof(indexFileName));
+
+ uint16 fileNameLen = *(uint16*)(rowData);
+ strncpy(indexFileName, rowData + sizeof(uint16), fileNameLen);
+
+ int bytesToRetain = fileNameLen - tableNameLen;
+ if (bytesToRetain <= 0)
+ /* We can't handle index names in which the MySQL index name and
+ the table name together are longer than the max index name. */
+ {
+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
+ DBUG_RETURN(DB2I_ERR_INVALID_NAME);
+ }
+ char indexName[MAX_DB2_FILENAME_LENGTH];
+ memset(indexName, 0, sizeof(indexName));
+
+ strncpy(indexName,
+ indexFileName,
+ bytesToRetain);
+
+ char db2IndexName[MAX_DB2_FILENAME_LENGTH+1];
+
+ convertMySQLNameToDB2Name(indexFileName, db2IndexName, sizeof(db2IndexName));
+
+ query.append(STRING_WITH_LEN("RENAME INDEX "));
+ query.append(db2FromLibName);
+ query.append('.');
+ query.append(db2IndexName);
+ query.append(STRING_WITH_LEN(" TO "));
+ if (db2i_table::appendQualifiedIndexFileName(indexName, db2ToFileName, query, db2i_table::ASCII_SQL, typeNone) == -1)
+ {
+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
+ DBUG_RETURN(DB2I_ERR_INVALID_NAME );
+ }
+ renameQuery.addStatement(query);
+ DBUG_PRINT("ha_ibmdb2i::rename_table", ("Sent to DB2: %s",query.c_ptr_safe()));
+ }
+ }
+
+
+ if (queryFile)
+ bridge()->deallocateFile(queryFile);
+
+ if (rc != HA_ERR_END_OF_FILE)
+ DBUG_RETURN(rc);
+
+ char db2Name[MAX_DB2_QUALIFIEDNAME_LENGTH];
+
+ /* Rename the table */
+ query.length(0);
+ query.append(STRING_WITH_LEN(" RENAME TABLE "));
+ db2i_table::getDB2QualifiedNameFromPath(from, db2Name);
+ query.append(db2Name);
+ query.append(STRING_WITH_LEN(" TO "));
+ query.append(db2ToFileName);
+ DBUG_PRINT("ha_ibmdb2i::rename_table", ("Sent to DB2: %s",query.c_ptr_safe()));
+ renameQuery.addStatement(query);
+ rc = bridge()->execSQL(renameQuery.getPtrToData(),
+ renameQuery.getStatementCount(),
+ getCommitLevel());
+
+ if (!rc)
+ db2i_table::renameAssocFiles(from, to);
+
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::create(const char *name, TABLE *table_arg,
+ HA_CREATE_INFO *create_info)
+{
+ DBUG_ENTER("ha_ibmdb2i::create");
+
+ int rc;
+ char fileSortSequence[11] = "*HEX";
+ char fileSortSequenceLibrary[11] = "";
+ char fileSortSequenceType = ' ';
+ char libName[MAX_DB2_SCHEMANAME_LENGTH+1];
+ char fileName[MAX_DB2_FILENAME_LENGTH+1];
+ char colName[MAX_DB2_COLNAME_LENGTH+1];
+ bool isTemporary;
+ ulong auto_inc_value;
+
+ db2i_table::getDB2LibNameFromPath(name, libName);
+ db2i_table::getDB2FileNameFromPath(name, fileName);
+
+ if (osVersion.v < 6)
+ {
+ if (strlen(libName) >
+ MAX_DB2_V5R4_LIBNAME_LENGTH + (isOrdinaryIdentifier(libName) ? 2 : 0))
+ {
+ getErrTxt(DB2I_ERR_TOO_LONG_SCHEMA,libName, MAX_DB2_V5R4_LIBNAME_LENGTH);
+ DBUG_RETURN(DB2I_ERR_TOO_LONG_SCHEMA);
+ }
+ }
+ else if (strlen(libName) > MAX_DB2_V6R1_LIBNAME_LENGTH)
+ {
+ getErrTxt(DB2I_ERR_TOO_LONG_SCHEMA,libName, MAX_DB2_V6R1_LIBNAME_LENGTH);
+ DBUG_RETURN(DB2I_ERR_TOO_LONG_SCHEMA);
+ }
+
+ String query(256);
+
+ if (strcmp(libName, DB2I_TEMP_TABLE_SCHEMA))
+ {
+ query.append(STRING_WITH_LEN("CREATE TABLE "));
+ query.append(libName);
+ query.append('.');
+ query.append(fileName);
+ isTemporary = FALSE;
+ }
+ else
+ {
+ query.append(STRING_WITH_LEN("DECLARE GLOBAL TEMPORARY TABLE "));
+ query.append(fileName);
+ isTemporary = TRUE;
+ }
+ query.append(STRING_WITH_LEN(" ("));
+
+ THD* thd = ha_thd();
+ enum_TimeFormat timeFormat = (enum_TimeFormat)(THDVAR(thd, compat_opt_time_as_duration));
+ enum_YearFormat yearFormat = (enum_YearFormat)(THDVAR(thd, compat_opt_year_as_int));
+ enum_BlobMapping blobMapping = (enum_BlobMapping)(THDVAR(thd, compat_opt_blob_cols));
+ enum_ZeroDate zeroDate = (enum_ZeroDate)(THDVAR(thd, compat_opt_allow_zero_date_vals));
+ bool propagateDefaults = THDVAR(thd, propagate_default_col_vals);
+
+ Field **field;
+ for (field= table_arg->field; *field; field++)
+ {
+ if ( field != table_arg->field ) // Not the first one
+ query.append(STRING_WITH_LEN(" , "));
+
+ if (!convertMySQLNameToDB2Name((*field)->field_name, colName, sizeof(colName)))
+ {
+ getErrTxt(DB2I_ERR_INVALID_NAME,"field",(*field)->field_name);
+ DBUG_RETURN(DB2I_ERR_INVALID_NAME );
+ }
+
+ query.append(colName);
+ query.append(' ');
+
+ if (rc = getFieldTypeMapping(*field,
+ query,
+ timeFormat,
+ blobMapping,
+ zeroDate,
+ propagateDefaults,
+ yearFormat))
+ DBUG_RETURN(rc);
+
+ if ( (*field)->flags & NOT_NULL_FLAG )
+ {
+ query.append(STRING_WITH_LEN(" NOT NULL "));
+ }
+ if ( (*field)->flags & AUTO_INCREMENT_FLAG )
+ {
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (table_arg->part_info)
+ {
+ getErrTxt(DB2I_ERR_PART_AUTOINC);
+ DBUG_RETURN(DB2I_ERR_PART_AUTOINC);
+ }
+#endif
+ query.append(STRING_WITH_LEN(" GENERATED BY DEFAULT AS IDENTITY ") );
+ if (create_info->auto_increment_value != 0)
+ {
+ /* Query was ALTER TABLE...AUTO_INCREMENT = x; or
+ CREATE TABLE ...AUTO_INCREMENT = x; Set the starting
+ value for the auto_increment column. */
+ char stringValue[22];
+ CHARSET_INFO *cs= &my_charset_bin;
+ uint len = (uint)(cs->cset->longlong10_to_str)(cs,stringValue,sizeof(stringValue), 10, create_info->auto_increment_value);
+ stringValue[len] = 0;
+ query.append(STRING_WITH_LEN(" (START WITH "));
+ query.append(stringValue);
+
+ uint64 maxValue=maxValueForField(*field);
+
+ if (maxValue)
+ {
+ len = (uint)(cs->cset->longlong10_to_str)(cs,stringValue,sizeof(stringValue), 10, maxValue);
+ stringValue[len] = 0;
+ query.append(STRING_WITH_LEN(" MAXVALUE "));
+ query.append(stringValue);
+ }
+
+ query.append(STRING_WITH_LEN(") "));
+ }
+
+ }
+ }
+
+ bool primaryHasStringField = false;
+
+ if (table_arg->s->primary_key != MAX_KEY && !isTemporary)
+ {
+ KEY& curKey = table_arg->key_info[table_arg->s->primary_key];
+ query.append(STRING_WITH_LEN(", PRIMARY KEY( "));
+ for (int j = 0; j < curKey.key_parts; ++j)
+ {
+ if (j != 0)
+ {
+ query.append( STRING_WITH_LEN(" , ") );
+ }
+ Field* field = curKey.key_part[j].field;
+ convertMySQLNameToDB2Name(field->field_name, colName, sizeof(colName));
+ query.append(colName);
+ enum_field_types type = field->real_type();
+ if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_BLOB ||
+ type == MYSQL_TYPE_STRING)
+ {
+ rc = updateAssociatedSortSequence(field->charset(),
+ &fileSortSequenceType,
+ fileSortSequence,
+ fileSortSequenceLibrary);
+ if (rc) DBUG_RETURN (rc);
+ primaryHasStringField = true;
+ }
+ }
+ query.append(STRING_WITH_LEN(" ) "));
+ }
+
+ rc = buildDB2ConstraintString(thd->lex,
+ query,
+ name,
+ table_arg->field,
+ &fileSortSequenceType,
+ fileSortSequence,
+ fileSortSequenceLibrary);
+ if (rc) DBUG_RETURN (rc);
+
+ query.append(STRING_WITH_LEN(" ) "));
+
+ if (isTemporary)
+ query.append(STRING_WITH_LEN(" ON COMMIT PRESERVE ROWS "));
+
+ DBUG_PRINT("ha_ibmdb2i::create", ("Sent to DB2: %s",query.c_ptr()));
+ SqlStatementStream sqlStream(query.length());
+ sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary);
+
+ for (uint i = 0; i < table_arg->s->keys; ++i)
+ {
+ if (i != table_arg->s->primary_key || isTemporary)
+ {
+ rc = buildCreateIndexStatement(sqlStream,
+ table_arg->key_info[i],
+ false,
+ libName,
+ fileName);
+ if (rc) DBUG_RETURN (rc);
+ }
+ }
+
+ bool noCommit = isTemporary || ((!autoCommitIsOn(thd)) && (thd_sql_command(thd) == SQLCOM_ALTER_TABLE));
+
+ initBridge();
+
+// if (THDVAR(thd, discovery_mode) == 1)
+// bridge()->expectErrors(QMY_ERR_TABLE_EXISTS);
+
+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
+ sqlStream.getStatementCount(),
+ (isTemporary ? QMY_NONE : getCommitLevel(thd)),
+ TRUE,
+ FALSE,
+ noCommit );
+
+ if (unlikely(rc == QMY_ERR_MSGID) &&
+ memcmp(bridge()->getErrorMsgID(), DB2I_SQL0350, 7) == 0)
+ {
+ my_error(ER_BLOB_USED_AS_KEY, MYF(0), "*unknown*");
+ rc = ER_BLOB_USED_AS_KEY;
+ }
+/* else if (unlikely(rc == QMY_ERR_TABLE_EXISTS) &&
+ THDVAR(thd, discovery_mode) == 1)
+ {
+ db2i_table* temp = new db2i_table(table_arg->s, name);
+ int32 rc = temp->fastInitForCreate(name);
+ delete temp;
+
+ if (!rc)
+ warning(thd, DB2I_ERR_WARN_CREATE_DISCOVER);
+
+ DBUG_RETURN(rc);
+ }
+*/
+
+ if (!rc && !isTemporary)
+ {
+ db2i_table* temp = new db2i_table(table_arg->s, name);
+ rc = temp->fastInitForCreate(name);
+ delete temp;
+ if (rc)
+ delete_table(name);
+ }
+
+ DBUG_RETURN(rc);
+}
+
+
+/**
+ @brief
+ Add an index on-line to a table. This method is called on behalf of
+ a CREATE INDEX or ALTER TABLE statement.
+ It is implemented via a composed DDL statement passed to DB2.
+*/
+int ha_ibmdb2i::add_index(TABLE *table_arg,
+ KEY *key_info,
+ uint num_of_keys)
+{
+ DBUG_ENTER("ha_ibmdb2i::add_index");
+
+ int rc;
+ SqlStatementStream sqlStream(256);
+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
+
+ quiesceAllFileHandles();
+
+ uint primaryKey = MAX_KEY;
+ if (table_arg->s->primary_key >= MAX_KEY && !db2Table->isTemporary())
+ {
+ for (int i = 0; i < num_of_keys; ++i)
+ {
+ if (strcmp(key_info[i].name, "PRIMARY") == 0)
+ {
+ primaryKey = i;
+ break;
+ }
+ else if (primaryKey == MAX_KEY &&
+ key_info[i].flags & HA_NOSAME)
+ {
+ primaryKey = i;
+ for (int j=0 ; j < key_info[i].key_parts ;j++)
+ {
+ uint fieldnr= key_info[i].key_part[j].fieldnr;
+ if (table_arg->s->field[fieldnr]->null_ptr ||
+ table_arg->s->field[fieldnr]->key_length() !=
+ key_info[i].key_part[j].length)
+ {
+ primaryKey = MAX_KEY;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+
+ for (int i = 0; i < num_of_keys; ++i)
+ {
+ KEY& curKey= key_info[i];
+ rc = buildCreateIndexStatement(sqlStream,
+ curKey,
+ (i == primaryKey),
+ libName,
+ fileName);
+ if (rc) DBUG_RETURN (rc);
+ }
+
+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
+ sqlStream.getStatementCount(),
+ getCommitLevel(),
+ FALSE,
+ FALSE,
+ FALSE,
+ dataHandle);
+
+ /* Handle the case where a unique index is being created but an error occurs
+ because the file contains duplicate key values. */
+ if (rc == ER_DUP_ENTRY)
+ print_keydup_error(MAX_KEY,ER(ER_DUP_ENTRY_WITH_KEY_NAME));
+
+ DBUG_RETURN(rc);
+}
+
+/**
+ @brief
+ Drop an index on-line from a table. This method is called on behalf of
+ a DROP INDEX or ALTER TABLE statement.
+ It is implemented via a composed DDL statement passed to DB2.
+*/
+int ha_ibmdb2i::prepare_drop_index(TABLE *table_arg,
+ uint *key_num, uint num_of_keys)
+{
+ DBUG_ENTER("ha_ibmdb2i::prepare_drop_index");
+ int rc;
+ int i = 0;
+ String query(64);
+ SqlStatementStream sqlStream(64 * num_of_keys);
+ SqlStatementStream shadowStream(64 * num_of_keys);
+
+ quiesceAllFileHandles();
+
+ const char* libName = db2Table->getDB2LibName(db2i_table::ASCII_SQL);
+ const char* fileName = db2Table->getDB2TableName(db2i_table::ASCII_SQL);
+
+ while (i < num_of_keys)
+ {
+ query.length(0);
+ DBUG_PRINT("info", ("ha_ibmdb2i::prepare_drop_index %u", key_num[i]));
+ KEY& curKey= table_arg->key_info[key_num[i]];
+ if (key_num[i] == table->s->primary_key && !db2Table->isTemporary())
+ {
+ query.append(STRING_WITH_LEN("ALTER TABLE "));
+ query.append(libName);
+ query.append(STRING_WITH_LEN("."));
+ query.append(fileName);
+ query.append(STRING_WITH_LEN(" DROP PRIMARY KEY"));
+ }
+ else
+ {
+ query.append(STRING_WITH_LEN("DROP INDEX "));
+ query.append(libName);
+ query.append(STRING_WITH_LEN("."));
+ db2i_table::appendQualifiedIndexFileName(curKey.name, fileName, query);
+ }
+ DBUG_PRINT("ha_ibmdb2i::prepare_drop_index", ("Sent to DB2: %s",query.c_ptr_safe()));
+ sqlStream.addStatement(query);
+
+ query.length(0);
+ query.append(STRING_WITH_LEN("DROP INDEX "));
+ query.append(libName);
+ query.append(STRING_WITH_LEN("."));
+ db2i_table::appendQualifiedIndexFileName(curKey.name, fileName, query, db2i_table::ASCII_SQL, typeHex);
+
+ DBUG_PRINT("ha_ibmdb2i::prepare_drop_index", ("Sent to DB2: %s",query.c_ptr_safe()));
+ shadowStream.addStatement(query);
+
+ ++i;
+ }
+
+ rc = bridge()->execSQL(sqlStream.getPtrToData(),
+ sqlStream.getStatementCount(),
+ getCommitLevel(),
+ FALSE,
+ FALSE,
+ FALSE,
+ dataHandle);
+
+ if (rc == 0)
+ bridge()->execSQL(shadowStream.getPtrToData(),
+ shadowStream.getStatementCount(),
+ getCommitLevel());
+
+ DBUG_RETURN(rc);
+}
+
+
+void
+ha_ibmdb2i::unlock_row()
+{
+ DBUG_ENTER("ha_ibmdb2i::unlock_row");
+ DBUG_VOID_RETURN;
+}
+
+int
+ha_ibmdb2i::index_end()
+{
+ DBUG_ENTER("ha_ibmdb2i::index_end");
+ warnIfInvalidData();
+ last_index_init_rc = 0;
+ if (likely(activeReadBuf))
+ activeReadBuf->endRead();
+ if (likely(!last_index_init_rc))
+ releaseIndexFile(active_index);
+ active_index= MAX_KEY;
+ DBUG_RETURN (0);
+}
+
+int ha_ibmdb2i::doCommit(handlerton *hton, THD *thd, bool all)
+{
+ if (!THDVAR(thd, transaction_unsafe))
+ {
+ if (all || autoCommitIsOn(thd))
+ {
+ DBUG_PRINT("ha_ibmdb2i::doCommit",("Committing all"));
+ return (db2i_ileBridge::getBridgeForThread(thd)->commitmentControl(QMY_COMMIT));
+ }
+ else
+ {
+ DBUG_PRINT("ha_ibmdb2i::doCommit",("Committing stmt"));
+ return (db2i_ileBridge::getBridgeForThread(thd)->commitStmtTx());
+ }
+ }
+
+ return (0);
+}
+
+
+int ha_ibmdb2i::doRollback(handlerton *hton, THD *thd, bool all)
+{
+ if (!THDVAR(thd,transaction_unsafe))
+ {
+ if (all || autoCommitIsOn(thd))
+ {
+ DBUG_PRINT("ha_ibmdb2i::doRollback",("Rolling back all"));
+ return ( db2i_ileBridge::getBridgeForThread(thd)->commitmentControl(QMY_ROLLBACK));
+ }
+ else
+ {
+ DBUG_PRINT("ha_ibmdb2i::doRollback",("Rolling back stmt"));
+ return (db2i_ileBridge::getBridgeForThread(thd)->rollbackStmtTx());
+ }
+ }
+ return (0);
+}
+
+
+void ha_ibmdb2i::start_bulk_insert(ha_rows rows)
+{
+ DBUG_ENTER("ha_ibmdb2i::start_bulk_insert");
+ DBUG_PRINT("ha_ibmdb2i::start_bulk_insert",("Rows hinted %d", rows));
+ int rc;
+ THD* thd = ha_thd();
+ int command = thd_sql_command(thd);
+
+ if (db2Table->hasBlobs() ||
+ (command == SQLCOM_REPLACE || command == SQLCOM_REPLACE_SELECT))
+ rows = 1;
+ else if (rows == 0)
+ rows = DEFAULT_MAX_ROWS_TO_BUFFER; // Shoot the moon
+
+ // If we're doing a multi-row insert, binlogging is active, and the table has an
+ // auto_increment column, then we'll attempt to lock the file while we perform a 'fast path' blocked
+ // insert. If we can't get the lock, then we'll do a row-by-row 'slow path' insert instead. The reason is
+ // because the MI generates the auto_increment (identity value), and if we can't lock the file,
+ // then we can't predetermine what that value will be for insertion into the MySQL write buffer.
+
+ if ((rows > 1) && // Multi-row insert
+ (thd->options & OPTION_BIN_LOG) && // Binlogging is on
+ (table->found_next_number_field)) // Table has an auto_increment column
+ {
+ if (!dataHandle)
+ rc = db2Table->dataFile()->allocateNewInstance(&dataHandle, curConnection);
+
+ rc = bridge()->lockObj(dataHandle, 1, QMY_LOCK, QMY_LEAR, QMY_YES);
+ if (rc==0) // Got the lock
+ {
+ autoIncLockAcquired = TRUE;
+ got_auto_inc_values = FALSE;
+ }
+ else // Didn't get the lock
+ rows = 1; // No problem, but don't block inserts
+ }
+
+ if (activeHandle == 0)
+ {
+ last_start_bulk_insert_rc = useDataFile();
+ if (last_start_bulk_insert_rc == 0)
+ last_start_bulk_insert_rc = prepWriteBuffer(rows, db2Table->dataFile());
+ }
+
+ if (last_start_bulk_insert_rc == 0)
+ outstanding_start_bulk_insert = true;
+ else
+ {
+ if (autoIncLockAcquired == TRUE)
+ {
+ bridge()->lockObj(dataHandle, 0, QMY_UNLOCK, QMY_LEAR, QMY_YES);
+ autoIncLockAcquired = FALSE;
+ }
+ }
+
+ DBUG_VOID_RETURN;
+}
+
+
+int ha_ibmdb2i::end_bulk_insert()
+{
+ DBUG_ENTER("ha_ibmdb2i::end_bulk_insert");
+ int rc = 0;
+
+ if (outstanding_start_bulk_insert)
+ {
+ rc = finishBulkInsert();
+ }
+
+ my_errno = rc;
+
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::prepReadBuffer(ha_rows rowsToRead, const db2i_file* file, char intent)
+{
+ DBUG_ENTER("ha_ibmdb2i::prepReadBuffer");
+ DBUG_ASSERT(rowsToRead > 0);
+
+ THD* thd = ha_thd();
+ char cmtLvl = getCommitLevel(thd);
+
+ const db2i_file::RowFormat* format;
+ int rc = file->obtainRowFormat(activeHandle, intent, cmtLvl, &format);
+
+ if (unlikely(rc)) DBUG_RETURN(rc);
+
+ if (lobFieldsRequested())
+ {
+ forceSingleRowRead = true;
+ rowsToRead = 1;
+ }
+
+ rowsToRead = min(stats.records+1,min(rowsToRead, DEFAULT_MAX_ROWS_TO_BUFFER));
+
+ uint bufSize = min((format->readRowLen * rowsToRead), THDVAR(thd, max_read_buffer_size));
+ multiRowReadBuf.allocBuf(format->readRowLen, format->readRowNullOffset, bufSize);
+ activeReadBuf = &multiRowReadBuf;
+
+ if (db2Table->hasBlobs())
+ {
+ if (!blobReadBuffers)
+ blobReadBuffers = new BlobCollection(db2Table, THDVAR(thd, lob_alloc_size));
+ rc = prepareReadBufferForLobs();
+ if (rc) DBUG_RETURN(rc);
+ }
+
+// if (accessIntent == QMY_UPDATABLE &&
+// thd_tx_isolation(thd) == ISO_REPEATABLE_READ &&
+// !THDVAR(thd, transaction_unsafe))
+// activeReadBuf->update(QMY_READ_ONLY, &releaseRowNeeded, QMY_REPEATABLE_READ);
+// else
+ activeReadBuf->update(intent, &releaseRowNeeded, cmtLvl);
+
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::prepWriteBuffer(ha_rows rowsToWrite, const db2i_file* file)
+{
+ DBUG_ENTER("ha_ibmdb2i::prepWriteBuffer");
+ DBUG_ASSERT(accessIntent == QMY_UPDATABLE && rowsToWrite > 0);
+
+ const db2i_file::RowFormat* format;
+ int rc = file->obtainRowFormat(activeHandle,
+ QMY_UPDATABLE,
+ getCommitLevel(ha_thd()),
+ &format);
+
+ if (unlikely(rc)) DBUG_RETURN(rc);
+
+ rowsToWrite = min(rowsToWrite, DEFAULT_MAX_ROWS_TO_BUFFER);
+
+ uint bufSize = min((format->writeRowLen * rowsToWrite), THDVAR(ha_thd(), max_write_buffer_size));
+ multiRowWriteBuf.allocBuf(format->writeRowLen, format->writeRowNullOffset, bufSize);
+ activeWriteBuf = &multiRowWriteBuf;
+
+ if (!blobWriteBuffers && db2Table->hasBlobs())
+ {
+ blobWriteBuffers = new ValidatedPointer<char>[db2Table->getBlobCount()];
+ }
+ DBUG_RETURN(rc);
+}
+
+
+int ha_ibmdb2i::flushWrite(FILE_HANDLE fileHandle, uchar* buf )
+{
+ DBUG_ENTER("ha_ibmdb2i::flushWrite");
+ int rc;
+ int64 generatedIdValue = 0;
+ bool IdValueWasGenerated = FALSE;
+ char* lastDupKeyNamePtr = NULL;
+ uint32 lastDupKeyNameLen = 0;
+ int loopCnt = 0;
+ bool retry_dup = FALSE;
+
+ while (loopCnt == 0 || retry_dup == TRUE)
+ {
+ rc = bridge()->writeRows(fileHandle,
+ activeWriteBuf->ptr(),
+ getCommitLevel(),
+ &generatedIdValue,
+ &IdValueWasGenerated,
+ &lastDupKeyRRN,
+ &lastDupKeyNamePtr,
+ &lastDupKeyNameLen,
+ &incrementByValue);
+ loopCnt++;
+ retry_dup = FALSE;
+ invalidateCachedStats();
+ if (lastDupKeyNameLen)
+ {
+ rrnAssocHandle = fileHandle;
+
+ int command = thd_sql_command(ha_thd());
+
+ if (command == SQLCOM_REPLACE ||
+ command == SQLCOM_REPLACE_SELECT)
+ lastDupKeyID = 0;
+ else
+ {
+ lastDupKeyID = getKeyFromName(lastDupKeyNamePtr, lastDupKeyNameLen);
+
+ if (likely(lastDupKeyID != MAX_KEY))
+ {
+ uint16 failedRow = activeWriteBuf->rowsWritten()+1;
+
+ if (buf && (failedRow != activeWriteBuf->rowCount()))
+ {
+ const char* badRow = activeWriteBuf->getRowN(failedRow-1);
+ bool savedReadAllColumns = readAllColumns;
+ readAllColumns = true;
+ mungeDB2row(buf,
+ badRow,
+ badRow + activeWriteBuf->getRowNullOffset(),
+ true);
+ readAllColumns = savedReadAllColumns;
+
+ if (table->found_next_number_field)
+ {
+ table->next_number_field->store(next_identity_value - (incrementByValue * (activeWriteBuf->rowCount() - (failedRow - 1))));
+ }
+ }
+
+ if (default_identity_value && // Table has ID colm and generating a value
+ (!autoIncLockAcquired || !got_auto_inc_values) &&
+ // Writing first or only row in block
+ loopCnt == 1 && // Didn't already retry
+ lastDupKeyID == table->s->next_number_index) // Autoinc column is in failed index
+ {
+ if (alterStartWith() == 0) // Reset next Identity value to max+1
+ retry_dup = TRUE; // Rtry the write operation
+ }
+ }
+ else
+ {
+ char unknownIndex[MAX_DB2_FILENAME_LENGTH+1];
+ convFromEbcdic(lastDupKeyNamePtr, unknownIndex, min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH));
+ unknownIndex[min(lastDupKeyNameLen, MAX_DB2_FILENAME_LENGTH)] = 0;
+ getErrTxt(DB2I_ERR_UNKNOWN_IDX, unknownIndex);
+ }
+ }
+ }
+ }
+
+ if ((rc == 0 || rc == HA_ERR_FOUND_DUPP_KEY)
+ && default_identity_value && IdValueWasGenerated &&
+ (!autoIncLockAcquired || !got_auto_inc_values))
+ {
+ /* Save the generated identity value for the MySQL last_insert_id() function. */
+ insert_id_for_cur_row = generatedIdValue;
+
+ /* Store the value into MySQL's buf for row-based replication
+ or for an 'on duplicate key update' clause. */
+ table->next_number_field->store((longlong) generatedIdValue, TRUE);
+ if (autoIncLockAcquired)
+ {
+ got_auto_inc_values = TRUE;
+ next_identity_value = generatedIdValue + incrementByValue;
+ }
+ }
+ else
+ {
+ if (!autoIncLockAcquired) // Don't overlay value for first row of a block
+ insert_id_for_cur_row = 0;
+ }
+
+
+ activeWriteBuf->resetAfterWrite();
+ DBUG_RETURN(rc);
+}
+
+int ha_ibmdb2i::alterStartWith()
+{
+ DBUG_ENTER("ha_ibmdb2i::alterStartWith");
+ int rc = 0;
+ ulonglong nextIdVal;
+ if (!dataHandle)
+ rc = db2Table->dataFile()->allocateNewInstance(&dataHandle, curConnection);
+ if (!rc) {rc = bridge()->lockObj(dataHandle, 1, QMY_LOCK, QMY_LENR, QMY_YES);}
+ if (!rc)
+ {
+ rc = getNextIdVal(&nextIdVal);
+ if (!rc) {rc = reset_auto_increment(nextIdVal);}
+ bridge()->lockObj(dataHandle, 0, QMY_UNLOCK, QMY_LENR, QMY_YES);
+ }
+ DBUG_RETURN(rc);
+}
+
+bool ha_ibmdb2i::lobFieldsRequested()
+{
+ if (!db2Table->hasBlobs())
+ {
+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("No LOBs"));
+ return (false);
+ }
+
+ if (readAllColumns)
+ {
+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("All cols requested"));
+ return (true);
+ }
+
+ for (int i = 0; i < db2Table->getBlobCount(); ++i)
+ {
+ if (bitmap_is_set(table->read_set, db2Table->blobFields[i]))
+ {
+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("LOB requested"));
+ return (true);
+ }
+ }
+
+ DBUG_PRINT("ha_ibmdb2i::lobFieldsRequested",("No LOBs requested"));
+ return (false);
+}
+
+
+int ha_ibmdb2i::prepareReadBufferForLobs()
+{
+ DBUG_ENTER("ha_ibmdb2i::prepareReadBufferForLobs");
+ DBUG_ASSERT(db2Table->hasBlobs());
+
+ uint32 activeLobFields = 0;
+ DB2LobField* lobField;
+ uint16 blobCount = db2Table->getBlobCount();
+
+ char* readBuf = activeReadBuf->getRowN(0);
+
+ for (int i = 0; i < blobCount; ++i)
+ {
+ int fieldID = db2Table->blobFields[i];
+ DB2Field& db2Field = db2Table->db2Field(fieldID);
+ lobField = db2Field.asBlobField(readBuf);
+ if (readAllColumns ||
+ bitmap_is_set(table->read_set, fieldID))
+ {
+ lobField->dataHandle = (ILEMemHandle)blobReadBuffers->getBufferPtr(fieldID);
+ activeLobFields++;
+ }
+ else
+ {
+ lobField->dataHandle = NULL;
+ }
+ }
+
+ if (activeLobFields == 0)
+ {
+ for (int i = 0; i < blobCount; ++i)
+ {
+ DB2Field& db2Field = db2Table->db2Field(db2Table->blobFields[i]);
+ uint16 offset = db2Field.getBufferOffset() + db2Field.calcBlobPad();
+
+ for (int r = 1; r < activeReadBuf->getRowCapacity(); ++r)
+ {
+ lobField = (DB2LobField*)(activeReadBuf->getRowN(r) + offset);
+ lobField->dataHandle = NULL;
+ }
+ }
+ }
+
+ activeReadBuf->setRowsToProcess((activeLobFields ? 1 : activeReadBuf->getRowCapacity()));
+ int rc = bridge()->objectOverride(activeHandle,
+ activeReadBuf->ptr(),
+ activeReadBuf->getRowLength());
+ DBUG_RETURN(rc);
+}
+
+
+uint32 ha_ibmdb2i::adjustLobBuffersForRead()
+{
+ DBUG_ENTER("ha_ibmdb2i::adjustLobBuffersForRead");
+
+ char* readBuf = activeReadBuf->getRowN(0);
+
+ for (int i = 0; i < db2Table->getBlobCount(); ++i)
+ {
+ DB2Field& db2Field = db2Table->db2Field(db2Table->blobFields[i]);
+ DB2LobField* lobField = db2Field.asBlobField(readBuf);
+ if (readAllColumns ||
+ bitmap_is_set(table->read_set, db2Table->blobFields[i]))
+ {
+ lobField->dataHandle = (ILEMemHandle)blobReadBuffers->reallocBuffer(db2Table->blobFields[i], lobField->length);
+
+ if (lobField->dataHandle == NULL)
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ else
+ {
+ lobField->dataHandle = 0;
+ }
+ }
+
+ int32 rc = bridge()->objectOverride(activeHandle,
+ activeReadBuf->ptr());
+ DBUG_RETURN(rc);
+}
+
+
+
+int ha_ibmdb2i::reset()
+{
+ DBUG_ENTER("ha_ibmdb2i::reset");
+
+ if (outstanding_start_bulk_insert)
+ {
+ finishBulkInsert();
+ }
+
+ if (activeHandle != 0)
+ {
+ releaseActiveHandle();
+ }
+
+ cleanupBuffers();
+
+ db2i_ileBridge::getBridgeForThread(ha_thd())->freeErrorStorage();
+
+ last_rnd_init_rc = last_index_init_rc = last_start_bulk_insert_rc = 0;
+
+ returnDupKeysImmediately = false;
+ onDupUpdate = false;
+ forceSingleRowRead = false;
+
+#ifndef DBUG_OFF
+ cachedBridge=NULL;
+#endif
+
+ DBUG_RETURN(0);
+}
+
+
+int32 ha_ibmdb2i::buildCreateIndexStatement(SqlStatementStream& sqlStream,
+ KEY& key,
+ bool isPrimary,
+ const char* db2LibName,
+ const char* db2FileName)
+{
+ DBUG_ENTER("ha_ibmdb2i::buildCreateIndexStatement");
+
+ char fileSortSequence[11] = "*HEX";
+ char fileSortSequenceLibrary[11] = "";
+ char fileSortSequenceType = ' ';
+ String query(256);
+ query.length(0);
+ int rc = 0;
+
+ if (isPrimary)
+ {
+ query.append(STRING_WITH_LEN("ALTER TABLE "));
+ query.append(db2LibName);
+ query.append('.');
+ query.append(db2FileName);
+ query.append(STRING_WITH_LEN(" ADD PRIMARY KEY "));
+ }
+ else
+ {
+ query.append(STRING_WITH_LEN("CREATE"));
+
+ if (key.flags & HA_NOSAME)
+ query.append(STRING_WITH_LEN(" UNIQUE WHERE NOT NULL"));
+
+ query.append(STRING_WITH_LEN(" INDEX "));
+
+ query.append(db2LibName);
+ query.append('.');
+ if (db2i_table::appendQualifiedIndexFileName(key.name, db2FileName, query))
+ {
+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
+ DBUG_RETURN(DB2I_ERR_INVALID_NAME );
+ }
+
+ query.append(STRING_WITH_LEN(" ON "));
+
+ query.append(db2LibName);
+ query.append('.');
+ query.append(db2FileName);
+ }
+
+ String fieldDefinition(128);
+ fieldDefinition.length(0);
+ fieldDefinition.append(STRING_WITH_LEN(" ( "));
+ for (int j = 0; j < key.key_parts; ++j)
+ {
+ char colName[MAX_DB2_COLNAME_LENGTH+1];
+ if (j != 0)
+ {
+ fieldDefinition.append(STRING_WITH_LEN(" , "));
+ }
+ Field* field = key.key_part[j].field;
+ convertMySQLNameToDB2Name(field->field_name, colName, sizeof(colName));
+ fieldDefinition.append(colName);
+ rc = updateAssociatedSortSequence(field->charset(),
+ &fileSortSequenceType,
+ fileSortSequence,
+ fileSortSequenceLibrary);
+ if (rc) DBUG_RETURN (rc);
+ }
+ fieldDefinition.append(STRING_WITH_LEN(" ) "));
+
+ query.append(fieldDefinition);
+
+ if ((THDVAR(ha_thd(), create_index_option)==1) &&
+ (fileSortSequenceType != 'B'))
+ {
+ String shadowQuery(256);
+ shadowQuery.length(0);
+
+ shadowQuery.append(STRING_WITH_LEN("CREATE INDEX "));
+
+ shadowQuery.append(db2LibName);
+ shadowQuery.append('.');
+ if (db2i_table::appendQualifiedIndexFileName(key.name, db2FileName, shadowQuery, db2i_table::ASCII_SQL, typeHex))
+ {
+ getErrTxt(DB2I_ERR_INVALID_NAME,"index","*generated*");
+ DBUG_RETURN(DB2I_ERR_INVALID_NAME );
+ }
+
+ shadowQuery.append(STRING_WITH_LEN(" ON "));
+
+ shadowQuery.append(db2LibName);
+ shadowQuery.append('.');
+ shadowQuery.append(db2FileName);
+ shadowQuery.append(fieldDefinition);
+ DBUG_PRINT("ha_ibmdb2i::buildCreateIndexStatement", ("Sent to DB2: %s",shadowQuery.c_ptr_safe()));
+ sqlStream.addStatement(shadowQuery,"*HEX","QSYS");
+ }
+
+ DBUG_PRINT("ha_ibmdb2i::buildCreateIndexStatement", ("Sent to DB2: %s",query.c_ptr_safe()));
+ sqlStream.addStatement(query,fileSortSequence,fileSortSequenceLibrary);
+
+ DBUG_RETURN(0);
+}
+
+
+void ha_ibmdb2i::doInitialRead(char orientation,
+ uint32 rowsToBuffer,
+ ILEMemHandle key,
+ int keyLength,
+ int keyParts)
+{
+ DBUG_ENTER("ha_ibmdb2i::doInitialRead");
+
+ if (forceSingleRowRead)
+ rowsToBuffer = 1;
+ else
+ rowsToBuffer = min(rowsToBuffer, activeReadBuf->getRowCapacity());
+
+ activeReadBuf->newReadRequest(activeHandle,
+ orientation,
+ rowsToBuffer,
+ THDVAR(ha_thd(), async_enabled),
+ key,
+ keyLength,
+ keyParts);
+ DBUG_VOID_RETURN;
+}
+
+
+int ha_ibmdb2i::start_stmt(THD *thd, thr_lock_type lock_type)
+{
+ DBUG_ENTER("ha_ibmdb2i::start_stmt");
+ initBridge(thd);
+ if (!THDVAR(thd, transaction_unsafe))
+ {
+ trans_register_ha(thd, FALSE, ibmdb2i_hton);
+
+ if (!autoCommitIsOn(thd))
+ {
+ bridge()->beginStmtTx();
+ }
+ }
+
+ DBUG_RETURN(0);
+}
+
+int32 ha_ibmdb2i::handleLOBReadOverflow()
+{
+ DBUG_ENTER("ha_ibmdb2i::handleLOBReadOverflow");
+ DBUG_ASSERT(db2Table->hasBlobs() && (activeReadBuf->getRowCapacity() == 1));
+
+ int32 rc = adjustLobBuffersForRead();
+
+ if (!rc)
+ {
+ activeReadBuf->rewind();
+ rc = bridge()->expectErrors(QMY_ERR_END_OF_BLOCK)
+ ->read(activeHandle,
+ activeReadBuf->ptr(),
+ accessIntent,
+ getCommitLevel(),
+ QMY_SAME);
+ releaseRowNeeded = TRUE;
+
+ }
+ DBUG_RETURN(rc);
+}
+
+
+int32 ha_ibmdb2i::finishBulkInsert()
+{
+ int32 rc = 0;
+
+ if (activeWriteBuf->rowCount() && activeHandle)
+ rc = flushWrite(activeHandle, table->record[0]);
+
+ if (activeHandle)
+ releaseActiveHandle();
+
+ if (autoIncLockAcquired == TRUE)
+ {
+ // We could check the return code on the unlock, but beware not
+ // to overlay the return code from the flushwrite or we will mask
+ // duplicate key errors..
+ bridge()->lockObj(dataHandle, 0, QMY_UNLOCK, QMY_LEAR, QMY_YES);
+ autoIncLockAcquired = FALSE;
+ }
+ outstanding_start_bulk_insert = false;
+ multiRowWriteBuf.freeBuf();
+ last_start_bulk_insert_rc = 0;
+
+ resetCharacterConversionBuffers();
+
+ return rc;
+}
+
+int ha_ibmdb2i::getKeyFromName(const char* name, size_t len)
+{
+ for (int i = 0; i < table_share->keys; ++i)
+ {
+ const char* indexName = db2Table->indexFile(i)->getDB2FileName();
+ if ((strncmp(name, indexName, len) == 0) &&
+ (strlen(indexName) == len))
+ {
+ return i;
+ }
+ }
+ return MAX_KEY;
+}
+
+/*
+Determine the number of I/O's it takes to read through the table.
+ */
+double ha_ibmdb2i::scan_time()
+ {
+ DBUG_ENTER("ha_ibmdb2i::scan_time");
+ DBUG_RETURN(ulonglong2double((stats.data_file_length)/IO_SIZE));
+ }
+
+
+/**
+ Estimate the number of I/O's it takes to read a set of ranges through
+ an index.
+
+ @param index
+ @param ranges
+ @param rows
+
+ @return The estimate number of I/Os
+*/
+
+double ha_ibmdb2i::read_time(uint index, uint ranges, ha_rows rows)
+{
+ DBUG_ENTER("ha_ibmdb2i::read_time");
+ int rc;
+ uint64 idxPageCnt = 0;
+ double cost;
+
+ if (unlikely(rows == HA_POS_ERROR))
+ DBUG_RETURN(double(rows) + ranges);
+
+ rc = bridge()->retrieveIndexInfo(db2Table->indexFile(index)->getMasterDefnHandle(),
+ &idxPageCnt);
+ if (!rc)
+ {
+ if ((idxPageCnt == 1) || // Retrieving rows in requested order or
+ (ranges == rows)) // 'Sweep' full records retrieval
+ cost = idxPageCnt/4;
+ else
+ {
+ uint64 totalRecords = stats.records + 1;
+ double dataPageCount = stats.data_file_length/IO_SIZE;
+
+ cost = (rows * dataPageCount / totalRecords) +
+ min(idxPageCnt, (log_2(idxPageCnt) * ranges +
+ rows * (log_2(idxPageCnt) + log_2(rows) - log_2(totalRecords))));
+ }
+ }
+ else
+ {
+ cost = rows2double(ranges+rows); // Use default costing
+ }
+ DBUG_RETURN(cost);
+}
+
+int ha_ibmdb2i::useIndexFile(int idx)
+{
+ DBUG_ENTER("ha_ibmdb2i::useIndexFile");
+
+ if (activeHandle)
+ releaseActiveHandle();
+
+ int rc = 0;
+
+ if (!indexHandles[idx])
+ rc = db2Table->indexFile(idx)->allocateNewInstance(&indexHandles[idx], curConnection);
+
+ if (rc == 0)
+ {
+ activeHandle = indexHandles[idx];
+ bumpInUseCounter(1);
+ }
+
+ DBUG_RETURN(rc);
+}
+
+
+ulong ha_ibmdb2i::index_flags(uint inx, uint part, bool all_parts) const
+{
+ return HA_READ_NEXT | HA_READ_PREV | HA_KEYREAD_ONLY | HA_READ_ORDER | HA_READ_RANGE;
+}
+
+
+static struct st_mysql_sys_var* ibmdb2i_system_variables[] = {
+ MYSQL_SYSVAR(rdb_name),
+ MYSQL_SYSVAR(transaction_unsafe),
+ MYSQL_SYSVAR(lob_alloc_size),
+ MYSQL_SYSVAR(max_read_buffer_size),
+ MYSQL_SYSVAR(max_write_buffer_size),
+ MYSQL_SYSVAR(async_enabled),
+ MYSQL_SYSVAR(assume_exclusive_use),
+ MYSQL_SYSVAR(compat_opt_blob_cols),
+ MYSQL_SYSVAR(compat_opt_time_as_duration),
+ MYSQL_SYSVAR(compat_opt_allow_zero_date_vals),
+ MYSQL_SYSVAR(compat_opt_year_as_int),
+ MYSQL_SYSVAR(propagate_default_col_vals),
+ MYSQL_SYSVAR(create_index_option),
+// MYSQL_SYSVAR(discovery_mode),
+ MYSQL_SYSVAR(system_trace_level),
+ NULL
+};
+
+
+struct st_mysql_storage_engine ibmdb2i_storage_engine=
+{ MYSQL_HANDLERTON_INTERFACE_VERSION };
+
+mysql_declare_plugin(ibmdb2i)
+{
+ MYSQL_STORAGE_ENGINE_PLUGIN,
+ &ibmdb2i_storage_engine,
+ "IBMDB2I",
+ "The IBM development team in Rochester, Minnesota",
+ "IBM DB2 for i Storage Engine",
+ PLUGIN_LICENSE_GPL,
+ ibmdb2i_init_func, /* Plugin Init */
+ ibmdb2i_done_func, /* Plugin Deinit */
+ 0x0100 /* 1.0 */,
+ NULL, /* status variables */
+ ibmdb2i_system_variables, /* system variables */
+ NULL /* config options */
+}
+mysql_declare_plugin_end;
diff --git a/storage/ibmdb2i/ha_ibmdb2i.h b/storage/ibmdb2i/ha_ibmdb2i.h
new file mode 100644
index 00000000000..e90f152919c
--- /dev/null
+++ b/storage/ibmdb2i/ha_ibmdb2i.h
@@ -0,0 +1,750 @@
+/*
+Licensed Materials - Property of IBM
+DB2 Storage Engine Enablement
+Copyright IBM Corporation 2007,2008
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+ (a) Redistributions of source code must retain this list of conditions, the
+ copyright notice in section {d} below, and the disclaimer following this
+ list of conditions.
+ (b) Redistributions in binary form must reproduce this list of conditions, the
+ copyright notice in section (d) below, and the disclaimer following this
+ list of conditions, in the documentation and/or other materials provided
+ with the distribution.
+ (c) The name of IBM may not be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ (d) The text of the required copyright notice is:
+ Licensed Materials - Property of IBM
+ DB2 Storage Engine Enablement
+ Copyright IBM Corporation 2007,2008
+ All rights reserved
+
+THIS SOFTWARE IS PROVIDED BY IBM CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL IBM CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+*/
+
+/** @file ha_ibmdb2i.h
+
+ @brief
+
+ @note
+
+ @see
+*/
+
+#ifdef USE_PRAGMA_INTERFACE
+#pragma interface /* gcc class implementation */
+#endif
+
+#include "as400_types.h"
+#include "as400_protos.h"
+#include "db2i_global.h"
+#include "db2i_ileBridge.h"
+#include "builtins.h"
+#include "db2i_misc.h"
+#include "db2i_file.h"
+#include "db2i_blobCollection.h"
+#include "db2i_collationSupport.h"
+#include "db2i_validatedPointer.h"
+#include "db2i_ioBuffers.h"
+#include "db2i_errors.h"
+#include "db2i_sqlStatementStream.h"
+
+/** @brief
+ IBMDB2I_SHARE is a structure that will be shared among all open handlers.
+ It is used to describe the underlying table definition, and it caches
+ table statistics.
+*/
+struct IBMDB2I_SHARE {
+ char *table_name;
+ uint table_name_length,use_count;
+ pthread_mutex_t mutex;
+ THR_LOCK lock;
+
+ db2i_table* db2Table;
+
+ class CStats
+ {
+ public:
+ void cacheUpdateTime(time_t time)
+ {update_time = time; initFlag |= lastModTime;}
+ time_t getUpdateTime() const
+ {return update_time;}
+ void cacheRowCount(ha_rows rows)
+ {records = rows; initFlag |= rowCount;}
+ ha_rows getRowCount() const
+ {return records;}
+ void cacheDelRowCount(ha_rows rows)
+ {deleted = rows; initFlag |= deletedRowCount;}
+ ha_rows getDelRowCount() const
+ {return deleted;}
+ void cacheMeanLength(ulong len)
+ {mean_rec_length = len; initFlag |= meanRowLen;}
+ ulong getMeanLength()
+ {return mean_rec_length;}
+ void cacheAugmentedDataLength(ulong len)
+ {data_file_length = len; initFlag |= ioCount;}
+ ulong getAugmentedDataLength()
+ {return data_file_length;}
+ bool isInited(uint flags)
+ {return initFlag & flags;}
+ void invalidate(uint flags)
+ {initFlag &= ~flags;}
+
+ private:
+ uint initFlag;
+ time_t update_time;
+ ha_rows records;
+ ha_rows deleted;
+ ulong mean_rec_length;
+ ulong data_file_length;
+ } cachedStats;
+
+};
+
+class ha_ibmdb2i: public handler
+{
+ THR_LOCK_DATA lock; ///< MySQL lock
+ IBMDB2I_SHARE *share; ///< Shared lock info
+
+ // The record we are positioned on, together with the handle used to get
+ // i.
+ uint32 currentRRN;
+ uint32 rrnAssocHandle;
+
+ // Dup key values needed by info()
+ uint32 lastDupKeyRRN;
+ uint32 lastDupKeyID;
+
+ bool returnDupKeysImmediately;
+
+ // Dup key value need by update()
+ bool onDupUpdate;
+
+
+ db2i_table* db2Table;
+
+ // The file handle of the PF or LF being accessed by the current operation.
+ FILE_HANDLE activeHandle;
+
+ // The file handle of the underlying PF
+ FILE_HANDLE dataHandle;
+
+ // Array of file handles belonging to the underlying LFs
+ FILE_HANDLE* indexHandles;
+
+ // Flag to indicate whether a call needs to be made to unlock a row when
+ // a read operation has ended. DB2 will handle row unlocking as we move
+ // through rows, but if an operation ends before we reach the end of a file,
+ // DB2 needs to know to unlock the last row read.
+ bool releaseRowNeeded;
+
+ // Pointer to a definition of the layout of the row buffer for the file
+ // described by activeHandle
+ const db2i_file::RowFormat* activeFormat;
+
+ IORowBuffer keyBuf;
+ uint32 keyLen;
+
+ IOWriteBuffer multiRowWriteBuf;
+ IOAsyncReadBuffer multiRowReadBuf;
+
+ IOAsyncReadBuffer* activeReadBuf;
+ IOWriteBuffer* activeWriteBuf;
+
+ BlobCollection* blobReadBuffers; // Dynamically allocated per query and used
+ // to manage the buffers used for reading LOBs
+ ValidatedPointer<char>* blobWriteBuffers;
+
+ // Return codes are not used/honored by rnd_init and start_bulk_insert
+ // so we need a way to signal the failure "downstream" to subsequent
+ // functions.
+ int last_rnd_init_rc;
+ int last_index_init_rc;
+ int last_start_bulk_insert_rc;
+
+ // end_bulk_insert may get called twice for a single start_bulk_insert
+ // This is our way to do cleanup only once.
+ bool outstanding_start_bulk_insert;
+
+ // Auto_increment 'increment by' value needed by write_row()
+ uint32 incrementByValue;
+ bool default_identity_value;
+
+ // Flags and values used during write operations for auto_increment processing
+ bool autoIncLockAcquired;
+ bool got_auto_inc_values;
+ uint64 next_identity_value;
+
+ // The access intent indicated by the last external_locks() call.
+ // May be either QMY_READ or QMY_UPDATABLE
+ char accessIntent;
+ char readAccessIntent;
+
+ ha_rows* indexReadSizeEstimates;
+
+ MEM_ROOT conversionBufferMemroot;
+
+ bool forceSingleRowRead;
+
+ bool readAllColumns;
+
+ bool invalidDataFound;
+
+ db2i_ileBridge* cachedBridge;
+
+ ValidatedObject<volatile uint32> curConnection;
+ uint16 activeReferences;
+
+public:
+
+ ha_ibmdb2i(handlerton *hton, TABLE_SHARE *table_arg);
+ ~ha_ibmdb2i();
+
+ const char *table_type() const { return "IBMDB2I"; }
+ const char *index_type(uint inx) { return "RADIX"; }
+ const key_map *keys_to_use_for_scanning() { return &key_map_full; }
+ const char **bas_ext() const;
+
+ ulonglong table_flags() const
+ {
+ return HA_NULL_IN_KEY | HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY |
+ HA_PARTIAL_COLUMN_READ |
+ HA_DUPLICATE_POS | HA_NO_PREFIX_CHAR_KEYS |
+ HA_HAS_RECORDS | HA_BINLOG_ROW_CAPABLE | HA_REQUIRES_KEY_COLUMNS_FOR_DELETE |
+ HA_CAN_INDEX_BLOBS;
+ }
+
+ ulong index_flags(uint inx, uint part, bool all_parts) const;
+
+// Note that we do not implement max_supported_record_length.
+// We'll let create fail accordingly if the row is
+// too long. This allows us to hide the fact that varchars > 32K are being
+// implemented as DB2 LOBs.
+
+ uint max_supported_keys() const { return 4000; }
+ uint max_supported_key_parts() const { return MAX_DB2_KEY_PARTS; }
+ uint max_supported_key_length() const { return 32767; }
+ uint max_supported_key_part_length() const { return 32767; }
+ double read_time(uint index, uint ranges, ha_rows rows);
+ double scan_time();
+ int open(const char *name, int mode, uint test_if_locked);
+ int close(void);
+ int write_row(uchar * buf);
+ int update_row(const uchar * old_data, uchar * new_data);
+ int delete_row(const uchar * buf);
+ int index_init(uint idx, bool sorted);
+ int index_read(uchar * buf, const uchar * key,
+ uint key_len, enum ha_rkey_function find_flag);
+ int index_next(uchar * buf);
+ int index_read_last(uchar * buf, const uchar * key, uint key_len);
+ int index_next_same(uchar *buf, const uchar *key, uint keylen);
+ int index_prev(uchar * buf);
+ int index_first(uchar * buf);
+ int index_last(uchar * buf);
+ int rnd_init(bool scan);
+ int rnd_end();
+ int rnd_next(uchar *buf);
+ int rnd_pos(uchar * buf, uchar *pos);
+ void position(const uchar *record);
+ int info(uint);
+ ha_rows records();
+ int extra(enum ha_extra_function operation);
+ int external_lock(THD *thd, int lock_type);
+ int delete_all_rows(void);
+ ha_rows records_in_range(uint inx, key_range *min_key,
+ key_range *max_key);
+ int delete_table(const char *from);
+ int rename_table(const char * from, const char * to);
+ int create(const char *name, TABLE *form,
+ HA_CREATE_INFO *create_info);
+ int updateFrm(TABLE *table_def, File file);
+ int openTableDef(TABLE *table_def);
+ int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
+ int prepare_drop_index(TABLE *table_arg, uint *key_num, uint num_of_keys);
+ int final_drop_index(TABLE *table_arg) {return 0;}
+ void get_auto_increment(ulonglong offset, ulonglong increment,
+ ulonglong nb_desired_values,
+ ulonglong *first_value,
+ ulonglong *nb_reserved_values);
+ int reset_auto_increment(ulonglong value);
+ void restore_auto_increment(ulonglong prev_insert_id) {return;}
+ void update_create_info(HA_CREATE_INFO *create_info);
+ int getNextIdVal(ulonglong *value);
+ int analyze(THD* thd,HA_CHECK_OPT* check_opt);
+ int optimize(THD* thd, HA_CHECK_OPT* check_opt);
+ bool can_switch_engines();
+ void free_foreign_key_create_info(char* str);
+ char* get_foreign_key_create_info();
+ int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
+ uint referenced_by_foreign_key();
+ bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
+ virtual bool get_error_message(int error, String *buf);
+
+ THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
+ enum thr_lock_type lock_type);
+
+ bool low_byte_first() const { return 0; }
+ void unlock_row();
+ int index_end();
+ int reset();
+ static int doCommit(handlerton *hton, THD *thd, bool all);
+ static int doRollback(handlerton *hton, THD *thd, bool all);
+ void start_bulk_insert(ha_rows rows);
+ int end_bulk_insert();
+ int start_stmt(THD *thd, thr_lock_type lock_type);
+
+ void initBridge(THD* thd = NULL)
+ {
+ if (thd == NULL) thd = ha_thd();
+ DBUG_PRINT("ha_ibmdb2i::initBridge",("Initing bridge. Conn ID=%d", thd->thread_id));
+ cachedBridge = db2i_ileBridge::getBridgeForThread(thd);
+ }
+
+ db2i_ileBridge* bridge() {DBUG_ASSERT(cachedBridge); return cachedBridge;}
+
+ static uint8 autoCommitIsOn(THD* thd)
+ { return (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ? QMY_NO : QMY_YES); }
+
+ uint8 getCommitLevel();
+ uint8 getCommitLevel(THD* thd);
+
+ static int doSavepointSet(THD* thd, char* name)
+ {
+ return db2i_ileBridge::getBridgeForThread(thd)->savepoint(QMY_SET_SAVEPOINT,
+ name);
+ }
+
+ static int doSavepointRollback(THD* thd, char* name)
+ {
+ return db2i_ileBridge::getBridgeForThread(thd)->savepoint(QMY_ROLLBACK_SAVEPOINT,
+ name);
+ }
+
+ static int doSavepointRelease(THD* thd, char* name)
+ {
+ return db2i_ileBridge::getBridgeForThread(thd)->savepoint(QMY_RELEASE_SAVEPOINT,
+ name);
+ }
+
+ // We can't guarantee that the rows we know about when this is called
+ // will be the same number of rows that read returns (since DB2 activity
+ // may insert additional rows). Therefore, we do as the Federated SE and
+ // return the max possible.
+ ha_rows estimate_rows_upper_bound()
+ {
+ return HA_POS_ERROR;
+ }
+
+
+private:
+
+ enum enum_TimeFormat
+ {
+ TIME_OF_DAY,
+ DURATION
+ };
+
+ enum enum_BlobMapping
+ {
+ AS_BLOB,
+ AS_VARCHAR
+ };
+
+ enum enum_ZeroDate
+ {
+ NO_SUBSTITUTE,
+ SUBSTITUTE_0001_01_01
+ };
+
+ enum enum_YearFormat
+ {
+ CHAR4,
+ SMALLINT
+ };
+
+ enum_ZeroDate cachedZeroDateOption;
+
+ IBMDB2I_SHARE *get_share(const char *table_name, TABLE *table);
+ int free_share(IBMDB2I_SHARE *share);
+ int32 mungeDB2row(uchar* record, const char* dataPtr, const char* nullMapPtr, bool skipLOBs);
+ int prepareRowForWrite(char* data, char* nulls, bool honorIdentCols);
+ int prepareReadBufferForLobs();
+ int32 prepareWriteBufferForLobs();
+ uint32 adjustLobBuffersForRead();
+ bool lobFieldsRequested();
+ int convertFieldChars(enum_conversionDirection direction, uint16 fieldID, const char* input, char* output, size_t ilen, size_t olen, size_t* outDataLen);
+
+ /**
+ Fast integer log2 function
+ */
+ uint64 log_2(uint64 val)
+ {
+ uint64 exp = 0;
+ while( (val >> exp) != 0)
+ {
+ exp++;
+ }
+ DBUG_ASSERT(exp-1 == (uint64)log2(val));
+ return exp-1;
+ }
+
+ void bumpInUseCounter(uint16 amount)
+ {
+ activeReferences += amount;
+ DBUG_PRINT("ha_ibmdb2i::bumpInUseCounter", ("activeReferences = %d", activeReferences));
+ if (activeReferences)
+ curConnection = (uint32)(ha_thd()->thread_id);
+ else
+ curConnection = 0;
+ }
+
+
+ int useDataFile()
+ {
+ DBUG_ENTER("ha_ibmdb2i::useDataFile");
+
+ int rc = 0;
+ if (!dataHandle)
+ rc = db2Table->dataFile()->allocateNewInstance(&dataHandle, curConnection);
+ else if (activeHandle == dataHandle)
+ DBUG_RETURN(0);
+
+ DBUG_ASSERT(activeHandle == 0);
+
+ if (likely(rc == 0))
+ {
+ activeHandle = dataHandle;
+ bumpInUseCounter(1);
+ }
+
+ DBUG_RETURN(rc);
+ }
+
+ void releaseAnyLockedRows()
+ {
+ if (releaseRowNeeded)
+ {
+ DBUG_PRINT("ha_ibmdb2i::releaseAnyLockedRows", ("Releasing rows"));
+ db2i_ileBridge::getBridgeForThread()->rrlslck(activeHandle, accessIntent);
+ releaseRowNeeded = FALSE;
+ }
+ }
+
+
+ void releaseDataFile()
+ {
+ DBUG_ENTER("ha_ibmdb2i::releaseDataFile");
+ releaseAnyLockedRows();
+ bumpInUseCounter(-1);
+ DBUG_ASSERT((volatile int)activeReferences >= 0);
+ activeHandle = 0;
+ DBUG_VOID_RETURN;
+ }
+
+ int useIndexFile(int idx);
+
+ void releaseIndexFile(int idx)
+ {
+ DBUG_ENTER("ha_ibmdb2i::releaseIndexFile");
+ releaseAnyLockedRows();
+ bumpInUseCounter(-1);
+ DBUG_ASSERT((volatile int)activeReferences >= 0);
+ activeHandle = 0;
+ DBUG_VOID_RETURN;
+ }
+
+ FILE_HANDLE allocateFileHandle(char* database, char* table, int* activityReference, bool hasBlobs);
+
+ int updateBuffers(const db2i_file::RowFormat* format, uint rowsToRead, uint rowsToWrite);
+
+ int flushWrite(FILE_HANDLE fileHandle, uchar* buf = NULL);
+
+ int alterStartWith();
+
+ int buildDB2ConstraintString(LEX* lex,
+ String& appendHere,
+ const char* database,
+ Field** fields,
+ char* fileSortSequenceType,
+ char* fileSortSequence,
+ char* fileSortSequenceLibrary);
+
+ void releaseWriteBuffer();
+
+ void setIndexReadEstimate(uint index, ha_rows rows)
+ {
+ if (!indexReadSizeEstimates)
+ {
+ indexReadSizeEstimates = (ha_rows*)my_malloc(sizeof(ha_rows) * table->s->keys, MYF(MY_WME | MY_ZEROFILL));
+ }
+ indexReadSizeEstimates[index] = rows;
+ }
+
+ ha_rows getIndexReadEstimate(uint index)
+ {
+ if (indexReadSizeEstimates)
+ return max(indexReadSizeEstimates[index], 1);
+
+ return 10000; // Assume index scan if no estimate exists.
+ }
+
+
+ void quiesceAllFileHandles()
+ {
+ db2i_ileBridge* bridge = db2i_ileBridge::getBridgeForThread();
+ if (dataHandle)
+ {
+ bridge->quiesceFileInstance(dataHandle);
+ }
+
+ for (int idx = 0; idx < table_share->keys; ++idx)
+ {
+ if (indexHandles[idx] != 0)
+ {
+ bridge->quiesceFileInstance(indexHandles[idx]);
+ }
+ }
+ }
+
+ int32 buildCreateIndexStatement(SqlStatementStream& sqlStream,
+ KEY& key,
+ bool isPrimary,
+ const char* db2LibName,
+ const char* db2FileName);
+
+ // Specify NULL for data when using the data pointed to by field
+ int32 convertMySQLtoDB2(Field* field, const DB2Field& db2Field, char* db2Buf, const uchar* data = NULL);
+
+ int32 convertDB2toMySQL(const DB2Field& db2Field, Field* field, const char* buf);
+ int getFieldTypeMapping(Field* field,
+ String& mapping,
+ enum_TimeFormat timeFormate,
+ enum_BlobMapping blobMapping,
+ enum_ZeroDate zeroDateHandling,
+ bool propagateDefaults,
+ enum_YearFormat yearFormat);
+
+ int getKeyFromName(const char* name, size_t len);
+
+ void releaseActiveHandle()
+ {
+ if (activeHandle == dataHandle)
+ releaseDataFile();
+ else
+ releaseIndexFile(active_index);
+ }
+
+
+ int32 finishBulkInsert();
+
+ void doInitialRead(char orientation,
+ uint32 rowsToBuffer,
+ ILEMemHandle key = 0,
+ int keyLength = 0,
+ int keyParts = 0);
+
+
+ int32 readFromBuffer(uchar* destination, char orientation)
+ {
+ char* row;
+ int32 rc = 0;
+ row = activeReadBuf->readNextRow(orientation, currentRRN);
+
+ if (unlikely(!row))
+ {
+ rc = activeReadBuf->lastrc();
+ if (rc == QMY_ERR_LOB_SPACE_TOO_SMALL)
+ {
+ rc = handleLOBReadOverflow();
+ if (rc == 0)
+ {
+ DBUG_ASSERT(activeReadBuf->rowCount() == 1);
+ row = activeReadBuf->readNextRow(orientation, currentRRN);
+
+ if (unlikely(!row))
+ rc = activeReadBuf->lastrc();
+ }
+ }
+ }
+
+ if (likely(rc == 0))
+ {
+ rrnAssocHandle = activeHandle;
+ rc = mungeDB2row(destination, row, row+activeReadBuf->getRowNullOffset(), false);
+ }
+ return rc;
+ }
+
+ int32 handleLOBReadOverflow();
+
+ char* getCharacterConversionBuffer(int fieldId, int length)
+ {
+ if (unlikely(!alloc_root_inited(&conversionBufferMemroot)))
+ init_alloc_root(&conversionBufferMemroot, 8192, 0);
+
+ return (char*)alloc_root(&conversionBufferMemroot, length);;
+ }
+
+ void resetCharacterConversionBuffers()
+ {
+ if (alloc_root_inited(&conversionBufferMemroot))
+ {
+ free_root(&conversionBufferMemroot, MYF(MY_MARK_BLOCKS_FREE));
+ }
+ }
+
+ void tweakReadSet()
+ {
+ THD* thd = ha_thd();
+ int command = thd_sql_command(thd);
+ if ((command == SQLCOM_UPDATE ||
+ command == SQLCOM_UPDATE_MULTI) ||
+ ((command == SQLCOM_DELETE ||
+ command == SQLCOM_DELETE_MULTI) &&
+ thd->options & OPTION_BIN_LOG))
+ readAllColumns = TRUE;
+ else
+ readAllColumns = FALSE;
+ }
+
+ /**
+
+ */
+ int useFileByHandle(char intent,
+ FILE_HANDLE handle)
+ {
+ DBUG_ENTER("ha_ibmdb2i::useFileByHandle");
+
+ const db2i_file* file;
+ if (handle == dataHandle)
+ file = db2Table->dataFile();
+ else
+ {
+ for (uint i = 0; i < table_share->keys; ++i)
+ {
+ if (indexHandles[i] == handle)
+ {
+ file = db2Table->indexFile(i);
+ active_index = i;
+ }
+ }
+ }
+
+ int rc = file->obtainRowFormat(handle, intent, getCommitLevel(), &activeFormat);
+ if (likely(rc == 0))
+ {
+ activeHandle = handle;
+ bumpInUseCounter(1);
+ }
+
+ DBUG_RETURN(rc);
+ }
+
+ const db2i_file* getFileForActiveHandle() const
+ {
+ if (activeHandle == dataHandle)
+ return db2Table->dataFile();
+ else
+ for (uint i = 0; i < table_share->keys; ++i)
+ if (indexHandles[i] == activeHandle)
+ return db2Table->indexFile(i);
+ DBUG_ASSERT(0);
+ return NULL;
+ }
+
+ int prepReadBuffer(ha_rows rowsToRead, const db2i_file* file, char intent);
+ int prepWriteBuffer(ha_rows rowsToWrite, const db2i_file* file);
+
+ void invalidateCachedStats()
+ {
+ share->cachedStats.invalidate(rowCount | deletedRowCount | objLength |
+ meanRowLen | ioCount);
+ }
+
+ void warnIfInvalidData()
+ {
+ if (unlikely(invalidDataFound))
+ {
+ warning(ha_thd(), DB2I_ERR_INVALID_DATA, table->alias);
+ }
+ }
+
+ /**
+ Calculate the maximum value that a particular field can hold.
+
+ This is used to anticipate overflows in the auto_increment processing.
+
+ @param field The Field to be analyzed
+
+ @return The maximum value
+ */
+ static uint64 maxValueForField(const Field* field)
+ {
+ uint64 maxValue=0;
+ switch (field->type())
+ {
+ case MYSQL_TYPE_TINY:
+ if (((const Field_num*)field)->unsigned_flag)
+ maxValue = (1 << 8) - 1;
+ else
+ maxValue = (1 << 7) - 1;
+ break;
+ case MYSQL_TYPE_SHORT:
+ if (((const Field_num*)field)->unsigned_flag)
+ maxValue = (1 << 16) - 1;
+ else
+ maxValue = (1 << 15) - 1;
+ break;
+ case MYSQL_TYPE_INT24:
+ if (((const Field_num*)field)->unsigned_flag)
+ maxValue = (1 << 24) - 1;
+ else
+ maxValue = (1 << 23) - 1;
+ break;
+ case MYSQL_TYPE_LONG:
+ if (((const Field_num*)field)->unsigned_flag)
+ maxValue = (1LL << 32) - 1;
+ else
+ maxValue = (1 << 31) - 1;
+ break;
+ case MYSQL_TYPE_LONGLONG:
+ if (((const Field_num*)field)->unsigned_flag)
+ maxValue = ~(0LL);
+ else
+ maxValue = 1 << 63 - 1;
+ break;
+ }
+
+ return maxValue;
+ }
+
+ void cleanupBuffers()
+ {
+ if (blobReadBuffers)
+ {
+ delete blobReadBuffers;
+ blobReadBuffers = NULL;
+ }
+ if (blobWriteBuffers)
+ {
+ delete[] blobWriteBuffers;
+ blobWriteBuffers = NULL;
+ }
+ if (alloc_root_inited(&conversionBufferMemroot))
+ {
+ free_root(&conversionBufferMemroot, MYF(0));
+ }
+ }
+
+};
diff --git a/storage/ibmdb2i/plug.in b/storage/ibmdb2i/plug.in
new file mode 100644
index 00000000000..0913d72aabf
--- /dev/null
+++ b/storage/ibmdb2i/plug.in
@@ -0,0 +1,12 @@
+MYSQL_STORAGE_ENGINE([ibmdb2i], [], [IBM DB2 for i Storage Engine],
+ [IBM DB2 for i Storage Engine], [max,max-no-ndb])
+MYSQL_PLUGIN_DYNAMIC([ibmdb2i], [ha_ibmdb2i.la])
+
+AC_CHECK_HEADER([qlgusr.h],
+ # qlgusr.h is just one of the headers from the i5/OS PASE environment; the
+ # EBCDIC headers are in /QIBM/include, and have to be converted to ASCII
+ # before cpp gets to them
+ [:],
+ # Missing PASE environment, can't build this engine
+ [mysql_plugin_ibmdb2i=no
+ with_plugin_ibmdb2i=no])
diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c
index 6a13ca863bd..8d296fdd061 100644
--- a/storage/innobase/btr/btr0sea.c
+++ b/storage/innobase/btr/btr0sea.c
@@ -1105,12 +1105,20 @@ btr_search_drop_page_hash_when_freed(
page = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL,
BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
&mtr);
+ /* Because the buffer pool mutex was released by
+ buf_page_peek_if_search_hashed(), it is possible that the
+ block was removed from the buffer pool by another thread
+ before buf_page_get_gen() got a chance to acquire the buffer
+ pool mutex again. Thus, we must check for a NULL return. */
+
+ if (UNIV_LIKELY(page != NULL)) {
#ifdef UNIV_SYNC_DEBUG
- buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH);
+ buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH);
#endif /* UNIV_SYNC_DEBUG */
- btr_search_drop_page_hash_index(page);
+ btr_search_drop_page_hash_index(page);
+ }
mtr_commit(&mtr);
}
diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c
index f594e64f517..65f1c9536bd 100644
--- a/storage/innobase/dict/dict0load.c
+++ b/storage/innobase/dict/dict0load.c
@@ -868,11 +868,11 @@ err_exit:
of the error condition, since the user may want to dump data from the
clustered index. However we load the foreign key information only if
all indexes were loaded. */
- if (err != DB_SUCCESS && !srv_force_recovery) {
- dict_mem_table_free(table);
- table = NULL;
- } else if (err == DB_SUCCESS) {
+ if (err == DB_SUCCESS) {
err = dict_load_foreigns(table->name, TRUE);
+ } else if (!srv_force_recovery) {
+ dict_table_remove_from_cache(table);
+ table = NULL;
}
#if 0
if (err != DB_SUCCESS && table != NULL) {
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index fb9a15c246c..828dcdb843d 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -977,6 +977,12 @@ innobase_next_autoinc(
/* Should never be 0. */
ut_a(increment > 0);
+ /* According to MySQL documentation, if the offset is greater than
+ the increment then the offset is ignored. */
+ if (offset > increment) {
+ offset = 0;
+ }
+
if (max_value <= current) {
next_value = max_value;
} else if (offset <= 1) {
@@ -3344,8 +3350,8 @@ build_template(
goto include_field;
}
- if (bitmap_is_set(table->read_set, i) ||
- bitmap_is_set(table->write_set, i)) {
+ if (bitmap_is_set(table->read_set, i) ||
+ bitmap_is_set(table->write_set, i)) {
/* This field is needed in the query */
goto include_field;
@@ -3437,7 +3443,7 @@ skip_field:
}
/************************************************************************
-Get the upper limit of the MySQL integral type. */
+Get the upper limit of the MySQL integral and floating-point type. */
ulonglong
ha_innobase::innobase_get_int_col_max_value(
@@ -3448,7 +3454,7 @@ ha_innobase::innobase_get_int_col_max_value(
switch(field->key_type()) {
/* TINY */
- case HA_KEYTYPE_BINARY:
+ case HA_KEYTYPE_BINARY:
max_value = 0xFFULL;
break;
case HA_KEYTYPE_INT8:
@@ -3462,7 +3468,7 @@ ha_innobase::innobase_get_int_col_max_value(
max_value = 0x7FFFULL;
break;
/* MEDIUM */
- case HA_KEYTYPE_UINT24:
+ case HA_KEYTYPE_UINT24:
max_value = 0xFFFFFFULL;
break;
case HA_KEYTYPE_INT24:
@@ -3476,12 +3482,20 @@ ha_innobase::innobase_get_int_col_max_value(
max_value = 0x7FFFFFFFULL;
break;
/* BIG */
- case HA_KEYTYPE_ULONGLONG:
+ case HA_KEYTYPE_ULONGLONG:
max_value = 0xFFFFFFFFFFFFFFFFULL;
break;
case HA_KEYTYPE_LONGLONG:
max_value = 0x7FFFFFFFFFFFFFFFULL;
break;
+ case HA_KEYTYPE_FLOAT:
+ /* We use the maximum as per IEEE754-2008 standard, 2^24 */
+ max_value = 0x1000000ULL;
+ break;
+ case HA_KEYTYPE_DOUBLE:
+ /* We use the maximum as per IEEE754-2008 standard, 2^53 */
+ max_value = 0x20000000000000ULL;
+ break;
default:
ut_error;
}
@@ -3804,7 +3818,7 @@ no_commit:
will be 0 if get_auto_increment() was not called.*/
if (auto_inc <= col_max_value
- && auto_inc > prebuilt->autoinc_last_value) {
+ && auto_inc >= prebuilt->autoinc_last_value) {
set_max_autoinc:
ut_a(prebuilt->autoinc_increment > 0);
@@ -4284,7 +4298,6 @@ convert_search_mode_to_innobase(
case HA_READ_MBR_WITHIN:
case HA_READ_MBR_DISJOINT:
case HA_READ_MBR_EQUAL:
- my_error(ER_TABLE_CANT_HANDLE_SPKEYS, MYF(0));
return(PAGE_CUR_UNSUPP);
/* do not use "default:" in order to produce a gcc warning:
enumeration value '...' not handled in switch
@@ -5835,7 +5848,7 @@ ha_innobase::records_in_range(
mode2);
} else {
- n_rows = 0;
+ n_rows = HA_POS_ERROR;
}
dtuple_free_for_mysql(heap1);
@@ -6538,7 +6551,7 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
f_key_info.referenced_key_name = thd_make_lex_string(
thd, f_key_info.referenced_key_name,
foreign->referenced_index->name,
- strlen(foreign->referenced_index->name), 1);
+ (uint) strlen(foreign->referenced_index->name), 1);
}
else
f_key_info.referenced_key_name= 0;
@@ -7150,7 +7163,7 @@ innodb_show_status(
bool result = FALSE;
- if (stat_print(thd, innobase_hton_name, strlen(innobase_hton_name),
+ if (stat_print(thd, innobase_hton_name, (uint) strlen(innobase_hton_name),
STRING_WITH_LEN(""), str, flen)) {
result= TRUE;
}
@@ -7181,7 +7194,7 @@ innodb_mutex_show_status(
ulint rw_lock_count_os_yield= 0;
ulonglong rw_lock_wait_time= 0;
#endif /* UNIV_DEBUG */
- uint hton_name_len= strlen(innobase_hton_name), buf1len, buf2len;
+ uint hton_name_len= (uint) strlen(innobase_hton_name), buf1len, buf2len;
DBUG_ENTER("innodb_mutex_show_status");
mutex_enter_noninline(&mutex_list_mutex);
@@ -7225,9 +7238,9 @@ innodb_mutex_show_status(
rw_lock_wait_time += mutex->lspent_time;
}
#else /* UNIV_DEBUG */
- buf1len= my_snprintf(buf1, sizeof(buf1), "%s:%lu",
+ buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s:%lu",
mutex->cfile_name, (ulong) mutex->cline);
- buf2len= my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
+ buf2len= (uint) my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
mutex->count_os_wait);
if (stat_print(thd, innobase_hton_name,
@@ -7709,11 +7722,13 @@ ha_innobase::get_auto_increment(
prebuilt->autoinc_last_value = next_value;
- ut_a(prebuilt->autoinc_last_value >= *first_value);
-
- /* Update the table autoinc variable */
- dict_table_autoinc_update_if_greater(
- prebuilt->table, prebuilt->autoinc_last_value);
+ if (prebuilt->autoinc_last_value < *first_value) {
+ *first_value = (~(ulonglong) 0);
+ } else {
+ /* Update the table autoinc variable */
+ dict_table_autoinc_update_if_greater(
+ prebuilt->table, prebuilt->autoinc_last_value);
+ }
} else {
/* This will force write_row() into attempting an update
of the table's AUTOINC counter. */
@@ -7766,7 +7781,7 @@ ha_innobase::get_error_message(int error, String *buf)
{
trx_t* trx = check_trx_exists(ha_thd());
- buf->copy(trx->detailed_error, strlen(trx->detailed_error),
+ buf->copy(trx->detailed_error, (uint) strlen(trx->detailed_error),
system_charset_info);
return FALSE;
@@ -8317,6 +8332,14 @@ static MYSQL_SYSVAR_BOOL(stats_on_metadata, innobase_stats_on_metadata,
"Enable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)",
NULL, NULL, TRUE);
+static MYSQL_SYSVAR_BOOL(use_legacy_cardinality_algorithm,
+ srv_use_legacy_cardinality_algorithm,
+ PLUGIN_VAR_OPCMDARG,
+ "Use legacy algorithm for picking random pages during index cardinality "
+ "estimation. Disable this to use a better algorithm, but note that your "
+ "query plans may change (enabled by default).",
+ NULL, NULL, TRUE);
+
static MYSQL_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"Enable InnoDB adaptive hash index (enabled by default). "
@@ -8479,6 +8502,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(open_files),
MYSQL_SYSVAR(rollback_on_timeout),
MYSQL_SYSVAR(stats_on_metadata),
+ MYSQL_SYSVAR(use_legacy_cardinality_algorithm),
MYSQL_SYSVAR(adaptive_hash_index),
MYSQL_SYSVAR(status_file),
MYSQL_SYSVAR(support_xa),
diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c
index 126fd9fdd33..d54a3378993 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.c
+++ b/storage/innobase/ibuf/ibuf0ibuf.c
@@ -2992,6 +2992,13 @@ ibuf_delete_rec(
success = btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr);
if (!success) {
+ if (fil_space_get_version(space) == -1) {
+ /* The tablespace has been dropped. It is possible
+ that another thread has deleted the insert buffer
+ entry. Do not complain. */
+ goto commit_and_exit;
+ }
+
fprintf(stderr,
"InnoDB: ERROR: Submit the output to"
" http://bugs.mysql.com\n"
@@ -3018,11 +3025,7 @@ ibuf_delete_rec(
fprintf(stderr, "InnoDB: ibuf tree ok\n");
fflush(stderr);
- btr_pcur_close(pcur);
-
- mutex_exit(&ibuf_mutex);
-
- return(TRUE);
+ goto func_exit;
}
root = ibuf_tree_root_get(ibuf_data, 0, mtr);
@@ -3033,15 +3036,15 @@ ibuf_delete_rec(
#ifdef UNIV_IBUF_DEBUG
ibuf_count_set(space, page_no, ibuf_count_get(space, page_no) - 1);
-#else
- UT_NOT_USED(space);
#endif
ibuf_data_sizes_update(ibuf_data, root, mtr);
ut_ad(ibuf_validate_low());
+commit_and_exit:
btr_pcur_commit_specify_mtr(pcur, mtr);
+func_exit:
btr_pcur_close(pcur);
mutex_exit(&ibuf_mutex);
diff --git a/storage/innobase/include/pars0pars.h b/storage/innobase/include/pars0pars.h
index 41b788ffa05..1c6c550d313 100644
--- a/storage/innobase/include/pars0pars.h
+++ b/storage/innobase/include/pars0pars.h
@@ -684,7 +684,7 @@ struct for_node_struct{
definition */
que_node_t* loop_start_limit;/* initial value of loop variable */
que_node_t* loop_end_limit; /* end value of loop variable */
- int loop_end_value; /* evaluated value for the end value:
+ lint loop_end_value; /* evaluated value for the end value:
it is calculated only when the loop
is entered, and will not change within
the loop */
diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h
index 43ef6650e90..abc204bb583 100644
--- a/storage/innobase/include/rem0rec.h
+++ b/storage/innobase/include/rem0rec.h
@@ -365,8 +365,9 @@ rec_set_field_extern_bits(
/***************************************************************
This is used to modify the value of an already existing field in a record.
The previous value must have exactly the same size as the new value. If len
-is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
-records. For new-style records, len must not be UNIV_SQL_NULL. */
+is UNIV_SQL_NULL then the field is treated as an SQL null.
+For records in ROW_FORMAT=COMPACT (new-style records), len must not be
+UNIV_SQL_NULL unless the field already is SQL null. */
UNIV_INLINE
void
rec_set_nth_field(
@@ -375,11 +376,7 @@ rec_set_nth_field(
const ulint* offsets,/* in: array returned by rec_get_offsets() */
ulint n, /* in: index number of the field */
const void* data, /* in: pointer to the data if not SQL null */
- ulint len); /* in: length of the data or UNIV_SQL_NULL.
- If not SQL null, must have the same
- length as the previous value.
- If SQL null, previous value must be
- SQL null. */
+ ulint len); /* in: length of the data or UNIV_SQL_NULL */
/**************************************************************
The following function returns the data size of an old-style physical
record, that is the sum of field lengths. SQL null fields
diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic
index 5a4a0a0b5df..d91fb4c4391 100644
--- a/storage/innobase/include/rem0rec.ic
+++ b/storage/innobase/include/rem0rec.ic
@@ -1219,8 +1219,9 @@ rec_get_nth_field_size(
/***************************************************************
This is used to modify the value of an already existing field in a record.
The previous value must have exactly the same size as the new value. If len
-is UNIV_SQL_NULL then the field is treated as an SQL null for old-style
-records. For new-style records, len must not be UNIV_SQL_NULL. */
+is UNIV_SQL_NULL then the field is treated as an SQL null.
+For records in ROW_FORMAT=COMPACT (new-style records), len must not be
+UNIV_SQL_NULL unless the field already is SQL null. */
UNIV_INLINE
void
rec_set_nth_field(
@@ -1230,11 +1231,7 @@ rec_set_nth_field(
ulint n, /* in: index number of the field */
const void* data, /* in: pointer to the data
if not SQL null */
- ulint len) /* in: length of the data or UNIV_SQL_NULL.
- If not SQL null, must have the same
- length as the previous value.
- If SQL null, previous value must be
- SQL null. */
+ ulint len) /* in: length of the data or UNIV_SQL_NULL */
{
byte* data2;
ulint len2;
@@ -1242,9 +1239,11 @@ rec_set_nth_field(
ut_ad(rec);
ut_ad(rec_offs_validate(rec, NULL, offsets));
- if (len == UNIV_SQL_NULL) {
- ut_ad(!rec_offs_comp(offsets));
- rec_set_nth_field_sql_null(rec, n);
+ if (UNIV_UNLIKELY(len == UNIV_SQL_NULL)) {
+ if (!rec_offs_nth_sql_null(offsets, n)) {
+ ut_a(!rec_offs_comp(offsets));
+ rec_set_nth_field_sql_null(rec, n);
+ }
return;
}
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index 9b2f3250486..5430190fa51 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -656,6 +656,21 @@ struct row_prebuilt_struct {
This eliminates lock waits in some
cases; note that this breaks
serializability. */
+ ulint new_rec_locks; /* normally 0; if
+ srv_locks_unsafe_for_binlog is
+ TRUE or session is using READ
+ COMMITTED isolation level, in a
+ cursor search, if we set a new
+ record lock on an index, this is
+ incremented; this is used in
+ releasing the locks under the
+ cursors if we are performing an
+ UPDATE and we determine after
+ retrieving the row that it does
+ not need to be locked; thus,
+ these can be used to implement a
+ 'mini-rollback' that releases
+ the latest record locks */
ulint mysql_prefix_len;/* byte offset of the end of
the last requested column */
ulint mysql_row_len; /* length in bytes of a row in the
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 6816823641c..05300e38430 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -253,6 +253,12 @@ extern ulint srv_read_ahead_rnd;
/* Number of threads that may have missed a lock wait wakeup */
extern ulint sync_wake_ups;
+/* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
+NOT update cardinality for indexes of InnoDB table". By default we are
+running with the fix disabled because MySQL 5.1 is frozen for such
+behavioral changes. */
+extern char srv_use_legacy_cardinality_algorithm;
+
/* In this structure we store status variables to be passed to MySQL */
typedef struct export_var_struct export_struc;
diff --git a/storage/innobase/include/trx0roll.h b/storage/innobase/include/trx0roll.h
index 25546430ba0..c1eca3d5753 100644
--- a/storage/innobase/include/trx0roll.h
+++ b/storage/innobase/include/trx0roll.h
@@ -15,6 +15,8 @@ Created 3/26/1996 Heikki Tuuri
#include "mtr0mtr.h"
#include "trx0sys.h"
+#define trx_roll_free_all_savepoints(s) trx_roll_savepoints_free((s), NULL)
+
/***********************************************************************
Returns a transaction savepoint taken at this point in time. */
@@ -237,7 +239,17 @@ trx_release_savepoint_for_mysql(
const char* savepoint_name); /* in: savepoint name */
/***********************************************************************
-Frees savepoint structs. */
+Frees a single savepoint struct. */
+
+void
+trx_roll_savepoint_free(
+/*=====================*/
+ trx_t* trx, /* in: transaction handle */
+ trx_named_savept_t* savep); /* in: savepoint to free */
+
+/***********************************************************************
+Frees savepoint structs starting from savep, if savep == NULL then
+free all savepoints. */
void
trx_roll_savepoints_free(
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 5017c15aaf0..f0833bc6f21 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -21,34 +21,6 @@ Created 3/26/1996 Heikki Tuuri
extern ulint trx_n_mysql_transactions;
-/*****************************************************************
-Resets the new record lock info in a transaction struct. */
-UNIV_INLINE
-void
-trx_reset_new_rec_lock_info(
-/*========================*/
- trx_t* trx); /* in: transaction struct */
-/*****************************************************************
-Registers that we have set a new record lock on an index. We only have space
-to store 2 indexes! If this is called to store more than 2 indexes after
-trx_reset_new_rec_lock_info(), then this function does nothing. */
-UNIV_INLINE
-void
-trx_register_new_rec_lock(
-/*======================*/
- trx_t* trx, /* in: transaction struct */
- dict_index_t* index); /* in: trx sets a new record lock on this
- index */
-/*****************************************************************
-Checks if trx has set a new record lock on an index. */
-UNIV_INLINE
-ibool
-trx_new_rec_locks_contain(
-/*======================*/
- /* out: TRUE if trx has set a new record lock
- on index */
- trx_t* trx, /* in: transaction struct */
- dict_index_t* index); /* in: index */
/************************************************************************
Releases the search latch if trx has reserved it. */
@@ -527,20 +499,6 @@ struct trx_struct{
lock_t* auto_inc_lock; /* possible auto-inc lock reserved by
the transaction; note that it is also
in the lock list trx_locks */
- dict_index_t* new_rec_locks[2];/* these are normally NULL; if
- srv_locks_unsafe_for_binlog is TRUE
- or session is using READ COMMITTED
- isolation level,
- in a cursor search, if we set a new
- record lock on an index, this is set
- to point to the index; this is
- used in releasing the locks under the
- cursors if we are performing an UPDATE
- and we determine after retrieving
- the row that it does not need to be
- locked; thus, these can be used to
- implement a 'mini-rollback' that
- releases the latest record locks */
UT_LIST_NODE_T(trx_t)
trx_list; /* list of transactions */
UT_LIST_NODE_T(trx_t)
diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic
index d562db233e9..09b2f822ff7 100644
--- a/storage/innobase/include/trx0trx.ic
+++ b/storage/innobase/include/trx0trx.ic
@@ -38,61 +38,3 @@ trx_start_if_not_started_low(
trx_start_low(trx, ULINT_UNDEFINED);
}
}
-
-/*****************************************************************
-Resets the new record lock info in a transaction struct. */
-UNIV_INLINE
-void
-trx_reset_new_rec_lock_info(
-/*========================*/
- trx_t* trx) /* in: transaction struct */
-{
- trx->new_rec_locks[0] = NULL;
- trx->new_rec_locks[1] = NULL;
-}
-
-/*****************************************************************
-Registers that we have set a new record lock on an index. We only have space
-to store 2 indexes! If this is called to store more than 2 indexes after
-trx_reset_new_rec_lock_info(), then this function does nothing. */
-UNIV_INLINE
-void
-trx_register_new_rec_lock(
-/*======================*/
- trx_t* trx, /* in: transaction struct */
- dict_index_t* index) /* in: trx sets a new record lock on this
- index */
-{
- if (trx->new_rec_locks[0] == NULL) {
- trx->new_rec_locks[0] = index;
-
- return;
- }
-
- if (trx->new_rec_locks[0] == index) {
-
- return;
- }
-
- if (trx->new_rec_locks[1] != NULL) {
-
- return;
- }
-
- trx->new_rec_locks[1] = index;
-}
-
-/*****************************************************************
-Checks if trx has set a new record lock on an index. */
-UNIV_INLINE
-ibool
-trx_new_rec_locks_contain(
-/*======================*/
- /* out: TRUE if trx has set a new record lock
- on index */
- trx_t* trx, /* in: transaction struct */
- dict_index_t* index) /* in: index */
-{
- return(trx->new_rec_locks[0] == index
- || trx->new_rec_locks[1] == index);
-}
diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c
index 173d074cb82..5afd19aa7e7 100644
--- a/storage/innobase/lock/lock0lock.c
+++ b/storage/innobase/lock/lock0lock.c
@@ -681,7 +681,10 @@ lock_is_table_exclusive(
lock_t* lock;
ibool ok = FALSE;
- ut_ad(table && trx);
+ ut_ad(table);
+ ut_ad(trx);
+
+ lock_mutex_enter_kernel();
for (lock = UT_LIST_GET_FIRST(table->locks);
lock;
@@ -689,7 +692,7 @@ lock_is_table_exclusive(
if (lock->trx != trx) {
/* A lock on the table is held
by some other transaction. */
- return(FALSE);
+ goto not_ok;
}
if (!(lock_get_type(lock) & LOCK_TABLE)) {
@@ -706,11 +709,16 @@ lock_is_table_exclusive(
auto_increment lock. */
break;
default:
+not_ok:
/* Other table locks than LOCK_IX are not allowed. */
- return(FALSE);
+ ok = FALSE;
+ goto func_exit;
}
}
+func_exit:
+ lock_mutex_exit_kernel();
+
return(ok);
}
@@ -1962,12 +1970,6 @@ lock_rec_lock_fast(
if (lock == NULL) {
if (!impl) {
lock_rec_create(mode, rec, index, trx);
-
- if (srv_locks_unsafe_for_binlog
- || trx->isolation_level
- == TRX_ISO_READ_COMMITTED) {
- trx_register_new_rec_lock(trx, index);
- }
}
return(TRUE);
@@ -1991,11 +1993,6 @@ lock_rec_lock_fast(
if (!lock_rec_get_nth_bit(lock, heap_no)) {
lock_rec_set_nth_bit(lock, heap_no);
- if (srv_locks_unsafe_for_binlog
- || trx->isolation_level
- == TRX_ISO_READ_COMMITTED) {
- trx_register_new_rec_lock(trx, index);
- }
}
}
@@ -2050,22 +2047,12 @@ lock_rec_lock_slow(
enough already granted on the record, we have to wait. */
err = lock_rec_enqueue_waiting(mode, rec, index, thr);
-
- if (srv_locks_unsafe_for_binlog
- || trx->isolation_level == TRX_ISO_READ_COMMITTED) {
- trx_register_new_rec_lock(trx, index);
- }
} else {
if (!impl) {
/* Set the requested lock on the record */
lock_rec_add_to_queue(LOCK_REC | mode, rec, index,
trx);
- if (srv_locks_unsafe_for_binlog
- || trx->isolation_level
- == TRX_ISO_READ_COMMITTED) {
- trx_register_new_rec_lock(trx, index);
- }
}
err = DB_SUCCESS;
@@ -3664,6 +3651,7 @@ lock_table_has_to_wait_in_queue(
dict_table_t* table;
lock_t* lock;
+ ut_ad(mutex_own(&kernel_mutex));
ut_ad(lock_get_wait(wait_lock));
table = wait_lock->un_member.tab_lock.table;
diff --git a/storage/innobase/page/page0cur.c b/storage/innobase/page/page0cur.c
index a297eb545a0..70b7de194fd 100644
--- a/storage/innobase/page/page0cur.c
+++ b/storage/innobase/page/page0cur.c
@@ -15,6 +15,8 @@ Created 10/4/1994 Heikki Tuuri
#include "mtr0log.h"
#include "log0recv.h"
#include "rem0cmp.h"
+#include "srv0srv.h"
+#include "ut0ut.h"
static ulint page_rnd = 976722341;
@@ -23,6 +25,44 @@ static ulint page_rnd = 976722341;
ulint page_cur_short_succ = 0;
# endif /* UNIV_SEARCH_PERF_STAT */
+/***********************************************************************
+This is a linear congruential generator PRNG. Returns a pseudo random
+number between 0 and 2^64-1 inclusive. The formula and the constants
+being used are:
+X[n+1] = (a * X[n] + c) mod m
+where:
+X[0] = ut_usectime()
+a = 1103515245 (3^5 * 5 * 7 * 129749)
+c = 12345 (3 * 5 * 823)
+m = 18446744073709551616 (2^64)
+*/
+#define LCG_a 1103515245
+#define LCG_c 12345
+static
+unsigned long long
+page_cur_lcg_prng()
+/*===============*/
+ /* out: number between 0 and 2^64-1 */
+{
+ static unsigned long long lcg_current = 0;
+ static ibool initialized = FALSE;
+ ulint time_sec;
+ ulint time_ms;
+
+ if (!initialized) {
+ ut_usectime(&time_sec, &time_ms);
+ lcg_current = (unsigned long long) (time_sec * 1000000
+ + time_ms);
+ initialized = TRUE;
+ }
+
+ /* no need to "% 2^64" explicitly because lcg_current is
+ 64 bit and this will be done anyway */
+ lcg_current = LCG_a * lcg_current + LCG_c;
+
+ return(lcg_current);
+}
+
/********************************************************************
Tries a search shortcut based on the last insert. */
UNIV_INLINE
@@ -493,9 +533,13 @@ page_cur_open_on_rnd_user_rec(
return;
}
- page_rnd += 87584577;
+ if (srv_use_legacy_cardinality_algorithm) {
+ page_rnd += 87584577;
- rnd = page_rnd % page_get_n_recs(page);
+ rnd = page_rnd % page_get_n_recs(page);
+ } else {
+ rnd = (ulint) page_cur_lcg_prng() % page_get_n_recs(page);
+ }
rec = page_get_infimum_rec(page);
@@ -1437,3 +1481,30 @@ page_cur_delete_rec(
page_dir_balance_slot(page, cur_slot_no);
}
}
+
+#ifdef UNIV_COMPILE_TEST_FUNCS
+
+/***********************************************************************
+Print the first n numbers, generated by page_cur_lcg_prng() to make sure
+(visually) that it works properly. */
+void
+test_page_cur_lcg_prng(
+/*===================*/
+ int n) /* in: print first n numbers */
+{
+ int i;
+ unsigned long long rnd;
+
+ for (i = 0; i < n; i++) {
+ rnd = page_cur_lcg_prng();
+ printf("%llu\t%%2=%llu %%3=%llu %%5=%llu %%7=%llu %%11=%llu\n",
+ rnd,
+ rnd % 2,
+ rnd % 3,
+ rnd % 5,
+ rnd % 7,
+ rnd % 11);
+ }
+}
+
+#endif /* UNIV_COMPILE_TEST_FUNCS */
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c
index 088d944cb91..2d9ed4fc944 100644
--- a/storage/innobase/row/row0mysql.c
+++ b/storage/innobase/row/row0mysql.c
@@ -1476,12 +1476,9 @@ row_unlock_for_mysql(
and clust_pcur, and we do not need to
reposition the cursors. */
{
- dict_index_t* index;
btr_pcur_t* pcur = prebuilt->pcur;
btr_pcur_t* clust_pcur = prebuilt->clust_pcur;
trx_t* trx = prebuilt->trx;
- rec_t* rec;
- mtr_t mtr;
ut_ad(prebuilt && trx);
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
@@ -1501,9 +1498,12 @@ row_unlock_for_mysql(
trx->op_info = "unlock_row";
- index = btr_pcur_get_btr_cur(pcur)->index;
+ if (prebuilt->new_rec_locks >= 1) {
- if (index != NULL && trx_new_rec_locks_contain(trx, index)) {
+ rec_t* rec;
+ dict_index_t* index;
+ dulint rec_trx_id;
+ mtr_t mtr;
mtr_start(&mtr);
@@ -1514,43 +1514,64 @@ row_unlock_for_mysql(
}
rec = btr_pcur_get_rec(pcur);
+ index = btr_pcur_get_btr_cur(pcur)->index;
- lock_rec_unlock(trx, rec, prebuilt->select_lock_type);
-
- mtr_commit(&mtr);
+ if (prebuilt->new_rec_locks >= 2) {
+ /* Restore the cursor position and find the record
+ in the clustered index. */
- /* If the search was done through the clustered index, then
- we have not used clust_pcur at all, and we must NOT try to
- reset locks on clust_pcur. The values in clust_pcur may be
- garbage! */
-
- if (index->type & DICT_CLUSTERED) {
+ if (!has_latches_on_recs) {
+ btr_pcur_restore_position(BTR_SEARCH_LEAF,
+ clust_pcur, &mtr);
+ }
- goto func_exit;
+ rec = btr_pcur_get_rec(clust_pcur);
+ index = btr_pcur_get_btr_cur(clust_pcur)->index;
}
- }
- index = btr_pcur_get_btr_cur(clust_pcur)->index;
+ /* If the record has been modified by this
+ transaction, do not unlock it. */
+ ut_a(index->type & DICT_CLUSTERED);
- if (index != NULL && trx_new_rec_locks_contain(trx, index)) {
+ if (index->trx_id_offset) {
+ rec_trx_id = trx_read_trx_id(rec
+ + index->trx_id_offset);
+ } else {
+ mem_heap_t* heap = NULL;
+ ulint offsets_[REC_OFFS_NORMAL_SIZE];
+ ulint* offsets = offsets_;
- mtr_start(&mtr);
+ *offsets_ = (sizeof offsets_) / sizeof *offsets_;
+ offsets = rec_get_offsets(rec, index, offsets,
+ ULINT_UNDEFINED, &heap);
- /* Restore the cursor position and find the record */
+ rec_trx_id = row_get_rec_trx_id(rec, index, offsets);
- if (!has_latches_on_recs) {
- btr_pcur_restore_position(BTR_SEARCH_LEAF, clust_pcur,
- &mtr);
+ if (UNIV_LIKELY_NULL(heap)) {
+ mem_heap_free(heap);
+ }
}
- rec = btr_pcur_get_rec(clust_pcur);
+ if (ut_dulint_cmp(rec_trx_id, trx->id) != 0) {
+ /* We did not update the record: unlock it */
+
+ rec = btr_pcur_get_rec(pcur);
+ index = btr_pcur_get_btr_cur(pcur)->index;
- lock_rec_unlock(trx, rec, prebuilt->select_lock_type);
+ lock_rec_unlock(trx, rec, prebuilt->select_lock_type);
+
+ if (prebuilt->new_rec_locks >= 2) {
+ rec = btr_pcur_get_rec(clust_pcur);
+ index = btr_pcur_get_btr_cur(clust_pcur)->index;
+
+ lock_rec_unlock(trx, rec,
+ prebuilt->select_lock_type);
+ }
+ }
mtr_commit(&mtr);
}
-func_exit:
trx->op_info = "";
return(DB_SUCCESS);
diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c
index 8c3b00a7841..29efb2861b7 100644
--- a/storage/innobase/row/row0sel.c
+++ b/storage/innobase/row/row0sel.c
@@ -2901,8 +2901,9 @@ row_sel_get_clust_rec_for_mysql(
func_exit:
*out_rec = clust_rec;
- if (prebuilt->select_lock_type == LOCK_X) {
- /* We may use the cursor in update: store its position */
+ if (prebuilt->select_lock_type != LOCK_NONE) {
+ /* We may use the cursor in update or in unlock_row():
+ store its position */
btr_pcur_store_position(prebuilt->clust_pcur, mtr);
}
@@ -3303,13 +3304,7 @@ row_search_for_mysql(
is set or session is using a READ COMMITED isolation level. Then
we are able to remove the record locks set here on an individual
row. */
-
- if ((srv_locks_unsafe_for_binlog
- || trx->isolation_level == TRX_ISO_READ_COMMITTED)
- && prebuilt->select_lock_type != LOCK_NONE) {
-
- trx_reset_new_rec_lock_info(trx);
- }
+ prebuilt->new_rec_locks = 0;
/*-------------------------------------------------------------*/
/* PHASE 1: Try to pop the row from the prefetch cache */
@@ -3951,6 +3946,12 @@ no_gap_lock:
switch (err) {
rec_t* old_vers;
case DB_SUCCESS:
+ if (srv_locks_unsafe_for_binlog
+ || trx->isolation_level == TRX_ISO_READ_COMMITTED) {
+ /* Note that a record of
+ prebuilt->index was locked. */
+ prebuilt->new_rec_locks = 1;
+ }
break;
case DB_LOCK_WAIT:
if (UNIV_LIKELY(prebuilt->row_read_type
@@ -3981,7 +3982,7 @@ no_gap_lock:
if (UNIV_LIKELY(trx->wait_lock != NULL)) {
lock_cancel_waiting_and_release(
trx->wait_lock);
- trx_reset_new_rec_lock_info(trx);
+ prebuilt->new_rec_locks = 0;
} else {
mutex_exit(&kernel_mutex);
@@ -3993,6 +3994,9 @@ no_gap_lock:
ULINT_UNDEFINED,
&heap);
err = DB_SUCCESS;
+ /* Note that a record of
+ prebuilt->index was locked. */
+ prebuilt->new_rec_locks = 1;
break;
}
mutex_exit(&kernel_mutex);
@@ -4142,6 +4146,15 @@ requires_clust_rec:
goto next_rec;
}
+ if ((srv_locks_unsafe_for_binlog
+ || trx->isolation_level == TRX_ISO_READ_COMMITTED)
+ && prebuilt->select_lock_type != LOCK_NONE) {
+ /* Note that both the secondary index record
+ and the clustered index record were locked. */
+ ut_ad(prebuilt->new_rec_locks == 1);
+ prebuilt->new_rec_locks = 2;
+ }
+
if (UNIV_UNLIKELY(rec_get_deleted_flag(clust_rec, comp))) {
/* The record is delete marked: we can skip it */
@@ -4267,13 +4280,7 @@ next_rec:
prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT;
}
did_semi_consistent_read = FALSE;
-
- if (UNIV_UNLIKELY(srv_locks_unsafe_for_binlog
- || trx->isolation_level == TRX_ISO_READ_COMMITTED)
- && prebuilt->select_lock_type != LOCK_NONE) {
-
- trx_reset_new_rec_lock_info(trx);
- }
+ prebuilt->new_rec_locks = 0;
/*-------------------------------------------------------------*/
/* PHASE 5: Move the cursor to the next index record */
@@ -4379,7 +4386,7 @@ lock_wait_or_error:
rec_loop we will again try to set a lock, and
new_rec_lock_info in trx will be right at the end. */
- trx_reset_new_rec_lock_info(trx);
+ prebuilt->new_rec_locks = 0;
}
mode = pcur->search_mode;
diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
index e0fe6f40197..958c48ca91c 100644
--- a/storage/innobase/srv/srv0srv.c
+++ b/storage/innobase/srv/srv0srv.c
@@ -265,6 +265,12 @@ ulint srv_read_ahead_seq = 0;
/* variable to count the number of random read-aheads */
ulint srv_read_ahead_rnd = 0;
+/* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
+NOT update cardinality for indexes of InnoDB table". By default we are
+running with the fix disabled because MySQL 5.1 is frozen for such
+behavioral changes. */
+char srv_use_legacy_cardinality_algorithm = TRUE;
+
/* structure to pass status variables to MySQL */
export_struc export_vars;
diff --git a/storage/innobase/trx/trx0roll.c b/storage/innobase/trx/trx0roll.c
index 91dcf035f96..8934fe87c7e 100644
--- a/storage/innobase/trx/trx0roll.c
+++ b/storage/innobase/trx/trx0roll.c
@@ -185,7 +185,25 @@ trx_rollback_last_sql_stat_for_mysql(
}
/***********************************************************************
-Frees savepoint structs. */
+Frees a single savepoint struct. */
+
+void
+trx_roll_savepoint_free(
+/*=====================*/
+ trx_t* trx, /* in: transaction handle */
+ trx_named_savept_t* savep) /* in: savepoint to free */
+{
+ ut_a(savep != NULL);
+ ut_a(UT_LIST_GET_LEN(trx->trx_savepoints) > 0);
+
+ UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
+ mem_free(savep->name);
+ mem_free(savep);
+}
+
+/***********************************************************************
+Frees savepoint structs starting from savep, if savep == NULL then
+free all savepoints. */
void
trx_roll_savepoints_free(
@@ -206,9 +224,7 @@ trx_roll_savepoints_free(
while (savep != NULL) {
next_savep = UT_LIST_GET_NEXT(trx_savepoints, savep);
- UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
- mem_free(savep->name);
- mem_free(savep);
+ trx_roll_savepoint_free(trx, savep);
savep = next_savep;
}
@@ -343,8 +359,8 @@ trx_savepoint_for_mysql(
}
/***********************************************************************
-Releases a named savepoint. Savepoints which
-were set after this savepoint are deleted. */
+Releases only the named savepoint. Savepoints which were set after this
+savepoint are left as is. */
ulint
trx_release_savepoint_for_mysql(
@@ -360,31 +376,16 @@ trx_release_savepoint_for_mysql(
savep = UT_LIST_GET_FIRST(trx->trx_savepoints);
+ /* Search for the savepoint by name and free if found. */
while (savep != NULL) {
if (0 == ut_strcmp(savep->name, savepoint_name)) {
- /* Found */
- break;
+ trx_roll_savepoint_free(trx, savep);
+ return(DB_SUCCESS);
}
savep = UT_LIST_GET_NEXT(trx_savepoints, savep);
}
- if (savep == NULL) {
-
- return(DB_NO_SAVEPOINT);
- }
-
- /* We can now free all savepoints strictly later than this one */
-
- trx_roll_savepoints_free(trx, savep);
-
- /* Now we can free this savepoint too */
-
- UT_LIST_REMOVE(trx_savepoints, trx->trx_savepoints, savep);
-
- mem_free(savep->name);
- mem_free(savep);
-
- return(DB_SUCCESS);
+ return(DB_NO_SAVEPOINT);
}
/***********************************************************************
diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c
index 1fceaa3562c..8ada38845c5 100644
--- a/storage/innobase/trx/trx0trx.c
+++ b/storage/innobase/trx/trx0trx.c
@@ -192,8 +192,6 @@ trx_create(
trx->n_autoinc_rows = 0;
- trx_reset_new_rec_lock_info(trx);
-
return(trx);
}
@@ -930,8 +928,8 @@ trx_commit_off_kernel(
mutex_enter(&kernel_mutex);
}
- /* Free savepoints */
- trx_roll_savepoints_free(trx, NULL);
+ /* Free all savepoints */
+ trx_roll_free_all_savepoints(trx);
trx->conc_state = TRX_NOT_STARTED;
trx->rseg = NULL;
diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt
index 4436c8fa7c4..fdc0b64f86a 100755
--- a/storage/myisam/CMakeLists.txt
+++ b/storage/myisam/CMakeLists.txt
@@ -51,6 +51,8 @@ IF(NOT SOURCE_SUBLIBS)
ADD_EXECUTABLE(myisampack myisampack.c)
TARGET_LINK_LIBRARIES(myisampack myisam mysys debug dbug strings zlib wsock32)
+ SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj")
+
IF(EMBED_MANIFESTS)
MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker")
MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker")
diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c
index 66097864622..58363894cff 100644
--- a/storage/myisam/ft_boolean_search.c
+++ b/storage/myisam/ft_boolean_search.c
@@ -335,7 +335,23 @@ static int _ftb_no_dupes_cmp(void* not_used __attribute__((unused)),
return CMP_NUM((*((my_off_t*)a)), (*((my_off_t*)b)));
}
-/* returns 1 if the search was finished (must-word wasn't found) */
+/*
+ When performing prefix search (a word with truncation operator), we
+ must preserve original prefix to ensure that characters which may be
+ expanded/contracted do not break the prefix. This is done by storing
+ newly found key immediatly after the original word in ftbw->word
+ buffer.
+
+ ftbw->word= LENGTH WORD [ LENGTH1 WORD1 ] WEIGHT REFERENCE
+ LENGTH - 1 byte, length of the WORD
+ WORD - LENGTH bytes, the word itself
+ LENGTH1 - 1 byte, length of the WORD1, present in case of prefix search
+ WORD1 - LENGTH bytes, the word itself, present in case of prefix search
+ WEIGHT - 4 bytes (HA_FT_WLEN), either weight or number of subkeys
+ REFERENCE - rec_reflength bytes, pointer to the record
+
+ returns 1 if the search was finished (must-word wasn't found)
+*/
static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
{
int r;
@@ -369,7 +385,8 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
if (ftbw->docid[0] < max_docid)
{
sflag|= SEARCH_SAME;
- _mi_dpointer(info, (uchar *)(ftbw->word + ftbw->len + HA_FT_WLEN),
+ _mi_dpointer(info, (uchar*) (lastkey_buf + HA_FT_WLEN +
+ (ftbw->off ? 0 : lastkey_buf[0] + 1)),
max_docid);
}
r=_mi_search(info, ftbw->keyinfo, (uchar*) lastkey_buf,
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index c6411a6a273..c14aa2254a3 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -44,6 +44,28 @@ TYPELIB myisam_stats_method_typelib= {
array_elements(myisam_stats_method_names) - 1, "",
myisam_stats_method_names, NULL};
+#ifndef DBUG_OFF
+/**
+ Causes the thread to wait in a spin lock for a query kill signal.
+ This function is used by the test frame work to identify race conditions.
+
+ The signal is caught and ignored and the thread is not killed.
+*/
+
+static void debug_wait_for_kill(const char *info)
+{
+ DBUG_ENTER("debug_wait_for_kill");
+ const char *prev_info;
+ THD *thd;
+ thd= current_thd;
+ prev_info= thd_proc_info(thd, info);
+ while(!thd->killed)
+ my_sleep(1000);
+ DBUG_PRINT("info", ("Exit debug_wait_for_kill"));
+ thd_proc_info(thd, prev_info);
+ DBUG_VOID_RETURN;
+}
+#endif
/*****************************************************************************
** MyISAM tables
@@ -63,7 +85,7 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
{
THD* thd = (THD*)param->thd;
Protocol *protocol= thd->protocol;
- uint length, msg_length;
+ size_t length, msg_length;
char msgbuf[MI_MAX_MSG_BUF];
char name[NAME_LEN*2+2];
@@ -316,6 +338,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
t2_keys in Number of keys in second table
t2_recs in Number of records in second table
strict in Strict check switch
+ table in handle to the table object
DESCRIPTION
This function compares two MyISAM definitions. By intention it was done
@@ -331,6 +354,10 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
Otherwise 'strict' flag must be set to 1 and it is not required to pass
converted dot-frm definition as t1_*.
+ For compatibility reasons we relax some checks, specifically:
+ - 4.0 (and earlier versions) always set key_alg to 0.
+ - 4.0 (and earlier versions) have the same language for all keysegs.
+
RETURN VALUE
0 - Equal definitions.
1 - Different definitions.
@@ -345,10 +372,11 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
- uint t2_keys, uint t2_recs, bool strict)
+ uint t2_keys, uint t2_recs, bool strict, TABLE *table_arg)
{
uint i, j;
DBUG_ENTER("check_definition");
+ my_bool mysql_40_compat= table_arg && table_arg->s->frm_version < FRM_VER_TRUE_VARCHAR;
if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys))
{
DBUG_PRINT("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u",
@@ -387,8 +415,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
test(t2_keyinfo[i].flag & HA_SPATIAL)));
DBUG_RETURN(1);
}
- if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs ||
- t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg)
+ if ((!mysql_40_compat &&
+ t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) ||
+ t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs)
{
DBUG_PRINT("error", ("Key %d has different definition", i));
DBUG_PRINT("error", ("t1_keysegs=%d, t1_key_alg=%d",
@@ -418,8 +447,9 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; /* purecov: inspected */
}
- if (t1_keysegs_j__type != t2_keysegs[j].type ||
- t1_keysegs[j].language != t2_keysegs[j].language ||
+ if ((!mysql_40_compat &&
+ t1_keysegs[j].language != t2_keysegs[j].language) ||
+ t1_keysegs_j__type != t2_keysegs[j].type ||
t1_keysegs[j].null_bit != t2_keysegs[j].null_bit ||
t1_keysegs[j].length != t2_keysegs[j].length)
{
@@ -672,7 +702,8 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked)
}
if (check_definition(keyinfo, recinfo, table->s->keys, recs,
file->s->keyinfo, file->s->rec,
- file->s->base.keys, file->s->base.fields, true))
+ file->s->base.keys, file->s->base.fields,
+ true, table))
{
/* purecov: begin inspected */
my_errno= HA_ERR_CRASHED;
@@ -1390,6 +1421,9 @@ int ha_myisam::enable_indexes(uint mode)
{
int error;
+ DBUG_EXECUTE_IF("wait_in_enable_indexes",
+ debug_wait_for_kill("wait_in_enable_indexes"); );
+
if (mi_is_all_keys_active(file->s->state.key_map, file->s->base.keys))
{
/* All indexes are enabled already. */
@@ -1503,8 +1537,9 @@ void ha_myisam::start_bulk_insert(ha_rows rows)
/*
Only disable old index if the table was empty and we are inserting
a lot of rows.
- We should not do this for only a few rows as this is slower and
- we don't want to update the key statistics based of only a few rows.
+ Note that in end_bulk_insert() we may truncate the table if
+ enable_indexes() failed, thus it's essential that indexes are
+ disabled ONLY for an empty table.
*/
if (file->state->records == 0 && can_enable_indexes &&
(!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
@@ -1536,8 +1571,27 @@ int ha_myisam::end_bulk_insert()
{
mi_end_bulk_insert(file);
int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0);
- return err ? err : can_enable_indexes ?
- enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) : 0;
+ if (!err)
+ {
+ if (can_enable_indexes)
+ {
+ /*
+ Truncate the table when enable index operation is killed.
+ After truncating the table we don't need to enable the
+ indexes, because the last repair operation is aborted after
+ setting the indexes as active and trying to recreate them.
+ */
+
+ if (((err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) &&
+ current_thd->killed)
+ {
+ delete_all_rows();
+ /* not crashed, despite being killed during repair */
+ file->s->state.changed&= ~(STATE_CRASHED|STATE_CRASHED_ON_REPAIR);
+ }
+ }
+ }
+ return err;
}
@@ -1561,7 +1615,7 @@ bool ha_myisam::check_and_repair(THD *thd)
old_query_length= thd->query_length;
pthread_mutex_lock(&LOCK_thread_count);
thd->query= table->s->table_name.str;
- thd->query_length= table->s->table_name.length;
+ thd->query_length= (uint) table->s->table_name.length;
pthread_mutex_unlock(&LOCK_thread_count);
if ((marked_crashed= mi_is_crashed(file)) || check(thd, &check_opt))
@@ -1779,7 +1833,7 @@ int ha_myisam::info(uint flag)
if (share->key_parts)
memcpy((char*) table->key_info[0].rec_per_key,
(char*) misam_info.rec_per_key,
- sizeof(table->key_info[0].rec_per_key)*share->key_parts);
+ sizeof(table->key_info[0].rec_per_key[0])*share->key_parts);
if (share->tmp_table == NO_TMP_TABLE)
pthread_mutex_unlock(&share->mutex);
@@ -1815,6 +1869,8 @@ int ha_myisam::extra(enum ha_extra_function operation)
{
if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_KEYREAD)
return 0;
+ if (operation == HA_EXTRA_MMAP && !opt_myisam_use_mmap)
+ return 0;
return mi_extra(file, operation, 0);
}
@@ -2178,6 +2234,15 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name,
}
}
+ /*
+ This query execution might have started after the query cache was flushed
+ by a concurrent INSERT. In this case, don't cache this statement as the
+ data file length difference might not be visible yet if the tables haven't
+ been unlocked by the concurrent insert thread.
+ */
+ if (file->state->uncacheable)
+ DBUG_RETURN(FALSE);
+
/* It is ok to try to cache current statement. */
DBUG_RETURN(TRUE);
}
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index bdca1a1f0b8..535b4f7f537 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -660,7 +660,7 @@ void mi_collect_stats_nonulls_first(HA_KEYSEG *keyseg, ulonglong *notnull,
uchar *key)
{
uint first_null, kp;
- first_null= ha_find_null(keyseg, key) - keyseg;
+ first_null= (uint) (ha_find_null(keyseg, key) - keyseg);
/*
All prefix tuples that don't include keypart_{first_null} are not-null
tuples (and all others aren't), increment counters for them.
@@ -716,7 +716,7 @@ int mi_collect_stats_nonulls_next(HA_KEYSEG *keyseg, ulonglong *notnull,
seg= keyseg + diffs[0] - 1;
/* Find first NULL in last_key */
- first_null_seg= ha_find_null(seg, last_key + diffs[1]) - keyseg;
+ first_null_seg= (uint) (ha_find_null(seg, last_key + diffs[1]) - keyseg);
for (kp= 0; kp < first_null_seg; kp++)
notnull[kp]++;
@@ -3952,7 +3952,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a)
key_block++;
sort_info->key_block=key_block;
sort_param->keyinfo=& sort_info->info->s->ft2_keyinfo;
- ft_buf->count=(ft_buf->buf - p)/val_len;
+ ft_buf->count=(uint) (ft_buf->buf - p)/val_len;
/* flushing buffer to second-level tree */
for (error=0; !error && p < ft_buf->buf; p+= val_len)
diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c
index 07105aea88d..2066d092e1f 100644
--- a/storage/myisam/mi_close.c
+++ b/storage/myisam/mi_close.c
@@ -35,9 +35,6 @@ int mi_close(register MI_INFO *info)
if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
- if (share->reopen == 1 && share->kfile >= 0)
- _mi_decrement_open_count(info);
-
if (info->lock_type != F_UNLCK)
{
if (mi_lock_database(info,F_UNLCK))
@@ -63,6 +60,8 @@ int mi_close(register MI_INFO *info)
my_free(mi_get_rec_buff_ptr(info, info->rec_buff), MYF(MY_ALLOW_ZERO_PTR));
if (flag)
{
+ DBUG_EXECUTE_IF("crash_before_flush_keys",
+ if (share->kfile >= 0) abort(););
if (share->kfile >= 0 &&
flush_key_blocks(share->key_cache, share->kfile,
share->temporary ? FLUSH_IGNORE_CHANGED :
@@ -78,6 +77,8 @@ int mi_close(register MI_INFO *info)
*/
if (share->mode != O_RDONLY && mi_is_crashed(info))
mi_state_info_write(share->kfile, &share->state, 1);
+ /* Decrement open count must be last I/O on this file. */
+ _mi_decrement_open_count(info);
if (my_close(share->kfile,MYF(0)))
error = my_errno;
}
diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c
index 6fe31f30c19..aa09216ce89 100644
--- a/storage/myisam/mi_delete.c
+++ b/storage/myisam/mi_delete.c
@@ -250,7 +250,11 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo,
if (info->ft1_to_ft2)
{
/* we're in ft1->ft2 conversion mode. Saving key data */
- insert_dynamic(info->ft1_to_ft2, (lastkey+off));
+ if (insert_dynamic(info->ft1_to_ft2, (lastkey+off)))
+ {
+ DBUG_PRINT("error",("Out of memory"));
+ DBUG_RETURN(-1);
+ }
}
else
{
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 3433c26f98b..d1cbd6955dd 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -66,7 +66,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
{
DBUG_ENTER("mi_dynmap_file");
- if (size > (my_off_t) (~((size_t) 0)) - MEMMAP_EXTRA_MARGIN)
+ if (size > (my_off_t) (~((size_t) 0)))
{
DBUG_PRINT("warning", ("File is too large for mmap"));
DBUG_RETURN(1);
@@ -80,7 +80,7 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
upon a write if no physical memory is available.
*/
info->s->file_map= (uchar*)
- my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN),
+ my_mmap(0, (size_t) size,
info->s->mode==O_RDONLY ? PROT_READ :
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NORESERVE,
@@ -113,7 +113,7 @@ void mi_remap_file(MI_INFO *info, my_off_t size)
if (info->s->file_map)
{
VOID(my_munmap((char*) info->s->file_map,
- (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN));
+ (size_t) info->s->mmaped_length));
mi_dynmap_file(info, size);
}
}
diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c
index ec359d13a14..6a4c21160f4 100644
--- a/storage/myisam/mi_locking.c
+++ b/storage/myisam/mi_locking.c
@@ -293,6 +293,8 @@ void mi_get_status(void* param, int concurrent_insert)
info->save_state=info->s->state.state;
info->state= &info->save_state;
info->append_insert_at_end= concurrent_insert;
+ if (concurrent_insert)
+ info->s->state.state.uncacheable= TRUE;
DBUG_VOID_RETURN;
}
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index 78749d50fe5..328cde20923 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -1160,7 +1160,8 @@ uchar *mi_keyseg_read(uchar *ptr, HA_KEYSEG *keyseg)
keyseg->null_pos = mi_uint4korr(ptr); ptr +=4;
keyseg->charset=0; /* Will be filled in later */
if (keyseg->null_bit)
- keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == 7));
+ /* We adjust bit_pos if null_bit is last in the byte */
+ keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == (1 << 7)));
else
{
keyseg->bit_pos= (uint16)keyseg->null_pos;
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index 2c4444d67c6..d9abcbce050 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -209,10 +209,17 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
This segment will be reallocated after construction of the tables.
*/
length=(uint) (elements*2+trees*(1 << myisam_quick_table_bits));
+ /*
+ To keep some algorithms simpler, we accept that they access
+ bytes beyond the end of the input data. This can affect up to
+ one byte less than the "word size" size used in this file,
+ which is BITS_SAVED / 8. To avoid accessing non-allocated
+ data, we add (BITS_SAVED / 8) - 1 bytes to the buffer size.
+ */
if (!(share->decode_tables=(uint16*)
my_malloc((length + OFFSET_TABLE_SIZE) * sizeof(uint16) +
- (uint) (share->pack.header_length - sizeof(header)),
- MYF(MY_WME | MY_ZEROFILL))))
+ (uint) (share->pack.header_length - sizeof(header) +
+ (BITS_SAVED / 8) - 1), MYF(MY_WME | MY_ZEROFILL))))
goto err1;
tmp_buff=share->decode_tables+length;
disk_cache= (uchar*) (tmp_buff+OFFSET_TABLE_SIZE);
@@ -255,7 +262,7 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
MYF(MY_HOLD_ON_ERROR));
/* Fix the table addresses in the tree heads. */
{
- long diff=PTR_BYTE_DIFF(decode_table,share->decode_tables);
+ my_ptrdiff_t diff=PTR_BYTE_DIFF(decode_table,share->decode_tables);
share->decode_tables=decode_table;
for (i=0 ; i < trees ; i++)
share->decode_trees[i].table=ADD_TO_PTR(share->decode_trees[i].table,
@@ -1431,6 +1438,7 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff)
bit_buff->current_byte=0;
return;
}
+
#if BITS_SAVED == 64
bit_buff->current_byte= ((((uint) ((uchar) bit_buff->pos[7]))) +
(((uint) ((uchar) bit_buff->pos[6])) << 8) +
@@ -1494,7 +1502,9 @@ my_bool _mi_memmap_file(MI_INFO *info)
DBUG_PRINT("warning",("File isn't extended for memmap"));
DBUG_RETURN(0);
}
- if (mi_dynmap_file(info, share->state.state.data_file_length))
+ if (mi_dynmap_file(info,
+ share->state.state.data_file_length +
+ MEMMAP_EXTRA_MARGIN))
DBUG_RETURN(0);
}
info->opt_flag|= MEMMAP_USED;
diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c
index 89fabfa46d0..1dd6c6b5f0d 100644
--- a/storage/myisam/mi_search.c
+++ b/storage/myisam/mi_search.c
@@ -409,7 +409,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
}
from+=keyseg->length;
page=from+nod_flag;
- length=from-vseg;
+ length= (uint) (from - vseg);
}
if (page > end)
diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c
index be67b7a5982..91cc146e706 100644
--- a/storage/myisam/mi_write.c
+++ b/storage/myisam/mi_write.c
@@ -562,7 +562,14 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo,
we cannot easily dispatch an empty page here */
b+=blen+ft2len+2;
for (a=anc_buff+a_length ; b < a ; b+=ft2len+2)
- insert_dynamic(info->ft1_to_ft2, b);
+ {
+ if (insert_dynamic(info->ft1_to_ft2, b))
+ {
+ mi_print_error(info->s, HA_ERR_OUT_OF_MEM);
+ my_errno= HA_ERR_OUT_OF_MEM;
+ DBUG_RETURN(-1);
+ }
+ }
/* fixing the page's length - it contains only one key now */
mi_putint(anc_buff,2+blen+ft2len+2,0);
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index f8fcdcb6fab..ac0be2f01cc 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -363,6 +363,7 @@ static void usage(void)
-#, --debug=... Output debug log. Often this is 'd:t:o,filename'.\n");
#endif
printf("\
+ -H, --HELP Display this help and exit.\n\
-?, --help Display this help and exit.\n\
-O, --set-variable var=option.\n\
Change the value of a variable. Please note that\n\
@@ -1305,7 +1306,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, char * name)
share->base.max_key_file_length != HA_OFFSET_ERROR)
printf("Max datafile length: %13s Max keyfile length: %13s\n",
llstr(share->base.max_data_file_length-1,llbuff),
- llstr(share->base.max_key_file_length-1,llbuff2));
+ ullstr(share->base.max_key_file_length - 1, llbuff2));
}
}
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index 9af3f652c5f..b64c7f6bd7f 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -38,6 +38,7 @@ typedef struct st_mi_status_info
my_off_t key_file_length;
my_off_t data_file_length;
ha_checksum checksum;
+ my_bool uncacheable; /* Active concurrent insert */
} MI_STATUS_INFO;
typedef struct st_mi_state_info
diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c
index 0b472f4fb0e..e094c302f92 100644
--- a/storage/myisam/rt_index.c
+++ b/storage/myisam/rt_index.c
@@ -95,7 +95,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag,
_mi_kpos(nod_flag, k), level + 1)))
{
case 0: /* found - exit from recursion */
- *saved_key = k - page_buf;
+ *saved_key = (uint) (k - page_buf);
goto ok;
case 1: /* not found - continue searching */
info->rtree_recursion_depth = level;
@@ -117,7 +117,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag,
info->lastkey_length = k_len + info->s->base.rec_reflength;
memcpy(info->lastkey, k, info->lastkey_length);
info->rtree_recursion_depth = level;
- *saved_key = last - page_buf;
+ *saved_key = (uint) (last - page_buf);
if (after_key < last)
{
@@ -314,7 +314,7 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length,
_mi_kpos(nod_flag, k), level + 1)))
{
case 0: /* found - exit from recursion */
- *saved_key = k - page_buf;
+ *saved_key = (uint) (k - page_buf);
goto ok;
case 1: /* not found - continue searching */
info->rtree_recursion_depth = level;
@@ -333,7 +333,7 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length,
memcpy(info->lastkey, k, info->lastkey_length);
info->rtree_recursion_depth = level;
- *saved_key = k - page_buf;
+ *saved_key = (uint) (k - page_buf);
if (after_key < last)
{
@@ -420,7 +420,7 @@ int rtree_get_next(MI_INFO *info, uint keynr, uint key_length)
info->lastkey_length = k_len + info->s->base.rec_reflength;
memcpy(info->lastkey, key, k_len + info->s->base.rec_reflength);
- *(int*)info->int_keypos = key - info->buff;
+ *(uint*)info->int_keypos = (uint) (key - info->buff);
if (after_key >= info->int_maxpos)
{
info->buff_used = 1;
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index 999dcf00b93..492bc15f749 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -117,7 +117,7 @@ static handler *myisammrg_create_handler(handlerton *hton,
*/
ha_myisammrg::ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg)
- :handler(hton, table_arg), file(0)
+ :handler(hton, table_arg), file(0), is_cloned(0)
{}
@@ -138,7 +138,8 @@ extern int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
- uint t2_keys, uint t2_recs, bool strict);
+ uint t2_keys, uint t2_recs, bool strict,
+ TABLE *table_arg);
static void split_file_name(const char *file_name,
LEX_STRING *db, LEX_STRING *name);
@@ -219,7 +220,7 @@ static int myisammrg_parent_open_callback(void *callback_param,
TABLE_LIST *child_l;
const char *db;
const char *table_name;
- uint dirlen;
+ size_t dirlen;
char dir_path[FN_REFLEN];
DBUG_ENTER("myisammrg_parent_open_callback");
@@ -414,7 +415,28 @@ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)),
/* retrieve children table list. */
my_errno= 0;
- if (!(file= myrg_parent_open(name, myisammrg_parent_open_callback, this)))
+ if (is_cloned)
+ {
+ /*
+ Open and attaches the MyISAM tables,that are under the MERGE table
+ parent, on the MyISAM storage engine interface directly within the
+ MERGE engine. The new MyISAM table instances, as well as the MERGE
+ clone itself, are not visible in the table cache. This is not a
+ problem because all locking is handled by the original MERGE table
+ from which this is cloned of.
+ */
+ if (!(file= myrg_open(table->s->normalized_path.str, table->db_stat,
+ HA_OPEN_IGNORE_IF_LOCKED)))
+ {
+ DBUG_PRINT("error", ("my_errno %d", my_errno));
+ DBUG_RETURN(my_errno ? my_errno : -1);
+ }
+
+ file->children_attached= TRUE;
+
+ info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
+ }
+ else if (!(file= myrg_parent_open(name, myisammrg_parent_open_callback, this)))
{
DBUG_PRINT("error", ("my_errno %d", my_errno));
DBUG_RETURN(my_errno ? my_errno : -1);
@@ -423,6 +445,55 @@ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)),
DBUG_RETURN(0);
}
+/**
+ Returns a cloned instance of the current handler.
+
+ @return A cloned handler instance.
+ */
+handler *ha_myisammrg::clone(MEM_ROOT *mem_root)
+{
+ MYRG_TABLE *u_table,*newu_table;
+ ha_myisammrg *new_handler=
+ (ha_myisammrg*) get_new_handler(table->s, mem_root, table->s->db_type());
+ if (!new_handler)
+ return NULL;
+
+ /* Inform ha_myisammrg::open() that it is a cloned handler */
+ new_handler->is_cloned= TRUE;
+ /*
+ Allocate handler->ref here because otherwise ha_open will allocate it
+ on this->table->mem_root and we will not be able to reclaim that memory
+ when the clone handler object is destroyed.
+ */
+ if (!(new_handler->ref= (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2)))
+ {
+ delete new_handler;
+ return NULL;
+ }
+
+ if (new_handler->ha_open(table, table->s->normalized_path.str, table->db_stat,
+ HA_OPEN_IGNORE_IF_LOCKED))
+ {
+ delete new_handler;
+ return NULL;
+ }
+
+ /*
+ Iterate through the original child tables and
+ copy the state into the cloned child tables.
+ We need to do this because all the child tables
+ can be involved in delete.
+ */
+ newu_table= new_handler->file->open_tables;
+ for (u_table= file->open_tables; u_table < file->end_table; u_table++)
+ {
+ newu_table->table->state= u_table->table->state;
+ newu_table++;
+ }
+
+ return new_handler;
+ }
+
/**
@brief Attach children to a MERGE table.
@@ -526,7 +597,7 @@ int ha_myisammrg::attach_children(void)
if (check_definition(keyinfo, recinfo, keys, recs,
u_table->table->s->keyinfo, u_table->table->s->rec,
u_table->table->s->base.keys,
- u_table->table->s->base.fields, false))
+ u_table->table->s->base.fields, false, NULL))
{
DBUG_PRINT("error", ("table definition mismatch: '%s'",
u_table->table->filename));
@@ -614,9 +685,10 @@ int ha_myisammrg::close(void)
DBUG_ENTER("ha_myisammrg::close");
/*
Children must not be attached here. Unless the MERGE table has no
- children. In this case children_attached is always true.
+ children or the handler instance has been cloned. In these cases
+ children_attached is always true.
*/
- DBUG_ASSERT(!this->file->children_attached || !this->file->tables);
+ DBUG_ASSERT(!this->file->children_attached || !this->file->tables || this->is_cloned);
rc= myrg_close(file);
file= 0;
DBUG_RETURN(rc);
@@ -824,6 +896,16 @@ int ha_myisammrg::info(uint flag)
table->s->crashed= 1;
#endif
stats.data_file_length= mrg_info.data_file_length;
+ if (mrg_info.errkey >= (int) table_share->keys)
+ {
+ /*
+ If value of errkey is higher than the number of keys
+ on the table set errkey to MAX_KEY. This will be
+ treated as unknown key case and error message generator
+ won't try to locate key causing segmentation fault.
+ */
+ mrg_info.errkey= MAX_KEY;
+ }
errkey= mrg_info.errkey;
table->s->keys_in_use.set_prefix(table->s->keys);
stats.mean_rec_length= mrg_info.reclength;
@@ -984,7 +1066,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
static void split_file_name(const char *file_name,
LEX_STRING *db, LEX_STRING *name)
{
- uint dir_length, prefix_length;
+ size_t dir_length, prefix_length;
char buff[FN_REFLEN];
db->length= 0;
@@ -1057,7 +1139,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
const char **table_names, **pos;
TABLE_LIST *tables= (TABLE_LIST*) create_info->merge_list.first;
THD *thd= current_thd;
- uint dirlgt= dirname_length(name);
+ size_t dirlgt= dirname_length(name);
DBUG_ENTER("ha_myisammrg::create");
/* Allocate a table_names array in thread mem_root. */
@@ -1116,7 +1198,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
void ha_myisammrg::append_create_info(String *packet)
{
const char *current_db;
- uint db_length;
+ size_t db_length;
THD *thd= current_thd;
MYRG_TABLE *open_table, *first;
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index 4e7ddebb836..21d41c9d75a 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -25,6 +25,7 @@
class ha_myisammrg: public handler
{
MYRG_INFO *file;
+ my_bool is_cloned; /* This instance has been cloned */
public:
TABLE_LIST *next_child_attach; /* next child to attach */
@@ -60,6 +61,7 @@ class ha_myisammrg: public handler
int open(const char *name, int mode, uint test_if_locked);
int attach_children(void);
int detach_children(void);
+ virtual handler *clone(MEM_ROOT *mem_root);
int close(void);
int write_row(uchar * buf);
int update_row(const uchar * old_data, uchar * new_data);
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c
index 64b4be2b7ca..14ba2853b22 100644
--- a/storage/myisammrg/myrg_open.c
+++ b/storage/myisammrg/myrg_open.c
@@ -33,7 +33,6 @@
myrg_attach_children(). Please duplicate changes in these
functions or make common sub-functions.
*/
-/* purecov: begin deadcode */ /* not used in MySQL server */
MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
{
@@ -198,7 +197,6 @@ err:
my_errno=save_errno;
DBUG_RETURN (NULL);
}
-/* purecov: end */
/**
@@ -428,10 +426,11 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
if (!m_info->rec_per_key_part)
{
if(!(m_info->rec_per_key_part= (ulong*)
- my_malloc(key_parts * sizeof(long), MYF(MY_WME|MY_ZEROFILL))))
+ my_malloc(key_parts * sizeof(long), MYF(MY_WME))))
goto err; /* purecov: inspected */
errpos= 1;
}
+ bzero((char*) m_info->rec_per_key_part, key_parts * sizeof(long));
}
/* Add MyISAM table info. */
diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp
index 89f680a80e4..e8e8d584f09 100644
--- a/storage/ndb/tools/restore/consumer_restore.cpp
+++ b/storage/ndb/tools/restore/consumer_restore.cpp
@@ -1375,7 +1375,7 @@ BackupRestore::logEntry(const LogEntry & tup)
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
- // Deep shit, TODO: handle the error
+ // TODO: handle the error
err << "Cannot start transaction" << endl;
exitHandler();
} // if
@@ -1524,7 +1524,7 @@ BackupRestore::tuple(const TupleS & tup)
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
- // Deep shit, TODO: handle the error
+ // TODO: handle the error
ndbout << "Cannot start transaction" << endl;
exitHandler();
} // if
diff --git a/storage/ndb/tools/restore/consumer_restorem.cpp b/storage/ndb/tools/restore/consumer_restorem.cpp
index 946012ee98e..233f8d5fe98 100644
--- a/storage/ndb/tools/restore/consumer_restorem.cpp
+++ b/storage/ndb/tools/restore/consumer_restorem.cpp
@@ -374,7 +374,7 @@ BackupRestore::tuple(const TupleS & tup)
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
- // Deep shit, TODO: handle the error
+ // TODO: handle the error
ndbout << "Cannot start transaction" << endl;
exit(-1);
} // if
@@ -463,7 +463,7 @@ BackupRestore::logEntry(const LogEntry & tup)
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
- // Deep shit, TODO: handle the error
+ // TODO: handle the error
ndbout << "Cannot start transaction" << endl;
exit(-1);
} // if
diff --git a/strings/Makefile.am b/strings/Makefile.am
index b3792d308c4..ddd41e627dc 100644
--- a/strings/Makefile.am
+++ b/strings/Makefile.am
@@ -53,7 +53,8 @@ EXTRA_DIST = ctype-big5.c ctype-cp932.c ctype-czech.c ctype-eucjpms.c ctype-euc
bmove_upp-sparc.s strappend-sparc.s strend-sparc.s \
strinstr-sparc.s strmake-sparc.s strmov-sparc.s \
strnmov-sparc.s strstr-sparc.s strxmov-sparc.s \
- t_ctype.h my_strchr.c CMakeLists.txt
+ t_ctype.h my_strchr.c CMakeLists.txt \
+ CHARSET_INFO.txt
libmystrings_a_LIBADD=
conf_to_src_SOURCES = conf_to_src.c xml.c ctype.c bcmp.c
diff --git a/strings/ctype.c b/strings/ctype.c
index 2c0fe09c07b..446eb168804 100644
--- a/strings/ctype.c
+++ b/strings/ctype.c
@@ -39,7 +39,7 @@
*/
-static char *mstr(char *str,const char *src,uint l1,uint l2)
+static char *mstr(char *str,const char *src,size_t l1,size_t l2)
{
l1= l1<l2 ? l1 : l2;
memcpy(str,src,l1);
@@ -143,7 +143,7 @@ typedef struct my_cs_file_info
-static int fill_uchar(uchar *a,uint size,const char *str, uint len)
+static int fill_uchar(uchar *a,uint size,const char *str, size_t len)
{
uint i= 0;
const char *s, *b, *e=str+len;
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c
index a57cc5b5ebe..920022aae91 100644
--- a/strings/my_vsnprintf.c
+++ b/strings/my_vsnprintf.c
@@ -108,7 +108,7 @@ size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
char *par = va_arg(ap, char *);
DBUG_ASSERT(to <= end);
if (to + abs(width) + 1 > end)
- width= end - to - 1; /* sign doesn't matter */
+ width= (uint) (end - to - 1); /* sign doesn't matter */
memmove(to, par, abs(width));
to+= width;
continue;
@@ -176,7 +176,7 @@ size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
{
- int result;
+ size_t result;
va_list args;
va_start(args,fmt);
result= my_vsnprintf(to, n, fmt, args);
diff --git a/support-files/Makefile.am b/support-files/Makefile.am
index 05d4ac8a620..47e8c395b31 100644
--- a/support-files/Makefile.am
+++ b/support-files/Makefile.am
@@ -120,6 +120,7 @@ SUFFIXES = .sh
-e 's!@''SHARED_LIB_VERSION''@!@SHARED_LIB_VERSION@!' \
-e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
-e 's!@''MYSQL_NO_DASH_VERSION''@!@MYSQL_NO_DASH_VERSION@!' \
+ -e 's!@''MYSQL_COPYRIGHT_YEAR''@!@MYSQL_COPYRIGHT_YEAR@!' \
-e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
-e 's!@''PERL_DBI_VERSION''@!@PERL_DBI_VERSION@!' \
-e 's!@''PERL_DBD_VERSION''@!@PERL_DBD_VERSION@!' \
diff --git a/support-files/my-huge.cnf.sh b/support-files/my-huge.cnf.sh
index 5be8f5e67a0..17a7ddb5855 100644
--- a/support-files/my-huge.cnf.sh
+++ b/support-files/my-huge.cnf.sh
@@ -26,9 +26,9 @@ socket = @MYSQL_UNIX_ADDR@
port = @MYSQL_TCP_PORT@
socket = @MYSQL_UNIX_ADDR@
skip-locking
-key_buffer = 384M
+key_buffer_size = 384M
max_allowed_packet = 1M
-table_cache = 512
+table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
@@ -46,9 +46,6 @@ thread_concurrency = 8
#
#skip-networking
-# Disable Federated by default
-skip-federated
-
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
@@ -124,7 +121,6 @@ server-id = 1
#innodb_data_home_dir = @localstatedir@/
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M
@@ -144,14 +140,8 @@ no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
-[isamchk]
-key_buffer = 256M
-sort_buffer_size = 256M
-read_buffer = 2M
-write_buffer = 2M
-
[myisamchk]
-key_buffer = 256M
+key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
diff --git a/support-files/my-innodb-heavy-4G.cnf.sh b/support-files/my-innodb-heavy-4G.cnf.sh
index 60b8138880e..e9390a5b9e8 100644
--- a/support-files/my-innodb-heavy-4G.cnf.sh
+++ b/support-files/my-innodb-heavy-4G.cnf.sh
@@ -80,7 +80,7 @@ max_connect_errors = 10
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
-table_cache = 2048
+table_open_cache = 2048
# Enable external file level locking. Enabled file locking will have a
# negative impact on performance, so only use it in case you have
@@ -167,7 +167,7 @@ ft_min_word_len = 4
# Table type which is used by default when creating new tables, if not
# specified differently during the CREATE TABLE statement.
-default_table_type = MYISAM
+default-storage-engine = MYISAM
# Thread stack size to use. This amount of memory is always reserved at
# connection time. MySQL itself usually needs no more than 64K of
@@ -211,10 +211,10 @@ binlog_format=mixed
# Log slow queries. Slow queries are queries which take more than the
# amount of time defined in "long_query_time" or which do not use
-# indexes well, if log_long_format is enabled. It is normally good idea
+# indexes well, if log_short_format is not enabled. It is normally good idea
# to have this turned on if you frequently add new queries to the
# system.
-log_slow_queries
+slow_query_log
# All queries taking more than this amount of time (in seconds) will be
# trated as slow. Do not use "1" as a value here, as this will result in
@@ -222,11 +222,6 @@ log_slow_queries
# currently measures time with second accuracy only).
long_query_time = 2
-# Log more information in the slow query log. Normally it is good to
-# have this turned on. This will enable logging of queries that are not
-# using indexes in addition to long running queries.
-log_long_format
-
# The directory used by MySQL for storing temporary files. For example,
# it is used to perform disk based large sorts, as well as for internal
# and explicit temporary tables. It might be good to put it on a
@@ -345,12 +340,6 @@ myisam_sort_buffer_size = 128M
# through the key cache (which is slower).
myisam_max_sort_file_size = 10G
-# If the temporary file used for fast index creation would be bigger
-# than using the key cache by the amount specified here, then prefer the
-# key cache method. This is mainly used to force long character keys in
-# large tables to use the slower key cache method to create the index.
-myisam_max_extra_sort_file_size = 10G
-
# If a table has more than one index, MyISAM can use more than one
# thread to repair them by sorting in parallel. This makes sense if you
# have multiple CPUs and plenty of memory.
@@ -359,7 +348,6 @@ myisam_repair_threads = 1
# Automatically check and repair not properly closed MyISAM tables.
myisam_recover
-
# *** INNODB Specific options ***
# Use this option if you have a MySQL server with InnoDB support enabled
@@ -482,14 +470,8 @@ no-auto-rehash
# Only allow UPDATEs and DELETEs that use keys.
#safe-updates
-[isamchk]
-key_buffer = 512M
-sort_buffer_size = 512M
-read_buffer = 8M
-write_buffer = 8M
-
[myisamchk]
-key_buffer = 512M
+key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
diff --git a/support-files/my-large.cnf.sh b/support-files/my-large.cnf.sh
index 0d5719e4438..bbdfdb32a96 100644
--- a/support-files/my-large.cnf.sh
+++ b/support-files/my-large.cnf.sh
@@ -26,9 +26,9 @@ socket = @MYSQL_UNIX_ADDR@
port = @MYSQL_TCP_PORT@
socket = @MYSQL_UNIX_ADDR@
skip-locking
-key_buffer = 256M
+key_buffer_size = 256M
max_allowed_packet = 1M
-table_cache = 256
+table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
@@ -46,9 +46,6 @@ thread_concurrency = 8
#
#skip-networking
-# Disable Federated by default
-skip-federated
-
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
@@ -124,7 +121,6 @@ server-id = 1
#innodb_data_home_dir = @localstatedir@/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 256M
@@ -144,14 +140,8 @@ no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
-[isamchk]
-key_buffer = 128M
-sort_buffer_size = 128M
-read_buffer = 2M
-write_buffer = 2M
-
[myisamchk]
-key_buffer = 128M
+key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
diff --git a/support-files/my-medium.cnf.sh b/support-files/my-medium.cnf.sh
index 211b8ed5e8e..88113d0a8d4 100644
--- a/support-files/my-medium.cnf.sh
+++ b/support-files/my-medium.cnf.sh
@@ -27,9 +27,9 @@ socket = @MYSQL_UNIX_ADDR@
port = @MYSQL_TCP_PORT@
socket = @MYSQL_UNIX_ADDR@
skip-locking
-key_buffer = 16M
+key_buffer_size = 16M
max_allowed_packet = 1M
-table_cache = 64
+table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
@@ -44,9 +44,6 @@ myisam_sort_buffer_size = 8M
#
#skip-networking
-# Disable Federated by default
-skip-federated
-
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
@@ -122,7 +119,6 @@ server-id = 1
#innodb_data_home_dir = @localstatedir@/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
@@ -142,14 +138,8 @@ no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
-[isamchk]
-key_buffer = 20M
-sort_buffer_size = 20M
-read_buffer = 2M
-write_buffer = 2M
-
[myisamchk]
-key_buffer = 20M
+key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
diff --git a/support-files/my-small.cnf.sh b/support-files/my-small.cnf.sh
index 7bf8f323d57..3bfa08d0bd1 100644
--- a/support-files/my-small.cnf.sh
+++ b/support-files/my-small.cnf.sh
@@ -27,9 +27,9 @@ socket = @MYSQL_UNIX_ADDR@
port = @MYSQL_TCP_PORT@
socket = @MYSQL_UNIX_ADDR@
skip-locking
-key_buffer = 16K
+key_buffer_size = 16K
max_allowed_packet = 1M
-table_cache = 4
+table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
@@ -55,7 +55,6 @@ server-id = 1
#innodb_data_home_dir = @localstatedir@/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
@@ -75,12 +74,8 @@ no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
-[isamchk]
-key_buffer = 8M
-sort_buffer_size = 8M
-
[myisamchk]
-key_buffer = 8M
+key_buffer_size = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 7c08fdf4734..778b04b30fe 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -41,7 +41,7 @@
%else
%define release 0.glibc23
%endif
-%define license GPL
+%define mysql_license GPL
%define mysqld_user mysql
%define mysqld_group mysql
%define server_suffix -standard
@@ -75,7 +75,7 @@ Summary: MySQL: a very fast and reliable SQL database server
Group: Applications/Databases
Version: @MYSQL_NO_DASH_VERSION@
Release: %{release}
-License: Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Under %{license} license as shown in the Description field.
+License: Copyright 2000-2008 MySQL AB, @MYSQL_COPYRIGHT_YEAR@ Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Under %{mysql_license} license as shown in the Description field.
Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz
URL: http://www.mysql.com/
Packager: Sun Microsystems, Inc. Product Engineering Team <build@mysql.com>
@@ -96,7 +96,7 @@ is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Sun Microsystems, Inc.
-Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved.
+Copyright 2000-2008 MySQL AB, @MYSQL_COPYRIGHT_YEAR@ Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
@@ -120,7 +120,7 @@ is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Sun Microsystems, Inc.
-Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved.
+Copyright 2000-2008 MySQL AB, @MYSQL_COPYRIGHT_YEAR@ Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
@@ -366,7 +366,7 @@ CFLAGS="$CFLAGS" \
CXXFLAGS="$CXXFLAGS" \
BuildMySQL "\
--with-debug \
- --with-comment=\"MySQL Community Server - Debug (%{license})\"")
+ --with-comment=\"MySQL Community Server - Debug (%{mysql_license})\"")
# We might want to save the config log file
if test -n "$MYSQL_DEBUGCONFLOG_DEST"
@@ -387,7 +387,7 @@ CFLAGS="$CFLAGS" \
CXXFLAGS="$CXXFLAGS" \
BuildMySQL "\
--with-embedded-server \
- --with-comment=\"MySQL Community Server (%{license})\"")
+ --with-comment=\"MySQL Community Server (%{mysql_license})\"")
# We might want to save the config log file
if test -n "$MYSQL_CONFLOG_DEST"
then
diff --git a/tests/bug25714.c b/tests/bug25714.c
index 03d28f59aa4..c0d9fbf7652 100644
--- a/tests/bug25714.c
+++ b/tests/bug25714.c
@@ -54,14 +54,14 @@ int main (int argc, char **argv)
printf("%s\n", mysql_error(&conn));
}
- OK = mysql_real_query (&conn, query4, strlen(query4));
+ OK = mysql_real_query (&conn, query4, (uint) strlen(query4));
assert(0 == OK);
printf("%ld inserted\n",
(long) mysql_insert_id(&conn));
- OK = mysql_real_query (&conn, query5, strlen(query5));
+ OK = mysql_real_query (&conn, query5, (uint) strlen(query5));
assert(0 == OK);
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 4f30d43f53f..6025063846a 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -262,7 +262,7 @@ static MYSQL_STMT *STDCALL
mysql_simple_prepare(MYSQL *mysql_arg, const char *query)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql_arg);
- if (stmt && mysql_stmt_prepare(stmt, query, strlen(query)))
+ if (stmt && mysql_stmt_prepare(stmt, query, (uint) strlen(query)))
{
mysql_stmt_close(stmt);
return 0;
@@ -723,6 +723,7 @@ static void do_verify_prepare_field(MYSQL_RES *result,
{
MYSQL_FIELD *field;
CHARSET_INFO *cs;
+ ulonglong expected_field_length;
if (!(field= mysql_fetch_field_direct(result, no)))
{
@@ -731,6 +732,8 @@ static void do_verify_prepare_field(MYSQL_RES *result,
}
cs= get_charset(field->charsetnr, 0);
DIE_UNLESS(cs);
+ if ((expected_field_length= length * cs->mbmaxlen) > UINT_MAX32)
+ expected_field_length= UINT_MAX32;
if (!opt_silent)
{
fprintf(stdout, "\n field[%d]:", no);
@@ -745,8 +748,8 @@ static void do_verify_prepare_field(MYSQL_RES *result,
fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)",
field->org_table, org_table);
fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db);
- fprintf(stdout, "\n length :`%lu`\t(expected: `%lu`)",
- field->length, length * cs->mbmaxlen);
+ fprintf(stdout, "\n length :`%lu`\t(expected: `%llu`)",
+ field->length, expected_field_length);
fprintf(stdout, "\n maxlength:`%ld`", field->max_length);
fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr);
fprintf(stdout, "\n default :`%s`\t(expected: `%s`)",
@@ -782,11 +785,11 @@ static void do_verify_prepare_field(MYSQL_RES *result,
as utf8. Field length is calculated as number of characters * maximum
number of bytes a character can occupy.
*/
- if (length && field->length != length * cs->mbmaxlen)
+ if (length && (field->length != expected_field_length))
{
- fprintf(stderr, "Expected field length: %d, got length: %d\n",
- (int) (length * cs->mbmaxlen), (int) field->length);
- DIE_UNLESS(field->length == length * cs->mbmaxlen);
+ fprintf(stderr, "Expected field length: %llu, got length: %lu\n",
+ expected_field_length, field->length);
+ DIE_UNLESS(field->length == expected_field_length);
}
if (def)
DIE_UNLESS(strcmp(field->def, def) == 0);
@@ -16552,61 +16555,6 @@ static void test_change_user()
DBUG_VOID_RETURN;
}
-#ifdef HAVE_SPATIAL
-/**
- Bug#37956 memory leak and / or crash with geometry and prepared statements!
-*/
-
-static void test_bug37956(void)
-{
- const char *query="select point(?,?)";
- MYSQL_STMT *stmt=NULL;
- ulong val=0;
- MYSQL_BIND bind_param[2];
- unsigned char buff[2]= { 134, 211 };
- DBUG_ENTER("test_bug37956");
- myheader("test_bug37956");
-
- stmt= mysql_simple_prepare(mysql, query);
- check_stmt(stmt);
-
- val=1;
- mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void *)&val);
- val=CURSOR_TYPE_READ_ONLY;
- mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void *)&val);
- val=0;
- mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, (void *)&val);
-
- memset(bind_param, 0, sizeof(bind_param));
- bind_param[0].buffer_type=MYSQL_TYPE_TINY;
- bind_param[0].buffer= (void *)buff;
- bind_param[0].is_null=NULL;
- bind_param[0].error=NULL;
- bind_param[0].is_unsigned=1;
- bind_param[1].buffer_type=MYSQL_TYPE_TINY;
- bind_param[1].buffer= (void *)(buff+1);
- bind_param[1].is_null=NULL;
- bind_param[1].error=NULL;
- bind_param[1].is_unsigned=1;
-
- if (mysql_stmt_bind_param(stmt, bind_param))
- {
- mysql_stmt_close(stmt);
- DIE_UNLESS(0);
- }
-
- if (mysql_stmt_execute(stmt))
- {
- mysql_stmt_close(stmt);
- DBUG_VOID_RETURN;
- }
- /* Should never reach here: execution returns an error. */
- mysql_stmt_close(stmt);
- DIE_UNLESS(0);
- DBUG_VOID_RETURN;
-}
-#endif
-
/*
Bug#27592 (stack overrun when storing datetime value using prepared statements)
*/
@@ -17768,6 +17716,69 @@ static void test_bug36326()
#endif
+/**
+ Bug#41078: With CURSOR_TYPE_READ_ONLY mysql_stmt_fetch() returns short
+ string value.
+*/
+
+static void test_bug41078(void)
+{
+ uint rc;
+ MYSQL_STMT *stmt= 0;
+ MYSQL_BIND param, result;
+ ulong cursor_type= CURSOR_TYPE_READ_ONLY;
+ ulong len;
+ char str[64];
+ const char param_str[]= "abcdefghijklmn";
+ my_bool is_null, error;
+
+ DBUG_ENTER("test_bug41078");
+
+ rc= mysql_query(mysql, "SET NAMES UTF8");
+ myquery(rc);
+
+ stmt= mysql_simple_prepare(mysql, "SELECT ?");
+ check_stmt(stmt);
+ verify_param_count(stmt, 1);
+
+ rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, &cursor_type);
+ check_execute(stmt, rc);
+
+ bzero(&param, sizeof(param));
+ param.buffer_type= MYSQL_TYPE_STRING;
+ param.buffer= (void *) param_str;
+ len= sizeof(param_str) - 1;
+ param.length= &len;
+
+ rc= mysql_stmt_bind_param(stmt, &param);
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ bzero(&result, sizeof(result));
+ result.buffer_type= MYSQL_TYPE_STRING;
+ result.buffer= str;
+ result.buffer_length= sizeof(str);
+ result.is_null= &is_null;
+ result.length= &len;
+ result.error= &error;
+
+ rc= mysql_stmt_bind_result(stmt, &result);
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_store_result(stmt);
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_fetch(stmt);
+ check_execute(stmt, rc);
+
+ DIE_UNLESS(len == sizeof(param_str) - 1 && !strcmp(str, param_str));
+
+ mysql_stmt_close(stmt);
+
+ DBUG_VOID_RETURN;
+}
/*
Read and parse arguments and MySQL options from my.cnf
@@ -18079,12 +18090,10 @@ static struct my_tests_st my_tests[]= {
{ "test_wl4166_2", test_wl4166_2 },
{ "test_bug38486", test_bug38486 },
{ "test_bug40365", test_bug40365 },
-#ifdef HAVE_SPATIAL
- { "test_bug37956", test_bug37956 },
-#endif
#ifdef HAVE_QUERY_CACHE
{ "test_bug36326", test_bug36326 },
#endif
+ { "test_bug41078", test_bug41078 },
{ 0, 0 }
};
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 942f0330c57..2d7fd0e08cd 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -480,19 +480,22 @@ size_t vio_read_shared_memory(Vio * vio, uchar* buf, size_t size)
size_t length;
size_t remain_local;
char *current_postion;
+ HANDLE events[2];
+
DBUG_ENTER("vio_read_shared_memory");
DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
size));
remain_local = size;
current_postion=buf;
+
+ events[0]= vio->event_server_wrote;
+ events[1]= vio->event_conn_closed;
+
do
{
if (vio->shared_memory_remain == 0)
{
- HANDLE events[2];
- events[0]= vio->event_server_wrote;
- events[1]= vio->event_conn_closed;
/*
WaitForMultipleObjects can return next values:
WAIT_OBJECT_0+0 - event from vio->event_server_wrote
@@ -500,7 +503,7 @@ size_t vio_read_shared_memory(Vio * vio, uchar* buf, size_t size)
anything
WAIT_ABANDONED_0 and WAIT_TIMEOUT - fail. We can't read anything
*/
- if (WaitForMultipleObjects(2, (HANDLE*)&events,FALSE,
+ if (WaitForMultipleObjects(array_elements(events), events, FALSE,
vio->net->read_timeout*1000) != WAIT_OBJECT_0)
{
DBUG_RETURN(-1);
@@ -543,17 +546,22 @@ size_t vio_write_shared_memory(Vio * vio, const uchar* buf, size_t size)
size_t length, remain, sz;
HANDLE pos;
const uchar *current_postion;
+ HANDLE events[2];
+
DBUG_ENTER("vio_write_shared_memory");
DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
size));
remain = size;
current_postion = buf;
+
+ events[0]= vio->event_server_read;
+ events[1]= vio->event_conn_closed;
+
while (remain != 0)
{
- if (WaitForSingleObject(vio->event_server_read,
- vio->net->write_timeout*1000) !=
- WAIT_OBJECT_0)
+ if (WaitForMultipleObjects(array_elements(events), events, FALSE,
+ vio->net->write_timeout*1000) != WAIT_OBJECT_0)
{
DBUG_RETURN((size_t) -1);
}
diff --git a/win/Makefile.am b/win/Makefile.am
index 279183480d8..5dc637ae8a3 100644
--- a/win/Makefile.am
+++ b/win/Makefile.am
@@ -14,8 +14,9 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## Process this file with automake to create Makefile.in
-EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \
- mysql_manifest.cmake create_manifest.js
+EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat build-vs9.bat \
+ build-vs9_x64.bat configure.js README mysql_manifest.cmake \
+ create_manifest.js
# Don't update the files from bitkeeper
%::SCCS/s.%