diff --git a/dbcon/mysql/ha_mcs.cpp b/dbcon/mysql/ha_mcs.cpp index 1ec9189ce..e9852b815 100644 --- a/dbcon/mysql/ha_mcs.cpp +++ b/dbcon/mysql/ha_mcs.cpp @@ -1229,8 +1229,9 @@ my_bool get_status_and_flush_cache(void *param, ha_mcs_cache *cache= (ha_mcs_cache*) param; int error; enum_sql_command sql_command= cache->table->in_use->lex->sql_command; - cache->insert_command= (sql_command != SQLCOM_INSERT && - sql_command != SQLCOM_LOAD); + cache->insert_command= (sql_command == SQLCOM_INSERT || + sql_command == SQLCOM_INSERT_SELECT || + sql_command == SQLCOM_LOAD); /* Call first the original Aria get_status function All Aria get_status functions takes Maria handler as the parameter @@ -1251,6 +1252,8 @@ my_bool get_status_and_flush_cache(void *param, return(1); } } + else if (!cache->insert_command) + cache->free_locks(); } else if (!cache->insert_command) cache->free_locks(); @@ -1761,7 +1764,9 @@ void ha_mcs_cache::free_locks() { /* We don't need to lock cache_handler anymore as it's already flushed */ + mysql_mutex_unlock(&cache_handler->file->lock.lock->mutex); thr_unlock(&cache_handler->file->lock, 0); + mysql_mutex_lock(&cache_handler->file->lock.lock->mutex); /* Restart transaction for columnstore table */ if (original_lock_type != F_WRLCK) @@ -1782,15 +1787,14 @@ int ha_mcs_cache::flush_insert_cache() { int error, error2; ha_maria *from= cache_handler; - parent *to= this; - uchar *record= to->table->record[0]; + uchar *record= table->record[0]; DBUG_ENTER("flush_insert_cache"); - to->start_bulk_insert(from->file->state->records, 0); + parent::start_bulk_insert(from->file->state->records, 0); from->rnd_init(1); while (!(error= from->rnd_next(record))) { - if ((error= to->write_row(record))) + if ((error= parent::write_row(record))) goto end; } if (error == HA_ERR_END_OF_FILE) @@ -1798,19 +1802,19 @@ int ha_mcs_cache::flush_insert_cache() end: from->rnd_end(); - if ((error2= to->end_bulk_insert()) && !error) + if ((error2= parent::end_bulk_insert()) && !error) error= error2; if (!error) { - if (to->ht->commit) - error= to->ht->commit(to->ht, table->in_use, 1); + if (parent::ht->commit) + error= parent::ht->commit(parent::ht, table->in_use, 1); } else { /* We can ignore the rollback error as we already have some other errors */ - if (to->ht->rollback) - to->ht->rollback(to->ht, table->in_use, 1); + if (parent::ht->rollback) + parent::ht->rollback(parent::ht, table->in_use, 1); } if (!error) diff --git a/dbcon/mysql/ha_mcs.h b/dbcon/mysql/ha_mcs.h index b1bdc293b..3c68053d0 100644 --- a/dbcon/mysql/ha_mcs.h +++ b/dbcon/mysql/ha_mcs.h @@ -54,7 +54,7 @@ class ha_mcs: public handler public: ha_mcs(handlerton* hton, TABLE_SHARE* table_arg); - ~ha_mcs() + virtual ~ha_mcs() { } @@ -237,7 +237,6 @@ public: int repair(THD* thd, HA_CHECK_OPT* check_opt); bool is_crashed() const; - friend class ha_mcs_cache; }; diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index 991cb556f..7099c9e1f 100755 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -6094,7 +6094,9 @@ bool isMCSTable(TABLE* table_ptr) string engineName = table_ptr->s->db_plugin->name.str; #endif - if (engineName == "Columnstore" || engineName == "InfiniDB") + if (engineName == "Columnstore" || + engineName == "InfiniDB" || + engineName == "Columnstore_cache") return true; else return false;