summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/aborted_clients.result6
-rw-r--r--mysql-test/r/alias.result4
-rw-r--r--mysql-test/r/alter_table-big.result32
-rw-r--r--mysql-test/r/alter_table.result9
-rw-r--r--mysql-test/r/analyze_format_json.result4
-rw-r--r--mysql-test/r/assign_key_cache-5405.result5
-rw-r--r--mysql-test/r/auth_named_pipe.result3
-rw-r--r--mysql-test/r/auth_rpl.result9
-rw-r--r--mysql-test/r/bug39022.result19
-rw-r--r--mysql-test/r/bug58669.result4
-rw-r--r--mysql-test/r/cache_innodb.result15
-rw-r--r--mysql-test/r/cast.result3
-rw-r--r--mysql-test/r/change_user_notembedded.result4
-rw-r--r--mysql-test/r/check.result13
-rw-r--r--mysql-test/r/commit.result64
-rw-r--r--mysql-test/r/compress.result3
-rw-r--r--mysql-test/r/concurrent_innodb_safelog.result130
-rw-r--r--mysql-test/r/concurrent_innodb_unsafelog.result130
-rw-r--r--mysql-test/r/connect.result69
-rw-r--r--mysql-test/r/connect2.result26
-rw-r--r--mysql-test/r/consistent_snapshot.result22
-rw-r--r--mysql-test/r/create-big.result118
-rw-r--r--mysql-test/r/create.result7
-rw-r--r--mysql-test/r/create_drop_role.result4
-rw-r--r--mysql-test/r/create_or_replace.result7
-rw-r--r--mysql-test/r/create_or_replace2.result2
-rw-r--r--mysql-test/r/create_or_replace_permission.result3
-rw-r--r--mysql-test/r/cte_grant.result11
-rw-r--r--mysql-test/r/ctype_errors.result13
-rw-r--r--mysql-test/r/ddl_i18n_koi8r.result50
-rw-r--r--mysql-test/r/ddl_i18n_utf8.result50
-rw-r--r--mysql-test/r/deadlock_innodb.result38
-rw-r--r--mysql-test/r/debug_sync.result28
-rw-r--r--mysql-test/r/delayed.result66
-rw-r--r--mysql-test/r/delete_returning_grant.result11
-rw-r--r--mysql-test/r/derived.result5
-rw-r--r--mysql-test/r/dirty_close.result17
-rw-r--r--mysql-test/r/drop.result15
-rw-r--r--mysql-test/r/empty_user_table.result1
-rw-r--r--mysql-test/r/enforce_storage_engine.result8
-rw-r--r--mysql-test/r/events_1.result5
-rw-r--r--mysql-test/r/events_bugs.result33
-rw-r--r--mysql-test/r/events_grant.result16
-rw-r--r--mysql-test/r/events_stress.result11
-rw-r--r--mysql-test/r/events_trans_notembedded.result3
-rw-r--r--mysql-test/r/explain_slowquerylog.result3
-rw-r--r--mysql-test/r/failed_auth_3909.result3
-rw-r--r--mysql-test/r/failed_auth_unixsocket.result1
-rw-r--r--mysql-test/r/filesort_debug.result10
-rw-r--r--mysql-test/r/flush-innodb-notembedded.result25
-rw-r--r--mysql-test/r/flush-innodb.result94
-rw-r--r--mysql-test/r/flush.result118
-rw-r--r--mysql-test/r/flush_block_commit.result39
-rw-r--r--mysql-test/r/flush_block_commit_notembedded.result22
-rw-r--r--mysql-test/r/flush_read_lock.result297
-rw-r--r--mysql-test/r/flush_read_lock_kill.result16
-rw-r--r--mysql-test/r/flush_table.result10
-rw-r--r--mysql-test/r/func_compress.result7
-rw-r--r--mysql-test/r/func_group.result4
-rw-r--r--mysql-test/r/func_misc.result43
-rw-r--r--mysql-test/r/func_str.result7
-rw-r--r--mysql-test/r/func_weight_string.result4
-rw-r--r--mysql-test/r/function_defaults_notembedded.result12
-rw-r--r--mysql-test/r/grant.result398
-rw-r--r--mysql-test/r/grant2.result126
-rw-r--r--mysql-test/r/grant3.result15
-rw-r--r--mysql-test/r/grant4.result13
-rw-r--r--mysql-test/r/grant_cache_no_prot.result38
-rw-r--r--mysql-test/r/grant_cache_ps_prot.result38
-rw-r--r--mysql-test/r/grant_explain_non_select.result32
-rw-r--r--mysql-test/r/grant_lowercase.result4
-rw-r--r--mysql-test/r/grant_lowercase_fs.result5
-rw-r--r--mysql-test/r/information_schema.result164
-rw-r--r--mysql-test/r/information_schema_db.result25
-rw-r--r--mysql-test/r/information_schema_linux.result3
-rw-r--r--mysql-test/r/init_connect.result63
-rw-r--r--mysql-test/r/init_connection_query_cache.result4
-rw-r--r--mysql-test/r/innodb_mysql_lock.result75
-rw-r--r--mysql-test/r/innodb_mysql_lock2.result88
-rw-r--r--mysql-test/r/innodb_mysql_sync.result107
-rw-r--r--mysql-test/r/insert_notembedded.result20
-rw-r--r--mysql-test/r/ipv4_and_ipv6.result6
-rw-r--r--mysql-test/r/ipv4_as_ipv6.result18
-rw-r--r--mysql-test/r/ipv6.result9
-rw-r--r--mysql-test/r/kill-2.result2
-rw-r--r--mysql-test/r/kill.result148
-rw-r--r--mysql-test/r/loaddata.result6
-rw-r--r--mysql-test/r/loadxml.result3
-rw-r--r--mysql-test/r/lock.result24
-rw-r--r--mysql-test/r/lock_multi.result289
-rw-r--r--mysql-test/r/lock_multi_bug38499.result9
-rw-r--r--mysql-test/r/lock_multi_bug38691.result7
-rw-r--r--mysql-test/r/lock_sync.result158
-rw-r--r--mysql-test/r/lock_tables_lost_commit.result7
-rw-r--r--mysql-test/r/locked_temporary-5955.result2
-rw-r--r--mysql-test/r/log_state.result16
-rw-r--r--mysql-test/r/log_tables.result33
-rw-r--r--mysql-test/r/lowercase_fs_off.result18
-rw-r--r--mysql-test/r/mdev-504.result1
-rw-r--r--mysql-test/r/mdev375.result3
-rw-r--r--mysql-test/r/mdl_sync.result1143
-rw-r--r--mysql-test/r/merge-big.result9
-rw-r--r--mysql-test/r/merge.result39
-rw-r--r--mysql-test/r/mix2_myisam.result26
-rw-r--r--mysql-test/r/multi_update.result21
-rw-r--r--mysql-test/r/myisam-big.result6
-rw-r--r--mysql-test/r/myisam-optimize.result14
-rw-r--r--mysql-test/r/myisam.result19
-rw-r--r--mysql-test/r/myisam_debug.result6
-rw-r--r--mysql-test/r/myisam_icp_notembedded.result3
-rw-r--r--mysql-test/r/myisam_optimize.result7
-rw-r--r--mysql-test/r/myisam_recover.result21
-rw-r--r--mysql-test/r/mysql-bug41486.result3
-rw-r--r--mysql-test/r/mysql-bug45236.result3
-rw-r--r--mysql-test/r/mysql_upgrade-6984.result1
-rw-r--r--mysql-test/r/mysql_upgrade.result1
-rw-r--r--mysql-test/r/mysqlbinlog.result8
-rw-r--r--mysql-test/r/mysqlbinlog_row_big.result5
-rw-r--r--mysql-test/r/mysqldump-max.result21
-rw-r--r--mysql-test/r/mysqldump.result18
-rw-r--r--mysql-test/r/mysqltest.result22
-rw-r--r--mysql-test/r/named_pipe.result3
-rw-r--r--mysql-test/r/non_blocking_api.result4
-rw-r--r--mysql-test/r/not_embedded_server.result8
-rw-r--r--mysql-test/r/openssl_1.result18
-rw-r--r--mysql-test/r/outfile.resultbin2139 -> 2323 bytes
-rw-r--r--mysql-test/r/overflow.result4
-rw-r--r--mysql-test/r/packet.result8
-rw-r--r--mysql-test/r/parser_not_embedded.result10
-rw-r--r--mysql-test/r/partition_cache.result15
-rw-r--r--mysql-test/r/partition_csv.result3
-rw-r--r--mysql-test/r/partition_debug_sync.result28
-rw-r--r--mysql-test/r/partition_grant.result16
-rw-r--r--mysql-test/r/partition_innodb.result25
-rw-r--r--mysql-test/r/partition_innodb_plugin.result21
-rw-r--r--mysql-test/r/partition_innodb_semi_consistent.result39
-rw-r--r--mysql-test/r/partition_innodb_stmt.result10
-rw-r--r--mysql-test/r/partition_symlink.result5
-rw-r--r--mysql-test/r/partition_sync.result26
-rw-r--r--mysql-test/r/plugin_auth.result59
-rw-r--r--mysql-test/r/plugin_auth_qa_1.result35
-rw-r--r--mysql-test/r/plugin_not_embedded.result5
-rw-r--r--mysql-test/r/plugin_vars.result10
-rw-r--r--mysql-test/r/pool_of_threads.result13
-rw-r--r--mysql-test/r/processlist.result8
-rw-r--r--mysql-test/r/ps.result15
-rw-r--r--mysql-test/r/ps_ddl.result12
-rw-r--r--mysql-test/r/ps_grant.result8
-rw-r--r--mysql-test/r/query_cache_28249.result25
-rw-r--r--mysql-test/r/query_cache_debug.result71
-rw-r--r--mysql-test/r/query_cache_notembedded.result24
-rw-r--r--mysql-test/r/query_cache_ps_no_prot.result46
-rw-r--r--mysql-test/r/query_cache_ps_ps_prot.result46
-rw-r--r--mysql-test/r/quick_select_4161.result5
-rw-r--r--mysql-test/r/read_only.result13
-rw-r--r--mysql-test/r/read_only_innodb.result18
-rw-r--r--mysql-test/r/rename.result11
-rw-r--r--mysql-test/r/rpl_mysqldump_slave.result6
-rw-r--r--mysql-test/r/schema.result52
-rw-r--r--mysql-test/r/shm.result3
-rw-r--r--mysql-test/r/show_check.result52
-rw-r--r--mysql-test/r/show_explain.result129
-rw-r--r--mysql-test/r/show_explain_non_select.result11
-rw-r--r--mysql-test/r/show_explain_ps.result6
-rw-r--r--mysql-test/r/shutdown.result5
-rw-r--r--mysql-test/r/skip_name_resolve.result3
-rw-r--r--mysql-test/r/sp-innodb.result3
-rw-r--r--mysql-test/r/sp-lock.result254
-rw-r--r--mysql-test/r/sp-security.result151
-rw-r--r--mysql-test/r/sp-threads.result28
-rw-r--r--mysql-test/r/sp.result4
-rw-r--r--mysql-test/r/sp_notembedded.result49
-rw-r--r--mysql-test/r/sp_sync.result36
-rw-r--r--mysql-test/r/sql_mode.result5
-rw-r--r--mysql-test/r/ssl-big.result5
-rw-r--r--mysql-test/r/ssl.result3
-rw-r--r--mysql-test/r/ssl_cipher.result3
-rw-r--r--mysql-test/r/ssl_compress.result3
-rw-r--r--mysql-test/r/ssl_timeout.result3
-rw-r--r--mysql-test/r/stat_tables_par.result40
-rw-r--r--mysql-test/r/stat_tables_par_innodb.result40
-rw-r--r--mysql-test/r/stat_tables_rbr.result3
-rw-r--r--mysql-test/r/stat_tables_repl.result10
-rw-r--r--mysql-test/r/status.result41
-rw-r--r--mysql-test/r/status2.result4
-rw-r--r--mysql-test/r/status_bug17954.result1
-rw-r--r--mysql-test/r/subselect.result4
-rw-r--r--mysql-test/r/subselect_no_exists_to_in.result4
-rw-r--r--mysql-test/r/subselect_no_mat.result4
-rw-r--r--mysql-test/r/subselect_no_opts.result4
-rw-r--r--mysql-test/r/subselect_no_scache.result4
-rw-r--r--mysql-test/r/subselect_no_semijoin.result4
-rw-r--r--mysql-test/r/subselect_sj.result4
-rw-r--r--mysql-test/r/subselect_sj_jcl6.result4
-rw-r--r--mysql-test/r/symlink.result10
-rw-r--r--mysql-test/r/synchronization.result55
-rw-r--r--mysql-test/r/temp_table.result3
-rw-r--r--mysql-test/r/timezone_grant.result12
-rw-r--r--mysql-test/r/trans_read_only.result6
-rw-r--r--mysql-test/r/trigger-compat.result6
-rw-r--r--mysql-test/r/trigger-trans.result9
-rw-r--r--mysql-test/r/trigger.result23
-rw-r--r--mysql-test/r/trigger_notembedded.result176
-rw-r--r--mysql-test/r/truncate_coverage.result71
-rw-r--r--mysql-test/r/udf_debug_sync.result8
-rw-r--r--mysql-test/r/union.result3
-rw-r--r--mysql-test/r/unsafe_binlog_innodb.result66
-rw-r--r--mysql-test/r/update.result4
-rw-r--r--mysql-test/r/user_limits.result60
-rw-r--r--mysql-test/r/userstat-badlogin-4824.result5
-rw-r--r--mysql-test/r/userstat.result3
-rw-r--r--mysql-test/r/variables-notembedded.result3
-rw-r--r--mysql-test/r/variables.result6
-rw-r--r--mysql-test/r/view.result30
-rw-r--r--mysql-test/r/view_debug.result5
-rw-r--r--mysql-test/r/view_grant.result253
-rw-r--r--mysql-test/r/wait_timeout.result10
-rw-r--r--mysql-test/r/xa.result48
-rw-r--r--mysql-test/r/xa_sync.result18
219 files changed, 5560 insertions, 2169 deletions
diff --git a/mysql-test/r/aborted_clients.result b/mysql-test/r/aborted_clients.result
index 7111a0c98db..8eb6df59653 100644
--- a/mysql-test/r/aborted_clients.result
+++ b/mysql-test/r/aborted_clients.result
@@ -1,9 +1,15 @@
FLUSH STATUS;
+connect con1,localhost,root,,;
+disconnect con1;
+connection default;
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='aborted_clients';
VARIABLE_VALUE
0
+connect con2,localhost,root,,;
KILL CONNECTION_ID();
ERROR 70100: Connection was killed
+disconnect con2;
+connection default;
SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='aborted_clients';
VARIABLE_VALUE
1
diff --git a/mysql-test/r/alias.result b/mysql-test/r/alias.result
index 9d826dd9bd7..defd44f2548 100644
--- a/mysql-test/r/alias.result
+++ b/mysql-test/r/alias.result
@@ -212,5 +212,9 @@ drop table t4;
create table t4 select t2.*, d as 'x', d as 'z' from t2;
drop table t4;
drop table t1,t2,t3;
+connect c1,localhost,root,,;
+connection c1;
DELETE ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZROM t1 WHERE 1=1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 't1 WHERE 1=1' at line 1
+connection default;
+disconnect c1;
diff --git a/mysql-test/r/alter_table-big.result b/mysql-test/r/alter_table-big.result
index f7a3ec6502e..32689daa3a6 100644
--- a/mysql-test/r/alter_table-big.result
+++ b/mysql-test/r/alter_table-big.result
@@ -1,5 +1,8 @@
drop table if exists t1, t2;
set debug_sync='RESET';
+connect addconroot, localhost, root,,;
+connect addconroot2, localhost, root,,;
+connection default;
create table t1 (n1 int, n2 int, n3 int,
key (n1, n2, n3),
key (n2, n3, n1),
@@ -10,10 +13,15 @@ insert into t1 values (1, 2, 3);
reset master;
set debug_sync='alter_table_enable_indexes SIGNAL parked WAIT_FOR go';
alter table t1 enable keys;;
+connection addconroot;
set debug_sync='now WAIT_FOR parked';
insert into t2 values (1);
insert into t1 values (1, 1, 1);;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot;
+connection default;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
@@ -25,36 +33,60 @@ master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `test`; insert into t1 values (1, 1, 1)
master-bin.000001 # Query # # COMMIT
drop tables t1, t2;
+disconnect addconroot;
+disconnect addconroot2;
set debug_sync='RESET';
End of 5.0 tests
drop table if exists t1, t2, t3;
+connect addconroot, localhost, root,,;
+connect addconroot2, localhost, root,,;
+connection default;
create table t1 (i int);
reset master;
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
alter table t1 change i c char(10) default 'Test1';;
+connection addconroot;
set debug_sync='now WAIT_FOR parked';
insert into t1 values ();;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot;
+connection default;
select * from t1;
c
Test1
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
alter table t1 change c vc varchar(100) default 'Test2';;
+connection addconroot;
set debug_sync='now WAIT_FOR parked';
rename table t1 to t2;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot;
+connection default;
drop table t2;
create table t1 (i int);
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
alter table t1 change i c char(10) default 'Test3', rename to t2;;
+connection addconroot;
set debug_sync='now WAIT_FOR parked';
insert into t2 values();;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot;
+connection default;
select * from t2;
c
Test3
alter table t2 change c vc varchar(100) default 'Test2', rename to t1;;
+connection addconroot;
+connection default;
rename table t1 to t3;
+disconnect addconroot;
+disconnect addconroot2;
drop table t3;
set debug_sync='alter_table_before_main_binlog SIGNAL parked WAIT_FOR go';
set debug_sync='RESET';
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 9c0a25f6d61..3388e7fcdcd 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -1681,16 +1681,17 @@ CREATE TABLE t1(a INT PRIMARY KEY, b INT);
INSERT INTO t1 VALUES (1,1), (2,2);
START TRANSACTION;
INSERT INTO t1 VALUES (3,3);
-# Connection con1
+connect con1, localhost, root;
# Sending:
ALTER TABLE t1 DISABLE KEYS;
-# Connection default
+connection default;
# Waiting until ALTER TABLE is blocked.
UPDATE t1 SET b = 4;
COMMIT;
-# Connection con1
+connection con1;
# Reaping: ALTER TABLE t1 DISABLE KEYS
-# Connection default
+disconnect con1;
+connection default;
DROP TABLE t1;
#
# 7: Which operations require copy and which can be done in-place?
diff --git a/mysql-test/r/analyze_format_json.result b/mysql-test/r/analyze_format_json.result
index 69930bc0215..4f8876a8414 100644
--- a/mysql-test/r/analyze_format_json.result
+++ b/mysql-test/r/analyze_format_json.result
@@ -242,6 +242,8 @@ insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
select database();
database()
test
+connect con1,localhost,root,,*NO-ONE*;
+connection con1;
select database();
database()
NULL
@@ -265,6 +267,8 @@ ANALYZE
}
}
}
+disconnect con1;
+connection default;
drop table t1;
#
# MDEV-7812: ANALYZE FORMAT=JSON UPDATE/DELETE doesnt print
diff --git a/mysql-test/r/assign_key_cache-5405.result b/mysql-test/r/assign_key_cache-5405.result
index 4a0fc58cd4f..c4cb56f3f72 100644
--- a/mysql-test/r/assign_key_cache-5405.result
+++ b/mysql-test/r/assign_key_cache-5405.result
@@ -1,12 +1,17 @@
create table t1 (f int, key(f)) engine=myisam;
set global kc1.key_buffer_size = 65536;
+connect con1, localhost, root;
set debug_sync='assign_key_cache_op_unlock wait_for op_locked';
cache index t1 in kc1;
+connection default;
set debug_sync='assign_key_cache_op_lock signal op_locked wait_for assigned';
cache index t1 in kc1;
+connection con1;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
set debug_sync='now signal assigned';
+disconnect con1;
+connection default;
Table Op Msg_type Msg_text
test.t1 assign_to_keycache status OK
drop table t1;
diff --git a/mysql-test/r/auth_named_pipe.result b/mysql-test/r/auth_named_pipe.result
index 3268b760a22..fb190ccd149 100644
--- a/mysql-test/r/auth_named_pipe.result
+++ b/mysql-test/r/auth_named_pipe.result
@@ -1,8 +1,11 @@
INSTALL SONAME 'auth_named_pipe';
CREATE USER 'USERNAME' IDENTIFIED WITH named_pipe;
+connect pipe_con,localhost,$USERNAME,,,,,PIPE;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
USERNAME@localhost USERNAME@%
+disconnect pipe_con;
+connection default;
DROP USER 'USERNAME';
CREATE USER nosuchuser IDENTIFIED WITH named_pipe;
ERROR 28000: Access denied for user 'nosuchuser'@'localhost'
diff --git a/mysql-test/r/auth_rpl.result b/mysql-test/r/auth_rpl.result
index 70626b02b2b..a3da7985da1 100644
--- a/mysql-test/r/auth_rpl.result
+++ b/mysql-test/r/auth_rpl.result
@@ -1,16 +1,18 @@
include/master-slave.inc
[connection master]
-[connection slave]
+connection slave;
include/stop_slave.inc
-[connection master]
+connection master;
CREATE USER 'plug_user' IDENTIFIED WITH 'test_plugin_server' AS 'plug_user';
GRANT REPLICATION SLAVE ON *.* TO plug_user;
FLUSH PRIVILEGES;
-[connection slave]
+connection slave;
CHANGE MASTER TO
MASTER_USER= 'plug_user',
MASTER_PASSWORD= 'plug_user';
include/start_slave.inc
+connection master;
+connection slave;
# Slave in-sync with master now.
SELECT user, plugin, authentication_string FROM mysql.user WHERE user LIKE 'plug_user';
user plugin authentication_string
@@ -20,5 +22,6 @@ include/stop_slave.inc
CHANGE MASTER TO MASTER_USER='root';
DROP USER 'plug_user';
# Cleanup (on master).
+connection master;
DROP USER 'plug_user';
include/rpl_end.inc
diff --git a/mysql-test/r/bug39022.result b/mysql-test/r/bug39022.result
index 75899ed686b..3cdda9eeca4 100644
--- a/mysql-test/r/bug39022.result
+++ b/mysql-test/r/bug39022.result
@@ -8,25 +8,30 @@ INSERT INTO t1 VALUES (13,0),(8,1),(9,2),(6,3),
(12,13),(7,14);
INSERT INTO t2 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),
(11),(12),(13),(14);
-# in thread1
+connect thread1, localhost, root,,;
+connect thread2, localhost, root,,;
+connection thread1;
START TRANSACTION;
-# in thread2
+connection thread2;
REPLACE INTO t2 VALUES (-17);
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE;
d
-# in thread1
+connection thread1;
REPLACE INTO t1(a,b) VALUES (67,20);
-# in thread2
+connection thread2;
COMMIT;
START TRANSACTION;
REPLACE INTO t1(a,b) VALUES (65,-50);
REPLACE INTO t2 VALUES (-91);
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE;
-# in thread1
+connection thread1;
# should not crash
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
-# in thread2
+connection thread2;
d
-# in thread1;
+disconnect thread2;
+connection thread1;
+disconnect thread1;
+connection default;
DROP TABLE t1,t2;
diff --git a/mysql-test/r/bug58669.result b/mysql-test/r/bug58669.result
index c9bd43e244b..a7d1d7b5581 100644
--- a/mysql-test/r/bug58669.result
+++ b/mysql-test/r/bug58669.result
@@ -5,6 +5,8 @@ CREATE USER user1@localhost;
CREATE DATABASE db1;
GRANT ALL PRIVILEGES ON db1.* TO user1@localhost;
CREATE TABLE db1.t1(a INT);
+connect con1,localhost,user1,,;
+connection con1;
SELECT CURRENT_USER();
CURRENT_USER()
user1@localhost
@@ -13,5 +15,7 @@ Variable_name Value
read_only ON
INSERT INTO db1.t1 VALUES (1);
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
+connection default;
+disconnect con1;
DROP DATABASE db1;
DROP USER user1@localhost;
diff --git a/mysql-test/r/cache_innodb.result b/mysql-test/r/cache_innodb.result
index 971750e3da2..18ae0ac8a83 100644
--- a/mysql-test/r/cache_innodb.result
+++ b/mysql-test/r/cache_innodb.result
@@ -131,9 +131,10 @@ select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t
id a
1 me
drop table t3,t2,t1;
+connect connection1,localhost,root,,;
SET SESSION STORAGE_ENGINE = InnoDB;
SET @@autocommit=1;
-connection default
+connection default;
SHOW VARIABLES LIKE 'have_query_cache';
Variable_name Value
have_query_cache YES
@@ -155,7 +156,7 @@ count(*)
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
-connection connection1
+connection connection1;
START TRANSACTION;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
@@ -171,7 +172,7 @@ count(*)
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
-connection default
+connection default;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
1
@@ -185,7 +186,7 @@ count(*)
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
-connection connection1
+connection connection1;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
2
@@ -197,7 +198,7 @@ INSERT INTO t2 VALUES (6,'w');
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
3
-connection default
+connection default;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
2
@@ -210,7 +211,7 @@ SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
1
COMMIT;
-connection connection1
+connection connection1;
COMMIT;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
@@ -221,6 +222,8 @@ Qcache_queries_in_cache 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
+disconnect connection1;
+connection default;
set @@global.query_cache_size = @save_query_cache_size;
drop table t2;
SET global query_cache_type=default;
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index 4c9f257fdf2..da23f8af40c 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -713,6 +713,7 @@ DROP TABLE t1;
SET @@GLOBAL.max_allowed_packet=2048;
Warnings:
Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
+connect newconn, localhost, root,,;
SELECT CONVERT('a', BINARY(2049));
CONVERT('a', BINARY(2049))
a
@@ -728,6 +729,8 @@ length(CONVERT(repeat('a',2048), CHAR(2049)))
2048
Warnings:
Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated
+connection default;
+disconnect newconn;
SET @@GLOBAL.max_allowed_packet=default;
#
# Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
diff --git a/mysql-test/r/change_user_notembedded.result b/mysql-test/r/change_user_notembedded.result
index 896a6045481..41a154f8d3d 100644
--- a/mysql-test/r/change_user_notembedded.result
+++ b/mysql-test/r/change_user_notembedded.result
@@ -1,6 +1,10 @@
+connect test,localhost,root,,;
+connection test;
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES)
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: NO)
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES)
ERROR 08S01: Unknown command
ERROR 08S01: Unknown command
+disconnect test;
+connection default;
that's all
diff --git a/mysql-test/r/check.result b/mysql-test/r/check.result
index 0ac42272c4f..bc41b95f192 100644
--- a/mysql-test/r/check.result
+++ b/mysql-test/r/check.result
@@ -1,3 +1,6 @@
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
drop table if exists t1,t2;
drop view if exists v1;
create table t1(n int not null, key(n), key(n), key(n), key(n));
@@ -6,9 +9,14 @@ Note 1831 Duplicate index 'n_2' defined on the table 'test.t1'. This is deprecat
Note 1831 Duplicate index 'n_3' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
Note 1831 Duplicate index 'n_4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
check table t1 extended;
+connection con2;
insert into t1 values (200000);
+connection con1;
Table Op Msg_type Msg_text
test.t1 check status OK
+connection default;
+disconnect con1;
+disconnect con2;
drop table t1;
Create table t1(f1 int);
Create table t2(f1 int);
@@ -34,12 +42,13 @@ DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT);
LOCK TABLE t1 WRITE;
-# Connection con1
+connect con1, localhost, root;
SET lock_wait_timeout= 1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check Error Lock wait timeout exceeded; try restarting transaction
test.t1 check status Operation failed
-# Connection default
+connection default;
UNLOCK TABLES;
DROP TABLE t1;
+disconnect con1;
diff --git a/mysql-test/r/commit.result b/mysql-test/r/commit.result
index a62d2940d85..b501f5a8dd7 100644
--- a/mysql-test/r/commit.result
+++ b/mysql-test/r/commit.result
@@ -1,3 +1,4 @@
+connect con1,localhost,root,,;
#
# Bug#20837 Apparent change of isolation level
# during transaction
@@ -43,11 +44,11 @@ s1
2
-1
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-connection con1
+connection con1;
START TRANSACTION;
INSERT INTO t1 VALUES (1000);
COMMIT;
-connection default
+connection default;
We should not be able to read the '1000'
SELECT * FROM t1;
s1
@@ -65,23 +66,23 @@ s1
1000
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
-connection default
+connection default;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION;
-connection con1
+connection con1;
START TRANSACTION;
INSERT INTO t1 VALUES (1001);
COMMIT;
-connection default
+connection default;
SELECT COUNT(*) FROM t1 WHERE s1 = 1001;
COUNT(*)
1
Should be 1
COMMIT AND CHAIN;
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1002);
COMMIT;
-connection default
+connection default;
SELECT COUNT(*) FROM t1 WHERE s1 = 1002;
COUNT(*)
1
@@ -97,23 +98,23 @@ s1
1002
DELETE FROM t1 WHERE s1 >= 1000;
COMMIT;
-connection default
+connection default;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION;
-connection con1
+connection con1;
START TRANSACTION;
INSERT INTO t1 VALUES (1001);
COMMIT;
-connection default
+connection default;
SELECT COUNT(*) FROM t1 WHERE s1 = 1001;
COUNT(*)
1
Should be 1
ROLLBACK AND CHAIN;
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1002);
COMMIT;
-connection default
+connection default;
SELECT COUNT(*) FROM t1 WHERE s1 = 1002;
COUNT(*)
1
@@ -129,33 +130,33 @@ s1
DELETE FROM t1 WHERE s1 >= 1000;
COMMIT;
SET @@completion_type=1;
-connection default
+connection default;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION;
-connection con1
+connection con1;
START TRANSACTION;
INSERT INTO t1 VALUES (1001);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1 WHERE s1 >= 1000;
s1
1001
Should see 1001
COMMIT AND NO CHAIN;
default transaction is now in REPEATABLE READ
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1002);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1 WHERE s1 >= 1000;
s1
1001
1002
Should see 1001 and 1002
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1003);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1 WHERE s1 >= 1000;
s1
1001
@@ -174,35 +175,35 @@ DELETE FROM t1 WHERE s1 >= 1000;
COMMIT AND NO CHAIN;
SET @@completion_type=0;
COMMIT;
-connection default
+connection default;
SET @@completion_type=1;
COMMIT AND NO CHAIN;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
START TRANSACTION;
-connection con1
+connection con1;
START TRANSACTION;
INSERT INTO t1 VALUES (1001);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1 WHERE s1 >= 1000;
s1
1001
Should see 1001
ROLLBACK AND NO CHAIN;
default transaction is now in REPEATABLE READ
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1002);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1 WHERE s1 >= 1000;
s1
1001
1002
Should see 1001 and 1002
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1003);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1 WHERE s1 >= 1000;
s1
1001
@@ -221,7 +222,7 @@ DELETE FROM t1 WHERE s1 >= 1000;
COMMIT AND NO CHAIN;
SET @@completion_type=0;
COMMIT;
-connection default
+connection default;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
START TRANSACTION;
@@ -230,10 +231,10 @@ s1
1
2
-1
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1000);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1;
s1
1
@@ -253,10 +254,10 @@ SELECT * FROM t1;
s1
1000
Should read '1000'
-connection con1
+connection con1;
INSERT INTO t1 VALUES (1001);
COMMIT;
-connection default
+connection default;
SELECT * FROM t1;
s1
1000
@@ -266,6 +267,7 @@ SET @@completion_type=0;
COMMIT AND NO CHAIN;
SET @@autocommit=1;
COMMIT;
+disconnect con1;
DROP TABLE t1;
#
# End of test cases for Bug#20837
diff --git a/mysql-test/r/compress.result b/mysql-test/r/compress.result
index 83b50351ba9..bd87015bf8f 100644
--- a/mysql-test/r/compress.result
+++ b/mysql-test/r/compress.result
@@ -1,3 +1,4 @@
+connect comp_con,localhost,root,,,,,COMPRESS;
SHOW STATUS LIKE 'Compression';
Variable_name Value
Compression ON
@@ -2163,3 +2164,5 @@ drop table t1;
SHOW STATUS LIKE 'Compression';
Variable_name Value
Compression ON
+connection default;
+disconnect comp_con;
diff --git a/mysql-test/r/concurrent_innodb_safelog.result b/mysql-test/r/concurrent_innodb_safelog.result
index 03d20f40be3..27889777ac1 100644
--- a/mysql-test/r/concurrent_innodb_safelog.result
+++ b/mysql-test/r/concurrent_innodb_safelog.result
@@ -1,4 +1,5 @@
SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connection default;
SET SQL_MODE="";
SELECT @@global.tx_isolation;
@@global.tx_isolation
@@ -13,7 +14,8 @@ drop table if exists t1;
**
** two UPDATE's running and both changing distinct result sets
**
-** connection thread1
+connect thread1, localhost, mysqltest,,;
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -32,13 +34,14 @@ insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10);
get_lock("hello",10)
1
-** connection thread2
+connect thread2, localhost, mysqltest,,;
+connection thread2;
** Start transaction for thread 2
begin;
** 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
+connection thread1;
** Start new transaction for thread 1
begin;
** Update on t1 will cause a table scan which will be blocked because
@@ -65,7 +68,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** Release the lock and collect result from update on thread 2
DO release_lock("hello");
** Table should have eta updates where tipo=11 but updates made by
@@ -85,7 +88,7 @@ eta tipo c
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Sending commit on thread 2.
commit;
-** connection thread1
+connection thread1;
** Make sure table reads didn't change yet on thread 1.
select * from t1;
eta tipo c
@@ -117,7 +120,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** Make sure the output is similar for t1.
select * from t1;
eta tipo c
@@ -132,7 +135,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -146,13 +149,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** two UPDATE's running and one changing result set
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -171,14 +174,14 @@ insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10);
get_lock("hello",10)
1
-** connection thread2
+connection thread2;
** Start transaction on thread 2
begin;
** Update will cause a table scan.
** This will cause a hang on the first row where tipo=1 until the
** blocking ULL is released.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=1;
-** connection thread1
+connection thread1;
** Start transaction on thread 1
begin;
** Update on t1 will cause a table scan which will be blocked because
@@ -204,7 +207,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** Release the lock and collect result from thread 2:
DO release_lock("hello");
** Seen from thread 2 the table should have been updated on four
@@ -223,7 +226,7 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
** Thread 2 has committed but the result should remain the same for
** thread 1 (updated on three places):
select * from t1;
@@ -256,7 +259,7 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -270,7 +273,7 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -284,13 +287,13 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** One UPDATE and one INSERT .... Monty's test
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1 (a int not null, b int not null);
@@ -299,13 +302,13 @@ insert into t1 values (1,1),(2,1),(3,1),(4,1);
select get_lock("hello2",10);
get_lock("hello2",10)
1
-** connection thread2
+connection thread2;
** Begin a new transaction on thread 2
begin;
** Update will create a table scan which creates a ULL where a=2;
** this will hang waiting on thread 1.
update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
-** connection thread1
+connection thread1;
** Insert new values to t1 from thread 1; this created an implicit
** commit since there are no on-going transactions.
insert into t1 values (1,1);
@@ -319,7 +322,7 @@ a b
3 1
4 1
1 1
-** connection thread2
+connection thread2;
** Collect results from thread 2 and release the lock.
DO release_lock("hello2");
** The table should look like the original+updates for thread 2,
@@ -333,13 +336,13 @@ a b
1 1
** Commit changes from thread 2
commit;
-** connection default
+connection default;
drop table t1;
**
** one UPDATE changing result set and SELECT ... FOR UPDATE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -354,7 +357,7 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
** Begin a new transaction on thread 2
begin;
** Select a range for update.
@@ -363,7 +366,7 @@ eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-** connection thread1
+connection thread1;
** Begin a new transaction on thread 1
begin;
** Update the same range which is marked for update on thread 2; this
@@ -385,7 +388,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** The table should look unmodified from thread 2.
select * from t1;
eta tipo c
@@ -403,10 +406,10 @@ eta tipo c
** Sending a commit should release the row locks and enable
** thread 1 to complete the transaction.
commit;
-** connection thread1
+connection thread1;
** Commit on thread 1.
commit;
-** connection thread2
+connection thread2;
** The table should not have been changed.
select * from t1;
eta tipo c
@@ -421,7 +424,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
** Even on thread 1:
select * from t1;
eta tipo c
@@ -436,13 +439,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** one UPDATE not changing result set and SELECT ... FOR UPDATE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -457,7 +460,7 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
** Starting new transaction on thread 2.
begin;
** Starting SELECT .. FOR UPDATE
@@ -466,7 +469,7 @@ eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-** connection thread1
+connection thread1;
** Starting new transaction on thread 1
begin;
@@ -492,7 +495,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** The same thing should hold true for the transaction on
** thread 2
select * from t1;
@@ -509,9 +512,9 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
commit;
-** connection thread2
+connection thread2;
** Even after committing:
select * from t1;
eta tipo c
@@ -526,7 +529,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -540,13 +543,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** two SELECT ... FOR UPDATE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -561,7 +564,7 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
** Begin a new transaction on thread 2
begin;
select * from t1 where tipo=2 FOR UPDATE;
@@ -569,14 +572,14 @@ eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-** connection thread1
+connection thread1;
** Begin a new transaction on thread 1
begin;
** Selecting a range for update by table scan will be blocked
** because of on-going transaction on thread 2.
select * from t1 where tipo=1 FOR UPDATE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-** connection thread2
+connection thread2;
** Table will be unchanged and the select command will not be
** blocked:
select * from t1;
@@ -594,10 +597,10 @@ eta tipo c
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Commit transacton on thread 2.
commit;
-** connection thread1
+connection thread1;
** Commit transaction on thread 1.
commit;
-** connection thread2
+connection thread2;
** Make sure table isn't blocked on thread 2:
select * from t1;
eta tipo c
@@ -612,7 +615,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
** Make sure table isn't blocked on thread 1:
select * from t1;
eta tipo c
@@ -627,13 +630,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** one UPDATE changing result set and DELETE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -648,10 +651,10 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
begin;
delete from t1 where tipo=2;
-** connection thread1
+connection thread1;
begin;
update t1 set tipo=1 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
@@ -668,7 +671,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -680,9 +683,9 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
commit;
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -693,7 +696,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -704,13 +707,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** one UPDATE not changing result set and DELETE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -725,10 +728,10 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
begin;
delete from t1 where tipo=2;
-** connection thread1
+connection thread1;
begin;
** Update on t1 will cause a table scan which will be blocked because
** the previously initiated table scan applied exclusive key locks on
@@ -750,7 +753,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -762,9 +765,9 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
commit;
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -775,7 +778,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -787,8 +790,11 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Cleanup
-** connection thread2
-** connection default
+connection thread1;
+disconnect thread1;
+connection thread2;
+disconnect thread2;
+connection default;
drop table t1;
drop user mysqltest@localhost;
SET SQL_MODE=default;
diff --git a/mysql-test/r/concurrent_innodb_unsafelog.result b/mysql-test/r/concurrent_innodb_unsafelog.result
index 4a140d9e610..39e757aeeb1 100644
--- a/mysql-test/r/concurrent_innodb_unsafelog.result
+++ b/mysql-test/r/concurrent_innodb_unsafelog.result
@@ -1,4 +1,5 @@
SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connection default;
SET SQL_MODE="";
SELECT @@global.tx_isolation;
@@global.tx_isolation
@@ -13,7 +14,8 @@ drop table if exists t1;
**
** two UPDATE's running and both changing distinct result sets
**
-** connection thread1
+connect thread1, localhost, mysqltest,,;
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -32,13 +34,14 @@ insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10);
get_lock("hello",10)
1
-** connection thread2
+connect thread2, localhost, mysqltest,,;
+connection thread2;
** Start transaction for thread 2
begin;
** 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
+connection thread1;
** Start new transaction for thread 1
begin;
** Update on t1 will cause a table scan which will be blocked because
@@ -64,7 +67,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** Release the lock and collect result from update on thread 2
DO release_lock("hello");
** Table should have eta updates where tipo=11 but updates made by
@@ -84,7 +87,7 @@ eta tipo c
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Sending commit on thread 2.
commit;
-** connection thread1
+connection thread1;
** Make sure table reads didn't change yet on thread 1.
select * from t1;
eta tipo c
@@ -116,7 +119,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** Make sure the output is similar for t1.
select * from t1;
eta tipo c
@@ -131,7 +134,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -145,13 +148,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
2 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
1 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** two UPDATE's running and one changing result set
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -170,14 +173,14 @@ insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
select get_lock("hello",10);
get_lock("hello",10)
1
-** connection thread2
+connection thread2;
** Start transaction on thread 2
begin;
** Update will cause a table scan.
** This will cause a hang on the first row where tipo=1 until the
** blocking ULL is released.
update t1 set eta=1+get_lock("hello",10)*0 where tipo=1;
-** connection thread1
+connection thread1;
** Start transaction on thread 1
begin;
** Update on t1 will cause a table scan which will be blocked because
@@ -202,7 +205,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** Release the lock and collect result from thread 2:
DO release_lock("hello");
** Seen from thread 2 the table should have been updated on four
@@ -221,7 +224,7 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
** Thread 2 has committed but the result should remain the same for
** thread 1 (updated on three places):
select * from t1;
@@ -254,7 +257,7 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -268,7 +271,7 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -282,13 +285,13 @@ eta tipo c
1 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** One UPDATE and one INSERT .... Monty's test
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1 (a int not null, b int not null);
@@ -297,13 +300,13 @@ insert into t1 values (1,1),(2,1),(3,1),(4,1);
select get_lock("hello2",10);
get_lock("hello2",10)
1
-** connection thread2
+connection thread2;
** Begin a new transaction on thread 2
begin;
** Update will create a table scan which creates a ULL where a=2;
** this will hang waiting on thread 1.
update t1 set b=10+get_lock(concat("hello",a),10)*0 where a=2;
-** connection thread1
+connection thread1;
** Insert new values to t1 from thread 1; this created an implicit
** commit since there are no on-going transactions.
insert into t1 values (1,1);
@@ -317,7 +320,7 @@ a b
3 1
4 1
1 1
-** connection thread2
+connection thread2;
** Collect results from thread 2 and release the lock.
DO release_lock("hello2");
** The table should look like the original+updates for thread 2,
@@ -331,13 +334,13 @@ a b
1 1
** Commit changes from thread 2
commit;
-** connection default
+connection default;
drop table t1;
**
** one UPDATE changing result set and SELECT ... FOR UPDATE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -352,7 +355,7 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
** Begin a new transaction on thread 2
begin;
** Select a range for update.
@@ -361,7 +364,7 @@ eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-** connection thread1
+connection thread1;
** Begin a new transaction on thread 1
begin;
** Update the same range which is marked for update on thread 2; this
@@ -383,7 +386,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** The table should look unmodified from thread 2.
select * from t1;
eta tipo c
@@ -401,10 +404,10 @@ eta tipo c
** Sending a commit should release the row locks and enable
** thread 1 to complete the transaction.
commit;
-** connection thread1
+connection thread1;
** Commit on thread 1.
commit;
-** connection thread2
+connection thread2;
** The table should not have been changed.
select * from t1;
eta tipo c
@@ -419,7 +422,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
** Even on thread 1:
select * from t1;
eta tipo c
@@ -434,13 +437,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** one UPDATE not changing result set and SELECT ... FOR UPDATE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -455,7 +458,7 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
** Starting new transaction on thread 2.
begin;
** Starting SELECT .. FOR UPDATE
@@ -464,7 +467,7 @@ eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-** connection thread1
+connection thread1;
** Starting new transaction on thread 1
begin;
@@ -489,7 +492,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 11 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
** The same thing should hold true for the transaction on
** thread 2
select * from t1;
@@ -506,9 +509,9 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
commit;
-** connection thread2
+connection thread2;
** Even after committing:
select * from t1;
eta tipo c
@@ -523,7 +526,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 11 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -537,13 +540,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 11 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** two SELECT ... FOR UPDATE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -558,7 +561,7 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
** Begin a new transaction on thread 2
begin;
select * from t1 where tipo=2 FOR UPDATE;
@@ -566,14 +569,14 @@ eta tipo c
20 2 ddddddddddddddddddddddddddddddddddddddddddd
40 2 fffffffffffffffffffffffffffffffffffffffffff
60 2 hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-** connection thread1
+connection thread1;
** Begin a new transaction on thread 1
begin;
** Selecting a range for update by table scan will be blocked
** because of on-going transaction on thread 2.
select * from t1 where tipo=1 FOR UPDATE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-** connection thread2
+connection thread2;
** Table will be unchanged and the select command will not be
** blocked:
select * from t1;
@@ -591,10 +594,10 @@ eta tipo c
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Commit transacton on thread 2.
commit;
-** connection thread1
+connection thread1;
** Commit transaction on thread 1.
commit;
-** connection thread2
+connection thread2;
** Make sure table isn't blocked on thread 2:
select * from t1;
eta tipo c
@@ -609,7 +612,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
** Make sure table isn't blocked on thread 1:
select * from t1;
eta tipo c
@@ -624,13 +627,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** one UPDATE changing result set and DELETE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -645,10 +648,10 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
begin;
delete from t1 where tipo=2;
-** connection thread1
+connection thread1;
begin;
update t1 set tipo=1 where tipo=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
@@ -665,7 +668,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -677,9 +680,9 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
commit;
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -690,7 +693,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -701,13 +704,13 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection default
+connection default;
drop table t1;
**
** one UPDATE not changing result set and DELETE
**
-** connection thread1
+connection thread1;
** Set up table
SET SESSION STORAGE_ENGINE = InnoDB;
create table t1(eta int(11) not null, tipo int(11), c varchar(255));
@@ -722,10 +725,10 @@ insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
-** connection thread2
+connection thread2;
begin;
delete from t1 where tipo=2;
-** connection thread1
+connection thread1;
begin;
** Update on t1 will cause a table scan which will be blocked because
** the previously initiated table scan applied exclusive key locks on
@@ -746,7 +749,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -758,9 +761,9 @@ eta tipo c
80 22 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
commit;
-** connection thread1
+connection thread1;
commit;
-** connection thread2
+connection thread2;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -771,7 +774,7 @@ eta tipo c
70 1 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
-** connection thread1
+connection thread1;
select * from t1;
eta tipo c
7 7 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -783,8 +786,11 @@ eta tipo c
80 1 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
90 11 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
** Cleanup
-** connection thread2
-** connection default
+connection thread1;
+disconnect thread1;
+connection thread2;
+disconnect thread2;
+connection default;
drop table t1;
drop user mysqltest@localhost;
SET SQL_MODE=default;
diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result
index 315aea0ef46..dfe4406605e 100644
--- a/mysql-test/r/connect.result
+++ b/mysql-test/r/connect.result
@@ -1,5 +1,6 @@
SET global secure_auth=0;
drop table if exists t1,t2;
+connect con1,localhost,root,,mysql;
show tables;
Tables_in_mysql
column_stats
@@ -32,14 +33,21 @@ time_zone_name
time_zone_transition
time_zone_transition_type
user
+connect con2,localhost,root,,test;
show tables;
Tables_in_test
connect(localhost,root,z,test2,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,root,z,test2;
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
connect(localhost,root,z,test,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,root,z,;
ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
+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";
+connect con3,localhost,test,gambling,mysql;
show tables;
Tables_in_mysql
column_stats
@@ -72,18 +80,29 @@ time_zone_name
time_zone_transition
time_zone_transition_type
user
+connect con4,localhost,test,gambling,test;
show tables;
Tables_in_test
+connection default;
+disconnect con3;
+disconnect con4;
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,,test2;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,"",MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,,'""';
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,zorro,test2;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,zorro,;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
update mysql.user set password=old_password("gambling2") where user=_binary"test";
flush privileges;
+connect con10,localhost,test,gambling2,;
+connect con5,localhost,test,gambling2,mysql;
+connection con5;
set password="";
set password='gambling3';
ERROR HY000: Password hash should be a 41-digit hexadecimal number
@@ -120,22 +139,35 @@ time_zone_name
time_zone_transition
time_zone_transition_type
user
+connect con6,localhost,test,gambling3,test;
show tables;
Tables_in_test
+connection default;
+disconnect con10;
+disconnect con5;
+disconnect con6;
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,,test2;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,,;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,zorro,test2;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
+connect fail_con,localhost,test,zorro,;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
delete from mysql.user where user=_binary"test";
flush privileges;
+connect con7,localhost,root,,test;
+connection con7;
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;
+connection default;
+disconnect con7;
drop table t1;
# ------------------------------------------------------------------
# -- End of 4.1 tests
@@ -153,6 +185,7 @@ SET GLOBAL event_scheduler = ON;
# -- Waiting for Event Scheduler to start...
# -- Disconnecting default connection...
+disconnect default;
# -- Check that we allow exactly three user connections, no matter how
# -- many threads are running.
@@ -202,8 +235,13 @@ SET GLOBAL event_scheduler = OFF;
# -- Waiting for Event Scheduler to stop...
# -- That's it. Closing connections...
+disconnect con_1;
+disconnect con_2;
+disconnect con_3;
+disconnect con_super_1;
# -- Restoring default connection...
+connect default,localhost,root,,test;
# -- Waiting for connections to close...
@@ -224,6 +262,7 @@ SET GLOBAL event_scheduler = ON;
# -- Waiting for Event Scheduler to start...
# -- Opening a new connection to check max_used_connections...
+connect con_1,localhost,root;
# -- Check that max_used_connections hasn't changed.
SHOW STATUS LIKE 'max_used_connections';
@@ -231,6 +270,8 @@ Variable_name Value
Max_used_connections 2
# -- Closing new connection...
+disconnect con_1;
+connection default;
# -- Stopping Event Scheduler...
SET GLOBAL event_scheduler = OFF;
@@ -238,9 +279,13 @@ SET GLOBAL event_scheduler = OFF;
# -- End of Bug#35074.
+connect extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
+connection extracon;
SELECT 'Connection on extra port ok';
Connection on extra port ok
Connection on extra port ok
+connect extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
+connection extracon2;
SELECT 'Connection on extra port 2 ok';
Connection on extra port 2 ok
Connection on extra port 2 ok
@@ -251,6 +296,9 @@ Connection on extra port 2 ok
#
GRANT ALL ON test.* TO 'O1234567890123456789012345678901234567890123456789012345678901234567890123456789'@'localhost' IDENTIFIED BY 'test123';
FLUSH PRIVILEGES;
+connect con1,localhost,O1234567890123456789012345678901234567890123456789012345678901234567890123456789x,test123,test;
+disconnect con1;
+connection default;
DROP USER 'O1234567890123456789012345678901234567890123456789012345678901234567890123456789'@'localhost';
FLUSH PRIVILEGES;
#
@@ -259,22 +307,36 @@ FLUSH PRIVILEGES;
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------
+disconnect extracon;
+disconnect extracon2;
+connection default;
CREATE USER mysqltest_up1 IDENTIFIED VIA mysql_native_password using '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB';
CREATE USER mysqltest_up2 IDENTIFIED VIA mysql_old_password using '09301740536db389';
connect(localhost,mysqltest_up1,foo,test,MASTER_PORT,MASTER_SOCKET);
+connect pcon1,localhost,mysqltest_up1,foo,,$MASTER_MYPORT,;
ERROR 28000: Access denied for user 'mysqltest_up1'@'localhost' (using password: YES)
+connect pcon2,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,;
+connection pcon2;
select user(), current_user();
user() current_user()
mysqltest_up1@localhost mysqltest_up1@%
+disconnect pcon2;
connect(localhost,mysqltest_up2,newpw,test,MASTER_PORT,MASTER_SOCKET);
+connect pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,;
ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: YES)
+connect pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,;
+connection pcon4;
select user(), current_user();
user() current_user()
mysqltest_up2@localhost mysqltest_up2@%
+disconnect pcon4;
connect(localhost,mysqltest_nouser,newpw,test,MASTER_PORT,MASTER_SOCKET);
+connect pcon5,localhost,mysqltest_nouser,newpw,,$MASTER_MYPORT,;
ERROR 28000: Access denied for user 'mysqltest_nouser'@'localhost' (using password: YES)
connect(localhost,mysqltest_nouser,,test,MASTER_PORT,MASTER_SOCKET);
+connect pcon5,localhost,mysqltest_nouser,,,$MASTER_MYPORT,;
ERROR 28000: Access denied for user 'mysqltest_nouser'@'localhost' (using password: NO)
+connection default;
update mysql.user set plugin='mysql_native_password' where user = 'mysqltest_up1';
update mysql.user set plugin='mysql_old_password' where user = 'mysqltest_up2';
select user, password, plugin, authentication_string from mysql.user
@@ -283,12 +345,19 @@ user password plugin authentication_string
mysqltest_up1 *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB mysql_native_password
mysqltest_up2 09301740536db389 mysql_old_password
flush privileges;
+connect pcon6,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,;
+connection pcon6;
select user(), current_user();
user() current_user()
mysqltest_up1@localhost mysqltest_up1@%
+disconnect pcon6;
+connect pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,;
+connection pcon7;
select user(), current_user();
user() current_user()
mysqltest_up2@localhost mysqltest_up2@%
+disconnect pcon7;
+connection default;
DROP USER mysqltest_up1@'%';
DROP USER mysqltest_up2@'%';
#
diff --git a/mysql-test/r/connect2.result b/mysql-test/r/connect2.result
index eecb6455162..b68f7ae7c43 100644
--- a/mysql-test/r/connect2.result
+++ b/mysql-test/r/connect2.result
@@ -1,44 +1,70 @@
call mtr.add_suppression("Allocation failed");
SET @old_debug= @@session.debug;
set @old_thread_cache_size=@@global.thread_cache_size;
+connect con1,localhost,root,,test,,;
select 1;
1
1
+disconnect con1;
+connection default;
set global debug_dbug='+d,simulate_failed_connection_1';
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
+connect con1,localhost,root,,test,,;
Got one of the listed errors
+connection default;
set global debug_dbug=@old_debug;
set global debug_dbug='+d,simulate_failed_connection_2';
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
+connect con1,localhost,root,,test,,;
Got one of the listed errors
+connection default;
set global debug_dbug=@old_debug;
+connect con1,localhost,root,,test,,;
select 1;
1
1
+disconnect con1;
+connect con1,localhost,root,,test,$MASTER_EXTRA_PORT,;
select 1;
1
1
+disconnect con1;
+connection default;
set global debug_dbug='+d,simulate_failed_connection_1';
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
+connect con1,localhost,root,,test,$MASTER_EXTRA_PORT,;
Got one of the listed errors
+connection default;
set global debug_dbug=@old_debug;
set global debug_dbug='+d,simulate_failed_connection_2';
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
+connect con1,localhost,root,,test,$MASTER_EXTRA_PORT,;
Got one of the listed errors
+connection default;
set global debug_dbug=@old_debug;
+connect con1,localhost,root,,test,$MASTER_EXTRA_PORT,;
select 1;
1
1
+disconnect con1;
+connection default;
set @@global.thread_cache_size=2;
+connect con1,localhost,root,,test,$MASTER_EXTRA_PORT,;
select 1;
1
1
+connect con2,localhost,root,,test,$MASTER_EXTRA_PORT,;
select 1;
1
1
+disconnect con1;
+disconnect con2;
+connection default;
set global debug_dbug='+d,simulate_failed_connection_2';
connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET);
+connect con1,localhost,root,,test,$MASTER_EXTRA_PORT,;
Got one of the listed errors
+connection default;
show status like "Threads_connected";
Variable_name Value
Threads_connected 1
diff --git a/mysql-test/r/consistent_snapshot.result b/mysql-test/r/consistent_snapshot.result
index 3a0227b1a1a..b978f1dd9d2 100644
--- a/mysql-test/r/consistent_snapshot.result
+++ b/mysql-test/r/consistent_snapshot.result
@@ -1,15 +1,15 @@
DROP TABLE IF EXISTS t1;
-# Establish connection con1 (user=root)
-# Establish connection con2 (user=root)
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
### Test 1:
### - While a consistent snapshot transaction is executed,
### no external inserts should be visible to the transaction.
-# Switch to connection con1
+connection con1;
CREATE TABLE t1 (a INT) ENGINE=innodb;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
-# Switch to connection con2
+connection con2;
INSERT INTO t1 VALUES(1);
-# Switch to connection con1
+connection con1;
SELECT * FROM t1;
a
COMMIT;
@@ -18,9 +18,9 @@ COMMIT;
### committed inserts should be visible to the transaction.
DELETE FROM t1;
START TRANSACTION;
-# Switch to connection con2
+connection con2;
INSERT INTO t1 VALUES(1);
-# Switch to connection con1
+connection con1;
SELECT * FROM t1;
a
1
@@ -31,12 +31,14 @@ COMMIT;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
DELETE FROM t1;
COMMIT WORK AND CHAIN;
-# Switch to connection con2
+connection con2;
INSERT INTO t1 VALUES(1);
-# Switch to connection con1
+connection con1;
SELECT * FROM t1;
a
1
COMMIT;
-# Switch to connection default + close connections con1 and con2
+connection default;
+disconnect con1;
+disconnect con2;
DROP TABLE t1;
diff --git a/mysql-test/r/create-big.result b/mysql-test/r/create-big.result
index bb8c62bb25c..d041419443e 100644
--- a/mysql-test/r/create-big.result
+++ b/mysql-test/r/create-big.result
@@ -1,11 +1,20 @@
+connect addconroot1, localhost, root,,;
+connect addconroot2, localhost, root,,;
+connect addconroot3, localhost, root,,;
+connection default;
drop table if exists t1,t2,t3,t4,t5;
set debug_sync='RESET';
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
create table t1 (j char(5));;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
ERROR 42S01: Table 't1' already exists
+connection default;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -14,10 +23,15 @@ t1 CREATE TABLE `t1` (
drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
create table t1 select 'Test' as j;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
ERROR 42S01: Table 't1' already exists
+connection default;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -27,10 +41,15 @@ drop table t1;
create table t3 (j char(5));
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
create table t1 like t3;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
ERROR 42S01: Table 't1' already exists
+connection default;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -39,10 +58,15 @@ t1 CREATE TABLE `t1` (
drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
rename table t3 to t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
ERROR 42S01: Table 't1' already exists
+connection default;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -51,10 +75,15 @@ t1 CREATE TABLE `t1` (
drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
alter table t3 rename to t1;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
ERROR 42S01: Table 't1' already exists
+connection default;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -63,10 +92,15 @@ t1 CREATE TABLE `t1` (
drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
alter table t3 rename to t1, add k int;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
ERROR 42S01: Table 't1' already exists
+connection default;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -74,30 +108,51 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t3;
set debug_sync='create_table_select_before_open SIGNAL parked WAIT_FOR go';
+connection default;
set debug_sync='create_table_select_before_open SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
drop table t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
rename table t1 to t2;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
drop table t2;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
select * from t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
i
1
+connection default;
drop table t1;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
insert into t1 values (2);;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
select * from t1;
i
1
@@ -106,37 +161,62 @@ drop table t1;
set @a:=0;
set debug_sync='create_table_select_before_create SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
create trigger t1_bi before insert on t1 for each row set @a:=1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
select @a;
@a
0
drop table t1;
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
drop table t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
rename table t1 to t2;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
drop table t2;
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
select * from t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
i
1
+connection default;
drop table t1;
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
insert into t1 values (2);;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
select * from t1;
i
1
@@ -145,27 +225,42 @@ drop table t1;
set @a:=0;
set debug_sync='create_table_select_before_lock SIGNAL parked WAIT_FOR go';
create table t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
create trigger t1_bi before insert on t1 for each row set @a:=1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
select @a;
@a
0
drop table t1;
set debug_sync='create_table_select_before_check_if_exists SIGNAL parked WAIT_FOR go';
create table if not exists t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
drop table t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
create table t1 (i int);
set @a:=0;
set debug_sync='create_table_select_before_check_if_exists SIGNAL parked WAIT_FOR go';
create table if not exists t1 select 1 as i;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
create trigger t1_bi before insert on t1 for each row set @a:=1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
Warnings:
Note 1050 Table 't1' already exists
+connection addconroot1;
+connection default;
select @a;
@a
0
@@ -178,10 +273,15 @@ create table t1 (i int);
set debug_sync='create_table_like_after_open SIGNAL parked WAIT_FOR go';
reset master;
create table t2 like t1;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
insert into t1 values (1);
drop table t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
@@ -203,21 +303,39 @@ create table t1 (i int);
set debug_sync='create_table_like_before_binlog SIGNAL parked WAIT_FOR go';
reset master;
create table t2 like t1;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
insert into t2 values (1);;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
drop table t2;
set debug_sync='create_table_like_before_binlog SIGNAL parked WAIT_FOR go';
create table t2 like t1;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
drop table t2;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
set debug_sync='create_table_like_before_binlog SIGNAL parked WAIT_FOR go';
create table t2 like t1;;
+connection addconroot1;
set debug_sync='now WAIT_FOR parked';
drop table t1;;
+connection addconroot2;
set debug_sync='now SIGNAL go';
+connection default;
+connection addconroot1;
+connection default;
drop table t2;
+disconnect addconroot1;
+disconnect addconroot2;
+disconnect addconroot3;
set debug_sync='RESET';
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index cad46f34c75..7b54f0633b5 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -567,9 +567,13 @@ select database();
database()
NULL
create user mysqltest_1;
+connect user1,localhost,mysqltest_1,,*NO-ONE*;
+connection user1;
select database(), user();
database() user()
NULL mysqltest_1@localhost
+connection default;
+disconnect user1;
drop user mysqltest_1;
use test;
create table t1 (a int, index `primary` (a));
@@ -1813,6 +1817,7 @@ create table t1 (a int, b int) engine=myisam;
create table t2 (a int, b int) engine=myisam;
insert into t1 values (1,1);
lock tables t1 read;
+connect user1,localhost,root,,test;
set @@lock_wait_timeout=5;
create table if not exists t1 (a int, b int);
Warnings:
@@ -1831,6 +1836,8 @@ create table t1 like t2;
ERROR 42S01: Table 't1' already exists
create or replace table t1 (a int, b int) select 2,2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+disconnect user1;
+connection default;
select * from t1;
a b
1 1
diff --git a/mysql-test/r/create_drop_role.result b/mysql-test/r/create_drop_role.result
index 6e05900264d..498dd4c1c02 100644
--- a/mysql-test/r/create_drop_role.result
+++ b/mysql-test/r/create_drop_role.result
@@ -43,6 +43,8 @@ CREATE USER u1@localhost;
REVOKE SHOW DATABASES ON *.* FROM 'u1'@'localhost';
GRANT SHOW DATABASES ON *.* TO role_1;
GRANT role_1 TO u1@localhost;
+connect user_a, localhost, u1,,;
+connection user_a;
SELECT CURRENT_USER;
CURRENT_USER
u1@localhost
@@ -65,6 +67,8 @@ mysql
performance_schema
test
SET ROLE NONE;
+connect user_b, localhost, root,,;
+connection user_b;
# Clearing up
DROP ROLE role_1;
DROP ROLE IF EXISTS role_1;
diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result
index ed25fbadf45..dc3d00aacc8 100644
--- a/mysql-test/r/create_or_replace.result
+++ b/mysql-test/r/create_or_replace.result
@@ -432,11 +432,18 @@ unlock tables;
CREATE TABLE t1 (col_int_nokey INT) ENGINE=InnoDB;
CREATE OR REPLACE TEMPORARY TABLE tmp LIKE t1;
LOCK TABLE t1 WRITE;
+connect con1,localhost,root,,test;
CREATE OR REPLACE TABLE t1 LIKE tmp;
+connection default;
KILL QUERY con_id;
+connection con1;
ERROR 70100: Query execution was interrupted
CREATE OR REPLACE TABLE t1 (a int);
+connection default;
KILL QUERY con_id;
+connection con1;
ERROR 70100: Query execution was interrupted
+disconnect con1;
+connection default;
drop table t1;
DROP TABLE t2;
diff --git a/mysql-test/r/create_or_replace2.result b/mysql-test/r/create_or_replace2.result
index 6f5e412b91c..47431212492 100644
--- a/mysql-test/r/create_or_replace2.result
+++ b/mysql-test/r/create_or_replace2.result
@@ -17,9 +17,11 @@ t1 CREATE TABLE `t1` (
`b` int(11) DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
+connection slave;
SHOW TABLES;
Tables_in_test
t1
+connection master;
drop temporary table if exists tmp;
drop table t1;
include/rpl_end.inc
diff --git a/mysql-test/r/create_or_replace_permission.result b/mysql-test/r/create_or_replace_permission.result
index f662bf1bfd8..b9938e4270a 100644
--- a/mysql-test/r/create_or_replace_permission.result
+++ b/mysql-test/r/create_or_replace_permission.result
@@ -19,6 +19,8 @@ REVOKE ALTER ROUTINE ON db1.* FROM mysqltest_1@localhost;
GRANT DELETE ON mysql.* TO mysqltest_1@localhost;
REVOKE DELETE ON mysql.* FROM mysqltest_1@localhost;
FLUSH PRIVILEGES;
+connect user_a, localhost, mysqltest_1,,;
+connection user_a;
SELECT CURRENT_USER;
CURRENT_USER
mysqltest_1@localhost
@@ -41,6 +43,7 @@ CREATE OR REPLACE USER u1@localhost;
ERROR 42000: Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
CREATE OR REPLACE ROLE developer;
ERROR 42000: Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
+connection default;
SELECT CURRENT_USER;
CURRENT_USER
root@localhost
diff --git a/mysql-test/r/cte_grant.result b/mysql-test/r/cte_grant.result
index 4b067f42ff2..1282a98fdef 100644
--- a/mysql-test/r/cte_grant.result
+++ b/mysql-test/r/cte_grant.result
@@ -1,11 +1,17 @@
+connect root,localhost,root,,test;
+connection root;
create database mysqltest;
create user mysqltest_1@localhost;
+connect user1,localhost,mysqltest_1,,test;
+connection user1;
+connection root;
create table mysqltest.t1 (a int, b int);
insert into mysqltest.t1 values (2,10), (1,30);
create table mysqltest.t2 (c int, d char(32));
insert into mysqltest.t2 values (1,'xxx'), (1,'zzz');
grant select on mysqltest.t1 to mysqltest_1@localhost;
grant select (c) on mysqltest.t2 to mysqltest_1@localhost;
+connection user1;
with t as (select c from mysqltest.t2 where c < 2)
select t.c,t1.b from t,mysqltest.t1 where t.c=t1.a;
c b
@@ -18,6 +24,7 @@ ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column
with t as (select c,d from mysqltest.t2 where c < 2)
select t.c,t.d,t1.b from t,mysqltest.t1 where t.c=t1.a;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 't2'
+connection root;
create view mysqltest.v1(f1,f2) as
with t as (select c from mysqltest.t2 where c < 2)
select t.c,t1.b from t,mysqltest.t1 where t.c=t1.a;
@@ -27,6 +34,7 @@ select t.a,b from t,mysqltest.t1 where mysqltest.t1.a = t.a;
grant select on mysqltest.v1 to mysqltest_1@localhost;
grant select (c) on mysqltest.v2 to mysqltest_1@localhost;
grant create view on mysqltest.* to mysqltest_1@localhost;
+connection user1;
create view mysqltest.v3(c,d) as
with t as (select c from mysqltest.t2 where c < 2)
select t.c,t1.b from t,mysqltest.t1 where t.c=t1.a;
@@ -44,11 +52,14 @@ select d from mysqltest.v2;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v2'
select * from mysqltest.v3;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v3'
+connection root;
grant select on mysqltest.v3 to mysqltest_1@localhost;
+connection user1;
select * from mysqltest.v3;
c d
1 30
1 30
+connection root;
revoke all privileges on mysqltest.v1 from mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
diff --git a/mysql-test/r/ctype_errors.result b/mysql-test/r/ctype_errors.result
index 5ae8c53ce8b..6f9e14a8942 100644
--- a/mysql-test/r/ctype_errors.result
+++ b/mysql-test/r/ctype_errors.result
@@ -1,5 +1,7 @@
Start of 5.4 tests
CREATE TABLE t1(f1 INT);
+connect con1,localhost,root,,test;
+connection con1;
SET lc_messages=ru_RU;
SHOW VARIABLES LIKE 'lc_messages';
Variable_name Value
@@ -9,6 +11,7 @@ ERROR 42S01: \0422\0430\0431\043B\0438\0446\0430 't1' \0443\0436\0435 \0441\0443
SET NAMES utf8;
CREATE TABLE t1(f1 INT);
ERROR 42S01: Таблица 't1' уже ÑущеÑтвует
+connection default;
SHOW VARIABLES LIKE 'lc_messages';
Variable_name Value
lc_messages en_US
@@ -22,21 +25,27 @@ SHOW GLOBAL VARIABLES LIKE 'lc_messages';
Variable_name Value
lc_messages ru_RU
SET GLOBAL lc_messages=en_US;
+disconnect con1;
DROP TABLE t1;
drop table `ק`;
ERROR 42S02: Unknown table 'test.ק'
+connect con1,localhost,root,,test;
+connection con1;
SET lc_messages=cs_CZ;
SET NAMES UTF8;
USE nonexistant;
ERROR 42000: Neznámá databáze 'nonexistant'
+disconnect con1;
+connection default;
#
# Bug#12736295: Buffer overflow for variable converted_err
# with non-latin1 server error message
#
-# Connection con1
+connect con1,localhost,root,,test;
SET lc_messages=ru_RU;
SET NAMES latin1;
SELECT '01234567890123456789012345678901234\';
ERROR 42000: \0423 \0432\0430\0441 \043E\0448\0438\0431\043A\0430 \0432 \0437\0430\043F\0440\043E\0441\0435. \0418\0437\0443\0447\0438\0442\0435 \0434\043E\043A\0443\043C\0435\043D\0442\0430\0446\0438\044E \043F\043E \0438\0441\043F\043E\043B\044C\0437\0443\0435\043C\043E\0439 \0432\0435\0440\0441\0438\0438 MariaDB \043D\0430 \043F\0440\0435\0434\043C\0435\0442 \043A\043E\0440\0440\0435\043A\0442\043D\043E\0433\043E \0441\0438\043D\0442\0430\043A\0441\0438\0441\0430 \043E\043A\043E\043B\043E ''0123456789012345678901234
-# Connection default
+disconnect con1;
+connection default;
End of 5.5 tests
diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result
index d81b6af0aeb..8423f8fe367 100644
--- a/mysql-test/r/ddl_i18n_koi8r.result
+++ b/mysql-test/r/ddl_i18n_koi8r.result
@@ -61,8 +61,7 @@ SELECT * FROM v3|
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
-
----> connection: con2
+connect con2,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -118,8 +117,7 @@ DROP DATABASE mysqltest1|
---> Restoring mysqltest1...
-
----> connection: con3
+connect con3,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -167,8 +165,9 @@ utf8_general_ci
SELECT * FROM v3|
ÔÅÓÔ
ÔÅÓÔ
-
----> connection: default
+connection default;
+disconnect con2;
+disconnect con3;
use test|
DROP DATABASE mysqltest1|
@@ -477,8 +476,7 @@ utf8_general_ci utf8_general_ci
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
-
----> connection: con2
+connect con2,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -879,8 +877,7 @@ DROP DATABASE mysqltest2|
---> Restoring mysqltest1...
---> Restoring mysqltest2...
-
----> connection: con3
+connect con3,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -1121,8 +1118,9 @@ koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r
SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
ca cb
utf8_general_ci utf8_general_ci
-
----> connection: default
+connection default;
+disconnect con2;
+disconnect con3;
use test|
DROP DATABASE mysqltest1|
DROP DATABASE mysqltest2|
@@ -1459,8 +1457,7 @@ ALTER TABLE t1 ADD COLUMN fake INT|
ALTER TABLE t1 DROP COLUMN fake|
ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
-
----> connection: con2
+connect con2,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -1894,8 +1891,7 @@ ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT|
ALTER TABLE mysqltest1.t1 DROP COLUMN fake|
ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
-
----> connection: con3
+connect con3,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -2159,8 +2155,9 @@ ca1 ca2 ca3 cb1 cb2 cb3
koi8r_general_ci utf8_general_ci koi8r_general_ci koi8r_general_ci utf8_general_ci koi8r_general_ci
DELETE FROM mysqltest2.log|
-
----> connection: default
+connection default;
+disconnect con2;
+disconnect con3;
use test|
DROP DATABASE mysqltest1|
DROP DATABASE mysqltest2|
@@ -2348,8 +2345,7 @@ END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREAT
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
-
----> connection: con2
+connect con2,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -2621,8 +2617,7 @@ DROP DATABASE mysqltest2|
---> Restoring mysqltest1...
---> Restoring mysqltest2...
-
----> connection: con3
+connect con3,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -2829,12 +2824,11 @@ Table Create Table
t2 CREATE TABLE `t2` (
`col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
-
----> connection: con2
-
----> connection: con3
-
----> connection: default
+connection con2;
+disconnect con2;
+connection con3;
+disconnect con3;
+connection default;
USE test;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result
index 5921a7f538d..2c9ea77b809 100644
--- a/mysql-test/r/ddl_i18n_utf8.result
+++ b/mysql-test/r/ddl_i18n_utf8.result
@@ -61,8 +61,7 @@ SELECT * FROM v3|
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
-
----> connection: con2
+connect con2,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -118,8 +117,7 @@ DROP DATABASE mysqltest1|
---> Restoring mysqltest1...
-
----> connection: con3
+connect con3,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -167,8 +165,9 @@ koi8r_general_ci
SELECT * FROM v3|
теÑÑ‚
теÑÑ‚
-
----> connection: default
+connection default;
+disconnect con2;
+disconnect con3;
use test|
DROP DATABASE mysqltest1|
@@ -477,8 +476,7 @@ utf8_general_ci utf8_general_ci
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
-
----> connection: con2
+connect con2,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -879,8 +877,7 @@ DROP DATABASE mysqltest2|
---> Restoring mysqltest1...
---> Restoring mysqltest2...
-
----> connection: con3
+connect con3,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -1121,8 +1118,9 @@ utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8
SELECT COLLATION(@a) AS ca, COLLATION(@b) cb|
ca cb
utf8_general_ci utf8_general_ci
-
----> connection: default
+connection default;
+disconnect con2;
+disconnect con3;
use test|
DROP DATABASE mysqltest1|
DROP DATABASE mysqltest2|
@@ -1459,8 +1457,7 @@ ALTER TABLE t1 ADD COLUMN fake INT|
ALTER TABLE t1 DROP COLUMN fake|
ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
-
----> connection: con2
+connect con2,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -1894,8 +1891,7 @@ ALTER TABLE mysqltest1.t1 ADD COLUMN fake INT|
ALTER TABLE mysqltest1.t1 DROP COLUMN fake|
ALTER TABLE mysqltest2.t1 ADD COLUMN fake INT|
ALTER TABLE mysqltest2.t1 DROP COLUMN fake|
-
----> connection: con3
+connect con3,localhost,root,,;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -2159,8 +2155,9 @@ ca1 ca2 ca3 cb1 cb2 cb3
utf8_general_ci utf8_general_ci koi8r_general_ci utf8_general_ci utf8_general_ci koi8r_general_ci
DELETE FROM mysqltest2.log|
-
----> connection: default
+connection default;
+disconnect con2;
+disconnect con3;
use test|
DROP DATABASE mysqltest1|
DROP DATABASE mysqltest2|
@@ -2348,8 +2345,7 @@ END ONE TIME 2030-01-01 00:00:00 NULL NULL NULL NULL ENABLED NOT PRESERVE CREAT
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
ALTER DATABASE mysqltest2 COLLATE cp866_general_ci|
-
----> connection: con2
+connect con2,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -2621,8 +2617,7 @@ DROP DATABASE mysqltest2|
---> Restoring mysqltest1...
---> Restoring mysqltest2...
-
----> connection: con3
+connect con3,localhost,root,,mysqltest1;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
@@ -2829,12 +2824,11 @@ Table Create Table
t2 CREATE TABLE `t2` (
`col1` varchar(10) COLLATE cp1251_general_cs DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_general_cs
-
----> connection: con2
-
----> connection: con3
-
----> connection: default
+connection con2;
+disconnect con2;
+connection con3;
+disconnect con3;
+connection default;
USE test;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
diff --git a/mysql-test/r/deadlock_innodb.result b/mysql-test/r/deadlock_innodb.result
index 7a4874d6aab..af78a6aa9d5 100644
--- a/mysql-test/r/deadlock_innodb.result
+++ b/mysql-test/r/deadlock_innodb.result
@@ -1,31 +1,31 @@
-# Establish connection con1 (user=root)
-# Establish connection con2 (user=root)
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
drop table if exists t1,t2;
-# Switch to connection con1
+connection con1;
create table t1 (id integer, x integer) engine = InnoDB;
insert into t1 values(0, 0);
set autocommit=0;
SELECT * from t1 where id = 0 FOR UPDATE;
id x
0 0
-# Switch to connection con2
+connection con2;
set autocommit=0;
update t1 set x=2 where id = 0;
-# Switch to connection con1
+connection con1;
update t1 set x=1 where id = 0;
select * from t1;
id x
0 1
commit;
-# Switch to connection con2
+connection con2;
commit;
-# Switch to connection con1
+connection con1;
select * from t1;
id x
0 2
commit;
drop table t1;
-# Switch to connection con1
+connection con1;
create table t1 (id integer, x integer) engine = InnoDB;
create table t2 (b integer, a integer) engine = InnoDB;
insert into t1 values(0, 0), (300, 300);
@@ -47,19 +47,19 @@ select * from t1;
id x
0 0
300 300
-# Switch to connection con2
+connection con2;
set autocommit=0;
update t1 set x=2 where id = 0;
-# Switch to connection con1
+connection con1;
update t1 set x=1 where id = 0;
select * from t1;
id x
0 1
300 300
commit;
-# Switch to connection con2
+connection con2;
commit;
-# Switch to connection con1
+connection con1;
select * from t1;
id x
0 2
@@ -71,7 +71,7 @@ create table t2 (b integer, a integer) engine = InnoDB;
insert into t1 values(0, 0), (300, 300);
insert into t2 values(0, 0), (1, 20), (2, 30);
commit;
-# Switch to connection con1
+connection con1;
select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
a b
0 0
@@ -87,7 +87,7 @@ select * from t1;
id x
0 0
300 300
-# Switch to connection con2
+connection con2;
update t2 set a=2 where b = 0;
select * from t2;
b a
@@ -95,22 +95,24 @@ b a
1 20
2 30
update t1 set x=2 where id = 0;
-# Switch to connection con1
+connection con1;
update t1 set x=1 where id = 0;
select * from t1;
id x
0 1
300 300
commit;
-# Switch to connection con2
+connection con2;
commit;
-# Switch to connection con1
+connection con1;
select * from t1;
id x
0 2
300 300
commit;
-# Switch to connection default + disconnect con1 and con2
+connection default;
+disconnect con1;
+disconnect con2;
drop table t1, t2;
End of 4.1 tests
set storage_engine=innodb;
diff --git a/mysql-test/r/debug_sync.result b/mysql-test/r/debug_sync.result
index 25fdf523200..8498a908000 100644
--- a/mysql-test/r/debug_sync.result
+++ b/mysql-test/r/debug_sync.result
@@ -234,44 +234,48 @@ Variable_name Value
debug_sync ON - current signal: ''
CREATE USER mysqltest_1@localhost;
GRANT SUPER ON *.* TO mysqltest_1@localhost;
-connection con1, mysqltest_1
+connect con1,localhost,mysqltest_1,,;
SET DEBUG_SYNC= 'RESET';
-connection default
+disconnect con1;
+connection default;
DROP USER mysqltest_1@localhost;
CREATE USER mysqltest_2@localhost;
GRANT ALL ON *.* TO mysqltest_2@localhost;
REVOKE SUPER ON *.* FROM mysqltest_2@localhost;
-connection con1, mysqltest_2
+connect con1,localhost,mysqltest_2,,;
SET DEBUG_SYNC= 'RESET';
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
-connection default
+disconnect con1;
+connection default;
DROP USER mysqltest_2@localhost;
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT);
-connection con1
+connect con1,localhost,root,,;
SET DEBUG_SYNC= 'before_lock_tables_takes_lock
SIGNAL opened WAIT_FOR flushed';
INSERT INTO t1 VALUES(1);
-connection default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
SET DEBUG_SYNC= 'after_flush_unlock SIGNAL flushed';
FLUSH TABLE t1;
-connection con1
-connection default
+connection con1;
+disconnect con1;
+connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c1 INT);
LOCK TABLE t1 READ;
-connection con1
+connect con1,localhost,root,,;
SET DEBUG_SYNC= 'wait_for_lock SIGNAL locked EXECUTE 2';
INSERT INTO t1 VALUES (1);
-connection default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
UNLOCK TABLES;
-connection con1
+connection con1;
retrieve INSERT result.
-connection default
+disconnect con1;
+connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result
index 98c8b599e88..80b99115055 100644
--- a/mysql-test/r/delayed.result
+++ b/mysql-test/r/delayed.result
@@ -297,16 +297,21 @@ drop table if exists t1;
create table t1 (a int, b int);
insert into t1 values (1,1);
lock table t1 read;
-connection: update
+connect update,localhost,root,,;
+connection update;
insert delayed into t1 values (2,2);;
-connection: select
+connection default;
+connect select,localhost,root,,;
select * from t1;
a b
1 1
-connection: default
+connection default;
select * from t1;
a b
1 1
+connection default;
+disconnect update;
+disconnect select;
unlock tables;
select * from t1;
a b
@@ -359,70 +364,70 @@ CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT);
# Test 1: Using LOCK TABLE
-# Connection con1
+connect con1, localhost, root;
LOCK TABLE t1 WRITE;
-# Connection default
+connection default;
LOCK TABLE t2 WRITE;
# Sending:
INSERT DELAYED INTO t1 VALUES (1);
-# Connection con1
+connection con1;
# Wait until INSERT DELAYED is blocked on table 't1'.
INSERT DELAYED INTO t2 VALUES (1);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
UNLOCK TABLES;
-# Connection default
+connection default;
# Reaping: INSERT DELAYED INTO t1 VALUES (1)
UNLOCK TABLES;
# Test 2: Using ALTER TABLE
START TRANSACTION;
SELECT * FROM t1 WHERE a=0;
a
-# Connection con1
+connection con1;
# Sending:
ALTER TABLE t1 MODIFY a INT UNSIGNED;;
-# Connection default
+connection default;
# Wait until ALTER TABLE is blocked on table 't1'.
INSERT DELAYED INTO t1 VALUES (3);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
-# Connection con1
+connection con1;
# Reaping: ALTER TABLE t1 COMMENT 'test'
# Test 3: Using RENAME TABLE
-# Connection default
+connection default;
START TRANSACTION;
INSERT INTO t2 VALUES (1);
-# Connection con1
+connection con1;
# Sending:
RENAME TABLE t1 to t5, t2 to t4;
-# Connection default
+connection default;
# Wait until RENAME TABLE is blocked on table 't1'.
INSERT DELAYED INTO t1 VALUES (4);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
-# Connection con1
+connection con1;
# Reaping: RENAME TABLE t1 to t5, t2 to t4
-# Connection default
+connection default;
# Reverting the renames
RENAME TABLE t5 to t1, t4 to t2;
# Test 4: Two INSERT DELAYED on the same table
START TRANSACTION;
INSERT INTO t2 VALUES (1);
-# Connection con2
+connect con2, localhost, root;
LOCK TABLE t1 WRITE, t2 WRITE;
-# Connection con1
+connection con1;
# Wait until LOCK TABLE is blocked on table 't2'.
INSERT DELAYED INTO t1 VALUES (5);
-# Connection default
+connection default;
# Wait until INSERT DELAYED is blocked on table 't1'.
INSERT DELAYED INTO t1 VALUES (6);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
-# Connection con2
+connection con2;
# Reaping: LOCK TABLE t1 WRITE, t2 WRITE
UNLOCK TABLES;
-# Connection con1
+connection con1;
# Reaping: INSERT DELAYED INTO t1 VALUES (5)
-# Connection default
+connection default;
# Test 5: LOCK TABLES + INSERT DELAYED in one connection.
# This test has triggered some asserts in metadata locking
# subsystem at some point in time..
@@ -434,13 +439,17 @@ LOCK TABLE t1 WRITE;
INSERT DELAYED INTO t2 VALUES (8);
UNLOCK TABLES;
SET AUTOCOMMIT= 1;
-# Connection con2
-# Connection con1
-# Connection default
+connection con2;
+disconnect con2;
+connection con1;
+disconnect con1;
+connection default;
DROP TABLE t1, t2, t3;
#
# Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables".
#
+connect con1,localhost,root,,;
+connection default;
drop table if exists t1, t2, tm;
create table t1(a int);
create table t2(a int);
@@ -448,10 +457,10 @@ create table tm(a int) engine=merge union=(t1, t2);
begin;
select * from t1;
a
-# Connection 'con1'.
+connection con1;
# Sending:
alter table t1 comment 'test';
-# Connection 'default'.
+connection default;
# Wait until ALTER TABLE blocks and starts waiting
# for connection 'default'. It should wait with a
# pending SNW lock on 't1'.
@@ -462,7 +471,8 @@ insert delayed into tm values (1);
ERROR HY000: DELAYED option not supported for table 'tm'
# Unblock ALTER TABLE.
commit;
-# Connection 'con1'.
+connection con1;
# Reaping ALTER TABLE:
-# Connection 'default'.
+disconnect con1;
+connection default;
drop tables tm, t1, t2;
diff --git a/mysql-test/r/delete_returning_grant.result b/mysql-test/r/delete_returning_grant.result
index bdd171940ba..b41d48a7112 100644
--- a/mysql-test/r/delete_returning_grant.result
+++ b/mysql-test/r/delete_returning_grant.result
@@ -4,10 +4,14 @@ CREATE TABLE t1 (a int(11), b varchar(32));
INSERT INTO t1 VALUES (7,'ggggggg'),(1,'a'),(3,'ccc'),(4,'dddd'),(1,'A'),
(2,'BB'),(4,'DDDD'),(5,'EEEEE'),(7,'GGGGGGG'),(2,'bb');
CREATE VIEW v1 AS SELECT a, UPPER(b) FROM t1;
+connect root,localhost,root,,test;
+connection root;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.t1 SELECT * FROM t1;
GRANT DELETE ON mysqltest.* TO mysqltest_1@localhost;
GRANT SELECT(b) ON mysqltest.t1 TO mysqltest_1@localhost;
+connect user1,localhost,mysqltest_1,,test;
+connection user1;
DELETE FROM mysqltest.t1 WHERE a=2 RETURNING b;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't1'
DELETE FROM mysqltest.t1 RETURNING b;
@@ -22,6 +26,7 @@ DDDD
EEEEE
GGGGGGG
bb
+connection root;
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
@@ -41,15 +46,19 @@ a b
1 a
7 ggggggg
INSERT INTO mysqltest.t1 SELECT * FROM t1;
+connection root;
CREATE VIEW mysqltest.v1(a) AS SELECT a FROM mysqltest.t1;
GRANT SELECT, INSERT ON mysqltest.t1 TO mysqltest_1@localhost;
+connection user1;
DELETE FROM mysqltest.v1;
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
DELETE FROM mysqltest.v1 RETURNING a;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 'v1'
+connection root;
GRANT SELECT ON mysqltest.* TO mysqltest_1@localhost;
+connection user1;
DELETE FROM mysqltest.v1 RETURNING a;
a
7
@@ -65,7 +74,9 @@ a
SELECT * FROM mysqltest.t1;
a b
INSERT INTO mysqltest.t1 SELECT * FROM t1;
+connection root;
DROP DATABASE mysqltest;
+disconnect user1;
DROP USER mysqltest_1@localhost;
DROP VIEW v1;
DROP TABLE t1;
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 1d643333424..d3c0aae91db 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -206,6 +206,8 @@ x
1
create user mysqltest_1;
create table t1 select 1 as a;
+connect con1,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection con1;
set optimizer_switch='derived_merge=off,derived_with_keys=off';
select 2 as a from (select * from t1) b;
ERROR 3D000: No database selected
@@ -385,6 +387,9 @@ ID DATA FID
select t2.* from (select * from t1) as A inner join t2 on A.ID = t2.FID;
ID DATA FID
drop table t1, t2;
+connection con1;
+disconnect con1;
+connection default;
drop user mysqltest_1;
# End of 4.1 tests
SELECT 0 FROM
diff --git a/mysql-test/r/dirty_close.result b/mysql-test/r/dirty_close.result
index f7012ff9c01..d13fdb09192 100644
--- a/mysql-test/r/dirty_close.result
+++ b/mysql-test/r/dirty_close.result
@@ -1,3 +1,8 @@
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+disconnect con1;
+connection con2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (n INT);
INSERT INTO t1 VALUES (1),(2),(3);
@@ -7,13 +12,25 @@ n
2
3
DROP TABLE t1;
+connection default;
+disconnect con2;
+connection default;
SELECT GET_LOCK("dangling", 0);
GET_LOCK("dangling", 0)
1
+connect con1, localhost, root,,;
+connection con1;
SELECT GET_LOCK('dangling', 3600);;
+connection default;
+disconnect con1;
+connect con1, localhost, root,,;
SELECT GET_LOCK('dangling', 3600);;
+connection default;
SELECT RELEASE_LOCK('dangling');
RELEASE_LOCK('dangling')
1
+connection con1;
GET_LOCK('dangling', 3600)
1
+connection default;
+disconnect con1;
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result
index c23ffbe327b..e2d69a75067 100644
--- a/mysql-test/r/drop.result
+++ b/mysql-test/r/drop.result
@@ -82,13 +82,22 @@ drop table if exists t1;
create table t1 (i int);
create database mysqltest;
lock tables t1 read;
+connect addconroot1, localhost, root,,;
drop table t1;
+connect addconroot2, localhost, root,,;
show open tables;
drop database mysqltest;
+connection default;
select 1;
1
1
unlock tables;
+connection addconroot1;
+connection addconroot2;
+disconnect addconroot2;
+connection addconroot1;
+disconnect addconroot1;
+connection default;
drop table if exists t1,t2;
create table t1 (a int);
create table t2 (a int);
@@ -99,14 +108,20 @@ drop table t1;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
unlock tables;
drop table t1,t2;
+connect addconroot, localhost, root,,;
+connection default;
create table t1 (i int);
create table t2 (i int);
lock tables t1 read;
+connection addconroot;
lock tables t2 read;
drop table t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES
+connection default;
drop table t1,t2;
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+disconnect addconroot;
+connection default;
unlock tables;
drop table t1,t2;
End of 5.0 tests
diff --git a/mysql-test/r/empty_user_table.result b/mysql-test/r/empty_user_table.result
index b93596ab59a..54a7fd4907b 100644
--- a/mysql-test/r/empty_user_table.result
+++ b/mysql-test/r/empty_user_table.result
@@ -2,6 +2,7 @@ create table t1 as select * from mysql.user;
truncate table mysql.user;
flush privileges;
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET);
+connect fail,localhost,u1;
Got one of the listed errors
insert mysql.user select * from t1;
drop table t1;
diff --git a/mysql-test/r/enforce_storage_engine.result b/mysql-test/r/enforce_storage_engine.result
index 6b5e1f6958b..296ed405a72 100644
--- a/mysql-test/r/enforce_storage_engine.result
+++ b/mysql-test/r/enforce_storage_engine.result
@@ -69,8 +69,12 @@ ERROR 42000: Unknown storage engine 'FooBar'
select @@session.enforce_storage_engine;
@@session.enforce_storage_engine
MyISAM
+connect con1,localhost,user_1,,;
+connection con1;
SET SESSION enforce_storage_engine=MyISAM;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
+disconnect con1;
+connection default;
SET SESSION enforce_storage_engine=NULL;
SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION';
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=Memory;
@@ -102,6 +106,8 @@ t1 CREATE TABLE `t1` (
DROP TABLE t1;
SET GLOBAL enforce_storage_engine=Memory;
SET SESSION sql_mode='';
+connect con1,localhost,root,,;
+connection con1;
select @@session.enforce_storage_engine;
@@session.enforce_storage_engine
MEMORY
@@ -119,6 +125,8 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`c1`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1
DROP TABLE t1;
+connection default;
+disconnect con1;
set global sql_mode=default;
SET SESSION enforce_storage_engine=NULL;
SET GLOBAL enforce_storage_engine=NULL;
diff --git a/mysql-test/r/events_1.result b/mysql-test/r/events_1.result
index 153137bc4f9..70443604f41 100644
--- a/mysql-test/r/events_1.result
+++ b/mysql-test/r/events_1.result
@@ -11,8 +11,10 @@ CREATE DATABASE db_x;
GRANT EVENT ON db_x.* TO pauline@localhost;
USE db_x;
CREATE TABLE x_table(a int);
+connect priv_conn,localhost,pauline,,db_x;
CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x;
CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table;
+connection default;
SHOW DATABASES LIKE 'db_x';
Database (db_x)
db_x
@@ -24,8 +26,11 @@ SHOW TABLES FROM db_x;
Tables_in_db_x
x_table
SET GLOBAL event_scheduler=off;
+connection priv_conn;
DROP EVENT e_x1;
DROP EVENT e_x2;
+disconnect priv_conn;
+connection default;
DROP DATABASE db_x;
DROP USER pauline@localhost;
USE events_test;
diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result
index bde4f1c785b..e8b849f8ce3 100644
--- a/mysql-test/r/events_bugs.result
+++ b/mysql-test/r/events_bugs.result
@@ -203,10 +203,13 @@ drop database if exists mysqltest_db1;
create user mysqltest_user1@localhost;
create database mysqltest_db1;
grant event on events_test.* to mysqltest_user1@localhost;
+connect conn2,localhost,mysqltest_user1,,events_test;
create event mysqltest_user1 on schedule every 10 second do select 42;
alter event mysqltest_user1 rename to mysqltest_db1.mysqltest_user1;
ERROR 42000: Access denied for user 'mysqltest_user1'@'localhost' to database 'mysqltest_db1'
"Let's test now rename when there is no select DB"
+disconnect conn2;
+connect conn2,localhost,mysqltest_user1,,*NO-ONE*;
select database();
database()
NULL
@@ -216,6 +219,8 @@ select event_schema, event_name, definer, event_type, status from information_sc
event_schema event_name definer event_type status
events_test mysqltest_user1 mysqltest_user1@localhost RECURRING ENABLED
drop event events_test.mysqltest_user1;
+disconnect conn2;
+connection default;
drop user mysqltest_user1@localhost;
drop database mysqltest_db1;
create event e_53 on schedule at (select s1 from ttx) do drop table t;
@@ -366,6 +371,7 @@ SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS;
event_name definer
e1 mysqltest_u1@localhost
DROP EVENT e1;
+connect conn1, localhost, mysqltest_u1, , events_test;
CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS;
event_name definer
@@ -390,6 +396,8 @@ CREATE DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
DROP EVENT e1;
ERROR HY000: Unknown event 'e1'
+disconnect conn1;
+connection default;
DROP USER mysqltest_u1@localhost;
SET GLOBAL EVENT_SCHEDULER= OFF;
SET @save_time_zone= @@TIME_ZONE;
@@ -586,7 +594,7 @@ Grants for evtest1@localhost
GRANT USAGE ON *.* TO 'evtest1'@'localhost' IDENTIFIED BY PASSWORD '*3170F3644E31580C25DE4A08F4C07CC9A2D40C32'
GRANT SELECT, INSERT ON `test`.* TO 'evtest1'@'localhost'
GRANT SELECT, INSERT, CREATE, EVENT ON `events_test`.* TO 'evtest1'@'localhost'
-connection e1;
+connect e1,localhost,evtest1,ev1,events_test,$MASTER_MYPORT,$MASTER_MYSOCK;
CREATE EVENT ev_sched_1823 ON SCHEDULE EVERY 2 SECOND
DO BEGIN
SET AUTOCOMMIT = 0;
@@ -615,6 +623,7 @@ Sleep 4 seconds
SELECT COUNT(*) > @row_cnt AS "Expect 0" FROM events_test.event_log;
Expect 0
0
+disconnect e1;
DROP EVENT events_test.ev_sched_1823;
DROP TABLE events_test.event_log;
SET GLOBAL event_scheduler = OFF;
@@ -640,9 +649,7 @@ GRANT EVENT ON *.* TO mysqltest_u1@localhost;
SET GLOBAL READ_ONLY = 1;
-#
-# Connection: u1_con (mysqltest_u1@localhost/events_test).
-#
+connect u1_con,localhost,mysqltest_u1,,events_test;
CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1;
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
@@ -653,9 +660,7 @@ ERROR HY000: The MariaDB server is running with the --read-only option so it can
DROP EVENT e1;
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
-#
-# Connection: root_con (root@localhost/events_test).
-#
+connect root_con,localhost,root,,events_test;
CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1;
@@ -665,9 +670,7 @@ DROP EVENT e1;
SET GLOBAL READ_ONLY = 0;
-#
-# Connection: u1_con (mysqltest_u1@localhost/test).
-#
+connection u1_con;
CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1;
CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1;
@@ -682,9 +685,7 @@ event_name last_executed IS NULL definer
e1 1 mysqltest_u1@localhost
e2 1 mysqltest_u1@localhost
-#
-# Connection: root_con (root@localhost/events_test).
-#
+connection root_con;
SET GLOBAL READ_ONLY = 1;
@@ -714,9 +715,9 @@ DROP EVENT e2;
SET GLOBAL READ_ONLY = 0;
-#
-# Connection: default
-#
+disconnect u1_con;
+disconnect root_con;
+connection default;
DROP USER mysqltest_u1@localhost;
diff --git a/mysql-test/r/events_grant.result b/mysql-test/r/events_grant.result
index 0fb589dfba5..a054e58494b 100644
--- a/mysql-test/r/events_grant.result
+++ b/mysql-test/r/events_grant.result
@@ -12,6 +12,7 @@ CREATE USER ev_test@localhost;
GRANT ALL ON events_test.* to ev_test@localhost;
GRANT ALL ON events_test2.* to ev_test@localhost;
REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
+connect ev_con1,localhost,ev_test,,events_test2;
select "NEW CONNECTION";
NEW CONNECTION
NEW CONNECTION
@@ -52,9 +53,12 @@ events_test two_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLE
"This should show us no events:";
SHOW EVENTS FROM test LIKE '%';
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
+connection default;
GRANT EVENT ON events_test2.* TO ev_test@localhost;
+connection ev_con1;
USE events_test2;
CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
+connection default;
USE events_test;
"We should see 4 events : one_event, two_event, three_event & four_event"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
@@ -70,9 +74,11 @@ EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_
def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event
def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
+connection default;
CREATE DATABASE events_test2;
USE events_test2;
CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
+connection ev_con1;
"Should see 4 events - one, two, three & five"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
@@ -80,7 +86,9 @@ def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND
def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event
def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
def events_test2 five_event root@localhost SQL SELECT 42 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE
+connection default;
REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
+connection ev_con1;
USE test;
"Should see 3 events - one, two & three"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
@@ -95,8 +103,10 @@ ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND;
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
def events_test one_event ev_test@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
+connection default;
USE events_test;
ALTER EVENT one_event COMMENT "comment";
+connection ev_con1;
"The definer should be root@localhost"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
@@ -106,16 +116,22 @@ ALTER EVENT one_event DO SELECT 12;
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
def events_test one_event ev_test@localhost SQL SELECT 12 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE comment
+connection default;
"make the definer again root@localhost"
ALTER EVENT one_event COMMENT "new comment";
+connection ev_con1;
"test DROP by another user"
DROP EVENT one_event;
+connection default;
"One event should not be there"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event
def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
def events_test2 five_event root@localhost SQL SELECT 42 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE
+connection ev_con1;
+disconnect ev_con1;
+connection default;
DROP USER ev_test@localhost;
DROP DATABASE events_test2;
DROP DATABASE events_test;
diff --git a/mysql-test/r/events_stress.result b/mysql-test/r/events_stress.result
index 6015e7c53eb..1a91ff0f528 100644
--- a/mysql-test/r/events_stress.result
+++ b/mysql-test/r/events_stress.result
@@ -9,8 +9,11 @@ GRANT ALL ON *.* TO event_user2@localhost;
CREATE USER event_user3@localhost;
CREATE DATABASE events_conn3_db;
GRANT ALL ON *.* TO event_user3@localhost;
+connect conn2,localhost,event_user2,,events_conn2_db;
"In the second connection we create some events which won't be dropped till the end"
+connect conn3,localhost,event_user3,,events_conn3_db;
"In the second connection we create some events which won't be dropped till the end"
+connection default;
USE events_conn1_test2;
CREATE EVENT ev_drop1 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
CREATE EVENT ev_drop2 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
@@ -52,13 +55,21 @@ USE events_conn1_test2;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
COUNT(*)
50
+connection conn2;
DROP DATABASE events_conn2_db;
+connection conn3;
DROP DATABASE events_conn3_db;
+connection default;
DROP DATABASE events_conn1_test2;
DROP DATABASE events_conn1_test3;
SET GLOBAL event_scheduler=off;
DROP DATABASE events_conn1_test4;
SET GLOBAL event_scheduler=on;
+connection conn2;
+disconnect conn2;
+connection conn3;
+disconnect conn3;
+connection default;
USE events_test;
DROP TABLE fill_it1;
DROP TABLE fill_it2;
diff --git a/mysql-test/r/events_trans_notembedded.result b/mysql-test/r/events_trans_notembedded.result
index fb68bc9ceab..324e28ddb62 100644
--- a/mysql-test/r/events_trans_notembedded.result
+++ b/mysql-test/r/events_trans_notembedded.result
@@ -6,6 +6,7 @@ create user mysqltest_user1@localhost;
grant create, insert, select, delete on mysqltest_db2.*
to mysqltest_user1@localhost;
create database mysqltest_db2;
+connect conn1,localhost,mysqltest_user1,,mysqltest_db2;
set autocommit=off;
select @@autocommit;
@@autocommit
@@ -41,6 +42,8 @@ a
OK: drop event: insufficient privileges
delete from t1;
commit work;
+disconnect conn1;
+connection default;
drop user mysqltest_user1@localhost;
drop database mysqltest_db2;
drop database events_test;
diff --git a/mysql-test/r/explain_slowquerylog.result b/mysql-test/r/explain_slowquerylog.result
index 8acbdc69a4c..2b350cf04ff 100644
--- a/mysql-test/r/explain_slowquerylog.result
+++ b/mysql-test/r/explain_slowquerylog.result
@@ -12,11 +12,14 @@ drop table t0;
#
# MDEV-5047 virtual THD::~THD(): Assertion `status_var.memory_used == 0' fails on disconnect
#
+connect con1,localhost,root,,;
ALTER TABLE nonexisting ENABLE KEYS;
ERROR 42S02: Table 'test.nonexisting' doesn't exist
SHOW WARNINGS;
Level Code Message
Error 1146 Table 'test.nonexisting' doesn't exist
+disconnect con1;
+connection default;
SELECT 1;
1
1
diff --git a/mysql-test/r/failed_auth_3909.result b/mysql-test/r/failed_auth_3909.result
index 0a757e2cee2..8b41ef4618a 100644
--- a/mysql-test/r/failed_auth_3909.result
+++ b/mysql-test/r/failed_auth_3909.result
@@ -9,10 +9,13 @@ Warning 1364 Field 'x509_subject' doesn't have a default value
Warning 1364 Field 'authentication_string' doesn't have a default value
flush privileges;
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET);
+connect fail,localhost,u1;
ERROR HY000: Plugin 'bar' is not loaded
connect(localhost,u2,,test,MASTER_PORT,MASTER_SOCKET);
+connect fail,localhost,u2;
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: NO)
connect(localhost,u2,password,test,MASTER_PORT,MASTER_SOCKET);
+connect fail,localhost,u2,password;
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: YES)
ERROR HY000: Plugin 'bar' is not loaded
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: NO)
diff --git a/mysql-test/r/failed_auth_unixsocket.result b/mysql-test/r/failed_auth_unixsocket.result
index 3cf58ca5bec..680d3b48a33 100644
--- a/mysql-test/r/failed_auth_unixsocket.result
+++ b/mysql-test/r/failed_auth_unixsocket.result
@@ -1,6 +1,7 @@
update mysql.user set plugin='unix_socket';
flush privileges;
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
+connect fail,localhost,$USER;
ERROR HY000: Plugin 'unix_socket' is not loaded
ERROR HY000: Plugin 'unix_socket' is not loaded
install plugin unix_socket soname 'auth_socket.so';
diff --git a/mysql-test/r/filesort_debug.result b/mysql-test/r/filesort_debug.result
index 13912ac8756..3eced35d58b 100644
--- a/mysql-test/r/filesort_debug.result
+++ b/mysql-test/r/filesort_debug.result
@@ -18,17 +18,21 @@ DROP FUNCTION f1;
# Bug #11747102
# 30771: LOG MORE INFO ABOUT THREADS KILL'D AND SORT ABORTED MESSAGES
#
-# connection 1
+connect con1, localhost, root;
+connect con2, localhost, root;
+connection con1;
CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
SET DEBUG_SYNC='filesort_start SIGNAL filesort_started WAIT_FOR filesort_killed';
# Sending: (not reaped since connection is killed later)
SELECT * FROM t1 ORDER BY f1 ASC, f0;
-# connection 2
+connection con2;
SET DEBUG_SYNC='now WAIT_FOR filesort_started';
KILL @id;
SET DEBUG_SYNC='now SIGNAL filesort_killed';
-# connection default
+connection default;
+disconnect con1;
+disconnect con2;
SET DEBUG_SYNC= "RESET";
DROP TABLE t1;
#
diff --git a/mysql-test/r/flush-innodb-notembedded.result b/mysql-test/r/flush-innodb-notembedded.result
index 911abfe6daf..0b63a7b3519 100644
--- a/mysql-test/r/flush-innodb-notembedded.result
+++ b/mysql-test/r/flush-innodb-notembedded.result
@@ -8,26 +8,31 @@ GRANT CREATE, DROP ON *.* TO user2@localhost;
GRANT RELOAD, SELECT ON *.* TO user3@localhost;
GRANT SELECT, LOCK TABLES ON *.* TO user4@localhost;
GRANT RELOAD, LOCK TABLES ON *.* TO user5@localhost;
-# Connection con1 as user1
+connect con1, localhost, user1;
FLUSH TABLE db1.t1 FOR EXPORT;
UNLOCK TABLES;
-# Connection default
-# Connection con1 as user2
+disconnect con1;
+connection default;
+connect con1, localhost, user2;
FLUSH TABLE db1.t1 FOR EXPORT;
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
-# Connection default
-# Connection con1 as user3
+disconnect con1;
+connection default;
+connect con1, localhost, user3;
FLUSH TABLE db1.t1 FOR EXPORT;
ERROR 42000: Access denied for user 'user3'@'localhost' to database 'db1'
-# Connection default
-# Connection con1 as user4
+disconnect con1;
+connection default;
+connect con1, localhost, user4;
FLUSH TABLE db1.t1 FOR EXPORT;
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
-# Connection default
-# Connection con1 as user5
+disconnect con1;
+connection default;
+connect con1, localhost, user5;
FLUSH TABLE db1.t1 FOR EXPORT;
ERROR 42000: SELECT command denied to user 'user5'@'localhost' for table 't1'
-# Connection default
+disconnect con1;
+connection default;
DROP USER user1@localhost, user2@localhost, user3@localhost,
user4@localhost, user5@localhost;
DROP TABLE db1.t1;
diff --git a/mysql-test/r/flush-innodb.result b/mysql-test/r/flush-innodb.result
index d596ffbbd51..bd09f0d62dc 100644
--- a/mysql-test/r/flush-innodb.result
+++ b/mysql-test/r/flush-innodb.result
@@ -71,26 +71,26 @@ DROP VIEW v1;
#
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) engine= InnoDB;
CREATE TABLE t2 (a INT) engine= InnoDB;
-# Connection con1
+connect con1, localhost, root;
START TRANSACTION;
INSERT INTO t1 VALUES (1, 1);
-# Connection default
+connection default;
# Should be blocked
# Sending:
FLUSH TABLES t1 FOR EXPORT;
-# Connection con1
+connection con1;
COMMIT;
-# Connection default
+connection default;
# Reaping: FLUSH TABLES t1 FOR EXPORT
-# Connection con1
+connection con1;
# Should not be blocked
INSERT INTO t2 VALUES (1);
# Should be blocked
# Sending:
INSERT INTO t1 VALUES (2, 2);
-# Connection default
+connection default;
UNLOCK TABLES;
-# Connection con1
+connection con1;
# Reaping: INSERT INTO t1 VALUES (2, 2);
# Test 3: Read operations should not be affected.
#
@@ -99,17 +99,17 @@ SELECT * FROM t1;
a b
1 1
2 2
-# Connection default
+connection default;
# Should not be blocked
FLUSH TABLES t1 FOR EXPORT;
-# Connection con1
+connection con1;
COMMIT;
# Should not be blocked
SELECT * FROM t1;
a b
1 1
2 2
-# Connection default
+connection default;
UNLOCK TABLES;
# Test 4: Blocked by DDL, blocks DDL.
#
@@ -118,39 +118,40 @@ SELECT * FROM t1;
a b
1 1
2 2
-# Connection con2
+connect con2, localhost, root;
# Sending:
ALTER TABLE t1 ADD INDEX i1(b);
-# Connection con1
+connection con1;
# Should be blocked
FLUSH TABLE t1 FOR EXPORT;
-# Connection default
+connection default;
COMMIT;
-# Connection con2
+connection con2;
# Reaping ALTER TABLE ...
-# Connection con1
+connection con1;
# Reaping FLUSH TABLE t1 FOR EXPORT
UNLOCK TABLES;
-# Connection default
+connection default;
FLUSH TABLE t1 FOR EXPORT;
-# Connection con2
+connection con2;
# Should be blocked
DROP TABLE t1;
-# Connection default
+connection default;
UNLOCK TABLES;
-# Connection con2
+connection con2;
# Reaping DROP TABLE t1
-# Connection default
+disconnect con2;
+connection default;
DROP TABLE t2;
# Test 5: Compatibilty with FLUSH TABLES WITH READ LOCK
#
CREATE TABLE t1(a INT) engine= InnoDB;
FLUSH TABLES WITH READ LOCK;
-# Connection con1
+connection con1;
# This should not block
FLUSH TABLE t1 FOR EXPORT;
UNLOCK TABLES;
-# Connection default
+connection default;
UNLOCK TABLES;
DROP TABLE t1;
# Test 6: Unsupported storage engines.
@@ -159,8 +160,9 @@ CREATE TABLE t1(a INT) engine= MEMORY;
FLUSH TABLE t1 FOR EXPORT;
ERROR HY000: Storage engine MEMORY of the table `test`.`t1` doesn't have this option
DROP TABLE t1;
-# Connection con1
-# Connection defalt
+connection con1;
+disconnect con1;
+connection default;
# Test 7: Check privileges required.
# in flush-innodb-notembedded.test
# Test 8: FLUSH TABLE <table_list> FOR EXPORT is incompatible
@@ -169,38 +171,39 @@ DROP TABLE t1;
#
CREATE TABLE t1 (a INT) engine= InnoDB;
CREATE TABLE t2 (a INT) engine= InnoDB;
-# Connection con1
+connect con1, localhost, root;
FLUSH TABLE t1 FOR EXPORT;
-# Connection default
+connection default;
# This should not block
FLUSH TABLE t2 FOR EXPORT;
UNLOCK TABLES;
# This should block
# Sending:
FLUSH TABLE t1 FOR EXPORT;
-# Connection con1
+connection con1;
UNLOCK TABLES;
-# Connection default
+connection default;
# Reaping: FLUSH TABLE t1 FOR EXPORT
UNLOCK TABLES;
# Test 9: LOCK TABLES ... READ is not affected
#
LOCK TABLE t1 READ;
-# Connection con1
+connection con1;
# Should not block
FLUSH TABLE t1 FOR EXPORT;
UNLOCK TABLES;
-# Connection default
+connection default;
UNLOCK TABLES;
FLUSH TABLE t1 FOR EXPORT;
-# Connection con1
+connection con1;
# Should not block
LOCK TABLE t1 READ;
UNLOCK TABLES;
-# Connection default
+connection default;
UNLOCK TABLES;
-# Connection con1
-# Connection default
+connection con1;
+disconnect con1;
+connection default;
DROP TABLE t1, t2;
# Test 10: Lock is released if transaction is started after doing
# 'flush table..' in same session
@@ -217,30 +220,30 @@ UNLOCK TABLES;
DROP TABLE t1;
# Test 11: Test 'flush table with fully qualified table names
# and with syntax local/NO_WRITE_TO_BINLOG
-# Connection con1
-# Connection default
+connect con1, localhost, root;
+connection default;
CREATE TABLE t1 ( i INT ) ENGINE = Innodb;
INSERT INTO t1 VALUES (100),(200);
FLUSH LOCAL TABLES test.t1 FOR EXPORT;
-# Connection con1
+connection con1;
# Should be blocked
# Sending:
FLUSH LOCAL TABLES t1 FOR EXPORT;
-# Connection default
+connection default;
UNLOCK TABLE;
-# Connection con1
+connection con1;
# Reaping: FLUSH LOCAL TABLES t1 FOR EXPORT
SELECT * FROM t1 ORDER BY i;
i
100
200
-# Connection default
+connection default;
# Should be blocked
# Sending:
FLUSH NO_WRITE_TO_BINLOG TABLES test.t1 FOR EXPORT;
-# Connection con1
+connection con1;
UNLOCK TABLES;
-# Connection default
+connection default;
# Reaping: FLUSH NO_WRITE_TO_BINLOG TABLES test.t1 FOR EXPORT
SELECT * FROM t1 ORDER BY i;
i
@@ -250,7 +253,7 @@ UNLOCK TABLE;
DROP TABLE t1;
# Test 12: Active transaction get committed if user execute
# "FLUSH TABLE ... FOR EXPORT" or "LOCK TABLE.."
-# Connection default
+connection default;
CREATE TABLE t1 ( i INT ) ENGINE = Innodb;
INSERT INTO t1 VALUES (100),(200);
START TRANSACTION;
@@ -278,7 +281,7 @@ UNLOCK TABLES;
DROP TABLE t1;
# Test 13: Verify "FLUSH TABLE ... FOR EXPORT" and "LOCK TABLE.."
# in same session
-# Connection default
+connection default;
CREATE TABLE t1 ( i INT ) ENGINE = Innodb;
# Lock table
LOCK TABLES test.t1 WRITE;
@@ -294,6 +297,9 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
LOCK TABLES test.t1 WRITE;
UNLOCK TABLES;
DROP TABLE t1;
+connection con1;
+disconnect con1;
+connection default;
# Reset innodb_file_per_table
SET GLOBAL innodb_file_per_table= @old_innodb_file_per_table;
# End of 5.6 tests
diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result
index b64351045bf..2c651b71a66 100644
--- a/mysql-test/r/flush.result
+++ b/mysql-test/r/flush.result
@@ -1,27 +1,42 @@
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
drop table if exists t1,t2;
drop database if exists mysqltest;
create temporary table t1(n int not null primary key);
create table t2(n int);
insert into t2 values(3);
+connection con1;
select * from t1;
n
3
+connection con2;
flush tables with read lock and disable checkpoint;
drop table t2;
ERROR HY000: Can't execute the query because you have a conflicting read lock
+connection con1;
drop table t2;
+connection con2;
unlock tables;
+connection con1;
+connection con1;
create database mysqltest;
create table mysqltest.t1(n int);
insert into mysqltest.t1 values (23);
flush tables with read lock;
+connection con2;
drop database mysqltest;
+connection con1;
select * from mysqltest.t1;
n
23
unlock tables;
+connection con2;
+connection con1;
create table t1 (n int);
flush tables with read lock;
+disconnect con1;
+connection con2;
insert into t1 values (345);
select * from t1;
n
@@ -54,10 +69,22 @@ unlock tables;
drop table t1, t2, t3;
create table t1 (c1 int);
create table t2 (c1 int);
+connect con1,localhost,root,,;
+connect con3,localhost,root,,;
+connection con1;
lock table t1 write;
+connection con2;
flush tables with read lock;
+connection con3;
insert into t2 values(1);
+connection con1;
unlock tables;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection con3;
+disconnect con3;
+connection default;
drop table t1, t2;
drop table if exists t1, t2;
set session low_priority_updates=1;
@@ -77,7 +104,10 @@ ERROR HY000: Can't execute the given command because you have active locked tabl
unlock tables;
drop table t1, t2;
set session low_priority_updates=default;
+connect con1,localhost,root,,;
select benchmark(200, (select sin(1))) > 1000;
+disconnect con1;
+connection default;
End of 5.0 tests
set @old_general_log= @@general_log;
set @old_read_only= @@read_only;
@@ -189,13 +219,14 @@ insert into t3 (a) values (2);
#
# III. Concurrent tests.
#
-# --> connection default
+connect con1,localhost,root,,;
#
# Check that flush tables <list> with read lock
# does not affect non-locked tables.
+connection default;
#
flush tables t1 with read lock;
-# --> connection con1;
+connection con1;
select * from t1;
a
1
@@ -203,7 +234,7 @@ select * from t2;
a
1
insert into t2 (a) values (3);
-# --> connection default;
+connection default;
unlock tables;
#
# Check that "FLUSH TABLES <list> WITH READ LOCK" is
@@ -211,13 +242,13 @@ unlock tables;
# Vice versa it is not true, since tables read-locked by
# "FLUSH TABLES <list> WITH READ LOCK" can't be flushed.
flush tables with read lock;
-# --> connection con1;
+connection con1;
flush table t1 with read lock;
select * from t1;
a
1
unlock tables;
-# --> connection default;
+connection default;
unlock tables;
#
# Check that FLUSH TABLES t1 WITH READ LOCK
@@ -225,32 +256,34 @@ unlock tables;
# WITH READ LOCK.
#
flush table t1 with read lock;
-# --> connection con1
+connection con1;
flush table t2 with read lock;
unlock tables;
-# --> connection default
+connection default;
unlock tables;
#
# Check that FLUSH TABLES t1 WITH READ LOCK
# does not conflict with SET GLOBAL read_only=1.
#
set global read_only=1;
-# connection con1
+connection con1;
flush table t1 with read lock;
unlock tables;
-# connection default
+connection default;
set global read_only=0;
#
# Check that it's possible to read-lock
# tables locked with FLUSH TABLE <list> WITH READ LOCK.
#
flush tables t1, t2 with read lock;
-# connection con1
+connection con1;
lock table t1 read, t2 read;
unlock tables;
-# connection default
+connection default;
unlock tables;
-# --> connection con1
+connection con1;
+disconnect con1;
+connection default;
drop table t1, t2, t3;
#
# Bug#51710 FLUSH TABLES <view> WITH READ LOCK kills the server
@@ -309,33 +342,35 @@ drop table t1;
# transactions unnecessarily.
#
drop table if exists t1;
-# --> conection default
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection default;
create table t1 (a int);
begin;
select * from t1;
a
-# --> connection con1
+connection con1;
#
# Issue a LOCK TABLE t1 READ. We could use HANDLER t1 OPEN
# or a long-running select -- anything that
# prevents FLUSH TABLE t1 from immediate completion would do.
#
lock table t1 read;
-# --> connection con2
+connection con2;
#
# FLUSH TABLE expels the table definition from the cache.
# Sending 'flush table t1'...
flush table t1;
-# --> connection default
+connection default;
# Let flush table sync in.
select * from t1;
-# --> connection con1
+connection con1;
select * from t1;
a
unlock tables;
-# --> connection con2
+connection con2;
# Reaping 'flush table t1'...
-# --> connection default
+connection default;
# Reaping 'select * from t1'...
a
commit;
@@ -345,33 +380,35 @@ commit;
begin;
select * from t1;
a
-# --> connection con1
+connection con1;
#
# Issue a LOCK TABLE t1 READ.
#
lock table t1 read;
-# --> connection con2
+connection con2;
#
# FLUSH TABLES expels the table definition from the cache.
# Sending 'flush tables'...
flush tables;
-# --> connection default
+connection default;
# Let flush table sync in.
select * from t1;
-# --> connection con1
+connection con1;
select * from t1;
a
unlock tables;
-# --> connection con2
+connection con2;
# Reaping 'flush tables'...
-# --> connection default
+connection default;
# Reaping 'select * from t1'...
a
commit;
# Cleanup
-# --> connection con1
-# --> connection con2
-# --> connection default
+connection con1;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection default;
drop table t1;
#
# Test for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge table
@@ -428,28 +465,36 @@ drop tables tm, t1, t2;
# FLUSH TABLES WITH READ LOCK".
#
drop table if exists t1, t2;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection default;
create table t1 (i int);
create table t2 (i int);
handler t1 open;
-# Switching to connection 'con1'.
+connection con1;
# Sending:
flush tables with read lock;
-# Switching to connection 'con2'.
+connection con2;
# Wait until FTWRL starts waiting for 't1' to be closed.
-# Switching to connection 'default'.
+connection default;
# The below statement should not cause deadlock.
# Sending:
insert into t2 values (1);
-# Switching to connection 'con2'.
+connection con2;
# Wait until INSERT starts to wait for FTWRL to go away.
-# Switching to connection 'con1'.
+connection con1;
# FTWRL should be able to continue now.
# Reap FTWRL.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap INSERT.
handler t1 close;
# Cleanup.
+connection con1;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection default;
drop tables t1, t2;
#
# Bug#57649 FLUSH TABLES under FLUSH TABLES <list> WITH READ LOCK leads
@@ -481,12 +526,13 @@ INSERT INTO t1 VALUES (1, 1);
CREATE TRIGGER t1_au AFTER UPDATE ON t1 FOR EACH ROW SET @var = "a";
BEGIN;
UPDATE t1 SET value= value + 1 WHERE id = 1;
-# Switching to connection 'con1'.
+connect con1, localhost, root;
# The below FLUSH TABLES WITH READ LOCK should succeed and
# should not be blocked by the transaction in default connection.
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;
-# Switching to connection 'default'.
+disconnect con1;
+connection default;
COMMIT;
DROP TABLE t1;
#
diff --git a/mysql-test/r/flush_block_commit.result b/mysql-test/r/flush_block_commit.result
index 7062d05c2d7..e9684e5aa46 100644
--- a/mysql-test/r/flush_block_commit.result
+++ b/mysql-test/r/flush_block_commit.result
@@ -1,50 +1,50 @@
# Save the initial number of concurrent sessions
-# Establish connection con1 (user=root)
-# Establish connection con2 (user=root)
-# Establish connection con3 (user=root)
-# Switch to connection con1
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connect con3,localhost,root,,;
+connection con1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT) ENGINE=innodb;
BEGIN;
INSERT INTO t1 VALUES(1);
-# Switch to connection con2
+connection con2;
FLUSH TABLES WITH READ LOCK;
-# Switch to connection con1
+connection con1;
# Sending:
COMMIT;
-# Switch to connection con2
+connection con2;
# Wait until COMMIT gets blocked.
# Verify that 'con1' was blocked and data did not move.
SELECT * FROM t1;
a
UNLOCK TABLES;
-# Switch to connection con1
+connection con1;
# Reaping COMMIT
-# Switch to connection con1
+connection con1;
BEGIN;
SELECT * FROM t1 FOR UPDATE;
a
1
-# Switch to connection con2
+connection con2;
BEGIN;
SELECT * FROM t1 FOR UPDATE;
-# Switch to connection con3
+connection con3;
FLUSH TABLES WITH READ LOCK;
-# Switch to connection con1
+connection con1;
COMMIT;
-# Switch to connection con2
+connection con2;
a
1
COMMIT;
-# Switch to connection con3
+connection con3;
UNLOCK TABLES;
-# Switch to connection con2
+connection con2;
COMMIT;
-# Switch to connection con1
+connection con1;
BEGIN;
INSERT INTO t1 VALUES(10);
FLUSH TABLES WITH READ LOCK;
-# Switch to connection con2
+connection con2;
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;
BEGIN;
@@ -57,7 +57,10 @@ Database Create Database
test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
COMMIT;
# Cleanup
-# Switch to connection default and close connections con1, con2, con3
+connection default;
+disconnect con1;
+disconnect con2;
+disconnect con3;
# We commit open transactions when we disconnect: only then we can
# drop the table.
DROP TABLE t1;
diff --git a/mysql-test/r/flush_block_commit_notembedded.result b/mysql-test/r/flush_block_commit_notembedded.result
index 130146bf252..7dd6410ac70 100644
--- a/mysql-test/r/flush_block_commit_notembedded.result
+++ b/mysql-test/r/flush_block_commit_notembedded.result
@@ -1,30 +1,36 @@
# Save the initial number of concurrent sessions
-# Establish connection con1 (user=root)
-# Establish connection con2 (user=root)
-# Switch to connection con1
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
CREATE TABLE t1 (a INT) ENGINE=innodb;
RESET MASTER;
SET AUTOCOMMIT=0;
SELECT 1;
1
1
-# Switch to connection con2
+connection con2;
FLUSH TABLES WITH READ LOCK;
include/show_binlog_events.inc
-# Switch to connection con1
+connection con1;
INSERT INTO t1 VALUES (1);
-# Switch to connection con2
+connection con2;
include/show_binlog_events.inc
UNLOCK TABLES;
-# Switch to connection con1
+connection con1;
DROP TABLE t1;
SET AUTOCOMMIT=1;
create table t1 (a int) engine=innodb;
+connection con1;
flush tables with read lock;
+connection con2;
begin;
insert into t1 values (1);;
+connection con1;
unlock tables;
+connection con2;
commit;
drop table t1;
-# Switch to connection default and close connections con1 and con2
+connection default;
+disconnect con1;
+disconnect con2;
# Wait till all disconnects are completed
diff --git a/mysql-test/r/flush_read_lock.result b/mysql-test/r/flush_read_lock.result
index 260edf8e51d..55c31ae8d12 100644
--- a/mysql-test/r/flush_read_lock.result
+++ b/mysql-test/r/flush_read_lock.result
@@ -85,6 +85,10 @@ insert into t1_temp values (1);
return 0;
end|
create event e1 on schedule every 1 minute do begin end;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connect con3,localhost,root,,;
+connection default;
#
# Test compatibility of FLUSH TABLES WITH READ LOCK
# with various statements.
@@ -186,34 +190,34 @@ unlock tables;
# COMMIT is blocked by active FTWRL in another
# connection.
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
begin;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Do some work so ROLLBACK is not a no-op.
insert into t3_trans values (1);
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
rollback;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
begin;
# Do some work so COMMIT is not a no-op.
insert into t3_trans values (1);
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
# Send:
commit;
-# Switching to connection 'con1'.
+connection con1;
# Wait until COMMIT is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap COMMIT.
delete from t3_trans;
#
@@ -223,18 +227,18 @@ insert into t3_trans values (1);
set debug_sync='RESET';
set debug_sync='ha_commit_trans_after_acquire_commit_lock SIGNAL parked WAIT_FOR go';
commit;
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
-# Switching to connection 'con2'.
+connection con2;
# Wait until FTWRL is blocked.
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap COMMIT.
-# Switching to connection 'con1'.
+connection con1;
# Reap FTWRL.
unlock tables;
-# Switching to connection 'default'.
+connection default;
delete from t3_trans;
set debug_sync= "RESET";
# We don't run similar test for BEGIN and ROLLBACK as
@@ -447,30 +451,30 @@ unlock tables;
# Check that active FTWRL in another connection
# blocks EXECUTE which changes data.
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
execute stmt1 ;
-# Switching to connection 'con1'.
+connection con1;
# Check that EXECUTE is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap EXECUTE.
set debug_sync='RESET';
set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
execute stmt1; ;
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
-# Switching to connection 'con2'.
+connection con2;
# Wait until FTWRL is blocked.
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap EXECUTE.
-# Switching to connection 'con1'.
+connection con1;
# Reap FTWRL.
unlock tables;
-# Switching to connection 'default'.
+connection default;
set debug_sync= "RESET";
delete from t1_base;
deallocate prepare stmt1;
@@ -631,20 +635,19 @@ drop trigger t1_bi;
# Check that FTWRL statements can be run while FTWRL
# is active in another connection.
#
-# Switching to connection 'con1'.
flush tables with read lock;
# The second FTWRL in a row is allowed at the moment.
# It does not make much sense as it does only flush.
flush tables with read lock;
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
flush tables with read lock;
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
#
# 14.2) FLUSH TABLES <list> WITH READ LOCK is not blocked by
# active FTWRL. But since the latter keeps tables open
@@ -654,25 +657,25 @@ flush tables with read lock;
# It does not make much sense though.
flush tables t1_base, t2_base with read lock;
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
flush tables t1_base, t2_base with read lock;
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
flush tables t1_base, t2_base with read lock;
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'con2'.
+connection con2;
# Wait until FTWRL is blocked.
-# Switching to connection 'default'.
+connection default;
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
# Reap FTWRL.
unlock tables;
-# Switching to connection 'default'.
+connection default;
#
# 14.3) FLUSH TABLES is compatible with FTWRL.
Success: Was able to run 'flush tables' under FTWRL.
@@ -711,16 +714,16 @@ unlock tables;
# Check that HANDLER statements can be run while FTWRL
# is active in another connection.
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
handler t1_base open;
handler t1_base read first;
i
handler t1_base close;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
#
# 17) HELP statement is compatible with FTWRL.
#
@@ -767,24 +770,24 @@ unlock tables;
# Check that KILL statements can be run while FTWRL
# is active in another connection.
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
kill query @id;
ERROR 70100: Query execution was interrupted
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Finally check that KILL doesn't block FTWRL
set debug_sync='RESET';
set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
kill query @id;
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
unlock tables;
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap KILL.
ERROR 70100: Query execution was interrupted
set debug_sync='RESET';
@@ -814,14 +817,14 @@ flush tables with read lock;
lock tables t1_base read;
unlock tables;
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
lock tables t1_base read;
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
#
# 21.b) LOCK TABLES WRITE on a base table is disallowed
# under FTWRL and should be blocked by active FTWRL.
@@ -830,14 +833,14 @@ lock tables t1_base write;
ERROR HY000: Can't execute the query because you have a conflicting read lock
unlock tables;
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
lock tables t1_base write ;
-# Switching to connection 'con1'.
+connection con1;
# Check that LOCK TABLES WRITE is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap LOCK TABLES WRITE
unlock tables;
#
@@ -848,14 +851,14 @@ flush tables with read lock;
lock tables t1_temp write;
unlock tables;
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
lock tables t1_temp write;
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
#
# 22) OPTIMIZE TABLE statement.
#
@@ -868,14 +871,14 @@ test.t1_base optimize Error Can't execute the query because you have a conflicti
test.t1_base optimize error Corrupt
unlock tables;
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
optimize table t1_base;
-# Switching to connection 'con1'.
+connection con1;
# Check that OPTIMIZE TABLE is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap OPTIMIZE TABLE
Table Op Msg_type Msg_text
test.t1_base optimize status OK
@@ -919,32 +922,32 @@ commit;
# Check that these statements are not blocked by
# active FTWRL in another connection.
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
begin;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Do some changes to avoid SAVEPOINT and friends
# being almost no-ops.
insert into t3_trans values (1);
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
savepoint sv1;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
insert into t3_trans values (2);
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
rollback to savepoint sv1;
release savepoint sv1;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
rollback;
# Check that these statements don't block FTWRL in
# another connection.
@@ -955,31 +958,31 @@ insert into t3_trans values (1);
set debug_sync='RESET';
set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
savepoint sv1;
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
unlock tables;
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap SAVEPOINT
insert into t3_trans values (2);
set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
rollback to savepoint sv1;
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
unlock tables;
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap ROLLBACK TO SAVEPOINT
set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
release savepoint sv1;
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
unlock tables;
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap RELEASE SAVEPOINT
rollback;
set debug_sync= "RESET";
@@ -1009,14 +1012,14 @@ test.t1_base repair Error Can't execute the query because you have a conflicting
test.t1_base repair error Corrupt
unlock tables;
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
repair table t1_base;
-# Switching to connection 'con1'.
+connection con1;
# Check that REPAIR TABLE is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap REPAIR TABLE
Table Op Msg_type Msg_text
test.t1_base repair status OK
@@ -1155,25 +1158,25 @@ delete from t3_temp_trans;
# SET AUTOCOMMIT=1 is blocked by active FTWRL in
# another connection.
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
set autocommit= 0;
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Do some work so implicit commit in SET AUTOCOMMIT=1
# is not a no-op.
insert into t3_trans values (1);
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
# Send:
set autocommit= 1;
-# Switching to connection 'con1'.
+connection con1;
# Wait until SET AUTOCOMMIT=1 is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap SET AUTOCOMMIT=1.
delete from t3_trans;
#
@@ -1183,18 +1186,18 @@ insert into t3_trans values (1);
set debug_sync='RESET';
set debug_sync='ha_commit_trans_after_acquire_commit_lock SIGNAL parked WAIT_FOR go';
set autocommit= 1;
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
-# Switching to connection 'con2'.
+connection con2;
# Wait until FTWRL is blocked.
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap SET AUTOCOMMIT=1.
-# Switching to connection 'con1'.
+connection con1;
# Reap FTWRL.
unlock tables;
-# Switching to connection 'default'.
+connection default;
delete from t3_trans;
set debug_sync= "RESET";
#
@@ -1308,36 +1311,37 @@ unlock tables;
# Check that XA non-COMMIT statements are not and COMMIT is
# blocked by active FTWRL in another connection
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
xa start 'test1';
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
insert into t3_trans values (1);
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
xa end 'test1';
xa prepare 'test1';
xa rollback 'test1';
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
xa start 'test1';
insert into t3_trans values (1);
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
+connection default;
xa end 'test1';
xa prepare 'test1';
# Send:
xa commit 'test1';;
-# Switching to connection 'con1'.
+connection con1;
# Wait until XA COMMIT is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap XA COMMIT.
delete from t3_trans;
#
@@ -1349,18 +1353,18 @@ xa prepare 'test1';
set debug_sync='RESET';
set debug_sync='trans_xa_commit_after_acquire_commit_lock SIGNAL parked WAIT_FOR go';
xa commit 'test1';
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
-# Switching to connection 'con2'.
+connection con2;
# Wait until FTWRL is blocked.
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap XA COMMIT.
-# Switching to connection 'con1'.
+connection con1;
# Reap FTWRL.
unlock tables;
-# Switching to connection 'default'.
+connection default;
delete from t3_trans;
set debug_sync= "RESET";
#
@@ -1413,14 +1417,14 @@ Table Op Msg_type Msg_text
test.t3_trans analyze status OK
unlock tables;
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
analyze table t3_trans;
-# Switching to connection 'con1'.
+connection con1;
# Check that ANALYZE TABLE is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap ANALYZE TABLE
Table Op Msg_type Msg_text
test.t3_trans analyze status OK
@@ -1478,28 +1482,28 @@ Success: Was able to run FTWRL while 'alter table t3_temp_trans add column c1 in
begin;
insert into t3_trans values (1);
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
check table t1_base;
-# Switching to connection 'con1'.
+connection con1;
# Check that CHECK TABLE is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap CHECK TABLE
Table Op Msg_type Msg_text
test.t1_base check status OK
begin;
delete from t3_trans;
#
-# Switching to connection 'con1'.
+connection con1;
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
alter table t1_temp add column c1 int;
-# Switching to connection 'con1'.
+connection con1;
# Check that ALTER TABLE is blocked.
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Reap ALTER TABLE
alter table t1_temp drop column c1;
#
@@ -1512,10 +1516,10 @@ alter table t1_temp drop column c1;
begin;
insert into t1_base values (1);
insert into t3_trans values (1);
-# Switching to connection 'con1'.
+connection con1;
# The below FTWRL should not be blocked by transaction in 'default'.
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
# Transaction still is able to read even with FTWRL active in another
# connection.
select * from t1_base;
@@ -1526,9 +1530,9 @@ j
select * from t3_trans;
i
1
-# Switching to connection 'con1'.
+connection con1;
unlock tables;
-# Switching to connection 'default'.
+connection default;
commit;
delete from t1_base;
delete from t3_trans;
@@ -1541,25 +1545,25 @@ delete from t3_trans;
set debug_sync='RESET';
set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go';
insert into t1_base values (1);
-# Switching to connection 'con1'.
+connection con1;
set debug_sync='now WAIT_FOR parked';
flush tables with read lock;
-# Switching to connection 'con2'.
+connection con2;
# Wait until FTWRL is blocked.
# Try to run another INSERT and see that it is blocked.
insert into t2_base values (1);;
-# Switching to connection 'con3'.
+connection con3;
# Wait until new INSERT is blocked.
# Unblock INSERT in the first connection.
set debug_sync='now SIGNAL go';
-# Switching to connection 'default'.
+connection default;
# Reap first INSERT.
-# Switching to connection 'con1'.
+connection con1;
# Reap FTWRL.
unlock tables;
-# Switching to connection 'con2'.
+connection con2;
# Reap second INSERT.
-# Switching to connection 'default'.
+connection default;
set debug_sync= "RESET";
delete from t1_base;
delete from t2_base;
@@ -1573,23 +1577,23 @@ delete from t2_base;
# only taken when there were such modifications.
flush tables with read lock;
-# Switching to connection 'con1'.
+connection con1;
# The below FTWRL should not be blocked by transaction in 'default'.
flush tables with read lock;
-# Switching to connection 'default'.
+connection default;
select * from t1_base;
i
select * from t3_trans;
i
commit;
-# Switching to connection 'con1'.
+connection con1;
select * from t1_base;
i
select * from t3_trans;
i
commit;
unlock tables;
-# Switching to connection 'default'.
+connection default;
unlock tables;
#
# Check how FLUSH TABLE WITH READ LOCK is handled for MERGE tables.
@@ -1669,4 +1673,7 @@ drop database `#mysql50#mysqltest-2`;
drop database mysqltest1;
drop temporary tables t1_temp, t2_temp;
drop tables t1_base, t2_base, t3_trans;
+disconnect con1;
+disconnect con2;
+disconnect con3;
set global sql_mode=default;
diff --git a/mysql-test/r/flush_read_lock_kill.result b/mysql-test/r/flush_read_lock_kill.result
index 8453d26cbea..05836b04524 100644
--- a/mysql-test/r/flush_read_lock_kill.result
+++ b/mysql-test/r/flush_read_lock_kill.result
@@ -1,8 +1,11 @@
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
DROP TABLE IF EXISTS t1;
SET DEBUG_SYNC= 'RESET';
CREATE TABLE t1 (kill_id INT) engine = InnoDB;
INSERT INTO t1 VALUES(connection_id());
-# Switching to connection 'default'.
+connection default;
# Start transaction.
BEGIN;
INSERT INTO t1 VALUES(connection_id());
@@ -11,13 +14,13 @@ INSERT INTO t1 VALUES(connection_id());
SET DEBUG_SYNC='ha_commit_trans_after_acquire_commit_lock SIGNAL acquired WAIT_FOR go';
# Sending:
COMMIT;
-# Switching to 'con1'.
+connection con1;
# Wait till COMMIT acquires protection against global read
# lock and pauses.
SET DEBUG_SYNC='now WAIT_FOR acquired';
# Sending:
FLUSH TABLES WITH READ LOCK;
-# Switching to 'con2'.
+connection con2;
SELECT ((@id := kill_id) - kill_id) FROM t1 LIMIT 1;
((@id := kill_id) - kill_id)
0
@@ -25,14 +28,15 @@ SELECT ((@id := kill_id) - kill_id) FROM t1 LIMIT 1;
# to active COMMIT
# Kill connection 'con1'.
KILL CONNECTION @id;
-# Switching to 'con1'.
+connection con1;
# Try to reap FLUSH TABLES WITH READ LOCK,
# it fail due to killed statement and connection.
Got one of the listed errors
-# Switching to 'con2'.
+connection con2;
# Resume COMMIT.
SET DEBUG_SYNC='now SIGNAL go';
-# Switching to 'default'.
+connection default;
# Reaping COMMIT.
+disconnect con2;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/r/flush_table.result b/mysql-test/r/flush_table.result
index 2b0ee1cb205..c56d63bd849 100644
--- a/mysql-test/r/flush_table.result
+++ b/mysql-test/r/flush_table.result
@@ -12,25 +12,35 @@ Table Op Msg_type Msg_text
test.t1 check status OK
unlock tables;
lock table t1 write;
+connect locker,localhost,root,,test;
+connection locker;
lock table t1 read;
+connection default;
flush table t1;
select * from t1;
a
1
unlock tables;
+connection locker;
unlock tables;
+connection default;
lock table t1 write;
+connection locker;
lock table t1 write;
+connection default;
flush table t1;
select * from t1;
a
1
unlock tables;
+connection locker;
unlock tables;
select * from t1;
a
1
+connection default;
drop table t1;
+disconnect locker;
create table t1(table_id char(20) primary key);
create table t2(table_id char(20) primary key);
insert into t1 values ('test.t1');
diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result
index e9c8193685b..9bedddd7740 100644
--- a/mysql-test/r/func_compress.result
+++ b/mysql-test/r/func_compress.result
@@ -1,4 +1,6 @@
set global max_allowed_packet=1048576;
+connect conn1,localhost,root,,;
+connection conn1;
select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ';
@test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa '
string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -70,12 +72,15 @@ Warning 1259 ZLIB: Input data corrupted
Warning 1256 Uncompressed data size too large; the maximum size is 1048576 (probably, length of uncompressed data was corrupted)
drop table t1;
set @@global.max_allowed_packet=1048576*100;
+connect newconn, localhost, root,,;
select compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null;
compress(repeat('aaaaaaaaaa', IF(XXX, 10, 10000000))) is null
0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: XXX
Warning 1292 Truncated incorrect DOUBLE value: XXX
+disconnect newconn;
+connection default;
set @@global.max_allowed_packet=default;
create table t1(a blob);
insert into t1 values(NULL), (compress('a'));
@@ -156,6 +161,8 @@ UNCOMPRESS(CAST(0 AS BINARY(5)))
NULL
Warnings:
Warning 1259 ZLIB: Input data corrupted
+disconnect conn1;
+connection default;
set global max_allowed_packet=default;
#
# End of 5.5 tests
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 0d9d4ffff9f..422e7bd25c8 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -2220,11 +2220,15 @@ INSERT INTO `t1` (b) VALUES ('2013-07-06 23:59:59');
EXPLAIN SELECT MIN(b) FROM t1 WHERE b <= '2013-11-06 23:59:59';
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
+connect con1,localhost,root,,;
+connection con1;
set names utf8;
# Should be the same as above:
EXPLAIN SELECT MIN(b) FROM t1 WHERE b <= '2013-11-06 23:59:59';
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
+connection default;
+disconnect con1;
DROP TABLE t1;
CREATE TABLE `t1` (
`a` int(11) NOT NULL AUTO_INCREMENT,
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index 700fda2e182..6590e3ef982 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -62,6 +62,7 @@ INSERT INTO t1 VALUES ('default', CONNECTION_ID());
SELECT GET_LOCK('bug16501',600);
GET_LOCK('bug16501',600)
1
+connect con1,localhost,root,,;
INSERT INTO t1 VALUES ('con1', CONNECTION_ID());
SELECT IS_USED_LOCK('bug16501') = connection_id
FROM t1
@@ -69,19 +70,23 @@ WHERE conn = 'default';
IS_USED_LOCK('bug16501') = connection_id
1
SELECT GET_LOCK('bug16501',600);
+connection default;
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
IS_USED_LOCK('bug16501') = CONNECTION_ID()
1
SELECT RELEASE_LOCK('bug16501');
RELEASE_LOCK('bug16501')
1
+connection con1;
GET_LOCK('bug16501',600)
1
+connection default;
SELECT IS_USED_LOCK('bug16501') = connection_id
FROM t1
WHERE conn = 'con1';
IS_USED_LOCK('bug16501') = connection_id
1
+connection con1;
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
IS_USED_LOCK('bug16501') = CONNECTION_ID()
1
@@ -91,6 +96,8 @@ RELEASE_LOCK('bug16501')
SELECT IS_USED_LOCK('bug16501');
IS_USED_LOCK('bug16501')
NULL
+disconnect con1;
+connection default;
DROP TABLE t1;
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
export_set(3, _latin1'foo', _utf8'bar', ',', 4)
@@ -595,7 +602,8 @@ is_free_lock('test')
select is_used_lock('test') = connection_id();
is_used_lock('test') = connection_id()
1
-# -> Switching to connection 'con1'
+connect con1,localhost,root,,;
+connection con1;
# IS_USED_LOCK, IS_FREE_LOCK: the lock is acquired in another
# connection
select is_used_lock('test') = connection_id();
@@ -612,7 +620,7 @@ get_lock('test', 0)
select release_lock('test');
release_lock('test')
0
-# -> Switching to connection 'default'
+connection default;
# RELEASE_LOCK returns 1 if it successfully releases a lock
select release_lock('test');
release_lock('test')
@@ -625,18 +633,18 @@ NULL
select get_lock('test', 0);
get_lock('test', 0)
1
-# -> Switching to connection 'con1'
+connection con1;
create table t1 select connection_id() as id;
select get_lock('test', 7200);
-# -> Switching to connection 'default'
+connection default;
select (@id := id) - id from t1;
(@id := id) - id
0
kill query @id;
-# -> Switching to connection 'con1'
+connection con1;
get_lock('test', 7200)
NULL
-# -> Switching to connection 'default'
+connection default;
# GET_LOCK() works recursively
select get_lock('test', 0);
get_lock('test', 0)
@@ -685,18 +693,18 @@ release_lock('test3')
select get_lock('test1', 0);
get_lock('test1', 0)
1
-# -> Switching to connection 'con1'
+connection con1;
select get_lock('test2', 0);
get_lock('test2', 0)
1
select get_lock('test1', 7200);
-# -> Switching to connection 'default'
+connection default;
select get_lock('test2', 7200);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
select release_lock('test1');
release_lock('test1')
1
-# -> Switching to connection 'con1'
+connection con1;
get_lock('test1', 7200)
1
select release_lock('test2');
@@ -705,7 +713,7 @@ release_lock('test2')
select release_lock('test1');
release_lock('test1')
1
-# -> Switching to connection 'default'
+connection default;
# LOCK/UNLOCK TABLES works fine with a user lock.
lock table t1 write;
select get_lock('test', 0);
@@ -755,16 +763,16 @@ release_lock('test2')
select get_lock('test', 0);
get_lock('test', 0)
1
-# -> Switching to connection 'con1'
+connection con1;
lock table t1 write;
select get_lock('test', 7200);
-# -> Switching to connection 'default'
+connection default;
lock table t1 read;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
select release_lock('test');
release_lock('test')
1
-# -> Switching to connection 'con1'
+connection con1;
get_lock('test', 7200)
1
select release_lock('test');
@@ -772,6 +780,8 @@ release_lock('test')
1
unlock tables;
# cleanup
+disconnect con1;
+connection default;
drop table t1;
# check too long identifier names
select get_lock(repeat('a', 192), 0);
@@ -1382,7 +1392,7 @@ DROP TABLE t2;
#
# MDEV-4018 : Microseconds in GET_LOCK()
#
-# -> Switching to connection 'default'
+connection default;
select is_used_lock('test') = connection_id();
is_used_lock('test') = connection_id()
NULL
@@ -1390,7 +1400,8 @@ NULL
select get_lock('test', 0);
get_lock('test', 0)
1
-# -> Switching to connection 'con1'
+connect con1,localhost,root,,;
+connection con1;
select is_used_lock('test') = connection_id();
is_used_lock('test') = connection_id()
0
@@ -1412,7 +1423,7 @@ get_lock('test', 0.000001)
select get_lock('test', 0.0000000000000001);
get_lock('test', 0.0000000000000001)
0
-# -> Switching to connection 'default'
+connection default;
select is_used_lock('test') = connection_id();
is_used_lock('test') = connection_id()
1
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index f196571218f..d8ad6d7edb6 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -1,5 +1,7 @@
drop table if exists t1,t2;
set global max_allowed_packet=1048576;
+connect conn1,localhost,root,,;
+connection conn1;
set names latin1;
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
@@ -2911,6 +2913,7 @@ SELECT @tmp_max:= @@global.max_allowed_packet;
@tmp_max:= @@global.max_allowed_packet
1048576
SET @@global.max_allowed_packet=1024*1024*1024;
+connect newconn, localhost, root,,;
SELECT @@global.max_allowed_packet;
@@global.max_allowed_packet
1073741824
@@ -2942,7 +2945,9 @@ Warning 1292 Truncated incorrect INTEGER value: '511993d3c99719e38a6779073019dac
Warning 1292 Truncated incorrect DECIMAL value: '[.DC2.]'
Warning 1292 Truncated incorrect INTEGER value: '511993d3c99719e38a6779073019dacd7178ddb9'
Warning 1292 Truncated incorrect DOUBLE value: '0.000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'
+connection conn1;
SET @@global.max_allowed_packet:= @tmp_max;
+disconnect newconn;
SELECT @tmp_max:= @@global.max_allowed_packet;
@tmp_max:= @@global.max_allowed_packet
1048576
@@ -4542,6 +4547,8 @@ SET NAMES latin2;
EXECUTE stmt;
COLLATION(space(2))
latin2_general_ci
+disconnect conn1;
+connection default;
set global max_allowed_packet=default;
#
# End of 5.6 tests
diff --git a/mysql-test/r/func_weight_string.result b/mysql-test/r/func_weight_string.result
index e63ee4267ea..df5b552d9ab 100644
--- a/mysql-test/r/func_weight_string.result
+++ b/mysql-test/r/func_weight_string.result
@@ -1,5 +1,7 @@
drop table if exists t1;
set global max_allowed_packet=1048576;
+connect conn1,localhost,root,,;
+connection conn1;
set names latin1;
select hex(weight_string(0x010203));
hex(weight_string(0x010203))
@@ -91,6 +93,8 @@ NULL
Warnings:
Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (1048576) - truncated
Warning 1301 Result of weight_string() was larger than max_allowed_packet (1048576) - truncated
+disconnect conn1;
+connection default;
set global max_allowed_packet=default;
#
# Start of 10.1 tests
diff --git a/mysql-test/r/function_defaults_notembedded.result b/mysql-test/r/function_defaults_notembedded.result
index 9bd03ab9f05..645133bad1d 100644
--- a/mysql-test/r/function_defaults_notembedded.result
+++ b/mysql-test/r/function_defaults_notembedded.result
@@ -48,15 +48,19 @@ DROP TABLE t1;
# with different sets of active defaults.
#
CREATE TABLE t1 ( a INT, b TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
+connect con1, localhost, root,,;
# 2011-04-19 08:04:01 UTC
SET TIMESTAMP = 1303200241.345678;
SET debug_sync = 'before_write_delayed SIGNAL parked WAIT_FOR go';
INSERT DELAYED INTO t1 ( a ) VALUES (1), (2), (3);
+connection default;
SET debug_sync = 'now WAIT_FOR parked';
+connect con2, localhost, root,,;
# 2011-04-19 08:04:01 UTC
SET TIME_ZONE="+03:00";
SET TIMESTAMP = 1303200241.456789;
INSERT DELAYED INTO t1 ( a, b ) VALUES (4, '1977-12-19 12:34:56.789123'), (5, '1977-12-19 12:34:57.891234'), (6, '1977-12-19 12:34:58.912345');
+connection default;
SET debug_sync = 'now SIGNAL go';
SELECT * FROM t1;
a b
@@ -66,6 +70,8 @@ a b
4 1977-12-19 09:34:56
5 1977-12-19 09:34:57
6 1977-12-19 09:34:58
+disconnect con1;
+disconnect con2;
DROP TABLE t1;
#
# Test of early activation of function defaults.
@@ -133,15 +139,19 @@ DROP TABLE t1;
# with different sets of active defaults.
#
CREATE TABLE t1 ( a INT, b TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6));
+connect con1, localhost, root,,;
# 2011-04-19 08:04:01 UTC
SET TIMESTAMP = 1303200241.345678;
SET debug_sync = 'before_write_delayed SIGNAL parked WAIT_FOR go';
INSERT DELAYED INTO t1 ( a ) VALUES (1), (2), (3);
+connection default;
SET debug_sync = 'now WAIT_FOR parked';
+connect con2, localhost, root,,;
# 2011-04-19 08:04:01 UTC
SET TIME_ZONE="+03:00";
SET TIMESTAMP = 1303200241.456789;
INSERT DELAYED INTO t1 ( a, b ) VALUES (4, '1977-12-19 12:34:56.789123'), (5, '1977-12-19 12:34:57.891234'), (6, '1977-12-19 12:34:58.912345');
+connection default;
SET debug_sync = 'now SIGNAL go';
SELECT * FROM t1;
a b
@@ -151,6 +161,8 @@ a b
4 1977-12-19 09:34:56.789123
5 1977-12-19 09:34:57.891234
6 1977-12-19 09:34:58.912345
+disconnect con1;
+disconnect con2;
DROP TABLE t1;
#
# Test of early activation of function defaults.
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 3020c7deba7..5d44f47dede 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -4,6 +4,8 @@ SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creato
SET GLOBAL log_bin_trust_function_creators = 1;
drop table if exists t1;
drop database if exists mysqltest;
+connect master,localhost,root,,;
+connection master;
SET NAMES binary;
delete from mysql.user where user='mysqltest_1';
delete from mysql.db where user='mysqltest_1';
@@ -518,6 +520,8 @@ 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'''
ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
@@ -551,6 +555,7 @@ update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 's' in table 't1'
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;
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
a q b r
10 2 1 2
@@ -565,6 +570,9 @@ grant all on mysqltest_2.* to mysqltest_3@localhost;
grant select on *.* to mysqltest_3@localhost;
grant select on mysqltest_2.t1 to mysqltest_3@localhost;
flush privileges;
+disconnect conn1;
+connect conn2,localhost,mysqltest_3,,;
+connection conn2;
use mysqltest_1;
update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
@@ -576,6 +584,7 @@ update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't2'
update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
+connection master;
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
a q b r
10 2 1 2
@@ -589,6 +598,7 @@ delete from mysql.columns_priv where user="mysqltest_3";
flush privileges;
drop database mysqltest_1;
drop database mysqltest_2;
+disconnect conn2;
SHOW PRIVILEGES;
Privilege Context Comment
Alter Tables To alter the table
@@ -622,14 +632,22 @@ Trigger Tables To use triggers
Create tablespace Server Admin To create/alter/drop tablespaces
Update Tables To update existing rows
Usage Server Admin No privileges - allow connect only
+connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root;
create database mysqltest;
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;
alter table t1 rename t2;
ERROR 42000: INSERT, CREATE command denied to user 'mysqltest_1'@'localhost' for table '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;
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.dummytable (dummyfield INT);
@@ -742,6 +760,7 @@ use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
+connection default;
use mysql;
insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_grantor',CURRENT_TIMESTAMP,'Select','Select');
flush privileges;
@@ -801,13 +820,18 @@ delete from mysql.db where user='mysqltest1';
delete from mysql.tables_priv where user='mysqltest1';
flush privileges;
drop database mysqltest;
+connection master;
create database db27515;
use db27515;
create table t1 (a int);
grant alter on db27515.t1 to user27515@localhost;
grant insert, create on db27515.t2 to user27515@localhost;
+connect conn27515, localhost, user27515, , db27515;
+connection conn27515;
rename table t1 to t2;
ERROR 42000: DROP command denied to user 'user27515'@'localhost' for table 't1'
+disconnect conn27515;
+connection master;
revoke all privileges, grant option from user27515@localhost;
drop user user27515@localhost;
drop database db27515;
@@ -849,8 +873,11 @@ select * from information_schema.schema_privileges
where grantee like "'mysqltest_8'%";
GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_8'@'%' def mysqltest SELECT NO
+connect conn3,localhost,mysqltest_8,,;
select * from t1;
a
+disconnect conn3;
+connection master;
revoke select on mysqltest.* from mysqltest_8@'';
show grants for mysqltest_8@'';
Grants for mysqltest_8@%
@@ -899,8 +926,11 @@ GRANT UPDATE (a) ON `test`.`t1` TO 'mysqltest_8'@'%'
select * from information_schema.column_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_8'@'%' def test t1 a UPDATE NO
+connect conn4,localhost,mysqltest_8,,;
select * from t1;
a
+disconnect conn4;
+connection master;
revoke update (a) on t1 from mysqltest_8@'';
show grants for mysqltest_8@'';
Grants for mysqltest_8@%
@@ -940,8 +970,11 @@ GRANT UPDATE ON `test`.`t1` TO 'mysqltest_8'@'%'
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_8'@'%' def test t1 UPDATE NO
+connect conn5,localhost,mysqltest_8,,;
select * from t1;
a
+disconnect conn5;
+connection master;
revoke update on t1 from mysqltest_8@'';
show grants for mysqltest_8@'';
Grants for mysqltest_8@%
@@ -979,8 +1012,11 @@ where grantee like "'mysqltest_8'%";
GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
'mysqltest_8'@'host8' def USAGE NO
'mysqltest_8'@'%' def USAGE NO
+connect conn5,localhost,mysqltest_8,,;
select * from t1;
a
+disconnect conn5;
+connection master;
flush privileges;
show grants for mysqltest_8@'';
Grants for mysqltest_8@%
@@ -996,7 +1032,9 @@ drop user mysqltest_8@'';
show grants for mysqltest_8@'';
ERROR 42000: There is no such grant defined for user 'mysqltest_8' on host '%'
connect(localhost,mysqltest_8,,test,MASTER_PORT,MASTER_SOCKET);
+connect conn6,localhost,mysqltest_8,,;
ERROR 28000: Access denied for user 'mysqltest_8'@'localhost' (using password: NO)
+connection master;
show grants for mysqltest_8;
ERROR 42000: There is no such grant defined for user 'mysqltest_8' on host '%'
drop user mysqltest_8@host8;
@@ -1006,6 +1044,7 @@ insert into mysql.user select * from t2;
flush privileges;
drop table t2;
drop table t1;
+connection master;
CREATE DATABASE mysqltest3;
USE mysqltest3;
CREATE TABLE t_nn (c1 INT);
@@ -1022,6 +1061,7 @@ GRANT SHOW VIEW ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIE
GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+connect mysqltest_1, localhost, mysqltest_1, mysqltest_1,;
SHOW CREATE VIEW mysqltest2.v_nn;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
SHOW CREATE TABLE mysqltest2.v_nn;
@@ -1057,6 +1097,7 @@ v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER
SHOW CREATE TABLE mysqltest2.v_yy;
View Create View character_set_client collation_connection
v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55) latin1 latin1_swedish_ci
+connection master;
SHOW CREATE TABLE mysqltest2.v_nn;
View Create View character_set_client collation_connection
v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn` latin1 latin1_swedish_ci
@@ -1079,9 +1120,12 @@ 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';
USE test;
+connection default;
+disconnect master;
create user longer_than_80_456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
ERROR HY000: String 'longer_than_80_4567890123456789012345678901234567890123456789012345678' is too long for user name (should be no longer than 80)
CREATE DATABASE mysqltest1;
@@ -1095,6 +1139,7 @@ CREATE TABLE mysqltest1.t2 (int_field INT);
"RENAME TABLE and ALTER TABLE"
CREATE USER mysqltest_1@localhost;
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
+connect conn42,localhost,mysqltest_1,,mysqltest1;
SELECT USER();
USER()
mysqltest_1@localhost
@@ -1106,12 +1151,18 @@ RENAME TABLE t1 TO t2;
ERROR 42000: DROP, ALTER command denied to user 'mysqltest_1'@'localhost' for table 't1'
ALTER TABLE t1 RENAME TO t2;
ERROR 42000: DROP, ALTER command denied to user 'mysqltest_1'@'localhost' for table 't1'
+disconnect conn42;
+connection default;
GRANT DROP ON mysqltest1.t1 TO mysqltest_1@localhost;
+connect conn42,localhost,mysqltest_1,,mysqltest1;
RENAME TABLE t1 TO t2;
ERROR 42000: ALTER command denied to user 'mysqltest_1'@'localhost' for table 't1'
ALTER TABLE t1 RENAME TO t2;
ERROR 42000: ALTER command denied to user 'mysqltest_1'@'localhost' for table 't1'
+disconnect conn42;
+connection default;
GRANT ALTER ON mysqltest1.t1 TO mysqltest_1@localhost;
+connect conn42,localhost,mysqltest_1,,mysqltest1;
SHOW GRANTS;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -1120,13 +1171,19 @@ RENAME TABLE t1 TO t2;
ERROR 42000: INSERT, CREATE command denied to user 'mysqltest_1'@'localhost' for table 't2'
ALTER TABLE t1 RENAME TO t2;
ERROR 42000: INSERT, CREATE command denied to user 'mysqltest_1'@'localhost' for table 't2'
+disconnect conn42;
+connection default;
GRANT INSERT, CREATE ON mysqltest1.t1 TO mysqltest_1@localhost;
+connect conn42,localhost,mysqltest_1,,mysqltest1;
SHOW GRANTS;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
GRANT SELECT, INSERT, CREATE, DROP, ALTER ON `mysqltest1`.`t1` TO 'mysqltest_1'@'localhost'
+disconnect conn42;
+connection default;
GRANT INSERT, SELECT, CREATE, ALTER, DROP ON mysqltest1.t2 TO mysqltest_1@localhost;
DROP TABLE mysqltest1.t2;
+connect conn42,localhost,mysqltest_1,,mysqltest1;
SHOW GRANTS;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -1136,8 +1193,11 @@ RENAME TABLE t1 TO t2;
RENAME TABLE t2 TO t1;
ALTER TABLE t1 RENAME TO t2;
ALTER TABLE t2 RENAME TO t1;
+disconnect conn42;
+connection default;
REVOKE DROP, INSERT ON mysqltest1.t1 FROM mysqltest_1@localhost;
REVOKE DROP, INSERT ON mysqltest1.t2 FROM mysqltest_1@localhost;
+connect conn42,localhost,mysqltest_1,,mysqltest1;
SHOW GRANTS;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -1147,6 +1207,8 @@ RENAME TABLE t1 TO t2;
ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 't1'
ALTER TABLE t1 RENAME TO t2;
ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 't1'
+disconnect conn42;
+connection default;
DROP USER mysqltest_1@localhost;
DROP DATABASE mysqltest1;
USE test;
@@ -1177,25 +1239,37 @@ ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghi
CREATE USER bug23556@localhost;
CREATE DATABASE bug23556;
GRANT SELECT ON bug23556.* TO bug23556@localhost;
+connect bug23556,localhost,bug23556,,bug23556;
+connection default;
USE bug23556;
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
GRANT DELETE ON t1 TO bug23556@localhost;
+connection bug23556;
USE bug23556;
TRUNCATE t1;
ERROR 42000: DROP command denied to user 'bug23556'@'localhost' for table 't1'
+connection default;
USE bug23556;
REVOKE DELETE ON t1 FROM bug23556@localhost;
GRANT DROP ON t1 TO bug23556@localhost;
+connection bug23556;
USE bug23556;
TRUNCATE t1;
+connection default;
USE bug23556;
DROP TABLE t1;
USE test;
DROP DATABASE bug23556;
DROP USER bug23556@localhost;
+connection default;
+disconnect bug23556;
+connect con1, localhost, root,,*NO-ONE*;
+connection con1;
GRANT PROCESS ON * TO user@localhost;
ERROR 3D000: No database selected
+disconnect con1;
+connection default;
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
DROP DATABASE IF EXISTS mysqltest3;
@@ -1217,8 +1291,7 @@ GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
-
----> connection: bug9504_con1
+connect bug9504_con1,localhost,mysqltest_1,,;
use mysqltest1;
use mysqltest2;
use mysqltest3;
@@ -1236,8 +1309,8 @@ mysqltest3.f_def()
SELECT mysqltest4.f_inv();
mysqltest4.f_inv()
1
-
----> connection: default
+connection default;
+disconnect bug9504_con1;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP DATABASE mysqltest3;
@@ -1251,8 +1324,7 @@ GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
SELECT 1;
-
----> connection: bug27337_con1
+connect bug27337_con1,localhost,mysqltest_1,,mysqltest2;
CREATE TABLE t1(c INT);
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
CALL mysqltest1.p1();
@@ -1260,14 +1332,14 @@ CALL mysqltest1.p1();
1
CREATE TABLE t1(c INT);
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
-
----> connection: bug27337_con2
+disconnect bug27337_con1;
+connect bug27337_con2,localhost,mysqltest_1,,mysqltest2;
CREATE TABLE t1(c INT);
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
SHOW TABLES;
Tables_in_mysqltest2
-
----> connection: default
+connection default;
+disconnect bug27337_con2;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
@@ -1279,8 +1351,7 @@ CREATE TABLE mysqltest1.t1(c INT);
CREATE TABLE mysqltest2.t2(c INT);
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
-
----> connection: bug27337_con1
+connect bug27337_con1,localhost,mysqltest_1,,mysqltest1;
SHOW TABLES FROM mysqltest1;
Tables_in_mysqltest1
t1
@@ -1288,8 +1359,7 @@ PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
EXECUTE stmt1;
Tables_in_mysqltest1
t1
-
----> connection: bug27337_con2
+connect bug27337_con2,localhost,mysqltest_2,,mysqltest2;
SHOW COLUMNS FROM mysqltest2.t2;
Field Type Null Key Default Extra
c int(11) YES NULL
@@ -1297,24 +1367,22 @@ PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
EXECUTE stmt2;
Field Type Null Key Default Extra
c int(11) YES NULL
-
----> connection: default
+connection default;
REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
-
----> connection: bug27337_con1
+connection bug27337_con1;
SHOW TABLES FROM mysqltest1;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
EXECUTE stmt1;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
-
----> connection: bug27337_con2
+connection bug27337_con2;
SHOW COLUMNS FROM mysqltest2.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
EXECUTE stmt2;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
-
----> connection: default
+connection default;
+disconnect bug27337_con1;
+disconnect bug27337_con2;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_1@localhost;
@@ -1328,6 +1396,8 @@ GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost';
GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost';
USE db27878;
CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1;
+connect user1,localhost,mysqltest_1,,test;
+connection user1;
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
@@ -1335,6 +1405,8 @@ SELECT * FROM test.t1;
f1 f2
1 1
2 2
+disconnect user1;
+connection default;
REVOKE UPDATE (f1) ON `test`.`t1` FROM 'mysqltest_1'@'localhost';
REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost';
REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost';
@@ -1394,8 +1466,7 @@ GRANT CREATE ROUTINE, EXECUTE ON mysqltest1.* TO testuser@localhost;
GRANT SELECT(b) ON t1 TO testuser@localhost;
GRANT SELECT ON t2 TO testuser@localhost;
GRANT SELECT ON mysqltest2.* TO testuser@localhost;
-
-# Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+connect bug57952_con1,localhost,testuser,,mysqltest1;
PREPARE s1 FROM 'SELECT b FROM t1';
PREPARE s2 FROM 'SELECT a FROM t2';
PREPARE s3 FROM 'SHOW TABLES FROM mysqltest2';
@@ -1411,14 +1482,12 @@ a
CALL p3;
Tables_in_mysqltest2
t3
-
-# Connection: default
+connection default;
REVOKE SELECT ON t1 FROM testuser@localhost;
GRANT SELECT(a) ON t1 TO testuser@localhost;
REVOKE SELECT ON t2 FROM testuser@localhost;
REVOKE SELECT ON mysqltest2.* FROM testuser@localhost;
-
-# Connection: bug57952_con1 (testuser@localhost, db: mysqltest1)
+connection bug57952_con1;
# - Check column-level privileges...
EXECUTE s1;
ERROR 42000: SELECT command denied to user 'testuser'@'localhost' for column 'b' in table 't1'
@@ -1442,8 +1511,8 @@ EXECUTE s3;
ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
CALL p3;
ERROR 42000: Access denied for user 'testuser'@'localhost' to database 'mysqltest2'
-
-# Connection: default
+connection default;
+disconnect bug57952_con1;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER testuser@localhost;
@@ -1474,28 +1543,26 @@ select db, routine_name, routine_type, proc_priv from mysql.procs_priv where use
db routine_name routine_type proc_priv
mysqltest1 f1 FUNCTION Execute
mysqltest1 p1 PROCEDURE Execute
-#
-# Create connection 'bug_36544_con1' as 'mysqluser1@localhost'.
+connect bug36544_con1,localhost,mysqluser1,,;
call mysqltest1.p1();
select mysqltest1.f1();
mysqltest1.f1()
0
-#
-# Switch to connection 'default'.
+connection default;
drop user mysqluser1@localhost;
#
# Test that dropping of user is properly reflected in
# both privilege tables and in in-memory structures.
#
-# Switch to connection 'bug36544_con1'.
+connection bug36544_con1;
# The connection cold be alive but should not be able to
# access to any of the stored routines.
call mysqltest1.p1();
ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.p1'
select mysqltest1.f1();
ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.f1'
-#
-# Switch to connection 'default'.
+disconnect bug36544_con1;
+connection default;
#
# Now create user with the same name and check that he
# has not inherited privileges.
@@ -1505,15 +1572,13 @@ Grants for mysqluser1@localhost
GRANT USAGE ON *.* TO 'mysqluser1'@'localhost'
select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser1' and host='localhost';
db routine_name routine_type proc_priv
-#
-# Create connection 'bug_36544_con2' as 'mysqluser1@localhost'.
+connect bug36544_con2,localhost,mysqluser1,,;
# Newly created user should not be able to access any of the routines.
call mysqltest1.p1();
ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.p1'
select mysqltest1.f1();
ERROR 42000: execute command denied to user 'mysqluser1'@'localhost' for routine 'mysqltest1.f1'
-#
-# Switch to connection 'default'.
+connection default;
#
# 2) Check that RENAME USER properly updates privileges on both
# stored procedures and functions.
@@ -1551,8 +1616,7 @@ select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1'
db table_name table_priv
mysqltest1 t11 Select
mysqltest1 t22 Select
-#
-# Switch to connection 'bug36544_con2'.
+connection bug36544_con2;
call mysqltest1.p1();
select mysqltest1.f1();
mysqltest1.f1()
@@ -1561,13 +1625,12 @@ select * from mysqltest1.t11;
i
select * from mysqltest1.t22;
i
-#
-# Switch to connection 'default'.
+connection default;
rename user mysqluser1@localhost to mysqluser10@localhost;
#
# Test that there are no privileges left for mysqluser1.
#
-# Switch to connection 'bug36544_con2'.
+connection bug36544_con2;
# The connection cold be alive but should not be able to
# access to any of the stored routines or tables.
call mysqltest1.p1();
@@ -1578,8 +1641,8 @@ select * from mysqltest1.t11;
ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't11'
select * from mysqltest1.t22;
ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't22'
-#
-# Switch to connection 'default'.
+disconnect bug36544_con2;
+connection default;
#
# Now create user with the old name and check that he
# has not inherited privileges.
@@ -1591,8 +1654,7 @@ select db, routine_name, routine_type, proc_priv from mysql.procs_priv where use
db routine_name routine_type proc_priv
select db, table_name, table_priv from mysql.tables_priv where user='mysqluser1' and host='localhost';
db table_name table_priv
-#
-# Create connection 'bug_36544_con3' as 'mysqluser1@localhost'.
+connect bug36544_con3,localhost,mysqluser1,,;
# Newly created user should not be able to access to any of the
# stored routines or tables.
call mysqltest1.p1();
@@ -1603,8 +1665,8 @@ select * from mysqltest1.t11;
ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't11'
select * from mysqltest1.t22;
ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't22'
-#
-# Switch to connection 'default'.
+disconnect bug36544_con3;
+connection default;
#
# Now check that privileges became associated with a new user
# name - mysqluser10.
@@ -1624,8 +1686,7 @@ select db, table_name, table_priv from mysql.tables_priv where user='mysqluser10
db table_name table_priv
mysqltest1 t11 Select
mysqltest1 t22 Select
-#
-# Create connection 'bug_36544_con4' as 'mysqluser10@localhost'.
+connect bug36544_con4,localhost,mysqluser10,,;
call mysqltest1.p1();
select mysqltest1.f1();
mysqltest1.f1()
@@ -1634,8 +1695,8 @@ select * from mysqltest1.t11;
i
select * from mysqltest1.t22;
i
-#
-# Switch to connection 'default'.
+disconnect bug36544_con4;
+connection default;
#
# Clean-up.
drop user mysqluser1@localhost;
@@ -1656,15 +1717,19 @@ create database mysqltest;
use mysqltest;
grant create on mysqltest.* to mysqltest@localhost;
create table t1 (i INT);
+connect user1,localhost,mysqltest,,mysqltest;
+connection user1;
insert into t1 values (1);
ERROR 42000: INSERT command denied to user 'mysqltest'@'localhost' for table 't1'
create table t2 (i INT);
create table t4 (i INT);
+connection default;
grant select, insert on mysqltest.t2 to mysqltest@localhost;
grant insert on mysqltest.t4 to mysqltest@localhost;
grant create, insert on mysqltest.t5 to mysqltest@localhost;
grant create, insert on mysqltest.t6 to mysqltest@localhost;
flush privileges;
+connection user1;
insert into t2 values (1);
create table if not exists t1 select * from t2;
ERROR 42000: INSERT command denied to user 'mysqltest'@'localhost' for table 't1'
@@ -1681,6 +1746,7 @@ create table t4 select * from t2;
ERROR 42S01: Table 't4' already exists
create table t1 select * from t2;
ERROR 42000: INSERT command denied to user 'mysqltest'@'localhost' for table 't1'
+connection default;
drop table t1,t2,t4,t5,t6;
revoke create on mysqltest.* from mysqltest@localhost;
revoke select, insert on mysqltest.t2 from mysqltest@localhost;
@@ -1688,6 +1754,7 @@ revoke insert on mysqltest.t4 from mysqltest@localhost;
revoke create, insert on mysqltest.t5 from mysqltest@localhost;
revoke create, insert on mysqltest.t6 from mysqltest@localhost;
drop user mysqltest@localhost;
+disconnect user1;
drop database mysqltest;
use test;
FLUSH PRIVILEGES without procs_priv table.
@@ -1711,6 +1778,7 @@ FLUSH PRIVILEGES;
CREATE DATABASE dbbug33464;
CREATE USER 'userbug33464'@'localhost';
GRANT CREATE ROUTINE ON dbbug33464.* TO 'userbug33464'@'localhost';
+connect connbug33464, localhost, userbug33464, , dbbug33464;
userbug33464@localhost dbbug33464
CREATE PROCEDURE sp3(v1 char(20))
@@ -1725,6 +1793,8 @@ CREATE FUNCTION fn2() returns char(50) SQL SECURITY DEFINER
BEGIN
return 2;
END//
+disconnect connbug33464;
+connection default;
USE dbbug33464;
root@localhost dbbug33464
@@ -1753,6 +1823,7 @@ SHOW GRANTS FOR 'user1'@'localhost';
Grants for user1@localhost
GRANT USAGE ON *.* TO 'user1'@'localhost'
GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user1'@'localhost'
+connect con1,localhost,user1,,;
** Connect as user1 and create a procedure.
** The creation will imply implicitly assigned
** EXECUTE and ALTER ROUTINE privileges to
@@ -1769,6 +1840,7 @@ BEGIN
SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END ;||
+connect con2,localhost,user2,,;
** Connect as user2 and create a procedure.
** Implicitly assignment of privileges will
** fail because the user2@localhost is an
@@ -1780,6 +1852,7 @@ REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END ;||
Warnings:
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
+connection default;
SHOW GRANTS FOR 'user1'@'localhost';
Grants for user1@localhost
GRANT USAGE ON *.* TO 'user1'@'localhost'
@@ -1789,6 +1862,8 @@ SHOW GRANTS FOR 'user2';
Grants for user2@%
GRANT USAGE ON *.* TO 'user2'@'%'
GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%'
+disconnect con1;
+disconnect con2;
DROP PROCEDURE db1.proc1;
DROP PROCEDURE db1.proc2;
REVOKE ALL ON db1.* FROM 'user1'@'localhost';
@@ -1801,6 +1876,7 @@ DROP DATABASE db1;
# Bug #25863 No database selected error, but documentation
# says * for global allowed
#
+connect conn1,localhost,root,,*NO-ONE*;
GRANT ALL ON * TO mysqltest_1;
ERROR 3D000: No database selected
GRANT ALL ON *.* TO mysqltest_1;
@@ -1820,18 +1896,23 @@ SHOW GRANTS FOR mysqltest_1;
Grants for mysqltest_1@%
GRANT ALL PRIVILEGES ON *.* TO 'mysqltest_1'@'%'
DROP USER mysqltest_1;
+connection default;
+disconnect conn1;
CREATE DATABASE db1;
CREATE DATABASE db2;
GRANT SELECT ON db1.* to 'testbug'@localhost;
USE db2;
CREATE TABLE t1 (a INT);
USE test;
+connect con1,localhost,testbug,,db1;
SELECT * FROM `../db2/tb2`;
ERROR 42S02: Table 'db1.../db2/tb2' doesn't exist
SELECT * FROM `../db2`.tb2;
ERROR 42000: SELECT command denied to user 'testbug'@'localhost' for table 'tb2'
SELECT * FROM `#mysql50#/../db2/tb2`;
ERROR 42000: Incorrect table name '#mysql50#/../db2/tb2'
+connection default;
+disconnect con1;
DROP USER 'testbug'@localhost;
DROP TABLE db2.t1;
DROP DATABASE db1;
@@ -1888,13 +1969,13 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT RELOAD, SHUTDOWN, PROCESS, FILE, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, CREATE USER ON *.* TO 'mysqltest_u1'@'localhost'
GRANT CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE ROUTINE, ALTER ROUTINE, EVENT ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
ERROR 42000: SHOW command denied to user 'mysqltest_u1'@'localhost' for table 't1'
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -1911,16 +1992,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT SELECT ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -1937,16 +2018,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT INSERT ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -1963,16 +2044,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT UPDATE ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -1989,16 +2070,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT DELETE ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2015,16 +2096,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT CREATE ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2041,16 +2122,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT DROP ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2067,16 +2148,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT ALTER ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2093,16 +2174,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT INDEX ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2119,16 +2200,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT REFERENCES ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2145,16 +2226,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT USAGE ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost' WITH GRANT OPTION
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2171,16 +2252,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT CREATE VIEW ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2197,16 +2278,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT SHOW VIEW ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2223,16 +2304,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT SELECT ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2249,16 +2330,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT INSERT ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2275,16 +2356,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT UPDATE ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2301,16 +2382,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT DELETE ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2327,16 +2408,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT CREATE ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2353,16 +2434,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT DROP ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2379,16 +2460,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT ALTER ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2405,16 +2486,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT INDEX ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2431,16 +2512,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT REFERENCES ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2457,16 +2538,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT USAGE ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost' WITH GRANT OPTION
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2483,16 +2564,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT CREATE VIEW ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2509,16 +2590,16 @@ SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT SHOW VIEW ON `mysqltest_db1`.`t1` TO 'mysqltest_u1'@'localhost'
-
-# connection: con1 (mysqltest_u1@mysqltest_db1)
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
+connection con1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-
-# connection: default
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -2542,7 +2623,7 @@ DROP DATABASE IF EXISTS secret;
DROP DATABASE IF EXISTS no_such_db;
CREATE DATABASE secret;
GRANT USAGE ON *.* TO untrusted@localhost;
-# Connection con1
+connect con1, localhost, untrusted;
SHOW GRANTS;
Grants for untrusted@localhost
GRANT USAGE ON *.* TO 'untrusted'@'localhost'
@@ -2557,7 +2638,8 @@ CREATE PROCEDURE no_such_db.foo() BEGIN END;
ERROR 42000: Access denied for user 'untrusted'@'localhost' to database 'no_such_db'
CREATE PROCEDURE secret.peek_at_secret() BEGIN END;
ERROR 42000: Access denied for user 'untrusted'@'localhost' to database 'secret'
-# Connection default
+connection default;
+disconnect con1;
DROP USER untrusted@localhost;
DROP DATABASE secret;
#
diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result
index bd14f21010b..d447bc10dc7 100644
--- a/mysql-test/r/grant2.result
+++ b/mysql-test/r/grant2.result
@@ -11,15 +11,27 @@ flush privileges;
grant all privileges on `my\_1`.* to mysqltest_1@localhost with grant option;
grant create user on *.* to mysqltest_1@localhost;
create user mysqltest_2@localhost;
+connect user_a,localhost,mysqltest_1,,;
+connection user_a;
grant select on `my\_1`.* to mysqltest_2@localhost;
grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql'
+disconnect user_a;
+connection default;
grant update on mysql.* to mysqltest_1@localhost;
+connect user_b,localhost,mysqltest_1,,;
+connection user_b;
grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
grant select on `my\_1`.* to mysqltest_3@localhost;
+disconnect user_b;
+connection default;
grant insert on mysql.* to mysqltest_1@localhost;
+connect user_c,localhost,mysqltest_1,,;
+connection user_c;
grant select on `my\_1`.* to mysqltest_3@localhost;
grant select on `my\_1`.* to mysqltest_4@localhost identified by 'pass';
+disconnect user_c;
+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\_%';
@@ -27,6 +39,8 @@ delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges;
grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
grant create user on *.* to mysqltest_1@localhost;
+connect user1,localhost,mysqltest_1,,;
+connection user1;
select current_user();
current_user()
mysqltest_1@localhost
@@ -41,6 +55,8 @@ grant select on `my\_1`.* to mysqltest_4@localhost with grant option;
ERROR 28000: Can't find any matching row in the user table
grant select on `my\_1`.* to mysqltest_4@localhost identified by 'mypass'
with grant option;
+disconnect user1;
+connection default;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT CREATE USER ON *.* TO 'mysqltest_1'@'localhost'
@@ -56,6 +72,8 @@ delete from mysql.db where user like 'mysqltest\_%';
flush privileges;
create database mysqltest_1;
grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option;
+connect user2,localhost,mysqltest_1,,;
+connection user2;
select current_user();
current_user()
mysqltest_1@localhost
@@ -66,6 +84,8 @@ mysqltest_1
test
grant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_1'
+disconnect user2;
+connection default;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -79,6 +99,8 @@ grant INSERT, SELECT on mysqltest.* to mysqltest_1@localhost;
flush privileges;
use mysqltest;
create table t1 (id int primary key, data varchar(255));
+connect mrbad, localhost, mysqltest_1,,mysqltest;
+connection mrbad;
show grants for current_user();
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -91,16 +113,22 @@ ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table '
select * from t1;
id data
1 I can't change it!
+disconnect mrbad;
+connection default;
drop table t1;
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
flush privileges;
create table t1 (a int, b int);
grant select (a) on t1 to mysqltest_1@localhost with grant option;
+connect mrugly, localhost, mysqltest_1,,mysqltest;
+connection mrugly;
grant select (a,b) on t1 to mysqltest_2@localhost;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't1'
grant select on t1 to mysqltest_3@localhost;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
+disconnect mrugly;
+connection default;
drop table t1;
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
@@ -118,14 +146,24 @@ create user mysqltest_6@host6;
create user mysqltest_7@host7;
flush privileges;
drop user mysqltest_3@host3;
+connect con8,127.0.0.1,root,,test,$MASTER_MYPORT,;
+disconnect con8;
+connection default;
drop user mysqltest_1@host1, mysqltest_2@host2, mysqltest_4@host4,
mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7;
+connect con9,127.0.0.1,root,,test,$MASTER_MYPORT,;
+disconnect con9;
+connection default;
create database mysqltest_1;
grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost;
+connect con10,localhost,mysqltest_1,,;
+connection con10;
set sql_log_off = 1;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
set sql_log_bin = 0;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
+disconnect con10;
+connection default;
delete from mysql.user where user like 'mysqltest\_1';
delete from mysql.db where user like 'mysqltest\_1';
drop database mysqltest_1;
@@ -270,14 +308,20 @@ GRANT SELECT ON "mysql".* TO '%@a'@'a'
drop user '%@a'@'a';
create user mysqltest_2@localhost;
grant create user on *.* to mysqltest_2@localhost;
+connect user3,localhost,mysqltest_2,,;
+connection user3;
select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 'user'
create user mysqltest_A@'%';
rename user mysqltest_A@'%' to mysqltest_B@'%';
drop user mysqltest_B@'%';
+disconnect user3;
+connection default;
drop user mysqltest_2@localhost;
create user mysqltest_3@localhost;
grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost;
+connect user4,localhost,mysqltest_3,,;
+connection user4;
show grants;
Grants for mysqltest_3@localhost
GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost'
@@ -294,12 +338,16 @@ create user mysqltest_A@'%';
rename user mysqltest_B@'%' to mysqltest_C@'%';
drop user mysqltest_C@'%';
drop user mysqltest_A@'%';
+disconnect user4;
+connection default;
drop user mysqltest_3@localhost;
set @@sql_mode='';
create database mysqltest_1;
create table mysqltest_1.t1 (i int);
insert into mysqltest_1.t1 values (1),(2),(3);
GRANT ALL ON mysqltest_1.t1 TO mysqltest_1@'127.0.0.0/255.0.0.0';
+connect n1,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection n1;
show grants for current_user();
Grants for mysqltest_1@127.0.0.0/255.0.0.0
GRANT USAGE ON *.* TO 'mysqltest_1'@'127.0.0.0/255.0.0.0'
@@ -309,15 +357,21 @@ i
1
2
3
+disconnect n1;
+connection default;
REVOKE ALL ON mysqltest_1.t1 FROM mysqltest_1@'127.0.0.0/255.0.0.0';
delete from mysql.user where user like 'mysqltest\_1';
flush privileges;
drop table mysqltest_1.t1;
grant all on mysqltest_1.* to mysqltest_1@'127.0.0.1';
+connect b12302,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,;
+connection b12302;
select current_user();
current_user()
mysqltest_1@127.0.0.1
set password = password('changed');
+disconnect b12302;
+connection default;
select host, length(password) from mysql.user where user like 'mysqltest\_1';
host length(password)
127.0.0.1 41
@@ -325,10 +379,14 @@ revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.1';
delete from mysql.user where user like 'mysqltest\_1';
flush privileges;
grant all on mysqltest_1.* to mysqltest_1@'127.0.0.0/255.0.0.0';
+connect b12302_2,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,;
+connection b12302_2;
select current_user();
current_user()
mysqltest_1@127.0.0.0/255.0.0.0
set password = password('changed');
+disconnect b12302_2;
+connection default;
select host, length(password) from mysql.user where user like 'mysqltest\_1';
host length(password)
127.0.0.0/255.0.0.0 41
@@ -336,17 +394,38 @@ revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.0/255.0.0.0';
delete from mysql.user where user like 'mysqltest\_1';
flush privileges;
drop database mysqltest_1;
+connect n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection n5;
set password = password("changed");
ERROR 42000: You are using MariaDB as an anonymous user and anonymous users are not allowed to modify user settings
+disconnect n5;
+connection default;
+connect con2root,localhost,root,,;
+connect con3root,localhost,root,,;
+connection default;
lock table mysql.user write;
+connection con2root;
flush privileges;
+connection con3root;
grant all on *.* to 'mysqltest_1'@'localhost';
+connection default;
unlock tables;
+connection con2root;
+connection con3root;
+connection default;
lock table mysql.user write;
+connection con2root;
set password for 'mysqltest_1'@'localhost' = password('');
+connection con3root;
revoke all on *.* from 'mysqltest_1'@'localhost';
+connection default;
unlock tables;
+connection con2root;
+connection con3root;
+connection default;
drop user 'mysqltest_1'@'localhost';
+disconnect con2root;
+disconnect con3root;
create database TESTDB;
create table t2(a int);
create temporary table t1 as select * from mysql.user;
@@ -361,8 +440,11 @@ Warning 1364 Field 'authentication_string' doesn't have a default value
INSERT INTO mysql.db (host, db, user, select_priv) VALUES
('%','TESTDB','mysqltest_1','Y');
FLUSH PRIVILEGES;
+connect con1,localhost,mysqltest_1,password,TESTDB;
create database TEStdb;
Got one of the listed errors
+connection default;
+disconnect con1;
delete from mysql.user;
delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';
insert into mysql.user select * from t1;
@@ -373,6 +455,8 @@ SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creato
SET GLOBAL log_bin_trust_function_creators = 1;
GRANT ALL PRIVILEGES ON test.* TO `a@`@localhost;
GRANT EXECUTE ON * TO `a@`@localhost;
+connect bug13310,localhost,'a@',,test;
+connection bug13310;
CREATE TABLE t2 (s1 INT);
INSERT INTO t2 VALUES (1);
DROP FUNCTION IF EXISTS f2;
@@ -383,6 +467,8 @@ f2()
1
DROP FUNCTION f2;
DROP TABLE t2;
+disconnect bug13310;
+connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;
DROP USER `a@`@localhost;
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
@@ -394,35 +480,48 @@ create database mysqltest_2;
grant all on mysqltest_1.* to mysqltest_u1@localhost;
use mysqltest_2;
create table t1 (i int);
+connect user1,localhost,mysqltest_u1,,mysqltest_1;
+connection user1;
show create table mysqltest_2.t1;
ERROR 42000: SHOW command denied to user 'mysqltest_u1'@'localhost' for table 't1'
create table t1 like mysqltest_2.t1;
ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1'
+connection default;
grant select on mysqltest_2.t1 to mysqltest_u1@localhost;
+connection user1;
show create table mysqltest_2.t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
create table t1 like mysqltest_2.t1;
+connection default;
+disconnect user1;
use test;
drop database mysqltest_1;
drop database mysqltest_2;
drop user mysqltest_u1@localhost;
grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option;
grant usage on *.* to mysqltest_2@localhost;
+connect con18600_1,localhost,mysqltest_1,,;
create database mysqltest_1;
use mysqltest_1;
create table t1 (f1 int);
grant create on `mysqltest\_1`.* to mysqltest_2@localhost;
grant select on mysqltest_1.t1 to mysqltest_2@localhost;
+connect con3,localhost,mysqltest_2,,;
+connection con3;
create database mysqltest_3;
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest_3'
use mysqltest_1;
create table t2(f1 int);
select * from t1;
f1
+connection default;
drop database mysqltest_1;
+connection default;
+disconnect con3;
+disconnect con18600_1;
revoke all privileges, grant option from mysqltest_1@localhost;
revoke all privileges, grant option from mysqltest_2@localhost;
drop user mysqltest_1@localhost;
@@ -435,6 +534,8 @@ CREATE TABLE t2 (b INT, c INT);
INSERT INTO t2 VALUES (1,100),(2,200);
GRANT SELECT ON t1 TO mysqltest1@localhost;
GRANT SELECT (b) ON t2 TO mysqltest1@localhost;
+connect conn1,localhost,mysqltest1,,;
+connection conn1;
USE db1;
SELECT c FROM t2;
ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2'
@@ -442,6 +543,8 @@ SELECT * FROM t2;
ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for table 't2'
SELECT * FROM t1 JOIN t2 USING (b);
ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2'
+connection default;
+disconnect conn1;
USE test;
DROP TABLE db1.t1, db1.t2;
DROP USER mysqltest1@localhost;
@@ -530,8 +633,7 @@ CREATE TABLE mysqltest_db2.t2_1(a INT);
# SQL-statement against temporary tables (loosely follow order in
# sql_command enum).
###########################################################################
-
-# -- connect con1, mysqltest_u1@localhost, mysqltest_db1
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
#
# Variants of CREATE TABLE.
#
@@ -770,8 +872,7 @@ DROP TEMPORARY TABLE t1;
# - Check that even outside of SUID context we can access temporary
# table once it is created.
###########################################################################
-
-# -- connect con2, mysqltest_u2@localhost, mysqltest_db1
+connect con2,localhost,mysqltest_u2,,mysqltest_db1;
CREATE TEMPORARY TABLE t2(a INT);
ERROR 42000: Access denied for user 'mysqltest_u2'@'localhost' to database 'mysqltest_db1'
CALL p1();
@@ -796,8 +897,7 @@ DROP TEMPORARY TABLE t4;
# - Check that once table is created it can be accessed from within any
# context, even by user without any privileges on tables.
###########################################################################
-
-# -- connect con3, mysqltest_u4@localhost, mysqltest_db1
+connect con3,localhost,mysqltest_u4,,mysqltest_db1;
CALL p1();
INSERT INTO t4 VALUES (4);
UPDATE t4 SET x = 10 WHERE x = 1;
@@ -812,8 +912,7 @@ DROP TEMPORARY TABLE t4;
# - SELECT_ACL, UPDATE_ACL and DELETE_ACL are required to include
# a temporary table into the underlying-table-list.
###########################################################################
-
-# -- connect con4, mysqltest_u5@localhost, mysqltest_db1
+connect con4,localhost,mysqltest_u5,,mysqltest_db1;
CREATE TEMPORARY TABLE t7(a INT);
CREATE TEMPORARY TABLE t8(a INT);
CREATE TEMPORARY TABLE t9(a INT);
@@ -832,13 +931,12 @@ DROP TEMPORARY TABLE t9;
###########################################################################
# That's all. Cleanup.
###########################################################################
-
-# -- connection: default
-# -- disconnect con1
+connection default;
# All remaining temporary tables are automatically dropped.
-# -- disconnect con2
-# -- disconnect con3
-# -- disconnect con4
+disconnect con1;
+disconnect con2;
+disconnect con3;
+disconnect con4;
SET GLOBAL keycache1.key_buffer_size = 0;
DROP DATABASE mysqltest_db1;
DROP DATABASE mysqltest_db2;
diff --git a/mysql-test/r/grant3.result b/mysql-test/r/grant3.result
index d1722fc8ea9..4c99fb02f19 100644
--- a/mysql-test/r/grant3.result
+++ b/mysql-test/r/grant3.result
@@ -1,6 +1,8 @@
set global sql_mode="";
set local sql_mode="";
SET NAMES binary;
+connect master,localhost,root,,;
+connection master;
drop table if exists t1;
delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%';
@@ -10,9 +12,14 @@ flush privileges;
create user mysqltest_1@localhost;
grant create user on *.* to mysqltest_1@localhost;
grant select on `my\_1`.* to mysqltest_1@localhost with grant option;
+connect user_a,localhost,mysqltest_1,,;
+connection user_a;
grant select on `my\_1`.* to mysqltest_2@localhost;
ERROR 42000: You are not allowed to create a user with GRANT
create user mysqltest_2@localhost;
+disconnect user_a;
+disconnect master;
+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\_%';
@@ -132,6 +139,8 @@ GRANT SELECT, UPDATE ON `mysqltest_1`.* TO 'mysqltest1'@'%';
REVOKE SELECT ON `mysqltest_1`.* FROM 'mysqltest1'@'%';
GRANT SELECT, UPDATE ON `mysqltest\_1`.* TO 'mysqltest1'@'%';
FLUSH PRIVILEGES;
+connect conn1,localhost,mysqltest1,,;
+connection conn1;
SHOW GRANTS;
Grants for mysqltest1@%
GRANT USAGE ON *.* TO 'mysqltest1'@'%'
@@ -139,6 +148,8 @@ GRANT SELECT, UPDATE ON `mysqltest\_1`.* TO 'mysqltest1'@'%'
GRANT UPDATE ON `mysqltest_1`.* TO 'mysqltest1'@'%'
SELECT * FROM mysqltest_1.t1;
a
+disconnect conn1;
+connection default;
DROP USER 'mysqltest1'@'%';
DROP DATABASE mysqltest_1;
#
@@ -163,6 +174,8 @@ Grants for user2@%
GRANT USAGE ON *.* TO 'user2'@'%'
GRANT SELECT (a), INSERT (b) ON `temp`.`t1` TO 'user2'@'%'
# Connect as the renamed user
+connect conn1, localhost, user2,,;
+connection conn1;
SHOW GRANTS;
Grants for user2@%
GRANT USAGE ON *.* TO 'user2'@'%'
@@ -177,6 +190,8 @@ a
# access this column.
SELECT b FROM temp.t1;
ERROR 42000: SELECT command denied to user 'user2'@'localhost' for column 'b' in table 't1'
+disconnect conn1;
+connection default;
DROP USER 'user2'@'%';
DROP DATABASE temp;
set global sql_mode=default;
diff --git a/mysql-test/r/grant4.result b/mysql-test/r/grant4.result
index 5a0032cd338..c3db2e03e3e 100644
--- a/mysql-test/r/grant4.result
+++ b/mysql-test/r/grant4.result
@@ -11,6 +11,8 @@ grant insert (a) on mysqltest_db1.t_column_priv_only to mysqltest_u1@localhost;
grant select on mysqltest_db1.t_select_priv to mysqltest_u1@localhost;
** Connect as restricted user mysqltest_u1.
+connect con1,localhost,mysqltest_u1,,;
+connection con1;
** Test column level privileges only. No SELECT privileges on the table.
** INSERT INTO ... VALUES ...
** Attempting to insert values to a table with only column privileges
@@ -72,6 +74,7 @@ t_select_priv CREATE TABLE `t_select_priv` (
show create table mysqltest_db1.t_no_priv;
ERROR 42000: SHOW command denied to user 'mysqltest_u1'@'localhost' for table 't_no_priv'
+connection default;
use mysqltest_db1;
CREATE TABLE t5 (s1 INT);
CREATE INDEX i ON t5 (s1);
@@ -85,6 +88,7 @@ GRANT UPDATE (s2) ON t6 to mysqltest_u1@localhost;
GRANT UPDATE (s2) ON v6 to mysqltest_u1@localhost;
GRANT SHOW VIEW ON v2 to mysqltest_u1@localhost;
GRANT SHOW VIEW, SELECT ON v3 to mysqltest_u1@localhost;
+connection con1;
use mysqltest_db1;
** Connect as restricted user mysqltest_u1.
** SELECT FROM INFORMATION_SCHEMA.STATISTICS will succeed because any privileges will do (authentication is enough).
@@ -121,6 +125,8 @@ ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table
SHOW CREATE VIEW v3;
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t_select_priv`.`a` AS `a`,`t_select_priv`.`b` AS `b` from `t_select_priv` latin1 latin1_swedish_ci
+connection default;
+disconnect con1;
drop database mysqltest_db1;
drop user mysqltest_u1@localhost;
#
@@ -147,11 +153,13 @@ insert into mysqltest_db1.t2 values (1);
# Create user which will try to do this.
create user mysqltest_u1@localhost;
grant insert, select on mysqltest_db1.t1 to mysqltest_u1@localhost;
+connect con1,localhost,mysqltest_u1,,;
+connection default;
# Corrupt t1 by replacing t1.MYI with a corrupt + unclosed one created
# by doing: 'create table t1 (a int key(a))'
# head -c1024 t1.MYI > corrupt_t1.MYI
flush table mysqltest_db1.t1;
-# Switching to connection 'con1'.
+connection con1;
check table mysqltest_db1.t1;
Table Op Msg_type Msg_text
mysqltest_db1.t1 check warning 1 client is using or hasn't closed the table properly
@@ -177,7 +185,8 @@ Table Op Msg_type Msg_text
mysqltest_db1.t1 repair warning Number of rows changed from 1 to 2
mysqltest_db1.t1 repair status OK
# Clean-up.
-# Switching to connection 'default'.
+disconnect con1;
+connection default;
drop database mysqltest_db1;
drop user mysqltest_u1@localhost;
create user foo1 identified by password '11111111111111111111111111111111111111111';
diff --git a/mysql-test/r/grant_cache_no_prot.result b/mysql-test/r/grant_cache_no_prot.result
index 34abd96f026..f1adb3ae839 100644
--- a/mysql-test/r/grant_cache_no_prot.result
+++ b/mysql-test/r/grant_cache_no_prot.result
@@ -7,7 +7,8 @@ set LOCAL query_cache_type=ON;
set GLOBAL query_cache_size=1355776;
reset query cache;
flush status;
------ establish connection root -----
+connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root;
show grants for current_user;
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
@@ -26,7 +27,8 @@ insert into test.t1 values ("test.t1");
select * from t1;
a
test.t1
------ establish connection root2 -----
+connect root2,localhost,root,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root2;
select * from t1;
a b c
1 1 1
@@ -56,7 +58,8 @@ grant SELECT on mysqltest.* to mysqltest_1@localhost;
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
grant SELECT on test.t1 to mysqltest_2@localhost;
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
------ establish connection user1 (user=mysqltest_1) -----
+connect user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user1;
show grants for current_user();
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -121,11 +124,13 @@ Qcache_hits 3
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
------ establish connection unkuser (user=unkuser) -----
+connect unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection unkuser;
show grants for current_user();
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
------ establish connection user2 (user=mysqltest_2) -----
+connect user2,localhost,mysqltest_2,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user2;
select "user2";
user2
user2
@@ -156,7 +161,8 @@ Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 2
------ establish connection user3 (user=mysqltest_3) -----
+connect user3,localhost,mysqltest_3,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user3;
select "user3";
user3
user3
@@ -181,7 +187,8 @@ Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 4
------ establish connection user4 (user=mysqltest_1) -----
+connect user4,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user4;
select "user4";
user4
user4
@@ -212,8 +219,21 @@ Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 5
------ close connections -----
------ switch to connection default -----
+connection root;
+disconnect root;
+connection root2;
+disconnect root2;
+connection user1;
+disconnect user1;
+connection user2;
+disconnect user2;
+connection user3;
+disconnect user3;
+connection user4;
+disconnect user4;
+connection unkuser;
+disconnect unkuser;
+connection default;
set names binary;
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
diff --git a/mysql-test/r/grant_cache_ps_prot.result b/mysql-test/r/grant_cache_ps_prot.result
index 5fe57c7c35d..56a98cc076d 100644
--- a/mysql-test/r/grant_cache_ps_prot.result
+++ b/mysql-test/r/grant_cache_ps_prot.result
@@ -7,7 +7,8 @@ set LOCAL query_cache_type=ON;
set GLOBAL query_cache_size=1355776;
reset query cache;
flush status;
------ establish connection root -----
+connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root;
show grants for current_user;
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
@@ -26,7 +27,8 @@ insert into test.t1 values ("test.t1");
select * from t1;
a
test.t1
------ establish connection root2 -----
+connect root2,localhost,root,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root2;
select * from t1;
a b c
1 1 1
@@ -56,7 +58,8 @@ grant SELECT on mysqltest.* to mysqltest_1@localhost;
grant SELECT on mysqltest.t1 to mysqltest_2@localhost;
grant SELECT on test.t1 to mysqltest_2@localhost;
grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;
------ establish connection user1 (user=mysqltest_1) -----
+connect user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user1;
show grants for current_user();
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -121,11 +124,13 @@ Qcache_hits 3
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 1
------ establish connection unkuser (user=unkuser) -----
+connect unkuser,localhost,unkuser,,,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection unkuser;
show grants for current_user();
Grants for @localhost
GRANT USAGE ON *.* TO ''@'localhost'
------ establish connection user2 (user=mysqltest_2) -----
+connect user2,localhost,mysqltest_2,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user2;
select "user2";
user2
user2
@@ -156,7 +161,8 @@ Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 2
------ establish connection user3 (user=mysqltest_3) -----
+connect user3,localhost,mysqltest_3,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user3;
select "user3";
user3
user3
@@ -181,7 +187,8 @@ Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 3
------ establish connection user4 (user=mysqltest_1) -----
+connect user4,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user4;
select "user4";
user4
user4
@@ -212,8 +219,21 @@ Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 4
------ close connections -----
------ switch to connection default -----
+connection root;
+disconnect root;
+connection root2;
+disconnect root2;
+connection user1;
+disconnect user1;
+connection user2;
+disconnect user2;
+connection user3;
+disconnect user3;
+connection user4;
+disconnect user4;
+connection unkuser;
+disconnect unkuser;
+connection default;
set names binary;
delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");
diff --git a/mysql-test/r/grant_explain_non_select.result b/mysql-test/r/grant_explain_non_select.result
index 1dbb5b1e3c0..53b7d687d6c 100644
--- a/mysql-test/r/grant_explain_non_select.result
+++ b/mysql-test/r/grant_explain_non_select.result
@@ -6,6 +6,8 @@ CREATE TABLE privtest_db.t2 (a INT);
INSERT INTO privtest_db.t2 VALUES (1), (2), (3);
GRANT USAGE ON *.* TO 'privtest'@'localhost';
GRANT SELECT ON privtest_db.t2 TO 'privtest'@'localhost';
+connect con1,localhost,privtest,,;
+connection con1;
USE privtest_db;
EXPLAIN INSERT INTO t1 VALUES (10);
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
@@ -15,7 +17,9 @@ EXPLAIN INSERT INTO t1 SELECT * FROM t2;
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
INSERT INTO t1 SELECT * FROM t2;
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
GRANT INSERT ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN INSERT INTO t1 VALUES (10);
id select_type table type possible_keys key key_len ref rows Extra
1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL
@@ -24,7 +28,9 @@ EXPLAIN INSERT INTO t1 SELECT * FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
INSERT INTO t1 SELECT * FROM t2;
+connection default;
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
+connection con1;
EXPLAIN REPLACE INTO t1 VALUES (10);
ERROR 42000: INSERT, DELETE command denied to user 'privtest'@'localhost' for table 't1'
REPLACE INTO t1 VALUES (10);
@@ -33,7 +39,9 @@ EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
ERROR 42000: INSERT, DELETE command denied to user 'privtest'@'localhost' for table 't1'
REPLACE INTO t1 SELECT * FROM t2;
ERROR 42000: INSERT, DELETE command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
GRANT INSERT ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN REPLACE INTO t1 VALUES (10);
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
REPLACE INTO t1 VALUES (10);
@@ -42,8 +50,10 @@ EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
REPLACE INTO t1 SELECT * FROM t2;
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
REVOKE INSERT ON privtest_db.t1 FROM 'privtest'@'localhost';
GRANT DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN REPLACE INTO t1 VALUES (10);
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
REPLACE INTO t1 VALUES (10);
@@ -52,7 +62,9 @@ EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
REPLACE INTO t1 SELECT * FROM t2;
ERROR 42000: INSERT command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
GRANT INSERT, DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN REPLACE INTO t1 VALUES (10);
id select_type table type possible_keys key key_len ref rows Extra
1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL
@@ -61,7 +73,9 @@ EXPLAIN REPLACE INTO t1 SELECT * FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
REPLACE INTO t1 SELECT * FROM t2;
+connection default;
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
+connection con1;
EXPLAIN UPDATE t1 SET a = a + 1;
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
UPDATE t1 SET a = a + 1;
@@ -70,7 +84,9 @@ EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
GRANT UPDATE ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN UPDATE t1 SET a = a + 1;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
UPDATE t1 SET a = a + 1;
@@ -79,8 +95,10 @@ EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
+connection default;
REVOKE UPDATE ON privtest_db.t1 FROM 'privtest'@'localhost';
GRANT SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN UPDATE t1 SET a = a + 1;
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
UPDATE t1 SET a = a + 1;
@@ -89,7 +107,9 @@ EXPLAIN UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
ERROR 42000: UPDATE command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
GRANT UPDATE, SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN UPDATE t1 SET a = a + 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 8
@@ -99,7 +119,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
UPDATE t1, t2 SET t1.a = t1.a + 1 WHERE t1.a = t2.a;
+connection default;
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
+connection con1;
EXPLAIN DELETE FROM t1 WHERE a = 10;
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
DELETE FROM t1 WHERE a = 10;
@@ -108,7 +130,9 @@ EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
GRANT DELETE ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN DELETE FROM t1 WHERE a = 10;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for column 'a' in table 't1'
DELETE FROM t1 WHERE a = 10;
@@ -117,8 +141,10 @@ EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
ERROR 42000: SELECT command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
GRANT SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN DELETE FROM t1 WHERE a = 10;
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
DELETE FROM t1 WHERE a = 10;
@@ -127,8 +153,10 @@ EXPLAIN DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
ERROR 42000: DELETE command denied to user 'privtest'@'localhost' for table 't1'
+connection default;
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
GRANT DELETE, SELECT ON privtest_db.t1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN DELETE FROM t1 WHERE a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
@@ -138,9 +166,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where
DELETE FROM t1 USING t1, t2 WHERE t1.a = t2.a;
+connection default;
REVOKE ALL PRIVILEGES ON privtest_db.t1 FROM 'privtest'@'localhost';
CREATE VIEW privtest_db.v1 (a) AS SELECT a FROM privtest_db.t1;
GRANT SELECT, INSERT, UPDATE, DELETE ON privtest_db.v1 TO 'privtest'@'localhost';
+connection con1;
EXPLAIN SELECT * FROM v1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
SELECT * FROM v1;
@@ -175,6 +205,8 @@ DELETE FROM v1 WHERE a = 10;
EXPLAIN DELETE FROM v1 USING v1, t2 WHERE v1.a = t2.a;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
DELETE FROM v1 USING v1, t2 WHERE v1.a = t2.a;
+connection default;
+disconnect con1;
DROP USER 'privtest'@localhost;
USE test;
DROP DATABASE privtest_db;
diff --git a/mysql-test/r/grant_lowercase.result b/mysql-test/r/grant_lowercase.result
index b449453a47a..d4a1667595e 100644
--- a/mysql-test/r/grant_lowercase.result
+++ b/mysql-test/r/grant_lowercase.result
@@ -1,8 +1,12 @@
set sql_mode="";
grant file on *.* to user1@localhost with grant option;
grant select on `a%`.* to user1@localhost with grant option;
+connect conn1,localhost,user1,,;
+connection conn1;
grant file on aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.* to 'user'@'%' identified by 'secret';
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
+connection default;
+disconnect conn1;
drop user user1@localhost;
call mtr.add_suppression("Incorrect database name");
alter table mysql.host modify Db varchar(200);
diff --git a/mysql-test/r/grant_lowercase_fs.result b/mysql-test/r/grant_lowercase_fs.result
index eb27b1d7ea0..e883067eca0 100644
--- a/mysql-test/r/grant_lowercase_fs.result
+++ b/mysql-test/r/grant_lowercase_fs.result
@@ -3,13 +3,18 @@ create user user_1@localhost;
create user USER_1@localhost;
GRANT CREATE ON db1.* to user_1@localhost;
GRANT SELECT ON db1.* to USER_1@localhost;
+connect con1,localhost,user_1,,db1;
CREATE TABLE t1(f1 int);
SELECT * FROM t1;
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't1'
+connect con2,localhost,USER_1,,db1;
SELECT * FROM t1;
f1
CREATE TABLE t2(f1 int);
ERROR 42000: CREATE command denied to user 'USER_1'@'localhost' for table 't2'
+connection default;
+disconnect con1;
+disconnect con2;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM USER_1@localhost;
DROP USER user_1@localhost;
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index fa5280df2b4..fba04812a5b 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -230,6 +230,8 @@ 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;
+connect user3,localhost,mysqltest_2,,;
+connection user3;
select table_name, column_name, privileges from information_schema.columns
where table_schema = 'mysqltest' and table_name = 't1';
table_name column_name privileges
@@ -237,12 +239,16 @@ t1 a select
show columns from mysqltest.t1;
Field Type Null Key Default Extra
a int(11) YES NULL
+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';
table_name column_name privileges
v1 c select
explain select * from v1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+connection default;
+disconnect user4;
drop view v1, mysqltest.v1;
drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5;
drop database mysqltest;
@@ -346,15 +352,21 @@ routine_schema routine_name
test sel2
test sub1
drop view v1;
+connect user1,localhost,mysqltest_1,,;
+connection user1;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
show create function sub1;
ERROR 42000: FUNCTION sub1 does not exist
+connection user3;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
sel2 NULL
sub1 NULL
+connection default;
grant all privileges on test.* to mysqltest_1@localhost;
+connect user2,localhost,mysqltest_1,,;
+connection user2;
select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES;
ROUTINE_NAME ROUTINE_DEFINITION
sel2 NULL
@@ -379,6 +391,9 @@ return i+1 latin1 latin1_swedish_ci latin1_swedish_ci
show function status like "sub2";
Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation
test sub2 FUNCTION mysqltest_1@localhost # # DEFINER latin1 latin1_swedish_ci latin1_swedish_ci
+connection default;
+disconnect user1;
+disconnect user3;
drop function sub2;
show create procedure sel2;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
@@ -510,6 +525,7 @@ def test PRIMARY def test t1 a 1 NULL NULL NULL NULL
def test constraint_1 def test t1 a 1 NULL NULL NULL NULL
def test key_1 def test t1 a 1 NULL NULL NULL NULL
def test key_2 def test t1 a 1 NULL NULL NULL NULL
+connection user2;
select table_name from information_schema.TABLES where table_schema like "test%";
table_name
t1
@@ -520,6 +536,8 @@ select ROUTINE_NAME from information_schema.ROUTINES;
ROUTINE_NAME
sel2
sub1
+disconnect user2;
+connection default;
delete from mysql.user where user='mysqltest_1';
drop table t1;
drop procedure sel2;
@@ -887,6 +905,8 @@ x_float NULL NULL
x_double_precision NULL NULL
drop table t1;
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
where COLUMN_NAME='TABLE_NAME' and table_name not like 'innodb%';
TABLE_NAME COLUMN_NAME PRIVILEGES
@@ -903,6 +923,8 @@ TABLE_CONSTRAINTS TABLE_NAME select
TABLE_PRIVILEGES TABLE_NAME select
TABLE_STATISTICS TABLE_NAME select
VIEWS TABLE_NAME select
+connection default;
+disconnect user10261;
delete from mysql.user where user='mysqltest_4';
delete from mysql.db where user='mysqltest_4';
flush privileges;
@@ -970,6 +992,11 @@ grant select (f1) on mysqltest.t1 to user1@localhost;
grant select on mysqltest.t2 to user2@localhost;
grant select on mysqltest.* to user3@localhost;
grant select on *.* to user4@localhost;
+connect con1,localhost,user1,,mysqltest;
+connect con2,localhost,user2,,mysqltest;
+connect con3,localhost,user3,,mysqltest;
+connect con4,localhost,user4,,;
+connection con1;
select * from information_schema.column_privileges order by grantee;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user1'@'localhost' def mysqltest t1 f1 SELECT NO
@@ -984,6 +1011,7 @@ show grants;
Grants for user1@localhost
GRANT USAGE ON *.* TO 'user1'@'localhost'
GRANT SELECT (f1) ON `mysqltest`.`t1` TO 'user1'@'localhost'
+connection con2;
select * from information_schema.column_privileges order by grantee;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.table_privileges order by grantee;
@@ -998,6 +1026,7 @@ show grants;
Grants for user2@localhost
GRANT USAGE ON *.* TO 'user2'@'localhost'
GRANT SELECT ON `mysqltest`.`t2` TO 'user2'@'localhost'
+connection con3;
select * from information_schema.column_privileges order by grantee;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
select * from information_schema.table_privileges order by grantee;
@@ -1012,6 +1041,7 @@ show grants;
Grants for user3@localhost
GRANT USAGE ON *.* TO 'user3'@'localhost'
GRANT SELECT ON `mysqltest`.* TO 'user3'@'localhost'
+connection con4;
select * from information_schema.column_privileges where grantee like '%user%'
order by grantee;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
@@ -1034,6 +1064,11 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
show grants;
Grants for user4@localhost
GRANT SELECT ON *.* TO 'user4'@'localhost'
+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;
@@ -1107,12 +1142,15 @@ t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
DROP TABLE t1,t2;
create table t1(f1 int);
create view v1 (c) as select f1 from t1;
+connect con5,localhost,root,,*NO-ONE*;
select database();
database()
NULL
show fields from test.v1;
Field Type Null Key Default Extra
c int(11) YES NULL
+connection default;
+disconnect con5;
drop view v1;
drop table t1;
alter database information_schema;
@@ -1223,11 +1261,15 @@ create table t1 (id int);
create view v1 as select * from t1;
create definer = mysqltest_1@localhost
sql security definer view v2 as select 1;
+connect con16681,localhost,mysqltest_1,,test;
+connection con16681;
select * from information_schema.views
where table_name='v1' or table_name='v2';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION ALGORITHM
def test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED
def test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci UNDEFINED
+connection default;
+disconnect con16681;
drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
@@ -1259,6 +1301,7 @@ SHOW CREATE FUNCTION f1;
Function sql_mode Create Function character_set_client collation_connection Database Collation
f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
RETURN @a + 1 latin1 latin1_swedish_ci latin1_swedish_ci
+connect conn1, localhost, mysql_bug20230,,;
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test';
ROUTINE_NAME ROUTINE_DEFINITION
f1 NULL
@@ -1273,6 +1316,8 @@ CALL p1();
SELECT f1();
f1()
2
+disconnect conn1;
+connection default;
DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
@@ -1351,6 +1396,7 @@ t1_ai
show triggers from mysqltest;
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
t1_ai INSERT t1 set @a = new.a + new.b + new.c AFTER NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
+connect con27629,localhost,mysqltest_1,,mysqltest;
show columns from t1;
Field Type Null Key Default Extra
b int(11) YES NULL
@@ -1362,6 +1408,8 @@ Trigger Event Table Statement Timing Created sql_mode Definer character_set_clie
select trigger_name from information_schema.triggers
where event_object_table='t1';
trigger_name
+connection default;
+disconnect con27629;
drop user mysqltest_1@localhost;
drop database mysqltest;
create table t1 (
@@ -1415,13 +1463,19 @@ select * from information_schema.engines WHERE ENGINE="MyISAM";
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
MyISAM DEFAULT MyISAM storage engine NO NO NO
grant select on *.* to user3148@localhost;
+connect con3148,localhost,user3148,,test;
+connection con3148;
select user,db from information_schema.processlist;
user db
user3148 test
+connection default;
+disconnect con3148;
drop user user3148@localhost;
+connect pslistcon,localhost,root,,test;
SELECT 'other connection here' AS who;
who
other connection here
+connection default;
SELECT IF(`time` > 0, 'OK', `time`) AS time_low,
IF(`time` < 1000, 'OK', `time`) AS time_high,
IF(time_ms >= 1000, 'OK', time_ms) AS time_ms_low,
@@ -1430,6 +1484,7 @@ FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE ID=@tid;
time_low time_high time_ms_low time_ms_high
OK OK OK OK
+disconnect pslistcon;
DROP TABLE IF EXISTS server_status;
DROP EVENT IF EXISTS event_status;
SET GLOBAL event_scheduler=1;
@@ -1579,10 +1634,22 @@ show open tables where f1()=0;
show open tables where f1()=0;
drop table t1;
drop function f1;
+connect conn1, localhost, root,,;
+connection conn1;
select * from information_schema.tables where 1=sleep(100000);
+connection default;
+connection conn1;
Got one of the listed errors
+connection default;
+disconnect conn1;
+connect conn1, localhost, root,,;
+connection conn1;
select * from information_schema.columns where 1=sleep(100000);
+connection default;
+connection conn1;
Got one of the listed errors
+connection default;
+disconnect conn1;
explain select count(*) from information_schema.tables;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases
@@ -1688,6 +1755,8 @@ USE db1;
CREATE TABLE t1 (id INT);
CREATE USER nonpriv;
USE test;
+connect nonpriv_con, localhost, nonpriv,,;
+connection nonpriv_con;
# connected as nonpriv
# Should return 0
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1';
@@ -1698,7 +1767,9 @@ USE INFORMATION_SCHEMA;
SELECT COUNT(*) FROM TABLES WHERE TABLE_NAME='t1';
COUNT(*)
0
+connection default;
# connected as root
+disconnect nonpriv_con;
DROP USER nonpriv;
DROP TABLE db1.t1;
DROP DATABASE db1;
@@ -1732,8 +1803,12 @@ DROP TABLE ubig;
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
1
grant usage on *.* to mysqltest_1@localhost;
+connect con1, localhost, mysqltest_1,,;
+connection con1;
select 1 from information_schema.tables where table_schema=repeat('a', 2000);
1
+connection default;
+disconnect con1;
drop user mysqltest_1@localhost;
End of 5.1 tests.
#
@@ -1746,13 +1821,15 @@ End of 5.1 tests.
drop tables if exists t1, t2, t3;
create table t1 (i int);
create table t2 (j int primary key auto_increment);
-# Switching to connection 'con3726_1'
+connect con3726_1,localhost,root,,test;
+connection con3726_1;
lock table t2 read;
-# Switching to connection 'con3726_2'
+connect con3726_2,localhost,root,,test;
+connection con3726_2;
# RENAME below will be blocked by 'lock table t2 read' above but
# will add two pending requests for exclusive metadata locks.
rename table t2 to t3;
-# Switching to connection 'default'
+connection default;
# These statements should not be blocked by pending lock requests
select table_name, column_name, data_type from information_schema.columns
where table_schema = 'test' and table_name in ('t1', 't2');
@@ -1764,10 +1841,12 @@ where table_schema = 'test' and table_name in ('t1', 't2');
table_name auto_increment
t1 NULL
t2 1
-# Switching to connection 'con3726_1'
+connection con3726_1;
unlock tables;
-# Switching to connection 'con3726_2'
-# Switching to connection 'default'
+connection con3726_2;
+connection default;
+disconnect con3726_1;
+disconnect con3726_2;
drop tables t1, t3;
EXPLAIN SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;
id select_type table type possible_keys key key_len ref rows Extra
@@ -1846,9 +1925,10 @@ create table t1 (a int, b int);
create view v1 as select t1.a, t1.b from t1;
alter table t1 change b c int;
lock table t1 read;
-# --> connection con1
+connect con1, localhost, root,,;
+connection con1;
flush tables;
-# --> connection default
+connection default;
select * from information_schema.views;
TABLE_CATALOG def
TABLE_SCHEMA test
@@ -1869,9 +1949,10 @@ unlock tables;
#
# Cleanup.
#
-# --> connection con1
+connection con1;
# Reaping 'flush tables'
-# --> connection default
+disconnect con1;
+connection default;
drop table t1;
drop view v1;
#
@@ -1897,47 +1978,33 @@ create table t2 (k int);
# Acquire lock on 't2' so upcoming RENAME is
# blocked.
lock tables t2 read;
-#
-# Switching to connection 'con12828477_1'.
-#
+connect con12828477_1, localhost, root,,mysqltest;
# The below RENAME should wait on 't2' while
# keeping X lock on 't1'.
rename table t1 to t3, t2 to t1, t3 to t2;
-#
-# Switching to connection 'con12828477_2'.
-#
+connect con12828477_2, localhost, root,,mysqltest;
# Wait while the above RENAME is blocked.
# Issue query to I_S which will open 't0' and get
# blocked on 't1' because of RENAME.
select table_name, auto_increment from information_schema.tables where table_schema='mysqltest';
-#
-# Switching to connection 'con12828477_3'.
-#
+connect con12828477_3, localhost, root,,mysqltest;
# Wait while the above SELECT is blocked.
#
# Check that it holds no lock on 't0' so it can be renamed.
rename table t0 to t4;
-#
-# Switching to connection 'default'.
-#
+connection default;
#
# Unblock the first RENAME.
unlock tables;
-#
-# Switching to connection 'con12828477_1'.
-#
+connection con12828477_1;
# Reap the first RENAME
-#
-# Switching to connection 'con12828477_2'.
-#
+connection con12828477_2;
# Reap SELECT to I_S.
table_name auto_increment
t0 NULL
t1 NULL
t2 NULL
-#
-# Switching to connection 'default'.
-#
+connection default;
#
# Now test that we don't keep locks in case when we to fill
# I_S table we read .FRM or .TRG file only (this was the case
@@ -1947,44 +2014,33 @@ rename table t4 to t0;
# Acquire lock on 't2' so upcoming RENAME is
# blocked.
lock tables t2 read;
-#
-# Switching to connection 'con12828477_1'.
-#
+connection con12828477_1;
# The below RENAME should wait on 't2' while
# keeping X lock on 't1'.
rename table t1 to t3, t2 to t1, t3 to t2;
-#
-# Switching to connection 'con12828477_2'.
-#
+connection con12828477_2;
# Wait while the above RENAME is blocked.
# Issue query to I_S which will open 't0' and get
# blocked on 't1' because of RENAME.
select event_object_table, trigger_name from information_schema.triggers where event_object_schema='mysqltest';
-#
-# Switching to connection 'con12828477_3'.
-#
+connection con12828477_3;
# Wait while the above SELECT is blocked.
#
# Check that it holds no lock on 't0' so it can be renamed.
rename table t0 to t4;
-#
-# Switching to connection 'default'.
-#
+connection default;
#
# Unblock the first RENAME.
unlock tables;
-#
-# Switching to connection 'con12828477_1'.
-#
+connection con12828477_1;
# Reap the first RENAME
-#
-# Switching to connection 'con12828477_2'.
-#
+connection con12828477_2;
# Reap SELECT to I_S.
event_object_table trigger_name
-#
-# Switching to connection 'default'.
-#
+connection default;
+disconnect con12828477_1;
+disconnect con12828477_2;
+disconnect con12828477_3;
#
# MDEV-3818: Query against view over IS tables worse than equivalent query without view
#
@@ -2030,6 +2086,8 @@ SELECT @val1 = @val2;
# MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases
#
drop database if exists db1;
+connect con1,localhost,root,,;
+connection con1;
create database db1;
use db1;
create table t1 (a int);
@@ -2068,4 +2126,6 @@ Variable_name Value
Opened_tables 3
drop database mysqltest;
drop database db1;
+connection default;
+disconnect con1;
set global sql_mode=default;
diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result
index c09e04f786a..ca1ab45b98b 100644
--- a/mysql-test/r/information_schema_db.result
+++ b/mysql-test/r/information_schema_db.result
@@ -38,10 +38,13 @@ create table t1
(f1 int(10) unsigned not null,
f2 varchar(100) not null,
primary key (f1), unique key (f2));
+connect user1,localhost,mysqltest_1,,;
+connection user1;
select * from information_schema.tables;
call mbase.p1();
call mbase.p1();
call mbase.p1();
+connection default;
use `inf%`;
drop user mysqltest_1@localhost;
drop table t1;
@@ -59,6 +62,7 @@ drop function func2;
drop database `inf%`;
drop procedure mbase.p1;
drop database mbase;
+disconnect user1;
use test;
create table t1 (i int);
create function f1 () returns int return (select max(i) from t1);
@@ -87,6 +91,7 @@ create user testdb_1@localhost;
grant all on testdb_1.* to testdb_1@localhost with grant option;
create user testdb_2@localhost;
grant all on test.* to testdb_2@localhost with grant option;
+connect testdb_1,localhost,testdb_1,,test;
use testdb_1;
create table t1 (f1 char(4));
create view v1 as select f1 from t1;
@@ -95,6 +100,7 @@ create view v5 as select f1 from t1;
grant select, show view on v5 to testdb_2@localhost;
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
+connection default;
use testdb_1;
create view v6 as select f1 from t1;
grant select, show view on v6 to testdb_2@localhost;
@@ -118,9 +124,11 @@ Field Type Null Key Default Extra
f1 char(4) YES NULL
Warnings:
Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist
+connection testdb_1;
create table t3 (f1 char(4), f2 char(4));
create view v3 as select f1,f2 from t3;
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
+connect testdb_2,localhost,testdb_2,,test;
create view v2 as select f1 from testdb_1.v1;
create view v4 as select f1,f2 from testdb_1.v3;
show fields from testdb_1.v5;
@@ -135,6 +143,7 @@ f1 char(4) YES NULL
show create view testdb_1.v6;
View Create View character_set_client collation_connection
v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1` latin1 latin1_swedish_ci
+connection testdb_1;
show fields from testdb_1.v7;
Field Type Null Key Default Extra
f1 char(4) YES NULL
@@ -147,8 +156,10 @@ Warnings:
Note 1449 The user specified as a definer ('no_such_user'@'no_such_host') does not exist
revoke insert(f1) on v3 from testdb_2@localhost;
revoke select,show view on v5 from testdb_2@localhost;
+connection default;
use testdb_1;
revoke select,show view on v6 from testdb_2@localhost;
+connection testdb_2;
show fields from testdb_1.v5;
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
show create view testdb_1.v5;
@@ -192,9 +203,15 @@ where a.table_name = 'testdb_1.v1';
view_definition
select * from v2;
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+connection default;
use test;
drop view testdb_1.v1, v2, testdb_1.v3, v4;
drop database testdb_1;
+connection testdb_1;
+disconnect testdb_1;
+connection testdb_2;
+disconnect testdb_2;
+connection default;
drop user testdb_1@localhost;
drop user testdb_2@localhost;
create database testdb_1;
@@ -202,6 +219,8 @@ create table testdb_1.t1 (a int);
create view testdb_1.v1 as select * from testdb_1.t1;
grant show view on testdb_1.* to mysqltest_1@localhost;
grant select on testdb_1.v1 to mysqltest_1@localhost;
+connect user1,localhost,mysqltest_1,,test;
+connection user1;
select table_schema, table_name, view_definition from information_schema.views
where table_name='v1';
table_schema table_name view_definition
@@ -209,13 +228,19 @@ testdb_1 v1 select `testdb_1`.`t1`.`a` AS `a` from `testdb_1`.`t1`
show create view testdb_1.v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v1` AS select `testdb_1`.`t1`.`a` AS `a` from `testdb_1`.`t1` latin1 latin1_swedish_ci
+connection default;
revoke select on testdb_1.v1 from mysqltest_1@localhost;
+connection user1;
select table_schema, table_name, view_definition from information_schema.views
where table_name='v1';
table_schema table_name view_definition
testdb_1 v1
show create view testdb_1.v1;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v1'
+connection default;
drop user mysqltest_1@localhost;
drop database testdb_1;
+connection user1;
+disconnect user1;
+connection default;
set global sql_mode=default;
diff --git a/mysql-test/r/information_schema_linux.result b/mysql-test/r/information_schema_linux.result
index 43095b76151..b4b7de7bc65 100644
--- a/mysql-test/r/information_schema_linux.result
+++ b/mysql-test/r/information_schema_linux.result
@@ -2,6 +2,9 @@
# MDEV-6756: map a linux pid (child pid) to a connection id shown in
# the output of SHOW PROCESSLIST
#
+connect con1,localhost,root;
SELECT max(tid) != min(tid) FROM information_schema.processlist;
max(tid) != min(tid)
1
+connection default;
+disconnect con1;
diff --git a/mysql-test/r/init_connect.result b/mysql-test/r/init_connect.result
index 0ff6c206422..11bb6036156 100644
--- a/mysql-test/r/init_connect.result
+++ b/mysql-test/r/init_connect.result
@@ -1,29 +1,51 @@
+connect con0,localhost,root,,;
+connection con0;
select hex(@a);
hex(@a)
NULL
+connect con1,localhost,user_1,,;
+connection con1;
select hex(@a);
hex(@a)
610063
+connection con0;
set global init_connect="set @a=2;set @b=3";
+connect con2,localhost,user_1,,;
+connection con2;
select @a, @b;
@a @b
2 3
+connection con0;
set GLOBAL init_connect=DEFAULT;
+connect con3,localhost,user_1,,;
+connection con3;
select @a;
@a
NULL
+connection con0;
set global init_connect="drop table if exists t1; create table t1(a char(10));\
insert into t1 values ('\0');insert into t1 values('abc')";
+connect con4,localhost,user_1,,;
+connection con4;
select hex(a) from t1;
hex(a)
00
616263
+connection con0;
set GLOBAL init_connect="adsfsdfsdfs";
+connect con5,localhost,user_1,,;
+connection con5;
select @a;
ERROR 08S01: Aborted connection to db: 'test' user: 'user_1' host: 'localhost' (init_connect command failed)
select @a;
Got one of the listed errors
+connection con0;
drop table t1;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+disconnect con4;
+disconnect con5;
End of 4.1 tests
create table t1 (x int);
insert into t1 values (3), (5), (7);
@@ -31,18 +53,24 @@ create table t2 (y int);
create user mysqltest1@localhost;
grant all privileges on test.* to mysqltest1@localhost;
set global init_connect="create procedure p1() select * from t1";
+connect con1,localhost,mysqltest1,,;
+connection con1;
call p1();
x
3
5
7
drop procedure p1;
+connection con0;
+disconnect con1;
set global init_connect="create procedure p1(x int)\
begin\
select count(*) from t1;\
select * from t1;\
set @x = x;
end";
+connect con1,localhost,mysqltest1,,;
+connection con1;
call p1(42);
count(*)
3
@@ -53,13 +81,23 @@ x
select @x;
@x
42
+connection con0;
+disconnect con1;
set global init_connect="call p1(4711)";
+connect con1,localhost,mysqltest1,,;
+connection con1;
select @x;
@x
4711
+connection con0;
+disconnect con1;
set global init_connect="drop procedure if exists p1";
+connect con1,localhost,mysqltest1,,;
+connection con1;
call p1();
ERROR 42000: PROCEDURE test.p1 does not exist
+connection con0;
+disconnect con1;
create procedure p1(out sum int)
begin
declare n int default 0;
@@ -81,9 +119,13 @@ end;
end loop;
end|
set global init_connect="call p1(@sum)";
+connect con1,localhost,mysqltest1,,;
+connection con1;
select @sum;
@sum
12
+connection con0;
+disconnect con1;
drop procedure p1;
create procedure p1(tbl char(10), v int)
begin
@@ -94,12 +136,16 @@ execute stmt1 using @v;
deallocate prepare stmt1;
end|
set global init_connect="call p1('t1', 11)";
+connect con1,localhost,mysqltest1,,;
+connection con1;
select * from t1;
x
3
5
7
11
+connection con0;
+disconnect con1;
drop procedure p1;
create function f1() returns int
begin
@@ -108,22 +154,36 @@ select count(*) into n from t1;
return n;
end|
set global init_connect="set @x = f1()";
+connect con1,localhost,mysqltest1,,;
+connection con1;
select @x;
@x
4
+connection con0;
+disconnect con1;
set global init_connect="create view v1 as select f1()";
+connect con1,localhost,mysqltest1,,;
+connection con1;
select * from v1;
f1()
4
+connection con0;
+disconnect con1;
set global init_connect="drop view v1";
+connect con1,localhost,mysqltest1,,;
+connection con1;
select * from v1;
ERROR 42S02: Table 'test.v1' doesn't exist
+connection con0;
+disconnect con1;
drop function f1;
create trigger trg1
after insert on t2
for each row
insert into t1 values (new.y);
set global init_connect="insert into t2 values (13), (17), (19)";
+connect con1,localhost,mysqltest1,,;
+connection con1;
select * from t1;
x
3
@@ -133,6 +193,9 @@ x
13
17
19
+connection default;
+disconnect con0;
+disconnect con1;
drop trigger trg1;
set global init_connect="set @a='a\\0c'";
revoke all privileges, grant option from mysqltest1@localhost;
diff --git a/mysql-test/r/init_connection_query_cache.result b/mysql-test/r/init_connection_query_cache.result
index 5a1e5c5244f..eacc06c05f6 100644
--- a/mysql-test/r/init_connection_query_cache.result
+++ b/mysql-test/r/init_connection_query_cache.result
@@ -6,6 +6,8 @@ set GLOBAL query_cache_size=1355776;
create user mysqltest1@localhost;
grant SELECT on test.* to mysqltest1@localhost;
create table t1 (a int);
+connect con1,localhost,mysqltest1,,;
+connection con1;
# This explain put here to be sure that init connection query
# has 'Impossible WHERE'.
explain extended select * from test.t1 where 0;
@@ -13,6 +15,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
+connection default;
+disconnect con1;
revoke all privileges, grant option from mysqltest1@localhost;
drop user mysqltest1@localhost;
drop table t1;
diff --git a/mysql-test/r/innodb_mysql_lock.result b/mysql-test/r/innodb_mysql_lock.result
index 70b86017008..a7f45d355f1 100644
--- a/mysql-test/r/innodb_mysql_lock.result
+++ b/mysql-test/r/innodb_mysql_lock.result
@@ -5,29 +5,38 @@ set session innodb_lock_wait_timeout=300;
# Bug #22876 Four-way deadlock
#
DROP TABLE IF EXISTS t1;
-# Connection 1
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connect con3,localhost,root,,;
+connection con1;
set @@autocommit=0;
CREATE TABLE t1(s1 INT UNIQUE) ENGINE=innodb;
INSERT INTO t1 VALUES (1);
-# Connection 2
+connection con2;
set @@autocommit=0;
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (1);
-# Connection 3
+connection con3;
set @@autocommit=0;
DROP TABLE t1;
-# Connection 1
+connection con1;
# Connection 1 is now holding the lock.
# Issuing insert from connection 1 while connection 2&3
# is waiting for the lock should give a deadlock error.
INSERT INTO t1 VALUES (2);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Cleanup
+connection con2;
commit;
set @@autocommit=1;
+connection con1;
commit;
set @@autocommit=1;
+connection con3;
set @@autocommit=1;
+connection default;
+disconnect con1;
+disconnect con3;
#
# Test for bug #37346 "innodb does not detect deadlock between update
# and alter table".
@@ -39,14 +48,15 @@ begin;
# Run statement which acquires X-lock on one of table's rows.
update t1 set c3=c3+1 where c2=3;
#
-# Switching to connection 'con37346'.
+connect con37346,localhost,root,,test,,;
+connection con37346;
# The below ALTER TABLE statement should wait till transaction
# in connection 'default' is complete and then succeed.
# It should not deadlock or fail with ER_LOCK_DEADLOCK error.
# Sending:
alter table t1 add column c4 int;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until the above ALTER TABLE gets blocked because this
# connection holds SW metadata lock on table to be altered.
# The below statement should succeed. It should not
@@ -55,10 +65,11 @@ update t1 set c3=c3+1 where c2=4;
# Unblock ALTER TABLE by committing transaction.
commit;
#
-# Switching to connection 'con37346'.
+connection con37346;
# Reaping ALTER TABLE.
#
-# Switching to connection 'default'.
+connection default;
+disconnect con37346;
drop table t1;
#
# Bug #42147 Concurrent DML and LOCK TABLE ... READ for InnoDB
@@ -72,22 +83,23 @@ drop table t1;
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT) engine= innodb;
-# Connection 2
# Get user-level lock
+connection con2;
SELECT get_lock('bug42147_lock', 60);
get_lock('bug42147_lock', 60)
1
-# Connection 1
+connection default;
INSERT INTO t1 SELECT get_lock('bug42147_lock', 60);
-# Connection 2
+connection con2;
LOCK TABLES t1 READ;
SELECT release_lock('bug42147_lock');
release_lock('bug42147_lock')
1
-# Connection 1
-# Connection 2
+connection default;
+connection con2;
UNLOCK TABLES;
-# Connection 1
+connection default;
+disconnect con2;
DROP TABLE t1;
#
# Bug#53798 OPTIMIZE TABLE breaks repeatable read
@@ -95,29 +107,30 @@ DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT) engine=innodb;
INSERT INTO t1 VALUES (1), (2), (3);
-# Connection con1
+connect con1, localhost, root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
SELECT * FROM t1;
a
1
2
3
-# Connection default
+connection default;
# This should block
# Sending:
OPTIMIZE TABLE t1;
-# Connection con1
+connection con1;
SELECT * FROM t1;
a
1
2
3
COMMIT;
-# Connection default
+connection default;
# Reaping OPTIMIZE TABLE t1
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK
+disconnect con1;
DROP TABLE t1;
#
# Bug#49891 View DDL breaks REPEATABLE READ
@@ -127,52 +140,58 @@ DROP VIEW IF EXISTS v2;
CREATE TABLE t1 ( f1 INTEGER ) ENGINE = innodb;
CREATE TABLE t2 ( f1 INTEGER );
CREATE VIEW v1 AS SELECT 1 FROM t1;
-# Connection con3
+connect con2, localhost, root;
+connect con3, localhost, root;
+connection con3;
LOCK TABLE t1 WRITE;
-# Connection default
+connection default;
START TRANSACTION;
# Sending:
SELECT * FROM v1;
-# Connection con2
+connection con2;
# Waiting for 'SELECT * FROM v1' to sync in.
# Sending:
ALTER VIEW v1 AS SELECT 2 FROM t2;
-# Connection con3
+connection con3;
# Waiting for 'ALTER VIEW v1 AS SELECT 2 FROM t2' to sync in.
UNLOCK TABLES;
-# Connection default;
+connection default;
# Reaping: SELECT * FROM v1
1
SELECT * FROM v1;
1
COMMIT;
-# Connection con2
+connection con2;
# Reaping: ALTER VIEW v1 AS SELECT 2 FROM t2
-# Connection default
+connection default;
DROP TABLE t1, t2;
DROP VIEW v1;
+disconnect con2;
+disconnect con3;
#
# Bug#11815600 [ERROR] INNODB COULD NOT FIND INDEX PRIMARY
# KEY NO 0 FOR TABLE IN ERROR LOG
#
DROP TABLE IF EXISTS t1;
-# Connection default
+connect con1,localhost,root;
+connection default;
CREATE TABLE t1 (id INT PRIMARY KEY, value INT) ENGINE = InnoDB;
INSERT INTO t1 VALUES (1, 12345);
START TRANSACTION;
SELECT * FROM t1;
id value
1 12345
-# Connection con1
+connection con1;
SET lock_wait_timeout=1;
ALTER TABLE t1 ADD INDEX idx(value);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ALTER TABLE t1 ADD INDEX idx(value);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-# Connection default
+connection default;
SELECT * FROM t1;
id value
1 12345
COMMIT;
DROP TABLE t1;
+disconnect con1;
set global innodb_lock_wait_timeout=@old_innodb_lock_wait_timeout;
diff --git a/mysql-test/r/innodb_mysql_lock2.result b/mysql-test/r/innodb_mysql_lock2.result
index 54203c140a2..df97b32a41c 100644
--- a/mysql-test/r/innodb_mysql_lock2.result
+++ b/mysql-test/r/innodb_mysql_lock2.result
@@ -17,6 +17,8 @@ select @@session.tx_isolation;
REPEATABLE-READ
# Prepare playground by creating tables, views,
# routines and triggers used in tests.
+connect con1, localhost, root,,;
+connection default;
drop table if exists t0, t1, t2, t3, t4, t5;
drop view if exists v1, v2;
drop procedure if exists p1;
@@ -179,6 +181,7 @@ end|
#
# No locks are necessary as this statement won't be written
# to the binary log and InnoDB supports snapshots.
+connection default;
Success: 'select * from t1' doesn't take row locks on 't1'.
#
# 1.2 Multi-UPDATE statement.
@@ -186,11 +189,13 @@ Success: 'select * from t1' doesn't take row locks on 't1'.
# Has to take shared locks on rows in the table being read as this
# statement will be written to the binary log and therefore should
# be serialized with concurrent statements.
+connection default;
Success: 'update t2, t1 set j= j - 1 where i = j' takes shared row locks on 't1'.
#
# 1.3 Multi-DELETE statement.
#
# The above is true for this statement as well.
+connection default;
Success: 'delete t2 from t1, t2 where i = j' takes shared row locks on 't1'.
#
# 1.4 DESCRIBE statement.
@@ -198,12 +203,15 @@ Success: 'delete t2 from t1, t2 where i = j' takes shared row locks on 't1'.
# This statement does not really read data from the
# target table and thus does not take any lock on it.
# We check this for completeness of coverage.
+connection default;
Success: 'describe t1' doesn't take row locks on 't1'.
#
# 1.5 SHOW statements.
#
# The above is true for SHOW statements as well.
+connection default;
Success: 'show create table t1' doesn't take row locks on 't1'.
+connection default;
Success: 'show keys from t1' doesn't take row locks on 't1'.
#
# 2. Statements which read tables through subqueries.
@@ -218,6 +226,7 @@ Success: 'show keys from t1' doesn't take row locks on 't1'.
# But in practice InnoDB does locking reads for all statements
# other than SELECT (unless it is a READ-COMITTED mode or
# innodb_locks_unsafe_for_binlog is ON).
+connection default;
Success: 'call p1((select i + 5 from t1 where i = 1))' takes shared row locks on 't1'.
#
# 2.2 CREATE TABLE with a subquery.
@@ -225,25 +234,30 @@ Success: 'call p1((select i + 5 from t1 where i = 1))' takes shared row locks on
# Has to take shared locks on rows in the table being read as
# this statement is written to the binary log and therefore
# should be serialized with concurrent statements.
+connection default;
Success: 'create table t0 engine=innodb select * from t1' takes shared row locks on 't1'.
drop table t0;
+connection default;
Success: 'create table t0 engine=innodb select j from t2 where j in (select i from t1)' takes shared row locks on 't1'.
drop table t0;
#
# 2.3 DELETE with a subquery.
#
# The above is true for this statement as well.
+connection default;
Success: 'delete from t2 where j in (select i from t1)' takes shared row locks on 't1'.
#
# 2.4 MULTI-DELETE with a subquery.
#
# Same is true for this statement as well.
+connection default;
Success: 'delete t2 from t3, t2 where k = j and j in (select i from t1)' takes shared row locks on 't1'.
#
# 2.5 DO with a subquery.
#
# In theory should not take row locks as it is not logged.
# In practice InnoDB takes shared row locks.
+connection default;
Success: 'do (select i from t1 where i = 1)' takes shared row locks on 't1'.
#
# 2.6 INSERT with a subquery.
@@ -251,18 +265,23 @@ Success: 'do (select i from t1 where i = 1)' takes shared row locks on 't1'.
# Has to take shared locks on rows in the table being read as
# this statement is written to the binary log and therefore
# should be serialized with concurrent statements.
+connection default;
Success: 'insert into t2 select i+5 from t1' takes shared row locks on 't1'.
+connection default;
Success: 'insert into t2 values ((select i+5 from t1 where i = 4))' takes shared row locks on 't1'.
#
# 2.7 LOAD DATA with a subquery.
#
# The above is true for this statement as well.
+connection default;
Success: 'load data infile '../../std_data/rpl_loaddata.dat' into table t2 (@a, @b) set j= @b + (select i from t1 where i = 1)' takes shared row locks on 't1'.
#
# 2.8 REPLACE with a subquery.
#
# Same is true for this statement as well.
+connection default;
Success: 'replace into t2 select i+5 from t1' takes shared row locks on 't1'.
+connection default;
Success: 'replace into t2 values ((select i+5 from t1 where i = 4))' takes shared row locks on 't1'.
#
# 2.9 SELECT with a subquery.
@@ -273,6 +292,7 @@ Success: 'replace into t2 values ((select i+5 from t1 where i = 4))' takes share
#
# Also serves as a test case for bug #46947 "Embedded SELECT
# without FOR UPDATE is causing a lock".
+connection default;
Success: 'select * from t2 where j in (select i from t1)' doesn't take row locks on 't1'.
#
# 2.10 SET with a subquery.
@@ -280,6 +300,7 @@ Success: 'select * from t2 where j in (select i from t1)' doesn't take row locks
# In theory should not require locking as it is not written
# to the binary log. In practice InnoDB acquires shared row
# locks.
+connection default;
Success: 'set @a:= (select i from t1 where i = 1)' takes shared row locks on 't1'.
#
# 2.11 SHOW with a subquery.
@@ -287,7 +308,9 @@ Success: 'set @a:= (select i from t1 where i = 1)' takes shared row locks on 't1
# Similarly to the previous case, in theory should not require locking
# as it is not written to the binary log. In practice InnoDB
# acquires shared row locks.
+connection default;
Success: 'show tables from test where Tables_in_test = 't2' and (select i from t1 where i = 1)' takes shared row locks on 't1'.
+connection default;
Success: 'show columns from t2 where (select i from t1 where i = 1)' takes shared row locks on 't1'.
#
# 2.12 UPDATE with a subquery.
@@ -295,11 +318,13 @@ Success: 'show columns from t2 where (select i from t1 where i = 1)' takes share
# Has to take shared locks on rows in the table being read as
# this statement is written to the binary log and therefore
# should be serialized with concurrent statements.
+connection default;
Success: 'update t2 set j= j-10 where j in (select i from t1)' takes shared row locks on 't1'.
#
# 2.13 MULTI-UPDATE with a subquery.
#
# Same is true for this statement as well.
+connection default;
Success: 'update t2, t3 set j= j -10 where j=k and j in (select i from t1)' takes shared row locks on 't1'.
#
# 3. Statements which read tables through a view.
@@ -310,9 +335,13 @@ Success: 'update t2, t3 set j= j -10 where j=k and j in (select i from t1)' take
# Since this statement is not written to the binary log
# and old version of rows are accessible thanks to MVCC,
# no locking is necessary.
+connection default;
Success: 'select * from v1' doesn't take row locks on 't1'.
+connection default;
Success: 'select * from v2' doesn't take row locks on 't1'.
+connection default;
Success: 'select * from t2 where j in (select i from v1)' doesn't take row locks on 't1'.
+connection default;
Success: 'select * from t3 where k in (select j from v2)' doesn't take row locks on 't1'.
#
# 3.2 Statements which modify a table and use views.
@@ -320,9 +349,13 @@ Success: 'select * from t3 where k in (select j from v2)' doesn't take row locks
# Since such statements are going to be written to the binary
# log they need to be serialized against concurrent statements
# and therefore should take shared row locks on data read.
+connection default;
Success: 'update t2 set j= j-10 where j in (select i from v1)' takes shared row locks on 't1'.
+connection default;
Success: 'update t3 set k= k-10 where k in (select j from v2)' takes shared row locks on 't1'.
+connection default;
Success: 'update t2, v1 set j= j-10 where j = i' takes shared row locks on 't1'.
+connection default;
Success: 'update v2 set j= j-10 where j = 3' takes shared row locks on 't1'.
#
# 4. Statements which read tables through stored functions.
@@ -338,7 +371,9 @@ Success: 'update v2 set j= j-10 where j = 3' takes shared row locks on 't1'.
# However in practice innodb takes strong lock on tables
# being selected from within SF, when SF is called from
# non SELECT statements like 'set' statement below.
+connection default;
Success: 'select f1()' doesn't take row locks on 't1'.
+connection default;
Success: 'set @a:= f1()' takes shared row locks on 't1'.
#
# 4.2 INSERT (or other statement which modifies data) with
@@ -349,6 +384,7 @@ Success: 'set @a:= f1()' takes shared row locks on 't1'.
# be serialized with concurrent statements affecting the data
# it uses. Therefore it should take row locks on the data
# it reads.
+connection default;
Success: 'insert into t2 values (f1() + 5)' takes shared row locks on 't1'.
#
# 4.3 SELECT/SET with a stored function which
@@ -358,7 +394,9 @@ Success: 'insert into t2 values (f1() + 5)' takes shared row locks on 't1'.
# it should be serialized with concurrent statements affecting
# the data it uses. Hence, row locks on the data read
# should be taken.
+connection default;
Success: 'select f2()' takes shared row locks on 't1'.
+connection default;
Success: 'set @a:= f2()' takes shared row locks on 't1'.
#
# 4.4. SELECT/SET with a stored function which does not
@@ -371,9 +409,13 @@ Success: 'set @a:= f2()' takes shared row locks on 't1'.
# However in practice innodb takes strong lock on tables
# being selected from within SF, when SF is called from
# non SELECT statements like 'set' statement below.
+connection default;
Success: 'select f3()' doesn't take row locks on 't1'.
+connection default;
Success: 'set @a:= f3()' takes shared row locks on 't1'.
+connection default;
Success: 'select f4()' doesn't take row locks on 't1'.
+connection default;
Success: 'set @a:= f4()' takes shared row locks on 't1'.
#
# 4.5. INSERT (or other statement which modifies data) with
@@ -385,7 +427,9 @@ Success: 'set @a:= f4()' takes shared row locks on 't1'.
# be serialized with concurrent statements affecting data it
# uses. Therefore it should take row locks on the data
# it reads.
+connection default;
Success: 'insert into t2 values (f3() + 5)' takes shared row locks on 't1'.
+connection default;
Success: 'insert into t2 values (f4() + 6)' takes shared row locks on 't1'.
#
# 4.6 SELECT/SET which uses a stored function with
@@ -394,7 +438,9 @@ Success: 'insert into t2 values (f4() + 6)' takes shared row locks on 't1'.
# Since call to such function is written to the binary log
# it should be serialized with concurrent statements.
# Hence reads should take row locks.
+connection default;
Success: 'select f5()' takes shared row locks on 't1'.
+connection default;
Success: 'set @a:= f5()' takes shared row locks on 't1'.
#
# 4.7 SELECT/SET which uses a stored function which
@@ -407,9 +453,13 @@ Success: 'set @a:= f5()' takes shared row locks on 't1'.
# However in practice innodb takes strong lock on tables
# being selected from within SF, when SF is called from
# non SELECT statements like 'set' statement below.
+connection default;
Success: 'select f6()' doesn't take row locks on 't1'.
+connection default;
Success: 'set @a:= f6()' takes shared row locks on 't1'.
+connection default;
Success: 'select f7()' doesn't take row locks on 't1'.
+connection default;
Success: 'set @a:= f7()' takes shared row locks on 't1'.
#
# 4.8 INSERT which uses stored function which
@@ -420,7 +470,9 @@ Success: 'set @a:= f7()' takes shared row locks on 't1'.
# should be serialized with concurrent statements affecting
# the data it uses. Therefore it should take row locks on
# the rows it reads.
+connection default;
Success: 'insert into t3 values (f6() + 5)' takes shared row locks on 't1'.
+connection default;
Success: 'insert into t3 values (f7() + 5)' takes shared row locks on 't1'.
#
# 4.9 SELECT which uses a stored function which
@@ -429,7 +481,9 @@ Success: 'insert into t3 values (f7() + 5)' takes shared row locks on 't1'.
# Since a call to such function is written to the binary log
# it should be serialized with concurrent statements.
# Hence, reads should take row locks.
+connection default;
Success: 'select f8()' takes shared row locks on 't1'.
+connection default;
Success: 'select f9()' takes shared row locks on 't1'.
#
# 4.10 SELECT which uses stored function which doesn't modify
@@ -438,6 +492,7 @@ Success: 'select f9()' takes shared row locks on 't1'.
#
# Calls to such functions won't get into the binary
# log and thus don't need to acquire row locks.
+connection default;
Success: 'select f10()' doesn't take row locks on 't1'.
#
# 4.11 INSERT which uses a stored function which doesn't modify
@@ -447,6 +502,7 @@ Success: 'select f10()' doesn't take row locks on 't1'.
# Since such statement is written to the binary log, it should
# be serialized with concurrent statements affecting the data it
# uses. Therefore it should take row locks on data it reads.
+connection default;
Success: 'insert into t2 values (f10() + 5)' takes shared row locks on 't1'.
#
# 4.12 SELECT which uses a stored function which modifies
@@ -456,6 +512,7 @@ Success: 'insert into t2 values (f10() + 5)' takes shared row locks on 't1'.
# Since a call to such function is written to the binary log
# it should be serialized from concurrent statements.
# Hence, reads should take row locks.
+connection default;
Success: 'select f11()' takes shared row locks on 't1'.
#
# 4.13 SELECT that reads a table through a subquery passed
@@ -466,6 +523,7 @@ Success: 'select f11()' takes shared row locks on 't1'.
# binary log, values of its parameters are written as literals.
# So there is no need to acquire row locks on rows used in
# the subquery.
+connection default;
Success: 'select f12((select i+10 from t1 where i=1))' doesn't take row locks on 't1'.
#
# 4.14 INSERT that reads a table via a subquery passed
@@ -475,6 +533,7 @@ Success: 'select f12((select i+10 from t1 where i=1))' doesn't take row locks on
# Since this statement is written to the binary log it should
# be serialized with concurrent statements affecting the data it
# uses. Therefore it should take row locks on the data it reads.
+connection default;
Success: 'insert into t2 values (f13((select i+10 from t1 where i=1)))' takes shared row locks on 't1'.
#
# 5. Statements that read tables through stored procedures.
@@ -485,6 +544,7 @@ Success: 'insert into t2 values (f13((select i+10 from t1 where i=1)))' takes sh
# Since neither this statement nor its components are
# written to the binary log, there is no need to take
# row locks on the data it reads.
+connection default;
Success: 'call p2(@a)' doesn't take row locks on 't1'.
#
# 5.2 Function that modifies data and uses CALL,
@@ -493,6 +553,7 @@ Success: 'call p2(@a)' doesn't take row locks on 't1'.
# Since a call to such function is written to the binary
# log, it should be serialized with concurrent statements.
# Hence, in this case reads should take row locks on data.
+connection default;
Success: 'select f14()' takes shared row locks on 't1'.
#
# 5.3 SELECT that calls a function that doesn't modify data and
@@ -500,6 +561,7 @@ Success: 'select f14()' takes shared row locks on 't1'.
#
# Calls to such functions won't get into the binary
# log and thus don't need to acquire row locks.
+connection default;
Success: 'select f15()' doesn't take row locks on 't1'.
#
# 5.4 INSERT which calls function which doesn't modify data and
@@ -508,6 +570,7 @@ Success: 'select f15()' doesn't take row locks on 't1'.
# Since such statement is written to the binary log it should
# be serialized with concurrent statements affecting data it
# uses. Therefore it should take row locks on data it reads.
+connection default;
Success: 'insert into t2 values (f15()+5)' takes shared row locks on 't1'.
#
# 6. Statements that use triggers.
@@ -519,30 +582,35 @@ Success: 'insert into t2 values (f15()+5)' takes shared row locks on 't1'.
# be serialized with concurrent statements affecting the data
# it uses. Therefore, it should take row locks on the data
# it reads.
+connection default;
Success: 'insert into t4 values (2)' takes shared row locks on 't1'.
#
# 6.2 Statement invoking a trigger that reads table through
# a subquery in a control construct.
#
# The above is true for this statement as well.
+connection default;
Success: 'update t4 set l= 2 where l = 1' takes shared row locks on 't1'.
#
# 6.3 Statement invoking a trigger that reads a table through
# a view.
#
# And for this statement.
+connection default;
Success: 'delete from t4 where l = 1' takes shared row locks on 't1'.
#
# 6.4 Statement invoking a trigger that reads a table through
# a stored function.
#
# And for this statement.
+connection default;
Success: 'insert into t5 values (2)' takes shared row locks on 't1'.
#
# 6.5 Statement invoking a trigger that reads a table through
# stored procedure.
#
# And for this statement.
+connection default;
Success: 'update t5 set l= 2 where l = 1' takes shared row locks on 't1'.
# Clean-up.
drop function f1;
@@ -564,10 +632,13 @@ drop view v1, v2;
drop procedure p1;
drop procedure p2;
drop table t1, t2, t3, t4, t5;
+disconnect con1;
#
# Test for bug#51263 "Deadlock between transactional SELECT
# and ALTER TABLE ... REBUILD PARTITION".
#
+connect con1,localhost,root,,test,,;
+connection default;
drop table if exists t1, t2;
create table t1 (i int auto_increment not null primary key) engine=innodb;
create table t2 (i int) engine=innodb;
@@ -575,10 +646,10 @@ insert into t1 values (1), (2), (3), (4), (5);
begin;
# Acquire SR metadata lock on t1 and LOCK_S row-locks on its rows.
insert into t2 select count(*) from t1;
-# Switching to connection 'con1'.
+connection con1;
# Sending:
alter table t1 add column j int;
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER is blocked because it tries to upgrade SNW
# metadata lock to X lock.
# It should not be blocked during copying data to new version of
@@ -593,9 +664,9 @@ insert into t1 values (6);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Unblock ALTER TABLE.
commit;
-# Switching to connection 'con1'.
+connection con1;
# Reaping ALTER TABLE.
-# Switching to connection 'default'.
+connection default;
#
# Now test for scenario in which bug was reported originally.
#
@@ -613,10 +684,10 @@ i
3
4
5
-# Switching to connection 'con1'.
+connection con1;
# Sending:
alter table t1 rebuild partition p0;
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER is blocked because of active SR lock.
# The below statement should succeed as transaction
# has SR metadata lock on t1 and only going to read
@@ -624,8 +695,9 @@ alter table t1 rebuild partition p0;
insert into t2 select count(*) from t1;
# Unblock ALTER TABLE.
commit;
-# Switching to connection 'con1'.
+connection con1;
# Reaping ALTER TABLE.
-# Switching to connection 'default'.
+connection default;
+disconnect con1;
# Clean-up.
drop tables t1, t2;
diff --git a/mysql-test/r/innodb_mysql_sync.result b/mysql-test/r/innodb_mysql_sync.result
index 478b0109816..0b9a17adf4d 100644
--- a/mysql-test/r/innodb_mysql_sync.result
+++ b/mysql-test/r/innodb_mysql_sync.result
@@ -5,23 +5,25 @@
DROP TABLE IF EXISTS t1;
# Create InnoDB table
CREATE TABLE t1 (id INT) engine=innodb;
-# Connection 1
+connect con2, localhost, root;
# Start optimizing table
+connection default;
SET DEBUG_SYNC='ha_admin_try_alter SIGNAL optimize_started WAIT_FOR table_altered';
OPTIMIZE TABLE t1;
-# Connection 2
# Change table to engine=memory
+connection con2;
SET DEBUG_SYNC='now WAIT_FOR optimize_started';
ALTER TABLE t1 engine=memory;
SET DEBUG_SYNC='now SIGNAL table_altered';
-# Connection 1
# Complete optimization
+connection default;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize error Got error -1 "Internal error < 0 (Not system error)" from storage engine MEMORY
test.t1 optimize status Operation failed
Warnings:
Error 1030 Got error -1 "Internal error < 0 (Not system error)" from storage engine MEMORY
+disconnect con2;
DROP TABLE t1;
SET DEBUG_SYNC='RESET';
#
@@ -29,16 +31,18 @@ SET DEBUG_SYNC='RESET';
# OPTIMIZE TABLE
#
DROP TABLE IF EXISTS t1;
+connect con1, localhost, root;
+connection default;
CREATE TABLE t1(a INT) ENGINE= InnoDB;
-# Connection con1
+connection con1;
SET DEBUG_SYNC= "ha_admin_open_ltable SIGNAL opening WAIT_FOR dropped";
# Sending:
OPTIMIZE TABLE t1;
-# Connection default
+connection default;
SET DEBUG_SYNC= "now WAIT_FOR opening";
DROP TABLE t1;
SET DEBUG_SYNC= "now SIGNAL dropped";
-# Connection con1
+connection con1;
# Reaping: OPTIMIZE TABLE t1
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
@@ -46,7 +50,8 @@ test.t1 optimize error Table 'test.t1' doesn't exist
test.t1 optimize status Operation failed
Warnings:
Error 1146 Table 'test.t1' doesn't exist
-# Connection default
+connection default;
+disconnect con1;
SET DEBUG_SYNC= "RESET";
#
# Bug#53757 assert in mysql_truncate_by_delete
@@ -55,10 +60,12 @@ DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1(a INT) Engine=InnoDB;
CREATE TABLE t2(id INT);
INSERT INTO t1 VALUES (1), (2);
+connect con1, localhost, root;
INSERT INTO t2 VALUES(connection_id());
SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed";
# Sending: (not reaped since connection is killed later)
TRUNCATE t1;
+connection default;
SET DEBUG_SYNC= "now WAIT_FOR opening";
SELECT ((@id := id) - id) FROM t2;
((@id := id) - id)
@@ -66,6 +73,7 @@ SELECT ((@id := id) - id) FROM t2;
KILL @id;
SET DEBUG_SYNC= "now SIGNAL killed";
DROP TABLE t1, t2;
+disconnect con1;
SET DEBUG_SYNC= "RESET";
#
# Bug#58933 Assertion `thd- >is_error()' fails on shutdown with ongoing
@@ -74,15 +82,15 @@ SET DEBUG_SYNC= "RESET";
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1), (2);
-# Connection con1
+connect con1,localhost,root;
SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL waiting WAIT_FOR killed';
# Sending:
OPTIMIZE TABLE t1;
-# Connection default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR waiting';
KILL QUERY ID;
SET DEBUG_SYNC= 'now SIGNAL killed';
-# Connection con1
+connection con1;
# Reaping: OPTIMIZE TABLE t1
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
@@ -90,24 +98,27 @@ test.t1 optimize error Query execution was interrupted
test.t1 optimize status Operation failed
Warnings:
Error 1317 Query execution was interrupted
-# Connection default
+connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
+disconnect con1;
#
# Bug#42230 during add index, cannot do queries on storage engines
# that implement add_index
#
DROP DATABASE IF EXISTS db1;
DROP TABLE IF EXISTS t1;
+connect con1,localhost,root;
+connect con2,localhost,root;
# Test 1: Secondary index, should not block reads (original test case).
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE TABLE db1.t1(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value INT) engine=innodb;
INSERT INTO db1.t1(value) VALUES (1), (2);
SET DEBUG_SYNC= "alter_table_inplace_after_lock_downgrade SIGNAL manage WAIT_FOR query";
# Sending:
ALTER TABLE db1.t1 ADD INDEX(value);
-# Connection con1
+connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
USE db1;
SELECT * FROM t1;
@@ -115,7 +126,7 @@ id value
1 1
2 2
SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
+connection default;
# Reaping: ALTER TABLE db1.t1 ADD INDEX(value)
DROP DATABASE db1;
# Test 2: Primary index (implicit), should block writes.
@@ -123,51 +134,53 @@ CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
SET DEBUG_SYNC= "alter_table_inplace_after_lock_downgrade SIGNAL manage WAIT_FOR query";
# Sending:
ALTER TABLE t1 ADD UNIQUE INDEX(a), LOCK=SHARED;
-# Connection con1
+connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
USE test;
SELECT * FROM t1;
a b
# Sending:
UPDATE t1 SET a=NULL;
-# Connection con2
+connection con2;
# Waiting for SELECT to be blocked by the metadata lock on t1
SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
+connection default;
# Reaping: ALTER TABLE t1 ADD UNIQUE INDEX(a)
-# Connection con1
+connection con1;
# Reaping: UPDATE t1 SET a=NULL
# Test 3: Primary index (explicit), should block writes.
-# Connection default
+connection default;
ALTER TABLE t1 DROP INDEX a;
SET DEBUG_SYNC= "alter_table_inplace_after_lock_downgrade SIGNAL manage WAIT_FOR query";
# Sending:
ALTER TABLE t1 ADD PRIMARY KEY (a), LOCK=SHARED;
-# Connection con1
+connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
SELECT * FROM t1;
a b
# Sending:
UPDATE t1 SET a=NULL;
-# Connection con2
+connection con2;
# Waiting for SELECT to be blocked by the metadata lock on t1
SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
+connection default;
# Reaping: ALTER TABLE t1 ADD PRIMARY KEY (a)
-# Connection con1
+connection con1;
# Reaping: UPDATE t1 SET a=NULL
# Test 4: Secondary unique index, should not block reads.
-# Connection default
+connection default;
SET DEBUG_SYNC= "alter_table_inplace_after_lock_downgrade SIGNAL manage WAIT_FOR query";
# Sending:
ALTER TABLE t1 ADD UNIQUE (b);
-# Connection con1
+connection con1;
SET DEBUG_SYNC= "now WAIT_FOR manage";
SELECT * FROM t1;
a b
SET DEBUG_SYNC= "now SIGNAL query";
-# Connection default
+connection default;
# Reaping: ALTER TABLE t1 ADD UNIQUE (b)
+disconnect con1;
+disconnect con2;
SET DEBUG_SYNC= "RESET";
DROP TABLE t1;
#
@@ -177,7 +190,7 @@ DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT NOT NULL, b INT NOT NULL) engine=innodb;
INSERT INTO t1 VALUES (1, 12345), (2, 23456);
-# Connection con1
+connect con1,localhost,root;
SET SESSION debug_dbug= "+d,alter_table_rollback_new_index";
ALTER TABLE t1 ADD PRIMARY KEY(a);
ERROR HY000: Unknown error
@@ -185,12 +198,13 @@ SELECT * FROM t1;
a b
1 12345
2 23456
-# Connection default
+connection default;
SELECT * FROM t1;
a b
1 12345
2 23456
DROP TABLE t1;
+disconnect con1;
#
# Bug#13417754 ASSERT IN ROW_DROP_DATABASE_FOR_MYSQL DURING DROP SCHEMA
#
@@ -198,25 +212,29 @@ DROP TABLE IF EXISTS t1;
DROP DATABASE IF EXISTS db1;
CREATE TABLE t1(a int) engine=InnoDB;
CREATE DATABASE db1;
-# Connection con1
+connect con1, localhost, root;
+connect con2, localhost, root;
+connection con1;
SET DEBUG_SYNC= 'after_innobase_rename_table SIGNAL locked WAIT_FOR continue';
# Sending:
ALTER TABLE t1 RENAME db1.t1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# DROP DATABASE db1 should now be blocked by ALTER TABLE
# Sending:
DROP DATABASE db1;
-# Connection default
+connection default;
# Check that DROP DATABASE is blocked by IX lock on db1
# Resume ALTER TABLE
SET DEBUG_SYNC= 'now SIGNAL continue';
-# Connection con1
+connection con1;
# Reaping: ALTER TABLE t1 RENAME db1.t1;
-# Connection con2
+connection con2;
# Reaping: DROP DATABASE db1
-# Connection default;
+connection default;
SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+disconnect con2;
#
# WL#5534 Online ALTER, Phase 1
#
@@ -226,18 +244,19 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT PRIMARY KEY, b INT) engine=InnoDB;
INSERT INTO t1 VALUES (1,1), (2,2);
SET DEBUG_SYNC= 'RESET';
+connect con1, localhost, root;
SET SESSION lock_wait_timeout= 1;
#
# 1: In-place + writes blocked.
#
-# Connection default
+connection default;
SET DEBUG_SYNC= 'alter_opened_table SIGNAL opened WAIT_FOR continue1';
SET DEBUG_SYNC= 'alter_table_inplace_after_lock_upgrade SIGNAL upgraded WAIT_FOR continue2';
SET DEBUG_SYNC= 'alter_table_inplace_before_commit SIGNAL beforecommit WAIT_FOR continue3';
SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL binlog WAIT_FOR continue4';
# Sending:
ALTER TABLE t1 ADD INDEX i1(b), ALGORITHM= INPLACE, LOCK= SHARED;
-# Connection con1;
+connection con1;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
# At this point, neither reads nor writes should be blocked.
SELECT * FROM t1;
@@ -267,7 +286,7 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction
INSERT INTO t1 VALUES (6,6);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC= 'now SIGNAL continue4';
-# Connection default
+connection default;
# Reaping ALTER TABLE ...
SET DEBUG_SYNC= 'RESET';
DELETE FROM t1 WHERE a= 3;
@@ -279,7 +298,7 @@ SET DEBUG_SYNC= 'alter_table_copy_after_lock_upgrade SIGNAL upgraded WAIT_FOR co
SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL binlog WAIT_FOR continue3';
# Sending:
ALTER TABLE t1 ADD INDEX i2(b), ALGORITHM= COPY, LOCK= SHARED;
-# Connection con1;
+connection con1;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
# At this point, neither reads nor writes should be blocked.
SELECT * FROM t1;
@@ -305,7 +324,7 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction
INSERT INTO t1 VALUES (5,5);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC= 'now SIGNAL continue3';
-# Connection default
+connection default;
# Reaping ALTER TABLE ...
Warnings:
Note 1831 Duplicate index 'i2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
@@ -318,14 +337,14 @@ DELETE FROM t1 WHERE a= 3;
#
# 4: In-place + reads and writes blocked.
#
-# Connection default
+connection default;
SET DEBUG_SYNC= 'alter_opened_table SIGNAL opened WAIT_FOR continue1';
SET DEBUG_SYNC= 'alter_table_inplace_after_lock_upgrade SIGNAL upgraded WAIT_FOR continue2';
SET DEBUG_SYNC= 'alter_table_inplace_before_commit SIGNAL beforecommit WAIT_FOR continue3';
SET DEBUG_SYNC= 'alter_table_before_main_binlog SIGNAL binlog WAIT_FOR continue4';
# Sending:
ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= INPLACE, LOCK= EXCLUSIVE;
-# Connection con1;
+connection con1;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
# At this point, neither reads nor writes should be blocked.
SELECT * FROM t1;
@@ -355,17 +374,20 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction
INSERT INTO t1 VALUES (6,6);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC= 'now SIGNAL continue4';
-# Connection default
+connection default;
# Reaping ALTER TABLE ...
Warnings:
Note 1831 Duplicate index 'i4' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
SET DEBUG_SYNC= 'RESET';
+connection default;
+disconnect con1;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
#
#BUG#13975225:ONLINE OPTIMIZE TABLE FOR INNODB TABLES
#
SET DEBUG_SYNC= 'alter_table_inplace_after_lock_downgrade SIGNAL downgraded WAIT_FOR continue';
+connect con1,localhost,root,,;
#Setting up INNODB table.
CREATE TABLE t1(fld1 INT, fld2 INT, fld3 INT) ENGINE= INNODB;
INSERT INTO t1 VALUES (155, 45, 55);
@@ -542,5 +564,6 @@ ALTER TABLE t1 FORCE;
connection con1;
SET DEBUG_SYNC= 'now WAIT_FOR rebuild';
connection default;
+disconnect con1;
SET DEBUG_SYNC= 'RESET';
DROP TABLE t1;
diff --git a/mysql-test/r/insert_notembedded.result b/mysql-test/r/insert_notembedded.result
index 41e31508fe0..d7ec70d36f8 100644
--- a/mysql-test/r/insert_notembedded.result
+++ b/mysql-test/r/insert_notembedded.result
@@ -8,6 +8,8 @@ ERROR HY000: 'test.v1' is not BASE TABLE
drop table t1;
drop view v1;
CREATE DATABASE meow;
+connect root,localhost,root,,meow;
+connection root;
CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
CREATE TABLE table_target3 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
@@ -27,6 +29,8 @@ GRANT SELECT ON view_stations TO user20989@localhost;
GRANT SELECT ON table_target TO user20989@localhost;
GRANT SELECT ON table_target2 TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON view_target3 TO user20989@localhost;
+connect user20989,localhost,user20989,,meow;
+connection user20989;
REPLACE INTO table_target
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
@@ -51,9 +55,13 @@ ON table_source.id = stations.icao
LEFT JOIN view_target3 AS old
USING (mexs_id);
ERROR HY000: View 'meow.view_target3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+connection root;
+disconnect user20989;
GRANT INSERT,DELETE ON table_target TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON view_target2 TO user20989@localhost;
GRANT INSERT,DELETE,SELECT ON table_target3 TO user20989@localhost;
+connect user20989,localhost,user20989,,meow;
+connection user20989;
REPLACE INTO table_target
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
FROM table_source
@@ -86,6 +94,8 @@ INNER JOIN view_stations AS stations
ON table_source.id = stations.icao
LEFT JOIN view_target3 AS old
USING (mexs_id);
+connection root;
+disconnect user20989;
SELECT * FROM table_target;
mexs_id messzeit
87654321 2006-07-12 07:50:00
@@ -106,24 +116,34 @@ DROP TABLE table_target3;
DROP VIEW view_target2;
DROP VIEW view_target3;
DROP USER user20989@localhost;
+disconnect root;
+connection default;
DROP DATABASE meow;
connection: default
set low_priority_updates=1;
drop table if exists t1;
create table t1 (a int, b int, unique key t1$a (a));
lock table t1 read;
+connect update,localhost,root,,;
+connection update;
connection: update
set low_priority_updates=1;
show variables like 'low_priority_updates';
Variable_name Value
low_priority_updates ON
insert into t1 values (1, 2) ON DUPLICATE KEY UPDATE b = 2;;
+connection default;
+connect select,localhost,root,,;
connection: select
select * from t1;
a b
+connection default;
connection: default
select * from t1;
a b
+connection default;
+disconnect update;
+disconnect select;
unlock tables;
drop table t1;
set low_priority_updates=default;
diff --git a/mysql-test/r/ipv4_and_ipv6.result b/mysql-test/r/ipv4_and_ipv6.result
index f15aeba65fa..447c20536e2 100644
--- a/mysql-test/r/ipv4_and_ipv6.result
+++ b/mysql-test/r/ipv4_and_ipv6.result
@@ -20,6 +20,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'::1';
RENAME USER testuser@'::1' to testuser1@'::1';
SET PASSWORD FOR testuser1@'::1' = PASSWORD ('9876');
@@ -49,6 +52,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'127.0.0.1';
RENAME USER testuser@'127.0.0.1' to testuser1@'127.0.0.1';
SET PASSWORD FOR testuser1@'127.0.0.1' = PASSWORD ('9876');
diff --git a/mysql-test/r/ipv4_as_ipv6.result b/mysql-test/r/ipv4_as_ipv6.result
index 82bca393d71..b92b545da86 100644
--- a/mysql-test/r/ipv4_as_ipv6.result
+++ b/mysql-test/r/ipv4_as_ipv6.result
@@ -20,6 +20,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'127.0.0.1';
RENAME USER testuser@'127.0.0.1' to testuser1@'127.0.0.1';
SET PASSWORD FOR testuser1@'127.0.0.1' = PASSWORD ('9876');
@@ -49,6 +52,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'0:0:0:0:0:FFFF:127.0.0.1';
RENAME USER testuser@'0:0:0:0:0:FFFF:127.0.0.1' to testuser1@'0:0:0:0:0:FFFF:127.0.0.1';
SET PASSWORD FOR testuser1@'0:0:0:0:0:FFFF:127.0.0.1' = PASSWORD ('9876');
@@ -78,6 +84,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
RENAME USER testuser@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' to testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1';
SET PASSWORD FOR testuser1@'0000:0000:0000:0000:0000:FFFF:127.0.0.1' = PASSWORD ('9876');
@@ -107,6 +116,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1';
RENAME USER testuser@'0:0000:0000:0:0000:FFFF:127.0.0.1' to testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1';
SET PASSWORD FOR testuser1@'0:0000:0000:0:0000:FFFF:127.0.0.1' = PASSWORD ('9876');
@@ -136,6 +148,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'0::0000:FFFF:127.0.0.1';
RENAME USER testuser@'0::0000:FFFF:127.0.0.1' to testuser1@'0::0000:FFFF:127.0.0.1';
SET PASSWORD FOR testuser1@'0::0000:FFFF:127.0.0.1' = PASSWORD ('9876');
@@ -166,6 +181,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'::FFFF:127.0.0.1';
RENAME USER testuser@'::FFFF:127.0.0.1' to testuser1@'::FFFF:127.0.0.1';
SET PASSWORD FOR testuser1@'::FFFF:127.0.0.1' = PASSWORD ('9876');
diff --git a/mysql-test/r/ipv6.result b/mysql-test/r/ipv6.result
index 1ff51fcc831..1540b4825e5 100644
--- a/mysql-test/r/ipv6.result
+++ b/mysql-test/r/ipv6.result
@@ -20,6 +20,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'::1';
RENAME USER testuser@'::1' to testuser1@'::1';
SET PASSWORD FOR testuser1@'::1' = PASSWORD ('9876');
@@ -50,6 +53,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'0000:0000:0000:0000:0000:0000:0000:0001';
RENAME USER testuser@'0000:0000:0000:0000:0000:0000:0000:0001' to testuser1@'0000:0000:0000:0000:0000:0000:0000:0001';
SET PASSWORD FOR testuser1@'0000:0000:0000:0000:0000:0000:0000:0001' = PASSWORD ('9876');
@@ -79,6 +85,9 @@ SELECT current_user();
current_user()
root@localhost
SHOW PROCESSLIST;
+connect con1, $IPv6, root, , test, $MASTER_MYPORT;
+connection default;
+disconnect con1;
REVOKE ALL ON test.* FROM testuser@'0:0:0:0:0:0:0:1';
RENAME USER testuser@'0:0:0:0:0:0:0:1' to testuser1@'0:0:0:0:0:0:0:1';
SET PASSWORD FOR testuser1@'0:0:0:0:0:0:0:1' = PASSWORD ('9876');
diff --git a/mysql-test/r/kill-2.result b/mysql-test/r/kill-2.result
index c2bcc979441..daaba2c092a 100644
--- a/mysql-test/r/kill-2.result
+++ b/mysql-test/r/kill-2.result
@@ -2,6 +2,8 @@
# MDEV-6896 kill user command cause MariaDB crash!
#
create user foo@'127.0.0.1';
+connect con1,127.0.0.1,foo,,;
+connection default;
select user from information_schema.processlist;
user
foo
diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result
index d40c4ee758c..0f01bf3f714 100644
--- a/mysql-test/r/kill.result
+++ b/mysql-test/r/kill.result
@@ -9,11 +9,18 @@ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
KILL tid;
RETURN (SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE ID = tid);
END|
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
+connection con2;
+connection con1;
SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read';
+connection con2;
SET DEBUG_SYNC='now WAIT_FOR con1_read';
SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
SET DEBUG_SYNC = 'RESET';
+connection con1;
SELECT 1;
Got one of the listed errors
SELECT 1;
@@ -22,16 +29,23 @@ SELECT 1;
SELECT @id != CONNECTION_ID();
@id != CONNECTION_ID()
1
+connection con2;
SELECT 4;
4
4
+connection default;
KILL (SELECT COUNT(*) FROM mysql.user);
ERROR 42000: KILL does not support subqueries or stored functions.
+connection con1;
+connection con2;
+connection con1;
SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
SET DEBUG_SYNC= 'before_do_command_net_read SIGNAL con1_read WAIT_FOR kill';
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR con1_read';
SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
SET DEBUG_SYNC = 'RESET';
+connection con1;
SELECT 1;
Got one of the listed errors
SELECT 1;
@@ -40,9 +54,11 @@ SELECT 1;
SELECT @id != CONNECTION_ID();
@id != CONNECTION_ID()
1
+connection con2;
SELECT 4;
4
4
+connection default;
CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT);
CREATE TABLE t2 (id INT UNSIGNED NOT NULL);
INSERT INTO t1 VALUES
@@ -52,25 +68,36 @@ INSERT INTO t1 VALUES
(0),(0),(0),(0),(0),(0),(0),(0), (0),(0),(0),(0),(0),(0),(0),(0);
INSERT t1 SELECT 0 FROM t1 AS a1, t1 AS a2 LIMIT 4032;
INSERT INTO t2 SELECT id FROM t1;
+connection con1;
+connection con2;
+connection con1;
SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync';
SELECT id FROM t1 WHERE id IN
(SELECT DISTINCT a.id FROM t2 a, t2 b, t2 c, t2 d
GROUP BY ACOS(1/a.id), b.id, c.id, d.id
HAVING a.id BETWEEN 10 AND 20);
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL @id;
SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
+connection con1;
Got one of the listed errors
SELECT 1;
1
1
+connection default;
SET DEBUG_SYNC = 'RESET';
DROP TABLE t1, t2;
+connection con1;
+connection con2;
+connection con1;
SET DEBUG_SYNC= 'before_acos_function SIGNAL in_sync WAIT_FOR kill';
SELECT ACOS(0);
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL QUERY @id;
+connection con1;
ACOS(0)
1.5707963267948966
SELECT 1;
@@ -79,6 +106,7 @@ SELECT 1;
SELECT @id = CONNECTION_ID();
@id = CONNECTION_ID()
1
+connection default;
SET DEBUG_SYNC = 'RESET';
CREATE TABLE t1 (f1 INT);
CREATE FUNCTION bug27563() RETURNS INT(11)
@@ -89,40 +117,58 @@ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @a:= 'exception';
SET DEBUG_SYNC= 'now SIGNAL in_sync WAIT_FOR kill';
RETURN 1;
END|
+connection con1;
+connection con2;
+connection con1;
INSERT INTO t1 VALUES (bug27563());
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL QUERY @id;
+connection con1;
ERROR 70100: Query execution was interrupted
SELECT * FROM t1;
f1
+connection default;
SET DEBUG_SYNC = 'RESET';
INSERT INTO t1 VALUES(0);
+connection con1;
UPDATE t1 SET f1= bug27563();
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL QUERY @id;
+connection con1;
ERROR 70100: Query execution was interrupted
SELECT * FROM t1;
f1
0
+connection default;
SET DEBUG_SYNC = 'RESET';
INSERT INTO t1 VALUES(1);
+connection con1;
DELETE FROM t1 WHERE bug27563() IS NULL;
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL QUERY @id;
+connection con1;
ERROR 70100: Query execution was interrupted
SELECT * FROM t1;
f1
0
1
+connection default;
SET DEBUG_SYNC = 'RESET';
+connection con1;
SELECT * FROM t1 WHERE f1= bug27563();
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL QUERY @id;
+connection con1;
ERROR 70100: Query execution was interrupted
SELECT * FROM t1;
f1
0
1
+connection default;
SET DEBUG_SYNC = 'RESET';
DROP FUNCTION bug27563;
CREATE TABLE t2 (f2 INT);
@@ -134,9 +180,12 @@ INSERT INTO t2 VALUES(0);
SET DEBUG_SYNC= 'now SIGNAL in_sync WAIT_FOR kill';
INSERT INTO t2 VALUES(1);
END|
+connection con1;
INSERT INTO t1 VALUES(2),(3);
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL QUERY @id;
+connection con1;
ERROR 70100: Query execution was interrupted
SELECT * FROM t1;
f1
@@ -145,26 +194,34 @@ f1
SELECT * FROM t2;
f2
0
+connection default;
SET DEBUG_SYNC = 'RESET';
DROP TABLE t1, t2;
+connection con1;
+connection con2;
+connection con1;
SET SESSION optimizer_search_depth=0;
SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync';
PREPARE stmt FROM 'EXPLAIN SELECT * FROM t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40 WHERE a1=a2 AND a2=a3 AND a3=a4 AND a4=a5 AND a5=a6 AND a6=a7 AND a7=a8 AND a8=a9 AND a9=a10 AND a10=a11 AND a11=a12 AND a12=a13 AND a13=a14 AND a14=a15 AND a15=a16 AND a16=a17 AND a17=a18 AND a18=a19 AND a19=a20 AND a20=a21 AND a21=a22 AND a22=a23 AND a23=a24 AND a24=a25 AND a25=a26 AND a26=a27 AND a27=a28 AND a28=a29 AND a29=a30 AND a30=a31 AND a31=a32 AND a32=a33 AND a33=a34 AND a34=a35 AND a35=a36 AND a36=a37 AND a37=a38 AND a38=a39 AND a39=a40 ';
EXECUTE stmt;
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
KILL QUERY @id;
+connection con1;
ERROR 70100: Query execution was interrupted
+connection default;
SET DEBUG_SYNC = 'RESET';
#
# Bug#19723: kill of active connection yields different error code
# depending on platform.
#
-
-# Connection: con1.
+connection con1;
SET DEBUG_SYNC= 'thread_end SIGNAL con1_end';
KILL @id;
ERROR 70100: Connection was killed
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR con1_end';
+connection con1;
# ER_SERVER_SHUTDOWN, CR_SERVER_GONE_ERROR, CR_SERVER_LOST,
# depending on the timing of close of the connection socket
SELECT 1;
@@ -175,6 +232,7 @@ SELECT 1;
SELECT @id != CONNECTION_ID();
@id != CONNECTION_ID()
1
+connection default;
SET DEBUG_SYNC = 'RESET';
#
# Additional test for WL#3726 "DDL locking for all metadata objects"
@@ -185,96 +243,99 @@ SET DEBUG_SYNC = 'RESET';
#
drop tables if exists t1, t2, t3;
create table t1 (i int primary key);
+connect blocker, localhost, root, , ;
+connect dml, localhost, root, , ;
+connect ddl, localhost, root, , ;
# Test for RENAME TABLE
-# Switching to connection 'blocker'
+connection blocker;
lock table t1 read;
-# Switching to connection 'ddl'
+connection ddl;
rename table t1 to t2;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
# Test for DROP TABLE
drop table t1;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
# Test for CREATE TRIGGER
create trigger t1_bi before insert on t1 for each row set @a:=1;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
#
# Tests for various kinds of ALTER TABLE
#
# Full-blown ALTER which should copy table
alter table t1 add column j int;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
# Two kinds of simple ALTER
alter table t1 rename to t2;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
alter table t1 disable keys;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
# Fast ALTER
alter table t1 alter column i set default 100;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
# Special case which is triggered only for MERGE tables.
-# Switching to connection 'blocker'
+connection blocker;
unlock tables;
create table t2 (i int primary key) engine=merge union=(t1);
lock tables t2 read;
-# Switching to connection 'ddl'
+connection ddl;
alter table t2 alter column i set default 100;
-# Switching to connection 'default'
+connection default;
kill query ID;
-# Switching to connection 'ddl'
+connection ddl;
ERROR 70100: Query execution was interrupted
# Test for DML waiting for meta-data lock
-# Switching to connection 'blocker'
+connection blocker;
unlock tables;
lock tables t1 read;
-# Switching to connection 'ddl'
+connection ddl;
truncate table t1;
-# Switching to connection 'dml'
+connection dml;
insert into t1 values (1);
-# Switching to connection 'default'
+connection default;
kill query ID2;
-# Switching to connection 'dml'
+connection dml;
ERROR 70100: Query execution was interrupted
-# Switching to connection 'blocker'
+connection blocker;
unlock tables;
-# Switching to connection 'ddl'
+connection ddl;
# Test for DML waiting for tables to be flushed
-# Switching to connection 'blocker'
+connection blocker;
lock tables t1 read;
-# Switching to connection 'ddl'
+connection ddl;
# Let us mark locked table t1 as old
flush tables;
-# Switching to connection 'dml'
+connection dml;
select * from t1;
-# Switching to connection 'default'
+connection default;
kill query ID2;
-# Switching to connection 'dml'
+connection dml;
ERROR 70100: Query execution was interrupted
-# Switching to connection 'blocker'
+connection blocker;
unlock tables;
-# Switching to connection 'ddl'
+connection ddl;
# Cleanup.
-# Switching to connection 'default'
+connection default;
drop table t1;
drop table t2;
#
@@ -282,6 +343,9 @@ drop table t2;
#
grant ALL on test.* to test@localhost;
grant ALL on test.* to test2@localhost;
+connect con3, localhost, test,,;
+connect con4, localhost, test2,,;
+connection default;
kill hard query user test2@nohost;
affected rows: 0
kill soft query user test@localhost;
@@ -296,16 +360,21 @@ revoke all privileges on test.* from test@localhost;
revoke all privileges on test.* from test2@localhost;
drop user test@localhost;
drop user test2@localhost;
+connection con3;
select 1;
Got one of the listed errors
+connection con4;
select 1;
Got one of the listed errors
+connection default;
#
# MDEV-4911 - add KILL query id, and add query id information to
# processlist
#
SELECT SLEEP(1000);
+connection con1;
KILL QUERY ID @id;
+connection default;
SLEEP(1000)
1
KILL QUERY ID 0;
@@ -316,11 +385,16 @@ ERROR HY000: Unknown query id: 0
#
CREATE USER u1@localhost;
SELECT SLEEP(1000);
+connection con1;
+connect con5, localhost, u1,,;
KILL QUERY ID ID;
ERROR HY000: You are not owner of query ID
+connection con1;
KILL QUERY ID @id;
+connection default;
SLEEP(1000)
1
+disconnect con5;
DROP USER u1@localhost;
SET DEBUG_SYNC = 'RESET';
DROP FUNCTION MY_KILL;
diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result
index 8cd3b0a7ac8..16572dd95c5 100644
--- a/mysql-test/r/loaddata.result
+++ b/mysql-test/r/loaddata.result
@@ -524,9 +524,15 @@ DROP TABLE t1;
# Bug #52512 : Assertion `! is_set()' in
# Diagnostics_area::set_ok_status on LOAD DATA
#
+connect con1,localhost,root,,test;
CREATE TABLE t1 (id INT NOT NULL);
LOAD DATA LOCAL INFILE 'tb.txt' INTO TABLE t1;
+connection default;
+disconnect con1;
+connect con1,localhost,root,,test;
DROP TABLE t1;
+connection default;
+disconnect con1;
#
# Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
#
diff --git a/mysql-test/r/loadxml.result b/mysql-test/r/loadxml.result
index 1128caf9122..c3b4c867c98 100644
--- a/mysql-test/r/loadxml.result
+++ b/mysql-test/r/loadxml.result
@@ -57,8 +57,11 @@ a b
select 1 as xml;
xml
1
+connect addconroot, localhost, root,,;
+connection addconroot;
create table t2(fl text);
LOAD XML LOCAL INFILE "MYSQLTEST_VARDIR/tmp/loadxml-dump.xml" INTO TABLE t2 ROWS IDENTIFIED BY '<person>';;
+connection default;
drop table t1;
drop table t2;
create table t1 (
diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result
index 501c379b257..381667745d8 100644
--- a/mysql-test/r/lock.result
+++ b/mysql-test/r/lock.result
@@ -272,20 +272,24 @@ drop view v1;
#
drop table if exists t1;
create table t1 (a int);
+connect con1,localhost,root,,;
set autocommit= 0;
insert into t1 values (1);
lock table t1 write;
-# Disconnect
# Ensure that metadata locks will be released if there is an open
# transaction (autocommit=off) in conjunction with lock tables.
+disconnect con1;
+connection default;
drop table t1;
# Same problem but now for BEGIN
drop table if exists t1;
create table t1 (a int);
+connect con1,localhost,root,,;
begin;
insert into t1 values (1);
-# Disconnect
# Ensure that metadata locks held by the transaction are released.
+disconnect con1;
+connection default;
drop table t1;
#
# Coverage for situations when we try to execute DDL on tables
@@ -451,32 +455,42 @@ DROP TABLE t1;
# Bug#43685 Lock table affects other non-related tables
#
DROP TABLE IF EXISTS t1, t2;
+connect con2, localhost, root;
CREATE TABLE t1 (id INT);
CREATE TABLE t2 (id INT);
-# Connection default
+connection default;
LOCK TABLE t1 WRITE;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
-# Connection con2
+connection con2;
LOCK TABLE t2 WRITE;
# This used to hang until the first connection
# unlocked t1.
FLUSH TABLE t2;
UNLOCK TABLES;
-# Connection default
+connection default;
UNLOCK TABLES;
DROP TABLE t1, t2;
+disconnect con2;
#
# End of 6.0 tests.
#
create table t1 (a int) engine=myisam;
lock tables t1 write concurrent, t1 as t2 read;
+connect con1,localhost,root,,;
+connection con1;
lock tables t1 read local;
unlock tables;
+connection default;
unlock tables;
+connection con1;
lock tables t1 read local;
+connection default;
lock tables t1 write concurrent, t1 as t2 read;
unlock tables;
+connection con1;
unlock tables;
+disconnect con1;
+connection default;
drop table t1;
diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result
index 12960a4f5f6..d4e0edaf1c2 100644
--- a/mysql-test/r/lock_multi.result
+++ b/mysql-test/r/lock_multi.result
@@ -1,85 +1,125 @@
drop table if exists t1,t2;
drop DATABASE if exists mysqltest_1;
+connect locker,localhost,root,,;
+connect locker2,localhost,root,,;
+connect reader,localhost,root,,;
+connect writer,localhost,root,,;
+connection locker;
create table t1(n int);
insert into t1 values (1);
+connection locker2;
select get_lock("mysqltest_lock", 100);
get_lock("mysqltest_lock", 100)
1
+connection locker;
update t1 set n = 2 and get_lock('mysqltest_lock', 100);
+connection writer;
update low_priority t1 set n = 4;
+connection reader;
select n from t1;
+connection locker2;
select release_lock("mysqltest_lock");
release_lock("mysqltest_lock")
1
+connection locker;
select release_lock("mysqltest_lock");
release_lock("mysqltest_lock")
1
+connection writer;
+connection reader;
n
4
drop table t1;
+connection locker;
create table t1(n int);
insert into t1 values (1),(2);
+connection locker2;
select get_lock("mysqltest_lock", 100);
get_lock("mysqltest_lock", 100)
1
+connection locker;
select n from t1 where get_lock('mysqltest_lock', 100);
+connection writer;
update low_priority t1 set n = 4;
+connection reader;
select n from t1;
n
1
2
+connection locker2;
select release_lock("mysqltest_lock");
release_lock("mysqltest_lock")
1
+connection locker;
n
1
2
select release_lock("mysqltest_lock");
release_lock("mysqltest_lock")
1
+connection writer;
drop table t1;
+connection locker;
create table t1 (a int, b int);
create table t2 (c int, d int);
insert into t1 values(1,1);
insert into t1 values(2,2);
insert into t2 values(1,2);
lock table t1 read;
+connection writer;
update t1,t2 set c=a where b=d;
+connection reader;
select c from t2;
c
2
+connection locker;
unlock tables;
drop table t1;
drop table t2;
+connection locker;
create table t1 (a int);
create table t2 (a int);
lock table t1 write, t2 write;
+connection reader;
insert t1 select * from t2;
+connection locker;
drop table t2;
unlock tables;
+connection reader;
ERROR 42S02: Table 'test.t2' doesn't exist
+connection locker;
drop table t1;
+connection locker;
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;
insert t1 select * from t2;
+connection locker;
drop table t2;
unlock tables;
+connection reader;
ERROR 42S02: Table 'test.t2' doesn't exist
+connection locker;
drop table t1;
End of 4.1 tests
create table t1(a int);
lock tables t1 write;
+connection reader;
show columns from t1;
Field Type Null Key Default Extra
a int(11) YES NULL
+connection locker;
unlock tables;
drop table t1;
+connection locker;
USE mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES;
+connection reader;
USE mysql;
SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
+connection locker;
OPTIMIZE TABLES columns_priv, db, host, user;
Table Op Msg_type Msg_text
mysql.columns_priv optimize status OK
@@ -87,157 +127,238 @@ mysql.db optimize status OK
mysql.host optimize status OK
mysql.user optimize status OK
UNLOCK TABLES;
+connection reader;
Select_priv
N
USE test;
+connection locker;
use test;
+connection default;
+connection writer;
CREATE TABLE t1 (c1 int);
LOCK TABLE t1 WRITE;
+connection locker;
FLUSH TABLES WITH READ LOCK;
+connection writer;
CREATE TABLE t2 (c1 int);
ERROR HY000: Table 't2' was not locked with LOCK TABLES
UNLOCK TABLES;
+connection locker;
UNLOCK TABLES;
+connection default;
DROP TABLE t1;
+connection writer;
CREATE TABLE t1 (c1 int);
LOCK TABLE t1 WRITE;
+connection locker;
FLUSH TABLES WITH READ LOCK;
+connection writer;
CREATE TABLE t2 AS SELECT * FROM t1;
ERROR HY000: Table 't2' was not locked with LOCK TABLES
UNLOCK TABLES;
+connection locker;
UNLOCK TABLES;
+connection default;
DROP TABLE t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
CREATE DATABASE mysqltest_1;
FLUSH TABLES WITH READ LOCK;
+connection con2;
DROP DATABASE mysqltest_1;
+connection con1;
DROP DATABASE mysqltest_1;
ERROR HY000: Can't execute the query because you have a conflicting read lock
UNLOCK TABLES;
+connection con2;
+connection default;
+disconnect con1;
+disconnect con2;
DROP DATABASE mysqltest_1;
ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist
+connection locker;
set sql_mode="";
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
set sql_mode=default;
lock tables t1 write;
+connection writer;
alter table t1 auto_increment=0;
+connection reader;
alter table t1 auto_increment=0;
+connection locker;
unlock tables;
+connection writer;
+connection reader;
+connection locker;
drop table t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connect con3,localhost,root,,;
+connect con4,localhost,root,,;
+connect con5,localhost,root,,;
create table t1 (a int);
create table t2 like t1;
-# con1
+connection con1;
lock tables t1 write;
-# con2
+connection con2;
flush tables with read lock;
-# con5
+connection con5;
# global read lock is taken
-# con3
+connection con3;
select * from t2 for update;
+connection con5;
# waiting for release of read lock
-# con4
+connection con4;
# would hang and later cause a deadlock
flush tables t2;
+connection con1;
# clean up
unlock tables;
+connection con2;
unlock tables;
+connection con3;
a
+connection default;
+disconnect con5;
+disconnect con4;
+disconnect con3;
+disconnect con2;
+disconnect con1;
drop table t1,t2;
#
# Lightweight version:
# Ensure that the wait for a GRL is done before opening tables.
#
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
create table t1 (a int);
create table t2 like t1;
#
# UPDATE
#
-# default
+connection default;
flush tables with read lock;
-# con1
+connection con1;
update t2 set a = 1;
-# default
+connection default;
# statement is waiting for release of read lock
-# con2
+connection con2;
flush table t2;
-# default
+connection default;
unlock tables;
-# con1
+connection con1;
#
# LOCK TABLES .. WRITE
#
-# default
+connection default;
flush tables with read lock;
-# con1
+connection con1;
lock tables t2 write;
-# default
+connection default;
# statement is waiting for release of read lock
-# con2
+connection con2;
flush table t2;
-# default
+connection default;
unlock tables;
-# con1
+connection con1;
unlock tables;
+connection default;
+disconnect con2;
+disconnect con1;
drop table t1,t2;
End of 5.0 tests
create table t1 (i int);
+connection locker;
lock table t1 read;
+connection writer;
update t1 set i= 10;
+connection reader;
select * from t1;
+connection default;
kill query ID;
+connection reader;
i
+connection writer;
ERROR 70100: Query execution was interrupted
+connection locker;
unlock tables;
+connection default;
drop table t1;
+disconnect locker;
+disconnect locker2;
+disconnect reader;
+disconnect writer;
drop table if exists t1;
create table t1 (i int);
-connection: default
+connect flush,localhost,root,,test,,;
+connection default;
lock tables t1 write;
-connection: flush
+connection flush;
flush tables with read lock;;
-connection: default
+connection default;
alter table t1 add column j int;
-connection: insert
+connect insert,localhost,root,,test,,;
+connection insert;
insert into t1 values (1,2);;
-connection: default
+connection default;
unlock tables;
-connection: flush
+connection flush;
select * from t1;
i j
unlock tables;
+connection insert;
+connection default;
select * from t1;
i j
1 2
drop table t1;
+disconnect flush;
+disconnect insert;
drop table if exists t1;
create table t1 (i int);
-connection: default
+connect flush,localhost,root,,test,,;
+connection default;
lock tables t1 write;
-connection: flush
+connection flush;
flush tables with read lock;;
-connection: default
+connection default;
flush tables;
unlock tables;
+connection flush;
+connection default;
+disconnect flush;
drop table t1;
drop table if exists t1,t2;
create table t1 (a int);
flush status;
lock tables t1 read;
+connect waiter,localhost,root,,;
+connection waiter;
insert into t1 values(1);
+connection default;
unlock tables;
+connection waiter;
+connection default;
drop table t1;
+disconnect waiter;
select @tlwa < @tlwb;
@tlwa < @tlwb
1
End of 5.1 tests
drop table if exists t1;
create table t1 (i int);
-connection: default
+connect flush,localhost,root,,test,,;
+connection default;
lock tables t1 write;
-connection: flush
+connection flush;
flush tables with read lock;;
-connection: default
+connection default;
flush tables;
drop table t1;
+connection flush;
+connection default;
+disconnect flush;
#
# Test for bug #46272 "MySQL 5.4.4, new MDL: unnecessary deadlock".
#
@@ -246,15 +367,14 @@ create table t1 (c1 int primary key, c2 int, c3 int);
insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
begin;
update t1 set c3=c3+1 where c2=3;
-#
-# Switching to connection 'con46272'.
+connect con46272,localhost,root,,test,,;
+connection con46272;
# The below ALTER TABLE statement should wait till transaction
# in connection 'default' is complete and then succeed.
# It should not deadlock or fail with ER_LOCK_DEADLOCK error.
# Sending:
alter table t1 add column c4 int;;
-#
-# Switching to connection 'default'.
+connection default;
# Wait until the above ALTER TABLE gets blocked because this
# connection holds SW metadata lock on table to be altered.
# The below statement should succeed. It should not
@@ -262,11 +382,10 @@ alter table t1 add column c4 int;;
update t1 set c3=c3+1 where c2=4;
# Unblock ALTER TABLE by committing transaction.
commit;
-#
-# Switching to connection 'con46272'.
+connection con46272;
# Reaping ALTER TABLE.
-#
-# Switching to connection 'default'.
+connection default;
+disconnect con46272;
drop table t1;
#
# Bug#47249 assert in MDL_global_lock::is_lock_type_compatible
@@ -292,10 +411,11 @@ DROP VIEW v1;
#
CREATE TABLE t1 ( f1 integer );
CREATE VIEW v1 AS SELECT f1 FROM t1 ;
-# Connection 2
+connect con2,localhost,root;
LOCK TABLES t1 WRITE, v1 READ;
FLUSH TABLE t1;
-# Connection 1
+disconnect con2;
+connection default;
LOCK TABLES t1 WRITE;
FLUSH TABLE t1;
DROP TABLE t1;
@@ -306,15 +426,17 @@ DROP VIEW v1;
#
drop table if exists t1;
drop view if exists v1;
+connect con50913,localhost,root;
+connection default;
create table t1 (i int);
create view v1 as select i from t1;
begin;
select * from t1;
i
-# Switching to connection 'con50913'.
+connection con50913;
# Sending:
alter table t1 add column j int;
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER TABLE gets blocked.
# The below statement should try to acquire SW lock on 't1'
# and therefore should get ER_LOCK_DEADLOCK error. Before
@@ -323,16 +445,16 @@ delete a from t1 as a where i = 1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Unblock ALTER TABLE.
commit;
-# Switching to connection 'con50913'.
+connection con50913;
# Reaping ALTER TABLE;
-# Switching to connection 'default'.
+connection default;
begin;
select * from v1;
i
-# Switching to connection 'con50913'.
+connection con50913;
# Sending:
alter table t1 drop column j;
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER TABLE gets blocked.
# The below statement should try to acquire SW lock on 't1'
# and therefore should get ER_LOCK_DEADLOCK error. Before
@@ -341,9 +463,10 @@ insert into v1 values (1);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Unblock ALTER TABLE.
commit;
-# Switching to connection 'con50913'.
+connection con50913;
# Reaping ALTER TABLE;
-# Switching to connection 'default'.
+connection default;
+disconnect con50913;
drop view v1;
drop table t1;
#
@@ -354,113 +477,122 @@ drop table t1;
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id int);
+connect con2, localhost, root,,;
SET SESSION lock_wait_timeout= 1;
#
# Test 1: acquire exclusive lock
#
-# Connection default
+connection default;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
-# Connection 2
+connection con2;
DROP TABLE t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-# Connection default
+connection default;
COMMIT;
#
# Test 2: upgrade shared lock
#
-# Connection default
+connection default;
START TRANSACTION;
SELECT * FROM t1;
id
1
-# Connection 2
+connection con2;
ALTER TABLE t1 RENAME TO t2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-# Connection default
+connection default;
COMMIT;
#
# Test 3: acquire shared lock
#
-# Connection default
+connection default;
LOCK TABLE t1 WRITE;
-# Connection 2
+connection con2;
INSERT INTO t1(id) VALUES (2);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-# Connection default
+connection default;
UNLOCK TABLES;
#
# Test 4: table level locks
#
-# Connection default
+connection default;
LOCK TABLE t1 READ;
-# Connection 2
+connection con2;
INSERT INTO t1(id) VALUES(4);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-# Connection default
+connection default;
UNLOCK TABLES;
#
# Test 5: Waiting on Table Definition Cache (TDC)
#
-# Connection default
+connect con3, localhost, root;
+connection default;
LOCK TABLE t1 READ;
-# Connection con3
+connection con3;
# Sending:
FLUSH TABLES;
-# Connection con2
+connection con2;
SELECT * FROM t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-# Connection default
+connection default;
UNLOCK TABLES;
-# Connection con3
+connection con3;
# Reaping: FLUSH TABLES
#
# Test 6: Timeouts in I_S queries
#
-# Connection default
+connection default;
CREATE TABLE t2 (id INT);
LOCK TABLE t2 WRITE;
-# Connection con3
+connection con3;
# Sending:
DROP TABLE t1, t2;
-# Connection con2
+connection con2;
SELECT table_name, table_comment FROM information_schema.tables
WHERE table_schema= 'test' AND table_name= 't1';
table_name table_comment
t1 Lock wait timeout exceeded; try restarting transaction
Warnings:
Warning 1205 Lock wait timeout exceeded; try restarting transaction
-# Connection default
+connection default;
UNLOCK TABLES;
-# Connection con3
+connection con3;
# Reaping: DROP TABLE t1, t2
-# Connection default
+connection default;
# Cleanup
+disconnect con2;
+disconnect con3;
#
# Test for bug #51134 "Crash in MDL_lock::destroy on a concurrent
# DDL workload".
#
drop tables if exists t1, t2, t3;
+connect con1, localhost, root, , ;
+connect con2, localhost, root, , ;
+connection default;
create table t3 (i int);
-# Switching to connection 'con1'
+connection con1;
# Lock 't3' so upcoming RENAME is blocked.
lock table t3 read;
-# Switching to connection 'con2'
+connection con2;
# Remember ID for this connection.
# Start statement which will try to acquire two instances
# of X metadata lock on the same object.
# Sending:
rename tables t1 to t2, t2 to t3;;
-# Switching to connection 'default'
+connection default;
# Wait until RENAME TABLE is blocked on table 't3'.
# Kill RENAME TABLE.
kill query ID;
-# Switching to connection 'con2'
+connection con2;
# RENAME TABLE should be aborted but should not crash.
ERROR 70100: Query execution was interrupted
-# Switching to connection 'con1'
+connection con1;
unlock tables;
-# Switching to connection 'default'
+connection default;
+disconnect con1;
+disconnect con2;
drop table t3;
#
# Test for the bug where upgradable metadata locks was acquired
@@ -470,9 +602,10 @@ drop table t3;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (id INT);
LOCK TABLE t1 WRITE;
-# Connection con1
+connect con1, localhost, root;
CREATE TEMPORARY TABLE t1 (id INT);
ALTER TABLE t1 ADD COLUMN j INT;
-# Connection default
+connection default;
+disconnect con1;
UNLOCK TABLES;
DROP TABLE t1;
diff --git a/mysql-test/r/lock_multi_bug38499.result b/mysql-test/r/lock_multi_bug38499.result
index 6922312b298..521ea010816 100644
--- a/mysql-test/r/lock_multi_bug38499.result
+++ b/mysql-test/r/lock_multi_bug38499.result
@@ -1,5 +1,8 @@
SET @odl_sync_frm = @@global.sync_frm;
SET @@global.sync_frm = OFF;
+connect locker,localhost,root,,;
+connect writer,localhost,root,,;
+connection default;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1( a INT, b INT );
CREATE TABLE t2( a INT, b INT );
@@ -11,7 +14,9 @@ INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
# 1.1.2. PS mode
# 1.2. test altering of columns that multiupdate uses
# 1.2.1. normal mode
+connection default;
# 1.2.2. PS mode
+connection default;
ALTER TABLE t1 ADD COLUMN a INT;
# 2. test UNIONs
# 2.1. test altering of columns that multiupdate doesn't use
@@ -19,6 +24,10 @@ ALTER TABLE t1 ADD COLUMN a INT;
# 2.1.2. PS mode
# 2.2. test altering of columns that multiupdate uses
# 2.2.1. normal mode
+connection default;
# 2.2.2. PS mode
+connection default;
DROP TABLE t1,t2;
+disconnect locker;
+disconnect writer;
SET @@global.sync_frm = @odl_sync_frm;
diff --git a/mysql-test/r/lock_multi_bug38691.result b/mysql-test/r/lock_multi_bug38691.result
index d0aa1c0277c..55836e161f4 100644
--- a/mysql-test/r/lock_multi_bug38691.result
+++ b/mysql-test/r/lock_multi_bug38691.result
@@ -1,5 +1,8 @@
SET @odl_sync_frm = @@global.sync_frm;
SET @@global.sync_frm = OFF;
+connect locker,localhost,root,,;
+connect writer,localhost,root,,;
+connection default;
DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1 (
a int(11) unsigned default NULL,
@@ -15,6 +18,10 @@ CREATE TABLE t3 SELECT * FROM t1;
# PS mode
# test altering of columns that multiupdate uses
# normal mode
+connection default;
# PS mode
+connection default;
DROP TABLE t1, t2, t3;
+disconnect locker;
+disconnect writer;
SET @@global.sync_frm = @odl_sync_frm;
diff --git a/mysql-test/r/lock_sync.result b/mysql-test/r/lock_sync.result
index 219cc08342e..f075262c3db 100644
--- a/mysql-test/r/lock_sync.result
+++ b/mysql-test/r/lock_sync.result
@@ -23,6 +23,9 @@ select @@global.concurrent_insert;
ALWAYS
# Prepare playground by creating tables, views,
# routines and triggers used in tests.
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection default;
drop table if exists t0, t1, t2, t3, t4, t5;
drop view if exists v1, v2;
drop procedure if exists p1;
@@ -201,7 +204,7 @@ end|
# Set common variables to be used by the scripts
# called below.
#
-# Switch to connection 'con1'.
+connection con1;
# Cache all functions used in the tests below so statements
# calling them won't need to open and lock mysql.proc table
# and we can assume that each statement locks its tables
@@ -226,7 +229,7 @@ show create function f14;
show create function f15;
show create function f16;
show create function f17;
-# Switch back to connection 'default'.
+connection default;
#
# 1. Statements that read tables and do not use subqueries.
#
@@ -236,6 +239,7 @@ show create function f17;
# No locks are necessary as this statement won't be written
# to the binary log and thanks to how MyISAM works SELECT
# will see version of the table prior to concurrent insert.
+connection default;
Success: 'select * from t1' allows concurrent inserts into 't1'.
#
# 1.2 Multi-UPDATE statement.
@@ -243,11 +247,13 @@ Success: 'select * from t1' allows concurrent inserts into 't1'.
# Has to take shared locks on rows in the table being read as this
# statement will be written to the binary log and therefore should
# be serialized with concurrent statements.
+connection default;
Success: 'update t2, t1 set j= j - 1 where i = j' doesn't allow concurrent inserts into 't1'.
#
# 1.3 Multi-DELETE statement.
#
# The above is true for this statement as well.
+connection default;
Success: 'delete t2 from t1, t2 where i = j' doesn't allow concurrent inserts into 't1'.
#
# 1.4 DESCRIBE statement.
@@ -256,20 +262,20 @@ Success: 'delete t2 from t1, t2 where i = j' doesn't allow concurrent inserts in
# target table and thus does not take any lock on it.
# We check this for completeness of coverage.
lock table t1 write;
-# Switching to connection 'con1'.
+connection con1;
# This statement should not be blocked.
describe t1;
-# Switching to connection 'default'.
+connection default;
unlock tables;
#
# 1.5 SHOW statements.
#
# The above is true for SHOW statements as well.
lock table t1 write;
-# Switching to connection 'con1'.
+connection con1;
# These statements should not be blocked.
show keys from t1;
-# Switching to connection 'default'.
+connection default;
unlock tables;
#
# 2. Statements which read tables through subqueries.
@@ -280,6 +286,7 @@ unlock tables;
# A strong lock is not necessary as this statement is not
# written to the binary log as a whole (it is written
# statement-by-statement).
+connection default;
Success: 'call p1((select i + 5 from t1 where i = 1))' allows concurrent inserts into 't1'.
#
# 2.2 CREATE TABLE with a subquery.
@@ -287,24 +294,29 @@ Success: 'call p1((select i + 5 from t1 where i = 1))' allows concurrent inserts
# Has to take a strong lock on the table being read as
# this statement is written to the binary log and therefore
# should be serialized with concurrent statements.
+connection default;
Success: 'create table t0 select * from t1' doesn't allow concurrent inserts into 't1'.
drop table t0;
+connection default;
Success: 'create table t0 select j from t2 where j in (select i from t1)' doesn't allow concurrent inserts into 't1'.
drop table t0;
#
# 2.3 DELETE with a subquery.
#
# The above is true for this statement as well.
+connection default;
Success: 'delete from t2 where j in (select i from t1)' doesn't allow concurrent inserts into 't1'.
#
# 2.4 MULTI-DELETE with a subquery.
#
# Same is true for this statement as well.
+connection default;
Success: 'delete t2 from t3, t2 where k = j and j in (select i from t1)' doesn't allow concurrent inserts into 't1'.
#
# 2.5 DO with a subquery.
#
# A strong lock is not necessary as it is not logged.
+connection default;
Success: 'do (select i from t1 where i = 1)' allows concurrent inserts into 't1'.
#
# 2.6 INSERT with a subquery.
@@ -312,18 +324,23 @@ Success: 'do (select i from t1 where i = 1)' allows concurrent inserts into 't1'
# Has to take a strong lock on the table being read as
# this statement is written to the binary log and therefore
# should be serialized with concurrent inserts.
+connection default;
Success: 'insert into t2 select i+5 from t1' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'insert into t2 values ((select i+5 from t1 where i = 4))' doesn't allow concurrent inserts into 't1'.
#
# 2.7 LOAD DATA with a subquery.
#
# The above is true for this statement as well.
+connection default;
Success: 'load data infile '../../std_data/rpl_loaddata.dat' into table t2 (@a, @b) set j= @b + (select i from t1 where i = 1)' doesn't allow concurrent inserts into 't1'.
#
# 2.8 REPLACE with a subquery.
#
# Same is true for this statement as well.
+connection default;
Success: 'replace into t2 select i+5 from t1' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'replace into t2 values ((select i+5 from t1 where i = 4))' doesn't allow concurrent inserts into 't1'.
#
# 2.9 SELECT with a subquery.
@@ -331,17 +348,21 @@ Success: 'replace into t2 values ((select i+5 from t1 where i = 4))' doesn't all
# Strong locks are not necessary as this statement is not written
# to the binary log and thanks to how MyISAM works this statement
# sees a version of the table prior to the concurrent insert.
+connection default;
Success: 'select * from t2 where j in (select i from t1)' allows concurrent inserts into 't1'.
#
# 2.10 SET with a subquery.
#
# The same is true for this statement as well.
+connection default;
Success: 'set @a:= (select i from t1 where i = 1)' allows concurrent inserts into 't1'.
#
# 2.11 SHOW with a subquery.
#
# And for this statement too.
+connection default;
Success: 'show tables from test where Tables_in_test = 't2' and (select i from t1 where i = 1)' allows concurrent inserts into 't1'.
+connection default;
Success: 'show columns from t2 where (select i from t1 where i = 1)' allows concurrent inserts into 't1'.
#
# 2.12 UPDATE with a subquery.
@@ -349,11 +370,13 @@ Success: 'show columns from t2 where (select i from t1 where i = 1)' allows conc
# Has to take a strong lock on the table being read as
# this statement is written to the binary log and therefore
# should be serialized with concurrent inserts.
+connection default;
Success: 'update t2 set j= j-10 where j in (select i from t1)' doesn't allow concurrent inserts into 't1'.
#
# 2.13 MULTI-UPDATE with a subquery.
#
# Same is true for this statement as well.
+connection default;
Success: 'update t2, t3 set j= j -10 where j=k and j in (select i from t1)' doesn't allow concurrent inserts into 't1'.
#
# 3. Statements which read tables through a view.
@@ -364,9 +387,13 @@ Success: 'update t2, t3 set j= j -10 where j=k and j in (select i from t1)' does
# Since this statement is not written to the binary log and
# an old version of the table is accessible thanks to how MyISAM
# handles concurrent insert, no locking is necessary.
+connection default;
Success: 'select * from v1' allows concurrent inserts into 't1'.
+connection default;
Success: 'select * from v2' allows concurrent inserts into 't1'.
+connection default;
Success: 'select * from t2 where j in (select i from v1)' allows concurrent inserts into 't1'.
+connection default;
Success: 'select * from t3 where k in (select j from v2)' allows concurrent inserts into 't1'.
#
# 3.2 Statements which modify a table and use views.
@@ -374,9 +401,13 @@ Success: 'select * from t3 where k in (select j from v2)' allows concurrent inse
# Since such statements are going to be written to the binary
# log they need to be serialized against concurrent statements
# and therefore should take strong locks on the data read.
+connection default;
Success: 'update t2 set j= j-10 where j in (select i from v1)' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'update t3 set k= k-10 where k in (select j from v2)' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'update t2, v1 set j= j-10 where j = i' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'update v2 set j= j-10 where j = 3' doesn't allow concurrent inserts into 't1'.
#
# 4. Statements which read tables through stored functions.
@@ -388,7 +419,9 @@ Success: 'update v2 set j= j-10 where j = 3' doesn't allow concurrent inserts in
# There is no need to take strong locks on the table
# being selected from in SF as the call to such function
# won't get into the binary log.
+connection default;
Success: 'select f1()' allows concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f1()' allows concurrent inserts into 't1'.
#
# 4.2 INSERT (or other statement which modifies data) with
@@ -399,6 +432,7 @@ Success: 'set @a:= f1()' allows concurrent inserts into 't1'.
# be serialized with concurrent statements affecting the data
# it uses. Therefore it should take strong lock on the data
# it reads.
+connection default;
Success: 'insert into t2 values (f1() + 5)' doesn't allow concurrent inserts into 't1'.
#
# 4.3 SELECT/SET with a stored function which
@@ -408,7 +442,9 @@ Success: 'insert into t2 values (f1() + 5)' doesn't allow concurrent inserts int
# it should be serialized with concurrent statements affecting
# the data it uses. Hence, a strong lock on the data read
# should be taken.
+connection default;
Success: 'select f2()' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f2()' doesn't allow concurrent inserts into 't1'.
#
# 4.4. SELECT/SET with a stored function which does not
@@ -417,9 +453,13 @@ Success: 'set @a:= f2()' doesn't allow concurrent inserts into 't1'.
#
# Call to this function won't get to the
# binary log and thus no strong lock is needed.
+connection default;
Success: 'select f3()' allows concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f3()' allows concurrent inserts into 't1'.
+connection default;
Success: 'select f4()' allows concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f4()' allows concurrent inserts into 't1'.
#
# 4.5. INSERT (or other statement which modifies data) with
@@ -431,7 +471,9 @@ Success: 'set @a:= f4()' allows concurrent inserts into 't1'.
# be serialized with concurrent statements affecting data it
# uses. Therefore it should take a strong lock on the data
# it reads.
+connection default;
Success: 'insert into t2 values (f3() + 5)' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'insert into t2 values (f4() + 6)' doesn't allow concurrent inserts into 't1'.
#
# 4.6 SELECT/SET which uses a stored function with
@@ -440,7 +482,9 @@ Success: 'insert into t2 values (f4() + 6)' doesn't allow concurrent inserts int
# Since call to such function is written to the binary log
# it should be serialized with concurrent statements.
# Hence reads should take a strong lock.
+connection default;
Success: 'select f5()' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f5()' doesn't allow concurrent inserts into 't1'.
#
# 4.7 SELECT/SET which uses a stored function which
@@ -450,9 +494,13 @@ Success: 'set @a:= f5()' doesn't allow concurrent inserts into 't1'.
# Calls to such functions won't get into
# the binary log and thus don't need strong
# locks.
+connection default;
Success: 'select f6()' allows concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f6()' allows concurrent inserts into 't1'.
+connection default;
Success: 'select f7()' allows concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f7()' allows concurrent inserts into 't1'.
#
# 4.8 INSERT which uses stored function which
@@ -463,7 +511,9 @@ Success: 'set @a:= f7()' allows concurrent inserts into 't1'.
# should be serialized with concurrent statements affecting
# the data it uses. Therefore it should take a strong lock on
# the table it reads.
+connection default;
Success: 'insert into t3 values (f6() + 5)' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'insert into t3 values (f7() + 5)' doesn't allow concurrent inserts into 't1'.
#
# 4.9 SELECT which uses a stored function which
@@ -472,7 +522,9 @@ Success: 'insert into t3 values (f7() + 5)' doesn't allow concurrent inserts int
# Since a call to such function is written to the binary log
# it should be serialized with concurrent statements.
# Hence, reads should take strong locks.
+connection default;
Success: 'select f8()' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'select f9()' doesn't allow concurrent inserts into 't1'.
#
# 4.10 SELECT which uses a stored function which doesn't modify
@@ -481,6 +533,7 @@ Success: 'select f9()' doesn't allow concurrent inserts into 't1'.
#
# Calls to such functions won't get into the binary
# log and thus don't need to acquire strong locks.
+connection default;
Success: 'select f10()' allows concurrent inserts into 't1'.
#
# 4.11 INSERT which uses a stored function which doesn't modify
@@ -490,6 +543,7 @@ Success: 'select f10()' allows concurrent inserts into 't1'.
# Since such statement is written to the binary log, it should
# be serialized with concurrent statements affecting the data it
# uses. Therefore it should take strong locks on data it reads.
+connection default;
Success: 'insert into t2 values (f10() + 5)' doesn't allow concurrent inserts into 't1'.
#
# 4.12 SELECT which uses a stored function which modifies
@@ -499,6 +553,7 @@ Success: 'insert into t2 values (f10() + 5)' doesn't allow concurrent inserts in
# Since a call to such function is written to the binary log
# it should be serialized from concurrent statements.
# Hence, read should take a strong lock.
+connection default;
Success: 'select f11()' doesn't allow concurrent inserts into 't1'.
#
# 4.13 SELECT that reads a table through a subquery passed
@@ -509,6 +564,7 @@ Success: 'select f11()' doesn't allow concurrent inserts into 't1'.
# binary log, values of its parameters are written as literals.
# So there is no need to acquire strong locks for tables used in
# the subquery.
+connection default;
Success: 'select f12((select i+10 from t1 where i=1))' allows concurrent inserts into 't1'.
#
# 4.14 INSERT that reads a table via a subquery passed
@@ -518,6 +574,7 @@ Success: 'select f12((select i+10 from t1 where i=1))' allows concurrent inserts
# Since this statement is written to the binary log it should
# be serialized with concurrent statements affecting the data it
# uses. Therefore it should take strong locks on the data it reads.
+connection default;
Success: 'insert into t2 values (f13((select i+10 from t1 where i=1)))' doesn't allow concurrent inserts into 't1'.
#
# 4.15 SELECT/SET with a stored function which
@@ -527,7 +584,9 @@ Success: 'insert into t2 values (f13((select i+10 from t1 where i=1)))' doesn't
# Since this statement is written to the binary log it should
# be serialized with concurrent statements affecting the data it
# uses. Therefore it should take strong locks on the data it reads.
+connection default;
Success: 'select f16()' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f16()' doesn't allow concurrent inserts into 't1'.
#
# 4.16 SELECT/SET with a stored function which call procedure
@@ -537,7 +596,9 @@ Success: 'set @a:= f16()' doesn't allow concurrent inserts into 't1'.
# Since this statement is written to the binary log it should
# be serialized with concurrent statements affecting the data it
# uses. Therefore it should take strong locks on the data it reads.
+connection default;
Success: 'select f17()' doesn't allow concurrent inserts into 't1'.
+connection default;
Success: 'set @a:= f17()' doesn't allow concurrent inserts into 't1'.
#
# 5. Statements that read tables through stored procedures.
@@ -548,6 +609,7 @@ Success: 'set @a:= f17()' doesn't allow concurrent inserts into 't1'.
# Since neither this statement nor its components are
# written to the binary log, there is no need to take
# strong locks on the data it reads.
+connection default;
Success: 'call p2(@a)' allows concurrent inserts into 't1'.
#
# 5.2 Function that modifies data and uses CALL,
@@ -556,6 +618,7 @@ Success: 'call p2(@a)' allows concurrent inserts into 't1'.
# Since a call to such function is written to the binary
# log, it should be serialized with concurrent statements.
# Hence, in this case reads should take strong locks on data.
+connection default;
Success: 'select f14()' doesn't allow concurrent inserts into 't1'.
#
# 5.3 SELECT that calls a function that doesn't modify data and
@@ -563,6 +626,7 @@ Success: 'select f14()' doesn't allow concurrent inserts into 't1'.
#
# Calls to such functions won't get into the binary
# log and thus don't need to acquire strong locks.
+connection default;
Success: 'select f15()' allows concurrent inserts into 't1'.
#
# 5.4 INSERT which calls function which doesn't modify data and
@@ -571,6 +635,7 @@ Success: 'select f15()' allows concurrent inserts into 't1'.
# Since such statement is written to the binary log it should
# be serialized with concurrent statements affecting data it
# uses. Therefore it should take strong locks on data it reads.
+connection default;
Success: 'insert into t2 values (f15()+5)' doesn't allow concurrent inserts into 't1'.
#
# 6. Statements that use triggers.
@@ -582,30 +647,35 @@ Success: 'insert into t2 values (f15()+5)' doesn't allow concurrent inserts into
# be serialized with concurrent statements affecting the data
# it uses. Therefore, it should take strong locks on the data
# it reads.
+connection default;
Success: 'insert into t4 values (2)' doesn't allow concurrent inserts into 't1'.
#
# 6.2 Statement invoking a trigger that reads table through
# a subquery in a control construct.
#
# The above is true for this statement as well.
+connection default;
Success: 'update t4 set l= 2 where l = 1' doesn't allow concurrent inserts into 't1'.
#
# 6.3 Statement invoking a trigger that reads a table through
# a view.
#
# And for this statement.
+connection default;
Success: 'delete from t4 where l = 1' doesn't allow concurrent inserts into 't1'.
#
# 6.4 Statement invoking a trigger that reads a table through
# a stored function.
#
# And for this statement.
+connection default;
Success: 'insert into t5 values (2)' doesn't allow concurrent inserts into 't1'.
#
# 6.5 Statement invoking a trigger that reads a table through
# stored procedure.
#
# And for this statement.
+connection default;
Success: 'update t5 set l= 2 where l = 1' doesn't allow concurrent inserts into 't1'.
# Clean-up.
drop function f1;
@@ -630,6 +700,8 @@ drop procedure p1;
drop procedure p2;
drop procedure p3;
drop table t1, t2, t3, t4, t5;
+disconnect con1;
+disconnect con2;
set @@global.concurrent_insert= @old_concurrent_insert;
#
# Test for bug #45143 "All connections hang on concurrent ALTER TABLE".
@@ -641,6 +713,10 @@ set @@global.concurrent_insert= @old_concurrent_insert;
drop table if exists t1;
drop view if exists v1;
# Create auxiliary connections used through the test.
+connect con_bug45143_1,localhost,root,,test,,;
+connect con_bug45143_3,localhost,root,,test,,;
+connect con_bug45143_2,localhost,root,,test,,;
+connection default;
# Reset DEBUG_SYNC facility before using it.
set debug_sync= 'RESET';
# Turn off logging so calls to locking subsystem performed
@@ -657,10 +733,10 @@ insert into t1 values (1);
select get_lock("lock_bug45143_wait", 0);
get_lock("lock_bug45143_wait", 0)
1
-# Switch to connection 'con_bug45143_1'.
+connection con_bug45143_1;
# Sending:
insert into t1 values (get_lock("lock_bug45143_wait", 100));;
-# Switch to connection 'con_bug45143_2'.
+connection con_bug45143_2;
# Wait until the above INSERT takes TL_WRITE_ALLOW_WRITE lock on 't1'
# and then gets blocked on user lock 'lock_bug45143_wait'.
# Ensure that upcoming SELECT waits after acquiring TL_WRITE_ALLOW_WRITE
@@ -668,13 +744,13 @@ insert into t1 values (get_lock("lock_bug45143_wait", 100));;
set debug_sync='thr_multi_lock_after_thr_lock SIGNAL parked WAIT_FOR go';
# Sending:
select count(*) > 0 from t1 as a, t1 as b for update;;
-# Switch to connection 'con_bug45143_3'.
+connection con_bug45143_3;
# Wait until the above SELECT ... FOR UPDATE is blocked after
# acquiring lock for the the first instance of 't1'.
set debug_sync= 'now WAIT_FOR parked';
# Send LOCK TABLE statement which will try to get TL_WRITE lock on 't1':
lock table v1 write;;
-# Switch to connection 'default'.
+connection default;
# Wait until this LOCK TABLES statement starts waiting for table lock.
# Allow SELECT ... FOR UPDATE to resume.
# Since it already has TL_WRITE_ALLOW_WRITE lock on the first instance
@@ -682,25 +758,28 @@ lock table v1 write;;
# waiting, even although there is another thread which has such lock
# on this table and also there is a thread waiting for a TL_WRITE on it.
set debug_sync= 'now SIGNAL go';
-# Switch to connection 'con_bug45143_2'.
+connection con_bug45143_2;
# Reap SELECT ... FOR UPDATE
count(*) > 0
1
-# Switch to connection 'default'.
+connection default;
# Resume execution of the INSERT statement.
select release_lock("lock_bug45143_wait");
release_lock("lock_bug45143_wait")
1
-# Switch to connection 'con_bug45143_1'.
+connection con_bug45143_1;
# Reap INSERT statement.
# In Statement and Mixed replication mode we get here "Unsafe
# for binlog" warnings. In row mode there are no warnings.
# Hide the discrepancy.
-# Switch to connection 'con_bug45143_3'.
+connection con_bug45143_3;
# Reap LOCK TABLES statement.
unlock tables;
-# Switch to connection 'default'.
+connection default;
# Do clean-up.
+disconnect con_bug45143_1;
+disconnect con_bug45143_2;
+disconnect con_bug45143_3;
set debug_sync= 'RESET';
set @@global.general_log= @old_general_log;
drop view v1;
@@ -711,38 +790,40 @@ drop table t1;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1(id INT);
CREATE TABLE t2(id INT);
-# Connection con2
+connect con2, localhost, root;
START TRANSACTION;
SELECT * FROM t1;
id
-# Connection default
+connection default;
# Sending:
ALTER TABLE t1 ADD COLUMN j INT;
-# Connection con2
+connection con2;
# This used to cause a deadlock.
INSERT INTO t2 SELECT * FROM t1;
COMMIT;
-# Connection default
+connection default;
# Reaping ALTER TABLE t1 ADD COLUMN j INT
DROP TABLE t1, t2;
+disconnect con2;
#
# Bug#51391 Deadlock involving events during rqg_info_schema test
#
CREATE EVENT e1 ON SCHEDULE EVERY 5 HOUR DO SELECT 1;
CREATE EVENT e2 ON SCHEDULE EVERY 5 HOUR DO SELECT 2;
-# Connection con1
+connect con1, localhost, root;
SET DEBUG_SYNC="before_lock_tables_takes_lock SIGNAL drop WAIT_FOR query";
# Sending:
DROP EVENT e1;;
-# Connection default
+connection default;
SET DEBUG_SYNC="now WAIT_FOR drop";
SELECT name FROM mysql.event, INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE definer = VARIABLE_VALUE;
name
SET DEBUG_SYNC="now SIGNAL query";
-# Connection con1
+connection con1;
# Reaping: DROP EVENT t1
-# Connection default
+disconnect con1;
+connection default;
DROP EVENT e2;
SET DEBUG_SYNC="RESET";
#
@@ -752,20 +833,22 @@ SET DEBUG_SYNC="RESET";
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT) engine=InnoDB;
INSERT INTO t1 VALUES (1), (2);
-# Connection con1
+connect con1, localhost, root;
+connect con2, localhost, root;
+connection con1;
SET SESSION lock_wait_timeout= 1;
SET DEBUG_SYNC= 'ha_admin_open_ltable SIGNAL opti_recreate WAIT_FOR opti_analyze';
# Sending:
OPTIMIZE TABLE t1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR opti_recreate';
SET DEBUG_SYNC= 'after_lock_tables_takes_lock SIGNAL thrlock WAIT_FOR release_thrlock';
# Sending:
INSERT INTO t1 VALUES (3);
-# Connection default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR thrlock';
SET DEBUG_SYNC= 'now SIGNAL opti_analyze';
-# Connection con1
+connection con1;
# Reaping: OPTIMIZE TABLE t1
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
@@ -774,9 +857,11 @@ test.t1 optimize status Operation failed
Warnings:
Error 1205 Lock wait timeout exceeded; try restarting transaction
SET DEBUG_SYNC= 'now SIGNAL release_thrlock';
-# Connection con2
+disconnect con1;
+connection con2;
# Reaping: INSERT INTO t1 VALUES (3)
-# Connection default
+disconnect con2;
+connection default;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';
#
@@ -789,28 +874,31 @@ CREATE TABLE t1(a INT);
CREATE FUNCTION f1() RETURNS INTEGER RETURN 1;
CREATE VIEW v1 AS SELECT * FROM t1 WHERE f1() = 1;
DROP FUNCTION f1;
-# Connection con1
+connect con2, localhost, root;
+connect con1, localhost, root;
SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped EXECUTE 2';
# Sending:
SHOW CREATE VIEW v1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
SET DEBUG_SYNC= 'now SIGNAL dropped';
SET DEBUG_SYNC= 'now WAIT_FOR opened';
# Sending:
FLUSH TABLES;
-# Connection default
+connection default;
# Waiting for FLUSH TABLES to be blocked.
SET DEBUG_SYNC= 'now SIGNAL dropped';
-# Connection con1
+connection con1;
# Reaping: SHOW CREATE VIEW v1
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`f1`() = 1) latin1 latin1_swedish_ci
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
-# Connection con2
+connection con2;
# Reaping: FLUSH TABLES
-# Connection default
+connection default;
SET DEBUG_SYNC= 'RESET';
DROP VIEW v1;
DROP TABLE t1;
+disconnect con1;
+disconnect con2;
diff --git a/mysql-test/r/lock_tables_lost_commit.result b/mysql-test/r/lock_tables_lost_commit.result
index df4b6eff5cf..769e9734c7a 100644
--- a/mysql-test/r/lock_tables_lost_commit.result
+++ b/mysql-test/r/lock_tables_lost_commit.result
@@ -1,8 +1,15 @@
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT) ENGINE=innodb;
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES(10);
+disconnect con1;
+connection con2;
SELECT * FROM t1;
a
10
DROP TABLE t1;
+connection default;
+disconnect con2;
diff --git a/mysql-test/r/locked_temporary-5955.result b/mysql-test/r/locked_temporary-5955.result
index 8999bdd39c4..ee2a9f499b2 100644
--- a/mysql-test/r/locked_temporary-5955.result
+++ b/mysql-test/r/locked_temporary-5955.result
@@ -1,2 +1,4 @@
+connect con1,localhost,root,,;
CREATE TEMPORARY TABLE tmp (i INT) ENGINE=InnoDB;
LOCK TABLES tmp AS p WRITE;
+disconnect con1;
diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result
index 6e3ab8a991a..8d79601d954 100644
--- a/mysql-test/r/log_state.result
+++ b/mysql-test/r/log_state.result
@@ -31,8 +31,8 @@ where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
Variable_name Value
general_log ON
slow_query_log OFF
-# Establish connection con1 (user=root)
-# Switch to connection con1
+connect con1,localhost,root,,;
+connection con1;
set @long_query_time = <long_query_time>;
set session long_query_time = @long_query_time;
select sleep(@long_query_time + 1);
@@ -40,10 +40,10 @@ sleep(@long_query_time + 1)
0
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id rows_affected
-# Switch to connection default
+connection default;
set global slow_query_log= ON;
set local slow_query_log= ON;
-# Switch to connection con1
+connection con1;
set session long_query_time = @long_query_time;
select sleep(@long_query_time + 1);
sleep(@long_query_time + 1)
@@ -57,7 +57,7 @@ sleep(@long_query_time + 2)
select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id rows_affected
TIMESTAMP USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 select sleep(@long_query_time + 2) THREAD_ID 0
-# Switch to connection default
+connection default;
show global variables
where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
Variable_name Value
@@ -226,6 +226,7 @@ TRUNCATE TABLE mysql.slow_log;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT, PRIMARY KEY (b));
INSERT INTO t2 VALUES (3),(4);
+connect con2,localhost,root,,;
INSERT INTO t1 VALUES (1+sleep(.02)),(2);
INSERT INTO t1 SELECT b+sleep(.02) from t2;
UPDATE t1 SET a=a+sleep(.02) WHERE a>2;
@@ -242,6 +243,8 @@ rows_examined sql_text
1 UPDATE t2 set b=b+sleep(.02) limit 1
4 UPDATE t1 SET a=a+sleep(.02) WHERE a in (SELECT b from t2)
6 DELETE FROM t1 WHERE a=a+sleep(.02) ORDER BY a LIMIT 2
+disconnect con2;
+connection default;
DROP TABLE t1,t2;
TRUNCATE TABLE mysql.slow_log;
# end of bug#49756
@@ -270,7 +273,8 @@ SELECT @@general_log_file = @my_glf;
@@general_log_file = @my_glf
1
SET GLOBAL general_log_file = @old_general_log_file;
-# Close connection con1
+disconnect con1;
+connection default;
SET GLOBAL long_query_time = DEFAULT;
SET GLOBAL log_output = @old_log_output;
SET global general_log = @old_general_log;
diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result
index ff5055e1ae4..46997361bbe 100644
--- a/mysql-test/r/log_tables.result
+++ b/mysql-test/r/log_tables.result
@@ -507,14 +507,47 @@ call proc25422_alter_slow(@iterations);
"Serial test (proc25422_alter_general)"
call proc25422_alter_general(@iterations);
"Parallel test"
+connect addconroot1, localhost, root,,;
+connect addconroot2, localhost, root,,;
+connect addconroot3, localhost, root,,;
+connect addconroot4, localhost, root,,;
+connect addconroot5, localhost, root,,;
+connect addconroot6, localhost, root,,;
+connect addconroot7, localhost, root,,;
+connect addconroot8, localhost, root,,;
+connection addconroot1;
call proc25422_truncate_slow(@iterations);
+connection addconroot2;
call proc25422_truncate_slow(@iterations);
+connection addconroot3;
call proc25422_truncate_general(@iterations);
+connection addconroot4;
call proc25422_truncate_general(@iterations);
+connection addconroot5;
call proc25422_alter_slow(@iterations);
+connection addconroot6;
call proc25422_alter_slow(@iterations);
+connection addconroot7;
call proc25422_alter_general(@iterations);
+connection addconroot8;
call proc25422_alter_general(@iterations);
+connection addconroot1;
+connection addconroot2;
+connection addconroot3;
+connection addconroot4;
+connection addconroot5;
+connection addconroot6;
+connection addconroot7;
+connection addconroot8;
+connection default;
+disconnect addconroot1;
+disconnect addconroot2;
+disconnect addconroot3;
+disconnect addconroot4;
+disconnect addconroot5;
+disconnect addconroot6;
+disconnect addconroot7;
+disconnect addconroot8;
drop procedure proc25422_truncate_slow;
drop procedure proc25422_truncate_general;
drop procedure proc25422_alter_slow;
diff --git a/mysql-test/r/lowercase_fs_off.result b/mysql-test/r/lowercase_fs_off.result
index dea4670d2c7..12da5127629 100644
--- a/mysql-test/r/lowercase_fs_off.result
+++ b/mysql-test/r/lowercase_fs_off.result
@@ -1,8 +1,12 @@
set GLOBAL sql_mode="";
set LOCAL sql_mode="";
+connect master,localhost,root,,;
+connection master;
create database d1;
grant all on d1.* to 'sample'@'localhost' identified by 'password';
flush privileges;
+connect sample,localhost,sample,password,d1;
+connection sample;
select database();
database()
d1
@@ -10,22 +14,31 @@ create database d2;
ERROR 42000: Access denied for user 'sample'@'localhost' to database 'd2'
create database D1;
ERROR 42000: Access denied for user 'sample'@'localhost' to database 'D1'
+disconnect sample;
+connection master;
drop user 'sample'@'localhost';
drop database if exists d1;
+disconnect master;
+connection default;
CREATE DATABASE d1;
USE d1;
CREATE TABLE T1(f1 INT);
CREATE TABLE t1(f1 INT);
GRANT SELECT ON T1 to user_1@localhost;
+connect con1,localhost,user_1,,d1;
select * from t1;
ERROR 42000: SELECT command denied to user 'user_1'@'localhost' for table 't1'
select * from T1;
f1
+connection default;
GRANT SELECT ON t1 to user_1@localhost;
+connection con1;
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
'user_1'@'localhost' def d1 T1 SELECT NO
'user_1'@'localhost' def d1 t1 SELECT NO
+connection default;
+disconnect con1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
DROP USER user_1@localhost;
DROP DATABASE d1;
@@ -38,17 +51,22 @@ GRANT USAGE ON db1.* to user_1@localhost;
GRANT EXECUTE ON PROCEDURE db1.P1 to user_1@localhost;
GRANT EXECUTE ON FUNCTION db1.f1 to user_1@localhost;
GRANT UPDATE ON db1.* to USER_1@localhost;
+connect con1,localhost,user_1,,db1;
call p1();
call P1();
select f1(1);
f1(1)
2
+connect con2,localhost,USER_1,,db1;
call p1();
ERROR 42000: execute command denied to user 'USER_1'@'localhost' for routine 'db1.p1'
call P1();
ERROR 42000: execute command denied to user 'USER_1'@'localhost' for routine 'db1.P1'
select f1(1);
ERROR 42000: execute command denied to user 'USER_1'@'localhost' for routine 'db1.f1'
+connection default;
+disconnect con1;
+disconnect con2;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM USER_1@localhost;
DROP FUNCTION f1;
diff --git a/mysql-test/r/mdev-504.result b/mysql-test/r/mdev-504.result
index 4d93e77c6e8..9b8b6795e0f 100644
--- a/mysql-test/r/mdev-504.result
+++ b/mysql-test/r/mdev-504.result
@@ -16,6 +16,7 @@ BEGIN
RETURN ROUND(3 * RAND() + 0.5);
END |
SET GLOBAL use_stat_tables = PREFERABLY;
+connection default;
DROP TABLE A;
DROP PROCEDURE p_analyze;
DROP FUNCTION rnd3;
diff --git a/mysql-test/r/mdev375.result b/mysql-test/r/mdev375.result
index 426336e5939..d7a66ebd6dd 100644
--- a/mysql-test/r/mdev375.result
+++ b/mysql-test/r/mdev375.result
@@ -1,12 +1,15 @@
SET GLOBAL log_warnings=4;
SET GLOBAL max_connections=2;
+connect con1,localhost,root,,;
SELECT 1;
1
1
+connect con2,localhost,root,,;
SELECT 2;
2
2
ERROR HY000: Too many connections
+connection default;
SELECT 0;
0
0
diff --git a/mysql-test/r/mdl_sync.result b/mysql-test/r/mdl_sync.result
index 206ad509e37..865e874f63e 100644
--- a/mysql-test/r/mdl_sync.result
+++ b/mysql-test/r/mdl_sync.result
@@ -1,28 +1,46 @@
SET DEBUG_SYNC= 'RESET';
+connect con1,localhost,root,,test,,;
+connect con2,localhost,root,,test,,;
+connect con3,localhost,root,,test,,;
+connection default;
drop table if exists t1,t2,t3;
create table t1 (i int);
create table t2 (i int);
connection: default
lock tables t2 read;
+connection con1;
connection: con1
set debug_sync='mdl_upgrade_lock SIGNAL parked WAIT_FOR go';
alter table t1 rename t3;
+connection default;
connection: default
set debug_sync= 'now WAIT_FOR parked';
+connection con2;
connection: con2
set debug_sync='mdl_acquire_lock_wait SIGNAL go';
drop table t1,t2;
+connection con1;
connection: con1
+connection default;
connection: default
unlock tables;
+connection con2;
connection: con2
ERROR 42S02: Unknown table 'test.t1'
+connection default;
drop table t3;
+disconnect con1;
+disconnect con2;
+disconnect con3;
SET DEBUG_SYNC= 'RESET';
#
# Basic test coverage for type-of-operation aware metadata locks.
#
drop table if exists t1, t2, t3;
+connect mdl_con1,localhost,root,,;
+connect mdl_con2,localhost,root,,;
+connect mdl_con3,localhost,root,,;
+connection default;
set debug_sync= 'RESET';
create table t1 (c1 int);
#
@@ -36,7 +54,7 @@ create table t1 (c1 int);
#
handler t1 open;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that S, SH, SR and SW locks are compatible with it.
handler t1 open t;
handler t close;
@@ -66,62 +84,62 @@ unlock tables;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above RENAME is blocked because of S lock.
#
-# Switching to connection 'default'.
+connection default;
# Unblock RENAME TABLE.
handler t1 close;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME TABLE.
# Restore the original state of the things.
rename table t2 to t1;
#
-# Switching to connection 'default'.
+connection default;
handler t1 open;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that upgrade from SNW to X is blocked by presence of S lock.
# Sending:
alter table t1 add column c2 int;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above ALTER TABLE is blocked because of S lock.
#
-# Switching to connection 'default'.
+connection default;
# Unblock ALTER TABLE.
handler t1 close;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
# Restore the original state of the things.
alter table t1 drop column c2;
#
-# Switching to connection 'default'.
+connection default;
handler t1 open;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that upgrade from SNRW to X is blocked by presence of S lock.
lock table t1 write;
# Sending:
alter table t1 add column c2 int;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above upgrade of SNRW to X in ALTER TABLE is blocked
# because of S lock.
#
-# Switching to connection 'default'.
+connection default;
# Unblock ALTER TABLE.
handler t1 close;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
# Restore the original state of the things.
alter table t1 drop column c2;
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
#
# 2) Acquire SH (shared high-priority) lock on the table.
# We have to involve DEBUG_SYNC facility for this as usually
@@ -131,7 +149,7 @@ set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
# Sending:
select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1';;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that S, SH, SR and SW locks are compatible with it.
handler t1 open;
@@ -162,76 +180,76 @@ unlock tables;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above RENAME is blocked because of SH lock.
# Unblock RENAME TABLE.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping SELECT ... FROM I_S.
table_name table_type auto_increment table_comment
t1 BASE TABLE NULL
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME TABLE.
# Restore the original state of the things.
rename table t2 to t1;
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
# Sending:
select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1';;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that upgrade from SNW to X is blocked by presence of SH lock.
# Sending:
alter table t1 add column c2 int;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above ALTER TABLE is blocked because of SH lock.
# Unblock RENAME TABLE.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping SELECT ... FROM I_S.
table_name table_type auto_increment table_comment
t1 BASE TABLE NULL
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
# Restore the original state of the things.
alter table t1 drop column c2;
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t1';;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that upgrade from SNRW to X is blocked by presence of S lock.
lock table t1 write;
# Sending:
alter table t1 add column c2 int;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above upgrade of SNRW to X in ALTER TABLE is blocked
# because of S lock.
# Unblock RENAME TABLE.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping SELECT ... FROM I_S.
table_name table_type auto_increment table_comment
t1 BASE TABLE NULL
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
# Restore the original state of the things.
alter table t1 drop column c2;
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
#
#
# 3) Acquire SR lock on the table.
@@ -242,7 +260,7 @@ select count(*) from t1;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that S, SH, SR and SW locks are compatible with it.
handler t1 open;
handler t1 close;
@@ -268,58 +286,58 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# Sending:
lock table t1 write;;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above LOCK TABLES is blocked because of SR lock.
# Unblock LOCK TABLES.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping LOCK TABLES.
delete from t1 limit 1;
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
begin;
select count(*) from t1;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that X lock is incompatible with SR lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above RENAME is blocked because of SR lock.
#
-# Switching to connection 'default'.
+connection default;
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME TABLE.
# Restore the original state of the things.
rename table t2 to t1;
#
-# Switching to connection 'default'.
+connection default;
begin;
select count(*) from t1;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that upgrade from SNW to X is blocked by presence of SR lock.
# Sending:
alter table t1 add column c2 int;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above ALTER TABLE is blocked because of SR lock.
#
-# Switching to connection 'default'.
+connection default;
# Unblock ALTER TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
# Restore the original state of the things.
alter table t1 drop column c2;
@@ -328,7 +346,7 @@ alter table t1 drop column c2;
# by presence of SR lock because SNRW is incompatible with SR anyway.
#
#
-# Switching to connection 'default'.
+connection default;
#
#
# 4) Acquire SW lock on the table.
@@ -337,7 +355,7 @@ alter table t1 drop column c2;
begin;
insert into t1 values (1);
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that S, SH, SR and SW locks are compatible with it.
handler t1 open;
handler t1 close;
@@ -360,51 +378,51 @@ ERROR 42000: Key column 'not_exist' doesn't exist in table
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above ALTER TABLE is blocked because of SW lock.
# Unblock ALTER TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'default'.
+connection default;
begin;
insert into t1 values (1);
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that SNRW lock is not compatible with SW lock.
# Sending:
lock table t1 write;;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above LOCK TABLES is blocked because of SW lock.
# Unblock LOCK TABLES.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping LOCK TABLES.
delete from t1 limit 2;
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
begin;
insert into t1 values (1);
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that X lock is incompatible with SW lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above RENAME is blocked because of SW lock.
#
-# Switching to connection 'default'.
+connection default;
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME TABLE.
# Restore the original state of the things.
rename table t2 to t1;
@@ -414,7 +432,7 @@ rename table t2 to t1;
# with SW anyway.
#
#
-# Switching to connection 'default'.
+connection default;
#
#
# 5) Acquire SU lock on the table. We have to use DEBUG_SYNC for
@@ -424,7 +442,7 @@ set debug_sync= 'alter_opened_table SIGNAL locked WAIT_FOR finish';
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that S, SH, SR and SW locks are compatible with it.
handler t1 open;
@@ -441,67 +459,67 @@ delete from t1 limit 1;
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above ALTER is blocked because of SU lock.
# Unblock ALTERs.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping first ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping another ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'alter_opened_table SIGNAL locked WAIT_FOR finish';
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that SNRW lock is incompatible with SU lock.
# Sending:
lock table t1 write;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above LOCK TABLES is blocked because of SU lock.
# Unblock ALTER and thus LOCK TABLES.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping LOCK TABLES
insert into t1 values (1);
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'alter_opened_table SIGNAL locked WAIT_FOR finish';
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that X lock is incompatible with SU lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above RENAME is blocked because of SU lock.
# Unblock ALTER and thus RENAME TABLE.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Now we have ALTER TABLE with SU->SNW and RENAME TABLE with pending
# X-lock. In this case ALTER TABLE should be chosen as victim.
# Reaping ALTER TABLE.
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME TABLE
# Revert back to original state of things.
rename table t2 to t1;
@@ -510,7 +528,7 @@ rename table t2 to t1;
# blocked by presence of another SU lock because SNW/SNRW is
# incompatible with SU anyway.
#
-# Switching to connection 'default'.
+connection default;
#
#
# 6) Acquire SNW lock on the table. We have to use DEBUG_SYNC for
@@ -520,7 +538,7 @@ set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR fini
# Sending:
alter table t1 add primary key (c1), lock=shared, algorithm=copy;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that S, SH and SR locks are compatible with it.
handler t1 open;
@@ -536,39 +554,39 @@ count(*)
# Sending:
delete from t1 limit 2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above DELETE is blocked because of SNW lock.
# Unblock ALTER and thus DELETE.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping DELETE.
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish';
# Sending:
alter table t1 add primary key (c1), lock=shared, algorithm=copy;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that SU lock is incompatible with SNW lock.
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above ALTER is blocked because of SNW lock.
# Unblock ALTERs.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping first ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping another ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
@@ -576,52 +594,52 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# SNW is only used by ALTER TABLE after upgrading from SU
# and SU is also incompatible with SNW.
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish';
# Sending:
alter table t1 add primary key (c1), lock=shared, algorithm=copy;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that SNRW lock is incompatible with SNW lock.
# Sending:
lock table t1 write;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above LOCK TABLES is blocked because of SNW lock.
# Unblock ALTER and thus LOCK TABLES.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping LOCK TABLES
insert into t1 values (1);
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish';
# Sending:
alter table t1 add primary key (c1), algorithm=copy, lock=shared;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
set debug_sync= 'now WAIT_FOR locked';
# Check that X lock is incompatible with SNW lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above RENAME is blocked because of SNW lock.
# Unblock ALTER and thus RENAME TABLE.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'default'.
+connection default;
# Reaping ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME TABLE
# Revert back to original state of things.
rename table t2 to t1;
@@ -630,7 +648,7 @@ rename table t2 to t1;
# blocked by presence of another SNW lock because SNW/SNRW is
# incompatible with SNW anyway.
#
-# Switching to connection 'default'.
+connection default;
#
#
# 7) Acquire SNRW lock on the table.
@@ -638,7 +656,7 @@ rename table t2 to t1;
#
lock table t1 write;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that S and SH locks are compatible with it.
handler t1 open;
handler t1 close;
@@ -650,46 +668,46 @@ c1
# Sending:
select count(*) from t1;;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above SELECT is blocked because of SNRW lock.
# Unblock SELECT.
unlock tables;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping SELECT.
count(*)
4
#
-# Switching to connection 'default'.
+connection default;
lock table t1 write;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that SW lock is incompatible with SNRW lock.
# Sending:
delete from t1 limit 1;;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above DELETE is blocked because of SNRW lock.
# Unblock DELETE.
unlock tables;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping DELETE.
#
-# Switching to connection 'default'.
+connection default;
lock table t1 write;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that SU lock is incompatible with SNRW lock.
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above ALTER is blocked because of SNRW lock.
# Unblock ALTER.
unlock tables;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
@@ -697,38 +715,38 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# SNW is only used by ALTER TABLE after upgrading from SU
# and SU is also incompatible with SNRW.
#
-# Switching to connection 'default'.
+connection default;
lock table t1 write;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that SNRW lock is incompatible with SNRW lock.
# Sending:
lock table t1 write;;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above LOCK TABLES is blocked because of SNRW lock.
# Unblock waiting LOCK TABLES.
unlock tables;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping LOCK TABLES
insert into t1 values (1);
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
lock table t1 write;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that X lock is incompatible with SNRW lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'default'.
+connection default;
# Check that the above RENAME is blocked because of SNRW lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME TABLE
# Revert back to original state of things.
rename table t2 to t1;
@@ -737,7 +755,7 @@ rename table t2 to t1;
# blocked by presence of another SNRW lock because SNW/SNRW is
# incompatible with SNRW anyway.
#
-# Switching to connection 'default'.
+connection default;
#
#
# 8) Now do the same round of tests for X lock. We use additional
@@ -745,144 +763,144 @@ rename table t2 to t1;
#
create table t2 (c1 int);
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Take a lock on t2, so RENAME TABLE t1 TO t2 will get blocked
# after acquiring X lock on t1.
lock tables t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME has acquired X lock on t1 and is waiting for t2.
# Check that S lock in incompatible with X lock.
# Sending:
handler t1 open;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above HANDLER statement is blocked because of X lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping HANDLER.
handler t1 close;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Prepare for blocking RENAME TABLE.
lock tables t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME has acquired X lock on t1 and is waiting for t2.
# Check that SH lock in incompatible with X lock.
# Sending:
select column_name from information_schema.columns where table_schema='test' and table_name='t1';;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above SELECT ... FROM I_S ... statement is blocked
# because of X lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping SELECT ... FROM I_S.
column_name
c1
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Prepare for blocking RENAME TABLE.
lock tables t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME has acquired X lock on t1 and is waiting for t2.
# Check that SR lock in incompatible with X lock.
# Sending:
select count(*) from t1;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above SELECT statement is blocked
# because of X lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping SELECT.
count(*)
4
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Prepare for blocking RENAME TABLE.
lock tables t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME has acquired X lock on t1 and is waiting for t2.
# Check that SW lock in incompatible with X lock.
# Sending:
delete from t1 limit 1;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above DELETE statement is blocked
# because of X lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping DELETE.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Prepare for blocking RENAME TABLE.
lock tables t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME has acquired X lock on t1 and is waiting for t2.
# Check that SU lock is incompatible with X lock.
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above ALTER statement is blocked
# because of X lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
@@ -890,59 +908,59 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# SNW is only used by ALTER TABLE after upgrading from SU
# and SU is also incompatible with X.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Prepare for blocking RENAME TABLE.
lock tables t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME has acquired X lock on t1 and is waiting for t2.
# Check that SNRW lock is incompatible with X lock.
# Sending:
lock table t1 write;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above LOCK TABLE statement is blocked
# because of X lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping LOCK TABLE.
unlock tables;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Prepare for blocking RENAME TABLE.
lock tables t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME has acquired X lock on t1 and is waiting for t2.
# Check that X lock is incompatible with X lock.
# Sending:
rename table t1 to t3;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above RENAME statement is blocked
# because of X lock.
# Unblock RENAME TABLE
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping RENAME.
rename table t3 to t1;
#
@@ -954,7 +972,7 @@ rename table t3 to t1;
# even stronger active or pending lock.
#
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
#
# 1) Check compatibility for pending SNW lock.
#
@@ -962,12 +980,12 @@ rename table t3 to t1;
begin;
insert into t1 values (1);
#
-# Switching to connection 'default'.
+connection default;
# Add pending SNW lock.
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that ALTER TABLE is waiting with pending SNW lock.
# Check that S, SH and SR locks are compatible with pending SNW
handler t1 open t;
@@ -983,23 +1001,23 @@ count(*)
# Sending:
delete from t1 limit 1;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above DELETE is blocked because of pending SNW lock.
# Unblock ALTER TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping ALTER.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping DELETE.
#
# We can't do similar check for SNW, SNRW and X locks because
# they will also be blocked by active SW lock.
#
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
#
# 2) Check compatibility for pending SNRW lock.
#
@@ -1009,12 +1027,12 @@ select count(*) from t1;
count(*)
3
#
-# Switching to connection 'default'.
+connection default;
# Add pending SNRW lock.
# Sending:
lock table t1 write;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that LOCK TABLE is waiting with pending SNRW lock.
# Check that S and SH locks are compatible with pending SNRW
handler t1 open t;
@@ -1027,72 +1045,72 @@ c1
# Sending:
select count(*) from t1;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above SELECT is blocked because of pending SNRW lock.
# Unblock LOCK TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping LOCK TABLE.
unlock tables;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping SELECT.
count(*)
3
# Restore pending SNRW lock.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
begin;
select count(*) from t1;
count(*)
3
#
-# Switching to connection 'default'.
+connection default;
# Sending:
lock table t1 write;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that LOCK TABLE is waiting with pending SNRW lock.
# Check that SW is incompatible with pending SNRW
# Sending:
insert into t1 values (1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above INSERT is blocked because of pending SNRW lock.
# Unblock LOCK TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping LOCK TABLE.
unlock tables;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping INSERT.
# Restore pending SNRW lock.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
begin;
select count(*) from t1;
count(*)
4
#
-# Switching to connection 'default'.
+connection default;
# Sending:
lock table t1 write;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that LOCK TABLE is waiting with pending SNRW lock.
# Check that SNW is compatible with pending SNRW
# So ALTER TABLE statements are not starved by LOCK TABLEs.
alter table t1 add primary key (c1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Unblock LOCK TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping LOCK TABLE.
unlock tables;
#
@@ -1100,7 +1118,7 @@ unlock tables;
# they will also be blocked by active SR lock.
#
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
#
# 3) Check compatibility for pending X lock.
#
@@ -1110,12 +1128,12 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'default'.
+connection default;
# Add pending X lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME TABLE is waiting with pending X lock.
# Check that SH locks are compatible with pending X
select column_name from information_schema.columns where
@@ -1126,143 +1144,143 @@ c1
# Sending:
handler t1 open;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above HANDLER OPEN is blocked because of pending X lock.
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping HANDLER t1 OPEN.
handler t1 close;
# Restore pending X lock.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
begin;
select count(*) from t1;
count(*)
4
#
-# Switching to connection 'default'.
+connection default;
# Add pending X lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME TABLE is waiting with pending X lock.
# Check that SR is incompatible with pending X
# Sending:
select count(*) from t1;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above SELECT is blocked because of pending X lock.
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping SELECT.
count(*)
4
# Restore pending X lock.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
begin;
select count(*) from t1;
count(*)
4
#
-# Switching to connection 'default'.
+connection default;
# Add pending X lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME TABLE is waiting with pending X lock.
# Check that SW is incompatible with pending X
# Sending:
delete from t1 limit 1;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above DELETE is blocked because of pending X lock.
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping DELETE.
# Restore pending X lock.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
begin;
select count(*) from t1;
count(*)
3
#
-# Switching to connection 'default'.
+connection default;
# Add pending X lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME TABLE is waiting with pending X lock.
# Check that SNW is incompatible with pending X
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above ALTER TABLE is blocked because of pending X lock.
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
# Restore pending X lock.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
handler t1 open;
#
-# Switching to connection 'default'.
+connection default;
# Add pending X lock.
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that RENAME TABLE is waiting with pending X lock.
# Check that SNRW is incompatible with pending X
# Sending:
lock table t1 write;;
#
-# Switching to connection 'mdl_con3'.
+connection mdl_con3;
# Check that the above LOCK TABLES is blocked because of pending X lock.
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Unblock RENAME TABLE.
handler t1 close;
#
-# Switching to connection 'default'.
+connection default;
# Reaping RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reaping LOCK TABLES.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
#
#
# C) Now let us test how type-of-operation locks are handled in
@@ -1283,7 +1301,7 @@ select count(*) from t1;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create an active SNW lock on t2.
# We have to use DEBUG_SYNC facility as otherwise SNW lock
# will be immediately released (or upgraded to X lock).
@@ -1292,7 +1310,7 @@ set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR fini
# Sending:
alter table t2 add primary key (c1), algorithm=copy, lock=shared;;
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'now WAIT_FOR locked';
# SR lock should be acquired without any waiting.
select count(*) from t2;
@@ -1307,16 +1325,16 @@ count(*)
# Sending:
insert into t2 values (1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above INSERT is blocked.
# Unblock ALTER TABLE and thus INSERT.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'default'.
+connection default;
# Reap INSERT.
commit;
#
@@ -1331,13 +1349,13 @@ select count(*) from t1;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create an active SNW lock on t1.
set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL locked WAIT_FOR finish';
# Sending:
alter table t1 add primary key (c1), algorithm=copy, lock=shared;;
#
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'now WAIT_FOR locked';
# We should still be able to get SR lock without waiting.
select count(*) from t1;
@@ -1349,16 +1367,16 @@ count(*)
# Sending:
insert into t1 values (1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above INSERT is blocked.
# Unblock ALTER TABLE and thus INSERT.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'default'.
+connection default;
# Reap INSERT.
commit;
#
@@ -1369,12 +1387,12 @@ commit;
begin;
insert into t1 values (1);
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create pending SNW lock on t1.
# Sending:
alter table t1 add primary key (c1);;
#
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER TABLE starts waiting for SNW lock.
# We should still be able to get both SW and SR locks without waiting.
select count(*) from t1;
@@ -1384,11 +1402,11 @@ delete from t1 limit 1;
# Unblock ALTER TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap ALTER TABLE.
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
#
-# Switching to connection 'default'.
+connection default;
#
# 2) Now similar tests for active SNW lock which is being upgraded
# to X lock.
@@ -1400,7 +1418,7 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Start transaction which will prevent SNW -> X upgrade from
# completing immediately.
begin;
@@ -1408,26 +1426,26 @@ select count(*) from t2;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create SNW lock pending upgrade to X on t2.
# Sending:
alter table t2 add column c2 int;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER TABLE starts waiting X lock.
# Check that attempt to acquire SR lock on t2 causes waiting.
# Sending:
select count(*) from t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above SELECT is blocked.
# Unblock ALTER TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap ALTER TABLE.
#
-# Switching to connection 'default'.
+connection default;
# Reap SELECT.
count(*)
3
@@ -1438,7 +1456,7 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Start transaction which will prevent SNW -> X upgrade from
# completing immediately.
begin;
@@ -1446,26 +1464,26 @@ select count(*) from t2;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create SNW lock pending upgrade to X on t2.
# Sending:
alter table t2 drop column c2;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER TABLE starts waiting X lock.
# Check that attempt to acquire SW lock on t2 causes waiting.
# Sending:
insert into t2 values (1);;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above INSERT is blocked.
# Unblock ALTER TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap ALTER TABLE.
#
-# Switching to connection 'default'.
+connection default;
# Reap INSERT.
commit;
#
@@ -1477,12 +1495,12 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create SNW lock pending upgrade to X.
# Sending:
alter table t1 add column c2 int;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER TABLE starts waiting X lock.
# Check that transaction is still able to acquire SR lock.
select count(*) from t1;
@@ -1495,10 +1513,10 @@ ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Unblock ALTER TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap ALTER TABLE.
#
-# Switching to connection 'default'.
+connection default;
#
# 3) Check how various locks used within transactional context
# interact with active/pending SNRW lock.
@@ -1510,21 +1528,21 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
lock table t2 write;
#
-# Switching to connection 'default'.
+connection default;
# Attempt to acquire SR should be blocked. It should
# not cause errors as it does not creates deadlock.
# Sending:
select count(*) from t2;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that the above SELECT is blocked
# Unblock SELECT.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reap SELECT.
count(*)
4
@@ -1535,21 +1553,21 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
lock table t2 write;
#
-# Switching to connection 'default'.
+connection default;
# Again attempt to acquire SW should be blocked and should
# not cause any errors.
# Sending:
delete from t2 limit 1;;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Check that the above DELETE is blocked
# Unblock DELETE.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reap DELETE.
commit;
#
@@ -1564,11 +1582,11 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Sending:
lock table t1 write;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until LOCK TABLE is blocked creating pending request for X lock.
# Check that another instance of SR lock is granted without waiting.
select count(*) from t1;
@@ -1581,22 +1599,22 @@ ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Unblock LOCK TABLES.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap LOCK TABLES.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
#
# **) Now case when transaction has a SW lock.
#
begin;
delete from t1 limit 1;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Sending:
lock table t1 write;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until LOCK TABLE is blocked creating pending request for X lock.
# Check that both SR and SW locks are granted without waiting
# and errors.
@@ -1607,11 +1625,11 @@ insert into t1 values (1, 1);
# Unblock LOCK TABLES.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap LOCK TABLES.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
#
# 4) Check how various locks used within transactional context
# interact with active/pending X lock.
@@ -1623,7 +1641,7 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Start transaction which will prevent X lock from going away
# immediately.
begin;
@@ -1631,26 +1649,26 @@ select count(*) from t2;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create pending X lock on t2.
# Sending:
rename table t2 to t3;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until RENAME TABLE starts waiting with pending X lock.
# Check that attempt to acquire SR lock on t2 causes waiting.
# Sending:
select count(*) from t2;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above SELECT is blocked.
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap RENAME TABLE.
#
-# Switching to connection 'default'.
+connection default;
# Reap SELECT.
ERROR 42S02: Table 'test.t2' doesn't exist
commit;
@@ -1661,7 +1679,7 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Start transaction which will prevent X lock from going away
# immediately.
begin;
@@ -1669,26 +1687,26 @@ select count(*) from t2;
count(*)
3
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Create pending X lock on t2.
# Sending:
rename table t2 to t3;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until RENAME TABLE starts waiting with pending X lock.
# Check that attempt to acquire SW lock on t2 causes waiting.
# Sending:
delete from t2 limit 1;;
#
-# Switching to connection 'mdl_con2'.
+connection mdl_con2;
# Check that the above DELETE is blocked.
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap RENAME TABLE.
#
-# Switching to connection 'default'.
+connection default;
# Reap DELETE.
ERROR 42S02: Table 'test.t2' doesn't exist
commit;
@@ -1705,11 +1723,11 @@ select count(*) from t1;
count(*)
4
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until RENAME TABLE is blocked creating pending request for X lock.
# Check that another instance of SR lock is granted without waiting.
select count(*) from t1;
@@ -1722,22 +1740,22 @@ ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'default'.
+connection default;
#
# **) The second case is when transaction has a SW lock.
#
begin;
delete from t1 limit 1;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Sending:
rename table t1 to t2;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until RENAME TABLE is blocked creating pending request for X lock.
# Check that both SR and SW locks are granted without waiting
# and errors.
@@ -1748,12 +1766,15 @@ insert into t1 values (1, 1);
# Unblock RENAME TABLE.
commit;
#
-# Switching to connection 'mdl_con1'.
+connection mdl_con1;
# Reap RENAME TABLE.
ERROR 42S01: Table 't2' already exists
#
-# Switching to connection 'default'.
+connection default;
# Clean-up.
+disconnect mdl_con1;
+disconnect mdl_con2;
+disconnect mdl_con3;
set debug_sync= 'RESET';
drop table t1, t2;
#
@@ -1762,6 +1783,9 @@ drop table t1, t2;
# have caused deadlocks.
#
drop table if exists t1, t2;
+connect handler_con1,localhost,root,,;
+connect handler_con2,localhost,root,,;
+connection default;
create table t1 (i int);
create table t2 (j int);
insert into t1 values (1);
@@ -1772,24 +1796,24 @@ insert into t1 values (1);
#
handler t1 open;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
lock table t1 write;
# Upgrade SNRW to X lock.
# Sending:
alter table t1 add column j int;;
#
-# Switching to connection 'handler_con2'.
+connection handler_con2;
# Wait until ALTER is blocked during upgrade.
#
-# Switching to connection 'default'.
+connection default;
# The below statement should not cause deadlock.
handler t1 read first;;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
# Reap ALTER TABLE.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reap HANDLER READ.
i j
1 NULL
@@ -1801,64 +1825,64 @@ handler t1 close;
#
handler t1 open;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
lock table t1 write, t2 read;
#
-# Switching to connection 'default'.
+connection default;
# Execute statement which will be blocked on table-level lock
# owned by connection 'handler_con1'.
# Sending:
insert into t2 values (1);;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
# Wait until INSERT is blocked on table-level lock.
# Sending 'alter table t1 drop column j'. It should not cause
# deadlock.
alter table t1 drop column j;
-# Switching to connection 'handler_con2'.
+connection handler_con2;
# Wait until ALTER is blocked during upgrade.
#
-# Switching to connection 'default'.
+connection default;
# Reap INSERT.
ERROR HY000: Wait on a lock was aborted due to a pending exclusive lock
handler t1 close;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
# Reaping 'alter table t1 drop column j'
unlock tables;
-# Switching to connection 'default'.
+connection default;
# Then, check the scenario in which upgrade of SNRW lock to X
# lock is blocked by HANDLER which is open in connection currently
# waiting to get SW lock on the same table.
#
handler t1 open;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
lock table t1 write;
#
-# Switching to connection 'default'.
+connection default;
# The below insert should be blocked because active SNRW lock on 't1'.
# Sending:
insert into t1 values (1);;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
# Wait until INSERT is blocked because of SNRW lock.
# The below ALTER TABLE will be blocked because of presence of HANDLER.
# Sending:
alter table t1 add column j int;;
#
-# Switching to connection 'default'.
+connection default;
# INSERT should be chosen as victim for resolving deadlock.
# Reaping INSERT.
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Close HANDLER to unblock ALTER TABLE.
handler t1 close;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
# Reaping ALTER TABLE.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
#
# Finally, test in which upgrade of SNRW lock to X lock is blocked
# by HANDLER which is open in connection currently waiting to get
@@ -1866,33 +1890,35 @@ unlock tables;
#
handler t1 open;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
lock table t1 write, t2 write;
#
-# Switching to connection 'default'.
+connection default;
# The below insert should be blocked because active SNRW lock on 't1'.
# Sending:
insert into t2 values (1);;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
# Wait until INSERT is blocked because of SNRW lock.
# The below ALTER TABLE will be blocked because of presence of HANDLER.
# Sending:
alter table t1 drop column j;;
#
-# Switching to connection 'default'.
+connection default;
# INSERT should be chosen as victim for resolving deadlock.
# Reaping INSERT.
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
# Close HANDLER to unblock ALTER TABLE.
handler t1 close;
#
-# Switching to connection 'handler_con1'.
+connection handler_con1;
# Reaping ALTER TABLE.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Clean-up.
+disconnect handler_con1;
+disconnect handler_con2;
drop tables t1, t2;
#
# Test coverage for basic deadlock detection in metadata
@@ -1900,6 +1926,10 @@ drop tables t1, t2;
#
drop tables if exists t0, t1, t2, t3, t4, t5;
set debug_sync= 'RESET';
+connect deadlock_con1,localhost,root,,;
+connect deadlock_con2,localhost,root,,;
+connect deadlock_con3,localhost,root,,;
+connection default;
create table t1 (i int);
create table t2 (j int);
create table t3 (k int);
@@ -1908,19 +1938,19 @@ create table t4 (k int);
# Test for the case in which no deadlock occurs.
#
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
begin;
insert into t1 values (1);
#
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
begin;
insert into t2 values (1);
#
-# Switching to connection 'default'.
+connection default;
# Send:
rename table t2 to t0, t3 to t2, t0 to t3;;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Wait until the above RENAME TABLE is blocked because it has to wait
# for 'deadlock_con2' which holds shared metadata lock on 't2'.
# The below statement should wait for exclusive metadata lock
@@ -1929,21 +1959,21 @@ rename table t2 to t0, t3 to t2, t0 to t3;;
# Send:
select * from t2;;
#
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Wait until the above SELECT * FROM t2 is starts waiting
# for an exclusive metadata lock to go away.
#
# Unblock RENAME TABLE by releasing shared metadata lock on t2.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reap RENAME TABLE.
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Reap SELECT.
k
#
-# Switching to connection 'default'.
+connection default;
#
# Let us check that in the process of waiting for conflicting lock
# on table 't2' to go away transaction in connection 'deadlock_con1'
@@ -1951,28 +1981,28 @@ k
# Send:
rename table t1 to t0, t3 to t1, t0 to t3;;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Wait until the above RENAME TABLE is blocked because it has to wait
# for 'deadlock_con1' which should still hold shared metadata lock on
# table 't1'.
# Commit transaction to unblock RENAME TABLE.
commit;
#
-# Switching to connection 'default'.
+connection default;
# Reap RENAME TABLE.
#
# Test for case when deadlock occurs and should be detected immediately.
#
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
begin;
insert into t2 values (2);
#
-# Switching to connection 'default'.
+connection default;
# Send:
rename table t2 to t0, t1 to t2, t0 to t1;;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Wait until the above RENAME TABLE is blocked because it has to wait
# for 'deadlock_con1' which holds shared metadata lock on 't2'.
#
@@ -1982,50 +2012,50 @@ rename table t2 to t0, t1 to t2, t0 to t1;;
select * from t1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
#
-# Switching to connection 'default'.
+connection default;
# Reap RENAME TABLE.
#
# Test for the case in which deadlock also occurs but not immediately.
#
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
begin;
insert into t2 values (1);
#
-# Switching to connection 'default'.
+connection default;
lock table t1 write;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# The below SELECT statement should wait for metadata lock
# on table 't1' and should not produce ER_LOCK_DEADLOCK
# immediately as no deadlock is possible at the moment.
select * from t1;;
#
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Wait until the above SELECT * FROM t1 is starts waiting
# for an UNRW metadata lock to go away.
# Send RENAME TABLE statement that will deadlock with the
# SELECT statement and thus should abort the latter.
rename table t1 to t0, t2 to t1, t0 to t2;;
#
-# Switching to connection 'default'.
+connection default;
# Wait till above RENAME TABLE is blocked while holding
# pending X lock on t1.
# Allow the above RENAME TABLE to acquire lock on t1 and
# create pending lock on t2 thus creating deadlock.
unlock tables;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Since the latest RENAME TABLE entered in deadlock with SELECT
# statement the latter should be aborted and emit ER_LOCK_DEADLOCK
# error and transaction should be rolled back.
# Reap SELECT * FROM t1.
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
#
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Reap RENAME TABLE ... .
#
-# Switching to connection 'default'.
+connection default;
drop tables t1, t2, t3, t4;
#
# Now, test case which shows that deadlock detection empiric
@@ -2040,17 +2070,17 @@ select * from t1;
i
1
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
begin;
select * from t1;
i
1
#
-# Switching to connection 'default'.
+connection default;
# Send:
alter table t1 add column j int, rename to t2;;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Wait until the above ALTER TABLE ... RENAME acquires exclusive
# metadata lock on 't2' and starts waiting for connection
# 'deadlock_con1' which holds shared lock on 't1'.
@@ -2060,7 +2090,7 @@ alter table t1 add column j int, rename to t2;;
select * from t2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
#
-# Switching to connection 'default'.
+connection default;
# Reap ALTER TABLE ... RENAME.
drop table t2;
#
@@ -2079,23 +2109,23 @@ set debug_sync= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
# Sending:
select * from t2, t1;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Wait till SELECT acquires MDL on 't2' and starts waiting for signal.
set debug_sync= 'now WAIT_FOR locked';
# Sending:
lock tables t1 write, t2 write;
#
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Wait until LOCK TABLES acquires SNRW lock on 't1' and is blocked
# while trying to acquire SNRW lock on 't1'.
# Resume SELECT execution, this should eventually unblock LOCK TABLES.
set debug_sync= 'now SIGNAL finish';
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Reaping LOCK TABLES.
unlock tables;
#
-# Switching to connection 'default'.
+connection default;
# Reaping SELECT. It succeed and not report ER_LOCK_DEADLOCK error.
j i
drop tables t1, t2;
@@ -2110,7 +2140,7 @@ set debug_sync='alter_table_copy_after_lock_upgrade SIGNAL parked1 WAIT_FOR go1'
# Sending:
alter table t1 add column j int;
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Wait till ALTER acquires SNW lock and stops.
set debug_sync='now WAIT_FOR parked1';
# Ensure that INSERT is paused once it detects that there is
@@ -2120,7 +2150,7 @@ set debug_sync='mdl_acquire_lock_wait SIGNAL parked2 WAIT_FOR go2';
# Sending:
insert into t1 values ();
#
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Wait till INSERT is paused.
set debug_sync='now WAIT_FOR parked2';
# Resume ALTER execution. Eventually it will release its
@@ -2128,13 +2158,13 @@ set debug_sync='now WAIT_FOR parked2';
# satisified.
set debug_sync='now SIGNAL go1';
#
-# Switching to connection 'default'.
+connection default;
# Reaping ALTER TABLE.
# Add a new request for SNW lock to waiting graph.
# Sending:
alter table t1 drop column j;
#
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Wait until ALTER is blocked.
# Resume INSERT so it can start deadlock detection.
#
@@ -2148,10 +2178,10 @@ alter table t1 drop column j;
# and ended with ER_LOCK_DEADLOCK error.
set debug_sync='now SIGNAL go2';
#
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Reaping INSERT.
#
-# Switching to connection 'default'.
+connection default;
# Reaping ALTER. It should succeed and not produce ER_LOCK_DEADLOCK.
drop table t1;
#
@@ -2167,30 +2197,30 @@ create table t2(j int);
# waits in MDL and TDC.
#
set debug_sync= 'RESET';
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Start a statement, which will acquire SR metadata lock on t1, open it
# and then stop, before trying to acquire SW lock on t2 and opening it.
set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
# Sending:
select * from t1 where i in (select j from t2 for update);
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Wait till the above SELECT stops.
set debug_sync='now WAIT_FOR parked';
# The below FLUSH TABLES WITH READ LOCK should acquire
# SNW locks on t1 and t2 and wait till SELECT closes t1.
# Sending:
flush tables t1, t2 with read lock;
-# Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
# Wait until FLUSH TABLES WITH t1, t2 READ LOCK starts waiting
# for SELECT to close t1.
# Resume SELECT, so it tries to acquire SW lock on t1 and blocks,
# creating a deadlock. This deadlock should be detected and resolved
# by backing-off SELECT. As a result FTWRL should be able to finish.
set debug_sync='now SIGNAL go';
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Reap FLUSH TABLES WITH READ LOCK.
unlock tables;
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Reap SELECT.
i
#
@@ -2199,29 +2229,29 @@ i
# for flush waits is important.
#
set debug_sync= 'RESET';
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
set debug_sync='flush_tables_with_read_lock_after_acquire_locks SIGNAL parked WAIT_FOR go';
# The below FLUSH TABLES WITH READ LOCK should acquire
# SNW locks on t1 and t2 and wait on debug sync point.
# Sending:
flush tables t1, t2 with read lock;
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Wait till FLUSH TABLE WITH READ LOCK stops.
set debug_sync='now WAIT_FOR parked';
# Start statement which will acquire SR metadata lock on t1, open
# it and then will block while trying to acquire SW lock on t2.
# Sending:
select * from t1 where i in (select j from t2 for update);
-# Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
# Wait till the above SELECT blocks.
# Resume FLUSH TABLES, so it tries to flush t1, thus creating
# a deadlock. This deadlock should be detected and resolved by
# backing-off SELECT. As a result FTWRL should be able to finish.
set debug_sync='now SIGNAL go';
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Reap FLUSH TABLES WITH READ LOCK.
unlock tables;
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Reap SELECT.
i
#
@@ -2229,81 +2259,89 @@ i
# waiting for MDL and one for TDC.
#
set debug_sync= 'RESET';
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Start a statement which will acquire SR metadata lock on t2, open it
# and then stop, before trying to acquire SR on t1 and opening it.
set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
# Sending:
select * from t2, t1;
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Wait till the above SELECT stops.
set debug_sync='now WAIT_FOR parked';
# The below FLUSH TABLES WITH READ LOCK should acquire
# SNW locks on t2 and wait till SELECT closes t2.
# Sending:
flush tables t2 with read lock;
-# Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
# Wait until FLUSH TABLES WITH READ LOCK starts waiting
# for SELECT to close t2.
# The below DROP TABLES should acquire X lock on t1 and start
# waiting for X lock on t2.
# Sending:
drop tables t1, t2;
-# Switching to connection 'default'.
+connection default;
# Wait until DROP TABLES starts waiting for X lock on t2.
# Resume SELECT, so it tries to acquire SR lock on t1 and blocks,
# creating a deadlock. This deadlock should be detected and resolved
# by backing-off SELECT. As a result, FTWRL should be able to finish.
set debug_sync='now SIGNAL go';
-# Switching to connection 'deadlock_con2'.
+connection deadlock_con2;
# Reap FLUSH TABLES WITH READ LOCK.
# Unblock DROP TABLES.
unlock tables;
-# Switching to connection 'deadlock_con3'.
+connection deadlock_con3;
# Reap DROP TABLES.
-# Switching to connection 'deadlock_con1'.
+connection deadlock_con1;
# Reap SELECT. It should emit error about missing table.
ERROR 42S02: Table 'test.t2' doesn't exist
-# Switching to connection 'default'.
+connection default;
set debug_sync= 'RESET';
+disconnect deadlock_con1;
+disconnect deadlock_con2;
+disconnect deadlock_con3;
#
# Test for a scenario in which FLUSH TABLES <list> WITH READ LOCK
# used to erroneously release metadata locks.
#
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection default;
drop tables if exists t1, t2;
set debug_sync= 'RESET';
create table t1(i int);
create table t2(j int);
-# Switching to connection 'con2'.
+connection con2;
set debug_sync='open_tables_after_open_and_process_table SIGNAL parked WAIT_FOR go';
# The below FLUSH TABLES <list> WITH READ LOCK should acquire
# SNW locks on t1 and t2, open table t1 and block on the debug
# sync point.
# Sending:
flush tables t1, t2 with read lock;
-# Switching to connection 'con1'.
+connection con1;
# Wait till FLUSH TABLES <list> WITH READ LOCK stops.
set debug_sync='now WAIT_FOR parked';
# Start a statement which will flush all tables and thus
# invalidate table t1 open by FLUSH TABLES <list> WITH READ LOCK.
# Sending:
flush tables;
-# Switching to connection 'default'.
+connection default;
# Wait till the above FLUSH TABLES blocks.
# Resume FLUSH TABLES <list> WITH READ LOCK, so it tries to open t2
# discovers that its t1 is obsolete and tries to reopen all tables.
# Such reopen should not cause releasing of SNW metadata locks
# which would result in assertion failures.
set debug_sync='now SIGNAL go';
-# Switching to connection 'con2'.
+connection con2;
# Reap FLUSH TABLES <list> WITH READ LOCK.
unlock tables;
-# Switching to connection 'con1'.
+connection con1;
# Reap FLUSH TABLES.
# Clean-up.
-# Switching to connection 'default'.
+connection default;
drop tables t1, t2;
set debug_sync= 'RESET';
+disconnect con1;
+disconnect con2;
#
# Test for bug #46748 "Assertion in MDL_context::wait_for_locks()
# on INSERT + CREATE TRIGGER".
@@ -2312,6 +2350,9 @@ drop tables if exists t1, t2, t3, t4, t5;
# Let us simulate scenario in which we open some tables from extended
# part of prelocking set but then encounter conflicting metadata lock,
# so have to back-off and wait for it to go away.
+connect con1root,localhost,root,,test,,;
+connect con2root,localhost,root,,test,,;
+connection default;
create table t1 (i int);
create table t2 (j int);
create table t3 (k int);
@@ -2321,31 +2362,33 @@ insert into t2 values (new.i);
create trigger t2_bi before insert on t2 for each row
insert into t3 values (new.j);
#
-# Switching to connection 'con1root'.
+connection con1root;
lock tables t4 read;
#
-# Switching to connection 'con2root'.
+connection con2root;
# Send :
rename table t3 to t5, t4 to t3;;
#
-# Switching to connection 'default'.
+connection default;
# Wait until the above RENAME TABLE adds pending requests for exclusive
# metadata lock on its tables and blocks due to 't4' being used by LOCK
# TABLES.
# Send :
insert into t1 values (1);;
#
-# Switching to connection 'con1root'.
+connection con1root;
# Wait until INSERT statement waits due to encountering pending
# exclusive metadata lock on 't3'.
unlock tables;
#
-# Switching to connection 'con2root'.
+connection con2root;
# Reap RENAME TABLE.
#
-# Switching to connection 'default'.
+connection default;
# Reap INSERT.
# Clean-up.
+disconnect con1root;
+disconnect con2root;
drop tables t1, t2, t3, t5;
#
# Bug#42546 - Backup: RESTORE fails, thinking it finds an existing table
@@ -2353,15 +2396,16 @@ drop tables t1, t2, t3, t5;
DROP TABLE IF EXISTS t1;
set @save_log_output=@@global.log_output;
set global log_output=file;
+connect con2, localhost, root,,;
#
# Test 1: CREATE TABLE
#
-# Connection 2
+connection con2;
# Start insert on the not-yet existing table
# Wait after taking the MDL lock
SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
INSERT INTO t1 VALUES(1,"def");
-# Connection 1
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Now INSERT has a MDL on the non-existent table t1.
#
@@ -2369,10 +2413,10 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked';
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL finish';
# Try to create that table.
CREATE TABLE t1 (c1 INT, c2 VARCHAR(100), KEY(c1));
-# Connection 2
# Insert fails
+connection con2;
ERROR 42S02: Table 'test.t1' doesn't exist
-# Connection 1
+connection default;
SET DEBUG_SYNC= 'RESET';
SHOW TABLES;
Tables_in_test
@@ -2382,12 +2426,12 @@ DROP TABLE IF EXISTS t1;
# Test 2: CREATE TABLE LIKE
#
CREATE TABLE t2 (c1 INT, c2 VARCHAR(100), KEY(c1));
-# Connection 2
+connection con2;
# Start insert on the not-yet existing table
# Wait after taking the MDL
SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked WAIT_FOR finish';
INSERT INTO t1 VALUES(1,"def");
-# Connection 1
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Now INSERT has a MDL on the non-existent table t1.
#
@@ -2395,16 +2439,17 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked';
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL finish';
# Try to create that table.
CREATE TABLE t1 LIKE t2;
-# Connection 2
# Insert fails
+connection con2;
ERROR 42S02: Table 'test.t1' doesn't exist
-# Connection 1
+connection default;
SET DEBUG_SYNC= 'RESET';
SHOW TABLES;
Tables_in_test
t1
t2
DROP TABLE t2;
+disconnect con2;
DROP TABLE IF EXISTS t1;
set global log_output=@save_log_output;
#
@@ -2412,20 +2457,24 @@ set global log_output=@save_log_output;
# FOR UPDATE"
#
drop tables if exists t1, t2;
+connect con46044, localhost, root,,;
+connect con46044_2, localhost, root,,;
+connect con46044_3, localhost, root,,;
+connection default;
create table t1 (i int);
insert into t1 values(1);
# Let us check that we won't deadlock if during filling
# of I_S table we encounter conflicting metadata lock
# which owner is in its turn waiting for our connection.
lock tables t1 read;
-# Switching to connection 'con46044_2'.
+connection con46044_2;
# Sending:
update t1 set i = 2;
-# Switching to connection 'con46044'.
+connection con46044;
# Waiting until UPDATE t1 SET ... is blocked.
# Sending:
create table t2 select * from t1;;
-# Switching to connection 'default'.
+connection default;
# Waiting until CREATE TABLE ... SELECT ... is blocked.
# First let us check that SHOW FIELDS/DESCRIBE doesn't
# gets blocked and emits and error.
@@ -2449,11 +2498,12 @@ table_name table_type auto_increment table_comment
t2 BASE TABLE NULL Table 'test'.'t2' was skipped since its definition is being modified by concurrent DDL statement
Warnings:
Warning 1684 Table 'test'.'t2' was skipped since its definition is being modified by concurrent DDL statement
-# Switching to connection 'default'.
+connection default;
unlock tables;
-# Switching to connection 'con46044'.
+connection con46044;
# Reaping CREATE TABLE ... SELECT ... .
drop table t2;
+connection con46044_2;
# Reaping UPDATE t1 statement
#
# Let us also check that queries to I_S wait for conflicting metadata
@@ -2462,84 +2512,90 @@ drop table t2;
# and ease of use points of view.
#
# We check same three queries to I_S in this new situation.
-# Switching to connection 'con46044_2'.
+connection con46044_2;
lock tables t1 read;
-# Switching to connection 'con46044_3'.
+connection con46044_3;
# Sending:
update t1 set i = 3;
-# Switching to connection 'con46044'.
+connection con46044;
# Waiting until UPDATE t1 SET ... is blocked.
# Sending:
create table t2 select * from t1;;
-# Switching to connection 'default'.
+connection default;
# Waiting until CREATE TABLE ... SELECT ... is blocked.
# Let us check that SHOW FIELDS/DESCRIBE gets blocked.
# Sending:
show fields from t2;;
-# Switching to connection 'con46044_2'.
+connection con46044_2;
# Wait until SHOW FIELDS gets blocked.
unlock tables;
-# Switching to connection 'con46044'.
+connection con46044;
# Reaping CREATE TABLE ... SELECT ... .
-# Switching to connection 'default'.
+connection default;
# Reaping SHOW FIELDS ...
Field Type Null Key Default Extra
i int(11) YES NULL
drop table t2;
+connection con46044_3;
# Reaping UPDATE t1 statement
-# Switching to connection 'con46044_2'.
+connection con46044_2;
lock tables t1 read;
-# Switching to connection 'con46044_3'.
+connection con46044_3;
# Sending:
update t1 set i = 4;
-# Switching to connection 'con46044'.
+connection con46044;
# Waiting until UPDATE t1 SET ... is blocked.
# Sending:
create table t2 select * from t1;;
-# Switching to connection 'default'.
+connection default;
# Waiting until CREATE TABLE ... SELECT ... is blocked.
# Check that I_S query which reads only .FRMs gets blocked.
# Sending:
select column_name from information_schema.columns where table_schema='test' and table_name='t2';;
-# Switching to connection 'con46044_2'.
+connection con46044_2;
# Wait until SELECT COLUMN_NAME FROM I_S.COLUMNS gets blocked.
unlock tables;
-# Switching to connection 'con46044'.
+connection con46044;
# Reaping CREATE TABLE ... SELECT ... .
-# Switching to connection 'default'.
+connection default;
# Reaping SELECT COLUMN_NAME FROM I_S.COLUMNS
column_name
i
drop table t2;
+connection con46044_3;
# Reaping UPDATE t1 statement
-# Switching to connection 'con46044_2'.
+connection con46044_2;
lock tables t1 read;
-# Switching to connection 'con46044_3'.
+connection con46044_3;
# Sending:
update t1 set i = 5;
-# Switching to connection 'con46044'.
+connection con46044;
# Waiting until UPDATE t1 SET ... is blocked.
# Sending:
create table t2 select * from t1;;
-# Switching to connection 'default'.
+connection default;
# Waiting until CREATE TABLE ... SELECT ... is blocked.
# Finally, check that I_S query which does full-blown table open
# also gets blocked.
# Sending:
select table_name, table_type, auto_increment, table_comment from information_schema.tables where table_schema='test' and table_name='t2';;
-# Switching to connection 'con46044_2'.
+connection con46044_2;
# Wait until SELECT ... FROM I_S.TABLES gets blocked.
unlock tables;
-# Switching to connection 'con46044'.
+connection con46044;
# Reaping CREATE TABLE ... SELECT ... .
-# Switching to connection 'default'.
+connection default;
# Reaping SELECT ... FROM I_S.TABLES
table_name table_type auto_increment table_comment
t2 BASE TABLE NULL
drop table t2;
+connection con46044_3;
# Reaping UPDATE t1 statement
-# Switching to connection 'default'.
+connection default;
# Clean-up.
+disconnect con46044;
+disconnect con46044_2;
+disconnect con46044_3;
drop table t1;
#
# Test for bug #46273 "MySQL 5.4.4 new MDL: Bug#989 is not fully fixed
@@ -2547,6 +2603,8 @@ drop table t1;
#
drop table if exists t1;
set debug_sync= 'RESET';
+connect con46273,localhost,root,,test,,;
+connection default;
create table t1 (c1 int primary key, c2 int, c3 int);
insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0);
begin;
@@ -2554,11 +2612,11 @@ select * from t1 where c2 = 3;
c1 c2 c3
3 3 0
#
-# Switching to connection 'con46273'.
+connection con46273;
set debug_sync='alter_table_copy_after_lock_upgrade SIGNAL alter_table_locked WAIT_FOR alter_go';
alter table t1 add column e int, rename to t2;;
#
-# Switching to connection 'default'.
+connection default;
set debug_sync='now WAIT_FOR alter_table_locked';
set debug_sync='mdl_acquire_lock_wait SIGNAL alter_go';
# The below statement should get ER_LOCK_DEADLOCK error
@@ -2567,10 +2625,11 @@ set debug_sync='mdl_acquire_lock_wait SIGNAL alter_go';
update t1 set c3=c3+1 where c2 = 3;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
#
-# Switching to connection 'con46273'.
+connection con46273;
# Reap ALTER TABLE.
#
-# Switching to connection 'default'.
+connection default;
+disconnect con46273;
# Clean-up.
set debug_sync= 'RESET';
drop table t2;
@@ -2579,64 +2638,70 @@ drop table t2;
# and DML".
#
drop tables if exists t1;
+connect con46673, localhost, root,,;
+connection default;
create table t1 (i int);
-# Switching to connection 'con46673'.
+connection con46673;
begin;
insert into t1 values (1);
-# Switching to connection 'default'.
+connection default;
# Statement below should not get blocked. And if after some
# changes to code it is there should not be a deadlock between
# it and transaction from connection 'con46673'.
flush tables with read lock;
unlock tables;
-# Switching to connection 'con46673'.
+connection con46673;
delete from t1 where i = 1;
commit;
-# Switching to connection 'default'.
+connection default;
# Clean-up
+disconnect con46673;
drop table t1;
#
# Bug#48210 FLUSH TABLES WITH READ LOCK deadlocks
# against concurrent CREATE PROCEDURE
#
+connect con2, localhost, root;
# Test 1: CREATE PROCEDURE
-# Connection 1
+connection default;
# Start CREATE PROCEDURE and open mysql.proc
SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait';
CREATE PROCEDURE p1() SELECT 1;
-# Connection 2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR table_opened';
# Check that FLUSH must wait to get the GRL
# and let CREATE PROCEDURE continue
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait';
FLUSH TABLES WITH READ LOCK;
-# Connection 1
-# Connection 2
+connection default;
+connection con2;
UNLOCK TABLES;
-# Connection 1
+connection default;
SET DEBUG_SYNC= 'RESET';
# Test 2: DROP PROCEDURE
+connection default;
# Start DROP PROCEDURE and open tables
SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait';
DROP PROCEDURE p1;
-# Connection 2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR table_opened';
# Check that FLUSH must wait to get the GRL
# and let DROP PROCEDURE continue
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL grlwait';
FLUSH TABLES WITH READ LOCK;
-# Connection 1
+connection default;
# Once FLUSH TABLES WITH READ LOCK starts waiting
# DROP PROCEDURE will be waked up and will drop
# procedure. Global read lock will be granted after
# this statement ends.
#
# Reaping DROP PROCEDURE.
-# Connection 2
+connection con2;
# Reaping FTWRL.
UNLOCK TABLES;
-# Connection 1
+connection default;
SET DEBUG_SYNC= 'RESET';
+disconnect con2;
#
# Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null'
# failed in open_ltable()
@@ -2644,6 +2709,10 @@ SET DEBUG_SYNC= 'RESET';
# Supress warnings written to the log file
call mtr.add_suppression("Wait on a lock was aborted due to a pending exclusive lock");
DROP TABLE IF EXISTS t1, t2;
+connect con1,localhost,root;
+connect con2,localhost,root;
+connect con3,localhost,root;
+connection default;
CREATE TABLE t1 (i INT);
CREATE TABLE t2 (i INT);
SET @old_general_log= @@global.general_log;
@@ -2653,34 +2722,47 @@ SET @@global.log_output= 'TABLE';
SET @old_sql_log_off= @@session.sql_log_off;
SET @@session.sql_log_off= 1;
# connection: con1
+connection con1;
HANDLER t1 OPEN;
# connection: con3
+connection con3;
SET @@session.sql_log_off= 1;
# connection: con2
+connection con2;
SET DEBUG_SYNC= 'thr_multi_lock_after_thr_lock SIGNAL parked WAIT_FOR go';
# Sending:
SELECT 1;
# connection: con3
+connection con3;
SET DEBUG_SYNC= 'now WAIT_FOR parked';
# connection: con1
+connection con1;
# Sending:
SELECT 1;
# connection: con3
+connection con3;
ALTER TABLE t1 ADD COLUMN j INT;
# connection: default
+connection default;
SET DEBUG_SYNC= 'now SIGNAL go';
# connection: con1
+connection con1;
# Reaping SELECT 1
1
1
HANDLER t1 CLOSE;
# connection: con2
+connection con2;
# Reaping SELECT 1
1
1
# connection: default
+connection default;
DROP TABLE t1, t2;
SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+disconnect con2;
+disconnect con3;
SET @@global.general_log= @old_general_log;
SET @@global.log_output= @old_log_output;
SET @@session.sql_log_off= @old_sql_log_off;
@@ -2691,12 +2773,15 @@ SET @@session.sql_log_off= @old_sql_log_off;
#
drop table if exists t1;
set debug_sync= 'RESET';
+connect con50913_1,localhost,root;
+connect con50913_2,localhost,root;
+connection default;
create table t1 (i int) engine=InnoDB;
-# Switching to connection 'con50913_1'.
+connection con50913_1;
set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL parked WAIT_FOR go';
# Sending:
alter table t1 add column j int, ALGORITHM=COPY;
-# Switching to connection 'default'.
+connection default;
# Wait until ALTER TABLE gets blocked on a sync point after
# acquiring thr_lock.c lock.
set debug_sync= 'now WAIT_FOR parked';
@@ -2704,14 +2789,16 @@ set debug_sync= 'now WAIT_FOR parked';
# thr_lock.c lock.
# Sending:
truncate table t1;
-# Switching to connection 'con50913_2'.
+connection con50913_2;
# Wait until TRUNCATE TABLE is blocked on MDL lock.
# Unblock ALTER TABLE.
set debug_sync= 'now SIGNAL go';
-# Switching to connection 'con50913_1'.
+connection con50913_1;
# Reaping ALTER TABLE.
-# Switching to connection 'default'.
+connection default;
# Reaping TRUNCATE TABLE.
+disconnect con50913_1;
+disconnect con50913_2;
set debug_sync= 'RESET';
drop table t1;
#
@@ -2723,30 +2810,34 @@ drop table t1;
# should be performed.
drop table if exists t1;
set debug_sync= 'RESET';
+connect con1,localhost,root;
+connect con2,localhost,root;
+connect con3,localhost,root;
+connection default;
create table t1 (i int);
-# Switching to connection 'con1'.
+connection con1;
begin;
select * from t1;
i
-# Switching to connection 'con2'.
+connection con2;
begin;
select * from t1;
i
-# Switching to connection 'default'.
+connection default;
# Start ALTER TABLE which will acquire SNW lock and
# table lock and get blocked on sync point.
set debug_sync= 'alter_table_copy_after_lock_upgrade SIGNAL parked WAIT_FOR go';
# Sending:
alter table t1 add column j int;
-# Switching to connection 'con1'.
+connection con1;
# Wait until ALTER TABLE gets blocked on a sync point.
set debug_sync= 'now WAIT_FOR parked';
# Sending:
insert into t1 values (1);
-# Switching to connection 'con2'.
+connection con2;
# Sending:
insert into t1 values (1);
-# Switching to connection 'con3'.
+connection con3;
# Wait until both 'con1' and 'con2' are blocked trying to acquire
# SW lock on the table.
# Unblock ALTER TABLE. Since it will try to upgrade SNW to X lock
@@ -2754,17 +2845,21 @@ insert into t1 values (1);
# should be found and DML statements in both 'con1' and 'con2'
# should be aborted with ER_LOCK_DEADLOCK errors.
set debug_sync= 'now SIGNAL go';
-# Switching to connection 'con1'.
+connection con1;
# Reaping INSERT. It should end with ER_LOCK_DEADLOCK error and
# not wait indefinitely (as it happened before the bugfix).
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
commit;
-# Switching to connection 'con2'.
+connection con2;
# Reaping INSERT.
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
commit;
-# Switching to connection 'default'.
+connection default;
# Reap ALTER TABLE.
+disconnect con1;
+disconnect con2;
+disconnect con3;
+connection default;
set debug_sync= 'RESET';
drop table t1;
#
@@ -2772,137 +2867,151 @@ drop table t1;
#
# Ensure that a acquired lock is not given up due to a conflict.
#
+connect con1,localhost,root,,test,,;
+connect con2,localhost,root,,test,,;
+connect con3,localhost,root,,test,,;
+connection default;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2),(3);
-# Connection: con1
+connection con1;
LOCK TABLES t1 WRITE;
SET debug_sync='upgrade_lock_for_truncate SIGNAL parked_truncate WAIT_FOR go_truncate';
TRUNCATE TABLE t1;
-# Connection: default
+connection default;
SET debug_sync='now WAIT_FOR parked_truncate';
-# Connection: con2
+connection con2;
SET debug_sync='after_open_table_ignore_flush SIGNAL parked_show WAIT_FOR go_show';
SHOW FIELDS FROM t1;
-# Connection: default
+connection default;
SET debug_sync='now WAIT_FOR parked_show';
-# Connection: con3
+connection con3;
SET debug_sync='after_flush_unlock SIGNAL parked_flush WAIT_FOR go_flush';
FLUSH TABLES t1;
-# Connection: default
+connection default;
SET debug_sync='now WAIT_FOR parked_flush';
SET debug_sync='now SIGNAL go_truncate';
# Ensure that truncate waits for a exclusive lock
SET debug_sync= 'now SIGNAL go_show';
-# Connection: con1 (TRUNCATE)
+connection con1;
# Reaping...
UNLOCK TABLES;
-# Connection: con2 (SHOW FIELDS FROM t1)
+connection con2;
# Reaping...
Field Type Null Key Default Extra
a int(11) YES NULL
-# Connection: default
+connection default;
SET debug_sync= 'now SIGNAL go_flush';
-# Connection: con3 (FLUSH TABLES t1)
+connection con3;
# Reaping...
-# Connection: default
+disconnect con1;
+disconnect con2;
+disconnect con3;
+connection default;
SET debug_sync= 'RESET';
DROP TABLE t1;
#
# Bug#52856 concurrent show columns or show full columns causes a crash!!!
#
CREATE TABLE t1(a CHAR(255));
+connect con1, localhost, root;
SET DEBUG_SYNC= "get_schema_column SIGNAL waiting WAIT_FOR completed";
SHOW FULL COLUMNS FROM t1;
+connection default;
SET DEBUG_SYNC= "now WAIT_FOR waiting";
SHOW FULL COLUMNS FROM t1;
Field Type Collation Null Key Default Extra Privileges Comment
a char(255) latin1_swedish_ci YES NULL #
SET DEBUG_SYNC= "now SIGNAL completed";
+connection con1;
Field Type Collation Null Key Default Extra Privileges Comment
a char(255) latin1_swedish_ci YES NULL #
+connection default;
DROP TABLE t1;
+disconnect con1;
#
# Tests for schema-scope locks
#
DROP DATABASE IF EXISTS db1;
DROP DATABASE IF EXISTS db2;
+connect con2, localhost, root;
+connect con3, localhost, root;
# Test 1:
# CREATE DATABASE blocks database DDL on the same database, but
# not database DDL on different databases. Tests X vs X lock.
#
-# Connection default
+connection default;
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
CREATE DATABASE db1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
CREATE DATABASE db1;
-# Connection con3
+connection con3;
CREATE DATABASE db2;
ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
DROP DATABASE db2;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: CREATE DATABASE db1
-# Connection con2
+connection con2;
# Reaping: CREATE DATABASE db1
ERROR HY000: Can't create database 'db1'; database exists
# Test 2:
# ALTER DATABASE blocks database DDL on the same database, but
# not database DDL on different databases. Tests X vs X lock.
#
-# Connection default
+connection default;
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
-# Connection con3
+connection con3;
CREATE DATABASE db2;
ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
DROP DATABASE db2;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
-# Connection con2
+connection con2;
# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
-# Connection default
+connection default;
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
DROP DATABASE db1;
-# Connection con3
+connection con3;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
-# Connection con2
+connection con2;
# Reaping: DROP DATABASE db1
CREATE DATABASE db1;
# Test 3:
# Two ALTER..UPGRADE of the same database are mutually exclusive, but
# two ALTER..UPGRADE of different databases are not. Tests X vs X lock.
#
-# Connection default
+connection default;
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;
-# Connection con3
+connection con3;
ALTER DATABASE `#mysql50#a-b-c-d` UPGRADE DATA DIRECTORY NAME;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
-# Connection con2
+connection con2;
# Reaping: ALTER DATABASE '#mysql50#a-b-c' UPGRADE DATA DIRECTORY NAME
ERROR 42000: Unknown database '#mysql50#a-b-c'
DROP DATABASE `a-b-c`;
@@ -2911,96 +3020,96 @@ DROP DATABASE `a-b-c-d`;
# DROP DATABASE blocks database DDL on the same database, but
# not database DDL on different databases. Tests X vs X lock.
#
-# Connection default
+connection default;
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
DROP DATABASE db1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
DROP DATABASE db1;
-# Connection con3
+connection con3;
CREATE DATABASE db2;
ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
DROP DATABASE db2;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: DROP DATABASE db1
-# Connection con2
+connection con2;
# Reaping: DROP DATABASE db1
ERROR HY000: Can't drop database 'db1'; database doesn't exist
-# Connection default
+connection default;
CREATE DATABASE db1;
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
DROP DATABASE db1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
-# Connection con3
+connection con3;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: DROP DATABASE db1
-# Connection con2
+connection con2;
# Reaping: ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
Got one of the listed errors
# Test 5:
# Locked database name prevents CREATE of tables in that database.
# Tests X vs IX lock.
#
-# Connection default
+connection default;
CREATE DATABASE db1;
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
DROP DATABASE db1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
CREATE TABLE db1.t1 (a INT);
-# Connection con3
+connection con3;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: DROP DATABASE db1
-# Connection con2
+connection con2;
# Reaping: CREATE TABLE db1.t1 (a INT)
ERROR 42000: Unknown database 'db1'
# Test 6:
# Locked database name prevents RENAME of tables to/from that database.
# Tests X vs IX lock.
#
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE TABLE db1.t1 (a INT);
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
DROP DATABASE db1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
RENAME TABLE db1.t1 TO test.t1;
-# Connection con3
+connection con3;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: DROP DATABASE db1
-# Connection con2
+connection con2;
# Reaping: RENAME TABLE db1.t1 TO test.t1
ERROR 42S02: Table 'db1.t1' doesn't exist
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE TABLE test.t2 (a INT);
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
DROP DATABASE db1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
RENAME TABLE test.t2 TO db1.t2;
-# Connection con3
+connection con3;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: DROP DATABASE db1
-# Connection con2
+connection con2;
# Reaping: RENAME TABLE test.t2 TO db1.t2
Got one of the listed errors
DROP TABLE test.t2;
@@ -3008,24 +3117,26 @@ DROP TABLE test.t2;
# Locked database name prevents DROP of tables in that database.
# Tests X vs IX lock.
#
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE TABLE db1.t1 (a INT);
SET DEBUG_SYNC= 'after_wait_locked_schema_name SIGNAL locked WAIT_FOR blocked';
# Sending:
DROP DATABASE db1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# Sending:
DROP TABLE db1.t1;
-# Connection con3
+connection con3;
SET DEBUG_SYNC= 'now SIGNAL blocked';
-# Connection default
+connection default;
# Reaping: DROP DATABASE db1
-# Connection con2
+connection con2;
# Reaping: DROP TABLE db1.t1
ERROR 42S02: Unknown table 'db1.t1'
-# Connection default
+connection default;
+disconnect con2;
+disconnect con3;
SET DEBUG_SYNC= 'RESET';
#
# End of tests for schema-scope locks
@@ -3035,30 +3146,34 @@ SET DEBUG_SYNC= 'RESET';
#
CREATE DATABASE db1;
CREATE TABLE db1.t1(a INT);
-# Connection default
+connect con2, localhost, root;
+connect con3, localhost, root;
+connection default;
FLUSH TABLE WITH READ LOCK;
-# Connection con2
+connection con2;
CREATE TABLE db1.t2(a INT);
-# Connection default
+connection default;
UNLOCK TABLES;
-# Connection con2
+connection con2;
# Reaping CREATE TABLE db1.t2(a INT)
-# Connection default
+connection default;
FLUSH TABLE WITH READ LOCK;
-# Connection con2
+connection con2;
ALTER DATABASE db1 DEFAULT CHARACTER SET utf8;
-# Connection default
+connection default;
UNLOCK TABLES;
-# Connection con2
+connection con2;
# Reaping ALTER DATABASE db1 DEFAULT CHARACTER SET utf8
-# Connection default
+connection default;
FLUSH TABLE WITH READ LOCK;
-# Connection con2
+connection con2;
FLUSH TABLE WITH READ LOCK;
UNLOCK TABLES;
-# Connection default
+connection default;
UNLOCK TABLES;
DROP DATABASE db1;
+disconnect con2;
+disconnect con3;
#
# Bug#56292 Deadlock with ALTER TABLE and MERGE tables
#
@@ -3068,35 +3183,43 @@ CREATE TABLE t2(a INT) engine=MyISAM;
CREATE TABLE m1(a INT) engine=MERGE UNION=(t1, t2);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (3), (4);
-# Connection con1
+connect con1, localhost, root;
+connect con2, localhost, root;
+connect con3, localhost, root;
+connection con1;
# We need EXECUTE 2 since ALTER TABLE does SU => SNW => X and we want
# to stop at the second upgrade.
SET DEBUG_SYNC= 'mdl_upgrade_lock SIGNAL upgrade WAIT_FOR continue EXECUTE 2';
# Sending:
ALTER TABLE m1 engine=MERGE UNION=(t2, t1);
-# Connection con2
+connection con2;
# Waiting for ALTER TABLE to try lock upgrade
SET DEBUG_SYNC= 'now WAIT_FOR upgrade';
SET DEBUG_SYNC= 'now SIGNAL continue';
SET DEBUG_SYNC= 'now WAIT_FOR upgrade';
# Sending:
DELETE FROM t2 WHERE a = 3;
-# Connection default
+connection con3;
# Check that DELETE is waiting on a metadata lock and not a table lock.
# Now that DELETE blocks on a metadata lock, we should be able to do
# SELECT * FROM m1 here. SELECT used to be blocked by a DELETE table
# lock request.
SELECT * FROM m1 WHERE a < 3;
+connection default;
# Resuming ALTER TABLE
SET DEBUG_SYNC= 'now SIGNAL continue';
-# Connection con1
+connection con1;
# Reaping: ALTER TABLE m1 engine=MERGE UNION=(t2, t1)
-# Connection con2
+connection con2;
# Reaping: DELETE FROM t2 WHERE a = 3
+connection con3;
# Reaping: SELECT * FROM m1 WHERE a < 3
a
1
2
-# Connection default
+connection default;
DROP TABLE m1, t1, t2;
SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+disconnect con2;
+disconnect con3;
diff --git a/mysql-test/r/merge-big.result b/mysql-test/r/merge-big.result
index b17140a7c79..3b6e116986e 100644
--- a/mysql-test/r/merge-big.result
+++ b/mysql-test/r/merge-big.result
@@ -6,11 +6,11 @@ drop table if exists t1,t2,t3,t4,t5,t6;
#
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
LOCK TABLE t1 WRITE;
-# connection con1
+connect con1,localhost,root,,;
SET @orig_debug=@@debug;
SET GLOBAL debug_dbug="+d,sleep_open_and_lock_after_open";
INSERT INTO t1 VALUES (1);
-# connection default
+connection default;
# Let INSERT go into thr_multi_lock().
# Kick INSERT out of thr_multi_lock().
FLUSH TABLES;
@@ -21,7 +21,8 @@ FLUSH TABLES;
SELECT * FROM t1;
c1
UNLOCK TABLES;
-# connection con1
+connection con1;
SET GLOBAL debug_dbug=@orig_debug;
-# connection default
+disconnect con1;
+connection default;
DROP TABLE t1;
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 804313af701..93b16896380 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -1121,31 +1121,46 @@ c1
2
UNLOCK TABLES;
DROP TABLE t1, t2, t3, t4;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection default;
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST;
REPAIR TABLE t1;
+connection con1;
INSERT INTO t2 VALUES (1);
+connection default;
Table Op Msg_type Msg_text
test.t1 repair status OK
DROP TABLE t1, t2;
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST;
LOCK TABLE t1 WRITE;
+connection con1;
INSERT INTO t2 VALUES (1);
+connection default;
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
UNLOCK TABLES;
+connection con1;
+connection default;
DROP TABLE t1, t2;
CREATE TABLE t1 (c1 INT) ENGINE= MyISAM;
LOCK TABLE t1 WRITE;
+connection con1;
INSERT INTO t1 VALUES (1);
+connection default;
FLUSH TABLES;
FLUSH TABLES;
SELECT * FROM t1;
c1
UNLOCK TABLES;
+connection con1;
+connection default;
DROP TABLE t1;
+disconnect con1;
+disconnect con2;
#
# Extra tests for Bug#26379 - Combination of FLUSH TABLE and
# REPAIR TABLE corrupts a MERGE table
@@ -1964,9 +1979,14 @@ COUNT(*)
SELECT COUNT(*) FROM t3;
COUNT(*)
210
+connect con1,localhost,root,,;
SELECT COUNT(DISTINCT a1.id) FROM t3 AS a1, t3 AS a2
WHERE a1.id = a2.id GROUP BY a2.grp;
+connection default;
TRUNCATE TABLE t1;
+connection con1;
+disconnect con1;
+connection default;
SELECT COUNT(*) FROM t1;
COUNT(*)
0
@@ -2824,10 +2844,15 @@ INSERT INTO t2 VALUES(2);
INSERT INTO t3 VALUES(3);
INSERT INTO t4 VALUES(4);
INSERT INTO t5 VALUES(5);
+connect con1,localhost,root,,;
UPDATE t2, tm1 SET t2.c1=f1();
+connection default;
FLUSH TABLES;
FLUSH TABLES;
UNLOCK TABLES;
+connection con1;
+disconnect con1;
+connection default;
SELECT * FROM tm1;
c1
1
@@ -3556,7 +3581,7 @@ DROP TABLE t1, t2, t3, t4, m1, m2;
# HANDLER ... OPEN.
# The general case.
DROP TABLE IF EXISTS t1, t2, t3;
-# Connection con1.
+connect con1,localhost,root,,;
CREATE TABLE t1 (c1 int);
CREATE TABLE t2 (c1 int);
CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
@@ -3564,10 +3589,11 @@ START TRANSACTION;
HANDLER t3 OPEN;
ERROR HY000: Storage engine MRG_MyISAM of the table `test`.`t3` doesn't have this option
DROP TABLE t1, t2, t3;
-# Connection default.
-# Disconnecting con1, all mdl_tickets must have been released.
+connection default;
+# all mdl_tickets must have been released.
+disconnect con1;
# The bug-specific case.
-# Connection con1.
+connect con1,localhost,root,,;
CREATE TABLE t1 (c1 int);
CREATE TABLE t2 (c1 int);
CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2);
@@ -3576,8 +3602,9 @@ START TRANSACTION;
HANDLER t3 OPEN;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t1, t3;
-# Connection default.
-# Disconnecting con1, all mdl_tickets must have been released.
+connection default;
+# all mdl_tickets must have been released.
+disconnect con1;
#
# A test case for Bug#47648 main.merge fails sporadically
#
diff --git a/mysql-test/r/mix2_myisam.result b/mysql-test/r/mix2_myisam.result
index bf706b1445d..25434b71ca2 100644
--- a/mysql-test/r/mix2_myisam.result
+++ b/mysql-test/r/mix2_myisam.result
@@ -2064,23 +2064,36 @@ delete t1 from t1,t2 where f1=f3 and f4='cc';
select * from t1;
f1 f2
drop table t1,t2;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connection a;
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
insert into t1(a) values (1),(2),(3);
commit;
+connection b;
set autocommit = 0;
update t1 set b = 5 where a = 2;
commit;
+connection a;
create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
set autocommit = 0;
+connection a;
insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
+connection b;
commit;
+connection a;
commit;
drop trigger t1t;
drop table t1;
+disconnect a;
+disconnect b;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connection a;
create table t1(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
create table t2(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
create table t3(a int not null, b int, c int, d int, primary key(a)) engine=MyISAM;
@@ -2113,6 +2126,7 @@ update t3 set b = b + 5 where a = 1;
update t4 set b = b + 5 where a = 1;
insert into t5(a) values(20);
commit;
+connection b;
set autocommit = 0;
insert into t1(a) values(7);
insert into t2(a) values(8);
@@ -2124,6 +2138,9 @@ drop trigger t2t;
drop trigger t3t;
drop trigger t4t;
drop table t1, t2, t3, t4, t5;
+connection default;
+disconnect a;
+disconnect b;
create table t1(a date) engine=MyISAM;
create table t2(a date, key(a)) engine=MyISAM;
insert into t1 values('2005-10-01');
@@ -2148,20 +2165,29 @@ select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
where mm.id is null lock in share mode;
id f_id f
drop table t1,t2;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connection a;
create table t1(a int not null, b int, primary key(a)) engine=MyISAM;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
update t1 set b = 5 where b = 1;
+connection b;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
select * from t1 where a = 7 and b = 3 for update;
a b
7 3
+connection a;
commit;
+connection b;
commit;
drop table t1;
+connection default;
+disconnect a;
+disconnect b;
CREATE TABLE t1 ( a int ) ENGINE=MyISAM;
BEGIN;
INSERT INTO t1 VALUES (1);
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index c680339536b..204596bf20b 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -418,6 +418,8 @@ select * from t2;
c2_id c2_p_id c2_note c2_active
1 1 A Note 1
drop table t1, t2;
+connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int, primary key (a));
create table mysqltest.t2 (a int, b int, primary key (a));
@@ -425,12 +427,18 @@ create table mysqltest.t3 (a int, b int, primary key (a));
create user mysqltest_1@localhost;
grant select on mysqltest.* to mysqltest_1@localhost;
grant update on mysqltest.t1 to mysqltest_1@localhost;
+connect user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user1;
update t1, t2 set t1.b=1 where t1.a=t2.a;
update t1, t2 set t1.b=(select t3.b from t3 where t1.a=t3.a) where t1.a=t2.a;
+connection root;
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;
create table t1 (a int, primary key (a));
create table t2 (a int, primary key (a));
create table t3 (a int, primary key (a));
@@ -487,10 +495,19 @@ insert into t1 values (1, 2), (2, 3), (3, 4);
create table t2 (a int);
insert into t2 values (10), (20), (30);
create view v1 as select a as b, a/10 as a from t2;
+connect locker,localhost,root,,test;
+connection locker;
lock table t1 write;
+connect changer,localhost,root,,test;
+connection changer;
alter table t1 add column c int default 100 after a;
+connect updater,localhost,root,,test;
+connection updater;
update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
+connection locker;
unlock tables;
+connection changer;
+connection updater;
select * from t1;
a c b
1 100 13
@@ -503,6 +520,10 @@ a
30
drop view v1;
drop table t1, t2;
+connection default;
+disconnect locker;
+disconnect changer;
+disconnect updater;
create table t1 (i1 int, i2 int, i3 int);
create table t2 (id int, c1 varchar(20), c2 varchar(20));
insert into t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2);
diff --git a/mysql-test/r/myisam-big.result b/mysql-test/r/myisam-big.result
index 95a6e91d766..fd0bcb1224b 100644
--- a/mysql-test/r/myisam-big.result
+++ b/mysql-test/r/myisam-big.result
@@ -34,7 +34,13 @@ insert into t1 select * from t1;
select count(*) from t1;
count(*)
131072
+connect con2,localhost,root,,;
+connection con2;
alter table t1 add index (id), add index(sometext), add index(sometext,id);
alter table t1 disable keys;
alter table t1 enable keys;
+connection default;
+connection con2;
+disconnect con2;
+connection default;
drop table t1,t2;
diff --git a/mysql-test/r/myisam-optimize.result b/mysql-test/r/myisam-optimize.result
index 9451046fe08..9de3c24301f 100644
--- a/mysql-test/r/myisam-optimize.result
+++ b/mysql-test/r/myisam-optimize.result
@@ -3,6 +3,7 @@
#
create table t1 (pk int primary key, i int) engine=MyISAM;
insert into t1 values (1,1),(2,2);
+connect con1,localhost,root,,;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -13,6 +14,8 @@ t1 CREATE TABLE `t1` (
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
+disconnect con1;
+connect con1,localhost,root,,;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -23,6 +26,8 @@ t1 CREATE TABLE `t1` (
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date
+disconnect con1;
+connect con1,localhost,root,,;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -33,9 +38,12 @@ t1 CREATE TABLE `t1` (
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date
+disconnect con1;
+connection default;
DROP TABLE t1;
create table t1 (pk int primary key, i int) engine=aria;
insert into t1 values (1,1),(2,2);
+connect con1,localhost,root,,;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -46,6 +54,8 @@ t1 CREATE TABLE `t1` (
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
+disconnect con1;
+connect con1,localhost,root,,;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -56,6 +66,8 @@ t1 CREATE TABLE `t1` (
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date
+disconnect con1;
+connect con1,localhost,root,,;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -66,4 +78,6 @@ t1 CREATE TABLE `t1` (
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date
+disconnect con1;
+connection default;
DROP TABLE t1;
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 093de1339f3..67a63d7a08a 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -548,7 +548,10 @@ select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
a a b
1 1 1
2 2 1
+connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
insert into t2 values(2,0);
+disconnect root;
+connection default;
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
a a b
1 1 1
@@ -563,7 +566,11 @@ LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
t1c1 t2c1
+connect con1,localhost,root,,;
+connection con1;
INSERT INTO t2 VALUES ('test000001'), ('test000005');
+disconnect con1;
+connection default;
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
t1c1 t2c1
@@ -1706,12 +1713,17 @@ set global concurrent_insert=1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5);
lock table t1 read local;
+connect con1,localhost,root,,;
+connection con1;
insert into t1 values(6),(7);
+connection default;
unlock tables;
delete from t1 where a>=3 and a<=4;
lock table t1 read local;
+connection con1;
set global concurrent_insert=2;
insert into t1 values (8),(9);
+connection default;
unlock tables;
insert into t1 values (10),(11),(12);
select * from t1;
@@ -1730,15 +1742,21 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+disconnect con1;
create table t1 (a int, b varchar(30) default "hello");
insert into t1 (a) values (1),(2),(3),(4),(5);
lock table t1 read local;
+connect con1,localhost,root,,;
+connection con1;
insert into t1 (a) values(6),(7);
+connection default;
unlock tables;
delete from t1 where a>=3 and a<=4;
lock table t1 read local;
+connection con1;
set global concurrent_insert=2;
insert into t1 (a) values (8),(9);
+connection default;
unlock tables;
insert into t1 (a) values (10),(11),(12);
select a from t1;
@@ -1757,6 +1775,7 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+disconnect con1;
set global concurrent_insert=@save_concurrent_insert;
create table t1 (a int, key(a));
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
diff --git a/mysql-test/r/myisam_debug.result b/mysql-test/r/myisam_debug.result
index 36a8fe6c724..39cbd69cdb0 100644
--- a/mysql-test/r/myisam_debug.result
+++ b/mysql-test/r/myisam_debug.result
@@ -1,6 +1,7 @@
#
# BUG#40827 - Killing insert-select to MyISAM can cause table corruption
#
+CONNECT insertConn, localhost, root,,;
CREATE TABLE `t1` (
`id` BIGINT(20) ,
`id1` BIGINT(20) AUTO_INCREMENT,
@@ -12,11 +13,11 @@ CREATE TABLE `t2` (
KEY (id1), KEY(id)
) ENGINE=MyISAM;
INSERT INTO t2 (id) VALUES (123);
-# Switch to insert Connection
+connection insertConn;
SET SESSION debug_dbug='+d,wait_in_enable_indexes';
# Send insert data
INSERT INTO t1(id) SELECT id FROM t2;
-# Switch to default Connection
+connection default;
# Wait for insert data to reach the debug point
SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE STATE = 'wait_in_enable_indexes' AND
@@ -27,3 +28,4 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1,t2;
+disconnect insertConn;
diff --git a/mysql-test/r/myisam_icp_notembedded.result b/mysql-test/r/myisam_icp_notembedded.result
index d965cbd980d..789259d62f1 100644
--- a/mysql-test/r/myisam_icp_notembedded.result
+++ b/mysql-test/r/myisam_icp_notembedded.result
@@ -14,6 +14,9 @@ KEY (c, b)
CREATE TABLE t2 ( a INT ) ENGINE=MyISAM;
INSERT INTO t2 VALUES
(7),(3),(7),(3);
+connect con2,127.0.0.1,root,,test;
# Now run a number of ICP queries while trying to kill them
+disconnect con2;
+connection default;
DROP TABLE t1,t2;
set optimizer_switch=@myisam_icp_notembedded_tmp;
diff --git a/mysql-test/r/myisam_optimize.result b/mysql-test/r/myisam_optimize.result
index ae0c5b59d06..b769c4ac3e9 100644
--- a/mysql-test/r/myisam_optimize.result
+++ b/mysql-test/r/myisam_optimize.result
@@ -13,12 +13,19 @@ CCCCCCCCCC 3
CCCCCCCCCC 4
set debug_sync='myisam_before_repair_by_sort wait_for go';
optimize table t1;
+connect con1,localhost,root,,;
select a, left(b,10) from t1 order by a;
+connect con2,localhost,root,,;
set debug_sync='now signal go';
+connection default;
Table Op Msg_type Msg_text
test.t1 optimize status OK
+connection con1;
a left(b,10)
3 CCCCCCCCCC
4 CCCCCCCCCC
+disconnect con1;
+disconnect con2;
+connection default;
drop table t1;
set debug_sync='reset';
diff --git a/mysql-test/r/myisam_recover.result b/mysql-test/r/myisam_recover.result
index 0829c1e8b82..2e239cfc392 100644
--- a/mysql-test/r/myisam_recover.result
+++ b/mysql-test/r/myisam_recover.result
@@ -9,9 +9,8 @@
# have effect on merge children.
# For that, we set the table cache to minimal size and populate it
# in a concurrent connection.
-#
-# Switching to connection con1
-#
+connect con1,localhost,root,,test,,;
+connection con1;
#
# Minimal values.
#
@@ -42,9 +41,7 @@ end while;
end|
call p_create();
drop procedure p_create;
-#
-# Switching to connection 'default'
-#
+connection default;
#
# We have to disable the ps-protocol, to avoid
# "Prepared statement needs to be re-prepared" errors
@@ -94,21 +91,22 @@ Error 1034 Number of rows changed from 3 to 6
# Cleanup
#
drop table t1, t1_mrg;
-#
-# Switching to connection con1
-#
+connection con1;
unlock tables;
prepare stmt from @drop_table_stmt;
execute stmt;
deallocate prepare stmt;
set @@global.table_definition_cache=default;
set @@global.table_open_cache=default;
+disconnect con1;
+connection default;
#
# 18075170 - sql node restart required to avoid deadlock after
# restore
#
# Check that auto-repair for MyISAM tables can now happen in the
# middle of transaction, without aborting it.
+connection default;
create table t1 (a int, key(a)) engine=myisam;
create table t2 (a int);
insert into t2 values (1);
@@ -142,9 +140,14 @@ Warnings:
Error 145 Table 't1' is marked as crashed and should be repaired
Error 1194 Table 't1' is marked as crashed and should be repaired
Error 1034 Number of rows changed from 1 to 2
+connect con2, localhost, root;
ALTER TABLE t2 ADD val INT;
+connection default;
# With fix we should have alter table waiting for t2 lock here.
ROLLBACK;
SET autocommit = 1;
+connection con2;
+connection default;
+disconnect con2;
# Cleanup
drop table t1, t2;
diff --git a/mysql-test/r/mysql-bug41486.result b/mysql-test/r/mysql-bug41486.result
index 62a6712eae1..d5760dcb1b9 100644
--- a/mysql-test/r/mysql-bug41486.result
+++ b/mysql-test/r/mysql-bug41486.result
@@ -1,6 +1,7 @@
DROP TABLE IF EXISTS t1;
SET @old_max_allowed_packet= @@global.max_allowed_packet;
SET @@global.max_allowed_packet = 2 * 1024 * 1024 + 1024;
+connect con1, localhost, root,,;
CREATE TABLE t1(data LONGBLOB);
INSERT INTO t1 SELECT REPEAT('1', 2*1024*1024);
SELECT COUNT(*) FROM t1;
@@ -13,4 +14,6 @@ SELECT LENGTH(data) FROM t1;
LENGTH(data)
2097152
DROP TABLE t1;
+disconnect con1;
+connection default;
SET @@global.max_allowed_packet = @old_max_allowed_packet;
diff --git a/mysql-test/r/mysql-bug45236.result b/mysql-test/r/mysql-bug45236.result
index cefcb1d314c..c1e41d62b63 100644
--- a/mysql-test/r/mysql-bug45236.result
+++ b/mysql-test/r/mysql-bug45236.result
@@ -1,8 +1,11 @@
DROP TABLE IF EXISTS t1;
SET @old_max_allowed_packet= @@global.max_allowed_packet;
SET @@global.max_allowed_packet = 1024 * 1024 + 1024;
+connect con1, localhost, root,,;
CREATE TABLE t1(data LONGBLOB);
INSERT INTO t1 SELECT CONCAT(REPEAT('1', 1024*1024 - 27),
"\'\r dummydb dummyhost");
DROP TABLE t1;
+disconnect con1;
+connection default;
SET @@global.max_allowed_packet = @old_max_allowed_packet;
diff --git a/mysql-test/r/mysql_upgrade-6984.result b/mysql-test/r/mysql_upgrade-6984.result
index 6aea4806ddb..fec0fcacb5f 100644
--- a/mysql-test/r/mysql_upgrade-6984.result
+++ b/mysql-test/r/mysql_upgrade-6984.result
@@ -55,6 +55,7 @@ performance_schema
test
Phase 6/6: Running 'FLUSH PRIVILEGES'
OK
+connect con1,localhost,root,foo,,,;
update mysql.user set password='' where user='root';
flush privileges;
set global event_scheduler=OFF;
diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result
index d10e042729f..99446cd9d6f 100644
--- a/mysql-test/r/mysql_upgrade.result
+++ b/mysql-test/r/mysql_upgrade.result
@@ -404,6 +404,7 @@ FATAL ERROR: Upgrade failed
# MDEV-4332 Increase username length from 16 characters
# MDEV-6068, MDEV-6178 mysql_upgrade breaks databases with long user names
#
+connection default;
GRANT SELECT ON mysql.* TO very_long_user_name_number_1;
GRANT SELECT ON mysql.* TO very_long_user_name_number_2;
GRANT ALL ON *.* TO even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost WITH GRANT OPTION;
diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result
index 94aaee0c574..c7da070a622 100644
--- a/mysql-test/r/mysqlbinlog.result
+++ b/mysql-test/r/mysqlbinlog.result
@@ -639,6 +639,10 @@ CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(connection_id());
FLUSH LOGS;
DROP TABLE t1;
+connect con1, localhost, root, , test;
+connection con1;
+disconnect con1;
+connection default;
1
DROP TABLE t1;
shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql
@@ -658,15 +662,19 @@ flush logs;
INSERT INTO t1 VALUES (1,USER());
flush logs;
mysqlbinlog var/log/master-bin.000018 > var/tmp/bug31611.sql
+connect unsecure,localhost,untrusted,,mysqltest1;
mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql
+connection unsecure;
INSERT INTO t1 VALUES (1,USER());
ERROR 42000: INSERT command denied to user 'untrusted'@'localhost' for table 't1'
SELECT * FROM t1;
a b
1 root@localhost
+connection default;
DROP DATABASE mysqltest1;
DROP USER untrusted@localhost;
Bug#32580 mysqlbinlog cannot read binlog event with user variables
+connection default;
USE test;
SET BINLOG_FORMAT = STATEMENT;
FLUSH LOGS;
diff --git a/mysql-test/r/mysqlbinlog_row_big.result b/mysql-test/r/mysqlbinlog_row_big.result
index 70e39266d1d..32c6b4d40ed 100644
--- a/mysql-test/r/mysqlbinlog_row_big.result
+++ b/mysql-test/r/mysqlbinlog_row_big.result
@@ -17,9 +17,8 @@ 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
+disconnect default;
+connect default, localhost,root,,;
#
# Delete all existing binary logs.
#
diff --git a/mysql-test/r/mysqldump-max.result b/mysql-test/r/mysqldump-max.result
index 5eff7a41abd..b75eb969da6 100644
--- a/mysql-test/r/mysqldump-max.result
+++ b/mysql-test/r/mysqldump-max.result
@@ -290,7 +290,10 @@ COUNT(*)
DROP VIEW v1;
DROP TABLE t1;
SET GLOBAL storage_engine=@old_engine;
-# Connection default
+connect c1,127.0.0.1,root,,test,$MASTER_MYPORT,;
+connect c2,127.0.0.1,root,,test,$MASTER_MYPORT,;
+connect c3,127.0.0.1,root,,test,$MASTER_MYPORT,;
+connection default;
SET binlog_format= mixed;
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
@@ -300,32 +303,32 @@ INSERT INTO t2 VALUES (1,0), (2,0);
SELECT GET_LOCK("block_queries_1", 120);
GET_LOCK("block_queries_1", 120)
1
-# Connection c3
+connection c3;
SELECT GET_LOCK("block_queries_2", 120);
GET_LOCK("block_queries_2", 120)
1
-# Connection c1
+connection c1;
SET @c= 0;
SELECT IF(@c<1, @c:=@c+1, GET_LOCK("block_queries_1", 120)) FROM t1 ORDER BY a;
-# Connection c2
+connection c2;
SET binlog_format="row";
SET @d= 10;
UPDATE t2 SET b=IF(@d<=10, @d:=@d+1, GET_LOCK("block_queries_2", 120)) ORDER BY a;
-# Connection default
+connection default;
# Make sure other queries are running (and waiting).
SELECT RELEASE_LOCK("block_queries_1");
RELEASE_LOCK("block_queries_1")
1
-# Connection c3
+connection c3;
SELECT RELEASE_LOCK("block_queries_2");
RELEASE_LOCK("block_queries_2")
1
-# Connection c1
+connection c1;
IF(@c<1, @c:=@c+1, GET_LOCK("block_queries_1", 120))
1
1
-# Connection c2
-# Connection default
+connection c2;
+connection default;
SELECT * FROM t2 ORDER BY a;
a b
1 11
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 559f8885b0d..ef124e74a76 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -3650,16 +3650,21 @@ drop user mysqltest_1@localhost;
#
# Bug#21424 mysqldump failing to export/import views
#
+connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root;
create database mysqldump_myDB;
use mysqldump_myDB;
create user myDB_User@localhost;
grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost;
create table t1 (c1 int);
insert into t1 values (3);
+connect user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user1;
use mysqldump_myDB;
create table u1 (f1 int);
insert into u1 values (4);
create view v1 (c1) as select * from t1;
+connection root;
use mysqldump_myDB;
drop view v1;
drop table t1;
@@ -3671,6 +3676,7 @@ flush privileges;
# Bug#21424 continues from here.
# Restore. Flush Privileges test ends.
#
+connection user1;
use mysqldump_myDB;
select * from mysqldump_myDB.v1;
c1
@@ -3678,6 +3684,8 @@ c1
select * from mysqldump_myDB.u1;
f1
4
+connection root;
+disconnect user1;
use mysqldump_myDB;
drop view v1;
drop table t1;
@@ -3685,6 +3693,8 @@ drop table u1;
revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
drop user myDB_User@localhost;
drop database mysqldump_myDB;
+connection default;
+disconnect root;
use test;
#
# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
@@ -3837,6 +3847,8 @@ use test;
create database mysqldump_test_db;
grant all privileges on mysqldump_test_db.* to user1;
grant all privileges on mysqldump_test_db.* to user2;
+connect user27293,localhost,user1,,mysqldump_test_db,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection user27293;
create procedure mysqldump_test_db.sp1() select 'hello';
-- insufficient privileges to SHOW CREATE PROCEDURE `sp1`
@@ -3859,6 +3871,8 @@ DELIMITER ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
drop procedure sp1;
+connection default;
+disconnect user27293;
drop user user1;
drop user user2;
drop database mysqldump_test_db;
@@ -5038,6 +5052,8 @@ END
# Test to check 'Insufficient privileges' error.
GRANT ALL PRIVILEGES ON BUG52792.* TO user1;
+connect conn_1, localhost, user1, , BUG52792, $MASTER_MYPORT, $MASTER_MYSOCK;
+connection conn_1;
# Running 'replace_regex on timestamp'
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -5125,6 +5141,8 @@ CREATE DEFINER=`root`@`localhost` EVENT `e2` ON SCHEDULE EVERY 1 SECOND STARTS '
<!-- - does user1 have permissions on mysql.proc?
-->
+connection default;
+disconnect conn_1;
DROP USER user1;
DROP DATABASE BUG52792;
# UTF-8
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index e258b1d156f..9a5db536893 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -183,6 +183,8 @@ select 7;
7
mysqltest: At line 1: End of line junk detected: "OCNE"
connect con1,localhost,root,,;
+connection default;
+disconnect con1;
select 5 from t1;
lower
case
@@ -568,14 +570,24 @@ mysqltest: At line 1: query 'connect con2,localhost,root,,illegal_db' failed: 1
mysqltest: At line 1: Illegal argument for port: 'illegal_port'
mysqltest: At line 1: Illegal option to connect: SMTP
200 connects succeeded
+connect test_con1,localhost,root,,;
+disconnect test_con1;
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql":
included from <stdin> at line 1:
At line 3: connection 'test_con1' not found in connection pool
+connect test_con1,localhost,root,,;
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/mysqltest.sql":
included from <stdin> at line 1:
At line 2: Connection test_con1 already exists
+connect con1,localhost,root,,;
+connection default;
+connection con1;
+disconnect con1;
+connect con2,localhost,root,,*NO-ONE*;
show tables;
ERROR 3D000: No database selected
+disconnect con2;
+connection default;
connect con1,localhost,root,,;
connection default;
connection con1;
@@ -957,13 +969,23 @@ select 1;
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
+connect con1,localhost,root,,;
con1
+connect con2,localhost,root,,;
con2
+connection default;
default
+connection con1;
con1
+connection con2;
con2
+connection con1;
con1
+connection con2;
con2
+disconnect con1;
con2
+disconnect con2;
-closed_connection-
End of tests
+connection default;
diff --git a/mysql-test/r/named_pipe.result b/mysql-test/r/named_pipe.result
index ddd48f0ba91..aaf2fa063e1 100644
--- a/mysql-test/r/named_pipe.result
+++ b/mysql-test/r/named_pipe.result
@@ -1,3 +1,4 @@
+connect pipe_con,localhost,root,,,,,PIPE;
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
@@ -2154,3 +2155,5 @@ Privat (Private Nutzung) Mobilfunk
Warnings:
Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
+connection default;
+disconnect pipe_con;
diff --git a/mysql-test/r/non_blocking_api.result b/mysql-test/r/non_blocking_api.result
index 248e372593b..4cb5c270f38 100644
--- a/mysql-test/r/non_blocking_api.result
+++ b/mysql-test/r/non_blocking_api.result
@@ -1,4 +1,7 @@
drop table if exists t1;
+connect con_nonblock,localhost,root,,test;
+connect con_normal,localhost,root,,test;
+connection con_nonblock;
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
@@ -7,4 +10,5 @@ a
SELECT * FROM t1;
a
1
+connection con_normal;
DROP TABLE t1;
diff --git a/mysql-test/r/not_embedded_server.result b/mysql-test/r/not_embedded_server.result
index 1cd54b131c3..ba68ca8619b 100644
--- a/mysql-test/r/not_embedded_server.result
+++ b/mysql-test/r/not_embedded_server.result
@@ -23,7 +23,7 @@ DROP TABLE t1;
# Bug#54812: assert in Diagnostics_area::set_ok_status during EXPLAIN
#
CREATE USER nopriv_user@localhost;
-connection: default
+connection default;
DROP TABLE IF EXISTS t1,t2,t3;
DROP FUNCTION IF EXISTS f;
CREATE TABLE t1 (key1 INT PRIMARY KEY);
@@ -32,7 +32,8 @@ INSERT INTO t1 VALUES (1),(2);
CREATE FUNCTION f() RETURNS INT RETURN 1;
GRANT FILE ON *.* TO 'nopriv_user'@'localhost';
FLUSH PRIVILEGES;
-connection: con1
+connect con1,localhost,nopriv_user,,;
+connection con1;
SELECT MAX(key1) FROM t1 WHERE f() < 1 INTO OUTFILE '<outfile>';
ERROR 42000: execute command denied to user 'nopriv_user'@'localhost' for routine 'test.f'
INSERT INTO t2 SELECT MAX(key1) FROM t1 WHERE f() < 1;
@@ -41,7 +42,8 @@ SELECT MAX(key1) INTO @dummy FROM t1 WHERE f() < 1;
ERROR 42000: execute command denied to user 'nopriv_user'@'localhost' for routine 'test.f'
CREATE TABLE t3 (i INT) AS SELECT MAX(key1) FROM t1 WHERE f() < 1;
ERROR 42000: execute command denied to user 'nopriv_user'@'localhost' for routine 'test.f'
-connection: default
+disconnect con1;
+connection default;
DROP TABLE t1,t2;
DROP FUNCTION f;
DROP USER nopriv_user@localhost;
diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result
index 1d5c6d179df..0aa4acb431c 100644
--- a/mysql-test/r/openssl_1.result
+++ b/mysql-test/r/openssl_1.result
@@ -9,10 +9,17 @@ grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA
grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB/CN=client" ISSUER "/CN=cacert/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB";
grant select on test.* to ssl_user5@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "xxx";
flush privileges;
+connect con1,localhost,ssl_user1,,,,,SSL-CIPHER=DHE-RSA-AES256-SHA;
connect(localhost,ssl_user2,,test,MASTER_PORT,MASTER_SOCKET);
+connect con2,localhost,ssl_user2,,,,,SSL-CIPHER=AES256-SHA;
ERROR 28000: Access denied for user 'ssl_user2'@'localhost' (using password: NO)
+connect con2,localhost,ssl_user2,,,,,SSL-CIPHER=DHE-RSA-AES256-SHA;
+connect con3,localhost,ssl_user3,,,,,SSL-CIPHER=DHE-RSA-AES256-SHA;
+connect con4,localhost,ssl_user4,,,,,SSL-CIPHER=DHE-RSA-AES256-SHA;
connect(localhost,ssl_user5,,test,MASTER_PORT,MASTER_SOCKET);
+connect con5,localhost,ssl_user5,,,,,SSL-CIPHER=DHE-RSA-AES256-SHA;
ERROR 28000: Access denied for user 'ssl_user5'@'localhost' (using password: NO)
+connection con1;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
@@ -21,6 +28,7 @@ f1
5
delete from t1;
ERROR 42000: DELETE command denied to user 'ssl_user1'@'localhost' for table 't1'
+connection con2;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
@@ -29,6 +37,7 @@ f1
5
delete from t1;
ERROR 42000: DELETE command denied to user 'ssl_user2'@'localhost' for table 't1'
+connection con3;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
@@ -37,6 +46,7 @@ f1
5
delete from t1;
ERROR 42000: DELETE command denied to user 'ssl_user3'@'localhost' for table 't1'
+connection con4;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
@@ -45,6 +55,11 @@ f1
5
delete from t1;
ERROR 42000: DELETE command denied to user 'ssl_user4'@'localhost' for table 't1'
+connection default;
+disconnect con1;
+disconnect con2;
+disconnect con3;
+disconnect con4;
drop user ssl_user1@localhost, ssl_user2@localhost,
ssl_user3@localhost, ssl_user4@localhost, ssl_user5@localhost;
drop table t1;
@@ -204,9 +219,12 @@ result
is still running; no cipher request crashed the server
GRANT SELECT ON test.* TO bug42158@localhost REQUIRE X509;
FLUSH PRIVILEGES;
+connect con1,localhost,bug42158,,,,,SSL;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
+disconnect con1;
+connection default;
DROP USER bug42158@localhost;
set global sql_mode=default;
End of 5.1 tests
diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result
index daea60c53eb..cafa9d9db4d 100644
--- a/mysql-test/r/outfile.result
+++ b/mysql-test/r/outfile.result
Binary files differ
diff --git a/mysql-test/r/overflow.result b/mysql-test/r/overflow.result
index a5fa7154833..a3e93aa5cba 100644
--- a/mysql-test/r/overflow.result
+++ b/mysql-test/r/overflow.result
@@ -1,2 +1,6 @@
+connect con1,localhost,root,,;
+connection con1;
drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
Got one of the listed errors
+connection default;
+disconnect con1;
diff --git a/mysql-test/r/packet.result b/mysql-test/r/packet.result
index dcc2c608d0b..254ad93d78e 100644
--- a/mysql-test/r/packet.result
+++ b/mysql-test/r/packet.result
@@ -13,18 +13,26 @@ len
select repeat('a',2000);
repeat('a',2000)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+connect con1,localhost,root,,;
+connection con1;
select @@net_buffer_length, @@max_allowed_packet;
@@net_buffer_length @@max_allowed_packet
1024 1024
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
ERROR 08S01: Got a packet bigger than 'max_allowed_packet' bytes
+connection default;
+disconnect con1;
set global max_allowed_packet=default;
set global net_buffer_length=default;
+connect con2,localhost,root,,;
+connection con2;
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
len
100
select length(repeat('a',2000));
length(repeat('a',2000))
2000
+connection default;
+disconnect con2;
set global max_allowed_packet=@max_allowed_packet;
set global net_buffer_length=@net_buffer_length;
diff --git a/mysql-test/r/parser_not_embedded.result b/mysql-test/r/parser_not_embedded.result
index fd545605c02..25349e51577 100644
--- a/mysql-test/r/parser_not_embedded.result
+++ b/mysql-test/r/parser_not_embedded.result
@@ -52,7 +52,11 @@
COMMIT AND CHAIN RELEASE;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RELEASE' at line 1
COMMIT AND NO CHAIN RELEASE;
+disconnect default;
+connect default, localhost, root,,;
COMMIT RELEASE;
+disconnect default;
+connect default, localhost, root,,;
COMMIT CHAIN RELEASE;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHAIN RELEASE' at line 1
COMMIT NO CHAIN RELEASE;
@@ -72,11 +76,17 @@ COMMIT AND NO CHAIN NO RELEASE;
ROLLBACK AND CHAIN RELEASE;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RELEASE' at line 1
ROLLBACK AND NO CHAIN RELEASE;
+disconnect default;
+connect default, localhost, root,,;
ROLLBACK RELEASE;
+disconnect default;
+connect default, localhost, root,,;
ROLLBACK CHAIN RELEASE;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHAIN RELEASE' at line 1
ROLLBACK NO CHAIN RELEASE;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHAIN RELEASE' at line 1
+disconnect default;
+connect default, localhost, root,,;
ROLLBACK AND NO RELEASE;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RELEASE' at line 1
ROLLBACK AND RELEASE;
diff --git a/mysql-test/r/partition_cache.result b/mysql-test/r/partition_cache.result
index 39ba4841337..697ba1bcd15 100644
--- a/mysql-test/r/partition_cache.result
+++ b/mysql-test/r/partition_cache.result
@@ -113,9 +113,10 @@ select count(*) from t1;
count(*)
1
drop table t1;
+connect connection1,localhost,root,,;
SET SESSION STORAGE_ENGINE = InnoDB;
SET @@autocommit=1;
-connection default
+connection default;
SHOW VARIABLES LIKE 'have_query_cache';
Variable_name Value
have_query_cache YES
@@ -137,7 +138,7 @@ count(*)
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
-connection connection1
+connection connection1;
START TRANSACTION;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
@@ -153,7 +154,7 @@ count(*)
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
-connection default
+connection default;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
1
@@ -167,7 +168,7 @@ count(*)
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
-connection connection1
+connection connection1;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
2
@@ -179,7 +180,7 @@ INSERT INTO t2 VALUES (6,'w');
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
3
-connection default
+connection default;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
2
@@ -192,7 +193,7 @@ SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
1
COMMIT;
-connection connection1
+connection connection1;
COMMIT;
SELECT sql_cache count(*) FROM t2 WHERE s2 = 'w';
count(*)
@@ -203,6 +204,8 @@ Qcache_queries_in_cache 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
+disconnect connection1;
+connection default;
set @@global.query_cache_size = @save_query_cache_size;
drop table t2;
SET global query_cache_type=default;
diff --git a/mysql-test/r/partition_csv.result b/mysql-test/r/partition_csv.result
index 18e28d4670a..836c49682b2 100644
--- a/mysql-test/r/partition_csv.result
+++ b/mysql-test/r/partition_csv.result
@@ -34,10 +34,13 @@ SET GLOBAL general_log =1;
# do some things to be logged to partitioned log, should fail
USE /* 1 */ test;
CREATE TABLE t1 (i INT);
+connect con1,localhost,root,,;
INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
i
1
+disconnect con1;
+connection default;
USE mysql;
SET GLOBAL general_log =0;
ALTER TABLE general_log RENAME TO gl_partitioned;
diff --git a/mysql-test/r/partition_debug_sync.result b/mysql-test/r/partition_debug_sync.result
index 7abe0163a98..971bc63e2e7 100644
--- a/mysql-test/r/partition_debug_sync.result
+++ b/mysql-test/r/partition_debug_sync.result
@@ -8,7 +8,7 @@ SET DEBUG_SYNC= 'RESET';
# by adding a small sleep to verify that the delete waits. This happens
# only until ALTER tries to upgrade its MDL lock, which ends up in MDL
# deadlock which is correctly reported.
-# Con 1
+connect con1, localhost, root,,;
SET DEBUG_SYNC= 'RESET';
CREATE TABLE t1
(a INTEGER,
@@ -23,14 +23,16 @@ PARTITION p3 VALUES LESS THAN MAXVALUE ) */;
SET DEBUG_SYNC= 'alter_table_before_create_table_no_lock SIGNAL removing_partitioning WAIT_FOR waiting_for_alter';
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL waiting_for_upgrade';
ALTER TABLE t1 REMOVE PARTITIONING;
-# Con default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR removing_partitioning';
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL waiting_for_alter';
SET DEBUG_SYNC= 'rm_table_no_locks_before_delete_table WAIT_FOR waiting_for_upgrade';
DROP TABLE IF EXISTS t1;
-# Con 1
+connection con1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
+connection default;
SET DEBUG_SYNC= 'RESET';
+connection con1;
SET DEBUG_SYNC= 'RESET';
#
# Bug#42438: Crash ha_partition::change_table_ptr
@@ -50,15 +52,16 @@ PARTITION p3 VALUES LESS THAN MAXVALUE);
SET DEBUG_SYNC= 'alter_table_before_open_tables SIGNAL removing_partitions WAIT_FOR waiting_for_alter';
SET DEBUG_SYNC= 'alter_table_before_rename_result_table WAIT_FOR delete_done';
ALTER TABLE t2 REMOVE PARTITIONING;
-# Con default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR removing_partitions';
SET DEBUG_SYNC= 'rm_table_no_locks_before_delete_table SIGNAL waiting_for_alter';
SET DEBUG_SYNC= 'rm_table_no_locks_before_binlog SIGNAL delete_done';
DROP TABLE IF EXISTS t2;
-# Con 1
+connection con1;
ERROR 42S02: Table 'test.t2' doesn't exist
SET DEBUG_SYNC= 'RESET';
-# Con default
+disconnect con1;
+connection default;
SET DEBUG_SYNC= 'RESET';
End of 5.1 tests
#
@@ -68,21 +71,22 @@ CREATE TABLE t1 (a int) ENGINE = InnoDB;
CREATE TABLE t2 (a int PRIMARY KEY)
ENGINE = InnoDB PARTITION BY HASH (a) PARTITIONS 3;
HANDLER t1 OPEN;
-# Con1
+connect con1, localhost, root,,;
LOCK TABLES t1 WRITE, t2 READ;
-# Default
+connection default;
SET DEBUG_SYNC="wait_for_lock SIGNAL locking";
INSERT INTO t2 VALUES (1), (2), (3);
-# Con1
+connection con1;
SET DEBUG_SYNC="now WAIT_FOR locking";
ALTER TABLE t1 ADD COLUMN b int;
-# Default
+connection default;
ERROR HY000: Wait on a lock was aborted due to a pending exclusive lock
SELECT 1;
1
1
-# Con1
+connection con1;
UNLOCK TABLES;
-# Default
+disconnect con1;
+connection default;
SET DEBUG_SYNC = 'RESET';
DROP TABLE t1, t2;
diff --git a/mysql-test/r/partition_grant.result b/mysql-test/r/partition_grant.result
index f036b0bcc28..cd8f8a970d0 100644
--- a/mysql-test/r/partition_grant.result
+++ b/mysql-test/r/partition_grant.result
@@ -7,6 +7,7 @@ create user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost;
revoke all privileges on *.* from mysqltest_1@localhost;
grant select,alter on mysqltest_1.* to mysqltest_1@localhost;
+connect conn1,localhost,mysqltest_1,,mysqltest_1;
show grants for current_user;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -14,21 +15,36 @@ GRANT SELECT, ALTER ON `mysqltest_1`.* TO 'mysqltest_1'@'localhost'
alter table t1 add b int;
alter table t1 drop partition p2;
ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 't1'
+disconnect conn1;
+connection default;
grant drop on mysqltest_1.* to mysqltest_1@localhost;
+connect conn2,localhost,mysqltest_1,,mysqltest_1;
alter table t1 drop partition p2;
+disconnect conn2;
+connection default;
revoke alter on mysqltest_1.* from mysqltest_1@localhost;
+connect conn3,localhost,mysqltest_1,,mysqltest_1;
alter table t1 drop partition p3;
ERROR 42000: ALTER command denied to user 'mysqltest_1'@'localhost' for table 't1'
+disconnect conn3;
+connection default;
revoke select,alter,drop on mysqltest_1.* from mysqltest_1@localhost;
drop table t1;
create table t1 (s1 int);
insert into t1 values (1);
grant alter on mysqltest_1.* to mysqltest_1@localhost;
+connect conn4,localhost,mysqltest_1,,mysqltest_1;
+connection conn4;
alter table t1 partition by list (s1) (partition p1 values in (2));
ERROR HY000: Table has no partition for some existing values
+connection default;
grant select, alter on mysqltest_1.* to mysqltest_1@localhost;
+disconnect conn4;
+connect conn5,localhost,mysqltest_1,,mysqltest_1;
alter table t1 partition by list (s1) (partition p1 values in (2));
ERROR HY000: Table has no partition for value 1
+disconnect conn5;
+connection default;
drop table t1;
drop user mysqltest_1@localhost;
drop schema mysqltest_1;
diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result
index bfe9dc96bc2..c9568f7b07f 100644
--- a/mysql-test/r/partition_innodb.result
+++ b/mysql-test/r/partition_innodb.result
@@ -89,19 +89,23 @@ BEGIN;
SELECT COUNT(*) FROM t1;
COUNT(*)
5
-# con1
+connect con1,localhost,root,,;
# SEND a ALTER PARTITION which waits on the ongoing transaction.
ALTER TABLE t1
REORGANIZE PARTITION hour_003, hour_004 INTO
(PARTITION oldest VALUES LESS THAN (4));
# Connection default wait until the ALTER is in 'waiting for table...'
# state and then continue the transaction by trying a SELECT
+connection default;
SELECT COUNT(*) FROM t1;
COUNT(*)
5
COMMIT;
-# con1, reaping ALTER.
-# Disconnecting con1 and switching to default. Cleaning up.
+# reaping ALTER.
+connection con1;
+# Cleaning up.
+disconnect con1;
+connection default;
SET GLOBAL innodb_thread_concurrency = @old_innodb_thread_concurrency;
SET GLOBAL innodb_thread_sleep_delay = @old_innodb_thread_sleep_delay;
DROP TABLE t1;
@@ -145,7 +149,7 @@ UPDATE t1 SET name = 'Mattias' WHERE id = 7;
SELECT * FROM t1 WHERE id = 7;
id name myDate
7 Mattias 2009-09-16
-# Connection con1
+connect con1, localhost, root,,;
SET lock_wait_timeout = 1;
# After the patch it will wait and fail on timeout.
ALTER TABLE t1 DROP PARTITION p3;
@@ -153,7 +157,8 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SHOW WARNINGS;
Level Code Message
Error 1205 Lock wait timeout exceeded; try restarting transaction
-# Connection default
+disconnect con1;
+connection default;
SELECT * FROM t1;
id name myDate
1 Lachlan 2009-09-13
@@ -778,13 +783,14 @@ PRIMARY KEY (a))
ENGINE = InnoDB
PARTITION BY HASH (a) PARTITIONS 3;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
-# con1
+connect con1, localhost, root,,;
ALTER TABLE t1 ADD INDEX idx1 (b);
-# con default
+connection default;
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
+disconnect con1;
DROP TABLE t1;
# Same test without partitioning
CREATE TABLE t1
@@ -793,11 +799,12 @@ b INT,
PRIMARY KEY (a))
ENGINE = InnoDB;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
-# con1
+connect con1, localhost, root,,;
ALTER TABLE t1 ADD INDEX idx1 (b);
-# con default
+connection default;
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
+disconnect con1;
DROP TABLE t1;
diff --git a/mysql-test/r/partition_innodb_plugin.result b/mysql-test/r/partition_innodb_plugin.result
index 63c9da69955..d53d2edb581 100644
--- a/mysql-test/r/partition_innodb_plugin.result
+++ b/mysql-test/r/partition_innodb_plugin.result
@@ -42,7 +42,7 @@ SET @old_innodb_strict_mode = @@global.innodb_strict_mode;
SET @@global.innodb_file_format = Barracuda,
@@global.innodb_file_per_table = ON,
@@global.innodb_strict_mode = ON;
-# Connection con1
+connect con1,localhost,root,,;
CREATE TABLE t1 (id INT NOT NULL
PRIMARY KEY,
user_num CHAR(10)
@@ -62,7 +62,8 @@ t1 CREATE TABLE `t1` (
/*!50100 PARTITION BY HASH (id)
PARTITIONS 1 */
SET GLOBAL innodb_file_per_table = OFF;
-# Connection con2
+disconnect con1;
+connect con2,localhost,root,,;
LOCK TABLE t1 WRITE;
# ALTER fails because COMPRESSED/KEY_BLOCK_SIZE
# are incompatible with innodb_file_per_table = OFF;
@@ -99,7 +100,8 @@ t1 CREATE TABLE `t1` (
/*!50100 PARTITION BY HASH (id)
PARTITIONS 3 */
DROP TABLE t1;
-# Connection default
+disconnect con2;
+connection default;
SET @@global.innodb_strict_mode = @old_innodb_strict_mode;
SET @@global.innodb_file_format = @old_innodb_file_format;
SET @@global.innodb_file_per_table = @old_innodb_file_per_table;
@@ -116,15 +118,15 @@ PARTITION `p1``\""e` VALUES LESS THAN (MAXVALUE)
SUBPARTITION `sp3``\""e`));
INSERT INTO `t``\""e` VALUES (0), (2), (6), (10), (14), (18), (22);
START TRANSACTION;
-# con1
+connect con1,localhost,root,,;
SET NAMES utf8;
START TRANSACTION;
-# default connection
+connection default;
UPDATE `t``\""e` SET a = 16 WHERE a = 0;
-# con1
+connection con1;
UPDATE `t``\""e` SET a = 8 WHERE a = 22;
UPDATE `t``\""e` SET a = 12 WHERE a = 0;
-# default connection
+connection default;
SELECT lock_table, COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS
GROUP BY lock_table;
lock_table COUNT(*)
@@ -148,8 +150,9 @@ SHOW ENGINE InnoDB STATUS;
Type Name Status
InnoDB index `PRIMARY` of table `test`.`t``\""e` /* Partition `p0``\""e`, Subpartition `sp0``\""e` */
set @@sql_mode = @old_sql_mode;
-# con1
+connection con1;
ROLLBACK;
-# default connection
+disconnect con1;
+connection default;
DROP TABLE `t``\""e`;
SET NAMES DEFAULT;
diff --git a/mysql-test/r/partition_innodb_semi_consistent.result b/mysql-test/r/partition_innodb_semi_consistent.result
index 11621a1ebd9..208bd0214f7 100644
--- a/mysql-test/r/partition_innodb_semi_consistent.result
+++ b/mysql-test/r/partition_innodb_semi_consistent.result
@@ -1,4 +1,7 @@
drop table if exists t1;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connection a;
set binlog_format=mixed;
set session transaction isolation level repeatable read;
create table t1(a int not null)
@@ -12,28 +15,36 @@ set autocommit=0;
select * from t1 where a=3 lock in share mode;
a
3
+connection b;
set binlog_format=mixed;
set session transaction isolation level repeatable read;
set autocommit=0;
update t1 set a=10 where a=5;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
+connection a;
commit;
+connection b;
set session transaction isolation level read committed;
update t1 set a=10 where a=5;
+connection a;
select * from t1 where a=2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1 where a=2 limit 1 for update;
a
2
+connection b;
update t1 set a=11 where a=6;
update t1 set a=12 where a=2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
update t1 set a=13 where a=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection a;
commit;
+connection b;
update t1 set a=14 where a=1;
commit;
+connection a;
select * from t1;
a
10
@@ -44,10 +55,15 @@ a
4
7
drop table t1;
+connection default;
+disconnect a;
+disconnect b;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
SET SESSION AUTOCOMMIT = 0;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
set binlog_format=mixed;
-# Switch to connection con1
+connection con1;
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256))
ENGINE = InnoDB
PARTITION BY RANGE (a)
@@ -62,11 +78,11 @@ info: Rows matched: 1 Changed: 1 Warnings: 0
SELECT * FROM t1;
a b
1 12
-# Switch to connection con2
+connection con2;
UPDATE t1 SET b = 21 WHERE a = 1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ROLLBACK;
-# Switch to connection con1
+connection con1;
SELECT * FROM t1;
a b
1 12
@@ -97,9 +113,9 @@ info: Rows matched: 1 Changed: 1 Warnings: 0
SELECT * FROM t1;
a b
1 init+con1
-# Switch to connection con2
+connection con2;
CALL p1;;
-# Switch to connection con1
+connection con1;
SELECT * FROM t1;
a b
1 init+con1
@@ -107,12 +123,12 @@ COMMIT;
SELECT * FROM t1;
a b
1 init+con1
-# Switch to connection con2
+connection con2;
SELECT * FROM t1;
a b
1 init+con1+con2
COMMIT;
-# Switch to connection con1
+connection con1;
# 3. test for updated key column:
TRUNCATE t1;
DELETE FROM t2;
@@ -124,9 +140,9 @@ info: Rows matched: 1 Changed: 1 Warnings: 0
SELECT * FROM t1;
a b
2 init+con1
-# Switch to connection con2
+connection con2;
CALL p1;;
-# Switch to connection con1
+connection con1;
SELECT * FROM t1;
a b
2 init+con1
@@ -134,9 +150,12 @@ COMMIT;
SELECT * FROM t1;
a b
2 init+con1
-# Switch to connection con2
+connection con2;
SELECT * FROM t1;
a b
2 init+con1
+connection default;
+disconnect con1;
+disconnect con2;
DROP PROCEDURE p1;
DROP TABLE t1, t2;
diff --git a/mysql-test/r/partition_innodb_stmt.result b/mysql-test/r/partition_innodb_stmt.result
index 22a9f28708c..543d4734216 100644
--- a/mysql-test/r/partition_innodb_stmt.result
+++ b/mysql-test/r/partition_innodb_stmt.result
@@ -1,4 +1,3 @@
-# connection default
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
CREATE TABLE t1
(
@@ -21,12 +20,13 @@ id
1
2
3
-#connection con1
+connect con1, localhost, root,,;
+connection con1;
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
INSERT INTO t1 VALUES(7);
COMMIT;
-# connection default
+connection default;
COMMIT;
FLUSH TABLES;
# Test REPEATABLE READ -> READ COMMITTED
@@ -38,11 +38,13 @@ id
2
3
7
-# connection con1
+connection con1;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
INSERT INTO t1 VALUES(9);
ERROR HY000: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
COMMIT;
+disconnect con1;
+connection default;
COMMIT;
DROP TABLE t1;
diff --git a/mysql-test/r/partition_symlink.result b/mysql-test/r/partition_symlink.result
index 2588a9b10e4..387717ab7e7 100644
--- a/mysql-test/r/partition_symlink.result
+++ b/mysql-test/r/partition_symlink.result
@@ -47,6 +47,7 @@ CREATE DATABASE mysqltest2;
USE mysqltest2;
CREATE TABLE t1 (a INT) ENGINE = MyISAM;
INSERT INTO t1 VALUES (0);
+connect con1,localhost,mysqltest_1,,;
# user mysqltest_1:
USE test;
CREATE TABLE t1 (a INT)
@@ -68,6 +69,7 @@ INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
a
1
+connection default;
# user root:
USE mysqltest2;
FLUSH TABLES;
@@ -96,6 +98,7 @@ PARTITION p1 VALUES IN (1)
DATA DIRECTORY 'MYSQLTEST_VARDIR/tmp'
INDEX DIRECTORY 'MYSQLTEST_VARDIR/tmp'
);
+connection con1;
# user mysqltest_1:
USE test;
CREATE TABLE t1 (a INT)
@@ -120,10 +123,12 @@ DATA DIRECTORY 'MYSQLTEST_VARDIR/tmp'
INDEX DIRECTORY 'MYSQLTEST_VARDIR/tmp'
);
Got one of the listed errors
+connection default;
# user root (cleanup):
DROP DATABASE mysqltest2;
USE test;
DROP USER mysqltest_1@localhost;
+disconnect con1;
create table t2 (i int )
ENGINE = MyISAM
partition by range (i)
diff --git a/mysql-test/r/partition_sync.result b/mysql-test/r/partition_sync.result
index 0e8254e984e..18cc506e849 100644
--- a/mysql-test/r/partition_sync.result
+++ b/mysql-test/r/partition_sync.result
@@ -6,22 +6,24 @@ CREATE TABLE t1 (a int) PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (1),
PARTITION p1 VALUES LESS THAN (2));
INSERT INTO t1 VALUES (0),(1);
-# Connection 2
+connect con1,localhost,root;
+connection con1;
BEGIN;
SELECT * FROM t1;
a
0
1
-# Connection 1
+connection default;
ALTER TABLE t1 DROP PARTITION p3;
ERROR HY000: Error in list of partitions to DROP
-# Connection 2
+connection con1;
# This failed with deadlock and should not do so.
SELECT * FROM t1;
a
0
1
-# Connection 1
+connection default;
+disconnect con1;
DROP TABLE t1;
#
# Bug #46654 False deadlock on concurrent DML/DDL
@@ -31,27 +33,31 @@ DROP TABLE IF EXISTS tbl_with_partitions;
CREATE TABLE tbl_with_partitions ( i INT )
PARTITION BY HASH(i);
INSERT INTO tbl_with_partitions VALUES (1);
-# Connection 3
+connect con2,localhost,root;
+connect con3,localhost,root;
+connection con3;
LOCK TABLE tbl_with_partitions READ;
-# Connection 1
# Access table with disabled autocommit
+connection default;
SET AUTOCOMMIT = 0;
SELECT * FROM tbl_with_partitions;
i
1
-# Connection 2
# Alter table, abort after prepare
+connection con2;
set session debug_dbug="+d,abort_copy_table";
ALTER TABLE tbl_with_partitions ADD COLUMN f INT;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
-# Connection 1
# Try accessing the table after Alter aborted.
# This used to give ER_LOCK_DEADLOCK.
+connection default;
SELECT * FROM tbl_with_partitions;
i
1
-# Connection 3
+connection con3;
UNLOCK TABLES;
-# Connection 1
# Cleanup
+connection default;
+disconnect con2;
+disconnect con3;
DROP TABLE tbl_with_partitions;
diff --git a/mysql-test/r/plugin_auth.result b/mysql-test/r/plugin_auth.result
index 626722f9dd1..345d6861ad4 100644
--- a/mysql-test/r/plugin_auth.result
+++ b/mysql-test/r/plugin_auth.result
@@ -31,18 +31,26 @@ proxies_priv CREATE TABLE `proxies_priv` (
PRIMARY KEY (`Host`,`User`,`Proxied_host`,`Proxied_user`),
KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User proxy privileges'
+connect plug_con,localhost,plug,plug_dest;
+connection plug_con;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
plug@localhost plug_dest@%
## test SET PASSWORD
SET PASSWORD = PASSWORD('plug_dest');
+connection default;
+disconnect plug_con;
## test bad credentials
ERROR 28000: Access denied for user 'plug'@'localhost' (using password: YES)
## test bad default plugin : should get CR_AUTH_PLUGIN_CANNOT_LOAD
## test correct default plugin
+connect plug_con_rightp,localhost,plug,plug_dest,,,,,auth_test_plugin;
+connection plug_con_rightp;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
plug@localhost plug_dest@%
+connection default;
+disconnect plug_con_rightp;
## test no_auto_create_user sql mode with plugin users
SET @@sql_mode=no_auto_create_user;
GRANT INSERT ON TEST.* TO grant_user IDENTIFIED WITH 'test_plugin_server';
@@ -51,9 +59,13 @@ DROP USER grant_user;
## test utf-8 user name
CREATE USER `Ÿ` IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
GRANT PROXY ON plug_dest TO `Ÿ`;
+connect non_ascii,localhost,Ÿ,plug_dest;
+connection non_ascii;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
Ÿ@localhost plug_dest@%
+connection default;
+disconnect non_ascii;
DROP USER `Ÿ`;
## test GRANT ... IDENTIFIED WITH/BY ...
CREATE DATABASE test_grant_db;
@@ -61,24 +73,33 @@ CREATE DATABASE test_grant_db;
GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user
IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
GRANT PROXY ON plug_dest TO new_grant_user;
+connect plug_con_grant,localhost,new_grant_user,plug_dest;
+connection plug_con_grant;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
new_grant_user@localhost plug_dest@%
USE test_grant_db;
CREATE TABLE t1 (a INT);
DROP TABLE t1;
+connection default;
+disconnect plug_con_grant;
REVOKE ALL PRIVILEGES ON test_grant_db.* FROM new_grant_user;
# try re-create existing user via GRANT IDENTIFIED BY
GRANT ALL PRIVILEGES ON test_grant_db.* TO new_grant_user
IDENTIFIED BY 'new_password';
connect(localhost,new_grant_user,plug_dest,test,MYSQL_PORT,MYSQL_SOCK);
+connect plug_con_grant_deny,localhost,new_grant_user,plug_dest;
ERROR 28000: Access denied for user 'new_grant_user'@'localhost' (using password: YES)
+connect plug_con_grant,localhost,new_grant_user,new_password;
+connection plug_con_grant;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
new_grant_user@localhost new_grant_user@%
USE test_grant_db;
CREATE TABLE t1 (a INT);
DROP TABLE t1;
+connection default;
+disconnect plug_con_grant;
DROP USER new_grant_user;
# try re-create existing user via GRANT IDENTIFIED WITH
GRANT ALL PRIVILEGES ON test_grant_db.* TO plug
@@ -111,6 +132,8 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
# this should fail : no such grant
REVOKE PROXY ON grant_plug_dest FROM grant_plug;
ERROR 42000: There is no such grant defined for user 'grant_plug' on host '%'
+connect grant_plug_dest_con,localhost,grant_plug_dest,grant_plug_dest_passwd;
+connection grant_plug_dest_con;
in grant_plug_dest_con
## testing what an ordinary user can grant
this should fail : no rights to grant all
@@ -134,7 +157,9 @@ ERROR 28000: Access denied for user 'grant_plug_dest'@'localhost'
this should fail : can't create users
GRANT PROXY ON grant_plug_dest TO grant_plug@localhost;
ERROR 42000: You are not allowed to create a user with GRANT
+connection default;
in default connection
+disconnect grant_plug_dest_con;
# test what root can grant
should work : root has PROXY to all users
GRANT PROXY ON ''@'%%' TO grant_plug;
@@ -144,10 +169,14 @@ GRANT PROXY ON ''@'%%' TO proxy_admin IDENTIFIED BY 'test'
WITH GRANT OPTION;
need USAGE : PROXY doesn't contain it.
GRANT USAGE on *.* TO proxy_admin;
+connect proxy_admin_con,localhost,proxy_admin,test;
+connection proxy_admin_con;
in proxy_admin_con;
should work : proxy_admin has proxy to ''@'%%'
GRANT PROXY ON future_user TO grant_plug;
+connection default;
in default connection
+disconnect proxy_admin_con;
SHOW GRANTS FOR grant_plug;
Grants for grant_plug@%
GRANT ALL PRIVILEGES ON *.* TO 'grant_plug'@'%' IDENTIFIED VIA test_plugin_server USING 'grant_plug_dest'
@@ -191,11 +220,15 @@ ERROR HY000: Variable 'proxy_user' is a read only variable
SELECT @@LOCAL.proxy_user;
@@LOCAL.proxy_user
NULL
+connect plug_con,localhost,plug,plug_dest;
+connection plug_con;
# in connection plug_con
SELECT @@LOCAL.proxy_user;
@@LOCAL.proxy_user
'plug'@'%'
+connection default;
# in connection default
+disconnect plug_con;
## cleanup
DROP USER plug;
DROP USER plug_dest;
@@ -219,11 +252,15 @@ ERROR HY000: Variable 'external_user' is a read only variable
SELECT @@LOCAL.external_user;
@@LOCAL.external_user
NULL
+connect plug_con,localhost,plug,plug_dest;
+connection plug_con;
# in connection plug_con
SELECT @@LOCAL.external_user;
@@LOCAL.external_user
plug_dest
+connection default;
# in connection default
+disconnect plug_con;
## cleanup
DROP USER plug;
DROP USER plug_dest;
@@ -236,9 +273,12 @@ GRANT USAGE ON anonymous_db.* TO ''@'%%'
IDENTIFIED WITH 'test_plugin_server' AS 'power_user';
GRANT PROXY ON power_user TO ''@'%%';
CREATE DATABASE confidential_db;
+connect plug_con,localhost, test_login_user, power_user, confidential_db;
SELECT user(),current_user(),@@proxy_user;
user() current_user() @@proxy_user
test_login_user@localhost power_user@% ''@'%%'
+connection default;
+disconnect plug_con;
DROP USER power_user;
DROP USER ''@'%%';
DROP DATABASE confidential_db;
@@ -274,10 +314,14 @@ ERROR 28000: Access denied for user 'root'@'localhost'
REVOKE PROXY ON u2@localhost FROM u1@localhost;
ERROR 28000: Access denied for user 'root'@'localhost'
# go try graning proxy on itself, so that it will need the table
+connect proxy_granter_con,localhost,u2,;
+connection proxy_granter_con;
GRANT PROXY ON u2@localhost TO u1@localhost;
ERROR 42S02: Table 'mysql.proxies_priv' doesn't exist
REVOKE PROXY ON u2@localhost FROM u1@localhost;
ERROR 42S02: Table 'mysql.proxies_priv' doesn't exist
+connection default;
+disconnect proxy_granter_con;
# test if REVOKE works without the proxies_priv table
REVOKE ALL PRIVILEGES ON *.* FROM u1@localhost, u2@localhost;
# test if DROP USER work without the proxies_priv table
@@ -310,9 +354,13 @@ CREATE USER uplain@localhost IDENTIFIED WITH 'cleartext_plugin_server'
AS 'cleartext_test';
## test plugin auth
ERROR 28000: Access denied for user 'uplain'@'localhost' (using password: YES)
+connect cleartext_con,localhost,uplain,cleartext_test;
+connection cleartext_con;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
uplain@localhost uplain@localhost
+connection default;
+disconnect cleartext_con;
DROP USER uplain@localhost;
#
# Bug #59038 : mysql.user.authentication_string column
@@ -409,6 +457,9 @@ ERROR 1045 (28000): Access denied for user 'unknown'@'localhost' (using password
CREATE USER bug12610784@localhost;
SET PASSWORD FOR bug12610784@localhost = PASSWORD('secret');
ERROR 28000: Access denied for user 'bug12610784'@'localhost' (using password: NO)
+connect b12610784,localhost,bug12610784,secret,test;
+connection default;
+disconnect b12610784;
DROP USER bug12610784@localhost;
#
# Bug #12818542: PAM: ADDING PASSWORD FOR AN ACCOUNT DISABLES PAM
@@ -419,13 +470,21 @@ IDENTIFIED WITH 'test_plugin_server' AS 'bug12818542_dest';
CREATE USER bug12818542_dest@localhost
IDENTIFIED BY 'bug12818542_dest_passwd';
GRANT PROXY ON bug12818542_dest@localhost TO bug12818542@localhost;
+connect bug12818542_con,localhost,bug12818542,bug12818542_dest;
+connection bug12818542_con;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
bug12818542@localhost bug12818542_dest@localhost
SET PASSWORD = PASSWORD('bruhaha');
+connection default;
+disconnect bug12818542_con;
+connect bug12818542_con2,localhost,bug12818542,bug12818542_dest;
+connection bug12818542_con2;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
bug12818542@localhost bug12818542_dest@localhost
+connection default;
+disconnect bug12818542_con2;
DROP USER bug12818542@localhost;
DROP USER bug12818542_dest@localhost;
SET GLOBAL SQL_MODE=default;
diff --git a/mysql-test/r/plugin_auth_qa_1.result b/mysql-test/r/plugin_auth_qa_1.result
index 44b5a88de1e..42a7b1491c0 100644
--- a/mysql-test/r/plugin_auth_qa_1.result
+++ b/mysql-test/r/plugin_auth_qa_1.result
@@ -96,14 +96,14 @@ CREATE USER plug_user
IDENTIFIED WITH test_plugin_server AS 'plug_dest';
CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
GRANT PROXY ON plug_dest TO plug_user;
-connect(plug_user,localhost,plug_user,plug_dest);
+connect plug_user,localhost,plug_user,plug_dest;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
plug_user@localhost plug_dest@%
connection default;
disconnect plug_user;
RENAME USER plug_user TO new_user;
-connect(plug_user,localhost,new_user,plug_dest);
+connect plug_user,localhost,new_user,plug_dest;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
new_user@localhost plug_dest@%
@@ -125,7 +125,7 @@ CREATE USER plug_user
IDENTIFIED WITH test_plugin_server AS 'plug_dest';
CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
GRANT PROXY ON plug_dest TO plug_user;
-connect(plug_user,localhost,plug_user,plug_dest);
+connect plug_user,localhost,plug_user,plug_dest;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
plug_user@localhost plug_dest@%
@@ -153,7 +153,6 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
new_user new_plugin_server new_dest
plug_dest
-connect(plug_user,localhost,new_user,new_dest);
ERROR HY000: Plugin 'new_plugin_server' is not loaded
UPDATE mysql.user SET plugin='test_plugin_server' WHERE user='new_user';
UPDATE mysql.user SET USER='new_dest' WHERE user='plug_dest';
@@ -163,7 +162,7 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
new_dest
new_user test_plugin_server new_dest
-connect(plug_user,localhost,new_user,new_dest);
+connect plug_user,localhost,new_user,new_dest;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
new_user@localhost new_dest@%
@@ -178,7 +177,7 @@ new_dest
new_user test_plugin_server new_dest
plug_dest
GRANT ALL PRIVILEGES ON test.* TO new_user;
-connect(plug_user,localhost,new_dest,new_dest_passwd);
+connect plug_user,localhost,new_dest,new_dest_passwd;
select USER(),CURRENT_USER();
USER() CURRENT_USER()
new_dest@localhost new_dest@%
@@ -192,7 +191,7 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
test_plugin_server proxied_user
proxied_user
-connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect proxy_con,localhost,proxied_user,proxied_user_passwd;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
proxied_user@localhost proxied_user@%
@@ -202,16 +201,15 @@ SELECT @@proxy_user;
NULL
connection default;
disconnect proxy_con;
-connect(proxy_con,localhost,proxy_user,proxied_user);
ERROR 28000: Access denied for user 'proxy_user'@'localhost' (using password: YES)
GRANT PROXY ON proxied_user TO ''@'%%';
-connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect proxy_con,localhost,proxied_user,proxied_user_passwd;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
proxied_user@localhost proxied_user@%
connection default;
disconnect proxy_con;
-connect(proxy_con,localhost,proxy_user,proxied_user);
+connect proxy_con,localhost,proxy_user,proxied_user;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
proxy_user@localhost proxied_user@%
@@ -229,7 +227,7 @@ SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
test_plugin_server proxied_user
proxied_user
-connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect proxy_con,localhost,proxied_user,proxied_user_passwd;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
proxied_user@localhost proxied_user@%
@@ -238,16 +236,15 @@ SELECT @@proxy_user;
NULL
connection default;
disconnect proxy_con;
-connect(proxy_con,localhost,proxy_user,proxied_user);
ERROR 28000: Access denied for user 'proxy_user'@'localhost' (using password: YES)
GRANT PROXY ON proxied_user TO ''@'%%';
-connect(proxy_con,localhost,proxied_user,proxied_user_passwd);
+connect proxy_con,localhost,proxied_user,proxied_user_passwd;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
proxied_user@localhost proxied_user@%
connection default;
disconnect proxy_con;
-connect(proxy_con,localhost,proxy_user,proxied_user);
+connect proxy_con,localhost,proxy_user,proxied_user;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
proxy_user@localhost proxied_user@%
@@ -276,11 +273,11 @@ proxied_user_2
proxied_user_3
proxied_user_4
proxied_user_5
-connect(proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd');
-connect(proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd);
-connect(proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd);
-connect(proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd);
-connect(proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd);
+connect proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd';
+connect proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd;
+connect proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd;
+connect proxy_con_4,localhost,proxied_user_4,proxied_user_4_pwd;
+connect proxy_con_5,localhost,proxied_user_5,proxied_user_5_pwd;
connection proxy_con_1;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
diff --git a/mysql-test/r/plugin_not_embedded.result b/mysql-test/r/plugin_not_embedded.result
index 8106abc497f..2edf6c496d3 100644
--- a/mysql-test/r/plugin_not_embedded.result
+++ b/mysql-test/r/plugin_not_embedded.result
@@ -3,11 +3,16 @@
#
CREATE USER bug51770@localhost;
GRANT INSERT ON mysql.plugin TO bug51770@localhost;
+connect con1,localhost,bug51770,,;
INSTALL PLUGIN example SONAME 'ha_example.so';
UNINSTALL PLUGIN example;
ERROR 42000: DELETE command denied to user 'bug51770'@'localhost' for table 'plugin'
+connection default;
GRANT DELETE ON mysql.plugin TO bug51770@localhost;
+connection con1;
UNINSTALL PLUGIN example;
+disconnect con1;
+connection default;
DROP USER bug51770@localhost;
INSTALL PLUGIN example SONAME '../ha_example.so';
ERROR HY000: No paths allowed for shared library
diff --git a/mysql-test/r/plugin_vars.result b/mysql-test/r/plugin_vars.result
index 869e0cf9a2a..0e382427b1d 100644
--- a/mysql-test/r/plugin_vars.result
+++ b/mysql-test/r/plugin_vars.result
@@ -15,8 +15,18 @@ WHILE x DO
SET x= x - 1;
SHOW VARIABLES;
END WHILE|
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
CALL p_install(100);
+connection con2;
CALL p_show_vars(100);
+connection default;
+connection con1;
+connection con2;
+connection default;
+disconnect con1;
+disconnect con2;
USE test;
DROP PROCEDURE p_install;
DROP PROCEDURE p_show_vars;
diff --git a/mysql-test/r/pool_of_threads.result b/mysql-test/r/pool_of_threads.result
index 9611d7ff43b..96ed24a0967 100644
--- a/mysql-test/r/pool_of_threads.result
+++ b/mysql-test/r/pool_of_threads.result
@@ -2157,23 +2157,36 @@ Warnings:
Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
SET optimizer_switch=@save_optimizer_switch;
+connection default;
SELECT sleep(5.5);
+connect con2,localhost,root,,;
+connection con2;
SELECT sleep(5);
# -- Success: more than --thread_pool_max_threads normal connections not possible
+connection default;
sleep(5.5)
0
+connection con2;
sleep(5)
0
+connection default;
SELECT sleep(5);
+connection con2;
SELECT sleep(5);
+connect extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
+connection extracon;
SELECT 'Connection on extra port ok';
Connection on extra port ok
Connection on extra port ok
+connect extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
+connection extracon2;
SELECT 'Connection on extra port 2 ok';
Connection on extra port 2 ok
Connection on extra port 2 ok
# -- Success: more than --extra-max-connections + 1 normal connections not possible
+connection default;
sleep(5)
0
+connection con2;
sleep(5)
0
diff --git a/mysql-test/r/processlist.result b/mysql-test/r/processlist.result
index ebec6175a5b..b8e2271530d 100644
--- a/mysql-test/r/processlist.result
+++ b/mysql-test/r/processlist.result
@@ -1,22 +1,30 @@
SET DEBUG_SYNC = 'dispatch_command_before_set_time WAIT_FOR do_set_time';
SELECT 1;
+connect con1,localhost,root,,;
SET DEBUG_SYNC = 'fill_schema_processlist_after_unow SIGNAL do_set_time WAIT_FOR fill_schema_proceed';
SELECT ID, TIME,TIME_MS FROM INFORMATION_SCHEMA.PROCESSLIST WHERE CONCAT(":", ID, ":") = ":TID:";
+connection default;
1
1
SET DEBUG_SYNC = 'now SIGNAL fill_schema_proceed';
+connection con1;
ID TIME TIME_MS
TID 0 0.000
set debug_sync='reset';
+connection default;
+connection con1;
SET debug_dbug="+d,sleep_inject_query_done_debug_sync";
select sleep(5);
sleep(5)
0
+connection default;
SET DEBUG_SYNC = 'now WAIT_FOR query_done';
select command, time < 5 from information_schema.processlist where id != connection_id();
command time < 5
Sleep 1
+disconnect con1;
set debug_sync='reset';
+connection default;
#
# 10.1 tests
#
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index e8a7eb133fb..d72ecd65547 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -897,10 +897,13 @@ show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 0
prepare stmt from "select 1";
+connect con1,localhost,root,,;
+connection con1;
prepare stmt from "select 2";
prepare stmt1 from "select 3";
prepare stmt2 from "select 4";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
+connection default;
prepare stmt2 from "select 4";
ERROR 42000: Can't create more than max_prepared_stmt_count statements (current value: 3)
select @@max_prepared_stmt_count;
@@ -909,6 +912,8 @@ select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 3
+disconnect con1;
+connection default;
deallocate prepare stmt;
select @@max_prepared_stmt_count;
@@max_prepared_stmt_count
@@ -2895,12 +2900,14 @@ INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (i INT);
INSERT INTO t2 VALUES (2);
LOCK TABLE t1 READ, t2 WRITE;
+connect conn1, localhost, root, , ;
PREPARE stmt1 FROM "SELECT i FROM t1";
PREPARE stmt2 FROM "INSERT INTO t2 (i) VALUES (3)";
EXECUTE stmt1;
i
1
EXECUTE stmt2;
+connection default;
SELECT * FROM t2;
i
2
@@ -2913,6 +2920,7 @@ ALTER TABLE t1 ADD COLUMN j INT;
ALTER TABLE t2 ADD COLUMN j INT;
INSERT INTO t1 VALUES (4, 5);
INSERT INTO t2 VALUES (4, 5);
+connection conn1;
EXECUTE stmt1;
i
1
@@ -2924,6 +2932,8 @@ i j
3 NULL
4 5
3 NULL
+disconnect conn1;
+connection default;
DROP TABLE t1, t2;
drop table if exists t1;
Warnings:
@@ -3793,11 +3803,16 @@ DROP TABLE t1;
#
# Test that metadata locks taken during prepare are released.
#
+connect con1,localhost,root,,;
+connection default;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
+connection con1;
BEGIN;
PREPARE stmt1 FROM "SELECT * FROM t1";
+connection default;
DROP TABLE t1;
+disconnect con1;
#
# Bug#56115: invalid memory reads when PS selecting from
diff --git a/mysql-test/r/ps_ddl.result b/mysql-test/r/ps_ddl.result
index dec0d12c455..a665224f59d 100644
--- a/mysql-test/r/ps_ddl.result
+++ b/mysql-test/r/ps_ddl.result
@@ -1820,6 +1820,8 @@ create procedure p_12093(a int) select * from t_12093;
create function f_12093_unrelated() returns int return 2;
create procedure p_12093_unrelated() begin end;
create view v_12093_unrelated as select * from t_12093;
+connect con1,localhost,root,,;
+connection default;
prepare stmt_sf from 'select f_12093();';
prepare stmt_sp from 'call p_12093(f_12093())';
execute stmt_sf;
@@ -1827,7 +1829,9 @@ f_12093()
0
execute stmt_sp;
a
+connection con1;
drop function f_12093_unrelated;
+connection default;
# XXX: used to be a bug
execute stmt_sf;
f_12093()
@@ -1842,6 +1846,7 @@ f_12093()
# XXX: used to be a bug
execute stmt_sp;
a
+connection default;
prepare stmt_sf from 'select f_12093();';
prepare stmt_sp from 'call p_12093(f_12093())';
execute stmt_sf;
@@ -1849,7 +1854,9 @@ f_12093()
0
execute stmt_sp;
a
+connection con1;
drop procedure p_12093_unrelated;
+connection default;
# XXX: used to be a bug
execute stmt_sf;
f_12093()
@@ -1864,6 +1871,7 @@ f_12093()
# XXX: used to be a bug
execute stmt_sp;
a
+connection default;
prepare stmt_sf from 'select f_12093();';
prepare stmt_sp from 'call p_12093(f_12093())';
execute stmt_sf;
@@ -1871,7 +1879,9 @@ f_12093()
0
execute stmt_sp;
a
+connection con1;
drop view v_12093_unrelated;
+connection default;
# XXX: used to be a bug
execute stmt_sf;
f_12093()
@@ -1886,9 +1896,11 @@ f_12093()
# XXX: used to be a bug
execute stmt_sp;
a
+connection default;
call p_verify_reprepare_count(6);
SUCCESS
+disconnect con1;
drop table t_12093;
drop function f_12093;
drop procedure p_12093;
diff --git a/mysql-test/r/ps_grant.result b/mysql-test/r/ps_grant.result
index 388f6aa7c91..0e296cdc699 100644
--- a/mysql-test/r/ps_grant.result
+++ b/mysql-test/r/ps_grant.result
@@ -13,6 +13,8 @@ show grants for second_user@localhost ;
Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
+connect con3,localhost,second_user,looser,mysqltest;
+connection con3;
select current_user();
current_user()
second_user@localhost
@@ -27,6 +29,7 @@ my_col
1
select a as my_col from t1;
ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1'
+connection default;
grant select on mysqltest.t1 to second_user@localhost
identified by 'looser' ;
show grants for second_user@localhost ;
@@ -40,6 +43,7 @@ Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost'
+connection con3;
show grants for second_user@localhost ;
Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
@@ -55,17 +59,21 @@ my_col
execute s_t9 ;
ERROR 42S02: Table 'mysqltest.t9' doesn't exist
deallocate prepare s_t9;
+connection default;
revoke all privileges on mysqltest.t1 from second_user@localhost;
show grants for second_user@localhost ;
Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
+connection con3;
show grants for second_user@localhost ;
Grants for second_user@localhost
GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
execute s_t1 ;
ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1'
+connection default;
+disconnect con3;
revoke all privileges, grant option from second_user@localhost ;
show grants for second_user@localhost ;
Grants for second_user@localhost
diff --git a/mysql-test/r/query_cache_28249.result b/mysql-test/r/query_cache_28249.result
index 72d713e8e70..ba694179ceb 100644
--- a/mysql-test/r/query_cache_28249.result
+++ b/mysql-test/r/query_cache_28249.result
@@ -3,8 +3,10 @@ SET @query_cache_limit= @@global.query_cache_limit;
SET @query_cache_min_res_unit= @@global.query_cache_min_res_unit;
SET @query_cache_size= @@global.query_cache_size;
# Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
-# Establish connections user1,user2,user3 (user=root)
-# Switch to connection user1
+connect user1,localhost,root,,test,,;
+connect user2,localhost,root,,test,,;
+connect user3,localhost,root,,test,,;
+connection user1;
SET GLOBAL query_cache_type=1;
SET GLOBAL query_cache_limit=10000;
SET GLOBAL query_cache_min_res_unit=0;
@@ -14,13 +16,13 @@ DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
-# Switch to connection user2
+connection user2;
LOCK TABLE t2 WRITE;
-# Switch to connection user1
+connection user1;
# "send" the next select, "reap" the result later.
# The select will be blocked by the write lock on the t1.
SELECT *, (SELECT COUNT(*) FROM t2) FROM t1;
-# Switch to connection user3
+connection user3;
# Poll till the select of connection user1 is blocked by the write lock on t1.
SELECT user,command,state,info FROM information_schema.processlist
WHERE state = 'Waiting for table metadata lock'
@@ -28,18 +30,18 @@ WHERE state = 'Waiting for table metadata lock'
user command state info
root Query Waiting for table metadata lock SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
INSERT INTO t1 VALUES (4);
-# Switch to connection user2
+connection user2;
UNLOCK TABLES;
-# Switch to connection user1
+connection user1;
# Collecting ("reap") the result from the previously blocked select.
# The printing of the result (varies between 3 and 4 rows) set has to be suppressed.
-# Switch to connection user3
+connection user3;
# The next select enforces that effects of "concurrent_inserts" like the
# record with a = 4 is missing in result sets can no more happen.
SELECT 1 FROM t1 WHERE a = 4;
1
1
-# Switch to connection user1
+connection user1;
# The next result set must contain 4 rows.
SELECT *, (SELECT COUNT(*) FROM t2) FROM t1;
a (SELECT COUNT(*) FROM t2)
@@ -55,7 +57,10 @@ a (SELECT COUNT(*) FROM t2)
3 0
4 0
DROP TABLE t1,t2;
-# Switch to connection default + close connections user1,user2,user3
+connection default;
+disconnect user1;
+disconnect user2;
+disconnect user3;
SET GLOBAL query_cache_type= @query_cache_type;
SET GLOBAL query_cache_limit= @query_cache_limit;
SET GLOBAL query_cache_min_res_unit= @query_cache_min_res_unit;
diff --git a/mysql-test/r/query_cache_debug.result b/mysql-test/r/query_cache_debug.result
index 01c642b325b..afc1eb3d135 100644
--- a/mysql-test/r/query_cache_debug.result
+++ b/mysql-test/r/query_cache_debug.result
@@ -5,24 +5,34 @@ set global query_cache_size= 1024*768;
drop table if exists t1;
create table t1 (a varchar(100));
insert into t1 values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
+connect bug30887con1, localhost, root, ,test;
+connect bug30887con2, localhost, root, ,test;
+connection bug30887con1;
Activate debug hook and attempt to retrieve the statement from the cache.
set debug_sync="wait_in_query_cache_insert SIGNAL parked WAIT_FOR go";
select SQL_CACHE * from t1;;
+connection default;
set debug_sync="now WAIT_FOR parked";
-On a second connection; clear the query cache.
+connection bug30887con2;
+clear the query cache.
show status like 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 1
set global query_cache_size= 0;
+connection default;
Signal the debug hook to release the lock.
set debug_sync="now SIGNAL go";
Show query cache status.
show status like 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 0
+connection bug30887con1;
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+disconnect bug30887con1;
+disconnect bug30887con2;
+connection default;
set debug_sync= 'RESET';
set global query_cache_size= 0;
use test;
@@ -36,24 +46,26 @@ 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
+connect con1,localhost,root,,test,,;
+connect con2,localhost,root,,test,,;
+connection con1;
SET DEBUG_SYNC = "wait_after_query_cache_invalidate SIGNAL parked WAIT_FOR go";
# Send concurrent insert, will wait in the query cache table invalidate
INSERT INTO t1 VALUES (4);
-# Switch to connection default
+connection default;
# Wait for concurrent insert to reach the debug point
SET DEBUG_SYNC = "now WAIT_FOR parked";
-# Switch to connection con2
+connection con2;
# Send SELECT that shouldn't be cached
SELECT * FROM t1;
a
1
2
3
-# Switch to connection default
+connection default;
# Notify the concurrent insert to proceed
SET DEBUG_SYNC = "now SIGNAL go";
-# Switch to connection con1
+connection con1;
# Gather insert result
SHOW STATUS LIKE "Qcache_queries_in_cache";
Variable_name Value
@@ -68,7 +80,9 @@ a
SHOW STATUS LIKE "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
-# Disconnect
+disconnect con1;
+disconnect con2;
+connection default;
# Restore defaults
SET DEBUG_SYNC= 'RESET';
RESET QUERY CACHE;
@@ -93,7 +107,10 @@ INSERT INTO t2 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
INSERT INTO t3 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
INSERT INTO t4 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
INSERT INTO t5 VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
-=================================== Connection thd1
+connect thd2, localhost, root, ,test;
+connect thd3, localhost, root, ,test;
+connect thd1, localhost, root, ,test;
+connection thd1;
**
** Load Query Cache with a result set and one table.
**
@@ -116,27 +133,27 @@ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
SET DEBUG_SYNC="wait_in_query_cache_invalidate1 SIGNAL parked1_1 WAIT_FOR go1_1";
SET DEBUG_SYNC="wait_in_query_cache_invalidate2 SIGNAL parked1_2 WAIT_FOR go1_2";
DELETE FROM t1 WHERE a like '%a%';;
-=================================== Connection default
+connection default;
** Assert that the expect process status is obtained.
SET DEBUG_SYNC="now WAIT_FOR parked1_1";
**
-=================================== Connection thd2
+connection thd2;
** On THD2: Insert a result into the cache. This attempt will be blocked
** because of a debug hook placed just before the mutex lock after which
** the first part of the result set is written.
SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked2 WAIT_FOR go2 EXECUTE 1";
SELECT SQL_CACHE * FROM t2 UNION SELECT * FROM t3;
-=================================== Connection default
+connection default;
** Assert that the SELECT-stmt thread reaches the sync point.
SET DEBUG_SYNC="now WAIT_FOR parked2";
**
**
-=================================== Connection thd3
+connection thd3;
** On THD3: Insert another result into the cache and block on the same
** debug hook.
SET DEBUG_SYNC="wait_in_query_cache_insert SIGNAL parked3 WAIT_FOR go3 EXECUTE 1";
SELECT SQL_CACHE * FROM t4 UNION SELECT * FROM t5;
-=================================== Connection default
+connection default;
** Assert that the SELECT-stmt thread reaches the sync point.
SET DEBUG_SYNC="now WAIT_FOR parked3";
**
@@ -166,23 +183,28 @@ SET DEBUG_SYNC="now SIGNAL go1_2";
**
*************************************************************************
** No tables should be locked
-=================================== Connection thd2
+connection thd2;
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
DELETE FROM t1;
DELETE FROM t2;
DELETE FROM t3;
-=================================== Connection thd3
+connection thd3;
a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
DELETE FROM t4;
DELETE FROM t5;
-=================================== Connection thd1
+connection thd1;
** Done.
+connection default;
+disconnect thd1;
+disconnect thd2;
+disconnect thd3;
SET DEBUG_SYNC= 'RESET';
SET GLOBAL query_cache_size= 0;
+connection default;
# Restore defaults
RESET QUERY CACHE;
FLUSH STATUS;
@@ -199,22 +221,27 @@ 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
+connect con1,localhost,root,,test,,;
+connect con2,localhost,root,,test,,;
+connection con1;
SET DEBUG_SYNC = "wait_in_query_cache_invalidate2 SIGNAL parked WAIT_FOR go";
# Send INSERT, will wait in the query cache table invalidation
INSERT INTO t1 VALUES (4);;
-# Switch to connection default
+connection default;
# Wait for insert to reach the debug point
SET DEBUG_SYNC = "now WAIT_FOR parked";
-# Switch to connection con2
+connection con2;
# Send a query that should wait on the query cache lock
RESET QUERY CACHE;
-# Switch to connection default
+connection default;
# Wait for the state to be reflected in the processlist
# Signal that the query cache can be unlocked
SET DEBUG_SYNC="now SIGNAL go";
-# Reap con1 and disconnect
-# Reap con2 and disconnect
+connection con1;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection default;
# Restore defaults
SET DEBUG_SYNC= 'RESET';
RESET QUERY CACHE;
diff --git a/mysql-test/r/query_cache_notembedded.result b/mysql-test/r/query_cache_notembedded.result
index 400ac2b2718..bfb8f4d1ff7 100644
--- a/mysql-test/r/query_cache_notembedded.result
+++ b/mysql-test/r/query_cache_notembedded.result
@@ -84,21 +84,31 @@ show status like "Qcache_free_blocks";
Variable_name Value
Qcache_free_blocks 1
drop table t1, t2, t3, t11, t21;
+connect root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root;
CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY AUTO_INCREMENT ) ENGINE =
MyISAM;
LOCK TABLE t1 READ LOCAL;
+connect root2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection root2;
INSERT INTO t1 VALUES (), (), ();
+connection root;
SELECT * FROM t1;
a
+connection root2;
SELECT * FROM t1;
a
1
2
3
+connection root;
SELECT * FROM t1;
a
UNLOCK TABLES;
drop table t1;
+connection default;
+disconnect root;
+disconnect root2;
flush query cache;
reset query cache;
flush status;
@@ -319,6 +329,7 @@ drop procedure f2;
drop procedure f3;
drop procedure f4;
drop table t1;
+connection default;
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
SET GLOBAL log_bin_trust_function_creators = 1;
reset query cache;
@@ -333,15 +344,21 @@ insert into t1 values(3);
set i_var = sleep(3);
return 0;
end;|
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
select f1();
+connection con2;
select sleep(4);
sleep(4)
0
select * from t1;
id
3
+connection con1;
f1()
0
+connection con2;
select * from t1;
id
3
@@ -351,6 +368,9 @@ id
3
drop table t1;
drop function f1;
+disconnect con1;
+disconnect con2;
+connection default;
set GLOBAL query_cache_size=0;
SET @@global.log_bin_trust_function_creators = @old_log_bin_trust_function_creators;
DROP DATABASE IF EXISTS bug30269;
@@ -363,6 +383,8 @@ INSERT INTO test1 VALUES (5, 'testit');
GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost';
GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost';
set global query_cache_size= 81920;
+connect bug30269, localhost, bug30269,,;
+connection bug30269;
USE bug30269;
show status like 'Qcache_queries_in_cache';
Variable_name Value
@@ -380,8 +402,10 @@ id
show status like 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 1
+connection default;
USE test;
DROP DATABASE bug30269;
+disconnect bug30269;
DROP USER 'bug30269'@'localhost';
set GLOBAL query_cache_type=ON;
set LOCAL query_cache_type=ON;
diff --git a/mysql-test/r/query_cache_ps_no_prot.result b/mysql-test/r/query_cache_ps_no_prot.result
index 5076003a7fb..ef1f92b597d 100644
--- a/mysql-test/r/query_cache_ps_no_prot.result
+++ b/mysql-test/r/query_cache_ps_no_prot.result
@@ -1,7 +1,7 @@
set GLOBAL query_cache_type=ON;
set LOCAL query_cache_type=ON;
----- establish connection con1 (root) ----
----- switch to connection default ----
+connect con1,localhost,root,,test,$MASTER_MYPORT,;
+connection default;
set @initial_query_cache_size = @@global.query_cache_size;
set @@global.query_cache_size=102400;
flush status;
@@ -49,7 +49,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 5
----- switch to connection con1 ----
+connection con1;
prepare stmt3 from "select * from t1 where c1=10";
execute stmt3;
c1
@@ -69,7 +69,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 8
----- switch to connection default ----
+connection default;
prepare stmt10 from "SELECT * FROM t1 WHERE c1 = 100";
show status like 'Qcache_hits';
Variable_name Value
@@ -92,18 +92,18 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 10
----- switch to connection con1 ----
+connection con1;
SELECT * FROM t1 WHERE c1 = 100;
c1
100
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 11
----- switch to connection default ----
+connection default;
prepare stmt11 from "SELECT * FROM t1 WHERE c1 = 1";
----- switch to connection con1 ----
+connection con1;
prepare stmt12 from "SELECT * FROM t1 WHERE c1 = 1";
----- switch to connection default ----
+connection default;
SELECT * FROM t1 WHERE c1 = 1;
c1
1
@@ -122,14 +122,14 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 13
----- switch to connection con1 ----
+connection con1;
execute stmt12;
c1
1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
----- switch to connection default ----
+connection default;
prepare stmt1 from "select * from t1 where c1=?";
show status like 'Qcache_hits';
Variable_name Value
@@ -147,7 +147,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 15
----- switch to connection con1 ----
+connection con1;
set @a=1;
prepare stmt4 from "select * from t1 where c1=?";
execute stmt4 using @a;
@@ -169,7 +169,7 @@ execute stmt4 using @a;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
----- switch to connection default ----
+connection default;
prepare stmt1 from "select * from t1 where c1=10";
set global query_cache_size=0;
show status like 'Qcache_hits';
@@ -193,7 +193,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
----- switch to connection con1 ----
+connection con1;
execute stmt3;
c1
10
@@ -212,7 +212,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
----- switch to connection default ----
+connection default;
set global query_cache_size=102400;
execute stmt1;
c1
@@ -232,7 +232,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 18
----- switch to connection con1 ----
+connection con1;
execute stmt3;
c1
10
@@ -251,7 +251,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
----- switch to connection default ----
+connection default;
set global query_cache_size=0;
show status like 'Qcache_hits';
Variable_name Value
@@ -274,7 +274,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
----- switch to connection con1 ----
+connection con1;
execute stmt3;
c1
10
@@ -293,12 +293,12 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
----- switch to connection default ----
+connection default;
set global query_cache_size=0;
prepare stmt1 from "select * from t1 where c1=10";
----- switch to connection con1 ----
+connection con1;
prepare stmt3 from "select * from t1 where c1=10";
----- switch to connection default ----
+connection default;
set global query_cache_size=102400;
show status like 'Qcache_hits';
Variable_name Value
@@ -321,7 +321,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
----- switch to connection con1 ----
+connection con1;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
@@ -343,7 +343,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
----- switch to connection default ----
+connection default;
set global query_cache_size=0;
prepare stmt1 from "select * from t1 where c1=?";
set global query_cache_size=102400;
@@ -372,7 +372,7 @@ show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
drop table t1;
----- disconnect connection con1 ----
+disconnect con1;
########################################################################
#
# BUG#25843: Changing default database between PREPARE and EXECUTE of
diff --git a/mysql-test/r/query_cache_ps_ps_prot.result b/mysql-test/r/query_cache_ps_ps_prot.result
index 4105bc40f94..e3f2da1dbbe 100644
--- a/mysql-test/r/query_cache_ps_ps_prot.result
+++ b/mysql-test/r/query_cache_ps_ps_prot.result
@@ -1,7 +1,7 @@
set GLOBAL query_cache_type=ON;
set LOCAL query_cache_type=ON;
----- establish connection con1 (root) ----
----- switch to connection default ----
+connect con1,localhost,root,,test,$MASTER_MYPORT,;
+connection default;
set @initial_query_cache_size = @@global.query_cache_size;
set @@global.query_cache_size=102400;
flush status;
@@ -49,7 +49,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 5
----- switch to connection con1 ----
+connection con1;
prepare stmt3 from "select * from t1 where c1=10";
execute stmt3;
c1
@@ -69,7 +69,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 8
----- switch to connection default ----
+connection default;
prepare stmt10 from "SELECT * FROM t1 WHERE c1 = 100";
show status like 'Qcache_hits';
Variable_name Value
@@ -92,18 +92,18 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 9
----- switch to connection con1 ----
+connection con1;
SELECT * FROM t1 WHERE c1 = 100;
c1
100
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 10
----- switch to connection default ----
+connection default;
prepare stmt11 from "SELECT * FROM t1 WHERE c1 = 1";
----- switch to connection con1 ----
+connection con1;
prepare stmt12 from "SELECT * FROM t1 WHERE c1 = 1";
----- switch to connection default ----
+connection default;
SELECT * FROM t1 WHERE c1 = 1;
c1
1
@@ -122,14 +122,14 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 11
----- switch to connection con1 ----
+connection con1;
execute stmt12;
c1
1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 12
----- switch to connection default ----
+connection default;
prepare stmt1 from "select * from t1 where c1=?";
show status like 'Qcache_hits';
Variable_name Value
@@ -147,7 +147,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 13
----- switch to connection con1 ----
+connection con1;
set @a=1;
prepare stmt4 from "select * from t1 where c1=?";
execute stmt4 using @a;
@@ -169,7 +169,7 @@ execute stmt4 using @a;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
----- switch to connection default ----
+connection default;
prepare stmt1 from "select * from t1 where c1=10";
set global query_cache_size=0;
show status like 'Qcache_hits';
@@ -193,7 +193,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
----- switch to connection con1 ----
+connection con1;
execute stmt3;
c1
10
@@ -212,7 +212,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
----- switch to connection default ----
+connection default;
set global query_cache_size=102400;
execute stmt1;
c1
@@ -232,7 +232,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
----- switch to connection con1 ----
+connection con1;
execute stmt3;
c1
10
@@ -251,7 +251,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
----- switch to connection default ----
+connection default;
set global query_cache_size=0;
show status like 'Qcache_hits';
Variable_name Value
@@ -274,7 +274,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
----- switch to connection con1 ----
+connection con1;
execute stmt3;
c1
10
@@ -293,12 +293,12 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
----- switch to connection default ----
+connection default;
set global query_cache_size=0;
prepare stmt1 from "select * from t1 where c1=10";
----- switch to connection con1 ----
+connection con1;
prepare stmt3 from "select * from t1 where c1=10";
----- switch to connection default ----
+connection default;
set global query_cache_size=102400;
show status like 'Qcache_hits';
Variable_name Value
@@ -321,7 +321,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
----- switch to connection con1 ----
+connection con1;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
@@ -343,7 +343,7 @@ c1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
----- switch to connection default ----
+connection default;
set global query_cache_size=0;
prepare stmt1 from "select * from t1 where c1=?";
set global query_cache_size=102400;
@@ -372,7 +372,7 @@ show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
drop table t1;
----- disconnect connection con1 ----
+disconnect con1;
########################################################################
#
# BUG#25843: Changing default database between PREPARE and EXECUTE of
diff --git a/mysql-test/r/quick_select_4161.result b/mysql-test/r/quick_select_4161.result
index 18ac4362a84..30ae0a09edc 100644
--- a/mysql-test/r/quick_select_4161.result
+++ b/mysql-test/r/quick_select_4161.result
@@ -22,11 +22,16 @@ INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25),
('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43),
('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37),
('1999-09-19',100100,37), ('2000-12-18',100700,38);
+connect killee, localhost, root;
set debug_sync='inside_make_join_statistics signal killme wait_for done';
select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
+connection default;
set debug_sync='now wait_for killme';
kill %connection%;
set debug_sync='now signal done';
+connection killee;
Got one of the listed errors
+connection default;
+disconnect killee;
drop table t1;
set debug_sync='reset';
diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result
index 964c259ebf8..e6fc5e670ef 100644
--- a/mysql-test/r/read_only.result
+++ b/mysql-test/r/read_only.result
@@ -2,7 +2,7 @@ set @start_read_only= @@global.read_only;
DROP TABLE IF EXISTS t1,t2,t3;
create user test@localhost;
grant CREATE, SELECT, DROP on *.* to test@localhost;
-connect (con1,localhost,test,,test);
+connect con1,localhost,test,,test;
connection default;
set global read_only=0;
connection con1;
@@ -109,7 +109,7 @@ set global read_only=0;
flush tables with read lock;
set global read_only=1;
unlock tables;
-connect (root2,localhost,root,,test);
+connect root2,localhost,root,,test;
connection default;
set global read_only=0;
flush tables with read lock;
@@ -120,6 +120,7 @@ select @@global.read_only;
@@global.read_only
1
unlock tables;
+disconnect root2;
drop temporary table ttt;
ERROR 42S02: Unknown table 'test.ttt'
drop temporary table if exists ttt;
@@ -127,6 +128,7 @@ Warnings:
Note 1051 Unknown table 'test.ttt'
connection default;
set global read_only=0;
+disconnect con1;
drop table t1,t2;
drop user test@localhost;
#
@@ -145,7 +147,7 @@ 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,);
+connect con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,;
connection con_bug27440;
create database mysqltest_db2;
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
@@ -171,6 +173,8 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (1), (2);
CREATE USER user1;
+connect con1, localhost, user1;
+connection default;
SET GLOBAL read_only= 1;
# All allowed with super privilege
START TRANSACTION;
@@ -181,6 +185,7 @@ START TRANSACTION READ WRITE;
COMMIT;
# We allow implicit RW transaction without super privilege
# for compatibility reasons
+connection con1;
START TRANSACTION;
# Check that table updates are still disallowed.
INSERT INTO t1 VALUES (3);
@@ -196,6 +201,8 @@ COMMIT;
START TRANSACTION READ WRITE;
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
COMMIT;
+disconnect con1;
+connection default;
DROP USER user1;
SET GLOBAL read_only= 0;
DROP TABLE t1;
diff --git a/mysql-test/r/read_only_innodb.result b/mysql-test/r/read_only_innodb.result
index a276e6cbc19..abfc5322ed0 100644
--- a/mysql-test/r/read_only_innodb.result
+++ b/mysql-test/r/read_only_innodb.result
@@ -1,11 +1,16 @@
DROP TABLE IF EXISTS table_11733 ;
create user test@localhost;
grant CREATE, SELECT, DROP on *.* to test@localhost;
+connect con1,localhost,test,,test;
+connection default;
set global read_only=0;
create table table_11733 (a int) engine=InnoDb;
+connection con1;
BEGIN;
insert into table_11733 values(11733);
+connection default;
set global read_only=1;
+connection con1;
select @@global.read_only;
@@global.read_only
1
@@ -14,14 +19,19 @@ a
11733
COMMIT;
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
+connection default;
set global read_only=0;
drop table table_11733 ;
drop user test@localhost;
+disconnect con1;
create user test@localhost;
GRANT CREATE, SELECT, DROP ON *.* TO test@localhost;
+connect con1, localhost, test, , test;
+connection default;
CREATE TABLE t1(a INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (0), (1);
SET GLOBAL read_only=1;
+connection con1;
SELECT * FROM t1;
a
0
@@ -32,8 +42,10 @@ a
0
1
COMMIT;
+connection default;
SET GLOBAL read_only=0;
FLUSH TABLES WITH READ LOCK;
+connection con1;
SELECT * FROM t1;
a
0
@@ -44,6 +56,7 @@ a
0
1
COMMIT;
+connection default;
UNLOCK TABLES;
connection con1;
lock table t1 read;
@@ -56,6 +69,7 @@ SET GLOBAL read_only=0;
UNLOCK TABLES;
DROP TABLE t1;
DROP USER test@localhost;
+disconnect con1;
echo End of 5.1 tests
#
# Bug#33669: Transactional temporary tables do not work under --read-only
@@ -71,7 +85,7 @@ INSERT INTO db1.t2 VALUES (2);
GRANT CREATE TEMPORARY TABLES, DROP, INSERT, DELETE, UPDATE,
SELECT, LOCK TABLES ON db1.* TO bug33669@localhost;
SET GLOBAL READ_ONLY = ON;
-# Connection con1 (user bug33669):
+connect con1,localhost,bug33669,,db1;
# Create, insert and drop temporary table:
@@ -225,6 +239,8 @@ DROP TABLE temp1, temp2;
# Disconnect and cleanup
+disconnect con1;
+connection default;
SET GLOBAL READ_ONLY = OFF;
DROP USER bug33669@localhost;
DROP DATABASE db1;
diff --git a/mysql-test/r/rename.result b/mysql-test/r/rename.result
index 74370ba74dd..2b8c925b309 100644
--- a/mysql-test/r/rename.result
+++ b/mysql-test/r/rename.result
@@ -40,20 +40,31 @@ select * from t3;
drop table if exists t1,t2,t3,t4;
Warnings:
Note 1051 Unknown table 'test.t4'
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
CREATE TABLE t1 (a int);
CREATE TABLE t3 (a int);
+connection con2;
FLUSH TABLES WITH READ LOCK;
+connection con1;
RENAME TABLE t1 TO t2, t3 to t4;
+connection con2;
show tables;
Tables_in_test
t1
t3
UNLOCK TABLES;
+connection con1;
+connection con2;
show tables;
Tables_in_test
t2
t4
drop table t2, t4;
+disconnect con2;
+disconnect con1;
+connection default;
End of 4.1 tests
#
# Bug#14959: "ALTER TABLE isn't able to rename a view"
diff --git a/mysql-test/r/rpl_mysqldump_slave.result b/mysql-test/r/rpl_mysqldump_slave.result
index 9d2fe860f47..903b671178f 100644
--- a/mysql-test/r/rpl_mysqldump_slave.result
+++ b/mysql-test/r/rpl_mysqldump_slave.result
@@ -3,7 +3,10 @@ include/master-slave.inc
#
# New --dump-slave, --apply-slave-statements functionality
#
+connection slave;
+connection master;
use test;
+connection slave;
-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
STOP ALL SLAVES;
@@ -23,9 +26,12 @@ start slave;
Warnings:
Note 1254 Slave is already running
*** Test mysqldump --dump-slave GTID functionality.
+connection master;
SET gtid_seq_no = 1000;
CREATE TABLE t1 (a INT PRIMARY KEY);
DROP TABLE t1;
+connection slave;
+connection slave;
CREATE TABLE t2 (a INT PRIMARY KEY);
DROP TABLE t2;
diff --git a/mysql-test/r/schema.result b/mysql-test/r/schema.result
index bb6dbd65f84..6d8271a49f3 100644
--- a/mysql-test/r/schema.result
+++ b/mysql-test/r/schema.result
@@ -16,80 +16,90 @@ drop schema foo;
# Bug #48940 MDL deadlocks against mysql_rm_db
#
DROP SCHEMA IF EXISTS schema1;
-# Connection default
+connect con2, localhost, root;
+connection default;
CREATE SCHEMA schema1;
CREATE TABLE schema1.t1 (a INT);
SET autocommit= FALSE;
INSERT INTO schema1.t1 VALUES (1);
-# Connection 2
+connection con2;
DROP SCHEMA schema1;
-# Connection default
+connection default;
ALTER SCHEMA schema1 DEFAULT CHARACTER SET utf8;
Got one of the listed errors
SET autocommit= TRUE;
-# Connection 2
-# Connection default
+connection con2;
+connection default;
+disconnect con2;
#
# Bug #49988 MDL deadlocks with mysql_create_db, reload_acl_and_cache
#
DROP SCHEMA IF EXISTS schema1;
-# Connection default
+connect con2, localhost, root;
+connection default;
CREATE SCHEMA schema1;
CREATE TABLE schema1.t1 (id INT);
LOCK TABLE schema1.t1 WRITE;
-# Connection con2
+connection con2;
DROP SCHEMA schema1;
-# Connection default
+connection default;
# CREATE SCHEMA used to give a deadlock.
# Now we prohibit CREATE SCHEMA in LOCK TABLES mode.
CREATE SCHEMA IF NOT EXISTS schema1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
# UNLOCK TABLES so DROP SCHEMA can continue.
UNLOCK TABLES;
-# Connection con2
-# Connection default
+connection con2;
+connection default;
+disconnect con2;
#
# Bug#54360 Deadlock DROP/ALTER/CREATE DATABASE with open HANDLER
#
CREATE DATABASE db1;
CREATE TABLE db1.t1 (a INT);
INSERT INTO db1.t1 VALUES (1), (2);
-# Connection con1
+connect con1, localhost, root;
HANDLER db1.t1 OPEN;
-# Connection default
+connection default;
# Sending:
DROP DATABASE db1;
-# Connection con2
-# Connection con1
+connect con2, localhost, root;
+connection con1;
CREATE DATABASE db2;
ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
DROP DATABASE db2;
HANDLER t1 CLOSE;
-# Connection default
+connection default;
# Reaping: DROP DATABASE db1
+disconnect con1;
+disconnect con2;
#
# Tests for increased CREATE/ALTER/DROP DATABASE concurrency with
# database name locks.
#
DROP DATABASE IF EXISTS db1;
DROP DATABASE IF EXISTS db2;
-# Connection default
+connect con2, localhost, root;
+connect con3, localhost, root;
+connection default;
CREATE DATABASE db1;
CREATE TABLE db1.t1 (id INT);
START TRANSACTION;
INSERT INTO db1.t1 VALUES (1);
-# Connection 2
+connection con2;
# DROP DATABASE should block due to the active transaction
# Sending:
DROP DATABASE db1;
-# Connection 3
+connection con3;
# But it should still be possible to CREATE/ALTER/DROP other databases.
CREATE DATABASE db2;
ALTER DATABASE db2 DEFAULT CHARACTER SET utf8;
DROP DATABASE db2;
-# Connection default
+connection default;
# End the transaction so DROP DATABASE db1 can continue
COMMIT;
-# Connection 2
+connection con2;
# Reaping: DROP DATABASE db1
-# Connection default;
+connection default;
+disconnect con2;
+disconnect con3;
diff --git a/mysql-test/r/shm.result b/mysql-test/r/shm.result
index a2c38627e9d..13f715b4e26 100644
--- a/mysql-test/r/shm.result
+++ b/mysql-test/r/shm.result
@@ -1,3 +1,4 @@
+connect shm_con,localhost,root,,,,$shm_name,SHM;
drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
@@ -2154,6 +2155,8 @@ Privat (Private Nutzung) Mobilfunk
Warnings:
Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
+connection default;
+disconnect shm_con;
mysqld is alive
SET @max_allowed_packet= @@global.max_allowed_packet;
SET @net_buffer_length= @@global.net_buffer_length;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 654b00d68ae..c3e7588a56d 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -524,6 +524,8 @@ create user mysqltest_2@localhost;
grant usage on `mysqltest`.* to mysqltest_2@localhost;
create user mysqltest_3@localhost;
grant drop on `mysqltest`.* to mysqltest_3@localhost;
+connect con1,localhost,mysqltest_1,,mysqltest;
+connection con1;
select * from t1;
a
1
@@ -534,6 +536,9 @@ drop table t1;
ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 't1'
drop database mysqltest;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
+disconnect con1;
+connect con2,localhost,mysqltest_2,,test;
+connection con2;
select * from mysqltest.t1;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't1'
show create database mysqltest;
@@ -542,6 +547,9 @@ drop table mysqltest.t1;
ERROR 42000: DROP command denied to user 'mysqltest_2'@'localhost' for table 't1'
drop database mysqltest;
ERROR 42000: Access denied for user 'mysqltest_2'@'localhost' to database 'mysqltest'
+disconnect con2;
+connect con3,localhost,mysqltest_3,,test;
+connection con3;
select * from mysqltest.t1;
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1'
show create database mysqltest;
@@ -549,6 +557,8 @@ Database Create Database
mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
drop table mysqltest.t1;
drop database mysqltest;
+disconnect con3;
+connection default;
set names binary;
delete from mysql.user
where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3';
@@ -1284,9 +1294,13 @@ create table mysqltest.t1(a int);
insert into mysqltest.t1 values(1);
create user mysqltest_4@localhost;
grant select on `mysqltest`.`t1` to mysqltest_4@localhost;
+connect con4,localhost,mysqltest_4,,mysqltest;
+connection con4;
show create database mysqltest;
Database Create Database
mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
+disconnect con4;
+connection default;
delete from mysql.user where user='mysqltest_4';
delete from mysql.db where user='mysqltest_4';
delete from mysql.tables_priv where user='mysqltest_4';
@@ -1458,17 +1472,22 @@ DROP EVENT ev1;
SHOW STORAGE ENGINES;
CREATE USER test_u@localhost;
GRANT PROCESS ON *.* TO test_u@localhost;
+connect conn1, localhost, test_u,,;
SHOW ENGINE MYISAM MUTEX;
SHOW ENGINE MYISAM STATUS;
+disconnect conn1;
+connection default;
DROP USER test_u@localhost;
End of 5.1 tests
#
# Bug#52593 SHOW CREATE TABLE is blocked if table is locked
# for write by another connection
DROP TABLE IF EXISTS t1;
+connect con1, localhost,root;
+connection default;
CREATE TABLE t1 (i INT PRIMARY KEY);
LOCK TABLE t1 WRITE;
-# Switching to connection 'con1'.
+connection con1;
# This statement used to be blocked.
SHOW CREATE TABLE t1;
Table Create Table
@@ -1476,7 +1495,8 @@ t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL,
PRIMARY KEY (`i`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-# Switching to connection 'default'.
+disconnect con1;
+connection default;
UNLOCK TABLES;
DROP TABLE t1;
#
@@ -1485,20 +1505,21 @@ DROP TABLE t1;
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT);
-# Connection con1
+connect con1,localhost,root;
LOCK TABLE t1 WRITE;
-# Connection default
+connection default;
START TRANSACTION;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
-# Connection con1
+connection con1;
ALTER TABLE t1 CHARACTER SET = utf8;
UNLOCK TABLES;
-# Connection default
+connection default;
COMMIT;
+disconnect con1;
DROP TABLE t1;
#
# Bug#55498 SHOW CREATE TRIGGER takes wrong type of metadata lock.
@@ -1507,23 +1528,24 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1;
# Test 1: SHOW CREATE TRIGGER with WRITE locked table.
-# Connection con1
+connect con1, localhost, root;
LOCK TABLE t1 WRITE;
-# Connection default
+connection default;
SHOW CREATE TRIGGER t1_bi;
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
t1_bi NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1 utf8 utf8_general_ci latin1_swedish_ci
-# Connection con1
+connection con1;
UNLOCK TABLES;
# Test 2: ALTER TABLE with SHOW CREATE TRIGGER in transaction
-# Connection default
+connection default;
START TRANSACTION;
SHOW CREATE TRIGGER t1_bi;
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
t1_bi NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a = 1 utf8 utf8_general_ci latin1_swedish_ci
-# Connection con1
+connection con1;
ALTER TABLE t1 CHARACTER SET = utf8;
-# Connection default
+disconnect con1;
+connection default;
COMMIT;
DROP TRIGGER t1_bi;
DROP TABLE t1;
@@ -1534,8 +1556,11 @@ SET NAMES latin1;
SELECT GET_LOCK('t', 1000);
GET_LOCK('t', 1000)
1
+connect con1,localhost,root,,;
+connection con1;
SET NAMES latin1;
SELECT GET_LOCK('t',1000) AS 'óóóó';;
+connection default;
SHOW PROCESSLIST;
Id User Host db Command Time State Info Progress
### root ### test Query ### ### SHOW PROCESSLIST 0.000
@@ -1548,8 +1573,11 @@ Id User Host db Command Time State Info Progress
SELECT RELEASE_LOCK('t');
RELEASE_LOCK('t')
1
+connection con1;
óóóó
1
+disconnect con1;
+connection default;
SET NAMES latin1;
#
# Test SHOW AUTHORS and SHOW CONTRIBUTORS
diff --git a/mysql-test/r/show_explain.result b/mysql-test/r/show_explain.result
index 0dc6f2b28ac..5a885766f7b 100644
--- a/mysql-test/r/show_explain.result
+++ b/mysql-test/r/show_explain.result
@@ -13,38 +13,48 @@ show explain for 2000000000;
ERROR HY000: Unknown thread id: 2000000000
show explain for (select max(a) from t0);
ERROR HY000: You may only use constant expressions in this statement
+connect con1, localhost, root,,;
+connection con1;
SET @old_debug= @@session.debug;
+connection default;
show explain for $thr2;
ERROR HY000: Target is not running an EXPLAINable command
show explain for $thr1;
ERROR HY000: Target is not running an EXPLAINable command
+connection con1;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select count(*) from t1 where a < 100000;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index a a 5 NULL 1000 Using where; Using index
Warnings:
Note 1003 select count(*) from t1 where a < 100000
+connection con1;
count(*)
1000
select max(c) from t1 where a < 10;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 10 Using index condition
Warnings:
Note 1003 select max(c) from t1 where a < 10
+connection con1;
max(c)
9
# We can catch EXPLAIN, too.
set @show_expl_tmp= @@optimizer_switch;
set optimizer_switch='index_condition_pushdown=on,mrr=on,mrr_sort_keys=on';
explain select max(c) from t1 where a < 10;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 10 Using index condition; Rowid-ordered scan
Warnings:
Note 1003 explain select max(c) from t1 where a < 10
+connection con1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 10 Using index condition; Rowid-ordered scan
set optimizer_switch= @show_expl_tmp;
@@ -53,6 +63,7 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
explain select a from t0 A union select a+1 from t0 B;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
@@ -60,6 +71,7 @@ id select_type table type possible_keys key key_len ref rows Extra
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
Warnings:
Note 1003 explain select a from t0 A union select a+1 from t0 B
+connection con1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
2 UNION B ALL NULL NULL NULL NULL 10
@@ -69,6 +81,7 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
explain select a from t0 A union select a+1 from t0 B;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
@@ -76,6 +89,7 @@ id select_type table type possible_keys key key_len ref rows Extra
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
Warnings:
Note 1003 explain select a from t0 A union select a+1 from t0 B
+connection con1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10
2 UNION B ALL NULL NULL NULL NULL 10
@@ -85,12 +99,14 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select a, (select max(a) from t0 B) from t0 A where a<1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
2 SUBQUERY B ALL NULL NULL NULL NULL 10
Warnings:
Note 1003 select a, (select max(a) from t0 B) from t0 A where a<1
+connection con1;
a (select max(a) from t0 B)
0 9
set debug_dbug=@old_debug;
@@ -98,12 +114,14 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
explain select a, (select max(a) from t0 B) from t0 A where a<1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
2 SUBQUERY B ALL NULL NULL NULL NULL 10
Warnings:
Note 1003 explain select a, (select max(a) from t0 B) from t0 A where a<1
+connection con1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 10 Using where
2 SUBQUERY B ALL NULL NULL NULL NULL 10
@@ -112,12 +130,14 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY a ALL NULL NULL NULL NULL 10 Using where
2 DEPENDENT SUBQUERY b ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
+connection con1;
a (select max(a) from t0 b where b.a+a.a<10)
0 9
set debug_dbug=@old_debug;
@@ -125,12 +145,14 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY a ALL NULL NULL NULL NULL 10 Using where
2 DEPENDENT SUBQUERY b ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
+connection con1;
a (select max(a) from t0 b where b.a+a.a<10)
0 9
set debug_dbug=@old_debug;
@@ -138,12 +160,14 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=2;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY a ALL NULL NULL NULL NULL 10 Using where
2 DEPENDENT SUBQUERY b ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
+connection con1;
a (select max(a) from t0 b where b.a+a.a<10)
0 9
set debug_dbug=@old_debug;
@@ -151,12 +175,14 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=2;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY a ALL NULL NULL NULL NULL 10 Using where
2 DEPENDENT SUBQUERY b ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
+connection con1;
a (select max(a) from t0 b where b.a+a.a<10)
0 9
set debug_dbug=@old_debug;
@@ -164,12 +190,14 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_end';
select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY a ALL NULL NULL NULL NULL 10 Using where
2 DEPENDENT SUBQUERY b ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select a, (select max(a) from t0 b where b.a+a.a<10) from t0 a where a<1
+connection con1;
a (select max(a) from t0 b where b.a+a.a<10)
0 9
set debug_dbug=@old_debug;
@@ -179,9 +207,11 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=2;
set debug_dbug='+d,show_explain_probe_join_exec_start';
set @foo= (select max(a) from t0 where sin(a) >0);
+connection default;
show explain for $thr2;
ERROR HY000: Target is not running an EXPLAINable command
kill query $thr2;
+connection con1;
ERROR 70100: Query execution was interrupted
set debug_dbug=@old_debug;
#
@@ -191,6 +221,7 @@ create table t2 as select a as a, a as dummy from t0 limit 2;
set @show_explain_probe_select_id=2;
set debug_dbug='+d,show_explain_probe_join_exec_start';
update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
@@ -203,6 +234,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 update t2 set dummy=0 where (select max(a) from t0 where t2.a + t0.a <3) >3
+connection con1;
drop table t2;
set debug_dbug=@old_debug;
#
@@ -212,6 +244,7 @@ create table t2 as select a as a, a as dummy from t0 limit 2;
set @show_explain_probe_select_id=2;
set debug_dbug='+d,show_explain_probe_join_exec_start';
delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3 ;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
@@ -224,6 +257,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 delete from t2 where (select max(a) from t0 where t2.a + t0.a <3) >3
+connection con1;
drop table t2;
set debug_dbug=@old_debug;
#
@@ -233,6 +267,7 @@ create table t2 as select a as a, a as dummy from t0 limit 3;
set @show_explain_probe_select_id=2;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
@@ -251,6 +286,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select t2.a, ((select max(a) from t0 where t2.a + t0.a <3) >3) as SUBQ from t2
+connection con1;
a SUBQ
0 0
1 0
@@ -266,11 +302,13 @@ id select_type table type possible_keys key key_len ref rows Extra
set debug_dbug='+d,show_explain_probe_join_exec_start';
set @show_explain_probe_select_id=1;
select * from t0 order by a;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using filesort
Warnings:
Note 1003 select * from t0 order by a
+connection con1;
a
0
1
@@ -286,17 +324,21 @@ set debug_dbug=@old_debug;
#
# SHOW EXPLAIN for SELECT ... with "Using temporary"
#
+connection default;
explain select distinct a from t0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using temporary
+connection con1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
set @show_explain_probe_select_id=1;
select distinct a from t0;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using temporary
Warnings:
Note 1003 select distinct a from t0
+connection con1;
a
0
1
@@ -312,17 +354,21 @@ set debug_dbug=@old_debug;
#
# SHOW EXPLAIN for SELECT ... with "Using temporary; Using filesort"
#
+connection default;
explain select distinct a from t0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using temporary
+connection con1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
set @show_explain_probe_select_id=1;
select distinct a from t0;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using temporary
Warnings:
Note 1003 select distinct a from t0
+connection con1;
a
0
1
@@ -346,6 +392,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
set debug_dbug='+d,show_explain_in_find_all_keys';
SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a;
+connection default;
# FIXED by "conservative assumptions about when QEP is available" fix:
# NOTE: current code will not show "Using join buffer":
show explain for $thr2;
@@ -354,6 +401,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
Warnings:
Note 1003 SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a
+connection con1;
a
1
2
@@ -375,12 +423,14 @@ Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` join `test`.`t2` group
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_end';
EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a ;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
Warnings:
Note 1003 EXPLAIN EXTENDED SELECT alias.a FROM t2, ( SELECT * FROM t2 ) AS alias GROUP BY alias.a
+connection con1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join)
@@ -405,9 +455,11 @@ id select_type table type possible_keys key key_len ref rows Extra
set @show_explain_probe_select_id=2;
set debug_dbug='+d,show_explain_probe_join_exec_end';
SELECT * FROM v1, t2;
+connection default;
show explain for $thr2;
ERROR HY000: Target is not running an EXPLAINable command
kill query $thr2;
+connection con1;
ERROR 70100: Query execution was interrupted
set debug_dbug=@old_debug;
DROP VIEW v1;
@@ -418,11 +470,13 @@ DROP TABLE t2, t3;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_end';
select sleep(1);
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select sleep(1)
+connection con1;
sleep(1)
0
set debug_dbug=@old_debug;
@@ -432,11 +486,13 @@ set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_end';
select * from t0 where 1>10;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
Warnings:
Note 1003 select * from t0 where 1>10
+connection con1;
a
set debug_dbug=@old_debug;
#
@@ -447,11 +503,13 @@ insert into t3 select a from t0;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_end';
select * from t0,t3 where t3.a=112233;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL no matching row in const table
Warnings:
Note 1003 select * from t0,t3 where t3.a=112233
+connection con1;
a a
set debug_dbug=@old_debug;
drop table t3;
@@ -477,6 +535,7 @@ SELECT * FROM t2 WHERE a =
(SELECT MAX(a) FROM t2
WHERE pk= (SELECT MAX(pk) FROM t2 WHERE pk = 3)
);
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 20 Using where
@@ -487,6 +546,7 @@ Note 1003 SELECT * FROM t2 WHERE a =
(SELECT MAX(a) FROM t2
WHERE pk= (SELECT MAX(pk) FROM t2 WHERE pk = 3)
)
+connection con1;
pk a
3 7
6 7
@@ -530,6 +590,7 @@ WHERE a1 < ALL (
SELECT a1 FROM t2
WHERE a1 IN ( SELECT a1 FROM t2, t4 )
);
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index NULL a1 5 NULL 20 Using where; Using index
@@ -541,6 +602,7 @@ WHERE a1 < ALL (
SELECT a1 FROM t2
WHERE a1 IN ( SELECT a1 FROM t2, t4 )
)
+connection con1;
count(*)
1740
set debug_dbug=@old_debug;
@@ -555,6 +617,7 @@ INSERT INTO t2 VALUES
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_end';
SELECT * FROM t2 WHERE (5, 78) IN (SELECT `a1`, MAX(`a1`) FROM t2 GROUP BY `a1`);
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> const distinct_key distinct_key 8 const,const 1
@@ -562,6 +625,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 MATERIALIZED t2 index NULL a1 4 NULL 20 Using index
Warnings:
Note 1003 SELECT * FROM t2 WHERE (5, 78) IN (SELECT `a1`, MAX(`a1`) FROM t2 GROUP BY `a1`)
+connection con1;
pk a1
set debug_dbug=@old_debug;
DROP TABLE t2;
@@ -574,11 +638,13 @@ INSERT INTO t1 VALUES (3),(1),(5),(1);
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
SELECT 'test' FROM t1 WHERE a=1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 5 const 1 Using index
Warnings:
Note 1003 SELECT 'test' FROM t1 WHERE a=1
+connection con1;
test
test
test
@@ -602,6 +668,7 @@ id select_type table type possible_keys key key_len ref rows Extra
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_test_if_quick_select';
select count(*) from t1 A, t1 B where B.key1 < A.col2 and A.col1=3 AND B.col2 + 1 < 100;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A ALL NULL NULL NULL NULL 100 Using where
@@ -626,6 +693,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE B ALL key1 NULL NULL NULL 100 Range checked for each record (index map: 0x1)
Warnings:
Note 1003 select count(*) from t1 A, t1 B where B.key1 < A.col2 and A.col1=3 AND B.col2 + 1 < 100
+connection con1;
count(*)
212
set debug_dbug=@old_debug;
@@ -639,11 +707,13 @@ INSERT INTO t1 (a) VALUES (3),(1),(5),(1);
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
SHOW INDEX FROM t1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE STATISTICS ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Open_full_table; Scanned 0 databases
Warnings:
Note 1003 SHOW INDEX FROM t1
+connection con1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a A NULL NULL NULL YES BTREE
t1 1 b 1 b A NULL NULL NULL YES BTREE
@@ -664,12 +734,14 @@ id select_type table type possible_keys key key_len ref rows Extra
set debug_dbug='+d,show_explain_probe_join_tab_preread';
set @show_explain_probe_select_id=1;
SELECT a + 1 FROM v1;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
2 DERIVED t1 ALL NULL NULL NULL NULL 2
Warnings:
Note 1003 SELECT a + 1 FROM v1
+connection con1;
a + 1
2
3
@@ -691,6 +763,7 @@ id select_type table type possible_keys key key_len ref rows Extra
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
set debug_dbug='+d,show_explain_probe_union_read';
SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 );
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
@@ -707,6 +780,7 @@ id select_type table type possible_keys key key_len ref rows Extra
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
Warnings:
Note 1003 SELECT a FROM t1 WHERE a IN ( SELECT 1+SLEEP(0.01) UNION SELECT 2 )
+connection con1;
a
set debug_dbug=@old_debug;
DROP TABLE t1;
@@ -734,6 +808,7 @@ set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
SELECT * FROM t1, ( SELECT * FROM t2 ) AS alias
WHERE a < ALL ( SELECT b FROM t1, t2 WHERE a = b );
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where
@@ -743,6 +818,7 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 SELECT * FROM t1, ( SELECT * FROM t2 ) AS alias
WHERE a < ALL ( SELECT b FROM t1, t2 WHERE a = b )
+connection con1;
a b
set debug_dbug=@old_debug;
DROP TABLE t1, t2;
@@ -768,12 +844,14 @@ id select_type table type possible_keys key key_len ref rows Extra
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select distinct t1.a from t1,t3 where t1.a=t3.a;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary
1 SIMPLE t3 ref a a 5 test.t1.a 7 Using index; Distinct
Warnings:
Note 1003 select distinct t1.a from t1,t3 where t1.a=t3.a
+connection con1;
a
1
2
@@ -785,19 +863,25 @@ drop table t1,t3,t4;
create user test2@localhost;
grant ALL on test.* to test2@localhost;
grant super on *.* to test2@localhost;
+connect con2, localhost, test2,,;
+connection con1;
#
# First, make sure that user 'test2' cannot do SHOW EXPLAIN on us
#
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select * from t0 where a < 3;
+connection default;
+connection con2;
show explain for $thr2;
ERROR 42000: Access denied; you need (at least one of) the PROCESS privilege(s) for this operation
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select * from t0 where a < 3
+connection con1;
a
0
1
@@ -806,31 +890,44 @@ set debug_dbug=@old_debug;
#
# Check that user test2 can do SHOW EXPLAIN on its own queries
#
+connect con3, localhost, test2,,;
+connection con2;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select * from t0 where a < 3;
+connection con1;
+connection con3;
show explain for $thr_con2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select * from t0 where a < 3
+connection con2;
a
0
1
2
+connection con1;
+disconnect con3;
#
# Now, grant test2 a PROCESSLIST permission, and see that he's able to observe us
#
+disconnect con2;
grant process on *.* to test2@localhost;
+connect con2, localhost, test2,,;
+connection con1;
set debug_dbug=@old_debug;
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select * from t0 where a < 3;
+connection default;
+connection con2;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select * from t0 where a < 3
+connection con1;
a
0
1
@@ -838,10 +935,14 @@ a
set debug_dbug=@old_debug;
revoke all privileges on test.* from test2@localhost;
drop user test2@localhost;
+disconnect con2;
#
# Test that it is possible to KILL a SHOW EXPLAIN command that's waiting
# on its target thread
#
+connect con2, localhost, root,,;
+connect con3, localhost, root,,;
+connection con2;
create table t1 (pk int primary key, data char(64)) engine=innodb;
insert into t1 select A.a + 10 * B.a + 100 * C.a, 'data1' from t0 A, t0 B, t0 C;
# Lock two threads
@@ -859,12 +960,18 @@ pk data
18 data1
19 data1
20 data1
+connection con1;
set autocommit=0;
select * from t1 where pk between 10 and 20 for update;
+connection default;
# do: send_eval show explain for thr2;
+connection con3;
kill query $thr_default;
+connection default;
ERROR 70100: Query execution was interrupted
+connection con2;
rollback;
+connection con1;
pk data
10 data1
11 data1
@@ -878,6 +985,8 @@ pk data
19 data1
20 data1
drop table t1;
+disconnect con3;
+disconnect con2;
#
# Check that the I_S table is invisible
#
@@ -904,6 +1013,7 @@ set debug_dbug='+d,show_explain_probe_join_exec_start';
SELECT a+SLEEP(0.01) FROM t1
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
ORDER BY b;
+connection default;
show explain for $thr2;
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 8 Using sort_union(a,b); Using where; Using filesort
@@ -911,6 +1021,7 @@ Warnings:
Note 1003 SELECT a+SLEEP(0.01) FROM t1
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
ORDER BY b
+connection con1;
a+SLEEP(0.01)
0
5372
@@ -925,6 +1036,7 @@ set debug_dbug='+d,show_explain_probe_do_select';
SELECT a+SLEEP(0.01) FROM t1
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
ORDER BY b;
+connection default;
show explain for $thr2;
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 8 Using sort_union(a,b); Using where; Using filesort
@@ -932,6 +1044,7 @@ Warnings:
Note 1003 SELECT a+SLEEP(0.01) FROM t1
WHERE a IN ( 255, 0 ) OR b BETWEEN 6 AND 129
ORDER BY b
+connection con1;
a+SLEEP(0.01)
0
5372
@@ -956,11 +1069,13 @@ id select_type table type possible_keys key key_len ref rows Extra
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
SELECT a FROM t1 GROUP BY a;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4112 Using temporary; Using filesort
Warnings:
Note 1003 SELECT a FROM t1 GROUP BY a
+connection con1;
a
1
2
@@ -994,12 +1109,14 @@ id select_type table type possible_keys key key_len ref rows Extra
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
SELECT SUM(a + SLEEP(0.1)) FROM t1 WHERE a IN ( SELECT c FROM t2 WHERE d < b ) OR b < 's';
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
2 DEPENDENT SUBQUERY t2 index_subquery PRIMARY,c c 5 func 1 Using index; Using where
Warnings:
Note 1003 SELECT SUM(a + SLEEP(0.1)) FROM t1 WHERE a IN ( SELECT c FROM t2 WHERE d < b ) OR b < 's'
+connection con1;
SUM(a + SLEEP(0.1))
7862
set debug_dbug=@old_debug;
@@ -1042,6 +1159,7 @@ id select_type table type possible_keys key key_len ref rows Extra
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_do_select';
SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, field2;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 system NULL NULL NULL NULL 1 Using filesort
@@ -1049,6 +1167,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ref PRIMARY PRIMARY 5 test.t1.b 1 Using index
Warnings:
Note 1003 SELECT b AS field1, b AS field2 FROM t1, t2, t3 WHERE d = b ORDER BY field1, field2
+connection con1;
field1 field2
set debug_dbug=@old_debug;
DROP TABLE t1,t2,t3;
@@ -1074,6 +1193,7 @@ set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
SELECT max(a+b+c) FROM t1 AS alias1, ( SELECT * FROM t2 ) AS alias
WHERE EXISTS ( SELECT * FROM t3 WHERE b = c ) OR a <= 10;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY alias1 ALL NULL NULL NULL NULL 14
@@ -1082,6 +1202,7 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 SELECT max(a+b+c) FROM t1 AS alias1, ( SELECT * FROM t2 ) AS alias
WHERE EXISTS ( SELECT * FROM t3 WHERE b = c ) OR a <= 10
+connection con1;
max(a+b+c)
279
set debug_dbug=@old_debug;
@@ -1112,6 +1233,7 @@ E3FB
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_join_exec_start';
select * from t0 where length('ãû') = a;
+connection default;
set names utf8;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
@@ -1119,6 +1241,7 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 select * from t0 where length('гы') = a
set names default;
+connection con1;
a
2
set debug_dbug=@old_debug;
@@ -1152,6 +1275,7 @@ SELECT SUM(b) FROM ( SELECT * FROM t1 ) AS alias1, t2
WHERE b <= ANY (
SELECT a FROM t1
WHERE a = b + SLEEP(0.2) OR a >= ( SELECT SUM(b) FROM t2 ));
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using index
@@ -1163,6 +1287,7 @@ Note 1003 SELECT SUM(b) FROM ( SELECT * FROM t1 ) AS alias1, t2
WHERE b <= ANY (
SELECT a FROM t1
WHERE a = b + SLEEP(0.2) OR a >= ( SELECT SUM(b) FROM t2 ))
+connection con1;
SUM(b)
0
set debug_dbug=@old_debug;
@@ -1181,8 +1306,12 @@ set debug_dbug='+d,show_explain_probe_best_ext_lim_search';
explain
select * from t0
where not exists ( select 1 from t1, t2 where t1.b=t2.b and t2.a=t0.a) and a is null;
+connection default;
kill query $thr2;
+connection con1;
ERROR 70100: Query execution was interrupted
drop table t0,t1,t2;
# End
+connection default;
+disconnect con1;
set debug_sync='RESET';
diff --git a/mysql-test/r/show_explain_non_select.result b/mysql-test/r/show_explain_non_select.result
index 0bd1e959405..6076a848e22 100644
--- a/mysql-test/r/show_explain_non_select.result
+++ b/mysql-test/r/show_explain_non_select.result
@@ -1,6 +1,9 @@
drop table if exists t0, t1;
SET @old_debug= @@session.debug;
set debug_sync='RESET';
+connect con2, localhost, root,,;
+connection con2;
+connection default;
create table t0 (a int) engine=myisam;
insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
create table t1 (a int, b int, filler char(100), key(a), key(b));
@@ -10,35 +13,43 @@ from t0 A, t0 B, t0 C;
#
# Test SHOW EXPLAIN for single-table DELETE
#
+connection con2;
set debug_dbug='+d,show_explain_probe_delete_exec_start';
delete from t1 where a<10 and b+1>1000;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 1 Using where
Warnings:
Note 1003 delete from t1 where a<10 and b+1>1000
+connection con2;
#
# Test SHOW EXPLAIN for multi-table DELETE
#
set @show_explain_probe_select_id=1;
set debug_dbug='+d,show_explain_probe_do_select';
delete t1 from t1, t0 where t0.a=t1.a and t1.b +1 > 1000;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 8 Using where
1 SIMPLE t1 ref a a 5 test.t0.a 4 Using where
Warnings:
Note 1003 delete t1 from t1, t0 where t0.a=t1.a and t1.b +1 > 1000
+connection con2;
#
# Test SHOW EXPLAIN for single-table UPDATE
#
+connection con2;
set debug_dbug='+d,show_explain_probe_update_exec_start';
update t1 set filler='filler-data-2' where a<10 and b+1>1000;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 1 Using where
Warnings:
Note 1003 update t1 set filler='filler-data-2' where a<10 and b+1>1000
+connection con2;
drop table t0,t1;
set debug_dbug=@old_debug;
set debug_sync='RESET';
diff --git a/mysql-test/r/show_explain_ps.result b/mysql-test/r/show_explain_ps.result
index f9b82c85f01..f5c487e9e44 100644
--- a/mysql-test/r/show_explain_ps.result
+++ b/mysql-test/r/show_explain_ps.result
@@ -10,14 +10,20 @@ NAME OBJECT_INSTANCE_BEGIN
# Check out if our cond is hit.
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+connect con1, localhost, root,,;
+connection con1;
+connection default;
+connection con1;
set @show_explain_probe_select_id=1;
set debug_dbug='d,show_explain_probe_join_exec_start';
select count(*) from t0 where a < 100000;
+connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where
Warnings:
Note 1003 select count(*) from t0 where a < 100000
+connection con1;
count(*)
10
set debug_dbug='';
diff --git a/mysql-test/r/shutdown.result b/mysql-test/r/shutdown.result
index 748d8ec16a6..ff2e450c3f0 100644
--- a/mysql-test/r/shutdown.result
+++ b/mysql-test/r/shutdown.result
@@ -1,9 +1,14 @@
create user user1@localhost;
+connect c1,localhost,user1,,;
shutdown;
ERROR 42000: Access denied; you need (at least one of) the SHUTDOWN privilege(s) for this operation
+connection default;
+disconnect c1;
+connect c1,localhost,root,,;
create procedure try_shutdown() shutdown;
drop procedure try_shutdown;
shutdown;
+connection default;
drop user user1@localhost;
#
# MDEV-8491 - On shutdown, report the user and the host executed that.
diff --git a/mysql-test/r/skip_name_resolve.result b/mysql-test/r/skip_name_resolve.result
index b2230ccbd91..1362e482717 100644
--- a/mysql-test/r/skip_name_resolve.result
+++ b/mysql-test/r/skip_name_resolve.result
@@ -6,10 +6,13 @@ 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';
+connect con1, localhost, root, , test, $MASTER_MYPORT, ;
SELECT USER();
USER()
#
SHOW PROCESSLIST;
+connection default;
+disconnect con1;
#
# Bug #37168: Missing variable - skip_name_resolve
#
diff --git a/mysql-test/r/sp-innodb.result b/mysql-test/r/sp-innodb.result
index b3405705698..2c3bc7dc4f3 100644
--- a/mysql-test/r/sp-innodb.result
+++ b/mysql-test/r/sp-innodb.result
@@ -71,6 +71,7 @@ END//
# Open another connection, create and initialize a table
# to be used for provoking deadlock, put a lock on the table:
+connect con1,localhost,root,,;
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
SET AUTOCOMMIT= 0;
@@ -79,6 +80,7 @@ UPDATE t1 SET i=1 WHERE i=1;
# On the default connection, do an update to provoke a
# deadlock, then call the function with handler. This case
# fails without the patch (with error ER_NO_SUCH_TABLE):
+connection default;
SET AUTOCOMMIT= 0;
UPDATE t1 SET i=1 WHERE i=1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
@@ -118,6 +120,7 @@ f1():
No such table
# Disconnect, drop functions and table:
+disconnect con1;
DROP FUNCTION f4;
DROP FUNCTION f3;
DROP FUNCTION f2;
diff --git a/mysql-test/r/sp-lock.result b/mysql-test/r/sp-lock.result
index 49ff0c7ba58..edc5bd641d3 100644
--- a/mysql-test/r/sp-lock.result
+++ b/mysql-test/r/sp-lock.result
@@ -129,11 +129,13 @@ drop temporary table t1;
# connection, try to use the routine.
# That should block on the pending exclusive lock.
#
-# Establish helper connections.
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connect con3, localhost, root,,;
#
# Test DROP PROCEDURE.
#
-# --> connection default
+connection default;
create procedure p1() begin end;
create function f1() returns int
begin
@@ -144,24 +146,24 @@ begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'drop procedure p1'...
drop procedure p1;
-# --> connection con2
+connection con2;
# Waiting for 'drop procedure t1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
-# --> connection con3
+connection con3;
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
-# --> connection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'drop procedure p1'...
-# --> connection con2
+connection con2;
# Reaping 'select f1()'
ERROR 42000: PROCEDURE test.p1 does not exist
-# --> connection default
+connection default;
#
# Test CREATE PROCEDURE.
#
@@ -170,25 +172,26 @@ begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'create procedure p1'...
create procedure p1() begin end;
-# --> connection con2
+connection con2;
# Waiting for 'create procedure t1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
-# --> connection con3
+connection con3;
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
-# --> connection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'create procedure p1'...
ERROR 42000: PROCEDURE p1 already exists
-# --> connection con2
+connection con2;
# Reaping 'select f1()'
f1()
1
+connection default;
#
# Test ALTER PROCEDURE.
#
@@ -196,25 +199,25 @@ begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'alter procedure p1'...
alter procedure p1 contains sql;
-# --> connection con2
+connection con2;
# Waiting for 'alter procedure t1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
-# --> connection con3
+connection con3;
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
-# --> connection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'alter procedure p1'...
-# --> connection con2
+connection con2;
# Reaping 'select f1()'
f1()
1
-# --> connection default
+connection default;
#
# Test DROP FUNCTION.
#
@@ -222,24 +225,24 @@ begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'drop function f1'...
drop function f1;
-# --> connection con2
+connection con2;
# Waiting for 'drop function f1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
-# --> connection con3
+connection con3;
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
-# --> connection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'drop function f1'...
-# --> connection con2
+connection con2;
# Reaping 'select f1()'
ERROR 42000: FUNCTION test.f1 does not exist
-# --> connection default
+connection default;
#
# Test CREATE FUNCTION.
#
@@ -248,26 +251,26 @@ begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'create function f1'...
create function f1() returns int return 2;
-# --> connection con2
+connection con2;
# Waiting for 'create function f1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
-# --> connection con3
+connection con3;
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
-# --> connection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'create function f1'...
ERROR 42000: FUNCTION f1 already exists
-# --> connection con2
+connection con2;
# Reaping 'select f1()'
f1()
1
-# --> connection default
+connection default;
#
# Test ALTER FUNCTION.
#
@@ -275,25 +278,25 @@ begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'alter function f1'...
alter function f1 contains sql;
-# --> connection con2
+connection con2;
# Waiting for 'alter function f1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
-# --> connection con3
+connection con3;
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
-# --> connection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'alter function f1'...
-# --> connection con2
+connection con2;
# Reaping 'select f1()'
f1()
1
-# --> connection default
+connection default;
drop function f1;
drop procedure p1;
#
@@ -330,12 +333,12 @@ call p4();
prepare stmt from "call p4()";
execute stmt;
execute stmt;
-# --> connection con1
+connection con1;
drop procedure p1;
drop procedure p2;
drop procedure p3;
drop procedure p4;
-# --> connection default
+connection default;
# This is to verify there was no implicit commit.
rollback to savepoint sv;
call p4();
@@ -356,16 +359,16 @@ create trigger t1_ai after insert on t1 for each row
insert into t2 (a, b) values (new.a, f1());
begin;
insert into t1 (a) values (1);
-# --> connection con1
+connection con1;
# Sending 'drop function f1'
drop function f1;
-# --> connection con2
+connection con2;
# Waiting for 'drop function f1' to get blocked on MDL lock...
-# --> connnection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'drop function f1'...
-# --> connection default
+connection default;
#
# A function is used from a view.
#
@@ -375,16 +378,16 @@ begin;
select * from v1;
a
1
-# --> connection con1
+connection con1;
# Sending 'drop function f1'
drop function f1;
-# --> connection con2
+connection con2;
# Waiting for 'drop function f1' to get blocked on MDL lock...
-# --> connnection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'drop function f1'...
-# --> connection default
+connection default;
#
# A procedure is used from a function.
#
@@ -399,16 +402,16 @@ begin;
select * from v1;
a
3
-# --> connection con1
+connection con1;
# Sending 'drop procedure p1'
drop procedure p1;
-# --> connection con2
+connection con2;
# Waiting for 'drop procedure p1' to get blocked on MDL lock...
-# --> connnection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'drop procedure p1'...
-# --> connection default
+connection default;
#
# Deep nesting: a function is used from a procedure used
# from a function used from a view used in a trigger.
@@ -420,16 +423,16 @@ create trigger t1_ai after insert on t1 for each row
insert into t2 (a, b) values (new.a, (select max(a) from v1));
begin;
insert into t1 (a) values (3);
-# --> connection con1
+connection con1;
# Sending 'drop function f2'
drop function f2;
-# --> connection con2
+connection con2;
# Waiting for 'drop function f2' to get blocked on MDL lock...
-# --> connnection default
+connection default;
commit;
-# --> connection con1
+connection con1;
# Reaping 'drop function f2'...
-# --> connection default
+connection default;
drop view v1;
drop function f1;
drop procedure p1;
@@ -475,23 +478,23 @@ savepoint sv;
select f2();
f2()
f2()
-# --> connection con1
+connection con1;
# Sending 'drop function f1'...
drop function f1;
-# --> connection con2
+connection con2;
# Waiting for 'drop function f1' to get blocked on MDL lock...
# Sending 'drop function f2'...
drop function f2;
-# --> connection default
+connection default;
# Waiting for 'drop function f2' to get blocked on MDL lock...
rollback to savepoint sv;
-# --> connection con2
+connection con2;
# Reaping 'drop function f2'...
-# --> connection default
+connection default;
unlock tables;
-# --> connection con1
+connection con1;
# Reaping 'drop function f1'...
-# --> connection default
+connection default;
drop function f1;
ERROR 42000: FUNCTION test.f1 does not exist
drop function f2;
@@ -526,31 +529,32 @@ begin
select f1() into @var;
execute stmt;
end|
-# --> connection con2
+connection con2;
prepare stmt from "select f2()";
-# --> connection default
+connection default;
begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'alter function f1 ...'...
alter function f1 comment "comment";
-# --> connection con2
+connection con2;
# Waiting for 'alter function f1 ...' to get blocked on MDL lock...
# Sending 'call p1()'...
call p1();
+connection default;
# Waiting for 'call p1()' to get blocked on MDL lock on f1...
# Let 'alter function f1 ...' go through...
commit;
-# --> connection con1
+connection con1;
# Reaping 'alter function f1 ...'
-# --> connection con2
+connection con2;
# Reaping 'call p1()'...
f2()
1
deallocate prepare stmt;
-# --> connection default
+connection default;
drop function f1;
drop function f2;
drop procedure p1;
@@ -569,10 +573,10 @@ begin;
select f1();
f1()
1
-# --> connection con1
+connection con1;
# Sending 'alter function f1 ...'...
alter function f1 comment "comment";
-# --> connection con2
+connection con2;
# Waiting for 'alter function f1 ...' to get blocked on MDL lock...
#
# We just mention p1() in the body of f2() to make
@@ -595,14 +599,15 @@ select f2() into @var;
end|
# Sending 'call p1()'...
call p1();
+connection default;
# Waiting for 'call p1()' to get blocked on MDL lock on f1...
# Let 'alter function f1 ...' go through...
commit;
-# --> connection con1
+connection con1;
# Reaping 'alter function f1 ...'
-# --> connection con2
+connection con2;
# Reaping 'call p1()'...
-# --> connection default
+connection default;
drop function f1;
drop function f2;
drop procedure p1;
@@ -626,14 +631,14 @@ close c;
select f2() into @var;
return res;
end|
-# --> connection con1
+connection con1;
select get_lock("30977", 0);
get_lock("30977", 0)
1
-# --> connection default
+connection default;
# Sending 'select f3()'...
select f3();
-# --> connection con1
+connection con1;
# Waiting for 'select f3()' to get blocked on the user level lock...
# Do something to change the cache version.
create function f4() returns int return 4;
@@ -641,7 +646,7 @@ drop function f4;
select release_lock("30977");
release_lock("30977")
1
-# --> connection default
+connection default;
# Reaping 'select f3()'...
# Routine 'f2()' should exist and get executed successfully.
f3()
@@ -688,10 +693,13 @@ select @exec_count;
drop procedure p1;
drop function f1;
set @@session.max_sp_recursion_depth=default;
-# --> connection con1
-# --> connection con2
-# --> connection con3
-# --> connection default
+connection con1;
+disconnect con1;
+connection con2;
+disconnect con2;
+connection con3;
+disconnect con3;
+connection default;
#
# SHOW CREATE PROCEDURE p1 called from p1, after p1 was altered
#
@@ -703,24 +711,26 @@ BEGIN
SELECT get_lock("test", 10);
SHOW CREATE PROCEDURE p1;
END|
-# Connection default
+connect con2, localhost, root;
+connect con3, localhost, root;
+connection default;
SELECT get_lock("test", 10);
get_lock("test", 10)
1
-# Connection 2
+connection con2;
# Will halt before executing SHOW CREATE PROCEDURE p1
# Sending:
CALL p1();
-# Connection 3
+connection con3;
# Alter p1
DROP PROCEDURE p1;
CREATE PROCEDURE p1() BEGIN END;
-# Connection default
+connection default;
# Resume CALL p1, now with new p1
SELECT release_lock("test");
release_lock("test")
1
-# Connection 2
+connection con2;
# Reaping: CALL p1()
get_lock("test", 10)
1
@@ -730,9 +740,11 @@ BEGIN
SELECT get_lock("test", 10);
SHOW CREATE PROCEDURE p1;
END latin1 latin1_swedish_ci latin1_swedish_ci
-# Connection 3
-# Connection 2
-# Connection default;
+connection con3;
+disconnect con3;
+connection con2;
+disconnect con2;
+connection default;
DROP PROCEDURE p1;
#
# Bug#57663 Concurrent statement using stored function and DROP DATABASE
@@ -740,26 +752,28 @@ DROP PROCEDURE p1;
#
DROP DATABASE IF EXISTS db1;
DROP FUNCTION IF EXISTS f1;
+connect con1, localhost, root;
+connect con2, localhost, root;
# Test 1: Check that DROP DATABASE block if a function is used
# by an active transaction.
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE FUNCTION db1.f1() RETURNS INTEGER RETURN 1;
START TRANSACTION;
SELECT db1.f1();
db1.f1()
1
-# Connection con1
+connection con1;
# Sending:
DROP DATABASE db1;
-# Connection default
+connection default;
# Waiting for DROP DATABASE to be blocked by the lock on f1()
COMMIT;
-# Connection con1
+connection con1;
# Reaping: DROP DATABASE db1
# Test 2: Check that DROP DATABASE blocks if a procedure is
# used by an active transaction.
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE PROCEDURE db1.p1() BEGIN END;
CREATE FUNCTION f1() RETURNS INTEGER
@@ -771,17 +785,17 @@ START TRANSACTION;
SELECT f1();
f1()
1
-# Connection con1
+connection con1;
# Sending:
DROP DATABASE db1;
-# Connection default
+connection default;
# Waiting for DROP DATABASE to be blocked by the lock on p1()
COMMIT;
-# Connection con1
+connection con1;
# Reaping: DROP DATABASE db1
# Test 3: Check that DROP DATABASE is not selected as a victim if a
# deadlock is discovered with DML statements.
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE TABLE db1.t1 (a INT);
CREATE FUNCTION db1.f1() RETURNS INTEGER RETURN 1;
@@ -789,18 +803,18 @@ START TRANSACTION;
SELECT db1.f1();
db1.f1()
1
-# Connection con1
+connection con1;
# Sending:
DROP DATABASE db1;
-# Connection default
+connection default;
# Waiting for DROP DATABASE to be blocked by the lock on f1()
SELECT * FROM db1.t1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
-# Connection con1
+connection con1;
# Reaping: DROP DATABASE db1
# Test 4: Check that active DROP DATABASE blocks stored routine DDL.
-# Connection default
+connection default;
CREATE DATABASE db1;
CREATE FUNCTION db1.f1() RETURNS INTEGER RETURN 1;
CREATE FUNCTION db1.f2() RETURNS INTEGER RETURN 2;
@@ -808,22 +822,24 @@ START TRANSACTION;
SELECT db1.f2();
db1.f2()
2
-# Connection con1
+connection con1;
# Sending:
DROP DATABASE db1;
-# Connection con2
+connection con2;
# Waiting for DROP DATABASE to be blocked by the lock on f2()
# Sending:
ALTER FUNCTION db1.f1 COMMENT "test";
-# Connection default
+connection default;
# Waiting for ALTER FUNCTION to be blocked by the schema lock on db1
COMMIT;
-# Connection con1
+connection con1;
# Reaping: DROP DATABASE db1
-# Connection con2
+disconnect con1;
+connection con2;
# Reaping: ALTER FUNCTION f1 COMMENT 'test'
ERROR 42000: FUNCTION db1.f1 does not exist
-# Connection default
+disconnect con2;
+connection default;
DROP FUNCTION f1;
#
# End of 5.5 tests
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 276da41a0fe..22172bf18fc 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -1,3 +1,5 @@
+connect con1root,localhost,root,,;
+connection con1root;
use test;
create user user1@localhost;
grant usage on *.* to user1@localhost;
@@ -39,6 +41,9 @@ set sql_mode='';
grant execute on procedure db1_secret.stamp to ''@'%';
grant execute on function db1_secret.db to ''@'%';
set sql_mode=default;
+connect con2user1,localhost,user1,,;
+connect con3anon,localhost,anon,,;
+connection con2user1;
call db1_secret.stamp(2);
select db1_secret.db();
db1_secret.db()
@@ -53,6 +58,7 @@ drop procedure db1_secret.stamp;
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.stamp'
drop function db1_secret.db;
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db1_secret.db'
+connection con3anon;
call db1_secret.stamp(3);
select db1_secret.db();
db1_secret.db()
@@ -67,6 +73,7 @@ drop procedure db1_secret.stamp;
ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.stamp'
drop function db1_secret.db;
ERROR 42000: alter routine command denied to user ''@'%' for routine 'db1_secret.db'
+connection con1root;
select * from t1;
u i
test 0
@@ -92,14 +99,17 @@ root@localhost 4
select db();
db()
test
+connection con2user1;
call db1_secret.stamp(5);
ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 't1'
select db1_secret.db();
ERROR 42000: SELECT command denied to user 'user1'@'localhost' for table 't1'
+connection con3anon;
call db1_secret.stamp(6);
ERROR 42000: INSERT command denied to user ''@'localhost' for table 't1'
select db1_secret.db();
ERROR 42000: SELECT command denied to user ''@'localhost' for table 't1'
+connection con1root;
drop database if exists db2;
create database db2;
use db2;
@@ -112,10 +122,13 @@ grant usage on db2.* to user2@localhost;
grant select,insert,update,delete,create routine on db2.* to user2@localhost;
grant create routine on db2.* to user1@localhost;
flush privileges;
+connection con2user1;
use db2;
create procedure p () insert into t2 values (1);
call p();
ERROR 42000: INSERT command denied to user 'user1'@'localhost' for table 't2'
+connect con4user2,localhost,user2,,;
+connection con4user2;
use db2;
call p();
ERROR 42000: execute command denied to user 'user2'@'localhost' for routine 'db2.p'
@@ -128,8 +141,11 @@ select * from t2;
s1
0
2
+connection con1root;
grant usage on procedure db2.q to user2@localhost with grant option;
+connection con4user2;
grant execute on procedure db2.q to user1@localhost;
+connection con2user1;
use db2;
call q();
select * from t2;
@@ -143,9 +159,13 @@ alter procedure q modifies sql data;
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db2.q'
drop procedure q;
ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db2.q'
+connection con1root;
use db2;
alter procedure q modifies sql data;
drop procedure q;
+disconnect con2user1;
+disconnect con3anon;
+disconnect con4user2;
use test;
select type,db,name from mysql.proc where db like 'db%';
type db name
@@ -182,26 +202,34 @@ show grants for userc@localhost;
Grants for userc@localhost
GRANT USAGE ON *.* TO 'userc'@'localhost'
GRANT EXECUTE ON PROCEDURE `sptest`.`p1` TO 'userc'@'localhost' WITH GRANT OPTION
+connect con2usera,localhost,usera,,;
+connect con3userb,localhost,userb,,;
+connect con4userc,localhost,userc,,;
+connection con2usera;
call sptest.p1(1);
grant execute on procedure sptest.p1 to userb@localhost;
ERROR 42000: grant command denied to user 'usera'@'localhost' for routine 'sptest.p1'
drop procedure sptest.p1;
ERROR 42000: alter routine command denied to user 'usera'@'localhost' for routine 'sptest.p1'
+connection con3userb;
call sptest.p1(2);
ERROR 42000: execute command denied to user 'userb'@'localhost' for routine 'sptest.p1'
grant execute on procedure sptest.p1 to userb@localhost;
ERROR 42000: execute command denied to user 'userb'@'localhost' for routine 'sptest.p1'
drop procedure sptest.p1;
ERROR 42000: alter routine command denied to user 'userb'@'localhost' for routine 'sptest.p1'
+connection con4userc;
call sptest.p1(3);
grant execute on procedure sptest.p1 to userb@localhost;
drop procedure sptest.p1;
ERROR 42000: alter routine command denied to user 'userc'@'localhost' for routine 'sptest.p1'
+connection con3userb;
call sptest.p1(4);
grant execute on procedure sptest.p1 to userb@localhost;
ERROR 42000: grant command denied to user 'userb'@'localhost' for routine 'sptest.p1'
drop procedure sptest.p1;
ERROR 42000: alter routine command denied to user 'userb'@'localhost' for routine 'sptest.p1'
+connection con1root;
select * from t1;
u i
usera@localhost 1
@@ -216,10 +244,15 @@ show grants for userb@localhost;
Grants for userb@localhost
GRANT USAGE ON *.* TO 'userb'@'localhost'
GRANT EXECUTE ON PROCEDURE `sptest`.`p1` TO 'userb'@'localhost'
+connection con4userc;
revoke all privileges on procedure sptest.p1 from userb@localhost;
+connection con1root;
show grants for userb@localhost;
Grants for userb@localhost
GRANT USAGE ON *.* TO 'userb'@'localhost'
+disconnect con4userc;
+disconnect con3userb;
+disconnect con2usera;
use test;
drop database sptest;
delete from mysql.user where user='usera' or user='userb' or user='userc';
@@ -227,6 +260,8 @@ delete from mysql.procs_priv where user='usera' or user='userb' or user='userc';
delete from mysql.tables_priv where user='usera';
flush privileges;
drop table t1;
+connect root,localhost,root,,test;
+connection root;
drop function if exists bug_9503;
drop user if exists user1@localhost;
create database mysqltest//
@@ -236,16 +271,25 @@ create user user1@localhost//
grant select on t1 to user1@localhost//
create function bug_9503 () returns int sql security invoker begin declare v int;
select min(s1) into v from t1; return v; end//
+connect user1,localhost,user1,,test;
+connection user1;
use mysqltest;
select bug_9503();
ERROR 42000: execute command denied to user 'user1'@'localhost' for routine 'mysqltest.bug_9503'
+connection root;
grant execute on function bug_9503 to user1@localhost;
+connection user1;
do 1;
use test;
+disconnect user1;
+connection root;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
drop function bug_9503;
use test;
drop database mysqltest;
+connection default;
+disconnect root;
+connection con1root;
use test;
select current_user();
current_user()
@@ -259,15 +303,19 @@ create procedure bug7291_2 () sql security invoker call bug7291_0();
grant execute on procedure bug7291_0 to user1@localhost;
grant execute on procedure bug7291_1 to user1@localhost;
grant execute on procedure bug7291_2 to user1@localhost;
+connect user1,localhost,user1,,;
+connection user1;
call bug7291_2();
current_user() user()
user1@localhost user1@localhost
call bug7291_1();
current_user() user()
root@localhost user1@localhost
+connection con1root;
drop procedure bug7291_1;
drop procedure bug7291_2;
drop procedure bug7291_0;
+disconnect user1;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
drop user user1@localhost;
drop database if exists mysqltest_1;
@@ -278,10 +326,17 @@ select 1 from dual;
end//
create user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost;
+connect n1,localhost,mysqltest_1,,information_schema,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection n1;
call mysqltest_1.p1();
ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine 'mysqltest_1.p1'
+disconnect n1;
+connect n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK;
+connection n2;
call mysqltest_1.p1();
ERROR 42000: execute command denied to user 'mysqltest_1'@'localhost' for routine 'mysqltest_1.p1'
+disconnect n2;
+connection default;
drop procedure mysqltest_1.p1;
drop database mysqltest_1;
revoke usage on *.* from mysqltest_1@localhost;
@@ -292,10 +347,13 @@ begin
return 'ok';
end;
create user user_bug12812@localhost IDENTIFIED BY 'ABC'|
+connect test_user_12812,localhost,user_bug12812,ABC,test;
SELECT test.bug12812()|
ERROR 42000: execute command denied to user 'user_bug12812'@'localhost' for routine 'test.bug12812'
CREATE VIEW v1 AS SELECT test.bug12812()|
ERROR 42000: execute command denied to user 'user_bug12812'@'localhost' for routine 'test.bug12812'
+connection default;
+disconnect test_user_12812;
DROP USER user_bug12812@localhost|
drop function bug12812|
create database db_bug14834;
@@ -305,16 +363,23 @@ create user user2_bug14834@localhost identified by '';
grant all on `db\_bug14834`.* to user2_bug14834@localhost;
create user user3_bug14834@localhost identified by '';
grant all on `db__ug14834`.* to user3_bug14834@localhost;
+connect user1_bug14834,localhost,user1_bug14834,,db_bug14834;
create procedure p_bug14834() select user(), current_user();
call p_bug14834();
user() current_user()
user1_bug14834@localhost user1_bug14834@localhost
+connect user2_bug14834,localhost,user2_bug14834,,db_bug14834;
call p_bug14834();
user() current_user()
user2_bug14834@localhost user1_bug14834@localhost
+connect user3_bug14834,localhost,user3_bug14834,,db_bug14834;
call p_bug14834();
user() current_user()
user3_bug14834@localhost user1_bug14834@localhost
+connection default;
+disconnect user1_bug14834;
+disconnect user2_bug14834;
+disconnect user3_bug14834;
drop user user1_bug14834@localhost;
drop user user2_bug14834@localhost;
drop user user3_bug14834@localhost;
@@ -331,6 +396,7 @@ sql security definer
select * from db_bug14533.t1;
grant execute on procedure db_bug14533.bug14533_1 to user_bug14533@localhost;
grant execute on procedure db_bug14533.bug14533_2 to user_bug14533@localhost;
+connect user_bug14533,localhost,user_bug14533,,test;
call db_bug14533.bug14533_1();
Field Type Null Key Default Extra
id int(11) YES NULL
@@ -340,10 +406,11 @@ desc db_bug14533.t1;
ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1'
select * from db_bug14533.t1;
ERROR 42000: SELECT command denied to user 'user_bug14533'@'localhost' for table 't1'
+connection default;
+disconnect user_bug14533;
drop user user_bug14533@localhost;
drop database db_bug14533;
-
----> connection: root
+connection con1root;
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest;
CREATE USER mysqltest_1@localhost;
@@ -351,20 +418,19 @@ GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost;
CREATE USER mysqltest_2@localhost;
GRANT SUPER ON *.* TO mysqltest_2@localhost;
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
-
----> connection: mysqltest_2_con
+connect mysqltest_2_con,localhost,mysqltest_2,,mysqltest;
+connect mysqltest_1_con,localhost,mysqltest_1,,mysqltest;
+connection mysqltest_2_con;
USE mysqltest;
CREATE PROCEDURE wl2897_p1() SELECT 1;
CREATE FUNCTION wl2897_f1() RETURNS INT RETURN 1;
-
----> connection: mysqltest_1_con
+connection mysqltest_1_con;
USE mysqltest;
CREATE DEFINER=root@localhost PROCEDURE wl2897_p2() SELECT 2;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
CREATE DEFINER=root@localhost FUNCTION wl2897_f2() RETURNS INT RETURN 2;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
-
----> connection: mysqltest_2_con
+connection mysqltest_2_con;
use mysqltest;
CREATE DEFINER='a @ b @ c'@localhost PROCEDURE wl2897_p3() SELECT 3;
Warnings:
@@ -372,8 +438,7 @@ Note 1449 The user specified as a definer ('a @ b @ c'@'localhost') does not exi
CREATE DEFINER='a @ b @ c'@localhost FUNCTION wl2897_f3() RETURNS INT RETURN 3;
Warnings:
Note 1449 The user specified as a definer ('a @ b @ c'@'localhost') does not exist
-
----> connection: con1root
+connection con1root;
USE mysqltest;
SHOW CREATE PROCEDURE wl2897_p1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
@@ -394,16 +459,18 @@ RETURN 3 latin1 latin1_swedish_ci latin1_swedish_ci
DROP USER mysqltest_1@localhost;
DROP USER mysqltest_2@localhost;
DROP DATABASE mysqltest;
-
----> connection: root
+disconnect mysqltest_1_con;
+disconnect mysqltest_2_con;
+connection con1root;
DROP DATABASE IF EXISTS mysqltest;
CREATE DATABASE mysqltest;
CREATE USER mysqltest_1@localhost;
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_1@localhost;
CREATE USER mysqltest_2@localhost;
GRANT ALL PRIVILEGES ON mysqltest.* TO mysqltest_2@localhost;
-
----> connection: mysqltest_1_con
+connect mysqltest_1_con,localhost,mysqltest_1,,mysqltest;
+connect mysqltest_2_con,localhost,mysqltest_2,,mysqltest;
+connection mysqltest_1_con;
USE mysqltest;
CREATE PROCEDURE bug13198_p1()
SELECT 1;
@@ -415,8 +482,7 @@ CALL bug13198_p1();
SELECT bug13198_f1();
bug13198_f1()
1
-
----> connection: mysqltest_2_con
+connection mysqltest_2_con;
USE mysqltest;
CALL bug13198_p1();
1
@@ -424,18 +490,17 @@ CALL bug13198_p1();
SELECT bug13198_f1();
bug13198_f1()
1
-
----> connection: root
+connection con1root;
+disconnect mysqltest_1_con;
DROP USER mysqltest_1@localhost;
-
----> connection: mysqltest_2_con
+connection mysqltest_2_con;
USE mysqltest;
CALL bug13198_p1();
ERROR HY000: The user specified as a definer ('mysqltest_1'@'localhost') does not exist
SELECT bug13198_f1();
ERROR HY000: The user specified as a definer ('mysqltest_1'@'localhost') does not exist
-
----> connection: root
+connection con1root;
+disconnect mysqltest_2_con;
DROP USER mysqltest_2@localhost;
DROP DATABASE mysqltest;
GRANT USAGE ON *.* TO user19857@localhost IDENTIFIED BY 'meow';
@@ -444,8 +509,8 @@ user19857@localhost;
SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
Host User Password
localhost user19857 *82DC221D557298F6CE9961037DB1C90604792F5C
-
----> connection: mysqltest_2_con
+connect mysqltest_2_con,localhost,user19857,meow,test;
+connection mysqltest_2_con;
USE test;
CREATE PROCEDURE sp19857() DETERMINISTIC
BEGIN
@@ -462,13 +527,18 @@ DECLARE a INT;
SET a=1;
SELECT a;
END latin1 latin1_swedish_ci latin1_swedish_ci
+disconnect mysqltest_2_con;
+connect mysqltest_2_con,localhost,user19857,meow,test;
+connection mysqltest_2_con;
DROP PROCEDURE IF EXISTS test.sp19857;
-
----> connection: root
+connection con1root;
+disconnect mysqltest_2_con;
SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
Host User Password
localhost user19857 *82DC221D557298F6CE9961037DB1C90604792F5C
DROP USER user19857@localhost;
+disconnect con1root;
+connection default;
use test;
DROP TABLE IF EXISTS t1;
DROP VIEW IF EXISTS v1;
@@ -493,6 +563,7 @@ SET @b:= (SELECT COUNT(*) FROM t1);
RETURN @b;
END|
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT f_evil();
+connect conn1, localhost, mysqltest_u1,,;
SELECT COUNT(*) FROM t1;
ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1'
SELECT f_evil();
@@ -515,6 +586,8 @@ ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table
SELECT @a, @b;
@a @b
mysqltest_u1@localhost NULL
+disconnect conn1;
+connection default;
DROP VIEW v1;
DROP FUNCTION f_evil;
DROP USER mysqltest_u1@localhost;
@@ -543,6 +616,9 @@ SELECT * FROM TestTab;
id
1
2
+CONNECT con_tester,localhost,tester,,B48872;
+CONNECT con_tester_denied,localhost,Tester,,B48872;
+connection con_tester;
SELECT * FROM TestTab;
id
1
@@ -559,6 +635,7 @@ f_Test()
SELECT F_TEST();
F_TEST()
123
+connection con_tester_denied;
SELECT * FROM TestTab;
SELECT `f_Test`();
SELECT `F_TEST`();
@@ -570,6 +647,9 @@ SELECT `f_Test_denied`();
SELECT `F_TEST_DENIED`();
`F_TEST_DENIED`()
123
+connection default;
+disconnect con_tester;
+disconnect con_tester_denied;
DROP TABLE `TestTab`;
DROP FUNCTION `f_Test`;
DROP FUNCTION `f_Test_denied`;
@@ -588,7 +668,7 @@ create database mysqltest_db;
create user bug57061_user@localhost;
create function mysqltest_db.f1() returns int return 0;
create procedure mysqltest_db.p1() begin end;
-# Connect as user 'bug57061_user@localhost'
+connect conn1, localhost, bug57061_user,,;
# Attempt to drop routine on which user doesn't have privileges
# should result in the same 'access denied' type of error whether
# routine exists or not.
@@ -600,7 +680,8 @@ drop function if exists mysqltest_db.f1;
ERROR 42000: alter routine command denied to user 'bug57061_user'@'localhost' for routine 'mysqltest_db.f1'
drop procedure if exists mysqltest_db.p1;
ERROR 42000: alter routine command denied to user 'bug57061_user'@'localhost' for routine 'mysqltest_db.p1'
-# Connection 'default'.
+connection default;
+disconnect conn1;
drop user bug57061_user@localhost;
drop database mysqltest_db;
#
@@ -612,20 +693,21 @@ CREATE DATABASE db1;
CREATE PROCEDURE db1.p1() SELECT 1;
CREATE USER user2@localhost IDENTIFIED BY '';
GRANT SELECT(db) ON mysql.proc TO user2@localhost;
-# Connection con2 as user2
+connect con2, localhost, user2;
# The statement below before disclosed info from body_utf8 column.
SHOW CREATE PROCEDURE db1.p1;
ERROR 42000: PROCEDURE p1 does not exist
# Check that SHOW works with SELECT grant on whole table
-# Connection default
+connection default;
GRANT SELECT ON mysql.proc TO user2@localhost;
-# Connection con2
+connection con2;
# This should work
SHOW CREATE PROCEDURE db1.p1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci
-# Connection default
+connection default;
+disconnect con2;
DROP USER user2@localhost;
DROP DATABASE db1;
#
@@ -639,7 +721,7 @@ create function mysqltest_db.f1() returns int return 0;
create procedure mysqltest_db.p1() begin end;
# Create user with no privileges on mysqltest_db database.
create user bug12602983_user@localhost;
-# Connect as user 'bug12602983_user@localhost'
+connect conn1, localhost, bug12602983_user,,;
# Attempt to execute routine on which user doesn't have privileges
# should result in the same 'access denied' error whether
# routine exists or not.
@@ -655,7 +737,8 @@ create view bug12602983_v1 as select mysqltest_db.f_does_not_exist();
ERROR 42000: execute command denied to user 'bug12602983_user'@'localhost' for routine 'mysqltest_db.f_does_not_exist'
create view bug12602983_v1 as select mysqltest_db.f1();
ERROR 42000: execute command denied to user 'bug12602983_user'@'localhost' for routine 'mysqltest_db.f1'
-# Connection 'default'.
+connection default;
+disconnect conn1;
drop user bug12602983_user@localhost;
drop database mysqltest_db;
set password=password('foobar');
diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result
index 4ce61c44762..eb1c0beff65 100644
--- a/mysql-test/r/sp-threads.result
+++ b/mysql-test/r/sp-threads.result
@@ -1,3 +1,7 @@
+connect con1root,localhost,root,,;
+connect con2root,localhost,root,,;
+connect con3root,localhost,root,,;
+connection con1root;
use test;
drop table if exists t1;
create table t1 (s1 int, s2 int, s3 int);
@@ -5,22 +9,26 @@ create procedure bug4934()
begin
insert into t1 values (1,0,1);
end//
+connection con2root;
use test;
call bug4934();
select * from t1;
s1 s2 s3
1 0 1
+connection con1root;
drop table t1;
create table t1 (s1 int, s2 int, s3 int);
drop procedure bug4934;
create procedure bug4934()
begin
end//
+connection con2root;
select * from t1;
s1 s2 s3
call bug4934();
select * from t1;
s1 s2 s3
+connection con1root;
drop table t1;
drop procedure bug4934;
drop procedure if exists bug9486;
@@ -30,8 +38,11 @@ create table t2 (id2 int);
create procedure bug9486()
update t1, t2 set val= 1 where id1=id2;
call bug9486();
+connection con2root;
lock tables t2 write;
+connection con1root;
call bug9486();
+connection con2root;
show processlist;
Id User Host db Command Time State Info Progress
# root localhost test Sleep # NULL 0.000
@@ -39,6 +50,7 @@ Id User Host db Command Time State Info Progress
# root localhost test Query # init show processlist 0.000
# root localhost test Sleep # NULL 0.000
unlock tables;
+connection con1root;
drop procedure bug9486;
drop table t1, t2;
drop procedure if exists bug11158;
@@ -51,9 +63,13 @@ call bug11158();
select * from t1;
id j
2 2
+connection con2root;
lock tables t2 read;
+connection con1root;
call bug11158();
+connection con2root;
unlock tables;
+connection con1root;
drop procedure bug11158;
drop table t1, t2;
drop function if exists bug11554;
@@ -61,12 +77,15 @@ drop view if exists v1;
create table t1 (i int);
create function bug11554 () returns int return 1;
create view v1 as select bug11554() as f;
+connection con2root;
insert into t1 (select f from v1);
+connection con1root;
drop function bug11554;
drop table t1;
drop view v1;
drop procedure if exists p1;
drop procedure if exists p2;
+connection con1root;
create table t1 (s1 int)|
create procedure p1() select * from t1|
create procedure p2()
@@ -75,13 +94,18 @@ insert into t1 values (1);
call p1();
select * from t1;
end|
+connection con2root;
use test;
lock table t1 write;
+connection con1root;
call p2();
+connection con3root;
use test;
drop procedure p1;
create procedure p1() select * from t1;
+connection con2root;
unlock tables;
+connection con1root;
s1
1
s1
@@ -89,3 +113,7 @@ s1
drop procedure p1;
drop procedure p2;
drop table t1;
+connection default;
+disconnect con1root;
+disconnect con2root;
+disconnect con3root;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 9453a1da3ca..de6b87d67cd 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -6417,6 +6417,8 @@ set x=-1;
return x;
end|
create view v1 as select 1 as one, f1() as days;
+connect bug29408, localhost, root,,*NO-ONE*;
+connection bug29408;
show create view test.v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v1` AS select 1 AS `one`,`f1`() AS `days` latin1 latin1_swedish_ci
@@ -6425,6 +6427,8 @@ where table_name='v1' and table_schema='test';
column_name
one
days
+connection default;
+disconnect bug29408;
drop view v1;
drop function f1;
diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result
index 40a06d312a0..73cc4f154c7 100644
--- a/mysql-test/r/sp_notembedded.result
+++ b/mysql-test/r/sp_notembedded.result
@@ -154,6 +154,7 @@ create user 'mysqltest_1'@'localhost';
grant all privileges on test.* to 'mysqltest_1'@'localhost';
create procedure 15298_1 () sql security definer show grants for current_user;
create procedure 15298_2 () sql security definer show grants;
+connect con1,localhost,mysqltest_1,,test;
call 15298_1();
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
@@ -162,6 +163,8 @@ call 15298_2();
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
+connection default;
+disconnect con1;
drop user mysqltest_1@localhost;
drop procedure 15298_1;
drop procedure 15298_2;
@@ -171,22 +174,39 @@ create table t1 (value varchar(15));
create procedure p1() update t1 set value='updated' where value='old';
call p1();
insert into t1 (value) values ("old"),("irrelevant");
+connect rl_holder, localhost, root,,;
+connect rl_acquirer, localhost, root,,;
+connect rl_contender, localhost, root,,;
+connect rl_wait, localhost, root,,;
+connection rl_holder;
select get_lock('b26162',120);
get_lock('b26162',120)
1
+connection rl_acquirer;
select 'rl_acquirer', value from t1 where get_lock('b26162',120);;
+connection rl_wait;
+connection default;
set session low_priority_updates=on;
call p1();;
+connection rl_wait;
+connection rl_contender;
select 'rl_contender', value from t1;
rl_contender value
rl_contender old
rl_contender irrelevant
+connection rl_holder;
select release_lock('b26162');
release_lock('b26162')
1
+connection rl_acquirer;
rl_acquirer value
rl_acquirer old
rl_acquirer irrelevant
+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;
@@ -203,9 +223,13 @@ VALUES('%', 'mysqltest_1', password(''), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N',
Warnings:
Warning 1364 Field 'authentication_string' doesn't have a default value
FLUSH PRIVILEGES;
+connect con1, localhost, mysqltest_1,,;
+connection con1;
CREATE PROCEDURE p1(i INT) BEGIN END;
Warnings:
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
+disconnect con1;
+connection default;
DROP PROCEDURE p1;
DELETE FROM mysql.user WHERE User='mysqltest_1';
FLUSH PRIVILEGES;
@@ -215,7 +239,7 @@ FLUSH PRIVILEGES;
SELECT GET_LOCK('Bug44521', 0);
GET_LOCK('Bug44521', 0)
1
-** Connection con1
+connect con1,localhost,root,,;
CREATE PROCEDURE p()
BEGIN
SELECT 1;
@@ -223,7 +247,8 @@ SELECT GET_LOCK('Bug44521', 100);
SELECT 2;
END$
CALL p();;
-** Default connection
+connection default;
+disconnect con1;
SELECT RELEASE_LOCK('Bug44521');
RELEASE_LOCK('Bug44521')
1
@@ -232,13 +257,21 @@ CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1);
CREATE FUNCTION f1 (inp TEXT) RETURNS INT NO SQL RETURN sleep(60);
CREATE VIEW v1 AS SELECT f1('a') FROM t1;
+connect con1, localhost, root,,;
SELECT * FROM v1;;
+connect con2, localhost, root,,;
SELECT * FROM v1;
+connection default;
+connection con1;
ERROR 70100: Query execution was interrupted
+connection con2;
ERROR 70100: Query execution was interrupted
+connection default;
DROP VIEW v1;
DROP TABLE t1;
DROP FUNCTION f1;
+disconnect con1;
+disconnect con2;
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------
@@ -249,11 +282,13 @@ DROP FUNCTION f1;
# The real problem was that server was unable handle properly stored
# functions in databases which names contained dot.
#
+connection default;
DROP DATABASE IF EXISTS `my.db`;
create database `my.db`;
use `my.db`;
CREATE FUNCTION f1(a int) RETURNS INT RETURN a;
-# Create new connection.
+connect addcon, localhost, root,,;
+connection addcon;
USE `my.db`;
SELECT f1(1);
f1(1)
@@ -261,7 +296,8 @@ f1(1)
SELECT `my.db`.f1(2);
`my.db`.f1(2)
2
-# Switching to default connection.
+connection default;
+disconnect addcon;
DROP DATABASE `my.db`;
USE test;
#
@@ -289,11 +325,14 @@ DROP EVENT teste_bug11763507;
# ------------------------------------------------------------------
grant create routine on test.* to foo1@localhost identified by 'foo';
update mysql.user set password = replace(password, '*', '-') where user='foo1';
+connect foo,localhost,foo1,foo;
show grants;
Grants for foo1@localhost
GRANT USAGE ON *.* TO 'foo1'@'localhost' IDENTIFIED BY PASSWORD '*F3A2A51A9B0F2BE2468926B4132313728C250DBF'
GRANT CREATE ROUTINE ON `test`.* TO 'foo1'@'localhost'
+connection default;
flush privileges;
+connection foo;
show grants;
Grants for foo1@localhost
GRANT USAGE ON *.* TO 'foo1'@'localhost' IDENTIFIED BY PASSWORD '-F3A2A51A9B0F2BE2468926B4132313728C250DBF'
@@ -304,6 +343,8 @@ Grants for foo1@localhost
GRANT USAGE ON *.* TO 'foo1'@'localhost' IDENTIFIED BY PASSWORD '-F3A2A51A9B0F2BE2468926B4132313728C250DBF'
GRANT CREATE ROUTINE ON `test`.* TO 'foo1'@'localhost'
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`spfoo` TO 'foo1'@'localhost'
+connection default;
+disconnect foo;
drop procedure spfoo;
drop user foo1@localhost;
set @@global.concurrent_insert= @old_concurrent_insert;
diff --git a/mysql-test/r/sp_sync.result b/mysql-test/r/sp_sync.result
index ba90b009ce4..d6c170712a7 100644
--- a/mysql-test/r/sp_sync.result
+++ b/mysql-test/r/sp_sync.result
@@ -8,7 +8,8 @@ SET DEBUG_SYNC= 'RESET';
# but before a MDL lock is taken. This must be noticed and the
# sp cache flushed so the correct version can be loaded.
#
-# Connection default
+connect con2, localhost, root;
+connection default;
CREATE FUNCTION f1() RETURNS INT RETURN 1;
# Get f1 cached
SELECT f1();
@@ -18,17 +19,18 @@ f1()
SET DEBUG_SYNC= 'before_execute_sql_command SIGNAL before WAIT_FOR changed';
# Sending:
SELECT f1();
-# Connection 2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR before';
# ... but before f1 is locked, change it.
DROP FUNCTION f1;
CREATE FUNCTION f1() RETURNS INT RETURN 2;
SET DEBUG_SYNC= 'now SIGNAL changed';
-# Connection default
# We should now get '2' and not '1'.
+connection default;
# Reaping: SELECT f1()
f1()
2
+disconnect con2;
DROP FUNCTION f1;
SET DEBUG_SYNC= 'RESET';
#
@@ -38,24 +40,28 @@ SET DEBUG_SYNC= 'RESET';
# to freed memory.
#
DROP FUNCTION IF EXISTS f1;
-# Connection default
+connect con2, localhost, root;
+connect con3, localhost, root;
+connection default;
CREATE FUNCTION f1() RETURNS INT RETURN 0;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'after_wait_locked_pname SIGNAL locked WAIT_FOR issued';
# con2 will now have an x-lock on f1
# Sending:
ALTER FUNCTION f1 COMMENT 'comment';
-# Connection default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR locked';
# This query will block due to the x-lock on f1 and back-off
SHOW OPEN TABLES WHERE f1()=0;
-# Connection con3
+connection con3;
# Check that the IS query is blocked before releasing the x-lock
SET DEBUG_SYNC= 'now SIGNAL issued';
-# Connection default
+connection default;
# Reaping: ALTER FUNCTION f1 COMMENT 'comment'
DROP FUNCTION f1;
SET DEBUG_SYNC= 'RESET';
+disconnect con2;
+disconnect con3;
#
# Bug #48246 assert in close_thread_table
#
@@ -65,7 +71,7 @@ CREATE FUNCTION f1(b INTEGER) RETURNS INTEGER RETURN 1;
CREATE PROCEDURE p1() SELECT COUNT(f1(a)) FROM t1, t0;
INSERT INTO t0 VALUES(1);
INSERT INTO t1 VALUES(1), (2);
-# Connection 2
+connect con2, localhost, root;
CALL p1();
COUNT(f1(a))
2
@@ -76,7 +82,7 @@ SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL locked_t1 WAIT_FOR go_for_t0
# reset properly causing an eventual assert.
# Sending:
CALL p1();
-# Connection default
+connection default;
SET DEBUG_SYNC= 'now WAIT_FOR locked_t1';
# Issue LOCK TABLES statement which will enter in MDL deadlock
# with CALL statement and as result will cause it to perform
@@ -84,11 +90,12 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked_t1';
SET DEBUG_SYNC= 'mdl_acquire_lock_wait SIGNAL go_for_t0';
LOCK TABLES t0 WRITE, t1 WRITE;
UNLOCK TABLES;
-# Connection 2
+connection con2;
# Reaping: CALL p1()
COUNT(f1(a))
2
-# Connection default
+connection default;
+disconnect con2;
DROP PROCEDURE p1;
DROP FUNCTION f1;
DROP TABLES t0, t1;
@@ -98,10 +105,15 @@ DROP TABLES t0, t1;
DROP SCHEMA IF EXISTS s1;
CREATE SCHEMA s1;
CREATE PROCEDURE s1.p1() BEGIN END;
+connect con3, localhost, root;
SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema';
CALL s1.p1;
+connection default;
SET DEBUG_SYNC='now WAIT_FOR check_db';
DROP SCHEMA s1;
SET DEBUG_SYNC='now SIGNAL dropped_schema';
+connection con3;
ERROR 42000: Unknown database 's1'
+connection default;
+disconnect con3;
SET DEBUG_SYNC = 'RESET';
diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result
index d71748bd9b1..ac1ad1c625b 100644
--- a/mysql-test/r/sql_mode.result
+++ b/mysql-test/r/sql_mode.result
@@ -497,14 +497,19 @@ xcx
drop table t1;
SET @@SQL_MODE=@OLD_SQL_MODE;
create user mysqltest_32753@localhost;
+connection default;
set @OLD_SQL_MODE=@@SESSION.SQL_MODE;
set session sql_mode='PAD_CHAR_TO_FULL_LENGTH';
flush privileges;
+connect user_32753,localhost,mysqltest_32753,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
select current_user();
current_user()
mysqltest_32753@localhost
+connection default;
set session sql_mode=@OLD_SQL_MODE;
flush privileges;
+disconnect user_32753;
+connection default;
drop user mysqltest_32753@localhost;
SET @org_mode=@@sql_mode;
SET @@sql_mode='traditional';
diff --git a/mysql-test/r/ssl-big.result b/mysql-test/r/ssl-big.result
index 39c4f34e46c..54c61507ade 100644
--- a/mysql-test/r/ssl-big.result
+++ b/mysql-test/r/ssl-big.result
@@ -1,3 +1,8 @@
DROP TABLE IF EXISTS t1, t2;
+connect ssl_con,localhost,root,,,,,SSL;
create table t1 (a int);
+disconnect ssl_con;
+connect ssl_con,localhost,root,,,,,SSL;
drop table t1;
+connection default;
+disconnect ssl_con;
diff --git a/mysql-test/r/ssl.result b/mysql-test/r/ssl.result
index 57427a228eb..c36b5c666cb 100644
--- a/mysql-test/r/ssl.result
+++ b/mysql-test/r/ssl.result
@@ -1,3 +1,4 @@
+connect ssl_con,localhost,root,,,,,SSL;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
@@ -2172,3 +2173,5 @@ NULL
select 'still connected?';
still connected?
still connected?
+connection default;
+disconnect ssl_con;
diff --git a/mysql-test/r/ssl_cipher.result b/mysql-test/r/ssl_cipher.result
index 78081300b5b..79998dfca80 100644
--- a/mysql-test/r/ssl_cipher.result
+++ b/mysql-test/r/ssl_cipher.result
@@ -1,9 +1,12 @@
#
# BUG#11760210 - SSL_CIPHER_LIST NOT SET OR RETURNED FOR "SHOW STATUS LIKE 'SSL_CIPHER_LIST'"
#
+connect ssl_con,localhost,root,,,,,SSL;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher AES128-SHA
SHOW STATUS LIKE 'Ssl_cipher_list';
Variable_name Value
Ssl_cipher_list AES128-SHA
+connection default;
+disconnect ssl_con;
diff --git a/mysql-test/r/ssl_compress.result b/mysql-test/r/ssl_compress.result
index 31f484ab58c..8260fde5c4e 100644
--- a/mysql-test/r/ssl_compress.result
+++ b/mysql-test/r/ssl_compress.result
@@ -1,3 +1,4 @@
+connect ssl_compress_con,localhost,root,,,,,SSL COMPRESS;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
@@ -2166,3 +2167,5 @@ Ssl_cipher DHE-RSA-AES256-SHA
SHOW STATUS LIKE 'Compression';
Variable_name Value
Compression ON
+connection default;
+disconnect ssl_compress_con;
diff --git a/mysql-test/r/ssl_timeout.result b/mysql-test/r/ssl_timeout.result
index 356e931ba4d..27dce524685 100644
--- a/mysql-test/r/ssl_timeout.result
+++ b/mysql-test/r/ssl_timeout.result
@@ -1,7 +1,10 @@
# connect with read timeout so SLEEP() should timeout
+connect ssl_con,localhost,root,,,,,SSL read_timeout=5;
# Check ssl turned on
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
SELECT SLEEP(600);
ERROR HY000: Lost connection to MySQL server during query
+connection default;
+disconnect ssl_con;
diff --git a/mysql-test/r/stat_tables_par.result b/mysql-test/r/stat_tables_par.result
index ed39b7af9a9..b965e289e1d 100644
--- a/mysql-test/r/stat_tables_par.result
+++ b/mysql-test/r/stat_tables_par.result
@@ -54,6 +54,9 @@ and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
revenue
77949.91860000002
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working';
use dbt3_s001;
@@ -64,6 +67,7 @@ where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24 ;
+connection con2;
set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
@@ -74,11 +78,16 @@ where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
+connection con1;
revenue
77949.91860000002
+connection con2;
revenue
77949.91860000002
+connection default;
set use_stat_tables='preferably';
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
@@ -137,16 +146,25 @@ dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_collection_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_shipdate);
+connection con2;
set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_receiptdate);
+connection con1;
+connection con2;
+connection default;
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
@@ -178,14 +196,22 @@ dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
set debug_sync='RESET';
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for all;
+connection con2;
set debug_sync='now WAIT_FOR parked';
use dbt3_s001;
set use_stat_tables='never';
set debug_sync='now SIGNAL finish';
+connection con1;
+connection default;
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
@@ -205,16 +231,25 @@ dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
set @save_global_use_stat_tables=@@global.use_stat_tables;
set global use_stat_tables='preferably';
set debug_sync='RESET';
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_update_start SIGNAL parker WAIT_FOR go1 EXECUTE 1';
set debug_sync='thr_multi_lock_after_thr_lock SIGNAL go2 EXECUTE 2';
use dbt3_s001;
analyze table lineitem persistent for all;
+connection con2;
set debug_sync='open_and_process_table WAIT_FOR parker';
set debug_sync='statistics_read_start SIGNAL go1 WAIT_FOR go2';
use dbt3_s001;
select * from mysql.index_stats, lineitem where index_name= 'i_l_shipdate' and l_orderkey=1 and l_partkey=68 order by prefix_arity;;
+connection con1;
+connection con2;
db_name table_name index_name prefix_arity avg_frequency l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
dbt3_s001 lineitem i_l_shipdate 1 2.6500 1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
+connection default;
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
set global use_stat_tables=@save_global_use_stat_tables;
DROP DATABASE dbt3_s001;
@@ -230,13 +265,18 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SET debug_sync='after_open_table_ignore_flush WAIT_FOR go';
select * from information_schema.statistics where table_schema='test';
+connect con1, localhost, root;
+connection con1;
select * from t1;
a b
1 1
2 2
SET DEBUG_SYNC= "now SIGNAL go";
+connection default;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT
def test t1 1 test a 1 a A 2 NULL NULL YES BTREE
+connection default;
+disconnect con1;
set debug_sync='RESET';
drop table t1;
set global use_stat_tables=@save_global_use_stat_tables;
diff --git a/mysql-test/r/stat_tables_par_innodb.result b/mysql-test/r/stat_tables_par_innodb.result
index cb4e4b09827..155582c9192 100644
--- a/mysql-test/r/stat_tables_par_innodb.result
+++ b/mysql-test/r/stat_tables_par_innodb.result
@@ -57,6 +57,9 @@ and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
revenue
77949.91860000002
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_mem_alloc_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 SIGNAL first_thread_working';
use dbt3_s001;
@@ -67,6 +70,7 @@ where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24 ;
+connection con2;
set debug_sync='statistics_mem_alloc_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_mem_alloc_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
@@ -77,11 +81,16 @@ where l_shipdate >= date '1994-01-01'
and l_shipdate < date '1994-01-01' + interval '1' year
and l_discount between 0.06 - 0.01 and 0.06 + 0.01
and l_quantity < 24;
+connection con1;
revenue
77949.91860000002
+connection con2;
revenue
77949.91860000002
+connection default;
set use_stat_tables='preferably';
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name;
db_name table_name index_name prefix_arity avg_frequency
@@ -140,16 +149,25 @@ dbt3_s001 lineitem i_l_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_collection_start1 WAIT_FOR second_thread_started_too';
set debug_sync='statistics_collection_start2 SIGNAL first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_shipdate);
+connection con2;
set debug_sync='statistics_collection_start1 SIGNAL second_thread_started_too';
set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for columns() indexes (i_l_receiptdate);
+connection con1;
+connection con2;
+connection default;
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem' order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
@@ -189,10 +207,14 @@ dbt3_s001 lineitem i_l_suppkey 1 600.5000
dbt3_s001 lineitem i_l_suppkey_partkey 1 30.0250
dbt3_s001 lineitem i_l_suppkey_partkey 2 8.5786
set debug_sync='RESET';
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_collection_start SIGNAL parked WAIT_FOR finish';
use dbt3_s001;
set use_stat_tables='preferably';
analyze table lineitem persistent for all;
+connection con2;
set debug_sync='now WAIT_FOR parked';
use dbt3_s001;
set use_stat_tables='never';
@@ -203,6 +225,10 @@ delete from lineitem where l_orderkey=1 and l_partkey=156;
select * from lineitem where l_orderkey=1 and l_partkey=156;
l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
set debug_sync='now SIGNAL finish';
+connection con1;
+connection default;
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
select * from mysql.index_stats where table_name='lineitem'
order by index_name, prefix_arity;
@@ -236,18 +262,27 @@ dbt3_s001 lineitem i_l_suppkey_partkey 4 1.0000
set @save_global_use_stat_tables=@@global.use_stat_tables;
set global use_stat_tables='preferably';
set debug_sync='RESET';
+connect con1, localhost, root,,;
+connect con2, localhost, root,,;
+connection con1;
set debug_sync='statistics_update_start SIGNAL parker WAIT_FOR go1 EXECUTE 1';
set debug_sync='thr_multi_lock_after_thr_lock SIGNAL go2 EXECUTE 2';
use dbt3_s001;
analyze table lineitem persistent for all;
+connection con2;
set debug_sync='open_and_process_table WAIT_FOR parker';
set debug_sync='statistics_read_start SIGNAL go1 WAIT_FOR go2';
use dbt3_s001;
select * from mysql.index_stats, lineitem where index_name= 'i_l_shipdate' and l_orderkey=1 and l_partkey=68 order by prefix_arity;;
+connection con1;
+connection con2;
db_name table_name index_name prefix_arity avg_frequency l_orderkey l_partkey l_suppkey l_linenumber l_quantity l_extendedprice l_discount l_tax l_returnflag l_linestatus l_shipDATE l_commitDATE l_receiptDATE l_shipinstruct l_shipmode l_comment
dbt3_s001 lineitem i_l_shipdate 1 2.6496 1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
dbt3_s001 lineitem i_l_shipdate 2 1.0149 1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
dbt3_s001 lineitem i_l_shipdate 3 1.0000 1 68 9 2 36 34850.16 0.09 0.06 N O 1996-04-12 1996-02-28 1996-04-20 TAKE BACK RETURN MAIL slyly bold pinto beans detect s
+connection default;
+disconnect con1;
+disconnect con2;
set debug_sync='RESET';
set global use_stat_tables=@save_global_use_stat_tables;
DROP DATABASE dbt3_s001;
@@ -263,13 +298,18 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SET debug_sync='after_open_table_ignore_flush WAIT_FOR go';
select * from information_schema.statistics where table_schema='test';
+connect con1, localhost, root;
+connection con1;
select * from t1;
a b
1 1
2 2
SET DEBUG_SYNC= "now SIGNAL go";
+connection default;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT
def test t1 1 test a 1 a A 2 NULL NULL YES BTREE
+connection default;
+disconnect con1;
set debug_sync='RESET';
drop table t1;
set global use_stat_tables=@save_global_use_stat_tables;
diff --git a/mysql-test/r/stat_tables_rbr.result b/mysql-test/r/stat_tables_rbr.result
index 35e74e29b08..7ae7ade4398 100644
--- a/mysql-test/r/stat_tables_rbr.result
+++ b/mysql-test/r/stat_tables_rbr.result
@@ -2,6 +2,7 @@
# Bug mdev-463: assertion failure when running ANALYZE with RBR on
#
SET GLOBAL use_stat_tables = PREFERABLY;
+connect con1,localhost,root,,;
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
@@ -9,6 +10,8 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
DROP TABLE t1;
SET GLOBAL use_stat_tables = DEFAULT;
+disconnect con1;
+connection default;
SET use_stat_tables = PREFERABLY;
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
ALTER TABLE t1 ANALYZE PARTITION p1;
diff --git a/mysql-test/r/stat_tables_repl.result b/mysql-test/r/stat_tables_repl.result
index 132e5f7beae..43c9fa554c9 100644
--- a/mysql-test/r/stat_tables_repl.result
+++ b/mysql-test/r/stat_tables_repl.result
@@ -11,6 +11,8 @@ Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
DROP TABLE t1;
+connection slave;
+connection master;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
ANALYZE TABLE t1;
@@ -18,6 +20,8 @@ Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
DROP INDEX idx1 ON t1;
+connection slave;
+connection master;
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
@@ -26,6 +30,8 @@ Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
ALTER TABLE t1 DROP COLUMN b;
+connection slave;
+connection master;
DROP TABLE t1;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
@@ -34,6 +40,8 @@ Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
ALTER TABLE t1 RENAME to s;
+connection slave;
+connection master;
DROP TABLE s;
CREATE TABLE t1 ( a int, b int, INDEX idx1(b) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,20), (1,20), (3,30);
@@ -42,5 +50,7 @@ Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
ALTER TABLE t1 CHANGE COLUMN b c int ;
+connection slave;
+connection master;
DROP TABLE t1;
include/rpl_end.inc
diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result
index 55afd159053..60ec5d7dec3 100644
--- a/mysql-test/r/status.result
+++ b/mysql-test/r/status.result
@@ -2,6 +2,8 @@ set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
SET @old_log_output = @@global.log_output;
SET GLOBAL LOG_OUTPUT = 'FILE';
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
flush status;
show status like 'Table_lock%';
Variable_name Value
@@ -11,7 +13,7 @@ select * from information_schema.session_status where variable_name like 'Table_
VARIABLE_NAME VARIABLE_VALUE
TABLE_LOCKS_IMMEDIATE 0
TABLE_LOCKS_WAITED 0
-# Switched to connection: con1
+connection con1;
set sql_log_bin=0;
set @old_general_log = @@global.general_log;
set global general_log = 'OFF';
@@ -21,21 +23,23 @@ insert into t1 values(1);
select 1;
1
1
-# Switched to connection: con2
+connection con2;
lock tables t1 read;
unlock tables;
lock tables t1 read;
-# Switched to connection: con1
+connection con1;
update t1 set n = 3;
-# Switched to connection: con2
+connection con2;
unlock tables;
-# Switched to connection: con1
+connection con1;
show status like 'Table_locks_waited';
Variable_name Value
Table_locks_waited 1
drop table t1;
set global general_log = @old_general_log;
-# Switched to connection: default
+disconnect con2;
+disconnect con1;
+connection default;
select 1;
1
1
@@ -77,6 +81,10 @@ VARIABLE_NAME VARIABLE_VALUE
MAX_USED_CONNECTIONS 1
SET @save_thread_cache_size=@@thread_cache_size;
SET GLOBAL thread_cache_size=3;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+disconnect con2;
SHOW STATUS LIKE 'max_used_connections';
Variable_name Value
Max_used_connections 3
@@ -90,19 +98,25 @@ Max_used_connections 2
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
VARIABLE_NAME VARIABLE_VALUE
MAX_USED_CONNECTIONS 2
+connect con2,localhost,root,,;
SHOW STATUS LIKE 'max_used_connections';
Variable_name Value
Max_used_connections 3
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
VARIABLE_NAME VARIABLE_VALUE
MAX_USED_CONNECTIONS 3
+connect con3,localhost,root,,;
SHOW STATUS LIKE 'max_used_connections';
Variable_name Value
Max_used_connections 4
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
VARIABLE_NAME VARIABLE_VALUE
MAX_USED_CONNECTIONS 4
+connection default;
SET GLOBAL thread_cache_size=@save_thread_cache_size;
+disconnect con3;
+disconnect con2;
+disconnect con1;
CREATE TABLE t1 ( a INT );
INSERT INTO t1 VALUES (1), (2);
SELECT a FROM t1 LIMIT 1;
@@ -151,6 +165,7 @@ SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
Last_query_cost 5.205836
DROP TABLE t1;
+connect con1,localhost,root,,;
show status like 'com_show_status';
Variable_name Value
Com_show_status 3
@@ -183,6 +198,8 @@ Variable_name Value
Com_show_status 8
rnd_diff tmp_table_diff
28 8
+disconnect con1;
+connection default;
flush status;
show status like 'Com%function';
Variable_name Value
@@ -201,6 +218,8 @@ Variable_name Value
Com_alter_function 0
Com_create_function 1
Com_drop_function 1
+connect root, localhost, root,,test;
+connection root;
create database db37908;
create table db37908.t1(f1 int);
insert into db37908.t1 values(1);
@@ -209,6 +228,8 @@ grant usage,execute on test.* to mysqltest_1@localhost;
create procedure proc37908() begin select 1; end |
create function func37908() returns int sql security invoker
return (select * from db37908.t1 limit 1)|
+connect user1,localhost,mysqltest_1,,test;
+connection user1;
select * from db37908.t1;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
show status where variable_name ='uptime' and 2 in (select * from db37908.t1);
@@ -217,11 +238,16 @@ show procedure status where name ='proc37908' and 1 in (select f1 from db37908.t
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
show function status where name ='func37908' and 1 in (select func37908());
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
+connection default;
+disconnect user1;
+disconnect root;
drop database db37908;
drop procedure proc37908;
drop function func37908;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
DROP USER mysqltest_1@localhost;
+connect con1,localhost,root,,;
+connection con1;
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
CREATE FUNCTION f1() RETURNS INTEGER
@@ -245,6 +271,8 @@ CALL p1();
SELECT 9;
9
9
+disconnect con1;
+connection default;
DROP PROCEDURE p1;
DROP FUNCTION f1;
flush status;
@@ -341,5 +369,6 @@ Handler_tmp_write 2
Handler_update 0
Handler_write 0
drop table t1;
+connection default;
set @@global.concurrent_insert= @old_concurrent_insert;
SET GLOBAL log_output = @old_log_output;
diff --git a/mysql-test/r/status2.result b/mysql-test/r/status2.result
index 146fb2adbaf..5805818fdf5 100644
--- a/mysql-test/r/status2.result
+++ b/mysql-test/r/status2.result
@@ -44,9 +44,13 @@ Assert Questions == 13
SHOW STATUS LIKE 'Questions';
Variable_name Value
Questions 13
+connect con1,localhost,root,,;
+connection con1;
SELECT 1;
1
1
+connection default;
+disconnect con1;
Assert Questions == 14
SHOW STATUS LIKE 'Questions';
Variable_name Value
diff --git a/mysql-test/r/status_bug17954.result b/mysql-test/r/status_bug17954.result
index 5c244cd8aca..82d4d1a9a7e 100644
--- a/mysql-test/r/status_bug17954.result
+++ b/mysql-test/r/status_bug17954.result
@@ -9,5 +9,6 @@ SELECT VALUE INTO @tc FROM v1 WHERE NAME = 'Threads_connected';
SELECT NAME FROM v1 WHERE NAME = 'Threads_created' AND VALUE < @tc;
NAME
DROP VIEW v1;
+connection default;
set @@global.concurrent_insert= @old_concurrent_insert;
SET GLOBAL log_output = @old_log_output;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index ac874f9943c..b306965034b 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -2611,7 +2611,11 @@ explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
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 ) ;
+disconnect root;
+connection default;
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
diff --git a/mysql-test/r/subselect_no_exists_to_in.result b/mysql-test/r/subselect_no_exists_to_in.result
index 6a5bec062c7..244f6057a2f 100644
--- a/mysql-test/r/subselect_no_exists_to_in.result
+++ b/mysql-test/r/subselect_no_exists_to_in.result
@@ -2614,7 +2614,11 @@ explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
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 ) ;
+disconnect root;
+connection default;
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index a574319b175..e095ed16ff9 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -2617,7 +2617,11 @@ explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
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 ) ;
+disconnect root;
+connection default;
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 62eecd568f0..f4714526613 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -2613,7 +2613,11 @@ explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
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 ) ;
+disconnect root;
+connection default;
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index 174c791489c..5ead5de4cf9 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -2617,7 +2617,11 @@ explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
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 ) ;
+disconnect root;
+connection default;
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index e0d62ac6d14..c57c46b76ff 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -2613,7 +2613,11 @@ explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
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 ) ;
+disconnect root;
+connection default;
create table t1 (a int, b int);
create table t2 (a int, b int);
insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5);
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result
index be252802c15..fdcfa800d1f 100644
--- a/mysql-test/r/subselect_sj.result
+++ b/mysql-test/r/subselect_sj.result
@@ -2880,6 +2880,8 @@ DROP TABLE t1, t2;
# MDEV-389: Wrong result (missing row) with semijoin, join_cache_level>4, LEFT JOIN...
# (testcase only)
#
+connect con1,localhost,root,,;
+connection con1;
SET join_cache_level = 5;
SET optimizer_switch = 'semijoin=on';
CREATE TABLE t1 (a INT NOT NULL, b CHAR(1), KEY(a)) ENGINE=MyISAM;
@@ -2894,6 +2896,8 @@ a cnt
1 1
4 1
drop table t1, t2;
+connection default;
+disconnect con1;
#
# MDEV-4071: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with ...
#
diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result
index 8e95b963971..2886118db30 100644
--- a/mysql-test/r/subselect_sj_jcl6.result
+++ b/mysql-test/r/subselect_sj_jcl6.result
@@ -2894,6 +2894,8 @@ DROP TABLE t1, t2;
# MDEV-389: Wrong result (missing row) with semijoin, join_cache_level>4, LEFT JOIN...
# (testcase only)
#
+connect con1,localhost,root,,;
+connection con1;
SET join_cache_level = 5;
SET optimizer_switch = 'semijoin=on';
CREATE TABLE t1 (a INT NOT NULL, b CHAR(1), KEY(a)) ENGINE=MyISAM;
@@ -2908,6 +2910,8 @@ a cnt
1 1
4 1
drop table t1, t2;
+connection default;
+disconnect con1;
#
# MDEV-4071: Valgrind warnings 'Invalid read' in subselect_engine::calc_const_tables with ...
#
diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result
index b02c9a0c6f5..2385e3887c4 100644
--- a/mysql-test/r/symlink.result
+++ b/mysql-test/r/symlink.result
@@ -122,25 +122,35 @@ INDEX DIRECTORY='TEST_DIR/tmp';
RENAME TABLE t2 TO t1;
ERROR HY000: Can't create/write to file 'TEST_DIR/tmp/t1.MYI' (Errcode: 17 "File exists")
DROP TABLE t2;
+connect session1,localhost,root,,;
+connect session2,localhost,root,,;
+connection session1;
create temporary table t1 (a int) engine=myisam data directory="MYSQLTEST_VARDIR/log" select 9 a;
show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/'
+connection session2;
create temporary table t1 (a int) engine=myisam data directory="MYSQLTEST_VARDIR/log" select 99 a;
show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/'
+connection default;
create table t1 (a int) engine=myisam select 42 a;
+connection session1;
select * from t1;
a
9
+disconnect session1;
+connection session2;
select * from t1;
a
99
+disconnect session2;
+connection default;
select * from t1;
a
42
diff --git a/mysql-test/r/synchronization.result b/mysql-test/r/synchronization.result
index 3f6d16178dd..ee8195820b0 100644
--- a/mysql-test/r/synchronization.result
+++ b/mysql-test/r/synchronization.result
@@ -1,6 +1,10 @@
DROP TABLE IF EXISTS t1,t2;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
CREATE TABLE t1 (x1 INT);
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -8,7 +12,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -16,7 +22,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -24,7 +33,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -32,7 +43,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -40,7 +54,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -48,7 +64,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -56,7 +75,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -64,7 +85,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -72,7 +96,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -80,7 +106,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -88,7 +117,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -96,7 +127,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -104,7 +138,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -112,7 +148,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -120,7 +159,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -128,7 +169,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -136,7 +180,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -144,7 +190,10 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
+connection con1;
ALTER TABLE t1 CHANGE x1 x2 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -152,7 +201,9 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
ALTER TABLE t1 CHANGE x2 x1 INT;
+connection con2;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
Table Create Table
@@ -160,4 +211,8 @@ t2 CREATE TABLE `t2` (
`xx` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
+connection con1;
DROP TABLE t1;
+connection default;
+disconnect con1;
+disconnect con2;
diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result
index ee0b3ab6d48..c674113e909 100644
--- a/mysql-test/r/temp_table.result
+++ b/mysql-test/r/temp_table.result
@@ -158,9 +158,12 @@ drop table t1, t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT);
LOCK TABLE t1 WRITE;
+connect conn1, localhost, root,,;
CREATE TEMPORARY TABLE t1 (i INT);
The following command should not block
DROP TEMPORARY TABLE t1;
+disconnect conn1;
+connection default;
DROP TABLE t1;
CREATE TABLE t1 (i INT);
CREATE TEMPORARY TABLE t2 (i INT);
diff --git a/mysql-test/r/timezone_grant.result b/mysql-test/r/timezone_grant.result
index d33d92dbc9e..42ce458d00f 100644
--- a/mysql-test/r/timezone_grant.result
+++ b/mysql-test/r/timezone_grant.result
@@ -9,6 +9,8 @@ create table t1 (a int, b datetime);
create table t2 (c int, d datetime);
create user mysqltest_1@localhost;
grant all privileges on test.* to mysqltest_1@localhost;
+connect tzuser, localhost, mysqltest_1,,;
+connection tzuser;
show grants for current_user();
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -26,10 +28,15 @@ select * from mysql.time_zone_name;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name'
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name'
+connection default;
+disconnect tzuser;
+connection default;
delete from mysql.db where user like 'mysqltest\_%';
flush privileges;
grant all privileges on test.t1 to mysqltest_1@localhost;
grant all privileges on test.t2 to mysqltest_1@localhost;
+connect tzuser2, localhost, mysqltest_1,,;
+connection tzuser2;
show grants for current_user();
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
@@ -57,6 +64,8 @@ update t1 set b = '2005-01-01 10:00';
update t1 set b = convert_tz(b, 'UTC', 'UTC');
update t1 join t2 on (t1.a = t2.a) set t1.b = '2005-01-01 10:00' where t2.b = 'foo';
update t1 join t2 on (t1.a = t2.a) set t1.b = convert_tz('2005-01-01 10:00','UTC','UTC') where t2.b = 'foo';
+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\_%';
@@ -66,6 +75,7 @@ create table t1 (a int, b datetime);
insert into t1 values (1, 20010101000000), (2, 20020101000000);
create user mysqltest_1@localhost;
grant all privileges on test.* to mysqltest_1@localhost;
+connect tzuser3, localhost, mysqltest_1,,;
create view v1 as select a, convert_tz(b, 'UTC', 'Europe/Moscow') as lb from t1;
select * from v1;
a lb
@@ -76,5 +86,7 @@ ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table '
drop view v1;
create view v1 as select a, convert_tz(b, 'UTC', 'Europe/Moscow') as lb from t1, mysql.time_zone;
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 'time_zone'
+connection default;
+disconnect tzuser3;
drop table t1;
drop user mysqltest_1@localhost;
diff --git a/mysql-test/r/trans_read_only.result b/mysql-test/r/trans_read_only.result
index 2b1055d4a7b..61ce646d535 100644
--- a/mysql-test/r/trans_read_only.result
+++ b/mysql-test/r/trans_read_only.result
@@ -7,7 +7,8 @@
SELECT @@tx_read_only;
@@tx_read_only
1
-# Also for new connections. Switching to con1
+# Also for new connections.
+connect con1, localhost, root;
SELECT @@tx_read_only;
@@tx_read_only
1
@@ -15,7 +16,8 @@ SET SESSION TRANSACTION READ WRITE;
SELECT @@tx_read_only;
@@tx_read_only
0
-# Connection default
+disconnect con1;
+connection default;
SELECT @@tx_read_only;
@@tx_read_only
1
diff --git a/mysql-test/r/trigger-compat.result b/mysql-test/r/trigger-compat.result
index 7659667fb37..3d96507d71f 100644
--- a/mysql-test/r/trigger-compat.result
+++ b/mysql-test/r/trigger-compat.result
@@ -8,8 +8,8 @@ CREATE DATABASE mysqltest_db1;
CREATE USER mysqltest_dfn@localhost;
CREATE USER mysqltest_inv@localhost;
GRANT CREATE, TRIGGER ON mysqltest_db1.* TO mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+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());
@@ -35,6 +35,8 @@ DROP TRIGGER wl2818_trg1;
Warnings:
Warning 1454 No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger will be activated under the authorization of the invoker, which may have insufficient privileges. Please recreate the trigger.
DROP TRIGGER wl2818_trg2;
+disconnect wl2818_definer_con;
+connection default;
use mysqltest_db1;
DROP TABLE t1;
DROP TABLE t2;
diff --git a/mysql-test/r/trigger-trans.result b/mysql-test/r/trigger-trans.result
index cab7336cbe5..c58c4230a40 100644
--- a/mysql-test/r/trigger-trans.result
+++ b/mysql-test/r/trigger-trans.result
@@ -113,13 +113,18 @@ for each row
begin
insert into t3 (c) values (1);
end|
+connect connection_aux,localhost,root,,test,,;
+connect connection_update,localhost,root,,test,,;
+connection connection_aux;
select get_lock("lock_bug26141_wait", 0);
get_lock("lock_bug26141_wait", 0)
1
+connection default;
select get_lock("lock_bug26141_sync", /* must not be priorly locked */ 0);
get_lock("lock_bug26141_sync", /* must not be priorly locked */ 0)
1
insert into t1 (c) values (2);
+connection connection_update;
select get_lock("lock_bug26141_sync", 1000);
get_lock("lock_bug26141_sync", 1000)
1
@@ -127,9 +132,11 @@ update t1 set c=3 where c=1;
select release_lock("lock_bug26141_sync");
release_lock("lock_bug26141_sync")
1
+connection connection_aux;
select release_lock("lock_bug26141_wait");
release_lock("lock_bug26141_wait")
1
+connection default;
select * from t1;
c
2
@@ -141,6 +148,8 @@ select * from t3;
c
1
drop table t1, t2, t3;
+disconnect connection_update;
+disconnect connection_aux;
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=innodb;
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index 86219875bed..19a8d53a428 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -4,6 +4,10 @@ drop database if exists mysqltest;
drop function if exists f1;
drop function if exists f2;
drop procedure if exists p1;
+connect addconroot1, localhost, root,,;
+connect addconroot2, localhost, root,,;
+connect addconwithoutdb, localhost, root,,*NO-ONE*;
+connection default;
create table t1 (i int);
create trigger trg before insert on t1 for each row set @a:=1;
set @a:=0;
@@ -733,7 +737,9 @@ set NEW.username = user;
select count(*) from ((select 1) union (select 2)) as d1 into i;
end|
update t1 set data = 1;
+connection addconroot1;
update t1 set data = 2;
+connection default;
drop table t1;
create table t1 (c1 int, c2 datetime);
create trigger tr1 before insert on t1 for each row
@@ -848,12 +854,14 @@ end//
CALL p1();
drop procedure p1;
drop table t1;
+connection addconwithoutdb;
create trigger t1_bi before insert on test.t1 for each row set @a:=0;
ERROR 3D000: No database selected
create trigger test.t1_bi before insert on t1 for each row set @a:=0;
ERROR 42S02: Table 'test.t1' doesn't exist
drop trigger t1_bi;
ERROR 3D000: No database selected
+connection default;
create table t1 (id int);
create trigger t1_bi before insert on t1 for each row set @a:=new.id;
create trigger t1_ai after insert on test.t1 for each row set @b:=new.id;
@@ -1061,7 +1069,10 @@ trigger_conn_id INT
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
SET NEW.trigger_conn_id = CONNECTION_ID();
INSERT INTO t1 (conn_id, trigger_conn_id) VALUES (CONNECTION_ID(), -1);
+connect con1,localhost,root,,;
INSERT INTO t1 (conn_id, trigger_conn_id) VALUES (CONNECTION_ID(), -1);
+connection default;
+disconnect con1;
SELECT * FROM t1 WHERE conn_id != trigger_conn_id;
conn_id trigger_conn_id
DROP TRIGGER t1_bi;
@@ -1275,10 +1286,12 @@ insert into t1 values ();
select @a;
@a
20
+connection addconroot1;
insert into t1 values ();
select @a;
@a
20
+connection default;
drop table t1;
drop function f1;
drop table if exists t1;
@@ -1445,6 +1458,9 @@ isave
1
2
drop table t1, t2, t3;
+disconnect addconroot1;
+disconnect addconroot2;
+disconnect addconwithoutdb;
Bug#28502 Triggers that update another innodb table will block
on X lock unnecessarily
@@ -1464,7 +1480,10 @@ end if;
end|
insert into t1 (id, count) values (1, 0);
lock table t1 write;
+connect connection_insert, localhost, root, , test, , ;
+connection connection_insert;
insert into t2 set id=1;
+connection default;
unlock tables;
update t2 set id=1 where id=1;
select * from t1;
@@ -1474,6 +1493,7 @@ select * from t2;
id
1
drop table t1, t2;
+disconnect connection_insert;
Additionally, provide test coverage for triggers and
all MySQL data changing commands.
@@ -2245,9 +2265,12 @@ VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9);
INSERT INTO t2
VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0);
UPDATE t1 SET a = 3;
+connect con1,localhost,root,,;
SELECT COUNT(*) FROM t1;
COUNT(*)
9
+disconnect con1;
+connection default;
SELECT * FROM t2;
b
9
diff --git a/mysql-test/r/trigger_notembedded.result b/mysql-test/r/trigger_notembedded.result
index 795f722b0d4..b0addf8d50f 100644
--- a/mysql-test/r/trigger_notembedded.result
+++ b/mysql-test/r/trigger_notembedded.result
@@ -8,69 +8,67 @@ CREATE DATABASE mysqltest_db1;
CREATE USER mysqltest_dfn@localhost;
CREATE USER mysqltest_inv@localhost;
GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
CREATE TABLE t1(num_value INT);
CREATE TABLE t2(user_str TEXT);
-
----> connection: default
+disconnect wl2818_definer_con;
+connection default;
GRANT INSERT, DROP ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
GRANT INSERT, DROP ON mysqltest_db1.t2 TO mysqltest_dfn@localhost;
-
----> connection: default
+connection default;
GRANT SUPER ON *.* TO mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
CREATE TRIGGER trg1 AFTER INSERT ON t1
FOR EACH ROW
INSERT INTO t2 VALUES(CURRENT_USER());
ERROR 42000: TRIGGER command denied to user 'mysqltest_dfn'@'localhost' for table 't1'
-
----> connection: default
+disconnect wl2818_definer_con;
+connection default;
GRANT TRIGGER ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
CREATE TRIGGER trg1 AFTER INSERT ON t1
FOR EACH ROW
INSERT INTO t2 VALUES(CURRENT_USER());
-
----> connection: default
+disconnect wl2818_definer_con;
+connection default;
REVOKE TRIGGER ON mysqltest_db1.t1 FROM mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
DROP TRIGGER trg1;
ERROR 42000: TRIGGER command denied to user 'mysqltest_dfn'@'localhost' for table 't1'
-
----> connection: wl2818_definer_con
+disconnect wl2818_definer_con;
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
INSERT INTO t1 VALUES(0);
ERROR 42000: TRIGGER command denied to user 'mysqltest_dfn'@'localhost' for table 't1'
-
----> connection: default
+disconnect wl2818_definer_con;
+connection default;
GRANT TRIGGER ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
INSERT INTO t1 VALUES(0);
DROP TRIGGER trg1;
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
-
----> connection: default
+disconnect wl2818_definer_con;
+connection default;
REVOKE SUPER ON *.* FROM mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
CREATE TRIGGER trg1 AFTER INSERT ON t1
FOR EACH ROW
INSERT INTO t2 VALUES(CURRENT_USER());
-
----> connection: default
+connection default;
GRANT ALL PRIVILEGES ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
GRANT ALL PRIVILEGES ON mysqltest_db1.t2 TO mysqltest_dfn@localhost;
GRANT ALL PRIVILEGES ON mysqltest_db1.t1
TO 'mysqltest_inv'@localhost;
GRANT SELECT ON mysqltest_db1.t2
TO 'mysqltest_inv'@localhost;
-
----> connection: wl2818_definer_con
+connection wl2818_definer_con;
use mysqltest_db1;
INSERT INTO t1 VALUES(1);
SELECT * FROM t1;
@@ -79,8 +77,8 @@ num_value
SELECT * FROM t2;
user_str
mysqltest_dfn@localhost
-
----> connection: wl2818_invoker_con
+connect wl2818_invoker_con,localhost,mysqltest_inv,,mysqltest_db1;
+connection wl2818_invoker_con;
use mysqltest_db1;
INSERT INTO t1 VALUES(2);
SELECT * FROM t1;
@@ -91,12 +89,10 @@ SELECT * FROM t2;
user_str
mysqltest_dfn@localhost
mysqltest_dfn@localhost
-
----> connection: default
+connection default;
use mysqltest_db1;
REVOKE INSERT ON mysqltest_db1.t2 FROM mysqltest_dfn@localhost;
-
----> connection: wl2818_invoker_con
+connection wl2818_invoker_con;
use mysqltest_db1;
INSERT INTO t1 VALUES(3);
ERROR 42000: INSERT command denied to user 'mysqltest_dfn'@'localhost' for table 't2'
@@ -109,8 +105,7 @@ SELECT * FROM t2;
user_str
mysqltest_dfn@localhost
mysqltest_dfn@localhost
-
----> connection: wl2818_definer_con
+connection wl2818_definer_con;
use mysqltest_db1;
DROP TRIGGER trg1;
CREATE DEFINER='mysqltest_inv'@'localhost'
@@ -118,12 +113,12 @@ CREATE DEFINER='mysqltest_inv'@'localhost'
FOR EACH ROW
SET @new_sum = 0;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
-
----> connection: default
+connection default;
use mysqltest_db1;
GRANT SUPER ON *.* TO mysqltest_dfn@localhost;
-
----> connection: wl2818_definer_con
+disconnect wl2818_definer_con;
+connect wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1;
+connection wl2818_definer_con;
CREATE DEFINER='mysqltest_inv'@'localhost'
TRIGGER trg1 BEFORE INSERT ON t1
FOR EACH ROW
@@ -173,8 +168,7 @@ def mysqltest_db1 trg2 INSERT def mysqltest_db1 t1 0 NULL SET @a = 2 ROW AFTER N
def mysqltest_db1 trg3 UPDATE def mysqltest_db1 t1 0 NULL SET @a = 3 ROW BEFORE NULL NULL OLD NEW NULL NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION @abc@def@@% latin1 latin1_swedish_ci latin1_swedish_ci
def mysqltest_db1 trg4 UPDATE def mysqltest_db1 t1 0 NULL SET @a = 4 ROW AFTER NULL NULL OLD NEW NULL NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION @hostname latin1 latin1_swedish_ci latin1_swedish_ci
def mysqltest_db1 trg5 DELETE def mysqltest_db1 t1 0 NULL SET @a = 5 ROW BEFORE NULL NULL OLD NEW NULL NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION @abcdef@@@hostname latin1 latin1_swedish_ci latin1_swedish_ci
-
----> connection: default
+connection default;
DROP USER mysqltest_dfn@localhost;
DROP USER mysqltest_inv@localhost;
DROP DATABASE mysqltest_db1;
@@ -194,29 +188,26 @@ CREATE USER mysqltest_u1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
GRANT TRIGGER ON mysqltest_db1.* TO mysqltest_u1@localhost;
SET @mysqltest_var = NULL;
-
----> connection: default
+connect bug15166_u1_con,localhost,mysqltest_u1,,mysqltest_db1;
+connection default;
use mysqltest_db1;
GRANT DELETE ON mysqltest_db1.* TO mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
Grants for mysqltest_u1@localhost
GRANT USAGE ON *.* TO 'mysqltest_u1'@'localhost'
GRANT DELETE, TRIGGER ON `mysqltest_db1`.* TO 'mysqltest_u1'@'localhost'
-
----> connection: bug15166_u1_con
+connection bug15166_u1_con;
use mysqltest_db1;
CREATE TRIGGER t1_trg_after_delete AFTER DELETE ON t1
FOR EACH ROW
SET @mysqltest_var = 'Hello, world!';
-
----> connection: default
+connection default;
use mysqltest_db1;
GRANT UPDATE ON mysqltest_db1.t1 TO mysqltest_u1@localhost;
GRANT UPDATE ON mysqltest_db1.t2 TO mysqltest_u1@localhost;
GRANT UPDATE(col) ON mysqltest_db1.t3 TO mysqltest_u1@localhost;
GRANT UPDATE(col) ON mysqltest_db1.t4 TO mysqltest_u1@localhost;
-
----> connection: bug15166_u1_con
+connection bug15166_u1_con;
use mysqltest_db1;
CREATE TRIGGER t1_trg_err_1 BEFORE INSERT ON t1
FOR EACH ROW
@@ -240,8 +231,7 @@ DROP TRIGGER t3_trg_err_2;
CREATE TRIGGER t4_trg_before_insert BEFORE INSERT ON t4
FOR EACH ROW
SET NEW.col = 't4_trg_before_insert';
-
----> connection: default
+connection default;
use mysqltest_db1;
REVOKE UPDATE ON mysqltest_db1.t1 FROM mysqltest_u1@localhost;
REVOKE UPDATE ON mysqltest_db1.t2 FROM mysqltest_u1@localhost;
@@ -251,8 +241,7 @@ REVOKE UPDATE(col) ON mysqltest_db1.t3 FROM mysqltest_u1@localhost;
REVOKE UPDATE(col) ON mysqltest_db1.t4 FROM mysqltest_u1@localhost;
GRANT SELECT(col) on mysqltest_db1.t3 TO mysqltest_u1@localhost;
GRANT SELECT(col) on mysqltest_db1.t4 TO mysqltest_u1@localhost;
-
----> connection: bug15166_u1_con
+connection bug15166_u1_con;
use mysqltest_db1;
CREATE TRIGGER t1_trg_after_insert AFTER INSERT ON t1
FOR EACH ROW
@@ -282,8 +271,7 @@ CREATE TRIGGER t4_trg_err_2 BEFORE UPDATE ON t4
FOR EACH ROW
SET NEW.col = CONCAT(OLD.col, '(updated)');
DROP TRIGGER t4_trg_err_2;
-
----> connection: default
+connection default;
use mysqltest_db1;
REVOKE SELECT ON mysqltest_db1.t1 FROM mysqltest_u1@localhost;
REVOKE SELECT ON mysqltest_db1.t2 FROM mysqltest_u1@localhost;
@@ -317,8 +305,7 @@ INSERT INTO t4 VALUES('t4_line2');
SELECT * FROM t4;
col
t4_trg_before_insert
-
----> connection: default
+connection default;
use mysqltest_db1;
REVOKE UPDATE ON mysqltest_db1.t1 FROM mysqltest_u1@localhost;
REVOKE UPDATE ON mysqltest_db1.t2 FROM mysqltest_u1@localhost;
@@ -374,69 +361,103 @@ CREATE USER mysqltest_dfn@localhost;
CREATE USER mysqltest_inv@localhost;
GRANT EXECUTE, CREATE ROUTINE, TRIGGER ON *.* TO mysqltest_dfn@localhost;
GRANT INSERT ON mysqltest_db1.* TO mysqltest_inv@localhost;
+connect definer,localhost,mysqltest_dfn,,mysqltest_db1;
+connect invoker,localhost,mysqltest_inv,,mysqltest_db1;
+connection definer;
CREATE PROCEDURE p1(OUT i INT) DETERMINISTIC NO SQL SET i = 3;
CREATE PROCEDURE p2(INOUT i INT) DETERMINISTIC NO SQL SET i = i * 5;
+connection definer;
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
CALL p1(NEW.i1);
CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW
CALL p2(NEW.i1);
+connection invoker;
INSERT INTO t1 VALUES (7);
ERROR 42000: UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1'
INSERT INTO t2 VALUES (11);
ERROR 42000: SELECT, UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't2'
+connection definer;
DROP TRIGGER t2_bi;
DROP TRIGGER t1_bi;
+connection default;
GRANT SELECT ON mysqltest_db1.* TO mysqltest_dfn@localhost;
+connection definer;
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
CALL p1(NEW.i1);
CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW
CALL p2(NEW.i1);
+connection invoker;
INSERT INTO t1 VALUES (13);
ERROR 42000: UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1'
INSERT INTO t2 VALUES (17);
ERROR 42000: UPDATE command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't2'
+connection default;
REVOKE SELECT ON mysqltest_db1.* FROM mysqltest_dfn@localhost;
+connection definer;
DROP TRIGGER t2_bi;
DROP TRIGGER t1_bi;
+connection default;
GRANT UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
+connection definer;
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
CALL p1(NEW.i1);
CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW
CALL p2(NEW.i1);
+connection invoker;
INSERT INTO t1 VALUES (19);
INSERT INTO t2 VALUES (23);
ERROR 42000: SELECT command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't2'
+connection default;
REVOKE UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost;
+connection definer;
DROP TRIGGER t2_bi;
DROP TRIGGER t1_bi;
+connection default;
GRANT SELECT, UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
+connection definer;
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
CALL p1(NEW.i1);
CREATE TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW
CALL p2(NEW.i1);
+connection invoker;
INSERT INTO t1 VALUES (29);
INSERT INTO t2 VALUES (31);
+connection default;
REVOKE SELECT, UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost;
+connection definer;
DROP TRIGGER t2_bi;
DROP TRIGGER t1_bi;
+connection default;
DROP PROCEDURE p2;
DROP PROCEDURE p1;
+connection default;
GRANT UPDATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
+connection definer;
CREATE PROCEDURE p1(OUT i INT) DETERMINISTIC NO SQL SET i = 37;
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
CALL p1(NEW.i1);
+connection invoker;
INSERT INTO t1 VALUES (41);
+connection definer;
DROP PROCEDURE p1;
CREATE PROCEDURE p1(IN i INT) DETERMINISTIC NO SQL SET @v1 = i + 43;
+connection invoker;
INSERT INTO t1 VALUES (47);
ERROR 42000: SELECT command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1'
+connection definer;
DROP PROCEDURE p1;
CREATE PROCEDURE p1(INOUT i INT) DETERMINISTIC NO SQL SET i = i + 51;
+connection invoker;
INSERT INTO t1 VALUES (53);
ERROR 42000: SELECT command denied to user 'mysqltest_dfn'@'localhost' for column 'i1' in table 't1'
+connection default;
DROP PROCEDURE p1;
REVOKE UPDATE ON mysqltest_db1.* FROM mysqltest_dfn@localhost;
+connection definer;
DROP TRIGGER t1_bi;
+disconnect definer;
+disconnect invoker;
+connection default;
DROP USER mysqltest_inv@localhost;
DROP USER mysqltest_dfn@localhost;
DROP TABLE t2;
@@ -448,24 +469,41 @@ CREATE TABLE t2 (id INTEGER);
INSERT INTO t2 VALUES (1),(2);
CREATE TRIGGER t1_test AFTER INSERT ON t1 FOR EACH ROW
INSERT INTO t2 VALUES (new.id);
+CONNECT rl_holder, localhost, root,,;
+CONNECT rl_acquirer, localhost, root,,;
+CONNECT wl_acquirer, localhost, root,,;
+CONNECT rl_contender, localhost, root,,;
+connection rl_holder;
SELECT GET_LOCK('B26162',120);
GET_LOCK('B26162',120)
1
+connection rl_acquirer;
SELECT 'rl_acquirer', GET_LOCK('B26162',120), id FROM t2 WHERE id = 1;
+connection wl_acquirer;
SET SESSION LOW_PRIORITY_UPDATES=1;
SET GLOBAL LOW_PRIORITY_UPDATES=1;
INSERT INTO t1 VALUES (5);
+connection rl_contender;
SELECT 'rl_contender', id FROM t2 WHERE id > 1;
+connection rl_holder;
SELECT RELEASE_LOCK('B26162');
RELEASE_LOCK('B26162')
1
+connection rl_acquirer;
rl_acquirer GET_LOCK('B26162',120) id
rl_acquirer 1 1
SELECT RELEASE_LOCK('B26162');
RELEASE_LOCK('B26162')
1
+connection wl_acquirer;
+connection rl_contender;
rl_contender id
rl_contender 2
+connection default;
+disconnect rl_acquirer;
+disconnect wl_acquirer;
+disconnect rl_contender;
+disconnect rl_holder;
DROP TRIGGER t1_test;
DROP TABLE t1,t2;
SET SESSION LOW_PRIORITY_UPDATES=DEFAULT;
@@ -473,18 +511,21 @@ SET GLOBAL LOW_PRIORITY_UPDATES=DEFAULT;
End of 5.0 tests.
drop table if exists t1;
create table t1 (i int);
-connection: default
+connect flush,localhost,root,,test,,;
+connection default;
lock tables t1 write;
-connection: flush
+connection flush;
flush tables with read lock;;
-connection: default
+connection default;
create trigger t1_bi before insert on t1 for each row begin end;
unlock tables;
-connection: flush
+connection flush;
unlock tables;
+connection default;
select * from t1;
i
drop table t1;
+disconnect flush;
CREATE DATABASE db1;
CREATE TABLE db1.t1 (a char(30)) ENGINE=MEMORY;
CREATE TRIGGER db1.trg AFTER INSERT ON db1.t1 FOR EACH ROW
@@ -492,11 +533,14 @@ INSERT INTO db1.t1 VALUES('Some very sensitive data goes here');
CREATE USER 'no_rights'@'localhost';
REVOKE ALL ON *.* FROM 'no_rights'@'localhost';
FLUSH PRIVILEGES;
+connect con1,localhost,no_rights,,;
SELECT trigger_name FROM INFORMATION_SCHEMA.TRIGGERS
WHERE trigger_schema = 'db1';
trigger_name
SHOW CREATE TRIGGER db1.trg;
ERROR 42000: Access denied; you need (at least one of) the TRIGGER privilege(s) for this operation
+connection default;
+disconnect con1;
DROP USER 'no_rights'@'localhost';
DROP DATABASE db1;
DROP DATABASE IF EXISTS mysqltest_db1;
@@ -504,6 +548,7 @@ CREATE DATABASE mysqltest_db1;
USE mysqltest_db1;
CREATE USER mysqltest_u1@localhost;
GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost;
+connect con1,localhost,mysqltest_u1,,mysqltest_db1;
CREATE TABLE t1 (
a1 int,
a2 int
@@ -515,10 +560,13 @@ CREATE TABLE t2 (
a1 int
);
INSERT INTO t2 VALUES (2);
+connection default;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
UPDATE IGNORE t1, t2 SET t1.a1 = 2, t2.a1 = 3 WHERE t1.a1 = 1 AND t2.a1 = 2;
ERROR 42000: TRIGGER command denied to user 'mysqltest_u1'@'localhost' for table 't1'
DROP DATABASE mysqltest_db1;
DROP USER mysqltest_u1@localhost;
+disconnect con1;
+connection default;
USE test;
End of 5.1 tests.
diff --git a/mysql-test/r/truncate_coverage.result b/mysql-test/r/truncate_coverage.result
index 395c71b2e6b..95e649912e5 100644
--- a/mysql-test/r/truncate_coverage.result
+++ b/mysql-test/r/truncate_coverage.result
@@ -5,48 +5,41 @@ DROP TABLE IF EXISTS t1;
#
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 VALUES (1);
-#
-# connection con1
+connect con1, localhost, root,,;
HANDLER t1 OPEN;
-#
-# connection default
+connection default;
LOCK TABLE t1 WRITE;
SET DEBUG_SYNC='mdl_upgrade_lock SIGNAL waiting';
TRUNCATE TABLE t1;
-#
-# connection con2
+connect con2, localhost, root,,;
SET DEBUG_SYNC='now WAIT_FOR waiting';
KILL QUERY @id;
-#
-# connection default
+disconnect con2;
+connection default;
ERROR 70100: Query execution was interrupted
UNLOCK TABLES;
-#
-# connection con1
+connection con1;
# Release shared metadata lock by closing HANDLER.
HANDLER t1 CLOSE;
-#
-# connection default
+disconnect con1;
+connection default;
DROP TABLE t1;
SET DEBUG_SYNC='RESET';
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 VALUES (1);
-#
-# connection con1
+connect con1, localhost, root,,;
HANDLER t1 OPEN;
-#
-# connection default
+connection default;
LOCK TABLE t1 WRITE;
SET DEBUG_SYNC='mdl_upgrade_lock SIGNAL waiting';
TRUNCATE TABLE t1;
-#
-# connection con2
+connect con2, localhost, root,,;
SET DEBUG_SYNC='now WAIT_FOR waiting';
-#
-# connection con1
+disconnect con2;
+connection con1;
HANDLER t1 CLOSE;
-#
-# connection default
+disconnect con1;
+connection default;
ERROR 42S02: Table 'test.t1' doesn't exist
UNLOCK TABLES;
DROP TABLE t1;
@@ -54,27 +47,22 @@ ERROR 42S02: Unknown table 'test.t1'
SET DEBUG_SYNC='RESET';
CREATE TABLE t1 (c1 INT);
INSERT INTO t1 VALUES (1);
-#
-# connection con1
+connect con1, localhost, root,,;
START TRANSACTION;
INSERT INTO t1 VALUES (2);
-#
-# connection default
+connection default;
SET DEBUG_SYNC='mdl_acquire_lock_wait SIGNAL waiting';
TRUNCATE TABLE t1;
-#
-# connection con1
+connection con1;
SET DEBUG_SYNC='now WAIT_FOR waiting';
KILL QUERY @id;
-#
-# connection default
+connection default;
ERROR 70100: Query execution was interrupted
-#
-# connection con1
+connection con1;
# Release SW lock by committing transaction.
COMMIT;
-#
-# connection default
+disconnect con1;
+connection default;
UNLOCK TABLES;
DROP TABLE t1;
SET DEBUG_SYNC='RESET';
@@ -86,22 +74,25 @@ SET DEBUG_SYNC='RESET';
DROP TABLE IF EXISTS t1, m1;
CREATE TABLE t1(a INT) engine=memory;
CREATE TABLE m1(a INT) engine=merge UNION(t1);
-# Connection con1
+connect con2, localhost, root;
+connect con1, localhost, root;
SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR dropped';
# Sending:
TRUNCATE TABLE m1;
-# Connection con2
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
# Sending:
FLUSH TABLES;
-# Connection default
+connection default;
# Waiting for FLUSH TABLES to be blocked.
SET DEBUG_SYNC= 'now SIGNAL dropped';
-# Connection con1
+connection con1;
# Reaping: TRUNCATE TABLE m1
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
-# Connection con2
+disconnect con1;
+connection con2;
# Reaping: FLUSH TABLES
-# Connection default
+disconnect con2;
+connection default;
SET DEBUG_SYNC= 'RESET';
DROP TABLE m1, t1;
diff --git a/mysql-test/r/udf_debug_sync.result b/mysql-test/r/udf_debug_sync.result
index 2db75f9aa76..8ce6dbdd5c0 100644
--- a/mysql-test/r/udf_debug_sync.result
+++ b/mysql-test/r/udf_debug_sync.result
@@ -1,20 +1,28 @@
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE VIEW v1 AS SELECT myfunc_int(1);
+connect con1, localhost, root,,;
+connection con1;
SET debug_sync='mysql_create_function_after_lock SIGNAL locked WAIT_FOR go';
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
+connection default;
SET debug_sync='now WAIT_FOR locked';
SET debug_sync='find_udf_before_lock SIGNAL go';
SELECT * FROM v1;
myfunc_int(1)
1
FLUSH TABLES;
+connection con1;
SET debug_sync='mysql_drop_function_after_lock SIGNAL locked WAIT_FOR go';
DROP FUNCTION myfunc_double;
+connection default;
SET debug_sync='now WAIT_FOR locked';
SET debug_sync='find_udf_before_lock SIGNAL go';
SELECT * FROM v1;
myfunc_int(1)
1
+connection con1;
+disconnect con1;
+connection default;
SET debug_sync='RESET';
DROP VIEW v1;
DROP FUNCTION myfunc_int;
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index dd7c8fcc8ee..12f18d6038d 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1377,6 +1377,7 @@ SELECT @tmp_max:= @@global.max_allowed_packet;
SET @@global.max_allowed_packet=25000000;
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '25000000'
+connect newconn, localhost, root,,;
CREATE TABLE t1 (a mediumtext);
CREATE TABLE t2 (b varchar(20));
INSERT INTO t1 VALUES ('a');
@@ -1414,7 +1415,9 @@ t3 CREATE TABLE `t3` (
`a` varbinary(510) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLES t1,t2,t3;
+connection default;
SET @@global.max_allowed_packet:= @tmp_max;
+disconnect newconn;
create table t1 ( id int not null auto_increment, primary key (id), col1 int);
insert into t1 (col1) values (2),(3),(4),(5),(6);
select 99 union all select id from t1 order by 1;
diff --git a/mysql-test/r/unsafe_binlog_innodb.result b/mysql-test/r/unsafe_binlog_innodb.result
index b2cf16ad58f..0fe3d38035b 100644
--- a/mysql-test/r/unsafe_binlog_innodb.result
+++ b/mysql-test/r/unsafe_binlog_innodb.result
@@ -14,6 +14,9 @@ select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
where mm.id is null lock in share mode;
id f_id f
drop table t1,t2;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connection a;
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
@@ -28,24 +31,41 @@ a b
6 2
7 3
update t1 set b = 5 where b = 1;
+connection b;
set autocommit = 0;
select * from t1 where a = 2 and b = 2 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection a;
commit;
+connection b;
commit;
drop table t1;
+connection default;
+disconnect a;
+disconnect b;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connection a;
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
set autocommit = 0;
update t1 set b = 5 where b = 1;
+connection b;
set autocommit = 0;
select * from t1 where a = 7 and b = 3 for update;
a b
7 3
commit;
+connection a;
commit;
drop table t1;
+connection default;
+disconnect a;
+disconnect b;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connection a;
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(d int not null, e int, primary key(d)) engine = InnoDB;
@@ -57,17 +77,33 @@ d e
3 1
8 6
12 1
+connection b;
set autocommit = 0;
insert into t1 select * from t2;
update t1 set b = (select e from t2 where a = d);
create table t3(d int not null, e int, primary key(d)) engine = InnoDB
select * from t2;
commit;
+connection a;
commit;
+connection default;
+disconnect a;
+disconnect b;
drop table t1, t2, t3;
+connect a,localhost,root,,;
+connect b,localhost,root,,;
+connect c,localhost,root,,;
+connect d,localhost,root,,;
SET SESSION STORAGE_ENGINE = InnoDB;
+connect e,localhost,root,,;
+connect f,localhost,root,,;
+connect g,localhost,root,,;
SET SESSION STORAGE_ENGINE = InnoDB;
+connect h,localhost,root,,;
+connect i,localhost,root,,;
+connect j,localhost,root,,;
SET SESSION STORAGE_ENGINE = InnoDB;
+connection a;
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
insert into t1 values (1,2),(5,3),(4,2);
create table t2(a int not null, b int, primary key(a)) engine = InnoDB;
@@ -89,35 +125,65 @@ a b
3 1
8 6
12 1
+connection b;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
insert into t1 select * from t2;
+connection c;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
update t3 set b = (select b from t2 where a = d);
+connection d;
set autocommit = 0;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
create table t4(a int not null, b int, primary key(a)) select * from t2;
+connection e;
set autocommit = 0;
insert into t5 (select * from t2 lock in share mode);
+connection f;
set autocommit = 0;
update t6 set e = (select b from t2 where a = d lock in share mode);
+connection g;
set autocommit = 0;
create table t7(a int not null, b int, primary key(a)) select * from t2 lock in share mode;
+connection h;
set autocommit = 0;
insert into t8 (select * from t2 for update);
+connection i;
set autocommit = 0;
update t9 set e = (select b from t2 where a = d for update);
+connection j;
set autocommit = 0;
create table t10(a int not null, b int, primary key(a)) select * from t2 for update;
+connection b;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection c;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection d;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection e;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection f;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection g;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection h;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection i;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection j;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection a;
commit;
+connection default;
+disconnect a;
+disconnect b;
+disconnect c;
+disconnect d;
+disconnect e;
+disconnect f;
+disconnect g;
+disconnect h;
+disconnect i;
+disconnect j;
drop table t1, t2, t3, t5, t6, t8, t9;
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index a0c35c6e0ca..f7a36c537f9 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -477,6 +477,8 @@ a quux
2 0.100000000000000000000000000000
3 NULL
DROP TABLE t1;
+connect con1,localhost,root,,test;
+connection con1;
set tmp_table_size=1024;
create table t1 (id int, a int, key idx(a));
create table t2 (id int unsigned not null auto_increment primary key, a int);
@@ -511,6 +513,8 @@ update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
affected rows: 127
info: Rows matched: 128 Changed: 127 Warnings: 0
drop table t1,t2;
+connection default;
+disconnect con1;
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS f1;
CREATE FUNCTION f1() RETURNS INT RETURN f1();
diff --git a/mysql-test/r/user_limits.result b/mysql-test/r/user_limits.result
index 5ab98d1fc30..bbf73d7c617 100644
--- a/mysql-test/r/user_limits.result
+++ b/mysql-test/r/user_limits.result
@@ -9,18 +9,27 @@ flush privileges;
create user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2;
flush user_resources;
+connect mqph, localhost, mysqltest_1,,;
+connection mqph;
select * from t1;
i
select * from t1;
i
select * from t1;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_queries_per_hour' resource (current value: 2)
+connect mqph2, localhost, mysqltest_1,,;
+connection mqph2;
select * from t1;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_queries_per_hour' resource (current value: 2)
+connection default;
drop user mysqltest_1@localhost;
+disconnect mqph;
+disconnect mqph2;
create user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2;
flush user_resources;
+connect muph, localhost, mysqltest_1,,;
+connection muph;
select * from t1;
i
select * from t1;
@@ -33,43 +42,69 @@ delete from t1;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_updates_per_hour' resource (current value: 2)
select * from t1;
i
+connect muph2, localhost, mysqltest_1,,;
+connection muph2;
delete from t1;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_updates_per_hour' resource (current value: 2)
select * from t1;
i
+connection default;
drop user mysqltest_1@localhost;
+disconnect muph;
+disconnect muph2;
create user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2;
flush user_resources;
+connect mcph1, localhost, mysqltest_1,,;
+connection mcph1;
select * from t1;
i
+connect mcph2, localhost, mysqltest_1,,;
+connection mcph2;
select * from t1;
i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect mcph3, localhost, mysqltest_1,,;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_connections_per_hour' resource (current value: 2)
select * from t1;
i
+disconnect mcph1;
+disconnect mcph2;
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect mcph3, localhost, mysqltest_1,,;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_connections_per_hour' resource (current value: 2)
+connection default;
drop user mysqltest_1@localhost;
flush privileges;
create user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 2;
flush user_resources;
+connect muc1, localhost, mysqltest_1,,;
+connection muc1;
select * from t1;
i
+connect muc2, localhost, mysqltest_1,,;
+connection muc2;
select * from t1;
i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect muc3, localhost, mysqltest_1,,;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: 2)
+disconnect muc1;
+connect muc3, localhost, mysqltest_1,,;
select * from t1;
i
+connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
+connect muc4, localhost, mysqltest_1,,;
+connection muc4;
select * from t1;
i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect muc5, localhost, mysqltest_1,,;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: 3)
+connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections -1;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
@@ -79,7 +114,11 @@ show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_USER_CONNECTIONS -1
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect muc5, localhost, mysqltest_1,,;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: -1)
+disconnect muc2;
+disconnect muc3;
+disconnect muc4;
drop user mysqltest_1@localhost;
select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
@@ -93,20 +132,33 @@ select @@session.max_user_connections, @@global.max_user_connections;
create user mysqltest_1@localhost;
grant usage on *.* to mysqltest_1@localhost;
flush user_resources;
+connect muca1, localhost, mysqltest_1,,;
+connection muca1;
select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
2 2
+connect muca2, localhost, mysqltest_1,,;
+connection muca2;
select * from t1;
i
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect muca3, localhost, mysqltest_1,,;
ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections
+connection default;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;
flush user_resources;
+connect muca3, localhost, mysqltest_1,,;
+connection muca3;
select @@session.max_user_connections, @@global.max_user_connections;
@@session.max_user_connections @@global.max_user_connections
3 2
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect muca4, localhost, mysqltest_1,,;
ERROR 42000: User 'mysqltest_1' has exceeded the 'max_user_connections' resource (current value: 3)
+connection default;
+disconnect muca1;
+disconnect muca2;
+disconnect muca3;
set global max_user_connections= 0;
grant usage on *.* to mysqltest_1@localhost with max_user_connections 0;
set global max_user_connections=-1;
@@ -119,10 +171,18 @@ select @@global.max_user_connections;
@@global.max_user_connections
-1
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect muca2, localhost, mysqltest_1,,;
ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections
+connect muca2, localhost, root,,;
+disconnect muca2;
+connection default;
set global max_user_connections=1;
+connect muca2, localhost, mysqltest_1,,;
connect(localhost,mysqltest_1,,test,MYSQL_PORT,MYSQL_SOCK);
+connect muca3, localhost, mysqltest_1,,;
ERROR 42000: User mysqltest_1 already has more than 'max_user_connections' active connections
+disconnect muca2;
+connection default;
drop user mysqltest_1@localhost;
drop table t1;
set global max_user_connections= @my_max_user_connections;
diff --git a/mysql-test/r/userstat-badlogin-4824.result b/mysql-test/r/userstat-badlogin-4824.result
index 8362e8d5239..6a38c2bd601 100644
--- a/mysql-test/r/userstat-badlogin-4824.result
+++ b/mysql-test/r/userstat-badlogin-4824.result
@@ -1,14 +1,19 @@
create user foo@localhost identified by 'foo';
flush user_statistics;
set global userstat=1;
+connect foo, localhost, foo, foo;
select 1;
1
1
+disconnect foo;
+connection default;
select user, bytes_received from information_schema.user_statistics where user = 'foo';
user bytes_received
foo 18
connect(localhost,foo,bar,test,MASTER_PORT,MASTER_SOCKET);
+connect foo, localhost, foo, bar;
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES)
+connection default;
select user, bytes_received from information_schema.user_statistics where user = 'foo';
user bytes_received
foo 18
diff --git a/mysql-test/r/userstat.result b/mysql-test/r/userstat.result
index 5ce10d96643..351f69f3031 100644
--- a/mysql-test/r/userstat.result
+++ b/mysql-test/r/userstat.result
@@ -80,9 +80,11 @@ delete from t1 where a=3;
select * from t1 where a=999;
a b
drop table t1;
+connect ssl_con,localhost,root,,,,,SSL;
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
+connection default;
create table t1 (a int, primary key (a), b int default 0) engine=innodb;
begin;
insert into t1 values(1,1);
@@ -132,6 +134,7 @@ Handler_write 7
select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key";
handler_read_key
9
+disconnect ssl_con;
set @@global.userstat=0;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
diff --git a/mysql-test/r/variables-notembedded.result b/mysql-test/r/variables-notembedded.result
index f8191345219..a8bf7ecc429 100644
--- a/mysql-test/r/variables-notembedded.result
+++ b/mysql-test/r/variables-notembedded.result
@@ -158,6 +158,7 @@ Warning 1708 The value of 'max_allowed_packet' should be no less than the value
SET GLOBAL net_buffer_length=4096;
Warnings:
Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
+CONNECT con1,localhost,root,,test;
SHOW SESSION VARIABLES LIKE 'max_allowed_packet';
Variable_name Value
max_allowed_packet 2048
@@ -165,6 +166,8 @@ SHOW SESSION VARIABLES LIKE 'net_buffer_length';
Variable_name Value
net_buffer_length 4096
Got one of the listed errors
+connection default;
+disconnect con1;
SELECT LENGTH(a) FROM t1;
LENGTH(a)
SET GLOBAL max_allowed_packet=default;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index fef3e4a3e9e..a38cf57189c 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -822,7 +822,8 @@ set @@global.lc_time_names=fr_FR;
select @@global.lc_time_names, @@lc_time_names;
@@global.lc_time_names @@lc_time_names
fr_FR en_US
-New connection
+connect con1,localhost,root,,;
+connection con1;
select @@global.lc_time_names, @@lc_time_names;
@@global.lc_time_names @@lc_time_names
fr_FR fr_FR
@@ -830,7 +831,8 @@ set @@lc_time_names=ru_RU;
select @@global.lc_time_names, @@lc_time_names;
@@global.lc_time_names @@lc_time_names
fr_FR ru_RU
-Returnung to default connection
+disconnect con1;
+connection default;
select @@global.lc_time_names, @@lc_time_names;
@@global.lc_time_names @@lc_time_names
fr_FR en_US
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 4a295762530..3fccd6e54c2 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2912,17 +2912,24 @@ set GLOBAL sql_mode="";
set LOCAL sql_mode="";
CREATE DATABASE bug21261DB;
USE bug21261DB;
+connect root,localhost,root,,bug21261DB;
+connection root;
CREATE TABLE t1 (x INT);
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
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;
INSERT INTO v1 (x) VALUES (5);
UPDATE v1 SET x=1;
+connection root;
GRANT SELECT ON v1 TO 'user21261'@'localhost';
GRANT SELECT ON t1 TO 'user21261'@'localhost';
+connection user21261;
UPDATE v1,t2 SET x=1 WHERE x=y;
+connection root;
SELECT * FROM t1;
x
1
@@ -2931,7 +2938,10 @@ DROP USER 'user21261'@'localhost';
DROP VIEW v1;
DROP TABLE t1;
DROP DATABASE bug21261DB;
+connection default;
USE test;
+disconnect root;
+disconnect user21261;
set GLOBAL sql_mode=default;
set LOCAL sql_mode=default;
create table t1 (f1 datetime);
@@ -4787,32 +4797,36 @@ DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1;
DROP VIEW IF EXISTS v1;
DROP PROCEDURE IF EXISTS p1;
-# Connection default
+connect con2, localhost, root;
+connect con3, localhost, root;
+connection default;
CREATE VIEW v1 AS SELECT schema_name FROM information_schema.schemata;
CREATE TABLE t1 (str VARCHAR(50));
CREATE PROCEDURE p1() INSERT INTO t1 SELECT * FROM v1;
# CALL p1() so the view is merged.
CALL p1();
-# Connection 3
+connection con3;
LOCK TABLE t1 READ;
-# Connection default
+connection default;
# Try to CALL p1() again, this time it should block for t1.
# Sending:
CALL p1();
-# Connection 2
+connection con2;
# ... then try to drop the view. This should block.
# Sending:
DROP VIEW v1;
-# Connection 3
+connection con3;
# Now allow CALL p1() to complete
UNLOCK TABLES;
-# Connection default
+connection default;
# Reaping: CALL p1()
-# Connection 2
+connection con2;
# Reaping: DROP VIEW v1
-# Connection default
+connection default;
DROP PROCEDURE p1;
DROP TABLE t1;
+disconnect con2;
+disconnect con3;
#
# Bug#12626844: WRONG ERROR MESSAGE WHILE CREATING A VIEW ON A
# NON EXISTING DATABASE
diff --git a/mysql-test/r/view_debug.result b/mysql-test/r/view_debug.result
index 0aab5c5ac33..cfb70b5e74c 100644
--- a/mysql-test/r/view_debug.result
+++ b/mysql-test/r/view_debug.result
@@ -5,14 +5,19 @@ CREATE PROCEDURE proc() SELECT * FROM v2;
CREATE ALGORITHM = UNDEFINED VIEW v1 AS SELECT 1;
CREATE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT 3 FROM v1;
DROP VIEW v1;
+connect con1,localhost,root,,test;
+connect con2,localhost,root,,test;
+connection con1;
CALL proc();
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
SET DEBUG_SYNC= 'after_cached_view_opened SIGNAL oppp WAIT_FOR created';
CALL proc();
+connection con2;
SET DEBUG_SYNC= 'now WAIT_FOR oppp';
SET DEBUG_SYNC= 'RESET';
CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT 2;
SET DEBUG_SYNC= 'now SIGNAL created';
+connection con1;
3
3
SET DEBUG_SYNC= 'RESET';
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index 525f9fbb5e1..948e88a1804 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -11,12 +11,16 @@ show grants for test@localhost;
Grants for test@localhost
GRANT USAGE ON *.* TO 'test'@'localhost'
drop user test@localhost;
+connect root,localhost,root,,test;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int);
create table mysqltest.t2 (a int, b int);
create user mysqltest_1@localhost;
grant select on mysqltest.t1 to mysqltest_1@localhost;
grant create view,select on test.* to mysqltest_1@localhost;
+connect user1,localhost,mysqltest_1,,test;
+connection user1;
create definer=root@localhost view v1 as select * from mysqltest.t1;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
create view v1 as select * from mysqltest.t1;
@@ -28,13 +32,16 @@ create view mysqltest.v2 as select * from mysqltest.t1;
ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2'
create view v2 as select * from mysqltest.t2;
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2'
+connection root;
show create view v1;
View Create View character_set_client collation_connection
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;
+connection user1;
use test;
alter view v1 as select * from mysqltest.t1;
create or replace view v1 as select * from mysqltest.t1;
+connection root;
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
revoke all privileges on test.* from mysqltest_1@localhost;
drop database mysqltest;
@@ -43,10 +50,12 @@ create database mysqltest;
create table mysqltest.t1 (a int, b int);
create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1;
grant select (c) on mysqltest.v1 to mysqltest_1@localhost;
+connection user1;
select c from mysqltest.v1;
c
select d from mysqltest.v1;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1'
+connection root;
revoke all privileges on mysqltest.v1 from mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
@@ -55,13 +64,16 @@ create table mysqltest.t1 (a int, b int);
create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1;
create user mysqltest_1@localhost;
grant select (c) on mysqltest.v1 to mysqltest_1@localhost;
+connection user1;
select c from mysqltest.v1;
c
select d from mysqltest.v1;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1'
+connection root;
revoke all privileges on mysqltest.v1 from mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int);
create table mysqltest.t2 (a int, b int);
@@ -76,6 +88,7 @@ grant select on mysqltest.v2 to mysqltest_1@localhost;
grant select on mysqltest.v3 to mysqltest_1@localhost;
grant select on mysqltest.v4 to mysqltest_1@localhost;
grant show view on mysqltest.v5 to mysqltest_1@localhost;
+connection user1;
select c from mysqltest.v1;
c
select c from mysqltest.v2;
@@ -114,7 +127,9 @@ explain select c from mysqltest.v5;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5'
show create view mysqltest.v5;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5'
+connection root;
grant select on mysqltest.v5 to mysqltest_1@localhost;
+connection user1;
show create view mysqltest.v5;
View Create View character_set_client collation_connection
v5 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v5` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` latin1 latin1_swedish_ci
@@ -122,9 +137,11 @@ explain select c from mysqltest.v1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
show create view mysqltest.v1;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
+connection root;
grant show view on mysqltest.v1 to mysqltest_1@localhost;
grant select on mysqltest.t1 to mysqltest_1@localhost;
revoke select on mysqltest.v5 from mysqltest_1@localhost;
+connection user1;
explain select c from mysqltest.v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
@@ -145,7 +162,9 @@ show create view mysqltest.v4;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4'
explain select c from mysqltest.v5;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v5'
+connection root;
grant show view on mysqltest.* to mysqltest_1@localhost;
+connection user1;
explain select c from mysqltest.v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
@@ -169,9 +188,11 @@ ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for unde
show create view mysqltest.v4;
View Create View character_set_client collation_connection
v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` latin1 latin1_swedish_ci
+connection root;
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int, primary key(a));
insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10);
@@ -184,6 +205,7 @@ create user mysqltest_1@localhost;
grant update (a) on mysqltest.v2 to mysqltest_1@localhost;
grant update on mysqltest.v1 to mysqltest_1@localhost;
grant select on mysqltest.* to mysqltest_1@localhost;
+connection user1;
use mysqltest;
update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c;
select * from t1;
@@ -226,9 +248,11 @@ ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table '
update v3 set a=a+c;
ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3'
use test;
+connection root;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int, primary key(a));
insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10);
@@ -239,6 +263,7 @@ create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1;
create user mysqltest_1@localhost;
grant delete on mysqltest.v1 to mysqltest_1@localhost;
grant select on mysqltest.* to mysqltest_1@localhost;
+connection user1;
use mysqltest;
delete from v1 where c < 4;
select * from t1;
@@ -256,9 +281,11 @@ ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table '
delete from v2 where c < 4;
ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2'
use test;
+connection root;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int, primary key(a));
insert into mysqltest.t1 values (1,2), (2,3);
@@ -269,6 +296,7 @@ create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1;
create user mysqltest_1@localhost;
grant insert on mysqltest.v1 to mysqltest_1@localhost;
grant select on mysqltest.* to mysqltest_1@localhost;
+connection user1;
use mysqltest;
insert into v1 values (5,6);
select * from t1;
@@ -288,9 +316,11 @@ ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table '
insert into v2 select x,y from t2;
ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2'
use test;
+connection root;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int);
create table mysqltest.t2 (a int, b int);
@@ -298,46 +328,62 @@ create user mysqltest_1@localhost;
grant update on mysqltest.t1 to mysqltest_1@localhost;
grant update(b) on mysqltest.t2 to mysqltest_1@localhost;
grant create view,update on test.* to mysqltest_1@localhost;
+connection user1;
create view v1 as select * from mysqltest.t1;
create view v2 as select b from mysqltest.t2;
create view mysqltest.v1 as select * from mysqltest.t1;
ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
create view v3 as select a from mysqltest.t2;
ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't2'
+connection root;
create table mysqltest.v3 (b int);
grant create view on mysqltest.v3 to mysqltest_1@localhost;
drop table mysqltest.v3;
+connection user1;
create view mysqltest.v3 as select b from mysqltest.t2;
+connection root;
grant create view, update on mysqltest.v3 to mysqltest_1@localhost;
drop view mysqltest.v3;
+connection user1;
create view mysqltest.v3 as select b from mysqltest.t2;
create view v4 as select b+1 from mysqltest.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
+connection root;
grant create view,update,select on test.* to mysqltest_1@localhost;
+connection user1;
create view v4 as select b+1 from mysqltest.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
+connection root;
grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost;
+connection user1;
create view v4 as select b+1 from mysqltest.t2;
+connection root;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
drop view v1,v2,v4;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int);
create user mysqltest_1@localhost;
grant all privileges on mysqltest.* to mysqltest_1@localhost;
+connection user1;
use mysqltest;
create view v1 as select * from t1;
use test;
+connection root;
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
create table mysqltest.t1 (a int, b int);
create user mysqltest_1@localhost;
grant select on mysqltest.t1 to mysqltest_1@localhost;
grant create view,select on test.* to mysqltest_1@localhost;
+connection user1;
create view v1 as select * from mysqltest.t1;
+connection root;
show create view v1;
View Create View character_set_client collation_connection
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
@@ -351,6 +397,7 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop view v1;
drop database mysqltest;
+connection root;
create database mysqltest;
use mysqltest;
create table t1 (a int);
@@ -370,6 +417,7 @@ grant select on v2 to mysqltest_1@localhost;
grant select on v3 to mysqltest_1@localhost;
grant select on v4 to mysqltest_1@localhost;
grant select on v5 to mysqltest_1@localhost;
+connection user1;
use mysqltest;
select * from v1;
f2()
@@ -384,6 +432,7 @@ ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or fun
select * from v5;
ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
use test;
+connection root;
drop view v1, v2, v3, v4, v5;
drop function f2;
drop table t1, t2;
@@ -391,6 +440,7 @@ use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
use mysqltest;
create table t1 (a int);
@@ -403,12 +453,14 @@ create user mysqltest_1@localhost;
grant select on t1 to mysqltest_1@localhost;
grant execute on function f2 to mysqltest_1@localhost;
grant create view on mysqltest.* to mysqltest_1@localhost;
+connection user1;
use mysqltest;
create algorithm=TEMPTABLE view v1 as select f2() from t1;
create algorithm=MERGE view v2 as select f2() from t1;
create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1;
create algorithm=MERGE SQL SECURITY INVOKER view v4 as select f2() from t1;
use test;
+connection root;
create view v5 as select * from v1;
revoke execute on function f2 from mysqltest_1@localhost;
select * from v1;
@@ -430,6 +482,7 @@ use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
use mysqltest;
create table t1 (a int);
@@ -440,6 +493,7 @@ grant select on t1 to mysqltest_1@localhost;
grant select on v1 to mysqltest_1@localhost;
grant create view on mysqltest.* to mysqltest_1@localhost;
drop table v1;
+connection user1;
use mysqltest;
create algorithm=TEMPTABLE view v1 as select *, a as b from t1;
create algorithm=MERGE view v2 as select *, a as b from t1;
@@ -447,6 +501,7 @@ create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select *, a as b from
create algorithm=MERGE SQL SECURITY INVOKER view v4 as select *, a as b from t1;
create view v5 as select * from v1;
use test;
+connection root;
revoke select on t1 from mysqltest_1@localhost;
select * from v1;
ERROR HY000: View 'mysqltest.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
@@ -465,6 +520,7 @@ use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
drop user mysqltest_1@localhost;
drop database mysqltest;
+connection root;
create database mysqltest;
use mysqltest;
create table t1 (a int);
@@ -480,6 +536,7 @@ grant select on v2 to mysqltest_1@localhost;
grant select on v3 to mysqltest_1@localhost;
grant select on v4 to mysqltest_1@localhost;
grant select on v5 to mysqltest_1@localhost;
+connection user1;
use mysqltest;
select * from v1;
a b
@@ -494,6 +551,7 @@ ERROR HY000: View 'mysqltest.v4' references invalid table(s) or column(s) or fun
select * from v5;
ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
use test;
+connection root;
drop view v1, v2, v3, v4, v5;
drop table t1;
use test;
@@ -507,6 +565,8 @@ delete from mysql.user where user='';
flush privileges;
create user 'test14256'@'%';
grant all on test.* to 'test14256'@'%';
+connect test14256,localhost,test14256,,test;
+connection test14256;
use test;
create view v1 as select 42;
show create view v1;
@@ -525,10 +585,13 @@ drop view v1;
select @v1def1, @v1def2, @v1def1=@v1def2;
@v1def1 @v1def2 @v1def1=@v1def2
test14256@% test14256@% 1
+connection root;
+disconnect test14256;
drop user test14256;
insert into mysql.user select * from t1;
flush privileges;
drop table t1;
+connection root;
create database mysqltest;
use mysqltest;
CREATE TABLE t1 (i INT);
@@ -538,15 +601,20 @@ View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
create user mysqltest_1@localhost;
GRANT SELECT, LOCK TABLES ON mysqltest.* TO mysqltest_1@localhost;
+connection user1;
use mysqltest;
LOCK TABLES v1 READ;
SHOW CREATE TABLE v1;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
UNLOCK TABLES;
use test;
+connection root;
use test;
drop user mysqltest_1@localhost;
drop database mysqltest;
+disconnect user1;
+disconnect root;
+connection default;
create definer=some_user@`` sql security invoker view v1 as select 1;
Warnings:
Note 1449 The user specified as a definer ('some_user'@'%') does not exist
@@ -579,6 +647,8 @@ GRANT UPDATE ON mysqltest1.v_tu TO readonly@localhost;
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;
SELECT * FROM mysqltest1.v_t1;
ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
INSERT INTO mysqltest1.v_t1 VALUES(4);
@@ -621,6 +691,8 @@ DELETE FROM mysqltest1.v_td WHERE x= 200;
ERROR 42000: SELECT command denied to user 'readonly'@'localhost' for column 'x' in table 'v_td'
DELETE FROM mysqltest1.v_tds WHERE x= 200;
DELETE FROM mysqltest1.v_td;
+connection default;
+disconnect n1;
DROP VIEW mysqltest1.v_tds;
DROP VIEW mysqltest1.v_td;
DROP VIEW mysqltest1.v_tus;
@@ -648,6 +720,7 @@ DROP TABLE t1;
USE test;
CREATE USER mysqltest_db1@localhost identified by 'PWD';
GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION;
+connect session1,localhost,mysqltest_db1,PWD,test;
CREATE SCHEMA mysqltest_db1 ;
USE mysqltest_db1 ;
CREATE TABLE t1 (f1 INTEGER);
@@ -669,6 +742,8 @@ CREATE VIEW view3 AS
SELECT * FROM view2;
SELECT * from view3;
f1
+connection default;
+disconnect session1;
DROP VIEW mysqltest_db1.view3;
DROP VIEW mysqltest_db1.view2;
DROP VIEW mysqltest_db1.view1;
@@ -708,6 +783,7 @@ END|
CREATE SQL SECURITY DEFINER VIEW v3 AS SELECT f2() AS cu;
CREATE USER mysqltest_u1@localhost;
GRANT ALL ON test.* TO mysqltest_u1@localhost;
+connect conn1, localhost, mysqltest_u1,,;
The following tests should all return 1.
@@ -733,6 +809,8 @@ cu = 'root@localhost'
SELECT cu = 'root@localhost' FROM v3;
cu = 'root@localhost'
1
+disconnect conn1;
+connection default;
DROP VIEW v3;
DROP FUNCTION f2;
DROP PROCEDURE p1;
@@ -740,6 +818,8 @@ DROP FUNCTION f1;
DROP VIEW v2;
DROP VIEW v1;
DROP USER mysqltest_u1@localhost;
+connect root,localhost,root,,;
+connection root;
CREATE DATABASE db17254;
USE db17254;
CREATE TABLE t1 (f1 INT);
@@ -749,16 +829,24 @@ GRANT SELECT ON db17254.* TO def_17254@localhost;
CREATE USER inv_17254@localhost;
GRANT SELECT ON db17254.t1 TO inv_17254@localhost;
GRANT CREATE VIEW ON db17254.* TO def_17254@localhost;
+connect def,localhost,def_17254,,db17254;
+connection def;
CREATE VIEW v1 AS SELECT * FROM t1;
+connection root;
DROP USER def_17254@localhost;
+connect inv,localhost,inv_17254,,db17254;
+connection inv;
for a user
SELECT * FROM v1;
ERROR 42000: SELECT command denied to user 'inv_17254'@'localhost' for table 'v1'
+connection root;
for a superuser
SELECT * FROM v1;
ERROR HY000: The user specified as a definer ('def_17254'@'localhost') does not exist
DROP USER inv_17254@localhost;
DROP DATABASE db17254;
+disconnect def;
+disconnect inv;
DROP DATABASE IF EXISTS mysqltest_db1;
DROP DATABASE IF EXISTS mysqltest_db2;
DROP USER mysqltest_u1;
@@ -769,6 +857,7 @@ CREATE DATABASE mysqltest_db1;
CREATE DATABASE mysqltest_db2;
GRANT ALL ON mysqltest_db1.* TO mysqltest_u1@localhost WITH GRANT OPTION;
GRANT ALL ON mysqltest_db2.* TO mysqltest_u2@localhost;
+connect conn1, localhost, mysqltest_u1, , mysqltest_db1;
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (1);
CREATE VIEW v1 AS SELECT i FROM t1 WHERE 1 IN (SELECT * FROM t1);
@@ -776,6 +865,7 @@ CREATE TABLE t2 (s CHAR(7));
INSERT INTO t2 VALUES ('public');
GRANT SELECT ON v1 TO mysqltest_u2@localhost;
GRANT SELECT ON t2 TO mysqltest_u2@localhost;
+connect conn2, localhost, mysqltest_u2, , mysqltest_db2;
SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2;
i s
1 public
@@ -787,20 +877,26 @@ PREPARE stmt2 FROM "SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2";
EXECUTE stmt2;
i s
1 public
+connection conn1;
REVOKE SELECT ON t2 FROM mysqltest_u2@localhost;
UPDATE t2 SET s = 'private' WHERE s = 'public';
+connection conn2;
SELECT * FROM mysqltest_db1.v1, mysqltest_db1.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2'
EXECUTE stmt1;
ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2'
EXECUTE stmt2;
ERROR 42000: SELECT command denied to user 'mysqltest_u2'@'localhost' for table 't2'
+disconnect conn2;
+disconnect conn1;
+connection default;
REVOKE ALL ON mysqltest_db1.* FROM mysqltest_u1@localhost;
REVOKE ALL ON mysqltest_db2.* FROM mysqltest_u2@localhost;
DROP DATABASE mysqltest_db1;
DROP DATABASE mysqltest_db2;
DROP USER mysqltest_u1@localhost;
DROP USER mysqltest_u2@localhost;
+connection root;
CREATE DATABASE db26813;
USE db26813;
CREATE TABLE t1(f1 INT, f2 INT);
@@ -812,20 +908,25 @@ GRANT DROP ON db26813.v1 TO u26813@localhost;
GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost;
GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost;
GRANT SELECT ON db26813.t1 TO u26813@localhost;
+connect u1,localhost,u26813,,db26813;
+connection u1;
ALTER VIEW v1 AS SELECT f2 FROM t1;
ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1'
ALTER VIEW v2 AS SELECT f2 FROM t1;
ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2'
ALTER VIEW v3 AS SELECT f2 FROM t1;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
+connection root;
SHOW CREATE VIEW v3;
View Create View character_set_client collation_connection
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
DROP USER u26813@localhost;
DROP DATABASE db26813;
+disconnect u1;
#
# Bug#29908 A user can gain additional access through the ALTER VIEW.
#
+connection root;
CREATE DATABASE mysqltest_29908;
USE mysqltest_29908;
CREATE TABLE t1(f1 INT, f2 INT);
@@ -840,6 +941,7 @@ CREATE USER u29908_2@localhost;
GRANT SELECT, DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost;
GRANT SELECT, DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost;
GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost;
+connect u2,localhost,u29908_2,,mysqltest_29908;
ALTER VIEW v1 AS SELECT f2 FROM t1;
ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
ALTER VIEW v2 AS SELECT f2 FROM t1;
@@ -847,6 +949,7 @@ ERROR 42000: Access denied; you need (at least one of) the SUPER privilege(s) fo
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci
+connect u1,localhost,u29908_1,,mysqltest_29908;
ALTER VIEW v1 AS SELECT f2 FROM t1;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -855,6 +958,7 @@ ALTER VIEW v2 AS SELECT f2 FROM t1;
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci
+connection root;
ALTER VIEW v1 AS SELECT f1 FROM t1;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
@@ -866,6 +970,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKE
DROP USER u29908_1@localhost;
DROP USER u29908_2@localhost;
DROP DATABASE mysqltest_29908;
+disconnect u1;
+disconnect u2;
#######################################################################
DROP DATABASE IF EXISTS mysqltest1;
DROP DATABASE IF EXISTS mysqltest2;
@@ -885,8 +991,7 @@ GRANT INSERT ON mysqltest1.t2 TO mysqltest_u1@localhost;
GRANT SELECT, UPDATE ON mysqltest1.t3 TO mysqltest_u1@localhost;
GRANT SELECT, DELETE ON mysqltest1.t4 TO mysqltest_u1@localhost;
GRANT ALL PRIVILEGES ON mysqltest2.* TO mysqltest_u1@localhost;
-
----> connection: bug24040_con
+connect bug24040_con,localhost,mysqltest_u1,,mysqltest2;
SELECT * FROM mysqltest1.t1;
c1
11
@@ -927,8 +1032,7 @@ CREATE VIEW v41 AS SELECT c4, c1 FROM mysqltest1.t4, mysqltest1.t1;
CREATE VIEW v42 AS SELECT c4, c2 FROM mysqltest1.t4, mysqltest1.t2;
ERROR 42000: create view command denied to user 'mysqltest_u1'@'localhost' for column 'c2' in table 'v42'
CREATE VIEW v43 AS SELECT c4, c3 FROM mysqltest1.t4, mysqltest1.t3;
-
----> connection: default
+connection default;
SELECT * FROM mysqltest1.t1;
c1
11
@@ -953,6 +1057,7 @@ SELECT * FROM mysqltest1.t4;
c4
41
42
+disconnect bug24040_con;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
DROP USER mysqltest_u1@localhost;
@@ -963,6 +1068,8 @@ CREATE VIEW v1 AS SELECT f1, f2 FROM t1;
CREATE USER foo;
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;
f1
@@ -976,6 +1083,9 @@ 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'
+connection default;
+disconnect root;
+disconnect addconfoo;
USE test;
REVOKE SELECT (f1) ON db1.t1 FROM foo;
REVOKE SELECT (f1) ON db1.v1 FROM foo;
@@ -983,8 +1093,11 @@ DROP USER foo;
DROP VIEW db1.v1;
DROP TABLE db1.t1;
DROP DATABASE db1;
+connection default;
Bug #11765687/#58677:
No privilege on table/view, but can know #rows / underlying table's name
+connect root,localhost,root,,test;
+connection root;
create database mysqltest1;
create table mysqltest1.t1 (i int);
create table mysqltest1.t2 (j int);
@@ -1008,6 +1121,8 @@ create user pjotr@localhost;
create user quintessa@localhost;
grant all privileges on mysqltest1.* to alice@localhost with grant option;
... as alice
+connect test11765687,localhost,alice,,mysqltest1;
+connection test11765687;
create view v1 as select * from t1;
create view v2 as select * from v1, t2;
create view v3 as select k from t3;
@@ -1051,28 +1166,43 @@ grant select on mysqltest1.t1 to pjotr@localhost;
grant select on mysqltest1.t2 to pjotr@localhost;
grant select, show view on mysqltest1.v2 to pjotr@localhost;
grant select, show view on mysqltest1.v1 to quintessa@localhost;
+disconnect test11765687;
... as bob
+connect test11765687,localhost,bob,,mysqltest1;
+connection test11765687;
select * from v1;
i
explain select * from v1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as cecil
+connect test11765687,localhost,cecil,,mysqltest1;
+connection test11765687;
select * from v1;
ERROR 42000: SELECT command denied to user 'cecil'@'localhost' for table 'v1'
explain select * from v1;
ERROR 42000: SELECT command denied to user 'cecil'@'localhost' for table 'v1'
+disconnect test11765687;
... as dan
+connect test11765687,localhost,dan,,mysqltest1;
+connection test11765687;
select * from v1;
i
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
+disconnect test11765687;
... as eugene
+connect test11765687,localhost,eugene,,mysqltest1;
+connection test11765687;
select * from v1;
i
explain select * from v1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as fiona
+connect test11765687,localhost,fiona,,mysqltest1;
+connection test11765687;
select * from v2;
i j
show create view v2;
@@ -1086,14 +1216,20 @@ explain select * from t2;
ERROR 42000: SELECT command denied to user 'fiona'@'localhost' for table 't2'
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as greg
+connect test11765687,localhost,greg,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v1;
ERROR 42000: SELECT command denied to user 'greg'@'localhost' for table 'v1'
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as han
+connect test11765687,localhost,han,,mysqltest1;
+connection test11765687;
select * from t3;
ERROR 42000: SELECT command denied to user 'han'@'localhost' for table 't3'
explain select * from t3;
@@ -1108,54 +1244,83 @@ k
explain select * from v3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 system NULL NULL NULL NULL 0 const row not found
+disconnect test11765687;
... as inga
+connect test11765687,localhost,inga,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as jamie
+connect test11765687,localhost,jamie,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as karl
+connect test11765687,localhost,karl,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as lena
+connect test11765687,localhost,lena,,mysqltest1;
+connection test11765687;
select * from v2;
ERROR 42000: SELECT command denied to user 'lena'@'localhost' for table 'v2'
explain select * from v2;
ERROR 42000: SELECT command denied to user 'lena'@'localhost' for table 'v2'
+disconnect test11765687;
... as mhairi
+connect test11765687,localhost,mhairi,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
1 SIMPLE t2 system NULL NULL NULL NULL 0 const row not found
+disconnect test11765687;
... as noam
+connect test11765687,localhost,noam,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as olga
+connect test11765687,localhost,olga,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as pjotr
+connect test11765687,localhost,pjotr,,mysqltest1;
+connection test11765687;
select * from v2;
i j
explain select * from v2;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as quintessa
+connect test11765687,localhost,quintessa,,mysqltest1;
+connection test11765687;
select * from v1;
i
explain select * from v1;
ERROR HY000: ANALYZE/EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+disconnect test11765687;
... as root again at last: clean-up time!
+connection root;
drop user alice@localhost;
drop user bob@localhost;
drop user cecil@localhost;
@@ -1174,9 +1339,12 @@ drop user olga@localhost;
drop user pjotr@localhost;
drop user quintessa@localhost;
drop database mysqltest1;
+disconnect root;
+connection default;
select * from information_schema.table_privileges;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
End of 5.0 tests.
+connection default;
DROP VIEW IF EXISTS v1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT);
@@ -1221,12 +1389,15 @@ 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;
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'
+disconnect connection1;
+connection default;
DROP TABLE t1, t2;
DROP VIEW v1;
DROP DATABASE mysqltest1;
@@ -1241,10 +1412,13 @@ CREATE TABLE t2 ( a INT, b INT );
CREATE VIEW v1 AS SELECT a, b FROM t1;
GRANT SELECT( a ) ON v1 TO mysqluser1@localhost;
GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost;
+connect connection1, localhost, mysqluser1, , test;
SELECT * FROM mysqltest1.v1;
ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
CREATE VIEW v1 AS SELECT * FROM mysqltest1.t2;
ERROR 42000: ANY command denied to user 'mysqluser1'@'localhost' for table 't2'
+disconnect connection1;
+connection default;
DROP TABLE t1, t2;
DROP VIEW v1;
DROP DATABASE mysqltest1;
@@ -1255,19 +1429,27 @@ USE mysqltest1;
CREATE VIEW v1 AS SELECT * FROM information_schema.tables LIMIT 1;
CREATE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT 1 AS A;
CREATE VIEW test.v3 AS SELECT 1 AS a;
+connection default;
GRANT SELECT ON mysqltest1.* to mysqluser1@localhost;
GRANT ALL ON test.* TO mysqluser1@localhost;
+connect connection1, localhost, mysqluser1, , test;
PREPARE stmt_v1 FROM "SELECT * FROM mysqltest1.v1";
PREPARE stmt_v2 FROM "SELECT * FROM mysqltest1.v2";
+connection default;
REVOKE SELECT ON mysqltest1.* FROM mysqluser1@localhost;
+connection connection1;
EXECUTE stmt_v1;
ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
EXECUTE stmt_v2;
ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v2'
+disconnect connection1;
+connect connection2, localhost, mysqluser1,,;
PREPARE stmt FROM "SELECT a FROM v3";
EXECUTE stmt;
a
1
+disconnect connection2;
+connection default;
DROP VIEW v1, v2;
DROP DATABASE mysqltest1;
DROP VIEW test.v3;
@@ -1303,6 +1485,7 @@ GRANT SELECT, SHOW VIEW ON v_t2 TO mysqluser1@localhost;
GRANT SELECT, SHOW VIEW ON v_f1 TO mysqluser1@localhost;
GRANT SELECT, SHOW VIEW ON v_v1 TO mysqluser1@localhost;
GRANT SELECT, SHOW VIEW ON v_v2 TO mysqluser1@localhost;
+connect connection1, localhost, mysqluser1,, mysqltest2;
CREATE VIEW v_mysqluser1_t1 AS SELECT * FROM mysqltest1.t1;
CREATE VIEW v_mysqluser1_t2 AS SELECT * FROM mysqltest1.t2;
CREATE VIEW v_mysqluser1_f1 AS SELECT mysqltest1.f1() AS a;
@@ -1338,10 +1521,12 @@ v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL
SHOW CREATE VIEW v_mysqluser1_v2;
View Create View character_set_client collation_connection
v_mysqluser1_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v2` AS select `v2`.`a` AS `a`,`v2`.`b` AS `b` from `mysqltest1`.`v2` latin1 latin1_swedish_ci
+connection default;
REVOKE SELECT ON TABLE t1 FROM mysqluser1@localhost;
REVOKE SELECT (a) ON TABLE t2 FROM mysqluser1@localhost;
REVOKE EXECUTE ON FUNCTION f1 FROM mysqluser1@localhost;
REVOKE SELECT ON TABLE v1 FROM mysqluser1@localhost;
+connection connection1;
SHOW CREATE VIEW mysqltest1.v_t1;
View Create View character_set_client collation_connection
v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` latin1 latin1_swedish_ci
@@ -1372,12 +1557,14 @@ v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL
SHOW CREATE VIEW v_mysqluser1_v2;
View Create View character_set_client collation_connection
v_mysqluser1_v2 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v2` AS select `v2`.`a` AS `a`,`v2`.`b` AS `b` from `mysqltest1`.`v2` latin1 latin1_swedish_ci
+connection default;
# Testing the case when the views reference missing objects.
# Obviously, there are no privileges to check for, so we
# need only each object type once.
DROP TABLE t1;
DROP FUNCTION f1;
DROP VIEW v1;
+connection connection1;
SHOW CREATE VIEW mysqltest1.v_t1;
View Create View character_set_client collation_connection
v_t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest1`.`v_t1` AS select `mysqltest1`.`t1`.`a` AS `a` from `mysqltest1`.`t1` latin1 latin1_swedish_ci
@@ -1408,9 +1595,11 @@ View Create View character_set_client collation_connection
v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `v1`.`a` AS `a` from `mysqltest1`.`v1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'mysqltest2.v_mysqluser1_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+connection default;
REVOKE SHOW VIEW ON v_t1 FROM mysqluser1@localhost;
REVOKE SHOW VIEW ON v_f1 FROM mysqluser1@localhost;
REVOKE SHOW VIEW ON v_v1 FROM mysqluser1@localhost;
+connection connection1;
SHOW CREATE VIEW mysqltest1.v_t1;
ERROR 42000: SHOW VIEW command denied to user 'mysqluser1'@'localhost' for table 'v_t1'
SHOW CREATE VIEW mysqltest1.v_f1;
@@ -1432,6 +1621,8 @@ View Create View character_set_client collation_connection
v_mysqluser1_v1 CREATE ALGORITHM=UNDEFINED DEFINER=`mysqluser1`@`localhost` SQL SECURITY DEFINER VIEW `v_mysqluser1_v1` AS select `v1`.`a` AS `a` from `mysqltest1`.`v1` latin1 latin1_swedish_ci
Warnings:
Warning 1356 View 'mysqltest2.v_mysqluser1_v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+disconnect connection1;
+connection default;
DROP USER mysqluser1@localhost;
DROP DATABASE mysqltest1;
DROP DATABASE mysqltest2;
@@ -1460,10 +1651,13 @@ CREATE USER mysqluser1;
GRANT SELECT ON TABLE t1 TO mysqluser1;
GRANT SELECT, SHOW VIEW ON TABLE v1 TO mysqluser1;
GRANT SELECT, SHOW VIEW ON TABLE v2 TO mysqluser1;
+connect mysqluser1, localhost, mysqluser1,,mysqltest1;
SELECT a FROM v1;
a
SELECT a FROM v2;
a
+connection default;
+disconnect mysqluser1;
DROP USER mysqluser1;
DROP DATABASE mysqltest1;
USE test;
@@ -1502,12 +1696,10 @@ GRANT SELECT ON t1 TO 'mysqluser1'@'%';
GRANT SELECT ON t2 TO 'mysqluser1'@'%';
GRANT SELECT ON v1_uses_t1 TO 'mysqluser1'@'%';
GRANT SELECT ON v1_uses_t2 TO 'mysqluser1'@'%';
-#
-# Connection 'mysqluser1'.
+connect mysqluser1, localhost, mysqluser1,,mysqltest1;
CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1;
CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2;
-#
-# Connection 'default'.
+connection default;
CREATE USER 'mysqluser2'@'%';
GRANT SELECT ON v2_uses_t1 TO 'mysqluser2'@'%';
GRANT SELECT ON v2_uses_t2 TO 'mysqluser2'@'%';
@@ -1515,8 +1707,7 @@ GRANT SELECT ON t2 TO 'mysqluser2'@'%';
GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser2'@'%';
# Make 'mysqluser1' unable to access t2.
REVOKE SELECT ON t2 FROM 'mysqluser1'@'%';
-#
-# Connection 'mysqluser2'.
+connect mysqluser2, localhost, mysqluser2,,mysqltest1;
# The below statement should succeed thanks to suid nature of v2_uses_t1.
SELECT * FROM v2_uses_t1;
i
@@ -1526,8 +1717,7 @@ SELECT * FROM v2_uses_t2;
ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
#
# 2) INVOKER-security view uses INVOKER-security view.
-#
-# Connection 'default'.
+connection default;
DROP VIEW v2_uses_t1, v2_uses_t2;
CREATE SQL SECURITY INVOKER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1;
CREATE SQL SECURITY INVOKER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2;
@@ -1535,16 +1725,14 @@ GRANT SELECT ON v2_uses_t1 TO 'mysqluser1'@'%';
GRANT SELECT ON v2_uses_t2 TO 'mysqluser1'@'%';
GRANT SELECT ON v1_uses_t1 TO 'mysqluser2'@'%';
GRANT SELECT ON v1_uses_t2 TO 'mysqluser2'@'%';
-#
-# Connection 'mysqluser1'.
+connection mysqluser1;
# For both versions of 'v2' 'mysqluser1' privileges should be used.
SELECT * FROM v2_uses_t1;
i
1
SELECT * FROM v2_uses_t2;
ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-#
-# Connection 'mysqluser2'.
+connection mysqluser2;
# And now for both versions of 'v2' 'mysqluser2' privileges should
# be used.
SELECT * FROM v2_uses_t1;
@@ -1554,21 +1742,17 @@ j
2
#
# 3) INVOKER-security view uses DEFINER-security view.
-#
-# Connection 'default'.
+connection default;
DROP VIEW v1_uses_t1, v1_uses_t2;
# To be able create 'v1_uses_t2' we also need select on t2.
GRANT SELECT ON t2 TO 'mysqluser1'@'%';
-#
-# Connection 'mysqluser1'.
+connection mysqluser1;
CREATE SQL SECURITY DEFINER VIEW v1_uses_t1 AS SELECT * FROM t1;
CREATE SQL SECURITY DEFINER VIEW v1_uses_t2 AS SELECT * FROM t2;
-#
-# Connection 'default'.
+connection default;
# Make 'mysqluser1' unable to access t2.
REVOKE SELECT ON t2 FROM 'mysqluser1'@'%';
-#
-# Connection 'mysqluser2'.
+connection mysqluser2;
# Due to suid nature of v1_uses_t1 and v1_uses_t2 the first
# select should succeed and the second select should fail.
SELECT * FROM v2_uses_t1;
@@ -1578,27 +1762,26 @@ SELECT * FROM v2_uses_t2;
ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
#
# 4) DEFINER-security view uses DEFINER-security view.
-#
-# Connection 'default'.
+connection default;
DROP VIEW v2_uses_t1, v2_uses_t2;
# To be able create 'v2_uses_t2' we also need select on t2.
GRANT SELECT ON t2 TO 'mysqluser1'@'%';
-#
-# Connection 'mysqluser2'.
+connection mysqluser2;
CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1;
CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2;
-#
-# Connection 'default'.
+connection default;
# Make 'mysqluser1' unable to access t2.
REVOKE SELECT ON t2 FROM 'mysqluser1'@'%';
-#
-# Connection 'mysqluser2'.
+connection mysqluser2;
# Again privileges of creator of innermost views should apply.
SELECT * FROM v2_uses_t1;
i
1
SELECT * FROM v2_uses_t2;
ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+disconnect mysqluser1;
+disconnect mysqluser2;
+connection default;
USE test;
DROP DATABASE mysqltest1;
DROP USER 'mysqluser1'@'%';
@@ -1656,8 +1839,7 @@ where t2.id = v1.id;
create sql security invoker view v42 as
select v2.id as id, v2.val as val from mysqltest2.t2 as t2, mysqltest2.v2_merge as v2
where t2.id = v2.id;
-#
-# Connect as user_11766767
+connect conn_11766767, localhost, user_11766767,,;
#
# A) Check how we handle privilege checking in multi-update for
# directly used views.
@@ -1748,7 +1930,8 @@ update mysqltest1.t11 as t11, mysqltest2.v42 as v4 set v4.val= 'test20'
#
# Clean-up.
#
-# Switching to connection 'default'.
+disconnect conn_11766767;
+connection default;
drop user user_11766767;
drop database mysqltest1;
drop database mysqltest2;
diff --git a/mysql-test/r/wait_timeout.result b/mysql-test/r/wait_timeout.result
index adb7d6bafd9..aa145ecf39b 100644
--- a/mysql-test/r/wait_timeout.result
+++ b/mysql-test/r/wait_timeout.result
@@ -1,6 +1,8 @@
SET @@global.wait_timeout= 2;
disconnect default;
+connect wait_con,localhost,root,,test,,;
connection wait_con;
+connect default,localhost,root,,test,,;
connection default;
--disable_reconnect;
SELECT 1;
@@ -14,14 +16,15 @@ Got one of the listed errors
SELECT 3;
3
3
-disconnection default;
+disconnect default;
connection wait_con;
-connection con1;
+connect con1,127.0.0.1,root,,test,$MASTER_MYPORT,;
--disable_reconnect;
SELECT 1;
1
1
connection wait_con;
+disconnect wait_con;
connection con1;
SELECT 2;
Got one of the listed errors
@@ -30,4 +33,5 @@ SELECT 3;
3
3
SET @@global.wait_timeout= <start_value>;
-disconnection con1;
+disconnect con1;
+connect default,localhost,root,,test,,;
diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result
index 6c242d950ab..de1d507bd4b 100644
--- a/mysql-test/r/xa.result
+++ b/mysql-test/r/xa.result
@@ -28,6 +28,8 @@ begin;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
create table t2 (a int);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
+connect con1,localhost,root,,;
+connection con1;
xa start 'testa','testb';
ERROR XAE08: XAER_DUPID: The XID already exists
xa start 'testa','testb', 123;
@@ -41,6 +43,7 @@ ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction
xa recover;
formatID gtrid_length bqual_length data
11 5 5 testb 0@P`
+connection default;
xa prepare 'testa','testb';
xa recover;
formatID gtrid_length bqual_length data
@@ -54,16 +57,24 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
select * from t1;
a
20
+disconnect con1;
+connection default;
drop table t1;
drop table if exists t1;
create table t1(a int, b int, c varchar(20), primary key(a)) engine = innodb;
insert into t1 values(1, 1, 'a');
insert into t1 values(2, 2, 'b');
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
xa start 'a','b';
update t1 set c = 'aa' where a = 1;
+connection con2;
xa start 'a','c';
update t1 set c = 'bb' where a = 2;
+connection con1;
update t1 set c = 'bb' where a = 2;
+connection con2;
update t1 set c = 'aa' where a = 1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
select count(*) from t1;
@@ -72,7 +83,13 @@ count(*)
xa end 'a','c';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
xa rollback 'a','c';
+disconnect con2;
+connect con3,localhost,root,,;
+connection con3;
xa start 'a','c';
+disconnect con1;
+disconnect con3;
+connection default;
drop table t1;
#
# BUG#51342 - more xid crashing
@@ -108,20 +125,28 @@ xa prepare 'a';
xa commit 'a';
CREATE TABLE t1(a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1),(2);
+connect con1,localhost,root,,;
BEGIN;
UPDATE t1 SET a=3 WHERE a=1;
+connection default;
BEGIN;
UPDATE t1 SET a=4 WHERE a=2;
+connection con1;
UPDATE t1 SET a=5 WHERE a=2;
+connection default;
UPDATE t1 SET a=5 WHERE a=1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
ROLLBACK;
+connection con1;
ROLLBACK;
BEGIN;
UPDATE t1 SET a=3 WHERE a=1;
+connection default;
XA START 'xid1';
UPDATE t1 SET a=4 WHERE a=2;
+connection con1;
UPDATE t1 SET a=5 WHERE a=2;
+connection default;
UPDATE t1 SET a=5 WHERE a=1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
XA END 'xid1';
@@ -130,6 +155,7 @@ XA ROLLBACK 'xid1';
XA START 'xid1';
XA END 'xid1';
XA ROLLBACK 'xid1';
+disconnect con1;
DROP TABLE t1;
#
# Bug#56448 Assertion failed: ! is_set() with second xa end
@@ -148,24 +174,25 @@ XA ROLLBACK 'x';
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a)) engine=InnoDB;
INSERT INTO t1 VALUES (1, 1), (2, 2);
-# Connection con1
+connect con1, localhost, root;
XA START 'a';
UPDATE t1 SET b= 3 WHERE a=1;
-# Connection default
+connection default;
XA START 'b';
UPDATE t1 SET b=4 WHERE a=2;
# Sending:
UPDATE t1 SET b=5 WHERE a=1;
-# Connection con1
+connection con1;
UPDATE t1 SET b=6 WHERE a=2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
XA COMMIT 'a';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
-# Connection default
+connection default;
# Reaping: UPDATE t1 SET b=5 WHERE a=1
XA END 'b';
XA ROLLBACK 'b';
DROP TABLE t1;
+disconnect con1;
#
# Bug#11766752 59936: multiple xa assertions - transactional
# statement fuzzer
@@ -209,24 +236,25 @@ CREATE TABLE t1 (a INT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
-# Connection con2
+connect con2,localhost,root;
XA START 'xid1';
# Sending:
INSERT INTO t2 SELECT a FROM t1;
-# Connection default
+connection default;
# Waiting until INSERT ... is blocked
DELETE FROM t1;
-# Connection con2
+connection con2;
# Reaping: INSERT INTO t2 SELECT a FROM t1
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
XA COMMIT 'xid1';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
-# Connection default
+connection default;
COMMIT;
-# Connection con2
+connection con2;
XA START 'xid1';
XA END 'xid1';
XA PREPARE 'xid1';
XA ROLLBACK 'xid1';
-# Connection default
+connection default;
DROP TABLE t1, t2;
+disconnect con2;
diff --git a/mysql-test/r/xa_sync.result b/mysql-test/r/xa_sync.result
index 769a13d1773..1482ff5cacf 100644
--- a/mysql-test/r/xa_sync.result
+++ b/mysql-test/r/xa_sync.result
@@ -2,23 +2,41 @@
# MDEV-7793 - Race condition between XA COMMIT/ROLLBACK and disconnect
#
# Note that this test is meaningful only with valgrind.
+connect con1, localhost, root;
+connect con2, localhost, root;
+connection con1;
XA START 'xatest';
XA END 'xatest';
XA PREPARE 'xatest';
+connection con2;
SET debug_sync='xa_after_search SIGNAL parked WAIT_FOR go';
XA COMMIT 'xatest';
+connection default;
SET debug_sync='now WAIT_FOR parked';
+disconnect con1;
# Waiting for thread to get deleted
SET debug_sync='now SIGNAL go';
+connection con2;
ERROR XAE04: XAER_NOTA: Unknown XID
+disconnect con2;
+connection default;
SET debug_sync='RESET';
+connect con1, localhost, root;
+connect con2, localhost, root;
+connection con1;
XA START 'xatest';
XA END 'xatest';
XA PREPARE 'xatest';
+connection con2;
SET debug_sync='xa_after_search SIGNAL parked WAIT_FOR go';
XA ROLLBACK 'xatest';
+connection default;
SET debug_sync='now WAIT_FOR parked';
+disconnect con1;
# Waiting for thread to get deleted
SET debug_sync='now SIGNAL go';
+connection con2;
ERROR XAE04: XAER_NOTA: Unknown XID
+disconnect con2;
+connection default;
SET debug_sync='RESET';