You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-4868 UPDATE on a ColumnStore table containing an IN-subquery
on a non-ColumnStore table does not work. As part of MCOL-4617, we moved the in-to-exists predicate creation and injection from the server into the engine. However, when query with an IN Subquery contains a non-ColumnStore table, the server still performs the in-to-exists predicate transformation for the foreign engine table. This caused ColumnStore's execution plan to contain incorrect WHERE predicates. As a fix, we call mutate_optimizer_flags() for the WRITE lock, in addition to the READ table lock. And in mutate_optimizer_flags(), we change the optimizer flag from OPTIMIZER_SWITCH_IN_TO_EXISTS to OPTIMIZER_SWITCH_MATERIALIZATION.
This commit is contained in:
@ -6546,7 +6546,7 @@ bool isForeignTableUpdate(THD* thd)
|
||||
{
|
||||
LEX* lex = thd->lex;
|
||||
|
||||
if (lex->sql_command != SQLCOM_UPDATE_MULTI)
|
||||
if (!isUpdateStatement(lex->sql_command))
|
||||
return false;
|
||||
|
||||
Item_field* item;
|
||||
@ -6561,6 +6561,40 @@ bool isForeignTableUpdate(THD* thd)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isMCSTableUpdate(THD* thd)
|
||||
{
|
||||
LEX* lex = thd->lex;
|
||||
|
||||
if (!isUpdateStatement(lex->sql_command))
|
||||
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;
|
||||
}
|
||||
|
||||
bool isMCSTableDelete(THD* thd)
|
||||
{
|
||||
LEX* lex = thd->lex;
|
||||
|
||||
if (!isDeleteStatement(lex->sql_command))
|
||||
return false;
|
||||
|
||||
TABLE_LIST* table_ptr = lex->first_select_lex()->get_table_list();
|
||||
|
||||
if (table_ptr && table_ptr->table && isMCSTable(table_ptr->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,
|
||||
@ -6570,7 +6604,7 @@ bool isUpdateHasForeignTable(THD* thd)
|
||||
{
|
||||
LEX* lex = thd->lex;
|
||||
|
||||
if (lex->sql_command != SQLCOM_UPDATE_MULTI)
|
||||
if (!isUpdateStatement(lex->sql_command))
|
||||
return false;
|
||||
|
||||
TABLE_LIST* table_ptr = lex->first_select_lex()->get_table_list();
|
||||
|
Reference in New Issue
Block a user