1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-3672 Fix double-DML execution

Direct update/delete executed doUpdateDelete as well as the regular
execution route for doUpdateDelete.

This patch only executes doUpdateDelete the first time and direct
update/delete collects the counts.
This commit is contained in:
Andrew Hutchings
2019-12-12 22:58:20 +00:00
parent 1fea11337c
commit 9734a25a35
2 changed files with 15 additions and 10 deletions

View File

@ -1194,7 +1194,7 @@ vector<string> getOnUpdateTimestampColumns(string& schema, string& tableName, in
return returnVal; return returnVal;
} }
uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, ha_rows *affected_rows) uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
{ {
if (get_fe_conn_info_ptr() == NULL) if (get_fe_conn_info_ptr() == NULL)
set_fe_conn_info_ptr((void*)new cal_connection_info()); set_fe_conn_info_ptr((void*)new cal_connection_info());
@ -2218,8 +2218,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, ha_rows *affected_rows)
} }
else else
{ {
if (affected_rows) ci->affectedRows = dmlRowCount;
*affected_rows = dmlRowCount;
} }
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, errorMsg.c_str()); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, errorMsg.c_str());
@ -2227,8 +2226,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, ha_rows *affected_rows)
else else
{ {
// if (dmlRowCount != 0) //Bug 5117. Handling self join. // if (dmlRowCount != 0) //Bug 5117. Handling self join.
if (affected_rows) ci->affectedRows = dmlRowCount;
*affected_rows = dmlRowCount;
//cout << " error status " << ci->rc << " and rowcount = " << dmlRowCount << endl; //cout << " error status " << ci->rc << " and rowcount = " << dmlRowCount << endl;
} }
@ -2289,8 +2287,13 @@ int ha_mcs_impl_direct_update_delete_rows(ha_rows *affected_rows)
cal_impl_if::gp_walk_info gwi; cal_impl_if::gp_walk_info gwi;
gwi.thd = thd; gwi.thd = thd;
int rc = doUpdateDelete(thd, gwi, affected_rows); cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
return rc; if (ci)
{
*affected_rows = ci->affectedRows;
}
return 0;
} }
int ha_mcs_impl_rnd_init(TABLE* table) int ha_mcs_impl_rnd_init(TABLE* table)
@ -2352,7 +2355,7 @@ int ha_mcs_impl_rnd_init(TABLE* table)
//Update and delete code //Update and delete code
if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI))
return doUpdateDelete(thd, gwi, NULL); return doUpdateDelete(thd, gwi);
uint32_t sessionID = tid2sid(thd->thread_id); uint32_t sessionID = tid2sid(thd->thread_id);
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
@ -4899,7 +4902,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
//Update and delete code //Update and delete code
if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI)) if ( ((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) || ((thd->lex)->sql_command == SQLCOM_UPDATE_MULTI))
return doUpdateDelete(thd, gwi, NULL); return doUpdateDelete(thd, gwi);
uint32_t sessionID = tid2sid(thd->thread_id); uint32_t sessionID = tid2sid(thd->thread_id);
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);

View File

@ -260,7 +260,8 @@ struct cal_connection_info
useXbit(false), useXbit(false),
utf8(false), utf8(false),
useCpimport(1), useCpimport(1),
delimiter('\7') delimiter('\7'),
affectedRows(0)
{ {
// check if this is a slave mysql daemon // check if this is a slave mysql daemon
isSlaveNode = checkSlave(); isSlaveNode = checkSlave();
@ -331,6 +332,7 @@ struct cal_connection_info
std::vector <execplan::CalpontSystemCatalog::ColType> columnTypes; std::vector <execplan::CalpontSystemCatalog::ColType> columnTypes;
// MCOL-1101 remove compilation unit variable rmParms // MCOL-1101 remove compilation unit variable rmParms
std::vector <execplan::RMParam> rmParms; std::vector <execplan::RMParam> rmParms;
long long affectedRows;
}; };
const std::string infinidb_err_msg = "\nThe query includes syntax that is not supported by MariaDB Columnstore. Use 'show warnings;' to get more information. Review the MariaDB Columnstore Syntax guide for additional information on supported distributed syntax or consider changing the MariaDB Columnstore Operating Mode (infinidb_vtable_mode)."; const std::string infinidb_err_msg = "\nThe query includes syntax that is not supported by MariaDB Columnstore. Use 'show warnings;' to get more information. Review the MariaDB Columnstore Syntax guide for additional information on supported distributed syntax or consider changing the MariaDB Columnstore Operating Mode (infinidb_vtable_mode).";