Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions mysql-test/r/profiling.result
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,31 @@ select @@profiling;
@@profiling
1
drop table if exists t2, t1, t3;
select QUERY_ID, SEQ, STATE from INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID = (select max(QUERY_ID) from INFORMATION_SCHEMA.PROFILING) order by SEQ;
QUERY_ID SEQ STATE
105 2 starting
105 3 Executing hook on transaction
105 4 starting
105 5 waiting for handler commit
105 6 checking permissions
105 7 checking permissions
105 8 checking permissions
105 9 dropping table
105 10 after drop
105 11 dropping table
105 12 after drop
105 13 dropping table
105 14 after drop
105 15 waiting for handler commit
105 16 waiting for handler commit
105 17 query end
105 18 closing tables
105 19 waiting for handler commit
105 20 freeing items
105 21 cleaning up
Warnings:
Warning 1287 'INFORMATION_SCHEMA.PROFILING' is deprecated and will be removed in a future release. Please use Performance Schema instead
Warning 1287 'INFORMATION_SCHEMA.PROFILING' is deprecated and will be removed in a future release. Please use Performance Schema instead
drop view if exists v1;
Warnings:
Note 1051 Unknown table 'test.v1'
Expand Down
47 changes: 47 additions & 0 deletions mysql-test/suite/perfschema/r/create_drop_table.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
TRUNCATE TABLE performance_schema.events_stages_history_long;
CREATE TABLE test.t1(a int);
DROP TABLE test.t1;
SELECT EVENT_NAME FROM performance_schema.events_stages_history_long ORDER BY EVENT_ID;
EVENT_NAME
stage/sql/System lock
stage/sql/waiting for handler commit
stage/sql/query end
stage/sql/closing tables
stage/sql/waiting for handler commit
stage/sql/freeing items
stage/sql/cleaning up
stage/sql/starting
stage/sql/Executing hook on transaction begin.
stage/sql/starting
stage/sql/checking permissions
stage/sql/Opening tables
stage/sql/creating table
stage/sql/After create
stage/sql/waiting for handler commit
stage/sql/waiting for handler commit
stage/sql/query end
stage/sql/closing tables
stage/sql/waiting for handler commit
stage/sql/freeing items
stage/sql/cleaning up
stage/sql/starting
stage/sql/Executing hook on transaction begin.
stage/sql/starting
stage/sql/checking permissions
stage/sql/dropping table
stage/sql/after drop
stage/sql/waiting for handler commit
stage/sql/waiting for handler commit
stage/sql/query end
stage/sql/closing tables
stage/sql/waiting for handler commit
stage/sql/freeing items
stage/sql/cleaning up
stage/sql/starting
stage/sql/checking permissions
stage/sql/Opening tables
stage/sql/init
stage/sql/System lock
stage/sql/optimizing
stage/sql/statistics
stage/sql/preparing
1 change: 1 addition & 0 deletions mysql-test/suite/perfschema/t/create_drop_table-master.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--loose-performance-schema-instrument='stage/sql/%=COUNTED'
6 changes: 6 additions & 0 deletions mysql-test/suite/perfschema/t/create_drop_table.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TRUNCATE TABLE performance_schema.events_stages_history_long;

CREATE TABLE test.t1(a int);
DROP TABLE test.t1;

SELECT EVENT_NAME FROM performance_schema.events_stages_history_long ORDER BY EVENT_ID;
1 change: 1 addition & 0 deletions mysql-test/t/profiling.test
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ select @@profiling;
--enable_warnings

drop table if exists t2, t1, t3;
select QUERY_ID, SEQ, STATE from INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID = (select max(QUERY_ID) from INFORMATION_SCHEMA.PROFILING) order by SEQ;
drop view if exists v1;
drop function if exists f1;

Expand Down
4 changes: 4 additions & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15119,6 +15119,7 @@ static PSI_file_info all_server_files[]=

/* clang-format off */
PSI_stage_info stage_after_create= { 0, "After create", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_after_drop= { 0, "after drop", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_alter_inplace_prepare= { 0, "preparing for alter table", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_alter_inplace= { 0, "altering table", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_alter_inplace_commit= { 0, "committing alter table to storage engine", 0, PSI_DOCUMENT_ME};
Expand All @@ -15136,6 +15137,7 @@ PSI_stage_info stage_creating_tmp_table= { 0, "Creating tmp table", 0, PSI_DOCUM
PSI_stage_info stage_deleting_from_main_table= { 0, "deleting from main table", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_deleting_from_reference_tables= { 0, "deleting from reference tables", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_discard_or_import_tablespace= { 0, "discard_or_import_tablespace", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_dropping_table= { 0, "dropping table", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_end= { 0, "end", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_executing= { 0, "executing", 0, PSI_DOCUMENT_ME};
PSI_stage_info stage_execution_of_init_command= { 0, "Execution of init_command", 0, PSI_DOCUMENT_ME};
Expand Down Expand Up @@ -15224,6 +15226,7 @@ extern PSI_stage_info stage_waiting_for_disk_space;

PSI_stage_info *all_server_stages[] = {
&stage_after_create,
&stage_after_drop,
&stage_alter_inplace_prepare,
&stage_alter_inplace,
&stage_alter_inplace_commit,
Expand All @@ -15241,6 +15244,7 @@ PSI_stage_info *all_server_stages[] = {
&stage_deleting_from_main_table,
&stage_deleting_from_reference_tables,
&stage_discard_or_import_tablespace,
&stage_dropping_table,
&stage_end,
&stage_executing,
&stage_execution_of_init_command,
Expand Down
2 changes: 2 additions & 0 deletions sql/mysqld.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ extern PSI_socket_key key_socket_client_connection;
Hint: grep PSI_stage_info | sort -u
*/
extern PSI_stage_info stage_after_create;
extern PSI_stage_info stage_after_drop;
extern PSI_stage_info stage_alter_inplace_prepare;
extern PSI_stage_info stage_alter_inplace;
extern PSI_stage_info stage_alter_inplace_commit;
Expand All @@ -602,6 +603,7 @@ extern PSI_stage_info stage_creating_tmp_table;
extern PSI_stage_info stage_deleting_from_main_table;
extern PSI_stage_info stage_deleting_from_reference_tables;
extern PSI_stage_info stage_discard_or_import_tablespace;
extern PSI_stage_info stage_dropping_table;
extern PSI_stage_info stage_end;
extern PSI_stage_info stage_executing;
extern PSI_stage_info stage_execution_of_init_command;
Expand Down
3 changes: 2 additions & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2972,6 +2972,7 @@ static bool drop_base_table(THD *thd, const Drop_tables_ctx &drop_ctx,
Foreign_key_parents_invalidator *fk_invalidator,
std::vector<MDL_ticket *> *safe_to_release_mdl,
MEM_ROOT *foreach_table_root) {
THD_STAGE_INFO(thd, stage_dropping_table);
char path[FN_REFLEN + 1];

/* Check that we have an exclusive lock on the table to be dropped. */
Expand Down Expand Up @@ -3253,7 +3254,7 @@ static bool drop_base_table(THD *thd, const Drop_tables_ctx &drop_ctx,
result |= mark_referencing_views_invalid(thd, table,
(drop_ctx.drop_database && atomic),
!atomic, foreach_table_root);

THD_STAGE_INFO(thd, stage_after_drop);
return result;
}

Expand Down