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

Merge branch 'develop' into mcol-3743

This commit is contained in:
Patrick LeBlanc
2020-04-13 12:49:28 -05:00
committed by GitHub
24 changed files with 442 additions and 202 deletions

View File

@ -272,8 +272,19 @@ void ConstantFilter::setDerivedTable()
fDerivedTable = ""; fDerivedTable = "";
return; return;
} }
for (unsigned i = 0; i < fFilterList.size(); i++)
{
fFilterList[i]->setDerivedTable();
}
fDerivedTable = fCol->derivedTable(); if (!fFilterList.empty())
{
fDerivedTable = fFilterList[0]->derivedTable();
}
else
{
fDerivedTable = "";
}
} }
void ConstantFilter::replaceRealCol(std::vector<SRCP>& derivedColList) void ConstantFilter::replaceRealCol(std::vector<SRCP>& derivedColList)

View File

@ -365,12 +365,18 @@ void GroupConcatAgUM::applyMapping(const boost::shared_array<int>& mapping, cons
// For some reason the rowgroup mapping fcns don't work right in this class. // For some reason the rowgroup mapping fcns don't work right in this class.
for (uint64_t i = 0; i < fRow.getColumnCount(); i++) for (uint64_t i = 0; i < fRow.getColumnCount(); i++)
{ {
if (fRow.getColumnWidth(i) > 8 && if (fRow.getColumnWidth(i) > 8)
(fRow.getColTypes()[i] == execplan::CalpontSystemCatalog::CHAR ||
fRow.getColTypes()[i] == execplan::CalpontSystemCatalog::VARCHAR ||
fRow.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT))
{ {
fRow.setStringField(row.getStringPointer(mapping[i]), row.getStringLength(mapping[i]), i); if (fRow.getColTypes()[i] == execplan::CalpontSystemCatalog::CHAR ||
fRow.getColTypes()[i] == execplan::CalpontSystemCatalog::VARCHAR ||
fRow.getColTypes()[i] == execplan::CalpontSystemCatalog::TEXT)
{
fRow.setStringField(row.getStringPointer(mapping[i]), row.getStringLength(mapping[i]), i);
}
else if (fRow.getColTypes()[i] == execplan::CalpontSystemCatalog::LONGDOUBLE)
{
fRow.setLongDoubleField(row.getLongDoubleField(mapping[i]), i);
}
} }
else else
{ {

View File

@ -1946,7 +1946,6 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
keysAgg.push_back(aggKey); keysAgg.push_back(aggKey);
scaleAgg.push_back(0); scaleAgg.push_back(0);
precisionAgg.push_back(-16); // for connector to skip null check precisionAgg.push_back(-16); // for connector to skip null check
typeAgg.push_back(CalpontSystemCatalog::BIGINT);
if (isUnsigned(typeProj[colProj])) if (isUnsigned(typeProj[colProj]))
{ {

View File

@ -167,6 +167,7 @@ static int columnstore_done_func(void* p)
{ {
DBUG_ENTER("columnstore_done_func"); DBUG_ENTER("columnstore_done_func");
config::Config::deleteInstanceMap();
my_hash_free(&mcs_open_tables); my_hash_free(&mcs_open_tables);
#ifndef _MSC_VER #ifndef _MSC_VER
pthread_mutex_destroy(&mcs_mutex); pthread_mutex_destroy(&mcs_mutex);

View File

@ -6883,7 +6883,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
return -1; return -1;
} }
} }
else else if ( !gwi.fatalParseError )
{ {
Message::Args args; Message::Args args;
args.add(ifp->func_name()); args.add(ifp->func_name());
@ -7478,14 +7478,15 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
if (nonSupportItem) if (nonSupportItem)
{ {
Message::Args args; if (gwi.parseErrorText.length() == 0)
{
if (nonSupportItem->name.length) Message::Args args;
args.add("'" + string(nonSupportItem->name.str) + "'"); if (nonSupportItem->name.length)
else args.add("'" + string(nonSupportItem->name.str) + "'");
args.add(""); else
args.add("");
gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_GROUP_BY, args); gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_GROUP_BY, args);
}
setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText, gwi); setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, gwi.parseErrorText, gwi);
return ER_CHECK_NOT_IMPLEMENTED; return ER_CHECK_NOT_IMPLEMENTED;
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2014 InfiniDB, Inc. /* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2019 MariaDB Corporation Copyright (C) 2019 MariaDB Corporation
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -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, uint64_t rows_changed)
} }
} }
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());
@ -3057,7 +3057,7 @@ int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed)
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());
@ -3071,7 +3071,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());
@ -3087,7 +3087,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());
@ -3300,7 +3300,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;
@ -3320,7 +3320,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;
@ -3338,7 +3338,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)
@ -3373,8 +3373,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.
@ -3603,7 +3603,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());
@ -3831,7 +3831,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());
@ -3863,7 +3863,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());
@ -3897,7 +3897,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));
@ -3911,7 +3911,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)
@ -3927,7 +3927,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());
@ -3970,7 +3970,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());
@ -4009,7 +4009,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;
} }
@ -4022,7 +4022,7 @@ COND* ha_mcs_impl_cond_push(COND* cond, TABLE* table)
} }
else else
{ {
return NULL; return nullptr;
} }
} }
@ -4045,7 +4045,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());
@ -4062,7 +4062,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
@ -4075,13 +4077,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.
@ -4132,7 +4134,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();
@ -4200,7 +4202,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());
@ -4519,7 +4521,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
{ {
@ -4621,7 +4623,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());
@ -4700,7 +4702,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 ||
@ -4962,8 +4964,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)^
@ -5237,7 +5239,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
{ {
@ -5315,7 +5317,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());
@ -5366,7 +5368,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
{ {

View File

@ -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,11 +14,14 @@
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
COND * COND *
simplify_joins_(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, simplify_joins_mcs(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
bool in_sj) bool in_sj)
{ {
TABLE_LIST *table; TABLE_LIST *table;
@ -26,7 +29,7 @@ simplify_joins_(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
TABLE_LIST *prev_table= 0; TABLE_LIST *prev_table= 0;
List_iterator<TABLE_LIST> li(*join_list); List_iterator<TABLE_LIST> li(*join_list);
bool straight_join= MY_TEST(join->select_options & SELECT_STRAIGHT_JOIN); bool straight_join= MY_TEST(join->select_options & SELECT_STRAIGHT_JOIN);
DBUG_ENTER("simplify_joins"); DBUG_ENTER("simplify_joins_mcs");
/* /*
Try to simplify join operations from join_list. Try to simplify join operations from join_list.
@ -54,7 +57,7 @@ simplify_joins_(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
the outer join is converted to an inner join and the outer join is converted to an inner join and
the corresponding on expression is added to E. the corresponding on expression is added to E.
*/ */
expr= simplify_joins_(join, &nested_join->join_list, expr= simplify_joins_mcs(join, &nested_join->join_list,
expr, FALSE, in_sj || table->sj_on_expr); expr, FALSE, in_sj || table->sj_on_expr);
if (!table->prep_on_expr || expr != table->on_expr) if (!table->prep_on_expr || expr != table->on_expr)
@ -67,7 +70,7 @@ simplify_joins_(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
} }
nested_join->used_tables= (table_map) 0; nested_join->used_tables= (table_map) 0;
nested_join->not_null_tables=(table_map) 0; nested_join->not_null_tables=(table_map) 0;
conds= simplify_joins_(join, &nested_join->join_list, conds, top, conds= simplify_joins_mcs(join, &nested_join->join_list, conds, top,
in_sj || table->sj_on_expr); in_sj || table->sj_on_expr);
used_tables= nested_join->used_tables; used_tables= nested_join->used_tables;
not_null_tables= nested_join->not_null_tables; not_null_tables= nested_join->not_null_tables;
@ -241,5 +244,89 @@ simplify_joins_(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top,
li.replace(repl_list); li.replace(repl_list);
} }
} }
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;
} }

