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
Merge pull request #1117 from drrtuy/MCOL-3828_1_4
MCOL-3828 This commit replaces the method that calls JOIN::optimise()
This commit is contained in:
committed by
Patrick LeBlanc
parent
1e9946e23a
commit
3d5d113a84
@ -1196,7 +1196,7 @@ vector<string> getOnUpdateTimestampColumns(string& schema, string& tableName, in
|
|||||||
|
|
||||||
uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
||||||
{
|
{
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -2009,7 +2009,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete ci->dmlProc;
|
delete ci->dmlProc;
|
||||||
ci->dmlProc = NULL;
|
ci->dmlProc = nullptr;
|
||||||
ci->dmlProc = new MessageQueueClient("DMLProc");
|
ci->dmlProc = new MessageQueueClient("DMLProc");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2069,7 +2069,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
|||||||
//cout << "line 1442. received 0 byte from DMLProc and retry = "<< retry << endl;
|
//cout << "line 1442. received 0 byte from DMLProc and retry = "<< retry << endl;
|
||||||
// Seems dmlProc isn't playing. Reset it and try again.
|
// Seems dmlProc isn't playing. Reset it and try again.
|
||||||
delete ci->dmlProc;
|
delete ci->dmlProc;
|
||||||
ci->dmlProc = NULL;
|
ci->dmlProc = nullptr;
|
||||||
isTimeOut = true; //@Bug 4742
|
isTimeOut = true; //@Bug 4742
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2117,7 +2117,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
|||||||
cout << ex.what() << endl;
|
cout << ex.what() << endl;
|
||||||
b = 1;
|
b = 1;
|
||||||
delete ci->dmlProc;
|
delete ci->dmlProc;
|
||||||
ci->dmlProc = NULL;
|
ci->dmlProc = nullptr;
|
||||||
errorMsg = ex.what();
|
errorMsg = ex.what();
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
@ -2125,7 +2125,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
|||||||
//cout << "... exception while writing to DMLProc" << endl;
|
//cout << "... exception while writing to DMLProc" << endl;
|
||||||
b = 1;
|
b = 1;
|
||||||
delete ci->dmlProc;
|
delete ci->dmlProc;
|
||||||
ci->dmlProc = NULL;
|
ci->dmlProc = nullptr;
|
||||||
errorMsg = "Unknown error caught";
|
errorMsg = "Unknown error caught";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2189,7 +2189,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
|||||||
errorMsg = "Lost connection to DMLProc";
|
errorMsg = "Lost connection to DMLProc";
|
||||||
b = 1;
|
b = 1;
|
||||||
delete ci->dmlProc;
|
delete ci->dmlProc;
|
||||||
ci->dmlProc = NULL;
|
ci->dmlProc = nullptr;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
@ -2247,7 +2247,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete ci->dmlProc;
|
delete ci->dmlProc;
|
||||||
ci->dmlProc = NULL;
|
ci->dmlProc = nullptr;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2375,7 +2375,7 @@ int ha_mcs_impl_rnd_init(TABLE* table)
|
|||||||
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
||||||
csc->identity(CalpontSystemCatalog::FE);
|
csc->identity(CalpontSystemCatalog::FE);
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
idbassert(ci != 0);
|
idbassert(ci != 0);
|
||||||
@ -2581,7 +2581,7 @@ int ha_mcs_impl_rnd_init(TABLE* table)
|
|||||||
ti = ci->tableMap[table];
|
ti = ci->tableMap[table];
|
||||||
ti.msTablePtr = table;
|
ti.msTablePtr = table;
|
||||||
|
|
||||||
if (ti.tpl_ctx == 0)
|
if (ti.tpl_ctx == nullptr)
|
||||||
{
|
{
|
||||||
ti.tpl_ctx = new sm::cpsm_tplh_t();
|
ti.tpl_ctx = new sm::cpsm_tplh_t();
|
||||||
ti.tpl_scan_ctx = sm::sp_cpsm_tplsch_t(new sm::cpsm_tplsch_t());
|
ti.tpl_scan_ctx = sm::sp_cpsm_tplsch_t(new sm::cpsm_tplsch_t());
|
||||||
@ -2589,7 +2589,7 @@ int ha_mcs_impl_rnd_init(TABLE* table)
|
|||||||
|
|
||||||
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
||||||
// call rnd_init for a table more than once.
|
// call rnd_init for a table more than once.
|
||||||
ti.tpl_scan_ctx->rowGroup = NULL;
|
ti.tpl_scan_ctx->rowGroup = nullptr;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -2707,7 +2707,7 @@ int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table)
|
|||||||
// if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
|
// if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
|
||||||
// return HA_ERR_END_OF_FILE;
|
// return HA_ERR_END_OF_FILE;
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
// @bug 3078
|
// @bug 3078
|
||||||
@ -2772,7 +2772,7 @@ int ha_mcs_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
THD* thd = current_thd;
|
THD* thd = current_thd;
|
||||||
cal_connection_info* ci = NULL;
|
cal_connection_info* ci = nullptr;
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() != NULL)
|
if (get_fe_conn_info_ptr() != NULL)
|
||||||
ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -2911,7 +2911,7 @@ int ha_mcs_impl_create(const char* name, TABLE* table_arg, HA_CREATE_INFO* creat
|
|||||||
{
|
{
|
||||||
THD* thd = current_thd;
|
THD* thd = current_thd;
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -2940,7 +2940,7 @@ int ha_mcs_impl_create(const char* name, TABLE* table_arg, HA_CREATE_INFO* creat
|
|||||||
int ha_mcs_impl_delete_table(const char* name)
|
int ha_mcs_impl_delete_table(const char* name)
|
||||||
{
|
{
|
||||||
THD* thd = current_thd;
|
THD* thd = current_thd;
|
||||||
char* dbName = NULL;
|
char* dbName = nullptr;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
@ -2951,7 +2951,7 @@ int ha_mcs_impl_delete_table(const char* name)
|
|||||||
//if this is an InfiniDB tmp table ('#sql*.frm') just leave...
|
//if this is an InfiniDB tmp table ('#sql*.frm') just leave...
|
||||||
if (!memcmp((uchar*)name, tmp_file_prefix, tmp_file_prefix_length)) return 0;
|
if (!memcmp((uchar*)name, tmp_file_prefix, tmp_file_prefix_length)) return 0;
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3010,7 +3010,7 @@ int ha_mcs_impl_write_row(const uchar* buf, TABLE* table)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3052,7 +3052,7 @@ int ha_mcs_impl_write_row(const uchar* buf, TABLE* table)
|
|||||||
|
|
||||||
int ha_mcs_impl_update_row()
|
int ha_mcs_impl_update_row()
|
||||||
{
|
{
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3066,7 +3066,7 @@ int ha_mcs_impl_update_row()
|
|||||||
|
|
||||||
int ha_mcs_impl_delete_row()
|
int ha_mcs_impl_delete_row()
|
||||||
{
|
{
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3082,7 +3082,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table)
|
|||||||
{
|
{
|
||||||
THD* thd = current_thd;
|
THD* thd = current_thd;
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3295,7 +3295,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table)
|
|||||||
SECURITY_ATTRIBUTES saAttr;
|
SECURITY_ATTRIBUTES saAttr;
|
||||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
saAttr.bInheritHandle = TRUE;
|
saAttr.bInheritHandle = TRUE;
|
||||||
saAttr.lpSecurityDescriptor = NULL;
|
saAttr.lpSecurityDescriptor = nullptr;
|
||||||
HANDLE handleList[2];
|
HANDLE handleList[2];
|
||||||
const char* pSectionMsg;
|
const char* pSectionMsg;
|
||||||
bSuccess = true;
|
bSuccess = true;
|
||||||
@ -3315,7 +3315,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Launch cpimport
|
// Launch cpimport
|
||||||
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList = NULL;
|
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList = nullptr;
|
||||||
SIZE_T attrSize = 0;
|
SIZE_T attrSize = 0;
|
||||||
STARTUPINFOEX siStartInfo;
|
STARTUPINFOEX siStartInfo;
|
||||||
|
|
||||||
@ -3333,7 +3333,7 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table)
|
|||||||
pSectionMsg = "HeapAlloc for AttrList";
|
pSectionMsg = "HeapAlloc for AttrList";
|
||||||
lpAttributeList = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>
|
lpAttributeList = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>
|
||||||
(HeapAlloc(GetProcessHeap(), 0, attrSize));
|
(HeapAlloc(GetProcessHeap(), 0, attrSize));
|
||||||
bSuccess = lpAttributeList != NULL;
|
bSuccess = lpAttributeList != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bSuccess)
|
if (bSuccess)
|
||||||
@ -3368,8 +3368,8 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table)
|
|||||||
memset(&siStartInfo, 0, sizeof(STARTUPINFOEX));
|
memset(&siStartInfo, 0, sizeof(STARTUPINFOEX));
|
||||||
siStartInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
|
siStartInfo.StartupInfo.cb = sizeof(STARTUPINFOEX);
|
||||||
siStartInfo.lpAttributeList = lpAttributeList;
|
siStartInfo.lpAttributeList = lpAttributeList;
|
||||||
siStartInfo.StartupInfo.hStdError = NULL;
|
siStartInfo.StartupInfo.hStdError = nullptr;
|
||||||
siStartInfo.StartupInfo.hStdOutput = NULL;
|
siStartInfo.StartupInfo.hStdOutput = nullptr;
|
||||||
siStartInfo.StartupInfo.hStdInput = ci->cpimport_stdin_Rd;
|
siStartInfo.StartupInfo.hStdInput = ci->cpimport_stdin_Rd;
|
||||||
siStartInfo.StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
siStartInfo.StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
|
||||||
// Create the child process.
|
// Create the child process.
|
||||||
@ -3598,7 +3598,7 @@ int ha_mcs_impl_end_bulk_insert(bool abort, TABLE* table)
|
|||||||
|
|
||||||
std::string aTmpDir(startup::StartUp::tmpDir());
|
std::string aTmpDir(startup::StartUp::tmpDir());
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3826,7 +3826,7 @@ int ha_mcs_impl_end_bulk_insert(bool abort, TABLE* table)
|
|||||||
|
|
||||||
int ha_mcs_impl_commit (handlerton* hton, THD* thd, bool all)
|
int ha_mcs_impl_commit (handlerton* hton, THD* thd, bool all)
|
||||||
{
|
{
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3858,7 +3858,7 @@ int ha_mcs_impl_commit (handlerton* hton, THD* thd, bool all)
|
|||||||
|
|
||||||
int ha_mcs_impl_rollback (handlerton* hton, THD* thd, bool all)
|
int ha_mcs_impl_rollback (handlerton* hton, THD* thd, bool all)
|
||||||
{
|
{
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3892,7 +3892,7 @@ int ha_mcs_impl_close_connection (handlerton* hton, THD* thd)
|
|||||||
// from vtable(lock_type = 2)
|
// from vtable(lock_type = 2)
|
||||||
// An ugly way. I will use ha_data w/o external_lock.
|
// An ugly way. I will use ha_data w/o external_lock.
|
||||||
// This in MCOL-2178
|
// This in MCOL-2178
|
||||||
cal_connection_info* ci = NULL;
|
cal_connection_info* ci = nullptr;
|
||||||
if(thd_get_ha_data(thd, hton) != (void*)0x42) // 0x42 is the magic CS sets when setup hton
|
if(thd_get_ha_data(thd, hton) != (void*)0x42) // 0x42 is the magic CS sets when setup hton
|
||||||
{
|
{
|
||||||
ci = reinterpret_cast<cal_connection_info*>(thd_get_ha_data(thd, hton));
|
ci = reinterpret_cast<cal_connection_info*>(thd_get_ha_data(thd, hton));
|
||||||
@ -3906,7 +3906,7 @@ int ha_mcs_impl_close_connection (handlerton* hton, THD* thd)
|
|||||||
{
|
{
|
||||||
rc = ha_mcs_impl_close_connection_(hton, thd, *ci);
|
rc = ha_mcs_impl_close_connection_(hton, thd, *ci);
|
||||||
delete ci->dmlProc;
|
delete ci->dmlProc;
|
||||||
ci->dmlProc = NULL;
|
ci->dmlProc = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ci->cal_conn_hndl)
|
if (ci->cal_conn_hndl)
|
||||||
@ -3915,7 +3915,7 @@ int ha_mcs_impl_close_connection (handlerton* hton, THD* thd)
|
|||||||
ci->cal_conn_hndl = 0;
|
ci->cal_conn_hndl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
thd_set_ha_data(thd, hton, NULL);
|
thd_set_ha_data(thd, hton, nullptr);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -3924,7 +3924,7 @@ int ha_mcs_impl_rename_table(const char* from, const char* to)
|
|||||||
{
|
{
|
||||||
IDEBUG( cout << "ha_mcs_impl_rename_table: " << from << " => " << to << endl );
|
IDEBUG( cout << "ha_mcs_impl_rename_table: " << from << " => " << to << endl );
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -3967,7 +3967,7 @@ COND* ha_mcs_impl_cond_push(COND* cond, TABLE* table)
|
|||||||
alias.assign(table->alias.ptr(), table->alias.length());
|
alias.assign(table->alias.ptr(), table->alias.length());
|
||||||
IDEBUG( cout << "ha_mcs_impl_cond_push: " << alias << endl );
|
IDEBUG( cout << "ha_mcs_impl_cond_push: " << alias << endl );
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -4006,7 +4006,7 @@ COND* ha_mcs_impl_cond_push(COND* cond, TABLE* table)
|
|||||||
if (ti.condInfo)
|
if (ti.condInfo)
|
||||||
{
|
{
|
||||||
delete ti.condInfo;
|
delete ti.condInfo;
|
||||||
ti.condInfo = 0;
|
ti.condInfo = nullptr;
|
||||||
ci->tableMap[table] = ti;
|
ci->tableMap[table] = ti;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4019,7 +4019,7 @@ COND* ha_mcs_impl_cond_push(COND* cond, TABLE* table)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4042,7 +4042,7 @@ int ha_mcs_impl_external_lock(THD* thd, TABLE* table, int lock_type)
|
|||||||
alias.assign(table->alias.ptr(), table->alias.length());
|
alias.assign(table->alias.ptr(), table->alias.length());
|
||||||
IDEBUG( cout << "external_lock for " << alias << endl );
|
IDEBUG( cout << "external_lock for " << alias << endl );
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -4059,7 +4059,9 @@ int ha_mcs_impl_external_lock(THD* thd, TABLE* table, int lock_type)
|
|||||||
CalTableMap::iterator mapiter = ci->tableMap.find(table);
|
CalTableMap::iterator mapiter = ci->tableMap.find(table);
|
||||||
// make sure this is a release lock (2nd) call called in
|
// make sure this is a release lock (2nd) call called in
|
||||||
// the table mode.
|
// the table mode.
|
||||||
if (mapiter != ci->tableMap.end() && mapiter->second.csep && lock_type == 2)
|
if (mapiter != ci->tableMap.end()
|
||||||
|
&& (mapiter->second.condInfo || mapiter->second.csep)
|
||||||
|
&& lock_type == 2)
|
||||||
{
|
{
|
||||||
// CS ends up processing query with handlers
|
// CS ends up processing query with handlers
|
||||||
// table mode
|
// table mode
|
||||||
@ -4072,13 +4074,13 @@ int ha_mcs_impl_external_lock(THD* thd, TABLE* table, int lock_type)
|
|||||||
ci->extendedStats = mapiter->second.conn_hndl->extendedStats;
|
ci->extendedStats = mapiter->second.conn_hndl->extendedStats;
|
||||||
ci->miniStats = mapiter->second.conn_hndl->miniStats;
|
ci->miniStats = mapiter->second.conn_hndl->miniStats;
|
||||||
sm::sm_cleanup(mapiter->second.conn_hndl);
|
sm::sm_cleanup(mapiter->second.conn_hndl);
|
||||||
mapiter->second.conn_hndl = 0;
|
mapiter->second.conn_hndl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapiter->second.condInfo)
|
if (mapiter->second.condInfo)
|
||||||
{
|
{
|
||||||
delete mapiter->second.condInfo;
|
delete mapiter->second.condInfo;
|
||||||
mapiter->second.condInfo = 0;
|
mapiter->second.condInfo = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MCOL-2178 Check for tableMap size to set this only once.
|
// MCOL-2178 Check for tableMap size to set this only once.
|
||||||
@ -4129,7 +4131,7 @@ int ha_mcs_impl_external_lock(THD* thd, TABLE* table, int lock_type)
|
|||||||
if (tme.second.condInfo)
|
if (tme.second.condInfo)
|
||||||
{
|
{
|
||||||
delete tme.second.condInfo;
|
delete tme.second.condInfo;
|
||||||
tme.second.condInfo= 0;
|
tme.second.condInfo= nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ci->tableMap.clear();
|
ci->tableMap.clear();
|
||||||
@ -4197,7 +4199,7 @@ int ha_mcs_impl_group_by_init(mcs_handler_info *handler_info, TABLE* table)
|
|||||||
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
||||||
csc->identity(CalpontSystemCatalog::FE);
|
csc->identity(CalpontSystemCatalog::FE);
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -4516,7 +4518,7 @@ int ha_mcs_impl_group_by_init(mcs_handler_info *handler_info, TABLE* table)
|
|||||||
|
|
||||||
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
||||||
// call rnd_init for a table more than once.
|
// call rnd_init for a table more than once.
|
||||||
ti.tpl_scan_ctx->rowGroup = NULL;
|
ti.tpl_scan_ctx->rowGroup = nullptr;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -4618,7 +4620,7 @@ int ha_mcs_impl_group_by_next(TABLE* table)
|
|||||||
// if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
|
// if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
|
||||||
// return HA_ERR_END_OF_FILE;
|
// return HA_ERR_END_OF_FILE;
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -4697,7 +4699,7 @@ int ha_mcs_impl_group_by_end(TABLE* table)
|
|||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
THD* thd = current_thd;
|
THD* thd = current_thd;
|
||||||
cal_connection_info* ci = NULL;
|
cal_connection_info* ci = nullptr;
|
||||||
|
|
||||||
if (thd->slave_thread && !get_replication_slave(thd) && (
|
if (thd->slave_thread && !get_replication_slave(thd) && (
|
||||||
thd->lex->sql_command == SQLCOM_INSERT ||
|
thd->lex->sql_command == SQLCOM_INSERT ||
|
||||||
@ -4959,8 +4961,8 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
|
|||||||
sm::cpsm_conhdl_t* hndl;
|
sm::cpsm_conhdl_t* hndl;
|
||||||
SCSEP csep;
|
SCSEP csep;
|
||||||
// Declare handlers ptrs in this scope for future use.
|
// Declare handlers ptrs in this scope for future use.
|
||||||
select_handler* sh = NULL;
|
select_handler* sh = nullptr;
|
||||||
derived_handler* dh = NULL;
|
derived_handler* dh = nullptr;
|
||||||
|
|
||||||
// update traceFlags according to the autoswitch state.
|
// update traceFlags according to the autoswitch state.
|
||||||
ci->traceFlags = (ci->traceFlags | CalpontSelectExecutionPlan::TRACE_TUPLE_OFF)^
|
ci->traceFlags = (ci->traceFlags | CalpontSelectExecutionPlan::TRACE_TUPLE_OFF)^
|
||||||
@ -5234,7 +5236,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
|
|||||||
|
|
||||||
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
||||||
// call rnd_init for a table more than once.
|
// call rnd_init for a table more than once.
|
||||||
ti.tpl_scan_ctx->rowGroup = NULL;
|
ti.tpl_scan_ctx->rowGroup = nullptr;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -5312,7 +5314,7 @@ int ha_cs_impl_select_next(uchar* buf, TABLE* table)
|
|||||||
int rc = HA_ERR_END_OF_FILE;
|
int rc = HA_ERR_END_OF_FILE;
|
||||||
THD* thd = current_thd;
|
THD* thd = current_thd;
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
if (get_fe_conn_info_ptr() == nullptr)
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
|
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
||||||
@ -5363,7 +5365,7 @@ int ha_cs_impl_select_next(uchar* buf, TABLE* table)
|
|||||||
|
|
||||||
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
// make sure rowgroup is null so the new meta data can be taken. This is for some case mysql
|
||||||
// call rnd_init for a table more than once.
|
// call rnd_init for a table more than once.
|
||||||
ti.tpl_scan_ctx->rowGroup = NULL;
|
ti.tpl_scan_ctx->rowGroup = nullptr;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2019 MariaDB Corporation
|
/* Copyright (C) 2019-20 MariaDB Corporation
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
@ -14,6 +14,9 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
MA 02110-1301, USA. */
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
#include "ha_mcs_opt_rewrites.h"
|
#include "ha_mcs_opt_rewrites.h"
|
||||||
|
|
||||||
// Search simplify_joins() function in the server's code for detail
|
// Search simplify_joins() function in the server's code for detail
|
||||||
@ -243,3 +246,87 @@ simplify_joins_mcs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool to
|
|||||||
}
|
}
|
||||||
DBUG_RETURN(conds);
|
DBUG_RETURN(conds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*@brief in_subselect_rewrite_walk - Rewrites Item_in_subselect*/
|
||||||
|
/************************************************************
|
||||||
|
* DESCRIPTION:
|
||||||
|
* It traverses filter predicates searching for
|
||||||
|
* Item_in_subselect and rewrites it adding equi-join predicate
|
||||||
|
* to finalise IN_2_EXISTS rewrite.
|
||||||
|
* PARAMETERS:
|
||||||
|
* item_arg - Item to check.
|
||||||
|
* arg - bool to early return if predicate injection fails.
|
||||||
|
* RETURN:
|
||||||
|
***********************************************************/
|
||||||
|
void in_subselect_rewrite_walk(const Item* item_arg, void* arg)
|
||||||
|
{
|
||||||
|
bool* result= reinterpret_cast<bool*>(arg);
|
||||||
|
if (*result) return;
|
||||||
|
|
||||||
|
Item* item= const_cast<Item*>(item_arg);
|
||||||
|
|
||||||
|
JOIN* join= nullptr;
|
||||||
|
if (typeid(*item) == typeid(Item_in_subselect))
|
||||||
|
{
|
||||||
|
Item_in_subselect* sub= reinterpret_cast<Item_in_subselect*>(item);
|
||||||
|
// MCS 1.4.3 doesn't support IN + subquery with UNION so
|
||||||
|
// we safe to take this JOIN.
|
||||||
|
join= sub->unit->first_select()->join;
|
||||||
|
// Inject equi-JOIN predicates if needed.
|
||||||
|
*result= sub->create_in_to_exists_cond(join);
|
||||||
|
*result= (*result) ? *result :
|
||||||
|
sub->inject_in_to_exists_cond(join);
|
||||||
|
}
|
||||||
|
else if (typeid(*item) == typeid(Item_singlerow_subselect))
|
||||||
|
{
|
||||||
|
Item_singlerow_subselect* sub=
|
||||||
|
reinterpret_cast<Item_singlerow_subselect*>(item);
|
||||||
|
// MCS 1.4.3 doesn't support IN + subquery with UNION so
|
||||||
|
// we safe to take this JOIN.
|
||||||
|
join= sub->unit->first_select()->join;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Exit for any but dedicated Items.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk recursively to process nested IN ops.
|
||||||
|
if (join->conds)
|
||||||
|
{
|
||||||
|
join->conds->traverse_cond(in_subselect_rewrite_walk,
|
||||||
|
arg, Item::POSTFIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@brief in_subselect_rewrite - Rewrites Item_in_subselect*/
|
||||||
|
/************************************************************
|
||||||
|
* DESCRIPTION:
|
||||||
|
* It traverses TABLE_LISTs running in_subselect_rewrite_walk
|
||||||
|
* PARAMETERS:
|
||||||
|
* select_lex
|
||||||
|
* RETURN:
|
||||||
|
* bool to to indicate predicate injection failures.
|
||||||
|
***********************************************************/
|
||||||
|
bool in_subselect_rewrite(SELECT_LEX *select_lex)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
TABLE_LIST *tbl;
|
||||||
|
List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
|
||||||
|
while (!result && (tbl= li++))
|
||||||
|
{
|
||||||
|
if (tbl->is_view_or_derived())
|
||||||
|
{
|
||||||
|
SELECT_LEX *dsl = tbl->derived->first_select();
|
||||||
|
result = in_subselect_rewrite(dsl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (select_lex->join && select_lex->join->conds)
|
||||||
|
{
|
||||||
|
select_lex->join->conds->traverse_cond(in_subselect_rewrite_walk, &result,
|
||||||
|
Item::POSTFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "idb_mysql.h"
|
#include "idb_mysql.h"
|
||||||
|
|
||||||
COND *simplify_joins_mcs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, bool in_sj);
|
COND *simplify_joins_mcs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, bool in_sj);
|
||||||
|
bool in_subselect_rewrite(SELECT_LEX *select_lex);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -42,26 +42,6 @@ void disable_indices_for_CEJ(THD *thd_)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool optimize_unflattened_subqueries_mcs(SELECT_LEX *select_lex)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
TABLE_LIST *tbl;
|
|
||||||
List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
|
|
||||||
while (!result && (tbl= li++))
|
|
||||||
{
|
|
||||||
if (tbl->is_view_or_derived())
|
|
||||||
{
|
|
||||||
SELECT_LEX *dsl = tbl->derived->first_select();
|
|
||||||
result = optimize_unflattened_subqueries_mcs(dsl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = (!result) ?
|
|
||||||
select_lex->optimize_unflattened_subqueries(false) : true;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mutate_optimizer_flags(THD *thd_)
|
void mutate_optimizer_flags(THD *thd_)
|
||||||
{
|
{
|
||||||
// MCOL-2178 Disable all optimizer flags as it was in the fork.
|
// MCOL-2178 Disable all optimizer flags as it was in the fork.
|
||||||
@ -272,7 +252,6 @@ void save_join_predicates(const Item* item, void* arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*@brief check_walk - It traverses filter conditions */
|
/*@brief check_walk - It traverses filter conditions */
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* DESCRIPTION:
|
* DESCRIPTION:
|
||||||
@ -863,18 +842,9 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|
|||||||
COND *conds = nullptr;
|
COND *conds = nullptr;
|
||||||
if (!unsupported_feature)
|
if (!unsupported_feature)
|
||||||
{
|
{
|
||||||
conds = simplify_joins_mcs(join, select_lex->join_list,
|
conds= simplify_joins_mcs(join, select_lex->join_list,
|
||||||
join->conds, TRUE, FALSE);
|
join->conds, TRUE, FALSE);
|
||||||
}
|
}
|
||||||
// MCOL-3747 IN-TO-EXISTS rewrite inside MDB didn't add
|
|
||||||
// an equi-JOIN condition.
|
|
||||||
if (!unsupported_feature
|
|
||||||
&& optimize_unflattened_subqueries_mcs(select_lex))
|
|
||||||
{
|
|
||||||
unsupported_feature = true;
|
|
||||||
handler->err_msg.assign("create_columnstore_select_handler(): \
|
|
||||||
Internal error occured in optimize_unflattened_subqueries_mcs()");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unsupported_feature && conds)
|
if (!unsupported_feature && conds)
|
||||||
{
|
{
|
||||||
@ -883,9 +853,19 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|
|||||||
#endif
|
#endif
|
||||||
join->conds = conds;
|
join->conds = conds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MCOL-3747 IN-TO-EXISTS rewrite inside MDB didn't add
|
||||||
|
// an equi-JOIN condition.
|
||||||
|
if (!unsupported_feature && in_subselect_rewrite(select_lex))
|
||||||
|
{
|
||||||
|
unsupported_feature = true;
|
||||||
|
handler->err_msg.assign("create_columnstore_select_handler(): \
|
||||||
|
Internal error occured in in_subselect_rewrite()");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't raise error now so set an error to raise it later in init_SH.
|
// We shouldn't raise error now so set an error to raise it later in init_SH.
|
||||||
handler->rewrite_error= unsupported_feature;
|
handler->rewrite_error= unsupported_feature;
|
||||||
|
|
||||||
// Return SH even if init fails b/c CS changed SELECT_LEX structures
|
// Return SH even if init fails b/c CS changed SELECT_LEX structures
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2019 MariaDB
|
Copyright (c) 2019-20 MariaDB
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
Reference in New Issue
Block a user