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

MCOL-4264 [Cross-Engine] UPDATE to INNODB table with WHERE clause using Columnstore as sub query failing

Problem:

When processing cross-engine queries like:

update cstab1 set a=100 where a not in (select a from innotab1 where a=11);
delete from innotab1  where a not in (select a from cstab1 where a=1);

the ColumnStore plugin erroneously executed the whole query inside
ColumnStore.

Fix:

- Adding a new member cal_connection_info::lock_type and setting it
  inside ha_mcs_impl_external_lock() to the value passed in the parameter
  "lock_type".

- Adding a method cal_connection_info::isReadOnly() to test
  if the last table lock made in ha_mcs_impl_external_lock()
  for done for reading.

- Adding a new condition checking cal_connection_info::isReadOnly() inside
  ha_mcs_impl_rnd_init(). If the current table was locked last time for reading,
  then doUpdateDelete() should not be executed.
This commit is contained in:
Alexander Barkov
2020-09-08 07:06:52 +04:00
parent 94c45d00ba
commit f00cc571b5
2 changed files with 22 additions and 3 deletions

View File

@ -2348,8 +2348,19 @@ int ha_mcs_impl_rnd_init(TABLE* table, const std::vector<COND*>& condStack)
return 0;
}
//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))
/*
Update and delete code.
Note, we may be updating/deleting a different table,
and the current one is only needed for reading,
e.g. cstab1 is needed for reading in this example:
UPDATE innotab1 SET a=100 WHERE a NOT IN (SELECT a FROM cstab1 WHERE a=1);
*/
if (!ci->isReadOnly() && // make sure the current table is being modified
(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, condStack);
uint32_t sessionID = tid2sid(thd->thread_id);
@ -4079,6 +4090,7 @@ int ha_mcs_impl_external_lock(THD* thd, TABLE* table, int lock_type)
return 0;
}
ci->lock_type= lock_type;
CalTableMap::iterator mapiter = ci->tableMap.find(table);
// make sure this is a release lock (2nd) call called in

View File

@ -262,7 +262,8 @@ struct cal_connection_info
utf8(false),
useCpimport(1),
delimiter('\7'),
affectedRows(0)
affectedRows(0),
lock_type(F_UNLCK)
{
// check if this is a slave mysql daemon
isSlaveNode = checkSlave();
@ -285,6 +286,11 @@ struct cal_connection_info
return true;
}
bool isReadOnly() const
{
return lock_type == F_RDLCK;
}
sm::cpsm_conhdl_t* cal_conn_hndl;
std::stack<sm::cpsm_conhdl_t*> cal_conn_hndl_st;
int queryState;
@ -335,6 +341,7 @@ struct cal_connection_info
// MCOL-1101 remove compilation unit variable rmParms
std::vector <execplan::RMParam> rmParms;
long long affectedRows;
int lock_type;
};
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).";