mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Refs: MW-360 * merged relevant parts of DROP TABLE query splitting from mysql-wsrep-features
This commit is contained in:
@ -2156,94 +2156,6 @@ static uint32 comment_length(THD *thd, uint32 comment_pos,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
static void
|
||||
wsrep_append_name(THD *thd, String *packet, const char *name, uint length,
|
||||
const CHARSET_INFO *from_cs, const CHARSET_INFO *to_cs)
|
||||
{
|
||||
const char *to_name= name;
|
||||
size_t to_length= length;
|
||||
String to_string(name,length, from_cs);
|
||||
if (from_cs != NULL && to_cs != NULL && from_cs != to_cs)
|
||||
thd->convert_string(&to_string, from_cs, to_cs);
|
||||
|
||||
if (to_cs != NULL)
|
||||
{
|
||||
to_name= to_string.c_ptr();
|
||||
to_length= to_string.length();
|
||||
}
|
||||
packet->append(to_name, to_length, packet->charset());
|
||||
}
|
||||
|
||||
int wsrep_replicate_drop_query(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
bool drop_temporary, bool dont_log_query)
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
int error= 0;
|
||||
String built_query;
|
||||
bool non_tmp_table_deleted= FALSE;
|
||||
|
||||
DBUG_ENTER("wsrep_build_drop_query");
|
||||
|
||||
if (!dont_log_query)
|
||||
{
|
||||
if (!drop_temporary)
|
||||
{
|
||||
built_query.set_charset(system_charset_info);
|
||||
if (if_exists)
|
||||
built_query.append("DROP TABLE IF EXISTS ");
|
||||
else
|
||||
built_query.append("DROP TABLE ");
|
||||
}
|
||||
}
|
||||
|
||||
for (table= tables; table; table= table->next_local)
|
||||
{
|
||||
char *db=table->db;
|
||||
int db_len= table->db_length;
|
||||
|
||||
DBUG_PRINT("table", ("table_l: '%s'.'%s' table: 0x%lx s: 0x%lx",
|
||||
table->db, table->table_name, (long) table->table,
|
||||
table->table ? (long) table->table->s : (long) -1));
|
||||
|
||||
if (!find_temporary_table(thd, table))
|
||||
{
|
||||
non_tmp_table_deleted= TRUE;
|
||||
|
||||
if (thd->db == NULL || strcmp(db,thd->db) != 0)
|
||||
{
|
||||
wsrep_append_name(thd, &built_query, db, db_len,
|
||||
system_charset_info, thd->charset());
|
||||
built_query.append(".");
|
||||
}
|
||||
|
||||
thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE;
|
||||
wsrep_append_name(thd, &built_query, table->table_name,
|
||||
strlen(table->table_name), system_charset_info,
|
||||
thd->charset());
|
||||
built_query.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
if (non_tmp_table_deleted)
|
||||
{
|
||||
/* Chop of the last comma */
|
||||
built_query.chop();
|
||||
built_query.append(" /* generated by server */");
|
||||
WSREP_DEBUG("TOI for %s", built_query.ptr());
|
||||
if (WSREP_TO_ISOLATION_BEGIN_QUERY(built_query.ptr(), NULL, NULL, tables))
|
||||
{
|
||||
WSREP_DEBUG("TOI failed for DROP TABLE: %s", WSREP_QUERY(thd));
|
||||
error= 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
#endif /* WITH_WSREP */
|
||||
/**
|
||||
Execute the drop of a normal or temporary table.
|
||||
|
||||
|
Reference in New Issue
Block a user