Commit 04c6b03c authored by sjaakola's avatar sjaakola Committed by Jan Lindström

Refs: MW-360 * merged relevant parts of DROP TABLE query splitting from mysql-wsrep-features

parent a754387a
......@@ -4030,26 +4030,6 @@ case SQLCOM_PREPARE:
/* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */
thd->variables.option_bits|= OPTION_KEEP_LOG;
}
#ifdef WITH_WSREP
bool has_tmp_tables= false;
for (TABLE_LIST *table= all_tables; table; table= table->next_global)
{
if (lex->drop_temporary || find_temporary_table(thd, table))
{
has_tmp_tables= true;
break;
}
}
if (has_tmp_tables)
{
wsrep_replicate_drop_query(thd, first_table, lex->check_exists,
lex->drop_temporary, false);
}
else
{
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables);
}
#endif /* WITH_WSREP */
/*
If we are a slave, we should add IF EXISTS if the query executed
on the master without an error. This will help a slave to
......@@ -4060,6 +4040,7 @@ case SQLCOM_PREPARE:
slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT)
lex->check_exists= 1;
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, all_tables);
/* DDL and binlog write order are protected by metadata locks. */
res= mysql_rm_table(thd, first_table, lex->check_exists,
lex->drop_temporary);
......
......@@ -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.
......
This diff is collapsed.
......@@ -337,9 +337,6 @@ void wsrep_init_sidno(const wsrep_uuid_t&);
bool wsrep_node_is_donor();
bool wsrep_node_is_synced();
int wsrep_replicate_drop_query(THD *thd, TABLE_LIST *tables, bool if_exists,
bool drop_temporary, bool dont_log_query);
#define WSREP_MYSQL_DB (char *)"mysql"
#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment