1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

Merge branch 'develop' into MCOL-4841

# Conflicts:
#	exemgr/main.cpp
#	oam/etc/Columnstore.xml.singleserver
#	primitives/primproc/primproc.cpp
This commit is contained in:
david.hall
2022-06-09 10:07:26 -05:00
523 changed files with 32140 additions and 8380 deletions

View File

@ -18,38 +18,42 @@
/*
* $Id$
*/
#include <regex>
#include <string>
#include <boost/algorithm/string.hpp>
#include <utils/loggingcpp/idberrorinfo.h>
bool parseAutoincrementTableComment(std::string comment, uint64_t& startValue, std::string& columnName)
{
algorithm::to_upper(comment);
regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*=[[:space:]]*", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*=[[:space:]]*", std::regex_constants::extended);
bool autoincrement = false;
columnName = "";
boost::match_results<std::string::const_iterator> what;
std::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = comment.begin();
end = comment.end();
boost::match_flag_type flags = boost::match_default;
std::regex_constants::match_flag_type flags = std::regex_constants::match_default;
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
if (what[0].matched)
{
// string params (what[0].first, what[0].second);
string params(&(*(what[0].second)));
std::string params(&(*(what[0].second)));
unsigned i = params.find_first_of(",");
if (i <= params.length())
{
// check whether there is more autoincrement column
string restComment = params.substr(i + 1, params.length());
std::string restComment = params.substr(i + 1, params.length());
start = restComment.begin();
end = restComment.end();
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
if (what[0].matched)
throw runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_INVALID_NUMBER_AUTOINCREMENT));
throw runtime_error(logging::IDBErrorInfo::instance()->errorMsg(ERR_INVALID_NUMBER_AUTOINCREMENT));
}
columnName = params.substr(0, i);
@ -112,25 +116,25 @@ bool parseAutoincrementTableComment(std::string comment, uint64_t& startValue, s
bool parseAutoincrementColumnComment(std::string comment, uint64_t& startValue)
{
algorithm::to_upper(comment);
regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex compat("[[:space:]]*AUTOINCREMENT[[:space:]]*", std::regex_constants::extended);
bool autoincrement = false;
boost::match_results<std::string::const_iterator> what;
std::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = comment.begin();
end = comment.end();
boost::match_flag_type flags = boost::match_default;
std::regex_constants::match_flag_type flags = std::regex_constants::match_default;
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
if (what[0].matched)
{
string params(&(*(what[0].second)));
std::string params(&(*(what[0].second)));
unsigned i = params.find_first_of(",");
if (i <= params.length())
{
string startVal = params.substr(i + 1, params.length());
std::string startVal = params.substr(i + 1, params.length());
// get rid of possible empty space
i = startVal.find_first_not_of(" ");
@ -160,7 +164,7 @@ bool parseAutoincrementColumnComment(std::string comment, uint64_t& startValue)
// (no digits) || (more chars) || (other errors & value = 0)
if ((ep == str) || (*ep != '\0') || (errno != 0))
{
throw runtime_error(IDBErrorInfo::instance()->errorMsg(ERR_INVALID_START_VALUE));
throw runtime_error(logging::IDBErrorInfo::instance()->errorMsg(ERR_INVALID_START_VALUE));
}
}
}
@ -176,4 +180,3 @@ bool parseAutoincrementColumnComment(std::string comment, uint64_t& startValue)
return autoincrement;
}
// vim:ts=4 sw=4:

View File

@ -96,7 +96,7 @@ execplan::ParseTree* ExistsSub::transform()
csep->subType(CalpontSelectExecutionPlan::EXISTS_SUBS);
// gwi for the sub query
gp_walk_info gwi;
gp_walk_info gwi(fGwip.timeZone);
gwi.thd = fGwip.thd;
gwi.subQuery = this;

View File

@ -44,7 +44,7 @@ using namespace execplan;
namespace cal_impl_if
{
void derivedTableOptimization(THD* thd, SCSEP& csep)
void derivedTableOptimization(gp_walk_info* gwip, SCSEP& csep)
{
// @bug5634. replace the unused column with ConstantColumn from derived table column list,
// ExeMgr will not project ConstantColumn. Only count for local derived column.
@ -135,8 +135,7 @@ void derivedTableOptimization(THD* thd, SCSEP& csep)
else
{
cols[i].reset(new ConstantColumn(val));
(reinterpret_cast<ConstantColumn*>(cols[i].get()))
->timeZone(thd->variables.time_zone->get_name()->ptr());
(reinterpret_cast<ConstantColumn*>(cols[i].get()))->timeZone(gwip->timeZone);
}
for (uint j = 0; j < unionColVec.size(); j++)
@ -156,8 +155,7 @@ void derivedTableOptimization(THD* thd, SCSEP& csep)
else
{
unionColVec[j][i].reset(new ConstantColumn(val));
(reinterpret_cast<ConstantColumn*>(unionColVec[j][i].get()))
->timeZone(thd->variables.time_zone->get_name()->ptr());
(reinterpret_cast<ConstantColumn*>(unionColVec[j][i].get()))->timeZone(gwip->timeZone);
}
}
}
@ -173,15 +171,13 @@ void derivedTableOptimization(THD* thd, SCSEP& csep)
if (!cols.empty())
{
cols[0].reset(new ConstantColumn(val));
(reinterpret_cast<ConstantColumn*>(cols[0].get()))
->timeZone(thd->variables.time_zone->get_name()->ptr());
(reinterpret_cast<ConstantColumn*>(cols[0].get()))->timeZone(gwip->timeZone);
nonConstCols.push_back(cols[0]);
for (uint j = 0; j < unionColVec.size(); j++)
{
unionColVec[j][0].reset(new ConstantColumn(val));
(reinterpret_cast<ConstantColumn*>(unionColVec[j][0].get()))
->timeZone(thd->variables.time_zone->get_name()->ptr());
(reinterpret_cast<ConstantColumn*>(unionColVec[j][0].get()))->timeZone(gwip->timeZone);
nonConstUnionColVec[j].push_back(unionColVec[j][0]);
}
}
@ -229,7 +225,7 @@ void derivedTableOptimization(THD* thd, SCSEP& csep)
if (horizontalOptimization && pt)
{
pt->walk(setDerivedTable);
setDerivedFilter(thd, pt, derivedTbFilterMap, derivedTbList);
setDerivedFilter(gwip, pt, derivedTbFilterMap, derivedTbList);
csep->filters(pt);
}
@ -301,7 +297,7 @@ void derivedTableOptimization(THD* thd, SCSEP& csep)
for (uint i = 0; i < csep->subSelectList().size(); i++)
{
SCSEP subselect(boost::dynamic_pointer_cast<CalpontSelectExecutionPlan>(csep->subSelectList()[i]));
derivedTableOptimization(thd, subselect);
derivedTableOptimization(gwip, subselect);
}
}
@ -339,7 +335,7 @@ void setDerivedTable(execplan::ParseTree* n)
}
}
ParseTree* setDerivedFilter(THD* thd, ParseTree*& n, map<string, ParseTree*>& filterMap,
ParseTree* setDerivedFilter(gp_walk_info* gwip, ParseTree*& n, map<string, ParseTree*>& filterMap,
CalpontSelectExecutionPlan::SelectList& derivedTbList)
{
if (!(n->derivedTable().empty()))
@ -381,7 +377,7 @@ ParseTree* setDerivedFilter(THD* thd, ParseTree*& n, map<string, ParseTree*>& fi
int64_t val = 1;
n = new ParseTree(new ConstantColumn(val));
(dynamic_cast<ConstantColumn*>(n->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(n->data()))->timeZone(gwip->timeZone);
}
else
{
@ -397,10 +393,10 @@ ParseTree* setDerivedFilter(THD* thd, ParseTree*& n, map<string, ParseTree*>& fi
ParseTree* rhs = n->right();
if (lhs)
n->left(setDerivedFilter(thd, lhs, filterMap, derivedTbList));
n->left(setDerivedFilter(gwip, lhs, filterMap, derivedTbList));
if (rhs)
n->right(setDerivedFilter(thd, rhs, filterMap, derivedTbList));
n->right(setDerivedFilter(gwip, rhs, filterMap, derivedTbList));
}
}
@ -428,7 +424,7 @@ SCSEP FromSubQuery::transform()
csep->subType(CalpontSelectExecutionPlan::FROM_SUBS);
// gwi for the sub query
gp_walk_info gwi;
gp_walk_info gwi(fGwip.timeZone);
gwi.thd = fGwip.thd;
gwi.subQuery = this;
gwi.viewName = fGwip.viewName;

View File

@ -151,7 +151,7 @@ execplan::ParseTree* InSub::transform()
csep->subType(CalpontSelectExecutionPlan::IN_SUBS);
// gwi for the sub query
gp_walk_info gwi;
gp_walk_info gwi(fGwip.timeZone);
gwi.thd = fGwip.thd;
gwi.subQuery = this;

View File

@ -163,6 +163,8 @@ ha_mcs::ha_mcs(handlerton* hton, TABLE_SHARE* table_arg)
HA_CAN_TABLE_CONDITION_PUSHDOWN | HA_CAN_DIRECT_UPDATE_AND_DELETE)
, m_lock_type(F_UNLCK)
{
const char* timeZone = current_thd->variables.time_zone->get_name()->ptr();
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &time_zone);
}
/**
@ -318,7 +320,7 @@ int ha_mcs::write_row(const uchar* buf)
int rc;
try
{
rc = ha_mcs_impl_write_row(buf, table, rows_changed);
rc = ha_mcs_impl_write_row(buf, table, rows_changed, time_zone);
}
catch (std::runtime_error& e)
{
@ -652,7 +654,7 @@ int ha_mcs::rnd_next(uchar* buf)
int rc;
try
{
rc = ha_mcs_impl_rnd_next(buf, table);
rc = ha_mcs_impl_rnd_next(buf, table, time_zone);
}
catch (std::runtime_error& e)
{

View File

@ -51,6 +51,7 @@ class ha_mcs : public handler
// call on Ubuntu18.
std::vector<COND*> condStack;
int m_lock_type;
long time_zone;
int impl_external_lock(THD* thd, TABLE* table, int lock_type);
int impl_rnd_init(TABLE* table, const std::vector<COND*>& condStack);

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2014 InfiniDB, Inc.
Copyright (C) 2016 MariaDB Corporation
Copyright (C) 2016-2022 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -52,6 +52,8 @@ extern "C"
const char* SetParmsPrelude = "Updated ";
const char* SetParmsError = "Invalid parameter: ";
const char* InvalidParmSize = "Invalid parameter size: Input value cannot be larger than ";
const char* MsgEMIndexSizeInitErrMsg = "mcs_emindex_size() takes no arguments";
const char* MsgEMIndexFreeInitErrMsg = "mcs_emindex_free() takes no arguments";
const size_t Plen = strlen(SetParmsPrelude);
const size_t Elen = strlen(SetParmsError);
@ -66,10 +68,53 @@ extern "C"
return str;
}
my_bool setparms_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count != 2 || args->arg_type[0] != STRING_RESULT || args->arg_type[1] != STRING_RESULT)
{
sprintf(message, "%s() requires two string arguments", funcname);
return 1;
}
initid->max_length = MAXSTRINGLENGTH;
char valuestr[MAXSTRINGLENGTH];
size_t vlen = args->lengths[1];
memcpy(valuestr, args->args[1], vlen--);
for (size_t i = 0; i < vlen; ++i)
if (!isdigit(valuestr[i]))
{
sprintf(message, "%s() second argument must be numeric or end in G, M or K", funcname);
return 1;
}
if (!isdigit(valuestr[vlen]))
{
switch (valuestr[vlen])
{
case 'G':
case 'g':
case 'M':
case 'm':
case 'K':
case 'k':
case '\0': break;
default:
sprintf(message, "%s() second argument must be numeric or end in G, M or K", funcname);
return 1;
}
}
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calsetparms(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
const char* mcssetparms(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
char parameter[MAXSTRINGLENGTH];
@ -135,50 +180,38 @@ extern "C"
return result;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcssetparms_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return setparms_init(initid, args, message, "MCSSETPARMS");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcssetparms_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calsetparms(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
return mcssetparms(initid, args, result, length, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calsetparms_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 2 || args->arg_type[0] != STRING_RESULT || args->arg_type[1] != STRING_RESULT)
{
strcpy(message, "CALSETPARMS() requires two string arguments");
return 1;
}
initid->max_length = MAXSTRINGLENGTH;
char valuestr[MAXSTRINGLENGTH];
size_t vlen = args->lengths[1];
memcpy(valuestr, args->args[1], vlen--);
for (size_t i = 0; i < vlen; ++i)
if (!isdigit(valuestr[i]))
{
strcpy(message, "CALSETPARMS() second argument must be numeric or end in G, M or K");
return 1;
}
if (!isdigit(valuestr[vlen]))
{
switch (valuestr[vlen])
{
case 'G':
case 'g':
case 'M':
case 'm':
case 'K':
case 'k':
case '\0': break;
default:
strcpy(message, "CALSETPARMS() second argument must be numeric or end in G, M or K");
return 1;
}
}
return 0;
return setparms_init(initid, args, message, "CALSETPARMS");
}
#ifdef _MSC_VER
@ -188,10 +221,24 @@ extern "C"
{
}
my_bool getstats_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count != 0)
{
sprintf(message, "%s() takes no arguments", funcname);
return 1;
}
initid->maybe_null = 1;
initid->max_length = 255;
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calgetstats(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
const char* mcsgetstats(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
if (get_fe_conn_info_ptr() == NULL)
@ -215,21 +262,37 @@ extern "C"
return result;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcsgetstats_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return getstats_init(initid, args, message, "MCSGETSTATS");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcsgetstats_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calgetstats(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
return mcsgetstats(initid, args, result, length, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calgetstats_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 0)
{
strcpy(message, "CALGETSTATS() takes no arguments");
return 1;
}
initid->maybe_null = 1;
initid->max_length = 255;
return 0;
return getstats_init(initid, args, message, "CALGETSTATS");
}
#ifdef _MSC_VER
@ -239,10 +302,21 @@ extern "C"
{
}
my_bool settrace_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count != 1 || args->arg_type[0] != INT_RESULT)
{
sprintf(message, "%s() requires one INTEGER argument", funcname);
return 1;
}
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long calsettrace(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
long long mcssettrace(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());
@ -257,18 +331,35 @@ extern "C"
return oldTrace;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcssettrace_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return settrace_init(initid, args, message, "MCSSETTRACE");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcssettrace_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long calsettrace(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
{
return mcssettrace(initid, args, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calsettrace_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 1 || args->arg_type[0] != INT_RESULT)
{
strcpy(message, "CALSETTRACE() requires one INTEGER argument");
return 1;
}
return 0;
return settrace_init(initid, args, message, "CALSETTRACE");
}
#ifdef _MSC_VER
@ -290,7 +381,7 @@ extern "C"
try
{
if (dbrm.getSystemReady() && dbrm.getSystemQueryReady())
if (dbrm.getSystemReady() > 0 && dbrm.getSystemQueryReady() > 0)
{
return 1;
}
@ -414,29 +505,26 @@ extern "C"
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calviewtablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
my_bool viewtablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count == 2 && (args->arg_type[0] != STRING_RESULT || args->arg_type[1] != STRING_RESULT))
{
strcpy(message, "CALVIEWTABLELOCK() requires two string arguments");
sprintf(message, "%s() requires two string arguments", funcname);
return 1;
}
else if ((args->arg_count == 1) && (args->arg_type[0] != STRING_RESULT))
{
strcpy(message, "CALVIEWTABLELOCK() requires one string argument");
sprintf(message, "%s() requires one string argument", funcname);
return 1;
}
else if (args->arg_count > 2)
{
strcpy(message, "CALVIEWTABLELOCK() takes one or two arguments only");
sprintf(message, "%s() takes one or two arguments only", funcname);
return 1;
}
else if (args->arg_count == 0)
{
strcpy(message, "CALVIEWTABLELOCK() requires at least one argument");
sprintf(message, "%s() requires at least one argument", funcname);
return 1;
}
@ -449,7 +537,15 @@ extern "C"
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calviewtablelock(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
my_bool mcsviewtablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return viewtablelock_init(initid, args, message, "MCSVIEWTABLELOCK");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* mcsviewtablelock(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
THD* thd = current_thd;
@ -504,18 +600,39 @@ extern "C"
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void calviewtablelock_deinit(UDF_INIT* initid)
void mcsviewtablelock_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calcleartablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
my_bool calviewtablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return viewtablelock_init(initid, args, message, "CALVIEWTABLELOCK");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calviewtablelock(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
return mcsviewtablelock(initid, args, result, length, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void calviewtablelock_deinit(UDF_INIT* initid)
{
}
my_bool cleartablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if ((args->arg_count != 1) || (args->arg_type[0] != INT_RESULT))
{
strcpy(message, "CALCLEARTABLELOCK() requires one integer argument (the lockID)");
sprintf(message, "%s() requires one integer argument (the lockID)", funcname);
return 1;
}
@ -525,10 +642,19 @@ extern "C"
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calcleartablelock(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
my_bool mcscleartablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return cleartablelock_init(initid, args, message, "MCSCLEARTABLELOCK");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* mcscleartablelock(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
if (get_fe_conn_info_ptr() == NULL)
@ -555,33 +681,54 @@ extern "C"
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void calcleartablelock_deinit(UDF_INIT* initid)
void mcscleartablelock_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool callastinsertid_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
my_bool calcleartablelock_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return cleartablelock_init(initid, args, message, "CALCLEARTABLELOCK");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calcleartablelock(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
return mcscleartablelock(initid, args, result, length, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void calcleartablelock_deinit(UDF_INIT* initid)
{
}
my_bool lastinsertid_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count == 2 && (args->arg_type[0] != STRING_RESULT || args->arg_type[1] != STRING_RESULT))
{
strcpy(message, "CALLASTINSRTID() requires two string arguments");
sprintf(message, "%s() requires two string arguments", funcname);
return 1;
}
else if ((args->arg_count == 1) && (args->arg_type[0] != STRING_RESULT))
{
strcpy(message, "CALLASTINSERTID() requires one string argument");
sprintf(message, "%s() requires one string argument", funcname);
return 1;
}
else if (args->arg_count > 2)
{
strcpy(message, "CALLASTINSERTID() takes one or two arguments only");
sprintf(message, "%s() takes one or two arguments only", funcname);
return 1;
}
else if (args->arg_count == 0)
{
strcpy(message, "CALLASTINSERTID() requires at least one argument");
sprintf(message, "%s() requires at least one argument", funcname);
return 1;
}
@ -591,10 +738,19 @@ extern "C"
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long callastinsertid(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
my_bool mcslastinsertid_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return lastinsertid_init(initid, args, message, "MCSLASTINSERTID");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long mcslastinsertid(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
{
THD* thd = current_thd;
@ -656,6 +812,29 @@ extern "C"
return (nextVal - 1);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcslastinsertid_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool callastinsertid_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return lastinsertid_init(initid, args, message, "CALLASTINSERTID");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long callastinsertid(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
{
return mcslastinsertid(initid, args, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
@ -663,6 +842,40 @@ extern "C"
{
}
my_bool flushcache_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count != 0)
{
sprintf(message, "%s() takes no arguments", funcname);
return 1;
}
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcsflushcache_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long mcsflushcache(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
{
return static_cast<long long>(cacheutils::flushPrimProcCache());
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcsflushcache_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return flushcache_init(initid, args, message, "MCSFLUSHCACHE");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
@ -675,7 +888,7 @@ extern "C"
#endif
long long calflushcache(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
{
return static_cast<long long>(cacheutils::flushPrimProcCache());
return mcsflushcache(initid, args, is_null, error);
}
#ifdef _MSC_VER
@ -683,13 +896,7 @@ extern "C"
#endif
my_bool calflushcache_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 0)
{
strcpy(message, "CALFLUSHCACHE() takes no arguments");
return 1;
}
return 0;
return flushcache_init(initid, args, message, "CALFLUSHCACHE");
}
static const unsigned long TraceSize = 16 * 1024;
@ -700,7 +907,7 @@ extern "C"
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calgettrace(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
const char* mcsgettrace(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
const std::string* msgp;
@ -741,16 +948,13 @@ extern "C"
return msgp->c_str();
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calgettrace_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
my_bool gettrace_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
#if 0
if (args->arg_count != 0)
{
strcpy(message, "CALGETTRACE() takes no arguments");
sprintf(message, "%s() takes no arguments", funcname);
return 1;
}
@ -764,14 +968,57 @@ extern "C"
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void calgettrace_deinit(UDF_INIT* initid)
my_bool mcsgettrace_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return gettrace_init(initid, args, message, "MCSGETTRACE");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcsgettrace_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calgetversion(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
const char* calgettrace(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
return mcsgettrace(initid, args, result, length, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calgettrace_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return gettrace_init(initid, args, message, "CALGETTRACE");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void calgettrace_deinit(UDF_INIT* initid)
{
}
my_bool getversion_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count != 0)
{
sprintf(message, "%s() takes no arguments", funcname);
return 1;
}
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* mcsgetversion(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
std::string version(columnstore_version);
@ -780,18 +1027,36 @@ extern "C"
return result;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcsgetversion_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return getversion_init(initid, args, message, "MCSGETVERSION");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcsgetversion_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calgetversion(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
return mcsgetversion(initid, args, result, length, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calgetversion_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 0)
{
strcpy(message, "CALGETVERSION() takes no arguments");
return 1;
}
return 0;
return getversion_init(initid, args, message, "CALGETVERSION");
}
#ifdef _MSC_VER
@ -801,10 +1066,21 @@ extern "C"
{
}
my_bool getsqlcount_init(UDF_INIT* initid, UDF_ARGS* args, char* message, const char* funcname)
{
if (args->arg_count != 0)
{
sprintf(message, "%s() takes no arguments", funcname);
return 1;
}
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calgetsqlcount(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
const char* mcsgetsqlcount(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
if (get_fe_conn_info_ptr() == NULL)
@ -843,18 +1119,36 @@ extern "C"
return result;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcsgetsqlcount_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
return getstats_init(initid, args, message, "MCSGETSQLCOUNT");
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcsgetsqlcount_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
const char* calgetsqlcount(UDF_INIT* initid, UDF_ARGS* args, char* result, unsigned long* length,
char* is_null, char* error)
{
return mcsgetsqlcount(initid, args, result, length, is_null, error);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool calgetsqlcount_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 0)
{
strcpy(message, "CALGETSQLCOUNT() takes no arguments");
return 1;
}
return 0;
return getstats_init(initid, args, message, "CALGETSQLCOUNT");
}
#ifdef _MSC_VER
@ -864,4 +1158,64 @@ extern "C"
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long mcs_emindex_size(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
{
DBRM dbrm;
return dbrm.EMIndexShmemSize();
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcs_emindex_size_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 0)
{
strcpy(message, MsgEMIndexSizeInitErrMsg);
return 1;
}
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcs_emindex_size_deinit(UDF_INIT* initid)
{
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long mcs_emindex_free(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
{
DBRM dbrm;
return dbrm.EMIndexShmemFree();
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool mcs_emindex_free_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 0)
{
strcpy(message, MsgEMIndexFreeInitErrMsg);
return 1;
}
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void mcs_emindex_free_deinit(UDF_INIT* initid)
{
}
} // extern "C"

View File

@ -29,9 +29,11 @@ class StoreFieldMariaDB : public StoreField
{
Field* m_field;
const CalpontSystemCatalog::ColType& m_type;
long m_timeZone;
public:
StoreFieldMariaDB(Field* f, const CalpontSystemCatalog::ColType& type) : m_field(f), m_type(type)
StoreFieldMariaDB(Field* f, const CalpontSystemCatalog::ColType& type, const long timeZone)
: m_field(f), m_type(type), m_timeZone(timeZone)
{
}
@ -76,8 +78,7 @@ class StoreFieldMariaDB : public StoreField
int store_timestamp(int64_t val) override
{
char tmp[256];
DataConvert::timestampToString(val, tmp, sizeof(tmp), current_thd->variables.time_zone->get_name()->ptr(),
m_type.precision);
DataConvert::timestampToString(val, tmp, sizeof(tmp), m_timeZone, m_type.precision);
return store_string(tmp, strlen(tmp));
}
@ -212,8 +213,10 @@ class WriteBatchFieldMariaDB : public WriteBatchField
Field* m_field;
const CalpontSystemCatalog::ColType& m_type;
uint32_t m_mbmaxlen;
WriteBatchFieldMariaDB(Field* field, const CalpontSystemCatalog::ColType& type, uint32_t mbmaxlen)
: m_field(field), m_type(type), m_mbmaxlen(mbmaxlen)
long m_timeZone;
WriteBatchFieldMariaDB(Field* field, const CalpontSystemCatalog::ColType& type, uint32_t mbmaxlen,
const long timeZone)
: m_field(field), m_type(type), m_mbmaxlen(mbmaxlen), m_timeZone(timeZone)
{
}
size_t ColWriteBatchDate(const uchar* buf, bool nullVal, ColBatchWriter& ci) override
@ -325,7 +328,7 @@ class WriteBatchFieldMariaDB : public WriteBatchField
my_timestamp_from_binary(&tm, buf, m_field->decimals());
MySQLTime time;
gmtSecToMySQLTime(tm.tv_sec, time, current_thd->variables.time_zone->get_name()->ptr());
gmtSecToMySQLTime(tm.tv_sec, time, m_timeZone);
if (!tm.tv_usec)
{
@ -838,4 +841,3 @@ class WriteBatchFieldMariaDB : public WriteBatchField
} // end of namespace datatypes
// vim:ts=2 sw=2:

View File

@ -25,27 +25,19 @@
#include <string>
#include <iostream>
#include <stack>
#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif
#include <fstream>
#include <sstream>
#include <cerrno>
#include <cstring>
#ifdef _MSC_VER
#include <unordered_set>
#else
#include <regex>
#include <tr1/unordered_set>
#endif
#include <utility>
#include <cassert>
using namespace std;
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/tokenizer.hpp>
using namespace boost;
@ -142,16 +134,16 @@ CalpontSystemCatalog::ColDataType convertDataType(const ddlpackage::ColumnType&
int parseCompressionComment(std::string comment)
{
algorithm::to_upper(comment);
regex compat("[[:space:]]*COMPRESSION[[:space:]]*=[[:space:]]*", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex compat("[[:space:]]*COMPRESSION[[:space:]]*=[[:space:]]*", std::regex_constants::extended);
int compressiontype = 0;
boost::match_results<std::string::const_iterator> what;
std::match_results<std::string::const_iterator> what;
std::string::const_iterator start, end;
start = comment.begin();
end = comment.end();
boost::match_flag_type flags = boost::match_default;
std::regex_constants::match_flag_type flags = std::regex_constants::match_default;
if (boost::regex_search(start, end, what, compat, flags))
if (std::regex_search(start, end, what, compat, flags))
{
// Find the pattern, now get the compression type
string compType(&(*(what[0].second)));
@ -649,11 +641,14 @@ bool anyNullInTheColumn(THD* thd, string& schema, string& table, string& columnN
csep.returnedCols(returnedColumnList);
SimpleFilter* sf = new SimpleFilter();
sf->timeZone(thd->variables.time_zone->get_name()->ptr());
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
sf->timeZone(timeZoneOffset);
boost::shared_ptr<Operator> sop(new PredicateOperator("isnull"));
sf->op(sop);
ConstantColumn* rhs = new ConstantColumn("", ConstantColumn::NULLDATA);
rhs->timeZone(thd->variables.time_zone->get_name()->ptr());
rhs->timeZone(timeZoneOffset);
sf->lhs(col[0]->clone());
sf->rhs(rhs);
@ -799,6 +794,10 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
if (valConfig.compare("YES") == 0)
isVarbinaryAllowed = true;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
//@Bug 1771. error out for not supported feature.
if (typeid(stmt) == typeid(CreateTableStatement))
{
@ -901,9 +900,9 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
try
{
convertedVal = colType.convertColumnData(
createTable->fTableDef->fColumns[i]->fDefaultValue->fValue, pushWarning,
thd->variables.time_zone->get_name()->ptr(), false, false, false);
convertedVal =
colType.convertColumnData(createTable->fTableDef->fColumns[i]->fDefaultValue->fValue,
pushWarning, timeZoneOffset, false, false, false);
}
catch (std::exception&)
{
@ -1143,7 +1142,7 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
algorithm::to_lower(alterTable->fTableName->fName);
}
alterTable->fTimeZone.assign(thd->variables.time_zone->get_name()->ptr());
alterTable->setTimeZone(timeZoneOffset);
if (schema.length() == 0)
{
@ -1313,9 +1312,8 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
try
{
convertedVal = colType.convertColumnData(
addColumnPtr->fColumnDef->fDefaultValue->fValue, pushWarning,
thd->variables.time_zone->get_name()->ptr(), false, false, false);
convertedVal = colType.convertColumnData(addColumnPtr->fColumnDef->fDefaultValue->fValue,
pushWarning, timeZoneOffset, false, false, false);
}
catch (std::exception&)
{
@ -1383,10 +1381,10 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
if (comment.length() > 0)
{
//@Bug 3782 This is for synchronization after calonlinealter to use
algorithm::to_upper(comment);
regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", regex_constants::extended);
boost::algorithm::to_upper(comment);
std::regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", std::regex_constants::extended);
if (regex_search(comment, pat))
if (std::regex_search(comment, pat))
{
return 0;
}
@ -1698,9 +1696,8 @@ int ProcessDDLStatement(string& ddlStatement, string& schema, const string& tabl
try
{
convertedVal = colType.convertColumnData(
addColumnsPtr->fColumns[0]->fDefaultValue->fValue, pushWarning,
thd->variables.time_zone->get_name()->ptr(), false, false, false);
convertedVal = colType.convertColumnData(addColumnsPtr->fColumns[0]->fDefaultValue->fValue,
pushWarning, timeZoneOffset, false, false, false);
}
catch (std::exception&)
{
@ -2353,14 +2350,14 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
bool schemaSyncOnly = false;
bool isCreate = true;
regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", regex_constants::extended);
std::regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", std::regex_constants::extended);
if (regex_search(tablecomment, pat))
if (std::regex_search(tablecomment, pat))
{
schemaSyncOnly = true;
pat = createpatstr;
if (!regex_search(stmt, pat))
if (!std::regex_search(stmt, pat))
{
isCreate = false;
}
@ -2390,7 +2387,7 @@ int ha_mcs_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO* crea
pat = alterpatstr;
if (regex_search(stmt, pat))
if (std::regex_search(stmt, pat))
{
ci.isAlter = true;
ci.alterTableState = cal_connection_info::ALTER_FIRST_RENAME;
@ -2802,4 +2799,3 @@ extern "C"
}
}
// vim:ts=4 sw=4:

View File

@ -337,7 +337,10 @@ int doProcessInsertValues(TABLE* table, uint32_t size, cal_connection_info& ci,
pDMLPackage->set_TableName(name);
name = table->s->db.str;
pDMLPackage->set_SchemaName(name);
pDMLPackage->set_TimeZone(thd->variables.time_zone->get_name()->ptr());
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
pDMLPackage->set_TimeZone(timeZoneOffset);
if (thd->lex->sql_command == SQLCOM_INSERT_SELECT)
pDMLPackage->set_isInsertSelect(true);
@ -676,7 +679,8 @@ int ha_mcs_impl_write_row_(const uchar* buf, TABLE* table, cal_connection_info&
}
}
int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci)
int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci,
long timeZone)
{
ByteStream rowData;
int rc = 0;
@ -746,7 +750,7 @@ int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::ca
Field* fieldPtr = table->field[colpos];
uint32_t mbmaxlen =
(fieldPtr->charset() && fieldPtr->charset()->mbmaxlen) ? fieldPtr->charset()->mbmaxlen : 0;
datatypes::WriteBatchFieldMariaDB field(fieldPtr, colType, mbmaxlen);
datatypes::WriteBatchFieldMariaDB field(fieldPtr, colType, mbmaxlen, timeZone);
idbassert(table == table->field[colpos]->table);
buf += h->ColWriteBatch(&field, buf, nullVal, writer);
}
@ -997,4 +1001,3 @@ int ha_mcs_impl_close_connection_(handlerton* hton, THD* thd, cal_connection_inf
return rc;
}
// vim:ts=4 sw=4:

View File

@ -45,7 +45,6 @@ using namespace std;
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/thread.hpp>
#include "errorids.h"
@ -1509,7 +1508,7 @@ uint32_t buildJoin(gp_walk_info& gwi, List<TABLE_LIST>& join_list,
return 0;
}
ParseTree* buildRowPredicate(THD* thd, RowColumn* lhs, RowColumn* rhs, string predicateOp)
ParseTree* buildRowPredicate(gp_walk_info* gwip, RowColumn* lhs, RowColumn* rhs, string predicateOp)
{
PredicateOperator* po = new PredicateOperator(predicateOp);
boost::shared_ptr<Operator> sop(po);
@ -1523,7 +1522,7 @@ ParseTree* buildRowPredicate(THD* thd, RowColumn* lhs, RowColumn* rhs, string pr
ParseTree* pt = new ParseTree(lo);
sop->setOpType(lhs->columnVec()[0]->resultType(), rhs->columnVec()[0]->resultType());
SimpleFilter* sf = new SimpleFilter(sop, lhs->columnVec()[0].get(), rhs->columnVec()[0].get());
sf->timeZone(thd->variables.time_zone->get_name()->ptr());
sf->timeZone(gwip->timeZone);
pt->left(new ParseTree(sf));
for (uint32_t i = 1; i < lhs->columnVec().size(); i++)
@ -1531,7 +1530,7 @@ ParseTree* buildRowPredicate(THD* thd, RowColumn* lhs, RowColumn* rhs, string pr
sop.reset(po->clone());
sop->setOpType(lhs->columnVec()[i]->resultType(), rhs->columnVec()[i]->resultType());
SimpleFilter* sf = new SimpleFilter(sop, lhs->columnVec()[i].get(), rhs->columnVec()[i].get());
sf->timeZone(thd->variables.time_zone->get_name()->ptr());
sf->timeZone(gwip->timeZone);
pt->right(new ParseTree(sf));
if (i + 1 < lhs->columnVec().size())
@ -1551,7 +1550,7 @@ bool buildRowColumnFilter(gp_walk_info* gwip, RowColumn* rhs, RowColumn* lhs, It
{
// (c1,c2,..) = (v1,v2,...) transform to: c1=v1 and c2=v2 and ...
assert(!lhs->columnVec().empty() && lhs->columnVec().size() == rhs->columnVec().size());
gwip->ptWorkStack.push(buildRowPredicate(gwip->thd, rhs, lhs, ifp->func_name()));
gwip->ptWorkStack.push(buildRowPredicate(gwip, rhs, lhs, ifp->func_name()));
}
else if (ifp->functype() == Item_func::IN_FUNC)
{
@ -1595,7 +1594,7 @@ bool buildRowColumnFilter(gp_walk_info* gwip, RowColumn* rhs, RowColumn* lhs, It
RowColumn* vals = dynamic_cast<RowColumn*>(tmpStack.top());
valVec.push_back(vals);
tmpStack.pop();
ParseTree* pt = buildRowPredicate(gwip->thd, columns, vals, predicateOp);
ParseTree* pt = buildRowPredicate(gwip, columns, vals, predicateOp);
while (!tmpStack.empty())
{
@ -1604,7 +1603,7 @@ bool buildRowColumnFilter(gp_walk_info* gwip, RowColumn* rhs, RowColumn* lhs, It
vals = dynamic_cast<RowColumn*>(tmpStack.top());
valVec.push_back(vals);
tmpStack.pop();
pt1->right(buildRowPredicate(gwip->thd, columns->clone(), vals, predicateOp));
pt1->right(buildRowPredicate(gwip, columns->clone(), vals, predicateOp));
pt = pt1;
}
@ -1646,8 +1645,8 @@ bool buildRowColumnFilter(gp_walk_info* gwip, RowColumn* rhs, RowColumn* lhs, It
break;
sop->setOpType(sc->resultType(), valVec[j]->columnVec()[i]->resultType());
cf->pushFilter(new SimpleFilter(sop, sc->clone(), valVec[j]->columnVec()[i]->clone(),
gwip->thd->variables.time_zone->get_name()->ptr()));
cf->pushFilter(
new SimpleFilter(sop, sc->clone(), valVec[j]->columnVec()[i]->clone(), gwip->timeZone));
}
if (j < valVec.size())
@ -1792,7 +1791,7 @@ bool buildEqualityPredicate(execplan::ReturnedColumn* lhs, execplan::ReturnedCol
}
SimpleFilter* sf = new SimpleFilter();
sf->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sf->timeZone(gwip->timeZone);
//@bug 2101 for when there are only constants in a delete or update where clause (eg "where 5 < 6").
// There will be no field column and it will get here only if the comparison is true.
@ -1906,11 +1905,11 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
sop.reset(new PredicateOperator(">"));
sop->setOpType(filterCol->resultType(), rhs->resultType());
sfr = new SimpleFilter(sop, filterCol, rhs);
sfr->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sfr->timeZone(gwip->timeZone);
sop.reset(new PredicateOperator("<"));
sop->setOpType(filterCol->resultType(), lhs->resultType());
sfl = new SimpleFilter(sop, filterCol->clone(), lhs);
sfl->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sfl->timeZone(gwip->timeZone);
ParseTree* ptp = new ParseTree(new LogicOperator("or"));
ptp->left(sfr);
ptp->right(sfl);
@ -1921,11 +1920,11 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
sop.reset(new PredicateOperator("<="));
sop->setOpType(filterCol->resultType(), rhs->resultType());
sfr = new SimpleFilter(sop, filterCol, rhs);
sfr->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sfr->timeZone(gwip->timeZone);
sop.reset(new PredicateOperator(">="));
sop->setOpType(filterCol->resultType(), lhs->resultType());
sfl = new SimpleFilter(sop, filterCol->clone(), lhs);
sfl->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sfl->timeZone(gwip->timeZone);
ParseTree* ptp = new ParseTree(new LogicOperator("and"));
ptp->left(sfr);
ptp->right(sfl);
@ -1985,8 +1984,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
cf->op(sop);
sop.reset(new PredicateOperator(eqop));
sop->setOpType(gwip->scsp->resultType(), lhs->resultType());
cf->pushFilter(
new SimpleFilter(sop, gwip->scsp->clone(), lhs, gwip->thd->variables.time_zone->get_name()->ptr()));
cf->pushFilter(new SimpleFilter(sop, gwip->scsp->clone(), lhs, gwip->timeZone));
while (!gwip->rcWorkStack.empty())
{
@ -1998,8 +1996,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
gwip->rcWorkStack.pop();
sop.reset(new PredicateOperator(eqop));
sop->setOpType(gwip->scsp->resultType(), lhs->resultType());
cf->pushFilter(
new SimpleFilter(sop, gwip->scsp->clone(), lhs, gwip->thd->variables.time_zone->get_name()->ptr()));
cf->pushFilter(new SimpleFilter(sop, gwip->scsp->clone(), lhs, gwip->timeZone));
}
if (!gwip->rcWorkStack.empty())
@ -2065,8 +2062,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
{
gwip->rcWorkStack.push(new ConstantColumn((int64_t)udf->val_int()));
}
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))
->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
}
else
{
@ -2088,8 +2084,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
{
gwip->rcWorkStack.push(new ConstantColumn(buf.ptr(), ConstantColumn::NUM));
}
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))
->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
return false;
}
@ -2265,19 +2260,19 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
SimpleFilter* sfo = 0;
// b IS NULL
ConstantColumn* nlhs1 = new ConstantColumn("", ConstantColumn::NULLDATA);
nlhs1->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
nlhs1->timeZone(gwip->timeZone);
sop.reset(new PredicateOperator("isnull"));
sop->setOpType(lhs->resultType(), rhs->resultType());
sfn1 = new SimpleFilter(sop, rhs, nlhs1);
sfn1->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sfn1->timeZone(gwip->timeZone);
ParseTree* ptpl = new ParseTree(sfn1);
// a IS NULL
ConstantColumn* nlhs2 = new ConstantColumn("", ConstantColumn::NULLDATA);
nlhs2->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
nlhs2->timeZone(gwip->timeZone);
sop.reset(new PredicateOperator("isnull"));
sop->setOpType(lhs->resultType(), rhs->resultType());
sfn2 = new SimpleFilter(sop, lhs, nlhs2);
sfn2->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sfn2->timeZone(gwip->timeZone);
ParseTree* ptpr = new ParseTree(sfn2);
// AND them both
ParseTree* ptpn = new ParseTree(new LogicOperator("and"));
@ -2287,7 +2282,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
sop.reset(new PredicateOperator("="));
sop->setOpType(lhs->resultType(), rhs->resultType());
sfo = new SimpleFilter(sop, lhs->clone(), rhs->clone());
sfo->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sfo->timeZone(gwip->timeZone);
// OR with the NULL comparison tree
ParseTree* ptp = new ParseTree(new LogicOperator("or"));
ptp->left(sfo);
@ -2337,7 +2332,7 @@ bool buildPredicateItem(Item_func* ifp, gp_walk_info* gwip)
bool buildConstPredicate(Item_func* ifp, ReturnedColumn* rhs, gp_walk_info* gwip)
{
SimpleFilter* sf = new SimpleFilter();
sf->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
sf->timeZone(gwip->timeZone);
boost::shared_ptr<Operator> sop(new PredicateOperator(ifp->func_name()));
ConstantColumn* lhs = 0;
@ -2356,7 +2351,7 @@ bool buildConstPredicate(Item_func* ifp, ReturnedColumn* rhs, gp_walk_info* gwip
lhs = new ConstantColumn((int64_t)0, ConstantColumn::NUM);
sop.reset(new PredicateOperator("="));
}
lhs->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
lhs->timeZone(gwip->timeZone);
CalpontSystemCatalog::ColType opType = rhs->resultType();
@ -2431,7 +2426,7 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp)
sc->tableAlias(gwi.tbList[i].alias);
sc->viewName(viewName, lower_case_table_names);
sc->resultType(ct);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
break;
}
}
@ -2490,7 +2485,7 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp)
sc->tableName(csep->derivedTbAlias());
sc->colPosition(j);
sc->tableAlias(csep->derivedTbAlias());
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
if (!viewName.empty())
{
sc->viewName(viewName, lower_case_table_names);
@ -2613,7 +2608,7 @@ void collectAllCols(gp_walk_info& gwi, Item_field* ifp)
sc->tableAlias(csep->derivedTbAlias());
sc->viewName(gwi.tbList[i].view);
sc->resultType(cols[j]->resultType());
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
// @bug5634 derived table optimization
cols[j]->incRefCount();
@ -2661,7 +2656,7 @@ void collectAllCols(gp_walk_info& gwi, Item_field* ifp)
sc->resultType(ct);
sc->tableAlias(gwi.tbList[i].alias, lower_case_table_names);
sc->viewName(viewName, lower_case_table_names);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
srcp.reset(sc);
gwi.returnedCols.push_back(srcp);
gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(sc->columnName(), srcp));
@ -2994,7 +2989,7 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr<CalpontSystemCatalog> csc,
sc->columnName(rc->alias());
sc->sequence(0);
sc->tableAlias(tan.alias);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
sc->derivedTable(csep->derivedTbAlias());
sc->derivedRefCol(rc);
return sc;
@ -3013,7 +3008,7 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr<CalpontSystemCatalog> csc,
tan.fisColumnStore, gwi.sessionid, lower_case_table_names);
sc->tableAlias(table->alias.ptr(), lower_case_table_names);
sc->isColumnStore(false);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
sc->resultType(fieldType_MysqlToIDB(field));
sc->oid(field->field_index + 1);
return sc;
@ -3043,7 +3038,7 @@ SimpleColumn* getSmallestColumn(boost::shared_ptr<CalpontSystemCatalog> csc,
SimpleColumn* sc = new SimpleColumn(tcn.schema, tcn.table, tcn.column, csc->sessionID());
sc->tableAlias(tan.alias);
sc->viewName(tan.view);
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
sc->resultType(csc->colType(oidlist[minWidthColOffset].objnum));
sc->charsetNumber(table->field[minWidthColOffset]->charset()->number);
return sc;
@ -3209,7 +3204,7 @@ ReturnedColumn* buildReturnedColumnNull(gp_walk_info& gwi)
return new SimpleColumn("noop");
ConstantColumn* rc = new ConstantColumnNull();
if (rc)
rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwi.timeZone);
return rc;
}
@ -3346,7 +3341,7 @@ static ConstantColumn* buildConstantColumnMaybeNullFromValStr(const Item* item,
{
ConstantColumn* rc = newConstantColumnMaybeNullFromValStrNoTz(item, valStr, gwi);
if (rc)
rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwi.timeZone);
return rc;
}
@ -3365,7 +3360,7 @@ static ConstantColumn* buildConstantColumnNotNullUsingValNative(Item* item, gp_w
{
ConstantColumn* rc = newConstantColumnNotNullUsingValNativeNoTz(item, gwi);
if (rc)
rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwi.timeZone);
return rc;
}
@ -3565,7 +3560,7 @@ ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool
ArithmeticColumn* ac = new ArithmeticColumn();
Item** sfitempp = item->arguments();
ArithmeticOperator* aop = new ArithmeticOperator(item->func_name());
aop->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
aop->timeZone(gwi.timeZone);
aop->setOverflowCheck(get_decimal_overflow_check(gwi.thd));
ParseTree* pt = new ParseTree(aop);
// ReturnedColumn *lhs = 0, *rhs = 0;
@ -3692,7 +3687,7 @@ ArithmeticColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool
else
{
ConstantColumn* cc = new ConstantColumn(string("0"), (int64_t)0);
cc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
cc->timeZone(gwi.timeZone);
if (gwi.clauseType == SELECT || gwi.clauseType == HAVING || gwi.clauseType == GROUP_BY) // select clause
{
@ -4065,15 +4060,14 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
THD* thd = current_thd;
sptp.reset(
new ParseTree(new ConstantColumn(static_cast<uint64_t>(thd->variables.default_week_format))));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
}
// add the keyword unit argument for interval function
if (funcName == "date_add_interval" || funcName == "extract" || funcName == "timestampdiff")
{
addIntervalArgs(gwi.thd, ifp, funcParms);
addIntervalArgs(&gwi, ifp, funcParms);
}
// check for unsupported arguments add the keyword unit argument for extract functions
@ -4123,19 +4117,19 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
// add the keyword unit argument and char length for cast functions
if (funcName == "cast_as_char")
{
castCharArgs(gwi.thd, ifp, funcParms);
castCharArgs(&gwi, ifp, funcParms);
}
// add the length and scale arguments
if (funcName == "decimal_typecast")
{
castDecimalArgs(gwi.thd, ifp, funcParms);
castDecimalArgs(&gwi, ifp, funcParms);
}
// add the type argument
if (funcName == "get_format")
{
castTypeArgs(gwi.thd, ifp, funcParms);
castTypeArgs(&gwi, ifp, funcParms);
}
// add my_time_zone
@ -4150,8 +4144,7 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
// FIXME: Get GMT offset (in seconds east of GMT) in Windows...
sptp.reset(new ParseTree(new ConstantColumn(static_cast<int64_t>(0), ConstantColumn::NUM)));
#endif
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
}
@ -4161,12 +4154,10 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
if (funcParms.size() == 0)
{
sptp.reset(new ParseTree(new ConstantColumn((int64_t)gwi.thd->rand.seed1, ConstantColumn::NUM)));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
sptp.reset(new ParseTree(new ConstantColumn((int64_t)gwi.thd->rand.seed2, ConstantColumn::NUM)));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
gwi.no_parm_func_list.push_back(fc);
}
@ -4220,8 +4211,7 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
tzinfo = string((char*)buf, length);
}
sptp.reset(new ParseTree(new ConstantColumn(tzinfo)));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
tzinfo.clear();
if (to_tzinfo)
@ -4233,8 +4223,7 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
tzinfo = string((char*)buf, length);
}
sptp.reset(new ParseTree(new ConstantColumn(tzinfo)));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
tzinfo.clear();
}
@ -4253,8 +4242,7 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
sign = -1;
}
sptp.reset(new ParseTree(new ConstantColumn(sign)));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
}
@ -4327,16 +4315,23 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
#endif
fc->operationType(functor->operationType(funcParms, fc->resultType()));
// For some reason, MDB has MYSQL_TYPE_DATETIME2 for functions on a TIMESTAMP
if (fc->operationType().colDataType == CalpontSystemCatalog::TIMESTAMP)
execplan::CalpontSystemCatalog::ColType& resultType = fc->resultType();
resultType.setTimeZone(gwi.timeZone);
fc->operationType(functor->operationType(funcParms, resultType));
// For floor/ceiling/truncate/round functions applied on TIMESTAMP columns, set the
// function result type to TIMESTAMP
if ((funcName == "floor" || funcName == "ceiling" || funcName == "truncate" || funcName == "round") &&
fc->operationType().colDataType == CalpontSystemCatalog::TIMESTAMP)
{
CalpontSystemCatalog::ColType ct = fc->resultType();
ct.colDataType = CalpontSystemCatalog::TIMESTAMP;
ct.colWidth = 8;
fc->resultType(ct);
}
fc->expressionId(ci->expressionId++);
// A few functions use a different collation than that found in
// the base ifp class
if (funcName == "locate" || funcName == "find_in_set" || funcName == "strcmp")
@ -4409,7 +4404,7 @@ ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& non
}
}
fc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
fc->timeZone(gwi.timeZone);
return fc;
}
@ -4549,11 +4544,13 @@ FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonS
Func* functor = funcexp->getFunctor(funcName);
fc->resultType(colType_MysqlToIDB(item));
fc->operationType(functor->operationType(funcParms, fc->resultType()));
execplan::CalpontSystemCatalog::ColType& resultType = fc->resultType();
resultType.setTimeZone(gwi.timeZone);
fc->operationType(functor->operationType(funcParms, resultType));
fc->functionName(funcName);
fc->functionParms(funcParms);
fc->expressionId(ci->expressionId++);
fc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
fc->timeZone(gwi.timeZone);
// For function join. If any argument has non-zero joininfo, set it to the function.
fc->setSimpleColumnList();
@ -4695,7 +4692,7 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi)
sc->alias(ifp->name.str);
sc->isColumnStore(prm.columnStore());
sc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi.timeZone);
if (!prm.columnStore() && ifp->field)
sc->oid(ifp->field->field_index + 1); // ExeMgr requires offset started from 1
@ -4803,7 +4800,7 @@ static void processAggregateColumnConstArg(gp_walk_info& gwi, SRCP& parm, Aggreg
{
// Explicit NULL or a const function that evaluated to NULL
cc = new ConstantColumnNull();
cc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
cc->timeZone(gwi.timeZone);
parm.reset(cc);
ac->constCol(SRCP(rt));
return;
@ -4878,7 +4875,7 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
ac = new AggregateColumn(gwi.sessionid);
}
ac->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
ac->timeZone(gwi.timeZone);
if (isp->name.length)
ac->alias(isp->name.str);
@ -5397,7 +5394,7 @@ because it has multiple arguments.";
return ac;
}
void addIntervalArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
void addIntervalArgs(gp_walk_info* gwip, Item_func* ifp, FunctionParm& functionParms)
{
string funcName = ifp->func_name();
int interval_type = -1;
@ -5409,7 +5406,7 @@ void addIntervalArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
else if (funcName == "extract")
interval_type = ((Item_extract*)ifp)->int_type;
functionParms.push_back(getIntervalType(thd, interval_type));
functionParms.push_back(getIntervalType(gwip, interval_type));
SPTP sptp;
if (funcName == "date_add_interval")
@ -5417,42 +5414,42 @@ void addIntervalArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
if (((Item_date_add_interval*)ifp)->date_sub_interval)
{
sptp.reset(new ParseTree(new ConstantColumn((int64_t)OP_SUB)));
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwip->timeZone);
functionParms.push_back(sptp);
}
else
{
sptp.reset(new ParseTree(new ConstantColumn((int64_t)OP_ADD)));
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwip->timeZone);
functionParms.push_back(sptp);
}
}
}
SPTP getIntervalType(THD* thd, int interval_type)
SPTP getIntervalType(gp_walk_info* gwip, int interval_type)
{
SPTP sptp;
sptp.reset(new ParseTree(new ConstantColumn((int64_t)interval_type)));
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwip->timeZone);
return sptp;
}
void castCharArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
void castCharArgs(gp_walk_info* gwip, Item_func* ifp, FunctionParm& functionParms)
{
Item_char_typecast* idai = (Item_char_typecast*)ifp;
SPTP sptp;
sptp.reset(new ParseTree(new ConstantColumn((int64_t)idai->get_cast_length())));
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwip->timeZone);
functionParms.push_back(sptp);
}
void castDecimalArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
void castDecimalArgs(gp_walk_info* gwip, Item_func* ifp, FunctionParm& functionParms)
{
Item_decimal_typecast* idai = (Item_decimal_typecast*)ifp;
SPTP sptp;
sptp.reset(new ParseTree(new ConstantColumn((int64_t)idai->decimals)));
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwip->timeZone);
functionParms.push_back(sptp);
// max length including sign and/or decimal points
@ -5460,12 +5457,12 @@ void castDecimalArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
sptp.reset(new ParseTree(new ConstantColumn((int64_t)idai->max_length - 1)));
else
sptp.reset(new ParseTree(new ConstantColumn((int64_t)idai->max_length - 2)));
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwip->timeZone);
functionParms.push_back(sptp);
}
void castTypeArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
void castTypeArgs(gp_walk_info* gwip, Item_func* ifp, FunctionParm& functionParms)
{
Item_func_get_format* get_format = (Item_func_get_format*)ifp;
SPTP sptp;
@ -5474,7 +5471,7 @@ void castTypeArgs(THD* thd, Item_func* ifp, FunctionParm& functionParms)
sptp.reset(new ParseTree(new ConstantColumn("DATE")));
else
sptp.reset(new ParseTree(new ConstantColumn("DATETIME")));
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwip->timeZone);
functionParms.push_back(sptp);
}
@ -5575,7 +5572,7 @@ void gp_walk(const Item* item, void* arg)
Item_hex_hybrid* hip = reinterpret_cast<Item_hex_hybrid*>(const_cast<Item*>(item));
gwip->rcWorkStack.push(new ConstantColumn((int64_t)hip->val_int(), ConstantColumn::NUM));
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top());
cc->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
cc->timeZone(gwip->timeZone);
break;
}
@ -5594,8 +5591,7 @@ void gp_walk(const Item* item, void* arg)
}
gwip->rcWorkStack.push(new ConstantColumn(cval));
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))
->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
break;
}
@ -5630,7 +5626,7 @@ void gp_walk(const Item* item, void* arg)
{
// push noop for unhandled item
SimpleColumn* rc = new SimpleColumn("noop");
rc->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwip->timeZone);
gwip->rcWorkStack.push(rc);
break;
}
@ -5650,14 +5646,13 @@ void gp_walk(const Item* item, void* arg)
{
// push noop for unhandled item
SimpleColumn* rc = new SimpleColumn("noop");
rc->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwip->timeZone);
gwip->rcWorkStack.push(rc);
break;
}
gwip->rcWorkStack.push(new ConstantColumn("", ConstantColumn::NULLDATA));
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))
->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(gwip->rcWorkStack.top()))->timeZone(gwip->timeZone);
break;
}
@ -6175,7 +6170,7 @@ void gp_walk(const Item* item, void* arg)
{
// push noop for unhandled item
SimpleColumn* rc = new SimpleColumn("noop");
rc->timeZone(gwip->thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwip->timeZone);
gwip->rcWorkStack.push(rc);
break;
}
@ -6664,7 +6659,7 @@ int processFrom(bool& isUnion, SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP&
plan->data(csep->data());
// gwi for the union unit
gp_walk_info union_gwi;
gp_walk_info union_gwi(gwi.timeZone);
union_gwi.thd = gwi.thd;
uint32_t err = 0;
@ -6777,8 +6772,7 @@ int processWhere(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep, const s
else if (join && join->zero_result_cause)
{
gwi.rcWorkStack.push(new ConstantColumn((int64_t)0, ConstantColumn::NUM));
(dynamic_cast<ConstantColumn*>(gwi.rcWorkStack.top()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(gwi.rcWorkStack.top()))->timeZone(gwi.timeZone);
}
for (Item* item : gwi.condList)
@ -7226,7 +7220,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
gwi.sessionid = sessionID;
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
csc->identity(CalpontSystemCatalog::FE);
csep->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
csep->timeZone(gwi.timeZone);
gwi.csc = csc;
CalpontSelectExecutionPlan::SelectList derivedTbList;
@ -7607,7 +7601,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
selectSubList.push_back(ssub);
SimpleColumn* rc = new SimpleColumn();
rc->colSource(rc->colSource() | SELECT_SUB);
rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwi.timeZone);
if (sub->get_select_lex()->get_table_list())
{
@ -8414,7 +8408,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
sc1->tableAlias(sc->tableAlias());
sc1->viewName(sc->viewName());
sc1->colPosition(0);
sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc1->timeZone(gwi.timeZone);
minSc.reset(sc1);
}
}
@ -8473,12 +8467,12 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
return 0;
}
int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti)
int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti, long timeZone)
{
gp_walk_info* gwi = ti.condInfo;
if (!gwi)
gwi = new gp_walk_info();
gwi = new gp_walk_info(timeZone);
gwi->thd = thd;
LEX* lex = thd->lex;
@ -8506,7 +8500,7 @@ int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti)
boost::algorithm::to_lower(alias);
}
sc->tableAlias(alias);
sc->timeZone(gwi->thd->variables.time_zone->get_name()->ptr());
sc->timeZone(gwi->timeZone);
assert(sc);
boost::shared_ptr<SimpleColumn> spsc(sc);
gwi->returnedCols.push_back(spsc);
@ -8581,7 +8575,10 @@ int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti)
int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
{
SELECT_LEX* select_lex = gi.groupByTables->select_lex;
gp_walk_info gwi;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
gp_walk_info gwi(timeZoneOffset);
gwi.thd = thd;
gwi.isGroupByHandler = true;
int status = getGroupPlan(gwi, *select_lex, csep, gi);
@ -8597,7 +8594,7 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
else if (status < 0)
return status;
// Derived table projection and filter optimization.
derivedTableOptimization(thd, csep);
derivedTableOptimization(&gwi, csep);
return 0;
}
@ -8618,7 +8615,7 @@ int cs_get_derived_plan(ha_columnstore_derived_handler* handler, THD* thd, SCSEP
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
#endif
// Derived table projection and filter optimization.
derivedTableOptimization(thd, csep);
derivedTableOptimization(&gwi, csep);
return 0;
}
@ -8649,7 +8646,7 @@ int cs_get_select_plan(ha_columnstore_select_handler* handler, THD* thd, SCSEP&
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
#endif
// Derived table projection and filter optimization.
derivedTableOptimization(thd, csep);
derivedTableOptimization(&gwi, csep);
return 0;
}
@ -8954,8 +8951,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
else if (join && join->zero_result_cause)
{
gwi.rcWorkStack.push(new ConstantColumn((int64_t)0, ConstantColumn::NUM));
(dynamic_cast<ConstantColumn*>(gwi.rcWorkStack.top()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(gwi.rcWorkStack.top()))->timeZone(gwi.timeZone);
}
SELECT_LEX tmp_select_lex;
@ -9443,7 +9439,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
selectSubList.push_back(ssub);
SimpleColumn* rc = new SimpleColumn();
rc->colSource(rc->colSource() | SELECT_SUB);
rc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
rc->timeZone(gwi.timeZone);
if (sub->get_select_lex()->get_table_list())
{
@ -10401,7 +10397,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
sc1->tableName(sc->tableName());
sc1->tableAlias(sc->tableAlias());
sc1->viewName(sc->viewName());
sc1->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
sc1->timeZone(gwi.timeZone);
sc1->colPosition(0);
minSc.reset(sc1);
}
@ -10462,4 +10458,3 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
}
} // namespace cal_impl_if
// vim:ts=4 sw=4:

View File

@ -54,7 +54,6 @@ using namespace std;
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/regex.hpp>
#include <boost/thread.hpp>
#include "mcs_basic_types.h"
@ -295,7 +294,8 @@ bool onlyOneTableinTM(cal_impl_if::cal_connection_info* ci)
return true;
}
int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool handler_flag = false)
int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, long timeZone,
bool handler_flag = false)
{
int rc = HA_ERR_END_OF_FILE;
int num_attr = ti.msTablePtr->s->fields;
@ -436,7 +436,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
{
// fetch and store data
(*f)->set_notnull();
datatypes::StoreFieldMariaDB mf(*f, colType);
datatypes::StoreFieldMariaDB mf(*f, colType, timeZone);
h->storeValueToField(row, s, &mf);
}
}
@ -891,6 +891,10 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
bool isFromSameTable = true;
execplan::SCSEP updateCP(new execplan::CalpontSelectExecutionPlan());
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
updateCP->isDML(true);
//@Bug 2753. the memory already freed by destructor of UpdateSqlStatement
@ -1014,9 +1018,9 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
// sysdate() etc.
if (!hasNonSupportItem && !cal_impl_if::nonConstFunc(ifp) && tmpVec.size() == 0)
{
gp_walk_info gwi;
gwi.thd = thd;
SRCP srcp(buildReturnedColumn(value, gwi, gwi.fatalParseError));
gp_walk_info gwi2(gwi.timeZone);
gwi2.thd = thd;
SRCP srcp(buildReturnedColumn(value, gwi2, gwi2.fatalParseError));
ConstantColumn* constCol = dynamic_cast<ConstantColumn*>(srcp.get());
if (constCol)
@ -1163,7 +1167,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
char buf[64];
gettimeofday(&tv, 0);
MySQLTime time;
gmtSecToMySQLTime(tv.tv_sec, time, thd->variables.time_zone->get_name()->ptr());
gmtSecToMySQLTime(tv.tv_sec, time, timeZoneOffset);
sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d.%06ld", time.year, time.month, time.day, time.hour,
time.minute, time.second, tv.tv_usec);
columnAssignmentPtr->fScalarExpression = buf;
@ -1314,7 +1318,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
pDMLPackage->set_TableName(tableName);
pDMLPackage->set_SchemaName(schemaName);
pDMLPackage->set_TimeZone(thd->variables.time_zone->get_name()->ptr());
pDMLPackage->set_TimeZone(timeZoneOffset);
pDMLPackage->set_IsFromCol(true);
// cout << " setting isFromCol to " << isFromCol << endl;
@ -1516,7 +1520,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
CalpontSystemCatalog::TableColName tcn = csc->colName(colrids[minWidthColOffset].objnum);
SimpleColumn* sc = new SimpleColumn(tcn.schema, tcn.table, tcn.column, csc->sessionID());
sc->tableAlias(aliasName);
sc->timeZone(thd->variables.time_zone->get_name()->ptr());
sc->timeZone(timeZoneOffset);
sc->resultType(csc->colType(colrids[minWidthColOffset].objnum));
SRCP srcp;
srcp.reset(sc);
@ -1660,7 +1664,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
// << endl;
VendorDMLStatement cmdStmt("CTRL+C", DML_COMMAND, sessionID);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(cmdStmt);
pDMLPackage->set_TimeZone(thd->variables.time_zone->get_name()->ptr());
pDMLPackage->set_TimeZone(timeZoneOffset);
ByteStream bytestream;
bytestream << static_cast<uint32_t>(sessionID);
pDMLPackage->write(bytestream);
@ -1783,7 +1787,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
{
VendorDMLStatement cmdStmt(command, DML_COMMAND, sessionID);
CalpontDMLPackage* pDMLPackage = CalpontDMLFactory::makeCalpontDMLPackageFromMysqlBuffer(cmdStmt);
pDMLPackage->set_TimeZone(thd->variables.time_zone->get_name()->ptr());
pDMLPackage->set_TimeZone(timeZoneOffset);
pDMLPackage->setTableOid(ci->tableOid);
ByteStream bytestream;
bytestream << static_cast<uint32_t>(sessionID);
@ -2008,6 +2012,10 @@ int ha_mcs_impl_analyze(THD* thd, TABLE* table)
execplan::MCSAnalyzeTableExecutionPlan::ReturnedColumnList returnedColumnList;
execplan::MCSAnalyzeTableExecutionPlan::ColumnMap columnMap;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
// Iterate over table oid list and create a `SimpleColumn` for every column with supported type.
for (uint32_t i = 0, e = oidlist.size(); i < e; ++i)
{
@ -2026,7 +2034,7 @@ int ha_mcs_impl_analyze(THD* thd, TABLE* table)
simpleColumn->oid(objNum);
simpleColumn->alias(tableColName.column);
simpleColumn->resultType(colType);
simpleColumn->timeZone(thd->variables.time_zone->get_name()->ptr());
simpleColumn->timeZone(timeZoneOffset);
returnedColumn.reset(simpleColumn);
returnedColumnList.push_back(returnedColumn);
@ -2040,7 +2048,7 @@ int ha_mcs_impl_analyze(THD* thd, TABLE* table)
caep->schemaName(table->s->db.str, lower_case_table_names);
caep->tableName(table->s->table_name.str, lower_case_table_names);
caep->timeZone(thd->variables.time_zone->get_name()->ptr());
caep->timeZone(timeZoneOffset);
SessionManager sm;
BRM::TxnID txnID;
@ -2160,7 +2168,10 @@ int ha_mcs_impl_direct_update_delete_rows(bool execute, ha_rows* affected_rows,
const std::vector<COND*>& condStack)
{
THD* thd = current_thd;
cal_impl_if::gp_walk_info gwi;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
cal_impl_if::gp_walk_info gwi(timeZoneOffset);
gwi.thd = thd;
int rc = 0;
@ -2189,8 +2200,10 @@ int ha_mcs::impl_rnd_init(TABLE* table, const std::vector<COND*>& condStack)
{
IDEBUG(cout << "rnd_init for table " << table->s->table_name.str << endl);
THD* thd = current_thd;
gp_walk_info gwi;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
gp_walk_info gwi(timeZoneOffset);
gwi.thd = thd;
if (thd->slave_thread && !get_replication_slave(thd) && isDMLStatement(thd->lex->sql_command))
@ -2333,7 +2346,7 @@ int ha_mcs::impl_rnd_init(TABLE* table, const std::vector<COND*>& condStack)
ti.msTablePtr = table;
// send plan whenever rnd_init is called
cp_get_table_plan(thd, ti.csep, ti);
cp_get_table_plan(thd, ti.csep, ti, timeZoneOffset);
}
IDEBUG(cerr << table->s->table_name.str << " send plan:" << endl);
@ -2563,7 +2576,7 @@ internal_error:
return ER_INTERNAL_ERROR;
}
int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table)
int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table, long timeZone)
{
THD* thd = current_thd;
@ -2606,7 +2619,7 @@ int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table)
try
{
rc = fetchNextRow(buf, ti, ci);
rc = fetchNextRow(buf, ti, ci, timeZone);
}
catch (std::exception& e)
{
@ -2846,7 +2859,7 @@ int ha_mcs_impl_delete_table(const char* name)
int rc = ha_mcs_impl_delete_table_(dbName, name, *ci);
return rc;
}
int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed)
int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed, long timeZone)
{
THD* thd = current_thd;
@ -2893,7 +2906,7 @@ int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed)
((thd->lex)->sql_command == SQLCOM_LOAD) || ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT) ||
ci->isCacheInsert))
{
rc = ha_mcs_impl_write_batch_row_(buf, table, *ci);
rc = ha_mcs_impl_write_batch_row_(buf, table, *ci, timeZone);
}
else
{
@ -3894,7 +3907,10 @@ COND* ha_mcs_impl_cond_push(COND* cond, TABLE* table, std::vector<COND*>& condSt
#ifdef DEBUG_WALK_COND
{
gp_walk_info gwi;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
gp_walk_info gwi(timeZoneOffset);
gwi.condPush = true;
gwi.sessionid = tid2sid(thd->thread_id);
cout << "------------------ cond push -----------------------" << endl;
@ -3906,7 +3922,12 @@ COND* ha_mcs_impl_cond_push(COND* cond, TABLE* table, std::vector<COND*>& condSt
if (!ti.csep)
{
if (!ti.condInfo)
ti.condInfo = new gp_walk_info();
{
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
ti.condInfo = new gp_walk_info(timeZoneOffset);
}
gp_walk_info* gwi = ti.condInfo;
gwi->dropCond = false;
@ -4554,7 +4575,7 @@ internal_error:
* HA_ERR_END_OF_FILE if the record set has come to an end
* others if something went wrong whilst getting the result set
***********************************************************/
int ha_mcs_impl_group_by_next(TABLE* table)
int ha_mcs_impl_group_by_next(TABLE* table, long timeZone)
{
THD* thd = current_thd;
@ -4594,7 +4615,7 @@ int ha_mcs_impl_group_by_next(TABLE* table)
{
// fetchNextRow interface forces to use buf.
unsigned char buf;
rc = fetchNextRow(&buf, ti, ci, true);
rc = fetchNextRow(&buf, ti, ci, timeZone, true);
}
catch (std::exception& e)
{
@ -4801,7 +4822,10 @@ int ha_mcs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
if (thd->slave_thread && !get_replication_slave(thd) && isDMLStatement(thd->lex->sql_command))
return 0;
gp_walk_info gwi;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
gp_walk_info gwi(timeZoneOffset);
gwi.thd = thd;
bool err = false;
@ -5237,7 +5261,7 @@ internal_error:
return ER_INTERNAL_ERROR;
}
int ha_mcs_impl_select_next(uchar* buf, TABLE* table)
int ha_mcs_impl_select_next(uchar* buf, TABLE* table, long timeZone)
{
THD* thd = current_thd;
@ -5336,7 +5360,7 @@ int ha_mcs_impl_select_next(uchar* buf, TABLE* table)
try
{
rc = fetchNextRow(buf, ti, ci);
rc = fetchNextRow(buf, ti, ci, timeZone);
}
catch (std::exception& e)
{

View File

@ -29,9 +29,9 @@ extern int ha_mcs_impl_delete_table(const char* name);
extern int ha_mcs_impl_analyze(THD* thd, TABLE* table);
extern int ha_mcs_impl_open(const char* name, int mode, uint32_t test_if_locked);
extern int ha_mcs_impl_close(void);
extern int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table);
extern int ha_mcs_impl_rnd_next(uchar* buf, TABLE* table, long timeZone);
extern int ha_mcs_impl_rnd_end(TABLE* table, bool is_derived_hand = false);
extern int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed);
extern int ha_mcs_impl_write_row(const uchar* buf, TABLE* table, uint64_t rows_changed, long timeZone);
extern void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table, bool is_cache_insert = false);
extern int ha_mcs_impl_end_bulk_insert(bool abort, TABLE* table);
extern int ha_mcs_impl_rename_table(const char* from, const char* to);
@ -45,9 +45,9 @@ extern int ha_mcs_impl_direct_update_delete_rows(bool execute, ha_rows* affected
extern int ha_mcs_impl_delete_row();
extern int ha_mcs_impl_rnd_pos(uchar* buf, uchar* pos);
extern int ha_mcs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table);
extern int ha_mcs_impl_select_next(uchar* buf, TABLE* table);
extern int ha_mcs_impl_select_next(uchar* buf, TABLE* table, long timeZone);
extern int ha_mcs_impl_group_by_init(mcs_handler_info* handler_info, TABLE* table);
extern int ha_mcs_impl_group_by_next(TABLE* table);
extern int ha_mcs_impl_group_by_next(TABLE* table, long timeZone);
extern int ha_mcs_impl_group_by_end(TABLE* table);
#endif
@ -59,7 +59,8 @@ extern int ha_mcs_impl_group_by_end(TABLE* table);
extern int ha_mcs_impl_rename_table_(const char* from, const char* to, cal_impl_if::cal_connection_info& ci);
extern int ha_mcs_impl_write_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci,
ha_rows& rowsInserted);
extern int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci);
extern int ha_mcs_impl_write_batch_row_(const uchar* buf, TABLE* table, cal_impl_if::cal_connection_info& ci,
long timeZone);
extern int ha_mcs_impl_write_last_batch(TABLE* table, cal_impl_if::cal_connection_info& ci, bool abort);
extern int ha_mcs_impl_commit_(handlerton* hton, THD* thd, bool all, cal_impl_if::cal_connection_info& ci);
extern int ha_mcs_impl_rollback_(handlerton* hton, THD* thd, bool all, cal_impl_if::cal_connection_info& ci);

