summaryrefslogtreecommitdiff
path: root/sql/sql_truncate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_truncate.cc')
-rw-r--r--sql/sql_truncate.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index 62f6f8a3f90..cb0849400ee 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -246,7 +246,7 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref,
inspite of errors.
*/
if (error == HA_ERR_WRONG_COMMAND ||
- table_ref->table->file->has_transactions())
+ table_ref->table->file->has_transactions_and_rollback())
DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG);
else
DBUG_RETURN(TRUNCATE_FAILED_BUT_BINLOG);
@@ -303,6 +303,12 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref,
versioned= table->versioned();
hton= table->file->ht;
+#ifdef WITH_WSREP
+ if (WSREP(thd) &&
+ !wsrep_should_replicate_ddl(thd, hton->db_type))
+ DBUG_RETURN(TRUE);
+#endif
+
table_ref->mdl_request.ticket= table->mdl_ticket;
}
else
@@ -320,8 +326,20 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref,
versioned= share->versioned;
sequence= share->table_type == TABLE_TYPE_SEQUENCE;
hton= share->db_type();
+#ifdef WITH_WSREP
+ if (WSREP(thd) &&
+ hton != view_pseudo_hton &&
+ !wsrep_should_replicate_ddl(thd, hton->db_type))
+ {
+ tdc_release_share(share);
+ DBUG_RETURN(TRUE);
+ }
+#endif
- tdc_release_share(share);
+ if (!versioned)
+ tdc_remove_referenced_share(thd, share);
+ else
+ tdc_release_share(share);
if (hton == view_pseudo_hton)
{
@@ -357,13 +375,6 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref,
if (*hton_can_recreate)
close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL);
}
- else
- {
- /* Table is already locked exclusively. Remove cached instances. */
- tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table_ref->db.str,
- table_ref->table_name.str, FALSE);
- }
-
DBUG_RETURN(FALSE);
}
@@ -435,6 +446,7 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref)
}
}
#endif /* WITH_WSREP */
+
if (lock_table(thd, table_ref, &hton_can_recreate))
DBUG_RETURN(TRUE);