mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge 10.5 into 10.6
This commit is contained in:
@ -33,6 +33,7 @@
|
||||
#include "sql_statistics.h"
|
||||
#include "wsrep_mysqld.h"
|
||||
|
||||
const LEX_CSTRING msg_status= {STRING_WITH_LEN("status")};
|
||||
const LEX_CSTRING msg_repair= { STRING_WITH_LEN("repair") };
|
||||
const LEX_CSTRING msg_assign_to_keycache=
|
||||
{ STRING_WITH_LEN("assign_to_keycache") };
|
||||
@ -490,6 +491,20 @@ static bool wsrep_toi_replication(THD *thd, TABLE_LIST *tables)
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
|
||||
static void send_read_only_warning(THD *thd, const LEX_CSTRING *msg_status,
|
||||
const LEX_CSTRING *table_name)
|
||||
{
|
||||
Protocol *protocol= thd->protocol;
|
||||
char buf[MYSQL_ERRMSG_SIZE];
|
||||
size_t length;
|
||||
length= my_snprintf(buf, sizeof(buf),
|
||||
ER_THD(thd, ER_OPEN_AS_READONLY),
|
||||
table_name->str);
|
||||
protocol->store(msg_status, system_charset_info);
|
||||
protocol->store(buf, length, system_charset_info);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Collect field names of result set that will be sent to a client
|
||||
|
||||
@ -774,20 +789,16 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
goto send_result;
|
||||
}
|
||||
|
||||
if ((table->table->db_stat & HA_READ_ONLY) && open_for_modify)
|
||||
if ((table->table->db_stat & HA_READ_ONLY) && open_for_modify &&
|
||||
operator_func != &handler::ha_analyze)
|
||||
{
|
||||
/* purecov: begin inspected */
|
||||
char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
|
||||
size_t length;
|
||||
enum_sql_command save_sql_command= lex->sql_command;
|
||||
DBUG_PRINT("admin", ("sending error message"));
|
||||
protocol->prepare_for_resend();
|
||||
protocol->store(&table_name, system_charset_info);
|
||||
protocol->store(operator_name, system_charset_info);
|
||||
protocol->store(&error_clex_str, system_charset_info);
|
||||
length= my_snprintf(buff, sizeof(buff), ER_THD(thd, ER_OPEN_AS_READONLY),
|
||||
table_name.str);
|
||||
protocol->store(buff, length, system_charset_info);
|
||||
send_read_only_warning(thd, &error_clex_str, &table_name);
|
||||
trans_commit_stmt(thd);
|
||||
trans_commit(thd);
|
||||
close_thread_tables(thd);
|
||||
@ -923,6 +934,15 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
|
||||
if (compl_result_code == HA_ADMIN_OK && collect_eis)
|
||||
{
|
||||
if (result_code == HA_ERR_TABLE_READONLY)
|
||||
{
|
||||
protocol->prepare_for_resend();
|
||||
protocol->store(&table_name, system_charset_info);
|
||||
protocol->store(operator_name, system_charset_info);
|
||||
send_read_only_warning(thd, &msg_status, &table_name);
|
||||
(void) protocol->write();
|
||||
result_code= HA_ADMIN_OK;
|
||||
}
|
||||
/*
|
||||
Here we close and reopen table in read mode because operation of
|
||||
collecting statistics is long and it will be better do not block
|
||||
@ -1032,7 +1052,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
protocol->prepare_for_resend();
|
||||
protocol->store(&table_name, system_charset_info);
|
||||
protocol->store(operator_name, system_charset_info);
|
||||
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
|
||||
protocol->store(&msg_status, system_charset_info);
|
||||
protocol->store(STRING_WITH_LEN("Engine-independent statistics collected"),
|
||||
system_charset_info);
|
||||
if (protocol->write())
|
||||
@ -1102,25 +1122,25 @@ send_result_message:
|
||||
break;
|
||||
|
||||
case HA_ADMIN_OK:
|
||||
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
|
||||
protocol->store(&msg_status, system_charset_info);
|
||||
protocol->store(STRING_WITH_LEN("OK"), system_charset_info);
|
||||
break;
|
||||
|
||||
case HA_ADMIN_FAILED:
|
||||
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
|
||||
protocol->store(&msg_status, system_charset_info);
|
||||
protocol->store(STRING_WITH_LEN("Operation failed"),
|
||||
system_charset_info);
|
||||
break;
|
||||
|
||||
case HA_ADMIN_REJECT:
|
||||
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
|
||||
protocol->store(&msg_status, system_charset_info);
|
||||
protocol->store(STRING_WITH_LEN("Operation need committed state"),
|
||||
system_charset_info);
|
||||
open_for_modify= FALSE;
|
||||
break;
|
||||
|
||||
case HA_ADMIN_ALREADY_DONE:
|
||||
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
|
||||
protocol->store(&msg_status, system_charset_info);
|
||||
protocol->store(STRING_WITH_LEN("Table is already up to date"),
|
||||
system_charset_info);
|
||||
break;
|
||||
@ -1265,7 +1285,11 @@ send_result_message:
|
||||
fatal_error=1;
|
||||
break;
|
||||
}
|
||||
|
||||
case HA_ERR_TABLE_READONLY:
|
||||
{
|
||||
send_read_only_warning(thd, &msg_status, &table_name);
|
||||
break;
|
||||
}
|
||||
default: // Probably HA_ADMIN_INTERNAL_ERROR
|
||||
{
|
||||
char buf[MYSQL_ERRMSG_SIZE];
|
||||
|
Reference in New Issue
Block a user