From: Christopher Powers Date: January 5 2012 6:21pm Subject: bzr push into mysql-trunk branch (chris.powers:3705) List-Archive: http://lists.mysql.com/commits/142307 Message-Id: <201201051822.q05IMLbe001806@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3705 Christopher Powers 2012-01-05 [merge] local merge modified: mysql-test/collections/default.experimental mysql-test/r/distinct.result mysql-test/r/group_by.result mysql-test/r/having.result mysql-test/r/innodb_explain_non_select_all.result mysql-test/r/innodb_icp.result mysql-test/r/innodb_icp_all.result mysql-test/r/innodb_icp_none.result mysql-test/r/innodb_mrr_all.result mysql-test/r/innodb_mrr_cost_all.result mysql-test/r/join.result mysql-test/r/join_outer.result mysql-test/r/join_outer_bka.result mysql-test/r/join_outer_bka_nixbnl.result mysql-test/r/myisam_icp.result mysql-test/r/myisam_icp_all.result mysql-test/r/myisam_icp_none.result mysql-test/r/select_all_bka.result mysql-test/r/select_all_bka_nixbnl.result mysql-test/suite/opt_trace/include/general2.inc mysql-test/suite/opt_trace/r/general2_no_prot.result mysql-test/suite/opt_trace/r/general2_ps_prot.result mysql-test/suite/opt_trace/r/temp_table.result mysql-test/t/distinct.test mysql-test/t/group_by.test mysql-test/t/having.test mysql-test/t/join.test mysql-test/t/join_outer.test sql/field.h sql/field_conv.cc sql/item_sum.cc sql/opt_sum.cc sql/sql_base.cc sql/sql_executor.cc sql/sql_lex.cc sql/sql_optimizer.cc sql/sql_parse.cc sql/sql_planner.cc sql/sql_select.cc sql/sql_tmp_table.cc sql/table.cc sql/table.h storage/myisam/mi_create.c unittest/gunit/bounded_queue-t.cc unittest/gunit/bounds_checked_array-t.cc unittest/gunit/cost_estimate-t.cc unittest/gunit/dbug-t.cc unittest/gunit/dynarray-t.cc unittest/gunit/field-t.cc unittest/gunit/filesort_buffer-t.cc unittest/gunit/get_diagnostics-t.cc unittest/gunit/gunit_test_main.cc unittest/gunit/item-t.cc unittest/gunit/mdl-t.cc unittest/gunit/mdl_mytap-t.cc unittest/gunit/my_regex-t.cc unittest/gunit/opt_range-t.cc unittest/gunit/opt_trace-t.cc unittest/gunit/sql_list-t.cc unittest/gunit/sql_plist-t.cc unittest/gunit/stdcxx-t.cc unittest/gunit/tap_event_listener.cc unittest/gunit/test_utils.cc unittest/gunit/thread_utils-t.cc unittest/gunit/thread_utils.cc === modified file 'include/mysql/psi/psi.h' --- a/include/mysql/psi/psi.h 2011-11-08 04:28:05 +0000 +++ b/include/mysql/psi/psi.h 2012-01-04 18:29:43 +0000 @@ -1130,13 +1130,14 @@ typedef void (*release_table_share_v1_t) /** Drop a table share. + @param temporary True for temporary tables @param schema_name the table schema name @param schema_name_length the table schema name length @param table_name the table name @param table_name_length the table name length */ typedef void (*drop_table_share_v1_t) - (const char *schema_name, int schema_name_length, + (my_bool temporary, const char *schema_name, int schema_name_length, const char *table_name, int table_name_length); /** === modified file 'include/mysql/psi/psi_abi_v1.h.pp' --- a/include/mysql/psi/psi_abi_v1.h.pp 2011-11-02 23:29:01 +0000 +++ b/include/mysql/psi/psi_abi_v1.h.pp 2012-01-04 18:29:43 +0000 @@ -281,7 +281,7 @@ typedef struct PSI_table_share* (*get_ta (my_bool temporary, struct TABLE_SHARE *share); typedef void (*release_table_share_v1_t)(struct PSI_table_share *share); typedef void (*drop_table_share_v1_t) - (const char *schema_name, int schema_name_length, + (my_bool temporary, const char *schema_name, int schema_name_length, const char *table_name, int table_name_length); typedef struct PSI_table* (*open_table_v1_t) (struct PSI_table_share *share, const void *identity); === modified file 'mysql-test/suite/perfschema/r/dml_handler.result' --- a/mysql-test/suite/perfschema/r/dml_handler.result 2011-08-11 03:11:58 +0000 +++ b/mysql-test/suite/perfschema/r/dml_handler.result 2012-01-04 18:29:43 +0000 @@ -153,3 +153,4 @@ ERROR HY000: Table storage engine for 'c SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=1; HANDLER performance_schema.accounts OPEN; ERROR HY000: Table storage engine for 'accounts' doesn't have this option +DROP TEMPORARY TABLE table_list; === modified file 'mysql-test/suite/perfschema/r/innodb_table_io.result' --- a/mysql-test/suite/perfschema/r/innodb_table_io.result 2011-08-11 03:11:58 +0000 +++ b/mysql-test/suite/perfschema/r/innodb_table_io.result 2012-01-04 18:29:43 +0000 @@ -107,9 +107,7 @@ wait/io/table/sql/handler handler.cc: TA wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test #sql-XXXX insert NULL wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test #sql-XXXX insert NULL wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL === modified file 'mysql-test/suite/perfschema/r/misc.result' --- a/mysql-test/suite/perfschema/r/misc.result 2011-04-20 17:56:53 +0000 +++ b/mysql-test/suite/perfschema/r/misc.result 2012-01-04 18:29:43 +0000 @@ -1,3 +1,24 @@ +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type +WHERE object_schema='test'; +object_schema object_name +CREATE TABLE test.t_before(a INT); +INSERT INTO test.t_before VALUES (1); +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type +WHERE object_schema='test'; +object_schema object_name +test t_before +RENAME TABLE test.t_before TO test.t_after; +SELECT COUNT(*) FROM test.t_after; +COUNT(*) +1 +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type +WHERE object_schema='test'; +object_schema object_name +test t_after +DROP TABLE test.t_after; +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type +WHERE object_schema='test'; +object_schema object_name SELECT EVENT_ID FROM performance_schema.events_waits_current WHERE THREAD_ID IN (SELECT THREAD_ID FROM performance_schema.threads) @@ -7,10 +28,19 @@ WHERE NAME LIKE "wait/synch/%") LIMIT 1; create table test.t1(a int) engine=performance_schema; ERROR HY000: Can't create table 'test.t1' (errno: 131) +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type +WHERE object_schema='test'; +object_schema object_name create table test.t1 like performance_schema.events_waits_current; ERROR HY000: Can't create table 'test.t1' (errno: 131) +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type +WHERE object_schema='test'; +object_schema object_name create table performance_schema.t1(a int); ERROR 42000: CREATE command denied to user 'root'@'localhost' for table 't1' +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type +WHERE object_schema='test'; +object_schema object_name drop table if exists test.ghost; create table test.ghost (a int, b int); alter table test.ghost add index index_a(a); === modified file 'mysql-test/suite/perfschema/r/temp_table_io.result' --- a/mysql-test/suite/perfschema/r/temp_table_io.result 2011-08-11 03:11:58 +0000 +++ b/mysql-test/suite/perfschema/r/temp_table_io.result 2012-01-04 18:29:43 +0000 @@ -73,42 +73,15 @@ event_name short_source object_type obje wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab insert NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab insert NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab insert NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab update NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab update NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab update NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab delete NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL -wait/io/table/sql/handler handler.cc: TEMPORARY TABLE test no_index_tab fetch NULL +wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL +wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL +wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL +wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL +wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL +wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL show status like 'performance_schema_%'; === modified file 'mysql-test/suite/perfschema/t/dml_handler.test' --- a/mysql-test/suite/perfschema/t/dml_handler.test 2011-10-19 21:49:22 +0000 +++ b/mysql-test/suite/perfschema/t/dml_handler.test 2012-01-04 18:29:43 +0000 @@ -15,7 +15,7 @@ --echo --echo # Create a temporary table of performance schema table names --echo - + CREATE TEMPORARY TABLE table_list (id INT AUTO_INCREMENT, PRIMARY KEY (id)) AS SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='performance_schema'; @@ -38,3 +38,5 @@ while ($count > 0) dec $count; } +DROP TEMPORARY TABLE table_list; + === modified file 'mysql-test/suite/perfschema/t/misc.test' --- a/mysql-test/suite/perfschema/t/misc.test 2011-10-19 21:49:22 +0000 +++ b/mysql-test/suite/perfschema/t/misc.test 2012-01-04 18:29:43 +0000 @@ -5,6 +5,40 @@ --source include/have_perfschema.inc # +# Bug#12790483 OBJECTS_SUMMARY_GLOBAL_BY_TYPE AND RENAME TABLE +# +# Rename table leaves old tables names behind in +# performance_schema.objects_summary_global_by_type +# +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type + WHERE object_schema='test'; + +CREATE TABLE test.t_before(a INT); +INSERT INTO test.t_before VALUES (1); + +# The new table should appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE. + +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type + WHERE object_schema='test'; + +RENAME TABLE test.t_before TO test.t_after; + +# The renamed table should appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE, but only +# after it is accessed. + +SELECT COUNT(*) FROM test.t_after; + +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type + WHERE object_schema='test'; + +DROP TABLE test.t_after; + +# The renamed table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE. + +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type + WHERE object_schema='test'; + +# # Bug#45496 Performance schema: assertion fails in # ha_perfschema::rnd_init:223 # @@ -26,6 +60,11 @@ LIMIT 1; --error ER_CANT_CREATE_TABLE create table test.t1(a int) engine=performance_schema; +# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE + +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type + WHERE object_schema='test'; + # # Bug#44897 Performance Schema: can create a ghost table in another database # @@ -33,6 +72,11 @@ create table test.t1(a int) engine=perfo --error ER_CANT_CREATE_TABLE create table test.t1 like performance_schema.events_waits_current; +# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE + +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type + WHERE object_schema='test'; + # # Bug#44898 PerformanceSchema: can create a table in db performance_schema, cannot insert # @@ -40,6 +84,11 @@ create table test.t1 like performance_sc --error ER_TABLEACCESS_DENIED_ERROR create table performance_schema.t1(a int); +# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE + +SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type + WHERE object_schema='test'; + # # Bug#51447 performance schema evil twin files # === modified file 'sql/handler.cc' --- a/sql/handler.cc 2012-01-05 10:12:47 +0000 +++ b/sql/handler.cc 2012-01-05 17:57:53 +0000 @@ -2119,7 +2119,11 @@ int ha_delete_table(THD *thd, handlerton #ifdef HAVE_PSI_TABLE_INTERFACE if (likely(error == 0)) - PSI_CALL(drop_table_share)(db, strlen(db), alias, strlen(alias)); + { + my_bool temp_table= (my_bool)is_prefix(alias, tmp_file_prefix); + PSI_CALL(drop_table_share)(temp_table, db, strlen(db), + alias, strlen(alias)); + } #endif DBUG_RETURN(error); @@ -3961,7 +3965,7 @@ void handler::get_dynamic_partition_info int ha_create_table(THD *thd, const char *path, const char *db, const char *table_name, HA_CREATE_INFO *create_info, - bool update_create_info) + bool update_create_info) { int error= 1; TABLE table; @@ -3969,16 +3973,17 @@ int ha_create_table(THD *thd, const char const char *name; TABLE_SHARE share; DBUG_ENTER("ha_create_table"); +#ifdef HAVE_PSI_TABLE_INTERFACE + my_bool temp_table= (my_bool)is_prefix(table_name, tmp_file_prefix) || + (create_info->options & HA_LEX_CREATE_TMP_TABLE ? TRUE : FALSE); +#endif init_tmp_table_share(thd, &share, db, 0, table_name, path); if (open_table_def(thd, &share, 0)) goto err; #ifdef HAVE_PSI_TABLE_INTERFACE - { - my_bool temp= (create_info->options & HA_LEX_CREATE_TMP_TABLE ? TRUE : FALSE); - share.m_psi= PSI_CALL(get_table_share)(temp, &share); - } + share.m_psi= PSI_CALL(get_table_share)(temp_table, &share); #endif if (open_table_from_share(thd, &share, "", 0, (uint) READ_ALL, 0, &table, @@ -3996,6 +4001,10 @@ int ha_create_table(THD *thd, const char { strxmov(name_buff, db, ".", table_name, NullS); my_error(ER_CANT_CREATE_TABLE, MYF(ME_BELL+ME_WAITTANG), name_buff, error); +#ifdef HAVE_PSI_TABLE_INTERFACE + PSI_CALL(drop_table_share)(temp_table, db, strlen(db), table_name, + strlen(table_name)); +#endif } err: free_table_share(&share); === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2012-01-05 12:12:18 +0000 +++ b/sql/sql_table.cc 2012-01-05 17:57:53 +0000 @@ -54,6 +54,7 @@ #include "transaction.h" #include "datadict.h" // dd_frm_type() #include "sql_resolver.h" // setup_order, fix_inner_refs +#include #ifdef __WIN__ #include @@ -2395,9 +2396,9 @@ int mysql_rm_table_no_locks(THD *thd, TA tbl_name.append('.'); tbl_name.append(String(table->table_name,system_charset_info)); - push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, - ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), - tbl_name.c_ptr()); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), + tbl_name.c_ptr()); } else { @@ -2423,21 +2424,21 @@ int mysql_rm_table_no_locks(THD *thd, TA /* No error if non existent table and 'IF EXIST' clause or view */ if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && - (if_exists || table_type == NULL)) + (if_exists || table_type == NULL)) { - error= 0; + error= 0; thd->clear_error(); } if (error == HA_ERR_ROW_IS_REFERENCED) { - /* the table is referenced by a foreign key constraint */ - foreign_key_error= 1; + /* the table is referenced by a foreign key constraint */ + foreign_key_error= 1; } if (!error || error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) { int new_error; - /* Delete the table definition file */ - strmov(end,reg_ext); + /* Delete the table definition file */ + strmov(end,reg_ext); if (!(new_error= mysql_file_delete(key_file_frm, path, MYF(MY_WME)))) { non_tmp_table_deleted= TRUE; @@ -2451,7 +2452,7 @@ int mysql_rm_table_no_locks(THD *thd, TA if (error) { if (wrong_tables.length()) - wrong_tables.append(','); + wrong_tables.append(','); wrong_tables.append(String(db,system_charset_info)); wrong_tables.append('.'); @@ -2464,6 +2465,11 @@ int mysql_rm_table_no_locks(THD *thd, TA my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), table->table_name);); +#ifdef HAVE_PSI_TABLE_INTERFACE + if (drop_temporary && likely(error == 0)) + PSI_CALL(drop_table_share)(true, table->db, table->db_length, + table->table_name, table->table_name_length); +#endif } DEBUG_SYNC(thd, "rm_table_no_locks_before_binlog"); thd->thread_specific_used|= (trans_tmp_table_deleted || @@ -4725,6 +4731,21 @@ mysql_rename_table(handlerton *base, con my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error, my_strerror(errbuf, sizeof(errbuf), error)); } + +#ifdef HAVE_PSI_TABLE_INTERFACE + /* + Remove the old table share from the pfs table share array. The new table + share will be created when the renamed table is first accessed. + */ + if (likely(error == 0)) + { + my_bool temp_table= (my_bool)is_prefix(old_name, tmp_file_prefix); + PSI_CALL(drop_table_share)(temp_table, old_db, strlen(old_db), + old_name, strlen(old_name)); + } +#endif + + DBUG_RETURN(error != 0); } === modified file 'storage/perfschema/pfs.cc' --- a/storage/perfschema/pfs.cc 2011-12-16 11:01:45 +0000 +++ b/storage/perfschema/pfs.cc 2012-01-04 18:29:43 +0000 @@ -1503,6 +1503,9 @@ static void destroy_cond_v1(PSI_cond* co static PSI_table_share* get_table_share_v1(my_bool temporary, TABLE_SHARE *share) { + /* Ignore temporary tables. */ + if (temporary) + return NULL; /* An instrumented thread is required, for LF_PINS. */ PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS); if (unlikely(pfs_thread == NULL)) @@ -1531,14 +1534,18 @@ static void release_table_share_v1(PSI_t @sa PSI_v1::drop_table_share. */ static void -drop_table_share_v1(const char *schema_name, int schema_name_length, +drop_table_share_v1(my_bool temporary, + const char *schema_name, int schema_name_length, const char *table_name, int table_name_length) { + /* Ignore temporary tables. */ + if (temporary) + return; PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS); if (unlikely(pfs_thread == NULL)) return; /* TODO: temporary tables */ - drop_table_share(pfs_thread, false, schema_name, schema_name_length, + drop_table_share(pfs_thread, temporary, schema_name, schema_name_length, table_name, table_name_length); } No bundle (reason: useless for push emails).