1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-27653 long uniques don't work with unicode collations

This commit is contained in:
Alexander Barkov
2022-10-28 13:43:51 +04:00
parent 9924466b3b
commit 284ac6f2b7
27 changed files with 668 additions and 66 deletions

View File

@ -35,7 +35,8 @@
#include "wsrep_mysqld.h"
/* Prepare, run and cleanup for mysql_recreate_table() */
static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list)
static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list,
Recreate_info *recreate_info)
{
bool result_code;
DBUG_ENTER("admin_recreate_table");
@ -56,7 +57,7 @@ static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list)
DEBUG_SYNC(thd, "ha_admin_try_alter");
tmp_disable_binlog(thd); // binlogging is done by caller if wanted
result_code= (thd->open_temporary_tables(table_list) ||
mysql_recreate_table(thd, table_list, false));
mysql_recreate_table(thd, table_list, recreate_info, false));
reenable_binlog(thd);
/*
mysql_recreate_table() can push OK or ERROR.
@ -516,6 +517,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
bool open_error;
bool collect_eis= FALSE;
bool open_for_modify= org_open_for_modify;
Recreate_info recreate_info;
DBUG_PRINT("admin", ("table: '%s'.'%s'", db, table->table_name.str));
DEBUG_SYNC(thd, "admin_command_kill_before_modify");
@ -776,7 +778,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
{
/* We use extra_open_options to be able to open crashed tables */
thd->open_options|= extra_open_options;
result_code= admin_recreate_table(thd, table);
result_code= admin_recreate_table(thd, table, &recreate_info) ?
HA_ADMIN_FAILED : HA_ADMIN_OK;
thd->open_options&= ~extra_open_options;
goto send_result;
}
@ -947,12 +950,31 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
repair was not implemented and we need to upgrade the table
to a new version so we recreate the table with ALTER TABLE
*/
result_code= admin_recreate_table(thd, table);
result_code= admin_recreate_table(thd, table, &recreate_info);
}
send_result:
lex->cleanup_after_one_table_open();
thd->clear_error(); // these errors shouldn't get client
if (recreate_info.records_duplicate())
{
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
protocol->store((char*) operator_name, system_charset_info);
protocol->store(warning_level_names[Sql_condition::WARN_LEVEL_WARN].str,
warning_level_names[Sql_condition::WARN_LEVEL_WARN].length,
system_charset_info);
char buf[80];
size_t length= my_snprintf(buf, sizeof(buf),
"Number of rows changed from %u to %u",
(uint) recreate_info.records_processed(),
(uint) recreate_info.records_copied());
protocol->store(buf, length, system_charset_info);
if (protocol->write())
goto err;
}
{
Diagnostics_area::Sql_condition_iterator it=
thd->get_stmt_da()->sql_conditions();
@ -1063,7 +1085,7 @@ send_result_message:
table->next_local= table->next_global= 0;
tmp_disable_binlog(thd); // binlogging is done by caller if wanted
result_code= admin_recreate_table(thd, table);
result_code= admin_recreate_table(thd, table, &recreate_info);
reenable_binlog(thd);
trans_commit_stmt(thd);
trans_commit(thd);
@ -1409,6 +1431,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
LEX *m_lex= thd->lex;
TABLE_LIST *first_table= m_lex->first_select_lex()->table_list.first;
bool res= TRUE;
Recreate_info recreate_info;
DBUG_ENTER("Sql_cmd_optimize_table::execute");
if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table,
@ -1417,7 +1440,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd)
WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table);
res= (specialflag & SPECIAL_NO_NEW_FUNC) ?
mysql_recreate_table(thd, first_table, true) :
mysql_recreate_table(thd, first_table, &recreate_info, true) :
mysql_admin_table(thd, first_table, &m_lex->check_opt,
"optimize", TL_WRITE, 1, 0, 0, 0,
&handler::ha_optimize, 0, true);