View File

@ -165,6 +165,7 @@ struct gp_walk_info
bool cs_vtable_impossible_where_on_union;
bool isGroupByHandler;
long timeZone;
// MCOL-4617 The below 2 fields are used for in-to-exists
// predicate creation and injection. See usage in InSub::transform()
@ -176,7 +177,7 @@ struct gp_walk_info
TableOnExprList tableOnExprList;
std::vector<COND*> condList;
gp_walk_info()
gp_walk_info(long timeZone_)
: sessionid(0)
, fatalParseError(false)
, condPush(false)
@ -197,6 +198,7 @@ struct gp_walk_info
, cs_vtable_is_update_with_derive(false)
, cs_vtable_impossible_where_on_union(false)
, isGroupByHandler(false)
, timeZone(timeZone_)
, inSubQueryLHS(nullptr)
, inSubQueryLHSItem(nullptr)
{
@ -391,7 +393,7 @@ const std::string infinidb_err_msg =
"distributed syntax or consider changing the MariaDB Columnstore Operating Mode (infinidb_vtable_mode).";
int cp_get_plan(THD* thd, execplan::SCSEP& csep);
int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti);
int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti, long timeZone);
int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_group_info& gi);
int cs_get_derived_plan(ha_columnstore_derived_handler* handler, THD* thd, execplan::SCSEP& csep,
gp_walk_info& gwi);
@ -428,14 +430,14 @@ execplan::ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi);
execplan::ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& nonSupport);
execplan::ReturnedColumn* buildPseudoColumn(Item* item, gp_walk_info& gwi, bool& nonSupport,
uint32_t pseudoType);
void addIntervalArgs(THD* thd, Item_func* ifp, funcexp::FunctionParm& functionParms);
void castCharArgs(THD* thd, Item_func* ifp, funcexp::FunctionParm& functionParms);
void castDecimalArgs(THD* thd, Item_func* ifp, funcexp::FunctionParm& functionParms);
void castTypeArgs(THD* thd, Item_func* ifp, funcexp::FunctionParm& functionParms);
void addIntervalArgs(gp_walk_info* gwip, Item_func* ifp, funcexp::FunctionParm& functionParms);
void castCharArgs(gp_walk_info* gwip, Item_func* ifp, funcexp::FunctionParm& functionParms);
void castDecimalArgs(gp_walk_info* gwip, Item_func* ifp, funcexp::FunctionParm& functionParms);
void castTypeArgs(gp_walk_info* gwip, Item_func* ifp, funcexp::FunctionParm& functionParms);
// void parse_item (Item* item, std::vector<Item_field*>& field_vec, bool& hasNonSupportItem, uint16&
// parseInfo);
bool isPredicateFunction(Item* item, gp_walk_info* gwip);
execplan::ParseTree* buildRowPredicate(THD* thd, execplan::RowColumn* lhs, execplan::RowColumn* rhs,
execplan::ParseTree* buildRowPredicate(gp_walk_info* gwip, execplan::RowColumn* lhs, execplan::RowColumn* rhs,
std::string predicateOp);
bool buildRowColumnFilter(gp_walk_info* gwip, execplan::RowColumn* rhs, execplan::RowColumn* lhs,
Item_func* ifp);
@ -448,13 +450,13 @@ std::string getViewName(TABLE_LIST* table_ptr);
bool buildConstPredicate(Item_func* ifp, execplan::ReturnedColumn* rhs, gp_walk_info* gwip);
execplan::CalpontSystemCatalog::ColType fieldType_MysqlToIDB(const Field* field);
execplan::CalpontSystemCatalog::ColType colType_MysqlToIDB(const Item* item);
execplan::SPTP getIntervalType(THD* thd, int interval_type);
execplan::SPTP getIntervalType(gp_walk_info* gwip, int interval_type);
uint32_t isPseudoColumn(std::string funcName);
void setDerivedTable(execplan::ParseTree* n);
execplan::ParseTree* setDerivedFilter(THD* thd, execplan::ParseTree*& n,
execplan::ParseTree* setDerivedFilter(gp_walk_info* gwip, execplan::ParseTree*& n,
std::map<std::string, execplan::ParseTree*>& obj,
execplan::CalpontSelectExecutionPlan::SelectList& derivedTbList);
void derivedTableOptimization(THD* thd, execplan::SCSEP& csep);
void derivedTableOptimization(gp_walk_info* gwip, execplan::SCSEP& csep);
bool buildEqualityPredicate(execplan::ReturnedColumn* lhs, execplan::ReturnedColumn* rhs, gp_walk_info* gwip,
boost::shared_ptr<execplan::Operator>& sop, const Item_func::Functype& funcType,
const std::vector<Item*>& itemList, bool isInSubs = false);

View File

@ -385,7 +385,10 @@ void partitionByValue_common(UDF_ARGS* args, // inp
csc->identity(CalpontSystemCatalog::FE);
OID_t oid = csc->lookupOID(tcn);
CalpontSystemCatalog::ColType ct = csc->colType(oid);
datatypes::SessionParam sp(current_thd->variables.time_zone->get_name()->ptr());
const char* timeZone = current_thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
datatypes::SessionParam sp(timeZoneOffset);
datatypes::SimpleValue startVal;
datatypes::SimpleValue endVal;
datatypes::round_style_t rfMin = datatypes::round_style_t::NONE;
@ -1252,7 +1255,10 @@ extern "C"
string schema, table, column;
CalpontSystemCatalog::ColType ct;
string errMsg;
datatypes::SessionParam sp(current_thd->variables.time_zone->get_name()->ptr());
const char* timeZone = current_thd->variables.time_zone->get_name()->ptr();
long timeZoneOffset;
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &timeZoneOffset);
datatypes::SessionParam sp(timeZoneOffset);
datatypes::SimpleValue startVal;
datatypes::SimpleValue endVal;
datatypes::round_style_t rfMin = datatypes::round_style_t::NONE;

View File

@ -581,6 +581,8 @@ ha_columnstore_derived_handler::ha_columnstore_derived_handler(THD* thd, TABLE_L
: derived_handler(thd, mcs_hton)
{
derived = dt;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &time_zone);
}
/***********************************************************
@ -625,7 +627,7 @@ int ha_columnstore_derived_handler::next_row()
{
DBUG_ENTER("ha_columnstore_derived_handler::next_row");
int rc = ha_mcs_impl_rnd_next(table->record[0], table);
int rc = ha_mcs_impl_rnd_next(table->record[0], table, time_zone);
DBUG_RETURN(rc);
}
@ -670,6 +672,8 @@ ha_mcs_group_by_handler::ha_mcs_group_by_handler(THD* thd_arg, Query* query)
, order_by(query->order_by)
, having(query->having)
{
const char* timeZone = thd_arg->variables.time_zone->get_name()->ptr();
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &time_zone);
}
/***********************************************************
@ -705,7 +709,7 @@ int ha_mcs_group_by_handler::init_scan()
int ha_mcs_group_by_handler::next_row()
{
DBUG_ENTER("ha_mcs_group_by_handler::next_row");
int rc = ha_mcs_impl_group_by_next(table);
int rc = ha_mcs_impl_group_by_next(table, time_zone);
DBUG_RETURN(rc);
}
@ -985,6 +989,8 @@ ha_columnstore_select_handler::ha_columnstore_select_handler(THD* thd, SELECT_LE
, pushdown_init_rc(0)
{
select = select_lex;
const char* timeZone = thd->variables.time_zone->get_name()->ptr();
dataconvert::timeZoneToOffset(timeZone, strlen(timeZone), &time_zone);
}
/***********************************************************
@ -1028,7 +1034,7 @@ int ha_columnstore_select_handler::next_row()
{
DBUG_ENTER("ha_columnstore_select_handler::next_row");
int rc = ha_mcs_impl_select_next(table->record[0], table);
int rc = ha_mcs_impl_select_next(table->record[0], table, time_zone);
DBUG_RETURN(rc);
}

View File

@ -76,6 +76,9 @@ struct mcs_handler_info
***********************************************************/
class ha_mcs_group_by_handler : public group_by_handler
{
private:
long time_zone;
public:
ha_mcs_group_by_handler(THD* thd_arg, Query* query);
~ha_mcs_group_by_handler();
@ -109,6 +112,7 @@ class ha_columnstore_derived_handler : public derived_handler
{
private:
COLUMNSTORE_SHARE* share;
long time_zone;
public:
ha_columnstore_derived_handler(THD* thd_arg, TABLE_LIST* tbl);
@ -138,6 +142,7 @@ class ha_columnstore_select_handler : public select_handler
COLUMNSTORE_SHARE* share;
bool prepared;
bool scan_ended;
long time_zone;
public:
bool scan_initialized;

View File

@ -494,7 +494,7 @@ execplan::ReturnedColumn* buildPseudoColumn(Item* item, gp_walk_info& gwi, bool&
cc = new ConstantColumn(localPm);
else
cc = new ConstantColumn("", ConstantColumn::NULLDATA);
cc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
cc->timeZone(gwi.timeZone);
cc->alias(ifp->full_name() ? ifp->full_name() : "");
return cc;
@ -556,7 +556,7 @@ execplan::ReturnedColumn* buildPseudoColumn(Item* item, gp_walk_info& gwi, bool&
parms.push_back(sptp);
fc->functionParms(parms);
fc->expressionId(ci->expressionId++);
fc->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
fc->timeZone(gwi.timeZone);
// string result type
CalpontSystemCatalog::ColType ct;
@ -579,4 +579,3 @@ execplan::ReturnedColumn* buildPseudoColumn(Item* item, gp_walk_info& gwi, bool&
}
} // namespace cal_impl_if
// vim:ts=4 sw=4:

View File

@ -109,8 +109,7 @@ execplan::ParseTree* ScalarSub::transform()
{
fSub = (Item_subselect*)(fFunc->arguments()[0]);
fColumn.reset(new ConstantColumn("", ConstantColumn::NULLDATA));
(dynamic_cast<ConstantColumn*>(fColumn.get()))
->timeZone(fGwip.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(fColumn.get()))->timeZone(fGwip.timeZone);
delete rhs;
return buildParseTree(op);
}
@ -176,7 +175,7 @@ execplan::ParseTree* ScalarSub::transform_between()
SOP sop;
sop.reset(op_LE);
rhs = new ParseTree(new SimpleFilter(sop, fColumn.get(), op3));
(dynamic_cast<SimpleFilter*>(rhs->data()))->timeZone(fGwip.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<SimpleFilter*>(rhs->data()))->timeZone(fGwip.timeZone);
}
SubSelect* sub1 = dynamic_cast<SubSelect*>(op2);
@ -192,7 +191,7 @@ execplan::ParseTree* ScalarSub::transform_between()
SOP sop;
sop.reset(op_GE);
lhs = new ParseTree(new SimpleFilter(sop, fColumn.get(), op2));
(dynamic_cast<SimpleFilter*>(lhs->data()))->timeZone(fGwip.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<SimpleFilter*>(lhs->data()))->timeZone(fGwip.timeZone);
}
if (!rhs || !lhs)
@ -245,7 +244,7 @@ execplan::ParseTree* ScalarSub::buildParseTree(PredicateOperator* op)
csep->subType(CalpontSelectExecutionPlan::SINGLEROW_SUBS);
// gwi for the sub query
gp_walk_info gwi;
gp_walk_info gwi(fGwip.timeZone);
gwi.thd = fGwip.thd;
gwi.subQuery = this;

View File

@ -67,7 +67,7 @@ SCSEP SelectSubQuery::transform()
csep->subType(CalpontSelectExecutionPlan::SELECT_SUBS);
// gwi for the sub query
gp_walk_info gwi;
gp_walk_info gwi(fGwip.timeZone);
gwi.thd = fGwip.thd;
gwi.subQuery = this;

View File

@ -65,7 +65,7 @@ void View::transform()
csep->sessionID(fParentGwip->sessionid);
// gwi for the sub query
gp_walk_info gwi;
gp_walk_info gwi(fParentGwip->timeZone);
gwi.thd = fParentGwip->thd;
uint32_t sessionID = csep->sessionID();

View File

@ -145,27 +145,25 @@ ReturnedColumn* buildBoundExp(WF_Boundary& bound, SRCP& order, gp_walk_info& gwi
// put interval val column to bound
(dynamic_cast<FunctionColumn*>(rc))->functionName(funcName);
(dynamic_cast<FunctionColumn*>(rc))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<FunctionColumn*>(rc))->timeZone(gwi.timeZone);
sptp.reset(new ParseTree(order->clone()));
funcParms.push_back(sptp);
sptp.reset(new ParseTree(intervalCol->val()->clone()));
funcParms.push_back(sptp);
funcParms.push_back(getIntervalType(gwi.thd, intervalCol->intervalType()));
funcParms.push_back(getIntervalType(&gwi, intervalCol->intervalType()));
SRCP srcp(intervalCol->val());
bound.fVal = srcp;
if (addOp)
{
sptp.reset(new ParseTree(new ConstantColumn("ADD")));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
}
else
{
sptp.reset(new ParseTree(new ConstantColumn("SUB")));
(dynamic_cast<ConstantColumn*>(sptp->data()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(sptp->data()))->timeZone(gwi.timeZone);
funcParms.push_back(sptp);
}
@ -187,7 +185,7 @@ ReturnedColumn* buildBoundExp(WF_Boundary& bound, SRCP& order, gp_walk_info& gwi
else
aop = new ArithmeticOperator("-");
aop->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
aop->timeZone(gwi.timeZone);
ParseTree* pt = new ParseTree(aop);
ParseTree *lhs = 0, *rhs = 0;
lhs = new ParseTree(order->clone());
@ -314,7 +312,7 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
Item_sum* item_sum = wf->window_func();
string funcName = ConvertFuncName(item_sum);
WindowFunctionColumn* ac = new WindowFunctionColumn(funcName);
ac->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
ac->timeZone(gwi.timeZone);
ac->distinct(item_sum->has_with_distinct());
Window_spec* win_spec = wf->window_spec;
SRCP srcp;
@ -407,45 +405,45 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
sprintf(sRespectNulls, "%lu", bRespectNulls);
srcp.reset(new ConstantColumn(sRespectNulls, (uint64_t)bRespectNulls,
ConstantColumn::NUM)); // IGNORE/RESPECT NULLS. 1 => RESPECT
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
break;
}
case Item_sum::FIRST_VALUE_FUNC:
srcp.reset(new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // OFFSET (always one)
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
srcp.reset(new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // FROM_FIRST
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
srcp.reset(
new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // IGNORE/RESPECT NULLS. 1 => RESPECT
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
break;
case Item_sum::LAST_VALUE_FUNC:
srcp.reset(new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // OFFSET (always one)
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
srcp.reset(new ConstantColumn("0", (uint64_t)0, ConstantColumn::NUM)); // FROM_LAST
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
srcp.reset(
new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // IGNORE/RESPECT NULLS. 1 => RESPECT
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
break;
case Item_sum::NTH_VALUE_FUNC:
// When the front end supports these paramters, this needs modification
srcp.reset(new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // FROM FIRST/LAST 1 => FIRST
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
srcp.reset(
new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // IGNORE/RESPECT NULLS. 1 => RESPECT
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
break;
@ -453,11 +451,11 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
case Item_sum::LAG_FUNC:
// When the front end supports these paramters, this needs modification
srcp.reset(new ConstantColumn("", ConstantColumn::NULLDATA)); // Default to fill in for NULL values
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
srcp.reset(
new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // IGNORE/RESPECT NULLS. 1 => RESPECT
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
funcParms.push_back(srcp);
break;
@ -802,8 +800,7 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
bound = 1;
srcp.reset(new ConstantColumn((int64_t)bound));
(dynamic_cast<ConstantColumn*>(srcp.get()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
frm.fStart.fVal = srcp;
frm.fStart.fBound.reset(buildBoundExp(frm.fStart, srcp, gwi));
@ -819,8 +816,7 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
bound = 1;
srcp.reset(new ConstantColumn((int64_t)bound));
(dynamic_cast<ConstantColumn*>(srcp.get()))
->timeZone(gwi.thd->variables.time_zone->get_name()->ptr());
(dynamic_cast<ConstantColumn*>(srcp.get()))->timeZone(gwi.timeZone);
frm.fEnd.fVal = srcp;
frm.fEnd.fBound.reset(buildBoundExp(frm.fEnd, srcp, gwi));

View File

@ -118,4 +118,3 @@ inline char* idb_mysql_query_str(THD* thd)
}
} // namespace
// vim:ts=4 sw=4:

View File

@ -19,16 +19,25 @@ fi
# DELETE libcalmysql.so entries first as they are in ha_columnstore.so in 1.4.2 onwards
$MDB 2> ${tmpdir}/mysql_install.log <<EOD
DELETE FROM mysql.func WHERE dl='libcalmysql.so';
CREATE OR REPLACE FUNCTION mcsgetstats RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calgetstats RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcssettrace RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calsettrace RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcssetparms RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calsetparms RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcsflushcache RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calflushcache RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcsgettrace RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calgettrace RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcsgetversion RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calgetversion RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calonlinealter RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcsviewtablelock RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calviewtablelock RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcscleartablelock RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calcleartablelock RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcslastinsertid RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION callastinsertid RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION mcsgetsqlcount RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION calgetsqlcount RETURNS STRING SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION idbpm RETURNS INTEGER SONAME 'ha_columnstore.so';
CREATE OR REPLACE FUNCTION idbdbroot RETURNS INTEGER SONAME 'ha_columnstore.so';