1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-10-31 18:30:33 +03:00

Code cleanup and deduplication

This commit is contained in:
Aleksei Antipovskii
2025-09-02 22:29:26 +02:00
committed by Leonid Fedorov
parent 5bdeaa6555
commit 76f135b2ac
10 changed files with 307 additions and 405 deletions

View File

@@ -84,7 +84,7 @@ CalpontSelectExecutionPlan::CalpontSelectExecutionPlan(int location)
, fLimitNum(-1)
, fHasOrderBy(false)
, fStringScanThreshold(ULONG_MAX)
, fQueryType(SELECT)
, fQueryType(IDBQueryType::SELECT)
, fPriority(querystats::DEFAULT_USER_PRIORITY_LEVEL)
, fStringTableThreshold(20)
, fOrderByThreads(1)
@@ -491,27 +491,20 @@ string CalpontSelectExecutionPlan::toString(const size_t ident) const
return output.str();
}
string CalpontSelectExecutionPlan::queryTypeToString(const uint32_t queryType)
string CalpontSelectExecutionPlan::queryTypeToString(const IDBQueryType queryType)
{
switch (queryType)
{
case SELECT: return "SELECT";
case UPDATE: return "UPDATE";
case DELETE: return "DELETE";
case INSERT_SELECT: return "INSERT_SELECT";
case CREATE_TABLE: return "CREATE_TABLE";
case DROP_TABLE: return "DROP_TABLE";
case ALTER_TABLE: return "ALTER_TABLE";
case INSERT: return "INSERT";
case LOAD_DATA_INFILE: return "LOAD_DATA_INFILE";
case IDBQueryType::SELECT: return "SELECT";
case IDBQueryType::UPDATE: return "UPDATE";
case IDBQueryType::DELETE: return "DELETE";
case IDBQueryType::INSERT_SELECT: return "INSERT_SELECT";
case IDBQueryType::CREATE_TABLE: return "CREATE_TABLE";
case IDBQueryType::DROP_TABLE: return "DROP_TABLE";
case IDBQueryType::ALTER_TABLE: return "ALTER_TABLE";
case IDBQueryType::INSERT: return "INSERT";
case IDBQueryType::LOAD_DATA_INFILE: return "LOAD_DATA_INFILE";
case IDBQueryType::UNION: return "UNION";
}
return "UNKNOWN";

View File

@@ -55,6 +55,23 @@ enum RM_PARMS
UMSMALLSIDEMEMORY,
};
// query type of select plan.
// TODO: move it somewhere?
#undef DELETE // Windows defines this...
enum class IDBQueryType : uint32_t
{
SELECT,
UPDATE,
DELETE,
INSERT_SELECT,
CREATE_TABLE,
DROP_TABLE,
ALTER_TABLE,
INSERT,
LOAD_DATA_INFILE,
UNION
};
struct RMParam
{
RMParam(uint32_t s, uint16_t i, uint64_t v) : sessionId(s), id(i), value(v)
@@ -97,21 +114,6 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
typedef std::vector<RMParam> RMParmVec;
// query type of this select plan.
#undef DELETE // Windows defines this...
enum IDB_QUERYTYPE
{
SELECT,
UPDATE,
DELETE,
INSERT_SELECT,
CREATE_TABLE,
DROP_TABLE,
ALTER_TABLE,
INSERT,
LOAD_DATA_INFILE
};
enum SE_LOCATION
{
MAIN,
@@ -641,7 +643,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
}
// query type. return string for easy stats insert
void queryType(const uint32_t queryType)
void queryType(const IDBQueryType queryType)
{
fQueryType = queryType;
}
@@ -649,7 +651,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
{
return queryTypeToString(fQueryType);
}
static std::string queryTypeToString(const uint32_t queryType);
static std::string queryTypeToString(const IDBQueryType queryType);
void priority(uint32_t p)
{
@@ -709,7 +711,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
{
fDJSMaxPartitionTreeDepth = value;
}
uint64_t djsMaxPartitionTreeDepth()
uint64_t djsMaxPartitionTreeDepth() const
{
return fDJSMaxPartitionTreeDepth;
}
@@ -947,7 +949,7 @@ class CalpontSelectExecutionPlan : public CalpontExecutionPlan
uint64_t fStringScanThreshold = ULONG_MAX;
// query type
uint32_t fQueryType = SELECT;
IDBQueryType fQueryType{IDBQueryType::SELECT};
uint32_t fPriority;
uint32_t fStringTableThreshold = 20;

View File

@@ -499,67 +499,7 @@ void adjustLastStep(JobStepVector& querySteps, DeliveredTableMap& deliverySteps,
deliverySteps[CNX_VTABLE_ID] = ws;
}
// TODO MCOL-894 we don't need to run sorting|distinct
// every time
// if ((jobInfo.limitCount != (uint64_t) - 1) ||
// (jobInfo.constantCol == CONST_COL_EXIST) ||
// (jobInfo.hasDistinct))
// {
if (jobInfo.annexStep.get() == NULL)
jobInfo.annexStep.reset(new TupleAnnexStep(jobInfo));
TupleAnnexStep* tas = dynamic_cast<TupleAnnexStep*>(jobInfo.annexStep.get());
tas->setLimit(jobInfo.limitStart, jobInfo.limitCount);
if (jobInfo.orderByColVec.size() > 0)
{
tas->addOrderBy(new LimitedOrderBy());
if (jobInfo.orderByThreads > 1)
tas->setParallelOp();
tas->setMaxThreads(jobInfo.orderByThreads);
}
if (jobInfo.constantCol == CONST_COL_EXIST)
tas->addConstant(new TupleConstantStep(jobInfo));
if (jobInfo.hasDistinct)
tas->setDistinct();
// }
if (jobInfo.annexStep)
{
TupleDeliveryStep* ds = dynamic_cast<TupleDeliveryStep*>(deliverySteps[CNX_VTABLE_ID].get());
RowGroup rg2 = ds->getDeliveredRowGroup();
if (jobInfo.trace)
cout << "Output RowGroup 2: " << rg2.toString() << endl;
AnyDataListSPtr spdlIn(new AnyDataList());
RowGroupDL* dlIn;
if (jobInfo.orderByColVec.size() > 0)
dlIn = new RowGroupDL(jobInfo.orderByThreads, jobInfo.fifoSize);
else
dlIn = new RowGroupDL(1, jobInfo.fifoSize);
dlIn->OID(CNX_VTABLE_ID);
spdlIn->rowGroupDL(dlIn);
JobStepAssociation jsaIn;
jsaIn.outAdd(spdlIn);
dynamic_cast<JobStep*>(ds)->outputAssociation(jsaIn);
jobInfo.annexStep->inputAssociation(jsaIn);
AnyDataListSPtr spdlOut(new AnyDataList());
RowGroupDL* dlOut = new RowGroupDL(1, jobInfo.fifoSize);
dlOut->OID(CNX_VTABLE_ID);
spdlOut->rowGroupDL(dlOut);
JobStepAssociation jsaOut;
jsaOut.outAdd(spdlOut);
jobInfo.annexStep->outputAssociation(jsaOut);
querySteps.push_back(jobInfo.annexStep);
dynamic_cast<TupleAnnexStep*>(jobInfo.annexStep.get())->initialize(rg2, jobInfo);
deliverySteps[CNX_VTABLE_ID] = jobInfo.annexStep;
}
addAnnexStep(querySteps, deliverySteps, jobInfo);
// Check if constant false
if (jobInfo.constantFalse)
@@ -4407,6 +4347,78 @@ void makeNoTableJobStep(JobStepVector& querySteps, JobStepVector& projectSteps,
namespace joblist
{
void addAnnexStep(JobStepVector& querySteps, DeliveredTableMap& deliverySteps, JobInfo& jobInfo,
IDBQueryType queryType)
{
// TODO MCOL-894 we don't need to run sorting|distinct
// every time
// if ((jobInfo.limitCount != (uint64_t) - 1) ||
// (jobInfo.constantCol == CONST_COL_EXIST) ||
// (jobInfo.hasDistinct))
// {
if (!jobInfo.annexStep)
{
jobInfo.annexStep.reset(new TupleAnnexStep(jobInfo));
}
auto* tas = dynamic_cast<TupleAnnexStep*>(jobInfo.annexStep.get());
tas->setLimit(jobInfo.limitStart, jobInfo.limitCount);
if (!jobInfo.orderByColVec.empty())
{
tas->addOrderBy(new LimitedOrderBy());
if (jobInfo.orderByThreads > 1)
tas->setParallelOp();
tas->setMaxThreads(jobInfo.orderByThreads);
}
if (queryType != IDBQueryType::UNION)
{
if (jobInfo.constantCol == CONST_COL_EXIST)
tas->addConstant(new TupleConstantStep(jobInfo));
if (jobInfo.hasDistinct)
tas->setDistinct();
}
// }
auto* tds = dynamic_cast<TupleDeliveryStep*>(deliverySteps[CNX_VTABLE_ID].get());
RowGroup rg = tds->getDeliveredRowGroup();
if (jobInfo.trace)
cout << "Output RowGroup 2: " << rg.toString() << endl;
AnyDataListSPtr spdlIn(new AnyDataList());
RowGroupDL* dlIn;
if (jobInfo.orderByColVec.empty())
{
dlIn = new RowGroupDL(1, jobInfo.fifoSize);
}
else
{
dlIn = new RowGroupDL(jobInfo.orderByThreads, jobInfo.fifoSize);
}
dlIn->OID(CNX_VTABLE_ID);
spdlIn->rowGroupDL(dlIn);
JobStepAssociation jsaIn;
jsaIn.outAdd(spdlIn);
dynamic_cast<JobStep*>(tds)->outputAssociation(jsaIn);
jobInfo.annexStep->inputAssociation(jsaIn);
AnyDataListSPtr spdlOut(new AnyDataList());
RowGroupDL* dlOut = new RowGroupDL(1, jobInfo.fifoSize);
dlOut->OID(CNX_VTABLE_ID);
spdlOut->rowGroupDL(dlOut);
JobStepAssociation jsaOut;
jsaOut.outAdd(spdlOut);
jobInfo.annexStep->outputAssociation(jsaOut);
querySteps.push_back(jobInfo.annexStep);
dynamic_cast<TupleAnnexStep*>(jobInfo.annexStep.get())->initialize(rg, jobInfo);
deliverySteps[CNX_VTABLE_ID] = jobInfo.annexStep;
}
void associateTupleJobSteps(JobStepVector& querySteps, JobStepVector& projectSteps,
DeliveredTableMap& deliverySteps, JobInfo& jobInfo,
const bool overrideLargeSideEstimate)

View File

@@ -131,6 +131,9 @@ void orExpresssion(const execplan::Operator* op, JobInfo& jobInfo);
// union the queries and return the tuple union step
SJSTEP unionQueries(JobStepVector& queries, uint64_t distinctUnionNum, JobInfo& jobInfo, uint32_t keyCount);
void addAnnexStep(JobStepVector& querySteps, DeliveredTableMap& deliverySteps, JobInfo& jobInfo,
IDBQueryType queryType = execplan::IDBQueryType::SELECT);
// Used for join graph analysis.
// WHITE - node is not processed.
// GREY - node is in process.

View File

@@ -42,11 +42,7 @@ using namespace boost;
#include "mcsanalyzetableexecutionplan.h"
#include "calpontsystemcatalog.h"
#include "dbrm.h"
#include "filter.h"
#include "simplefilter.h"
#include "constantfilter.h"
#include "existsfilter.h"
#include "selectfilter.h"
#include "returnedcolumn.h"
#include "aggregatecolumn.h"
#include "windowfunctioncolumn.h"
@@ -57,7 +53,6 @@ using namespace boost;
#include "pseudocolumn.h"
#include "simplecolumn.h"
#include "rowcolumn.h"
#include "treenodeimpl.h"
#include "udafcolumn.h"
using namespace execplan;
@@ -73,11 +68,9 @@ using namespace logging;
#include "primitivestep.h"
#include "jl_logger.h"
#include "jlf_execplantojoblist.h"
#include "rowaggregation.h"
#include "tuplehashjoin.h"
#include "tupleunion.h"
#include "expressionstep.h"
#include "tupleconstantstep.h"
#include "tuplehavingstep.h"
#include "windowfunctionstep.h"
#include "tupleannexstep.h"
@@ -1944,6 +1937,43 @@ void makeAnalyzeTableJobSteps(MCSAnalyzeTableExecutionPlan* caep, JobInfo& jobIn
}
}
void fixUnionExpressionCol(ParseTree* tree, void* obj)
{
if (tree->left() || tree->right())
{
return;
}
auto* ac = dynamic_cast<ArithmeticColumn*>(tree->data());
if (ac && ac->expression())
{
ac->expression()->walk(fixUnionExpressionCol, obj);
ac->setSimpleColumnList();
return;
}
auto* fc = dynamic_cast<FunctionColumn*>(tree->data());
if (fc && !fc->functionParms().empty())
{
for (auto& parm : fc->functionParms())
{
parm->walk(fixUnionExpressionCol, obj);
}
fc->setSimpleColumnList();
return;
}
auto* csep = static_cast<CalpontSelectExecutionPlan*>(obj);
auto* rc = dynamic_cast<ReturnedColumn*>(tree->data());
if (rc)
{
if (dynamic_cast<ConstantColumn*>(rc) || rc->orderPos() == -1ull)
{
return;
}
auto* newrc = csep->returnedCols()[rc->orderPos()]->clone();
csep->returnedCols()[rc->orderPos()]->incRefCount();
tree->data(newrc);
}
}
} // namespace
namespace joblist
@@ -1985,43 +2015,6 @@ void makeJobSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, JobStepVec
makeVtableModeSteps(csep, jobInfo, querySteps, projectSteps, deliverySteps);
}
void fixUnionExpressionCol(ParseTree* tree, void* obj)
{
if (tree->left() || tree->right())
{
return;
}
auto* ac = dynamic_cast<ArithmeticColumn*>(tree->data());
if (ac && ac->expression())
{
ac->expression()->walk(fixUnionExpressionCol, obj);
ac->setSimpleColumnList();
return;
}
auto* fc = dynamic_cast<FunctionColumn*>(tree->data());
if (fc && !fc->functionParms().empty())
{
for (auto& parm : fc->functionParms())
{
parm->walk(fixUnionExpressionCol, obj);
}
fc->setSimpleColumnList();
return;
}
auto* csep = static_cast<CalpontSelectExecutionPlan*>(obj);
auto* rc = dynamic_cast<ReturnedColumn*>(tree->data());
if (rc)
{
if (dynamic_cast<ConstantColumn*>(rc) || rc->orderPos() == -1ull)
{
return;
}
auto* newrc = csep->returnedCols()[rc->orderPos()]->clone();
csep->returnedCols()[rc->orderPos()]->incRefCount();
tree->data(newrc);
}
}
void makeUnionJobSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, JobStepVector& querySteps,
JobStepVector& /*projectSteps*/, DeliveredTableMap& deliverySteps)
{
@@ -2030,7 +2023,7 @@ void makeUnionJobSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, JobSt
uint32_t unionRetColsCount = csep->returnedCols().size();
JobStepVector unionFeeders;
std::decay_t<decltype(csep->orderByCols())> expOrderByCols;
std::remove_cv_t<std::remove_reference_t<decltype(csep->orderByCols())>> expOrderByCols;
for (auto& obc : csep->orderByCols())
{
if (obc->orderPos() != -1ull)
@@ -2091,6 +2084,7 @@ void makeUnionJobSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, JobSt
uint16_t stepNo = jobInfo.subId * 10000;
numberSteps(querySteps, stepNo, jobInfo.traceFlags);
deliverySteps[execplan::CNX_VTABLE_ID] = unionStep;
if (!csep->orderByCols().empty() || csep->limitStart() != 0 || csep->limitNum() != -1ull)
{
jobInfo.limitStart = csep->limitStart();
@@ -2139,45 +2133,7 @@ void makeUnionJobSteps(CalpontSelectExecutionPlan* csep, JobInfo& jobInfo, JobSt
}
doProject(csep->returnedCols(), jobInfo);
checkReturnedColumns(csep, jobInfo);
auto* tas = new TupleAnnexStep(jobInfo);
jobInfo.annexStep.reset(tas);
tas->setLimit(jobInfo.limitStart, jobInfo.limitCount);
if (!jobInfo.orderByColVec.empty())
{
tas->addOrderBy(new LimitedOrderBy());
if (jobInfo.orderByThreads > 1)
{
tas->setParallelOp();
}
tas->setMaxThreads(jobInfo.orderByThreads);
}
auto* tds = dynamic_cast<TupleDeliveryStep*>(unionStep.get());
RowGroup rg = tds->getDeliveredRowGroup();
AnyDataListSPtr spdlIn(new AnyDataList());
RowGroupDL* dlIn;
if (!jobInfo.orderByColVec.empty())
dlIn = new RowGroupDL(jobInfo.orderByThreads, jobInfo.fifoSize);
else
dlIn = new RowGroupDL(1, jobInfo.fifoSize);
dlIn->OID(CNX_VTABLE_ID);
spdlIn->rowGroupDL(dlIn);
JobStepAssociation jsaIn;
jsaIn.outAdd(spdlIn);
dynamic_cast<JobStep*>(tds)->outputAssociation(jsaIn);
jobInfo.annexStep->inputAssociation(jsaIn);
AnyDataListSPtr spdlOut(new AnyDataList());
RowGroupDL* dlOut = new RowGroupDL(1, jobInfo.fifoSize);
dlOut->OID(CNX_VTABLE_ID);
spdlOut->rowGroupDL(dlOut);
JobStepAssociation jsaOut;
jsaOut.outAdd(spdlOut);
jobInfo.annexStep->outputAssociation(jsaOut);
querySteps.push_back(jobInfo.annexStep);
dynamic_cast<TupleAnnexStep*>(jobInfo.annexStep.get())->initialize(rg, jobInfo);
deliverySteps[CNX_VTABLE_ID] = jobInfo.annexStep;
addAnnexStep(querySteps, deliverySteps, jobInfo, IDBQueryType::UNION);
}
}
} // namespace joblist

