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

MCOL-1482 An UPDATE operation on a non-ColumnStore table involving a

cross-engine join with a ColumnStore table errors out.

ColumnStore cannot directly update a foreign table. We detect whether
a multi-table UPDATE operation is performed on a foreign table, if so,
do not create the select_handler and let the server execute the UPDATE
operation instead.
This commit is contained in:
Gagan Goel
2021-06-10 10:48:12 +00:00
parent 28fd12a008
commit 49255f5cbd
6 changed files with 180 additions and 71 deletions

View File

@ -6325,6 +6325,48 @@ bool isMCSTable(TABLE* table_ptr)
return false;
}
bool isForeignTableUpdate(THD* thd)
{
LEX* lex = thd->lex;
if (lex->sql_command != SQLCOM_UPDATE_MULTI)
return false;
Item_field* item;
List_iterator_fast<Item> field_it(lex->first_select_lex()->item_list);
while ((item = (Item_field*) field_it++))
{
if (item->field && item->field->table && !isMCSTable(item->field->table))
return true;
}
return false;
}
// This function is different from isForeignTableUpdate()
// above as it only checks if any of the tables involved
// in the multi-table update statement is a foreign table,
// irrespective of whether the update is performed on the
// foreign table or not, as in isForeignTableUpdate().
bool isUpdateHasForeignTable(THD* thd)
{
LEX* lex = thd->lex;
if (lex->sql_command != SQLCOM_UPDATE_MULTI)
return false;
TABLE_LIST* table_ptr = lex->first_select_lex()->get_table_list();
for (; table_ptr; table_ptr = table_ptr->next_local)
{
if (table_ptr->table && !isMCSTable(table_ptr->table))
return true;
}
return false;
}
/*@brief set some runtime params to run the query */
/***********************************************************
* DESCRIPTION:
@ -6576,10 +6618,7 @@ int processWhere(SELECT_LEX &select_lex,
else if (select_lex.where)
icp = select_lex.where;
}
else if (!join && ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) ||
((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) ||
((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ||
((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI )))
else if (!join && isUpdateOrDeleteStatement(gwi.thd->lex->sql_command))
{
isUpdateDelete = true;
}
@ -7392,7 +7431,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
}
//@Bug 3030 Add error check for dml statement
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) )
if (isUpdateOrDeleteStatement(gwi.thd->lex->sql_command))
{
if ( after_size - before_size != 0 )
{
@ -7426,7 +7465,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
case REAL_RESULT:
case TIME_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
if (isUpdateOrDeleteStatement(gwi.thd->lex->sql_command))
{ }
else
{
@ -7458,7 +7497,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
case Item::NULL_ITEM:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) )
if (isUpdateOrDeleteStatement(gwi.thd->lex->sql_command))
{ }
else
{
@ -9258,7 +9297,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
}
//@Bug 3030 Add error check for dml statement
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) )
if (isUpdateOrDeleteStatement(gwi.thd->lex->sql_command))
{
if ( after_size - before_size != 0 )
{
@ -9289,7 +9328,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
case REAL_RESULT:
case TIME_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
if (isUpdateOrDeleteStatement(gwi.thd->lex->sql_command))
{ }
else
{
@ -9321,7 +9360,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
case Item::NULL_ITEM:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) )
if (isUpdateOrDeleteStatement(gwi.thd->lex->sql_command))
{ }
else
{