diff options
Diffstat (limited to 'sql/sql_truncate.cc')
-rw-r--r-- | sql/sql_truncate.cc | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index bfcdda6e0e9..a745293ec31 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -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); } @@ -417,9 +428,10 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) #ifdef WITH_WSREP if (WSREP(thd) && - wsrep_to_isolation_begin(thd, table_ref->db.str, table_ref->table_name.str, 0)) - DBUG_RETURN(TRUE); + wsrep_to_isolation_begin(thd, table_ref->db.str, table_ref->table_name.str, NULL)) + DBUG_RETURN(TRUE); #endif /* WITH_WSREP */ + if (lock_table(thd, table_ref, &hton_can_recreate)) DBUG_RETURN(TRUE); |