View File

@@ -60,7 +60,6 @@ using namespace logging;
#include "ha_subquery.h"
#include "ha_mcs_pushdown.h"
#include "ha_tzinfo.h"
#include "ha_mcs_logging.h"
using namespace cal_impl_if;
#include "aggregatecolumn.h"
@@ -70,7 +69,6 @@ using namespace cal_impl_if;
#include "calpontsystemcatalog.h"
#include "constantcolumn.h"
#include "constantfilter.h"
#include "existsfilter.h"
#include "functioncolumn.h"
#include "groupconcatcolumn.h"
#include "intervalcolumn.h"
@@ -80,10 +78,8 @@ using namespace cal_impl_if;
#include "rewrites.h"
#include "rowcolumn.h"
#include "rulebased_optimizer.h"
#include "selectfilter.h"
#include "simplecolumn_decimal.h"
#include "simplecolumn_int.h"
#include "simplecolumn_uint.h"
#include "simplefilter.h"
#include "udafcolumn.h"
using namespace execplan;
@@ -2736,7 +2732,7 @@ ReturnedColumn* buildReturnedColumnNull(gp_walk_info& gwi)
}
ReturnedColumn* buildReturnedColumnBody(Item* item, gp_walk_info& gwi, bool& nonSupport, bool /*isRefItem*/,
bool isUnion)
IDBQueryType queryType)
{
ReturnedColumn* rc = NULL;
@@ -2758,7 +2754,7 @@ ReturnedColumn* buildReturnedColumnBody(Item* item, gp_walk_info& gwi, bool& non
{
Item_field* ifp = (Item_field*)item;
return wrapIntoAggregate(buildSimpleColumn(ifp, gwi, isUnion), gwi, ifp);
return wrapIntoAggregate(buildSimpleColumn(ifp, gwi, queryType), gwi, ifp);
}
case Item::NULL_ITEM: return buildReturnedColumnNull(gwi);
case Item::CONST_ITEM:
@@ -2797,10 +2793,10 @@ ReturnedColumn* buildReturnedColumnBody(Item* item, gp_walk_info& gwi, bool& non
}
if (func_name == "+" || func_name == "-" || func_name == "*" || func_name == "/")
return buildArithmeticColumn(ifp, gwi, nonSupport, isUnion);
return buildArithmeticColumn(ifp, gwi, nonSupport, queryType);
else
{
return buildFunctionColumn(ifp, gwi, nonSupport, false, isUnion);
return buildFunctionColumn(ifp, gwi, nonSupport, false, queryType);
}
}
@@ -2817,13 +2813,13 @@ ReturnedColumn* buildReturnedColumnBody(Item* item, gp_walk_info& gwi, bool& non
{
case Item::SUM_FUNC_ITEM: return buildAggregateColumn(*(ref->ref), gwi);
case Item::FIELD_ITEM: return buildReturnedColumn(*(ref->ref), gwi, nonSupport, false, isUnion);
case Item::FIELD_ITEM: return buildReturnedColumn(*(ref->ref), gwi, nonSupport, false, queryType);
case Item::REF_ITEM:
return buildReturnedColumn(*(((Item_ref*)(*(ref->ref)))->ref), gwi, nonSupport, false, isUnion);
return buildReturnedColumn(*(((Item_ref*)(*(ref->ref)))->ref), gwi, nonSupport, false, queryType);
case Item::FUNC_ITEM:
return buildFunctionColumn((Item_func*)(*(ref->ref)), gwi, nonSupport, false, isUnion);
return buildFunctionColumn((Item_func*)(*(ref->ref)), gwi, nonSupport, false, queryType);
case Item::WINDOW_FUNC_ITEM: return buildWindowFunctionColumn(*(ref->ref), gwi, nonSupport);
@@ -2835,7 +2831,7 @@ ReturnedColumn* buildReturnedColumnBody(Item* item, gp_walk_info& gwi, bool& non
default:
if (ref->ref_type() == Item_ref::DIRECT_REF)
{
return buildReturnedColumn(ref->real_item(), gwi, nonSupport, false, isUnion);
return buildReturnedColumn(ref->real_item(), gwi, nonSupport, false, queryType);
}
gwi.fatalParseError = true;
gwi.parseErrorText = "Unknown REF item";
@@ -2925,11 +2921,11 @@ ReturnedColumn* buildReturnedColumnBody(Item* item, gp_walk_info& gwi, bool& non
return rc;
}
ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport, bool isRefItem,
bool isUnion)
IDBQueryType queryType)
{
bool disableWrapping = gwi.disableWrapping;
gwi.disableWrapping = gwi.disableWrapping || itemDisablesWrapping(item, gwi);
ReturnedColumn* rc = buildReturnedColumnBody(item, gwi, nonSupport, isRefItem, isUnion);
ReturnedColumn* rc = buildReturnedColumnBody(item, gwi, nonSupport, isRefItem, queryType);
gwi.disableWrapping = disableWrapping;
return rc;
}
@@ -2963,7 +2959,8 @@ ReturnedColumn* buildBooleanConstantColumn(Item* item, gp_walk_info& gwi, bool&
return cc;
}
ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool isUnion)
ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bool& nonSupport,
IDBQueryType queryType)
{
if (get_fe_conn_info_ptr() == NULL)
{
@@ -2992,7 +2989,7 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
if (gwi.clauseType == SELECT || /*gwi.clauseType == HAVING || */ gwi.clauseType == GROUP_BY ||
gwi.clauseType == FROM) // select list
{
lhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, isUnion));
lhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, queryType));
if (!lhs->data() && (sfitempp[0]->type() == Item::FUNC_ITEM))
{
@@ -3007,12 +3004,12 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
gwi.fatalParseError = false;
// ReturnedColumn* rc = buildAggFrmTempField(sfitempp[0], gwi);
ReturnedColumn* rc = buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, isUnion);
ReturnedColumn* rc = buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, queryType);
if (rc)
lhs = new ParseTree(rc);
}
rhs = new ParseTree(buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, isUnion));
rhs = new ParseTree(buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, queryType));
if (!rhs->data() && (sfitempp[1]->type() == Item::FUNC_ITEM))
{
@@ -3027,7 +3024,7 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
gwi.fatalParseError = false;
// ReturnedColumn* rc = buildAggFrmTempField(sfitempp[1], gwi);
ReturnedColumn* rc = buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, isUnion);
ReturnedColumn* rc = buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, queryType);
if (rc)
rhs = new ParseTree(rc);
}
@@ -3038,7 +3035,7 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
{
if (gwi.ptWorkStack.empty())
{
rhs = new ParseTree(buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, isUnion));
rhs = new ParseTree(buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, queryType));
}
else
{
@@ -3050,7 +3047,7 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
{
if (gwi.rcWorkStack.empty())
{
rhs = new ParseTree(buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, isUnion));
rhs = new ParseTree(buildReturnedColumn(sfitempp[1], gwi, nonSupport, false, queryType));
}
else
{
@@ -3063,7 +3060,7 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
{
if (gwi.ptWorkStack.empty())
{
lhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, isUnion));
lhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, queryType));
}
else
{
@@ -3075,7 +3072,7 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
{
if (gwi.rcWorkStack.empty())
{
lhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, isUnion));
lhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, queryType));
}
else
{
@@ -3108,13 +3105,13 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
if (gwi.clauseType == SELECT || gwi.clauseType == HAVING || gwi.clauseType == GROUP_BY) // select clause
{
rhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, isUnion));
rhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, queryType));
}
else
{
if (gwi.rcWorkStack.empty())
{
rhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, isUnion));
rhs = new ParseTree(buildReturnedColumn(sfitempp[0], gwi, nonSupport, false, queryType));
}
else
{
@@ -3236,17 +3233,18 @@ ReturnedColumn* buildArithmeticColumnBody(Item_func* item, gp_walk_info& gwi, bo
}
return ac;
}
ReturnedColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool isUnion)
ReturnedColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport,
IDBQueryType queryType)
{
bool disableWrapping = gwi.disableWrapping;
gwi.disableWrapping = gwi.disableWrapping || itemDisablesWrapping(item, gwi);
ReturnedColumn* rc = buildArithmeticColumnBody(item, gwi, nonSupport, isUnion);
ReturnedColumn* rc = buildArithmeticColumnBody(item, gwi, nonSupport, queryType);
gwi.disableWrapping = disableWrapping;
return rc;
}
ReturnedColumn* buildFunctionColumnBody(Item_func* ifp, gp_walk_info& gwi, bool& nonSupport,
bool selectBetweenIn, bool isUnion)
bool selectBetweenIn, IDBQueryType queryType)
{
if (get_fe_conn_info_ptr() == NULL)
{
@@ -3309,12 +3307,12 @@ ReturnedColumn* buildFunctionColumnBody(Item_func* ifp, gp_walk_info& gwi, bool&
// Arithmetic exp
if (funcName == "+" || funcName == "-" || funcName == "*" || funcName == "/")
{
return buildArithmeticColumn(ifp, gwi, nonSupport, isUnion);
return buildArithmeticColumn(ifp, gwi, nonSupport, queryType);
}
else if (funcName == "case")
{
fc = buildCaseFunction(ifp, gwi, nonSupport, isUnion);
fc = buildCaseFunction(ifp, gwi, nonSupport, queryType);
}
else if ((funcName == "charset" || funcName == "collation") && ifp->argument_count() == 1 &&
@@ -3489,7 +3487,7 @@ ReturnedColumn* buildFunctionColumnBody(Item_func* ifp, gp_walk_info& gwi, bool&
rc = buildBooleanConstantColumn(ifp->arguments()[i], gwi, nonSupport);
else
{
rc = buildReturnedColumn(ifp->arguments()[i], gwi, nonSupport, false, isUnion);
rc = buildReturnedColumn(ifp->arguments()[i], gwi, nonSupport, false, queryType);
}
// MCOL-1510 It must be a temp table field, so find the corresponding column.
@@ -3857,16 +3855,17 @@ ReturnedColumn* buildFunctionColumnBody(Item_func* ifp, gp_walk_info& gwi, bool&
return fc;
}
ReturnedColumn* buildFunctionColumn(Item_func* ifp, gp_walk_info& gwi, bool& nonSupport, bool selectBetweenIn,
bool isUnion)
IDBQueryType queryType)
{
bool disableWrapping = gwi.disableWrapping;
gwi.disableWrapping = gwi.disableWrapping || itemDisablesWrapping(ifp, gwi);
ReturnedColumn* rc = buildFunctionColumnBody(ifp, gwi, nonSupport, selectBetweenIn, isUnion);
ReturnedColumn* rc = buildFunctionColumnBody(ifp, gwi, nonSupport, selectBetweenIn, queryType);
gwi.disableWrapping = disableWrapping;
return rc;
}
FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool isUnion)
FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonSupport,
IDBQueryType queryType)
{
if (get_fe_conn_info_ptr() == NULL)
{
@@ -3949,7 +3948,7 @@ FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonS
// rwWorkStack or ptWorkStack.
// For example, simple predicates, such as 1=1 or 1=0, land in the
// ptWorkStack but other stuff might land in the rwWorkStack
ReturnedColumn* parm = buildReturnedColumn(item->arguments()[i], gwi, nonSupport, false, isUnion);
ReturnedColumn* parm = buildReturnedColumn(item->arguments()[i], gwi, nonSupport, false, queryType);
if (parm)
{
@@ -4089,7 +4088,7 @@ ConstantColumn* buildDecimalColumn(const Item* idp, const std::string& valStr, g
return cc;
}
SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi, bool isUnion)
SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi, IDBQueryType queryType)
{
if (!gwi.csc)
{
@@ -4104,7 +4103,7 @@ SimpleColumn* buildSimpleColumn(Item_field* ifp, gp_walk_info& gwi, bool isUnion
strcmp(ifp->cached_table->db.str, "information_schema") == 0)
isInformationSchema = true;
if (isUnion && !isInformationSchema)
if (queryType == IDBQueryType::UNION && !isInformationSchema)
{
auto* rc = gwi.returnedCols[ifp->field->field_index]->clone();
rc->orderPos(ifp->field->field_index);
@@ -4569,7 +4568,7 @@ ReturnedColumn* buildAggregateColumnBody(Item* item, gp_walk_info& gwi)
case Item::FIELD_ITEM:
{
Item_field* ifp = static_cast<Item_field*>(sfitemp);
SimpleColumn* sc = buildSimpleColumn(ifp, gwi, false);
SimpleColumn* sc = buildSimpleColumn(ifp, gwi);
if (!sc)
{
@@ -5686,7 +5685,7 @@ int processGroupBy(SELECT_LEX& select_lex, gp_walk_info& gwi, const bool withRol
{
Item_field* ifp = (Item_field*)groupItem;
// this GB col could be an alias of F&E on the SELECT clause, not necessarily a field.
ReturnedColumn* rc = buildSimpleColumn(ifp, gwi, false);
ReturnedColumn* rc = buildSimpleColumn(ifp, gwi);
SimpleColumn* sc = dynamic_cast<SimpleColumn*>(rc);
if (sc)
@@ -6210,7 +6209,8 @@ int processLimitAndOffset(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep
if (gwi.subSelectType != CalpontSelectExecutionPlan::IN_SUBS &&
gwi.subSelectType != CalpontSelectExecutionPlan::EXISTS_SUBS)
{
if (select_lex.master_unit()->global_parameters()->limit_params.explicit_limit) {
if (select_lex.master_unit()->global_parameters()->limit_params.explicit_limit)
{
if (select_lex.master_unit()->global_parameters()->limit_params.offset_limit)
{
Item_int* offset =
@@ -6434,7 +6434,7 @@ int processSelect(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep, vector
collectAllCols(gwi, ifp);
break;
}
SimpleColumn* sc = buildSimpleColumn(ifp, gwi, false);
SimpleColumn* sc = buildSimpleColumn(ifp, gwi);
if (sc)
{
@@ -6840,6 +6840,85 @@ int processSelect(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep, vector
return 0;
}
int processOrderByCol(const ORDER* ordercol, gp_walk_info& gwi, IDBQueryType queryType = IDBQueryType::SELECT)
{
ReturnedColumn* rc = nullptr;
if (ordercol->in_field_list && (ordercol->counter_used || ((*ordercol->item)->type() == Item::FIELD_ITEM &&
queryType == IDBQueryType::UNION)))
{
auto* ifp = dynamic_cast<Item_field*>(*ordercol->item);
auto pos = ordercol->counter_used ? ordercol->counter - 1 : ifp->field->field_index;
rc = gwi.returnedCols[pos]->clone();
rc->orderPos(pos);
// can not be optimized off if used in order by with counter.
// set with self derived table alias if it's derived table
gwi.returnedCols[pos]->incRefCount();
}
else
{
Item* ord_item = *ordercol->item;
// ignore not_used column on order by.
if ((ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT) &&
ord_item->full_name() && !strcmp(ord_item->full_name(), "Not_used"))
{
return 0;
}
else if (ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT)
{
// DRRTUY This section looks useless b/c there is no
// way to put constant INT into an ORDER BY list
rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone();
}
else if (ord_item->type() == Item::SUBSELECT_ITEM)
{
gwi.fatalParseError = true;
}
else if ((ord_item->type() == Item::FUNC_ITEM) &&
(((Item_func*)ord_item)->functype() == Item_func::COLLATE_FUNC))
{
push_warning(gwi.thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_IGNORED,
"COLLATE is ignored in ColumnStore");
return 0;
}
else
{
rc = buildReturnedColumn(ord_item, gwi, gwi.fatalParseError, false, queryType);
rc = wrapIntoAggregate(rc, gwi, ord_item);
}
// @bug5501 try item_ptr if item can not be fixed. For some
// weird dml statement state, item can not be fixed but the
// infomation is available in item_ptr.
if (!rc || gwi.fatalParseError)
{
Item* item_ptr = ordercol->item_ptr;
while (item_ptr->type() == Item::REF_ITEM)
item_ptr = *((Item_ref*)item_ptr)->ref;
rc = buildReturnedColumn(item_ptr, gwi, gwi.fatalParseError, false, queryType);
}
if (!rc)
{
string emsg = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_ORDER_BY);
gwi.parseErrorText = emsg;
setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, emsg, gwi);
return ER_CHECK_NOT_IMPLEMENTED;
}
}
if (ordercol->direction == ORDER::ORDER_ASC)
rc->asc(true);
else
rc->asc(false);
gwi.orderByCols.emplace_back(rc);
return 0;
}
/*@brief Process ORDER BY part of a query or sub-query */
/***********************************************************
* DESCRIPTION:
@@ -6886,77 +6965,11 @@ int processOrderBy(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep,
for (; ordercol; ordercol = ordercol->next)
{
ReturnedColumn* rc = NULL;
if (ordercol->in_field_list && ordercol->counter_used)
if (auto ret = processOrderByCol(ordercol, gwi); ret != 0)
{
rc = gwi.returnedCols[ordercol->counter - 1]->clone();
rc->orderPos(ordercol->counter - 1);
// can not be optimized off if used in order by with counter.
// set with self derived table alias if it's derived table
gwi.returnedCols[ordercol->counter - 1]->incRefCount();
// Errors have already been reported.
return ret;
}
else
{
Item* ord_item = *(ordercol->item);
// ignore not_used column on order by.
if ((ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT) &&
ord_item->full_name() && !strcmp(ord_item->full_name(), "Not_used"))
{
continue;
}
else if (ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT)
{
// DRRTUY This section looks useless b/c there is no
// way to put constant INT into an ORDER BY list
rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone();
}
else if (ord_item->type() == Item::SUBSELECT_ITEM)
{
gwi.fatalParseError = true;
}
else if ((ord_item->type() == Item::FUNC_ITEM) &&
(((Item_func*)ord_item)->functype() == Item_func::COLLATE_FUNC))
{
push_warning(gwi.thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_IGNORED,
"COLLATE is ignored in ColumnStore");
continue;
}
else
{
rc = buildReturnedColumn(ord_item, gwi, gwi.fatalParseError);
rc = wrapIntoAggregate(rc, gwi, ord_item);
}
// @bug5501 try item_ptr if item can not be fixed. For some
// weird dml statement state, item can not be fixed but the
// infomation is available in item_ptr.
if (!rc || gwi.fatalParseError)
{
Item* item_ptr = ordercol->item_ptr;
while (item_ptr->type() == Item::REF_ITEM)
item_ptr = *(((Item_ref*)item_ptr)->ref);
rc = buildReturnedColumn(item_ptr, gwi, gwi.fatalParseError);
}
if (!rc)
{
string emsg = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_ORDER_BY);
gwi.parseErrorText = emsg;
setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, emsg, gwi);
return ER_CHECK_NOT_IMPLEMENTED;
}
}
if (ordercol->direction == ORDER::ORDER_ASC)
rc->asc(true);
else
rc->asc(false);
gwi.orderByCols.push_back(SRCP(rc));
}
}
@@ -7042,80 +7055,11 @@ int processOrderBy(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep,
for (; ordercol; ordercol = ordercol->next)
{
ReturnedColumn* rc = NULL;
if (ordercol->in_field_list && ordercol->item &&
(ordercol->counter_used || (*ordercol->item)->type() == Item::FIELD_ITEM))
if (auto ret = processOrderByCol(ordercol, gwi, IDBQueryType::UNION); ret != 0)
{
auto* ifp = dynamic_cast<Item_field*>(*ordercol->item);
auto pos = ordercol->counter_used ? ordercol->counter - 1 : ifp->field->field_index;
rc = gwi.returnedCols[pos]->clone();
rc->orderPos(pos);
// can not be optimized off if used in order by with counter.
// set with self derived table alias if it's derived table
gwi.returnedCols[pos]->incRefCount();
// Errors have already been reported.
return ret;
}
else
{
Item* ord_item = *(ordercol->item);
// ignore not_used column on order by.
if ((ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT) &&
ord_item->full_name() && !strcmp(ord_item->full_name(), "Not_used"))
{
continue;
}
else if (ord_item->type() == Item::CONST_ITEM && ord_item->cmp_type() == INT_RESULT)
{
// DRRTUY This section looks useless b/c there is no
// way to put constant INT into an ORDER BY list
rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone();
}
else if (ord_item->type() == Item::SUBSELECT_ITEM)
{
gwi.fatalParseError = true;
}
else if ((ord_item->type() == Item::FUNC_ITEM) &&
(((Item_func*)ord_item)->functype() == Item_func::COLLATE_FUNC))
{
push_warning(gwi.thd, Sql_condition::WARN_LEVEL_NOTE, WARN_OPTION_IGNORED,
"COLLATE is ignored in ColumnStore");
continue;
}
else
{
rc = buildReturnedColumn(ord_item, gwi, gwi.fatalParseError, false, true);
rc = wrapIntoAggregate(rc, gwi, ord_item);
}
// @bug5501 try item_ptr if item can not be fixed. For some
// weird dml statement state, item can not be fixed but the
// infomation is available in item_ptr.
if (!rc || gwi.fatalParseError)
{
Item* item_ptr = ordercol->item_ptr;
while (item_ptr->type() == Item::REF_ITEM)
item_ptr = *(((Item_ref*)item_ptr)->ref);
rc = buildReturnedColumn(item_ptr, gwi, gwi.fatalParseError, false, true);
}
if (!rc)
{
string emsg = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_ORDER_BY);
gwi.parseErrorText = emsg;
setError(gwi.thd, ER_CHECK_NOT_IMPLEMENTED, emsg, gwi);
return ER_CHECK_NOT_IMPLEMENTED;
}
}
if (ordercol->direction == ORDER::ORDER_ASC)
rc->asc(true);
else
rc->asc(false);
gwi.orderByCols.push_back(SRCP(rc));
}
}
@@ -7212,7 +7156,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
for (uint32_t i = 0; i < funcFieldVec.size(); i++)
{
SimpleColumn* sc = buildSimpleColumn(funcFieldVec[i], gwi, false);
SimpleColumn* sc = buildSimpleColumn(funcFieldVec[i], gwi);
if (!sc || gwi.fatalParseError)
{
@@ -7269,7 +7213,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
SRCP minSc; // min width projected column. for count(*) use
bool unionSel = (!isUnion && select_lex.master_unit()->is_unit_op()) ? true : false;
bool unionSel = !isUnion && select_lex.master_unit()->is_unit_op();
gwi.clauseType = GROUP_BY;
// Group by list. not valid for union main query

View File

@@ -119,7 +119,7 @@ void gp_walk(const Item* item, void* arg)
if (ifp)
{
// XXX: this looks awfuly wrong.
execplan::SimpleColumn* scp = buildSimpleColumn(ifp, *gwip, false);
execplan::SimpleColumn* scp = buildSimpleColumn(ifp, *gwip);
if (!scp)
break;

View File

@@ -30,8 +30,7 @@
#include <sstream>
#include <cerrno>
#include <cstring>
#include <time.h>
#include <cassert>
#include <ctime>
#include <vector>
#include <map>
#include <limits>
@@ -41,7 +40,6 @@
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/thread.hpp>
#include "mcs_basic_types.h"
#include "idb_mysql.h"
#define NEED_CALPONT_INTERFACE
@@ -68,7 +66,6 @@ using namespace messageqcpp;
#include "dmlpackage.h"
#include "calpontdmlpackage.h"
#include "insertdmlpackage.h"
#include "vendordmlstatement.h"
#include "calpontdmlfactory.h"
using namespace dmlpackage;
@@ -88,28 +85,19 @@ using namespace BRM;
#include "querystats.h"
using namespace querystats;
#include "calpontselectexecutionplan.h"
#include "mcsanalyzetableexecutionplan.h"
#include "calpontsystemcatalog.h"
#include "simplecolumn_int.h"
#include "simplecolumn_decimal.h"
#include "aggregatecolumn.h"
#include "constantcolumn.h"
#include "simplefilter.h"
#include "constantfilter.h"
#include "functioncolumn.h"
#include "arithmeticcolumn.h"
#include "arithmeticoperator.h"
#include "logicoperator.h"
#include "predicateoperator.h"
#include "rowcolumn.h"
#include "selectfilter.h"
using namespace execplan;
#include "joblisttypes.h"
using namespace joblist;
#include "cacheutils.h"
#include "errorcodes.h"
#include "idberrorinfo.h"
@@ -118,13 +106,10 @@ using namespace logging;
#include "resourcemanager.h"
#include "funcexp.h"
#include "functor.h"
using namespace funcexp;
#include "installdir.h"
#include "columnstoreversion.h"
#include "ha_mcs_sysvars.h"
#include "ha_mcs_datatype.h"
#include "statistics.h"
@@ -156,7 +141,8 @@ void gp_walk_info::mergeTableStatistics(const TableStatisticsMap& aTableStatisti
}
}
std::optional<ColumnStatisticsMap> gp_walk_info::findStatisticsForATable(SchemaAndTableName& schemaAndTableName)
std::optional<ColumnStatisticsMap> gp_walk_info::findStatisticsForATable(
SchemaAndTableName& schemaAndTableName)
{
auto tableStatisticsMapIt = tableStatisticsMap.find(schemaAndTableName);
if (tableStatisticsMapIt == tableStatisticsMap.end())
@@ -167,7 +153,7 @@ std::optional<ColumnStatisticsMap> gp_walk_info::findStatisticsForATable(SchemaA
return {tableStatisticsMapIt->second};
}
}
} // namespace cal_impl_if
namespace
{
@@ -927,7 +913,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
Item_field* item;
List_iterator_fast<Item> field_it(thd->lex->first_select_lex()->item_list);
List_iterator_fast<Item> value_it(thd->lex->value_list);
updateCP->queryType(CalpontSelectExecutionPlan::UPDATE);
updateCP->queryType(IDBQueryType::UPDATE);
ci->stats.fQueryType = updateCP->queryType();
tr1::unordered_set<string> timeStampColumnNames;
@@ -1211,7 +1197,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector<COND*>& c
#endif
else
{
updateCP->queryType(CalpontSelectExecutionPlan::DELETE);
updateCP->queryType(IDBQueryType::DELETE);
ci->stats.fQueryType = updateCP->queryType();
}
@@ -3383,11 +3369,13 @@ void ha_mcs_impl_start_bulk_insert(ha_rows rows, TABLE* table, bool is_cache_ins
}
if ((thd->lex)->sql_command == SQLCOM_INSERT)
ci->stats.fQueryType =
CalpontSelectExecutionPlan::queryTypeToString(CalpontSelectExecutionPlan::INSERT);
{
ci->stats.fQueryType = CalpontSelectExecutionPlan::queryTypeToString(IDBQueryType::INSERT);
}
else if ((thd->lex)->sql_command == SQLCOM_LOAD)
ci->stats.fQueryType =
CalpontSelectExecutionPlan::queryTypeToString(CalpontSelectExecutionPlan::LOAD_DATA_INFILE);
{
ci->stats.fQueryType = CalpontSelectExecutionPlan::queryTypeToString(IDBQueryType::LOAD_DATA_INFILE);
}
//@Bug 4387. Check BRM status before start statement.
boost::scoped_ptr<DBRM> dbrmp(new DBRM());

View File

@@ -438,16 +438,21 @@ void parse_item(Item* item, std::vector<Item_field*>& field_vec, bool& hasNonSup
const std::string bestTableName(const Item_field* ifp);
// execution plan util functions prototypes
execplan::ReturnedColumn* buildReturnedColumn(Item* item, gp_walk_info& gwi, bool& nonSupport,
bool isRefItem = false, bool isUnion = false);
execplan::ReturnedColumn* buildFunctionColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport,
bool selectBetweenIn = false, bool isUnion = false);
execplan::ReturnedColumn* buildArithmeticColumn(Item_func* item, gp_walk_info& gwi, bool& nonSupport,
bool isUnion);
execplan::ReturnedColumn* buildReturnedColumn(
Item* item, gp_walk_info& gwi, bool& nonSupport, bool isRefItem = false,
execplan::IDBQueryType queryType = execplan::IDBQueryType::SELECT);
execplan::ReturnedColumn* buildFunctionColumn(
Item_func* item, gp_walk_info& gwi, bool& nonSupport, bool selectBetweenIn = false,
execplan::IDBQueryType queryType = execplan::IDBQueryType::SELECT);
execplan::ReturnedColumn* buildArithmeticColumn(
Item_func* item, gp_walk_info& gwi, bool& nonSupport,
execplan::IDBQueryType queryType = execplan::IDBQueryType::SELECT);
execplan::ConstantColumn* buildDecimalColumn(const Item* item, const std::string& str, gp_walk_info& gwi);
execplan::SimpleColumn* buildSimpleColumn(Item_field* item, gp_walk_info& gwi, bool isUnion);
execplan::FunctionColumn* buildCaseFunction(Item_func* item, gp_walk_info& gwi, bool& nonSupport,
bool isUnion);
execplan::SimpleColumn* buildSimpleColumn(Item_field* item, gp_walk_info& gwi,
execplan::IDBQueryType queryType = execplan::IDBQueryType::SELECT);
execplan::FunctionColumn* buildCaseFunction(
Item_func* item, gp_walk_info& gwi, bool& nonSupport,
execplan::IDBQueryType queryType = execplan::IDBQueryType::SELECT);
execplan::ParseTree* buildParseTree(Item* item, gp_walk_info& gwi, bool& nonSupport);
execplan::ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi);
execplan::ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& nonSupport);

View File

@@ -8,7 +8,6 @@
#include "errorids.h"
#include "idberrorinfo.h"
#include "exceptclasses.h"
using namespace logging;
#include "pseudocolumn.h"
@@ -423,7 +422,7 @@ execplan::ReturnedColumn* buildPseudoColumn(Item* item, gp_walk_info& gwi, bool&
if (!field->field || !field->db_name.str || strlen(field->db_name.str) == 0)
return nullOnError(gwi, funcName);
SimpleColumn* sc = buildSimpleColumn(field, gwi, false);
SimpleColumn* sc = buildSimpleColumn(field, gwi);
if (!sc)
return nullOnError(gwi, funcName);