diff --git a/VERSION b/VERSION index b1f5b5380..93054d9c9 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ COLUMNSTORE_VERSION_MAJOR=6 COLUMNSTORE_VERSION_MINOR=4 -COLUMNSTORE_VERSION_PATCH=6 +COLUMNSTORE_VERSION_PATCH=7 COLUMNSTORE_VERSION_RELEASE=1 diff --git a/dbcon/execplan/calpontsystemcatalog.cpp b/dbcon/execplan/calpontsystemcatalog.cpp index 500f78119..5257112af 100644 --- a/dbcon/execplan/calpontsystemcatalog.cpp +++ b/dbcon/execplan/calpontsystemcatalog.cpp @@ -1982,7 +1982,11 @@ CalpontSystemCatalog::CalpontSystemCatalog() : fExeMgr(new ClientRotator(0, "Exe CalpontSystemCatalog::~CalpontSystemCatalog() { - delete fExeMgr; + if (fExeMgr) + { + delete fExeMgr; + fExeMgr = nullptr; + } } #if 0 diff --git a/dbcon/execplan/calpontsystemcatalog.h b/dbcon/execplan/calpontsystemcatalog.h index af03e707b..5be4b023a 100644 --- a/dbcon/execplan/calpontsystemcatalog.h +++ b/dbcon/execplan/calpontsystemcatalog.h @@ -216,6 +216,7 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog uint64_t nextvalue; // next autoincrement value uint32_t charsetNumber; const CHARSET_INFO* cs; + private: long timeZone; @@ -832,9 +833,12 @@ class CalpontSystemCatalog : public datatypes::SystemCatalog /** Destructor */ ~CalpontSystemCatalog(); + // This ctor must be used to produce non-shared CSC that exists for a short period, + // e.g. in client UDFs like calshowpartitions(). + explicit CalpontSystemCatalog(); + private: /** Constuctors */ - explicit CalpontSystemCatalog(); explicit CalpontSystemCatalog(const CalpontSystemCatalog& rhs); CalpontSystemCatalog& operator=(const CalpontSystemCatalog& rhs); diff --git a/dbcon/mysql/ha_mcs_client_udfs.cpp b/dbcon/mysql/ha_mcs_client_udfs.cpp index 904f5486b..481d9c442 100644 --- a/dbcon/mysql/ha_mcs_client_udfs.cpp +++ b/dbcon/mysql/ha_mcs_client_udfs.cpp @@ -38,7 +38,7 @@ using namespace oam; #include "errorids.h" using namespace logging; -//#include "resourcemanager.h" +// #include "resourcemanager.h" #include "columnstoreversion.h" #include "ha_mcs_sysvars.h" @@ -98,7 +98,10 @@ extern "C" boost::algorithm::to_lower(pstr); if (get_fe_conn_info_ptr() == NULL) + { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); idbassert(ci != 0); @@ -197,7 +200,10 @@ extern "C" char* is_null, char* error) { if (get_fe_conn_info_ptr() == NULL) + { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -247,7 +253,10 @@ extern "C" long long calsettrace(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error) { if (get_fe_conn_info_ptr() == NULL) + { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -292,7 +301,7 @@ extern "C" try { - if (dbrm.getSystemReady() > 0 && dbrm.getSystemQueryReady() > 0) + if (dbrm.getSystemReady() > 0 && dbrm.getSystemQueryReady() > 0) { return 1; } @@ -457,7 +466,10 @@ extern "C" THD* thd = current_thd; if (get_fe_conn_info_ptr() == NULL) + { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); execplan::CalpontSystemCatalog::TableName tableName; @@ -534,7 +546,10 @@ extern "C" char* is_null, char* error) { if (get_fe_conn_info_ptr() == NULL) + { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); long long lockID = *reinterpret_cast(args->args[0]); @@ -625,14 +640,12 @@ extern "C" boost::algorithm::to_lower(tableName.table); } - boost::shared_ptr csc = - execplan::CalpontSystemCatalog::makeCalpontSystemCatalog( - execplan::CalpontSystemCatalog::idb_tid2sid(thd->thread_id)); - csc->identity(execplan::CalpontSystemCatalog::FE); + execplan::CalpontSystemCatalog csc; + csc.identity(execplan::CalpontSystemCatalog::FE); try { - nextVal = csc->nextAutoIncrValue(tableName); + nextVal = csc.nextAutoIncrValue(tableName); } catch (std::exception&) { @@ -717,7 +730,10 @@ extern "C" } if (get_fe_conn_info_ptr() == NULL) + { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -810,7 +826,10 @@ extern "C" char* is_null, char* error) { if (get_fe_conn_info_ptr() == NULL) + { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); idbassert(ci != 0); diff --git a/dbcon/mysql/ha_mcs_ddl.cpp b/dbcon/mysql/ha_mcs_ddl.cpp index 54ee97a17..2d18688fc 100644 --- a/dbcon/mysql/ha_mcs_ddl.cpp +++ b/dbcon/mysql/ha_mcs_ddl.cpp @@ -52,6 +52,7 @@ using namespace boost; #include "ha_mcs_sysvars.h" #include "idb_mysql.h" +#include "ha_mcs.h" #include "ha_mcs_impl_if.h" using namespace cal_impl_if; @@ -775,8 +776,10 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl int rc = 0; parser.Parse(ddlStatement.c_str()); - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index 344cb4566..55f6de406 100644 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -1885,8 +1885,10 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip) } } - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } if (ifp->functype() == Item_func::BETWEEN) { @@ -2784,8 +2786,10 @@ void setError(THD* thd, uint32_t errcode, string errmsg) thd->raise_error_printf(errcode, errmsg.c_str()); // reset expressionID - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); ci->expressionId = 0; @@ -3557,8 +3561,10 @@ ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupp ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport) { - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -3818,8 +3824,10 @@ ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& nonSupport, bool selectBetweenIn) { - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -4416,8 +4424,10 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonSupport) { - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -4842,8 +4852,10 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi) vector orderCols; ConstArgParam constArgParam; - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); diff --git a/dbcon/mysql/ha_mcs_impl.cpp b/dbcon/mysql/ha_mcs_impl.cpp index 9e7292949..baa808e5e 100644 --- a/dbcon/mysql/ha_mcs_impl.cpp +++ b/dbcon/mysql/ha_mcs_impl.cpp @@ -775,8 +775,10 @@ vector getOnUpdateTimestampColumns(string& schema, string& tableName, in uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& condStack) { - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2072,8 +2074,10 @@ int ha_mcs_impl_analyze(THD* thd, TABLE* table) query.assign(idb_mysql_query_str(thd)); caep->data(query); - if (!get_fe_conn_info_ptr()) + if (!get_fe_conn_info_ptr()) { set_fe_conn_info_ptr(reinterpret_cast(new cal_connection_info(), thd)); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); idbassert(ci != 0); @@ -2268,8 +2272,10 @@ int ha_mcs::impl_rnd_init(TABLE* table, const std::vector& condStack) boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); csc->identity(CalpontSystemCatalog::FE); - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2592,8 +2598,10 @@ int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table, long timeZone) // if (MIGR::infinidb_vtable.impossibleWhereOnUnion) // return HA_ERR_END_OF_FILE; - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2678,6 +2686,7 @@ int ha_mcs_impl_rnd_end(TABLE* table, bool is_pushdown_hand) { set_fe_conn_info_ptr((void*)new cal_connection_info()); ci = reinterpret_cast(get_fe_conn_info_ptr()); + thd_set_ha_data(thd, mcs_hton, ci); } if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) @@ -2775,8 +2784,10 @@ int ha_mcs_impl_create(const char* name, TABLE* table_arg, HA_CREATE_INFO* creat { THD* thd = current_thd; - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2817,8 +2828,10 @@ int ha_mcs_impl_delete_table(const char* name) if (!memcmp((uchar*)name, tmp_file_prefix, tmp_file_prefix_length)) return 0; - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2880,8 +2893,10 @@ int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed, return ER_CHECK_NOT_IMPLEMENTED; } - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -2931,8 +2946,10 @@ int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed, int ha_mcs_impl_update_row() { - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); int rc = ci->rc; @@ -2945,8 +2962,10 @@ int ha_mcs_impl_update_row() int ha_mcs_impl_delete_row() { - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); int rc = ci->rc; @@ -2964,8 +2983,10 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table, bool is_cache_ins if (thd->slave_thread && !get_replication_slave(thd)) return; - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -3518,8 +3539,10 @@ int ha_mcs_impl_end_bulk_insert(bool abort, TABLE* table) std::string aTmpDir(startup::StartUp::tmpDir()); - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -3669,7 +3692,12 @@ int ha_mcs_impl_end_bulk_insert(bool abort, TABLE* table) } else { - ha_mcs_impl::log_this(thd, "End SQL statement with error", logging::LOG_TYPE_DEBUG, + ostringstream oss; + oss << "End SQL statement with error, rc=" << rc + << ", aPid=" << aPid + << ", WIF=" << WIFEXITED(aStatus) + << ", WEXIT=" << WEXITSTATUS(aStatus); + ha_mcs_impl::log_this(thd, oss.str().c_str(), logging::LOG_TYPE_DEBUG, tid2sid(thd->thread_id)); } @@ -3756,8 +3784,10 @@ int ha_mcs_impl_end_bulk_insert(bool abort, TABLE* table) int ha_mcs_impl_commit(handlerton* hton, THD* thd, bool all) { - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -3789,8 +3819,10 @@ int ha_mcs_impl_commit(handlerton* hton, THD* thd, bool all) int ha_mcs_impl_rollback(handlerton* hton, THD* thd, bool all) { - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -3848,6 +3880,10 @@ int ha_mcs_impl_close_connection(handlerton* hton, THD* thd) ci->cal_conn_hndl = 0; } + delete ci; + set_fe_conn_info_ptr(nullptr, thd); + thd_set_ha_data(thd, hton, nullptr); + return rc; } @@ -3855,8 +3891,10 @@ int ha_mcs_impl_rename_table(const char* from, const char* to) { IDEBUG(cout << "ha_mcs_impl_rename_table: " << from << " => " << to << endl); - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -3899,8 +3937,10 @@ COND* ha_mcs_impl_cond_push(COND* cond, TABLE* table, std::vector& condSt alias.assign(table->alias.ptr(), table->alias.length()); IDEBUG(cout << "ha_mcs_impl_cond_push: " << alias << endl); - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -4006,8 +4046,10 @@ int ha_mcs::impl_external_lock(THD* thd, TABLE* table, int lock_type) alias.assign(table->alias.ptr(), table->alias.length()); IDEBUG(cout << "external_lock for " << alias << endl); - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -4169,8 +4211,10 @@ int ha_mcs_impl_group_by_init(mcs_handler_info* handler_info, TABLE* table) boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); csc->identity(CalpontSystemCatalog::FE); - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -4586,8 +4630,10 @@ int ha_mcs_impl_group_by_next(TABLE* table, long timeZone) if (isMCSTableUpdate(thd) || isMCSTableDelete(thd)) return HA_ERR_END_OF_FILE; - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -4667,6 +4713,7 @@ int ha_mcs_impl_group_by_end(TABLE* table) { set_fe_conn_info_ptr((void*)new cal_connection_info()); ci = reinterpret_cast(get_fe_conn_info_ptr()); + thd_set_ha_data(thd, mcs_hton, ci); } if (((thd->lex)->sql_command == SQLCOM_INSERT) || ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT)) @@ -4870,8 +4917,10 @@ int ha_mcs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table) boost::shared_ptr csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); csc->identity(CalpontSystemCatalog::FE); - if (!get_fe_conn_info_ptr()) + if (!get_fe_conn_info_ptr()) { set_fe_conn_info_ptr(reinterpret_cast(new cal_connection_info(), thd)); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -5271,8 +5320,10 @@ int ha_mcs_impl_select_next(uchar* buf, TABLE* table, long timeZone) int rc = HA_ERR_END_OF_FILE; - if (get_fe_conn_info_ptr() == nullptr) + if (get_fe_conn_info_ptr() == nullptr) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); diff --git a/dbcon/mysql/ha_mcs_partition.cpp b/dbcon/mysql/ha_mcs_partition.cpp index c65c79f46..963064ed6 100644 --- a/dbcon/mysql/ha_mcs_partition.cpp +++ b/dbcon/mysql/ha_mcs_partition.cpp @@ -27,7 +27,7 @@ #include #include #include -//#include +// #include #include using namespace std; @@ -378,13 +378,12 @@ void partitionByValue_common(UDF_ARGS* args, // inp try { - boost::shared_ptr csc = - CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); - csc->identity(execplan::CalpontSystemCatalog::FE); + CalpontSystemCatalog csc; + csc.identity(execplan::CalpontSystemCatalog::FE); CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column, lower_case_table_names); - csc->identity(CalpontSystemCatalog::FE); - OID_t oid = csc->lookupOID(tcn); - CalpontSystemCatalog::ColType ct = csc->colType(oid); + csc.identity(CalpontSystemCatalog::FE); + OID_t oid = csc.lookupOID(tcn); + CalpontSystemCatalog::ColType ct = csc.colType(oid); const char* timeZone = current_thd->variables.time_zone->get_name()->ptr(); long timeZoneOffset; dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset); @@ -626,12 +625,11 @@ extern "C" } boost::algorithm::to_lower(column); - boost::shared_ptr csc = - CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); - csc->identity(CalpontSystemCatalog::FE); + CalpontSystemCatalog csc; + csc.identity(CalpontSystemCatalog::FE); CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column, lower_case_table_names); - OID_t oid = csc->lookupOID(tcn); - ct = csc->colType(oid); + OID_t oid = csc.lookupOID(tcn); + ct = csc.colType(oid); if (oid == -1) { @@ -701,7 +699,6 @@ extern "C" else output << "Enabled"; } - // use our own buffer to make sure it fits. initid->ptr = new char[output.str().length() + 1]; memcpy(initid->ptr, output.str().c_str(), output.str().length()); @@ -1294,12 +1291,11 @@ extern "C" } boost::algorithm::to_lower(column); - boost::shared_ptr csc = - CalpontSystemCatalog::makeCalpontSystemCatalog(tid2sid(current_thd->thread_id)); - csc->identity(CalpontSystemCatalog::FE); + CalpontSystemCatalog csc; + csc.identity(CalpontSystemCatalog::FE); CalpontSystemCatalog::TableColName tcn = make_tcn(schema, table, column, lower_case_table_names); - OID_t oid = csc->lookupOID(tcn); - ct = csc->colType(oid); + OID_t oid = csc.lookupOID(tcn); + ct = csc.colType(oid); if (oid == -1) { diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index 4596bf1cf..e25c5f7a0 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -233,12 +233,10 @@ void* get_fe_conn_info_ptr(THD* thd) void set_fe_conn_info_ptr(void* ptr, THD* thd) { - if (current_thd == NULL && thd == NULL) - { - return; - } + if (thd == NULL) thd = current_thd; + if (thd == NULL) return; - THDVAR(current_thd, fe_conn_info_ptr) = (uint64_t)(ptr); + THDVAR(thd, fe_conn_info_ptr) = (uint64_t)(ptr); } ulonglong get_original_optimizer_flags(THD* thd) diff --git a/dbcon/mysql/ha_pseudocolumn.cpp b/dbcon/mysql/ha_pseudocolumn.cpp index 26fb82264..5b1010e82 100644 --- a/dbcon/mysql/ha_pseudocolumn.cpp +++ b/dbcon/mysql/ha_pseudocolumn.cpp @@ -20,6 +20,7 @@ using namespace execplan; #include "functor.h" #include "functor_str.h" +#include "ha_mcs.h" #include "ha_mcs_impl_if.h" #include "ha_mcs_sysvars.h" using namespace cal_impl_if; @@ -53,8 +54,10 @@ void bailout(char* error, const string& funcName) int64_t idblocalpm() { - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -477,8 +480,10 @@ uint32_t isPseudoColumn(string funcName) execplan::ReturnedColumn* buildPseudoColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, uint32_t pseudoType) { - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); diff --git a/dbcon/mysql/ha_window_function.cpp b/dbcon/mysql/ha_window_function.cpp index e94372cea..a30ba0b71 100644 --- a/dbcon/mysql/ha_window_function.cpp +++ b/dbcon/mysql/ha_window_function.cpp @@ -30,6 +30,7 @@ using namespace std; #include "idb_mysql.h" #include "ha_mcs_impl_if.h" #include "ha_mcs_sysvars.h" +#include "ha_mcs.h" #include "arithmeticcolumn.h" #include "arithmeticoperator.h" @@ -95,8 +96,10 @@ WF_FRAME frame(Window_frame_bound::Bound_precedence_type bound, Item* offset) } ReturnedColumn* buildBoundExp(WF_Boundary& bound, SRCP& order, gp_walk_info& gwi) { - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); @@ -302,8 +305,10 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n // String str; // item->print(&str, QT_INFINIDB_NO_QUOTE); // cout << str.c_ptr() << endl; - if (get_fe_conn_info_ptr() == NULL) + if (get_fe_conn_info_ptr() == NULL) { set_fe_conn_info_ptr((void*)new cal_connection_info()); + thd_set_ha_data(current_thd, mcs_hton, get_fe_conn_info_ptr()); + } cal_connection_info* ci = reinterpret_cast(get_fe_conn_info_ptr()); diff --git a/dbcon/mysql/is_columnstore_columns.cpp b/dbcon/mysql/is_columnstore_columns.cpp index 4076bbd1d..c45abdf94 100644 --- a/dbcon/mysql/is_columnstore_columns.cpp +++ b/dbcon/mysql/is_columnstore_columns.cpp @@ -60,15 +60,12 @@ static int is_columnstore_columns_fill(THD* thd, TABLE_LIST* tables, COND* cond) TABLE* table = tables->table; InformationSchemaCond isCond; - boost::shared_ptr systemCatalogPtr = - execplan::CalpontSystemCatalog::makeCalpontSystemCatalog( - execplan::CalpontSystemCatalog::idb_tid2sid(thd->thread_id)); - + execplan::CalpontSystemCatalog csc; const std::vector< std::pair > - catalog_tables = systemCatalogPtr->getTables(); + catalog_tables = csc.getTables(); - systemCatalogPtr->identity(execplan::CalpontSystemCatalog::FE); + csc.identity(execplan::CalpontSystemCatalog::FE); if (cond) { @@ -89,7 +86,7 @@ static int is_columnstore_columns_fill(THD* thd, TABLE_LIST* tables, COND* cond) // So simply ignore the dropped table. try { - column_rid_list = systemCatalogPtr->columnRIDs((*it).second, true, lower_case_table_names); + column_rid_list = csc.columnRIDs((*it).second, true, lower_case_table_names); } catch (IDBExcept& ex) { @@ -105,9 +102,8 @@ static int is_columnstore_columns_fill(THD* thd, TABLE_LIST* tables, COND* cond) for (size_t col_num = 0; col_num < column_rid_list.size(); col_num++) { - execplan::CalpontSystemCatalog::TableColName tcn = - systemCatalogPtr->colName(column_rid_list[col_num].objnum); - execplan::CalpontSystemCatalog::ColType ct = systemCatalogPtr->colType(column_rid_list[col_num].objnum); + execplan::CalpontSystemCatalog::TableColName tcn = csc.colName(column_rid_list[col_num].objnum); + execplan::CalpontSystemCatalog::ColType ct = csc.colType(column_rid_list[col_num].objnum); table->field[0]->store(tcn.schema.c_str(), tcn.schema.length(), cs); table->field[1]->store(tcn.table.c_str(), tcn.table.length(), cs); diff --git a/dbcon/mysql/is_columnstore_tables.cpp b/dbcon/mysql/is_columnstore_tables.cpp index 63b8517cb..0928ac625 100644 --- a/dbcon/mysql/is_columnstore_tables.cpp +++ b/dbcon/mysql/is_columnstore_tables.cpp @@ -47,11 +47,8 @@ static int is_columnstore_tables_fill(THD* thd, TABLE_LIST* tables, COND* cond) TABLE* table = tables->table; InformationSchemaCond isCond; - boost::shared_ptr systemCatalogPtr = - execplan::CalpontSystemCatalog::makeCalpontSystemCatalog( - execplan::CalpontSystemCatalog::idb_tid2sid(thd->thread_id)); - - systemCatalogPtr->identity(execplan::CalpontSystemCatalog::FE); + execplan::CalpontSystemCatalog csc; + csc.identity(execplan::CalpontSystemCatalog::FE); if (cond) { @@ -60,7 +57,7 @@ static int is_columnstore_tables_fill(THD* thd, TABLE_LIST* tables, COND* cond) const std::vector< std::pair > - catalog_tables = systemCatalogPtr->getTables(); + catalog_tables = csc.getTables(); for (std::vector >::const_iterator it = @@ -72,7 +69,7 @@ static int is_columnstore_tables_fill(THD* thd, TABLE_LIST* tables, COND* cond) try { - execplan::CalpontSystemCatalog::TableInfo tb_info = systemCatalogPtr->tableInfo((*it).second); + execplan::CalpontSystemCatalog::TableInfo tb_info = csc.tableInfo((*it).second); std::string create_date = dataconvert::DataConvert::dateToString((*it).second.create_date); table->field[0]->store((*it).second.schema.c_str(), (*it).second.schema.length(), cs); table->field[1]->store((*it).second.table.c_str(), (*it).second.table.length(), cs); @@ -83,7 +80,7 @@ static int is_columnstore_tables_fill(THD* thd, TABLE_LIST* tables, COND* cond) if (tb_info.tablewithautoincr) { table->field[5]->set_notnull(); - table->field[5]->store(systemCatalogPtr->nextAutoIncrValue((*it).second)); + table->field[5]->store(csc.nextAutoIncrValue((*it).second)); } else {