1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Do not log ALTER table to ddl log for REPAIR

REPAIR of InnoDB tables was logging ALTER TABLE and REPAIR to ddl log.
ALTER TABLE contained the new tableid and REPAIR, wrongly, contained the
old rowid.

Now only REPAIR is logged

ddl.log changes:
REPAIR TABLE and OPTIMIZE TABLE that are done through ALTER TABLE will
now contain the old and new table id. If not done through ALTER TABLE,
only the current rowid will be shown (as before).
This commit is contained in:
Monty
2025-01-26 20:17:17 +02:00
parent aae9b50a53
commit f099f778b3
7 changed files with 59 additions and 30 deletions

View File

@@ -817,6 +817,25 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* purecov: end */
}
/*
This has to be tested separately from the following test as
optimizer table takes a MDL_SHARED_WRITE lock but we want to
log this to the ddl log.
*/
if (lock_type == TL_WRITE && table->mdl_request.type >= MDL_SHARED_WRITE)
{
/* Store information about table for ddl log */
storage_engine_partitioned= table->table->file->partition_engine();
strmake(storage_engine_name, table->table->file->real_table_type(),
sizeof(storage_engine_name)-1);
tabledef_version.str= tabledef_version_buff;
if ((tabledef_version.length= table->table->s->tabledef_version.length))
memcpy((char*) tabledef_version.str,
table->table->s->tabledef_version.str,
MY_UUID_SIZE);
}
/*
Close all instances of the table to allow MyISAM "repair"
(which is internally also used from "optimize") to rename files.
@@ -835,16 +854,6 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->close_unused_temporary_table_instances(table);
else
{
/* Store information about table for ddl log */
storage_engine_partitioned= table->table->file->partition_engine();
strmake(storage_engine_name, table->table->file->real_table_type(),
sizeof(storage_engine_name)-1);
tabledef_version.str= tabledef_version_buff;
if ((tabledef_version.length= table->table->s->tabledef_version.length))
memcpy((char*) tabledef_version.str,
table->table->s->tabledef_version.str,
MY_UUID_SIZE);
if (wait_while_table_is_used(thd, table->table, HA_EXTRA_NOT_USED))
goto err;
DEBUG_SYNC(thd, "after_admin_flush");
@@ -1476,6 +1485,14 @@ send_result_message:
ddl_log.org_database= table->db;
ddl_log.org_table= table->table_name;
ddl_log.org_table_id= tabledef_version;
if (recreate_used)
{
LEX_CUSTRING tabledef_version=
{ recreate_info.tabledef_version, MY_UUID_SIZE };
ddl_log.new_database= table->db;
ddl_log.new_table= table->table_name;
ddl_log.new_table_id= tabledef_version;
}
backup_log_ddl(&ddl_log);
}