View File

@ -20,7 +20,8 @@
#include "idb_mysql.h" #include "idb_mysql.h"
COND *simplify_joins_(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

View File

@ -27,7 +27,7 @@ void disable_indices_for_CEJ(THD *thd_)
TABLE_LIST* global_list; TABLE_LIST* global_list;
for (global_list = thd_->lex->query_tables; global_list; global_list = global_list->next_global) for (global_list = thd_->lex->query_tables; global_list; global_list = global_list->next_global)
{ {
// MCOL-652 - doing this with derived tables can cause bad things to happen // MCOL-652 - doing this with derived tables can cause bad things to happen
if (!global_list->derived) if (!global_list->derived)
{ {
global_list->index_hints= new (thd_->mem_root) List<Index_hint>(); global_list->index_hints= new (thd_->mem_root) List<Index_hint>();
@ -42,26 +42,6 @@ void disable_indices_for_CEJ(THD *thd_)
} }
} }
bool optimize_unflattened_subqueries_(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_(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.
@ -242,7 +222,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:
@ -516,7 +495,7 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived)
//To search for CROSS JOIN-s we use tree invariant //To search for CROSS JOIN-s we use tree invariant
//G(V,E) where [V] = [E]+1 //G(V,E) where [V] = [E]+1
List<Item> join_preds_list; List<Item> join_preds_list;
TABLE_LIST *tl; TABLE_LIST *tl;
for (tl = sl->get_table_list(); !unsupported_feature && tl; tl = tl->next_local) for (tl = sl->get_table_list(); !unsupported_feature && tl; tl = tl->next_local)
{ {
Item_cond* where_icp= 0; Item_cond* where_icp= 0;
@ -756,68 +735,38 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
{ {
ha_columnstore_select_handler* handler = NULL; ha_columnstore_select_handler* handler = NULL;
// MCOL-2178 Disable SP support in the select_handler for now.
// Check the session variable value to enable/disable use of // Check the session variable value to enable/disable use of
// select_handler // select_handler
// Disable processing of select_result_interceptor classes if (!get_select_handler(thd))
// which intercept and transform result set rows. E.g.:
// select a,b into @a1, @a2 from t1;
if (!get_select_handler(thd) || (thd->lex)->sphead ||
((thd->lex)->result &&
!((select_dumpvar *)(thd->lex)->result)->var_list.is_empty()))
{ {
return handler; return handler;
} }
bool unsupported_feature = false; // Disable SP support in the select_handler for now.
if ((thd->lex)->sphead)
{
return handler;
}
// Disable processing of select_result_interceptor classes
// which intercept and transform result set rows. E.g.:
// select a,b into @a1, @a2 from t1;
if (((thd->lex)->result &&
!((select_dumpvar *)(thd->lex)->result)->var_list.is_empty()))
{
return handler;
}
// Select_handler use the short-cut that effectively disables // Select_handler use the short-cut that effectively disables
// INSERT..SELECT, LDI, SELECT..INTO OUTFILE // INSERT..SELECT, LDI, SELECT..INTO OUTFILE
if ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT if ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT
|| (thd->lex)->sql_command == SQLCOM_CREATE_TABLE || (thd->lex)->sql_command == SQLCOM_CREATE_TABLE
|| (thd->lex)->exchange) || (thd->lex)->exchange)
{ {
unsupported_feature = true; return handler;
}
JOIN *join= select_lex->join;
// Next block tries to execute the query using SH very early to fallback
// if execution fails.
if (!unsupported_feature)
{
disable_indices_for_CEJ(thd);
if (select_lex->handle_derived(thd->lex, DT_MERGE))
{
// early quit b/c of the error in handle_derived
return handler;
}
COND *conds = simplify_joins_(join, select_lex->join_list, join->conds, TRUE, FALSE);
// MCOL-3747 IN-TO-EXISTS rewrite inside MDB didn't add
// an equi-JOIN condition.
optimize_unflattened_subqueries_(select_lex);
if (conds)
{
#ifdef DEBUG_WALK_COND
conds->traverse_cond(cal_impl_if::debug_walk, NULL, Item::POSTFIX);
#endif
join->conds = conds;
}
// Impossible HAVING or WHERE
// TODO replace with function call
if (unsupported_feature
|| select_lex->having_value == Item::COND_FALSE
|| select_lex->cond_value == Item::COND_FALSE )
{
unsupported_feature = true;
restore_optimizer_flags(thd);
}
} }
bool unsupported_feature = false;
// Iterate and traverse through the item list and do not create SH // Iterate and traverse through the item list and do not create SH
// if the unsupported (set/get_user_var) functions are present. // if the unsupported (set/get_user_var) functions are present.
TABLE_LIST* table_ptr = select_lex->get_table_list(); TABLE_LIST* table_ptr = select_lex->get_table_list();
@ -830,31 +779,58 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
item_check(item, &unsupported_feature); item_check(item, &unsupported_feature);
if (unsupported_feature) if (unsupported_feature)
{ {
break; return handler;
} }
} }
} }
if (!unsupported_feature) // We apply dedicated rewrites from MDB here so MDB's data structures
// becomes dirty and CS has to raise an error in case of any problem
// or unsupported feature.
handler= new ha_columnstore_select_handler(thd, select_lex);
JOIN *join= select_lex->join;
{ {
handler= new ha_columnstore_select_handler(thd, select_lex); disable_indices_for_CEJ(thd);
mcs_handler_info mhi= mcs_handler_info(reinterpret_cast<void*>(handler), SELECT);
// handler::table is the place for the result set if (select_lex->handle_derived(thd->lex, DT_MERGE))
int rc= 0;
// Skip execution for EXPLAIN queries
if (!thd->lex->describe)
{ {
rc= ha_cs_impl_pushdown_init(&mhi, handler->table); unsupported_feature = true;
handler->err_msg.assign("create_columnstore_select_handler(): \
Internal error occured in SL::handle_derived()");
} }
// Return SH even if init fails b/c CS changed SELECT_LEX structures COND *conds = nullptr;
// with simplify_joins_() if (!unsupported_feature)
if (rc) {
conds= simplify_joins_mcs(join, select_lex->join_list,
join->conds, TRUE, FALSE);
}
if (!unsupported_feature && conds)
{
#ifdef DEBUG_WALK_COND
conds->traverse_cond(cal_impl_if::debug_walk, NULL, Item::POSTFIX);
#endif
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; unsupported_feature = true;
return handler; handler->err_msg.assign("create_columnstore_select_handler(): \
Internal error occured in in_subselect_rewrite()");
}
} }
return NULL; // We shouldn't raise error now so set an error to raise it later in init_SH.
handler->rewrite_error= unsupported_feature;
// Return SH even if init fails b/c CS changed SELECT_LEX structures
// with simplify_joins_mcs()
return handler;
} }
/*********************************************************** /***********************************************************
@ -868,7 +844,8 @@ ha_columnstore_select_handler::ha_columnstore_select_handler(THD *thd,
SELECT_LEX* select_lex) SELECT_LEX* select_lex)
: select_handler(thd, mcs_hton) : select_handler(thd, mcs_hton)
{ {
select = select_lex; select= select_lex;
rewrite_error= false;
} }
/*********************************************************** /***********************************************************
@ -892,10 +869,26 @@ int ha_columnstore_select_handler::init_scan()
{ {
DBUG_ENTER("ha_columnstore_select_handler::init_scan"); DBUG_ENTER("ha_columnstore_select_handler::init_scan");
// Dummy init for SH. Actual init happens in create_SH
// to allow fallback to other handlers if SH fails.
int rc = 0; int rc = 0;
if (!rewrite_error)
{
// handler::table is the place for the result set
// Skip execution for EXPLAIN queries
if (!thd->lex->describe)
{
mcs_handler_info mhi= mcs_handler_info(
reinterpret_cast<void*>(this), SELECT);
rc= ha_cs_impl_pushdown_init(&mhi, this->table);
}
}
else
{
my_printf_error(ER_INTERNAL_ERROR, "%s", MYF(0), err_msg.c_str());
sql_print_error("%s", err_msg.c_str());
rc= ER_INTERNAL_ERROR;
}
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -936,6 +929,3 @@ int ha_columnstore_select_handler::end_scan()
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
void ha_columnstore_select_handler::print_error(int, unsigned long)
{}

View File

@ -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
@ -80,9 +80,9 @@ class ha_mcs_group_by_handler: public group_by_handler
public: public:
ha_mcs_group_by_handler(THD* thd_arg, Query* query); ha_mcs_group_by_handler(THD* thd_arg, Query* query);
~ha_mcs_group_by_handler(); ~ha_mcs_group_by_handler();
int init_scan(); int init_scan() override;
int next_row(); int next_row() override;
int end_scan(); int end_scan() override;
List<Item>* select; List<Item>* select;
TABLE_LIST* table_list; TABLE_LIST* table_list;
@ -114,9 +114,9 @@ private:
public: public:
ha_columnstore_derived_handler(THD* thd_arg, TABLE_LIST *tbl); ha_columnstore_derived_handler(THD* thd_arg, TABLE_LIST *tbl);
~ha_columnstore_derived_handler(); ~ha_columnstore_derived_handler();
int init_scan(); int init_scan() override;
int next_row(); int next_row() override;
int end_scan(); int end_scan() override;
void print_error(int, unsigned long); void print_error(int, unsigned long);
}; };
@ -139,12 +139,13 @@ private:
COLUMNSTORE_SHARE *share; COLUMNSTORE_SHARE *share;
public: public:
bool rewrite_error;
std::string err_msg;
ha_columnstore_select_handler(THD* thd_arg, SELECT_LEX* sel); ha_columnstore_select_handler(THD* thd_arg, SELECT_LEX* sel);
~ha_columnstore_select_handler(); ~ha_columnstore_select_handler();
int init_scan(); int init_scan() override;
int next_row(); int next_row() override;
int end_scan(); int end_scan() override;
void print_error(int, unsigned long);
}; };
#endif #endif

View File

@ -274,13 +274,13 @@
</Cmd42> </Cmd42>
<Cmd43> <Cmd43>
<Name>assignElasticIPAddress</Name> <Name>assignElasticIPAddress</Name>
<Desc1>Assign Amazon Elastic IP Address to a module</Desc1> <Desc1>Assign Amazon Elastic IP Address to a module (deprecated)</Desc1>
<Arg1>Required: Amazon Elastic IP Address</Arg1> <Arg1>Required: Amazon Elastic IP Address</Arg1>
<Arg2>Required: Module Name</Arg2> <Arg2>Required: Module Name</Arg2>
</Cmd43> </Cmd43>
<Cmd44> <Cmd44>
<Name>unassignElasticIPAddress</Name> <Name>unassignElasticIPAddress</Name>
<Desc1>Unassign Amazon Elastic IP Address</Desc1> <Desc1>Unassign Amazon Elastic IP Address (deprecated)</Desc1>
<Arg1>Required: Amazon Elastic IP Address</Arg1> <Arg1>Required: Amazon Elastic IP Address</Arg1>
</Cmd44> </Cmd44>
<Cmd45> <Cmd45>

View File

@ -4,6 +4,15 @@
# #
# pre-uninstall steps for columnstore install # pre-uninstall steps for columnstore install
running_systemd() {
if [ "$(ps --no-headers -o comm 1)" == "systemd" ]; then
echo 0
else
echo 1
fi
}
rpmmode=install rpmmode=install
user=`whoami 2>/dev/null` user=`whoami 2>/dev/null`
@ -28,7 +37,7 @@ columnstore stop > /dev/null 2>&1
# Test we are using systemd # Test we are using systemd
systemctl cat mariadb.service > /dev/null 2>&1 systemctl cat mariadb.service > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
systemctl stop mariadb.service > /dev/null 2>&1 systemctl stop mariadb.service > /dev/null 2>&1
else else
pkill mysqld pkill mysqld

View File

@ -17,6 +17,14 @@
# Short-Description: Start/stop MariaDB Columnstore DW DBMS # Short-Description: Start/stop MariaDB Columnstore DW DBMS
### END INIT INFO ### END INIT INFO
running_systemd() {
if [ "$(ps --no-headers -o comm 1)" == "systemd" ]; then
echo 0
else
echo 1
fi
}
USER=`whoami 2>/dev/null` USER=`whoami 2>/dev/null`
# Source function library. # Source function library.
@ -95,7 +103,7 @@ stop() {
fuser -k 8604/tcp > /dev/null 2>&1 fuser -k 8604/tcp > /dev/null 2>&1
# Test we are using systemd # Test we are using systemd
systemctl cat mariadb.service > /dev/null 2>&1 systemctl cat mariadb.service > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
systemctl stop mariadb.service > /dev/null 2>&1 systemctl stop mariadb.service > /dev/null 2>&1
else else
pkill mysqld pkill mysqld

View File

@ -4,6 +4,15 @@
# #
# Post-install steps for calpont-mysql install # Post-install steps for calpont-mysql install
# check if running systemd
running_systemd() {
if [ "$(ps --no-headers -o comm 1)" == "systemd" ]; then
echo 0
else
echo 1
fi
}
# check log for error # check log for error
checkForError() { checkForError() {
# check for password error # check for password error
@ -13,7 +22,7 @@ checkForError() {
rm -f ${tmpdir}/error.check rm -f ${tmpdir}/error.check
# Test we are using systemd # Test we are using systemd
systemctl cat mariadb.service > /dev/null 2>&1 systemctl cat mariadb.service > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
systemctl stop mariadb.service > /dev/null 2>&1 systemctl stop mariadb.service > /dev/null 2>&1
else else
pkill mysqld pkill mysqld
@ -62,7 +71,7 @@ done
# Restart in the same way that mysqld will be started normally. # Restart in the same way that mysqld will be started normally.
# Test we are using systemd # Test we are using systemd
systemctl cat mariadb.service > /dev/null 2>&1 systemctl cat mariadb.service > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
systemctl stop mariadb.service > /dev/null 2>&1 systemctl stop mariadb.service > /dev/null 2>&1
else else
pkill mysqld pkill mysqld
@ -71,7 +80,7 @@ sleep 2
export MYSQL_OPTS="--skip-grant-tables" export MYSQL_OPTS="--skip-grant-tables"
# Test we are using systemd # Test we are using systemd
systemctl cat mariadb.service > /dev/null 2>&1 systemctl cat mariadb.service > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
systemctl start mariadb.service systemctl start mariadb.service
else else
/usr/bin/mysqld_safe --skip-grant-tables & /usr/bin/mysqld_safe --skip-grant-tables &
@ -87,7 +96,7 @@ if [ $? -ne 0 ]; then
echo "ERROR: Invalid password in .my.cnf, or Columnstore plugin install missing" echo "ERROR: Invalid password in .my.cnf, or Columnstore plugin install missing"
# Test we are using systemd # Test we are using systemd
systemctl cat mariadb.service > /dev/null 2>&1 systemctl cat mariadb.service > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
systemctl stop mariadb.service > /dev/null 2>&1 systemctl stop mariadb.service > /dev/null 2>&1
else else
pkill mysqld pkill mysqld
@ -98,7 +107,7 @@ fi
# Test we are using systemd # Test we are using systemd
systemctl cat mariadb.service > /dev/null 2>&1 systemctl cat mariadb.service > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
systemctl stop mariadb.service > /dev/null 2>&1 systemctl stop mariadb.service > /dev/null 2>&1
else else
pkill mysqld pkill mysqld

View File

@ -65,5 +65,5 @@ install(TARGETS mycnfUpgrade DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-
########### next target ############### ########### next target ###############
install(PROGRAMS quick_installer_single_server.sh quick_installer_multi_server.sh quick_installer_amazon.sh install(PROGRAMS quick_installer_single_server.sh quick_installer_multi_server.sh
DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-platform) DESTINATION ${ENGINE_BINDIR} COMPONENT columnstore-platform)

View File

@ -136,7 +136,7 @@ int main(int argc, char* argv[])
} }
//my.cnf.rpmsave file //my.cnf.rpmsave file
string mycnfsaveFile = "/etc/my.cnf/columnstore.cnf.rpmsave"; string mycnfsaveFile = std::string(MCSMYCNFDIR) + "/columnstore.cnf.rpmsave";
ifstream mycnfsavefile (mycnfsaveFile.c_str()); ifstream mycnfsavefile (mycnfsaveFile.c_str());
if (!mycnfsavefile) if (!mycnfsavefile)

View File

@ -317,7 +317,7 @@ int main(int argc, char* argv[])
cout << " Enter one of the options within [], if available, or" << endl; cout << " Enter one of the options within [], if available, or" << endl;
cout << " Enter a new value" << endl << endl; cout << " Enter a new value" << endl << endl;
cout << endl; cout << endl;
cout << "Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-qa][-port][-i][-sn]" << endl; cout << "Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-port][-i][-sn]" << endl;
cout << " [-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count][-x][-xr]" << endl; cout << " [-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count][-x][-xr]" << endl;
cout << " [-numBlocksPct][-totalUmMemory][-sm-bucket][-sm-region][-sm-id]" << endl; cout << " [-numBlocksPct][-totalUmMemory][-sm-bucket][-sm-region][-sm-id]" << endl;
cout << " [-sm-secret][-sm-endpoint][-sm-cache][-sm-prefix]" << endl; cout << " [-sm-secret][-sm-endpoint][-sm-cache][-sm-prefix]" << endl;
@ -443,11 +443,6 @@ int main(int argc, char* argv[])
multi_server_quick_install = true; multi_server_quick_install = true;
noPrompting = true; noPrompting = true;
} }
else if( string("-qa") == argv[i] )
{
amazon_quick_install = true;
noPrompting = true;
}
else if ( string("-f") == argv[i] ) else if ( string("-f") == argv[i] )
nodeps = "--nodeps"; nodeps = "--nodeps";
else if ( string("-o") == argv[i] ) else if ( string("-o") == argv[i] )
@ -587,7 +582,7 @@ int main(int argc, char* argv[])
else else
{ {
cout << " ERROR: Invalid Argument = " << argv[i] << endl; cout << " ERROR: Invalid Argument = " << argv[i] << endl;
cout << "Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-qa][-port][-i][-sn]" << endl; cout << "Usage: postConfigure [-h][-c][-u][-p][-qs][-qm][-port][-i][-sn]" << endl;
cout << " [-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count][-x][-xr]" << endl; cout << " [-pm-ip-addrs][-um-ip-addrs][-pm-count][-um-count][-x][-xr]" << endl;
cout << " [-numBlocksPct][-totalUmMemory][-sm-bucket][-sm-region][-sm-id]" << endl; cout << " [-numBlocksPct][-totalUmMemory][-sm-bucket][-sm-region][-sm-id]" << endl;
cout << " [-sm-secret][-sm-endpoint][-sm-cache][-sm-prefix]" << endl; cout << " [-sm-secret][-sm-endpoint][-sm-cache][-sm-prefix]" << endl;
@ -1484,6 +1479,7 @@ int main(int argc, char* argv[])
bool amazonInstall = false; bool amazonInstall = false;
string cloud = oam::UnassignedName; string cloud = oam::UnassignedName;
#if 0
if (!multi_server_quick_install) if (!multi_server_quick_install)
{ {
string amazonLog = tmpDir + "/amazon.log"; string amazonLog = tmpDir + "/amazon.log";
@ -1523,6 +1519,7 @@ int main(int argc, char* argv[])
amazonInstall = true; amazonInstall = true;
} }
} }
#endif
try try
{ {

View File

@ -1359,15 +1359,13 @@ ioManager::ioManager(FileBufferMgr& fbm,
go(); go();
} }
void ioManager::buildOidFileName(const BRM::OID_t oid, const uint16_t dbRoot, const uint16_t partNum, const uint32_t segNum, char* file_name) void ioManager::buildOidFileName(const BRM::OID_t oid, uint16_t dbRoot, const uint32_t partNum, const uint16_t segNum, char* file_name)
{ {
if (fFileOp.getFileName(oid, file_name, dbRoot, partNum, segNum) != WriteEngine::NO_ERROR) // when it's a request for the version buffer, the dbroot comes in as 0 for legacy reasons
{ if (dbRoot == 0 && oid < 1000)
file_name[0] = 0; dbRoot = fdbrm.getDBRootOfVBOID(oid);
throw std::runtime_error("fileOp.getFileName failed");
} fFileOp.getFileNameForPrimProc(oid, file_name, dbRoot, partNum, segNum);
//cout << "Oid2Filename o: " << oid << " n: " << file_name << endl;
} }
const int ioManager::localLbidLookup(BRM::LBID_t lbid, const int ioManager::localLbidLookup(BRM::LBID_t lbid,

View File

@ -83,9 +83,9 @@ public:
uint32_t& fileBlockOffset); uint32_t& fileBlockOffset);
void buildOidFileName(const BRM::OID_t oid, void buildOidFileName(const BRM::OID_t oid,
const uint16_t dbRoot, uint16_t dbRoot,
const uint16_t partNum, const uint32_t partNum,
const uint32_t segNum, const uint16_t segNum,
char* file_name); char* file_name);
const uint32_t getExtentRows() const uint32_t getExtentRows()
@ -153,7 +153,6 @@ private:
uint32_t fDecreaseOpenFilesCount; uint32_t fDecreaseOpenFilesCount;
bool fFDCacheTrace; bool fFDCacheTrace;
std::ofstream fFDTraceFile; std::ofstream fFDTraceFile;
}; };
// @bug2631, for remount filesystem by loadBlock() in primitiveserver // @bug2631, for remount filesystem by loadBlock() in primitiveserver

View File

@ -141,6 +141,10 @@ FuncExp::FuncExp()
fFuncMap["instr"] = new Func_instr(); fFuncMap["instr"] = new Func_instr();
fFuncMap["isnull"] = new Func_isnull(false); fFuncMap["isnull"] = new Func_isnull(false);
fFuncMap["isnotnull"] = new Func_isnull(true); fFuncMap["isnotnull"] = new Func_isnull(true);
fFuncMap["istrue"] = new Func_IsTrue();
fFuncMap["isnottrue"] = new Func_IsNotTrue();
fFuncMap["isfalse"] = new Func_IsFalse();
fFuncMap["isnotfalse"] = new Func_IsNotFalse();
fFuncMap["last_day"] = new Func_last_day(); fFuncMap["last_day"] = new Func_last_day();
fFuncMap["lcase"] = new Func_lcase(); //dlh fFuncMap["lcase"] = new Func_lcase(); //dlh
fFuncMap["least"] = new Func_least(); //dlh fFuncMap["least"] = new Func_least(); //dlh

View File

@ -1,4 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc. /* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2020 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
@ -241,6 +242,88 @@ private:
}; };
/** @brief Func_Truth class
*/
class Func_Truth : public Func_Bool
{
public:
Func_Truth(const std::string& funcName, bool a_value, bool a_affirmative) :
Func_Bool(funcName), value(a_value), affirmative(a_affirmative) {}
virtual ~Func_Truth() {}
execplan::CalpontSystemCatalog::ColType operationType(FunctionParm& fp, execplan::CalpontSystemCatalog::ColType& resultType)
{
assert (fp.size() == 1);
return fp[0]->data()->resultType();
}
bool getBoolVal(rowgroup::Row& row,
FunctionParm& fp,
bool& isNull,
execplan::CalpontSystemCatalog::ColType& op_ct)
{
bool val = fp[0]->data()->getBoolVal(row, isNull);
/*
NULL val IS {TRUE, FALSE} --> FALSE
NULL val IS NOT {TRUE, FALSE} --> TRUE
{TRUE, FALSE} val IS {TRUE, FALSE} value --> val == value
{TRUE, FALSE} val IS NOT {TRUE, FALSE} value --> val != value
These cases can be reduced to the following bitwise operation.
*/
bool ret = (isNull & (!affirmative)) | ((!isNull) & (affirmative ^ (value ^ val)));
isNull = false;
return ret;
}
private:
const bool value, affirmative;
};
/** @brief Func_IsTrue class
*/
class Func_IsTrue : public Func_Truth
{
public:
Func_IsTrue() : Func_Truth("istrue", true, true) {}
~Func_IsTrue() {}
};
/** @brief Func_IsNotTrue class
*/
class Func_IsNotTrue : public Func_Truth
{
public:
Func_IsNotTrue() : Func_Truth("isnottrue", true, false) {}
~Func_IsNotTrue() {}
};
/** @brief Func_IsFalse class
*/
class Func_IsFalse : public Func_Truth
{
public:
Func_IsFalse() : Func_Truth("isfalse", false, true) {}
~Func_IsFalse() {}
};
/** @brief Func_IsNotFalse class
*/
class Func_IsNotFalse : public Func_Truth
{
public:
Func_IsNotFalse() : Func_Truth("isnotfalse", false, false) {}
~Func_IsNotFalse() {}
};
} }
#endif #endif

