diff --git a/mysql-test/suite/perfschema/r/misc.result b/mysql-test/suite/perfschema/r/misc.result index b859715e024..83ca6d5cf3f 100644 --- a/mysql-test/suite/perfschema/r/misc.result +++ b/mysql-test/suite/perfschema/r/misc.result @@ -164,3 +164,13 @@ Warnings: Note 1051 Unknown table 'test.t0' FLUSH TABLE t0; DROP TABLE t0; +# +# MDEV-24364 Alter rename table does not remove PFS share +# +create or replace table yt4 (x int) engine innodb; +alter table yt4 rename to t1, algorithm=copy; +drop tables t1; +select object_type, object_schema, object_name +from performance_schema.objects_summary_global_by_type +where object_schema="test"; +object_type object_schema object_name diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test index 38972f42cef..848be3beea1 100644 --- a/mysql-test/suite/perfschema/t/misc.test +++ b/mysql-test/suite/perfschema/t/misc.test @@ -287,3 +287,14 @@ enable_query_log; # an unexpected refcount. FLUSH TABLE t0; DROP TABLE t0; + +--echo # +--echo # MDEV-24364 Alter rename table does not remove PFS share +--echo # +create or replace table yt4 (x int) engine innodb; +alter table yt4 rename to t1, algorithm=copy; +drop tables t1; + +select object_type, object_schema, object_name +from performance_schema.objects_summary_global_by_type +where object_schema="test"; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 318c01bb1dc..4e1ff93c576 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10956,6 +10956,8 @@ do_continue:; { /* The original table is the backup */ backup_name= alter_ctx.table_name; + PSI_CALL_drop_table_share(0, alter_ctx.db.str, (int) alter_ctx.db.length, + alter_ctx.table_name.str, (int) alter_ctx.table_name.length); } // Rename the new table to the correct name.