View File

@ -163,6 +163,11 @@ void MessageQueueClient::setup(bool syncProto)
otherEndIPStr = fConfig->getConfig(fOtherEnd, "IPAddr"); otherEndIPStr = fConfig->getConfig(fOtherEnd, "IPAddr");
otherEndPortStr = fConfig->getConfig(fOtherEnd, "Port"); otherEndPortStr = fConfig->getConfig(fOtherEnd, "Port");
if (otherEndIPStr == "unassigned")
{
otherEndIPStr = "0.0.0.0";
}
if (otherEndIPStr.length() == 0) otherEndIPStr = "127.0.0.1"; if (otherEndIPStr.length() == 0) otherEndIPStr = "127.0.0.1";
if (otherEndPortStr.length() == 0 || static_cast<uint16_t>(strtol(otherEndPortStr.c_str(), 0, 0)) == 0) if (otherEndPortStr.length() == 0 || static_cast<uint16_t>(strtol(otherEndPortStr.c_str(), 0, 0)) == 0)

View File

@ -2412,6 +2412,29 @@ int FileOp::oid2FileName( FID fid,
return NO_ERROR; return NO_ERROR;
} }
void FileOp::getFileNameForPrimProc(FID fid,
char* fullFileName,
uint16_t dbRoot,
uint32_t partition,
uint16_t segment) const
{
string dbRootPath = Config::getDBRootByNum(dbRoot);
if (dbRootPath.empty())
{
ostringstream oss;
oss << "(dbroot " << dbRoot << " offline)";
dbRootPath = oss.str();
}
// different filenames for the version buffer files
if (fid < 1000)
snprintf(fullFileName, FILE_NAME_SIZE, "%s/versionbuffer.cdf", dbRootPath.c_str());
else
snprintf(fullFileName, FILE_NAME_SIZE, "%s/%03u.dir/%03u.dir/%03u.dir/%03u.dir/%03u.dir/FILE%03d.cdf",
dbRootPath.c_str(), fid >> 24, (fid & 0x00ff0000) >> 16, (fid & 0x0000ff00) >> 8,
fid & 0x000000ff, partition, segment);
}
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Search for directory path associated with specified OID. * Search for directory path associated with specified OID.

View File

@ -310,6 +310,12 @@ public:
uint32_t partition, uint32_t partition,
uint16_t segment ) const; uint16_t segment ) const;
/* Added for MCOL-3251 */
void getFileNameForPrimProc(FID fid, char* fileName,
uint16_t dbRoot,
uint32_t partition,
uint16_t segment ) const;
/** /**
* @brief Construct directory path for the specified fid (OID), DBRoot, and * @brief Construct directory path for the specified fid (OID), DBRoot, and
* partition number. Directory does not have to exist, nor is it created. * partition number. Directory does not have to exist, nor is it created.