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

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

170
dbcon/mysql/ha_exists_sub.cpp Executable file → Normal file
View File

@ -46,33 +46,38 @@ extern void makeAntiJoin(const ParseTree* n);
void checkCorrelation(const ParseTree* n, void* obj)
{
ExistsFilter *ef = reinterpret_cast<ExistsFilter*>(obj);
TreeNode *tn = n->data();
SimpleFilter *sf = dynamic_cast<SimpleFilter*>(tn);
if (!sf)
return;
uint64_t lJoinInfo = sf->lhs()->joinInfo();
uint64_t rJoinInfo = sf->rhs()->joinInfo();
ExistsFilter* ef = reinterpret_cast<ExistsFilter*>(obj);
TreeNode* tn = n->data();
SimpleFilter* sf = dynamic_cast<SimpleFilter*>(tn);
if (lJoinInfo & JOIN_CORRELATED)
{
ConstantColumn *cc = dynamic_cast<ConstantColumn*>(sf->rhs());
if ((!cc || (cc && sf->op()->op() == OP_EQ)) && !(rJoinInfo & JOIN_CORRELATED))
ef->correlated(true);
}
if (rJoinInfo & JOIN_CORRELATED)
{
ConstantColumn *cc = dynamic_cast<ConstantColumn*>(sf->lhs());
if ((!cc || (cc && sf->op()->op() == OP_EQ)) && !(lJoinInfo & JOIN_CORRELATED))
ef->correlated(true);
}
if (!sf)
return;
uint64_t lJoinInfo = sf->lhs()->joinInfo();
uint64_t rJoinInfo = sf->rhs()->joinInfo();
if (lJoinInfo & JOIN_CORRELATED)
{
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(sf->rhs());
if ((!cc || (cc && sf->op()->op() == OP_EQ)) && !(rJoinInfo & JOIN_CORRELATED))
ef->correlated(true);
}
if (rJoinInfo & JOIN_CORRELATED)
{
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(sf->lhs());
if ((!cc || (cc && sf->op()->op() == OP_EQ)) && !(lJoinInfo & JOIN_CORRELATED))
ef->correlated(true);
}
}
ExistsSub::ExistsSub(gp_walk_info& gwip) : WhereSubQuery(gwip)
{}
ExistsSub::ExistsSub(gp_walk_info& gwip, Item_subselect* sub) :
WhereSubQuery(gwip, sub)
WhereSubQuery(gwip, sub)
{}
ExistsSub::~ExistsSub()
@ -80,63 +85,69 @@ ExistsSub::~ExistsSub()
execplan::ParseTree* ExistsSub::transform()
{
idbassert(fSub);
idbassert(fSub);
SCSEP csep(new CalpontSelectExecutionPlan());
csep->sessionID(fGwip.sessionid);
csep->location(CalpontSelectExecutionPlan::WHERE);
csep->subType (CalpontSelectExecutionPlan::EXISTS_SUBS);
SCSEP csep(new CalpontSelectExecutionPlan());
csep->sessionID(fGwip.sessionid);
csep->location(CalpontSelectExecutionPlan::WHERE);
csep->subType (CalpontSelectExecutionPlan::EXISTS_SUBS);
// gwi for the sub query
gp_walk_info gwi;
gwi.thd = fGwip.thd;
gwi.subQuery = this;
// gwi for the sub query
gp_walk_info gwi;
gwi.thd = fGwip.thd;
gwi.subQuery = this;
// @4827 merge table list to gwi in case there is FROM sub to be referenced
// in the FROM sub
gwi.derivedTbCnt = fGwip.derivedTbList.size();
uint32_t tbCnt = fGwip.tbList.size();
// @4827 merge table list to gwi in case there is FROM sub to be referenced
// in the FROM sub
gwi.derivedTbCnt = fGwip.derivedTbList.size();
uint32_t tbCnt = fGwip.tbList.size();
gwi.tbList.insert(gwi.tbList.begin(), fGwip.tbList.begin(), fGwip.tbList.end());
gwi.derivedTbList.insert(gwi.derivedTbList.begin(), fGwip.derivedTbList.begin(), fGwip.derivedTbList.end());
gwi.tbList.insert(gwi.tbList.begin(), fGwip.tbList.begin(), fGwip.tbList.end());
gwi.derivedTbList.insert(gwi.derivedTbList.begin(), fGwip.derivedTbList.begin(), fGwip.derivedTbList.end());
if (fSub->get_select_lex()->with_sum_func)
{
fGwip.fatalParseError = true;
fGwip.parseErrorText = logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_AGG_EXISTS);
return NULL;
}
if (fSub->get_select_lex()->with_sum_func)
{
fGwip.fatalParseError = true;
fGwip.parseErrorText = logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_AGG_EXISTS);
return NULL;
}
if (getSelectPlan(gwi, *(fSub->get_select_lex()), csep) != 0)
{
fGwip.fatalParseError = true;
if (gwi.fatalParseError && !gwi.parseErrorText.empty())
fGwip.parseErrorText = gwi.parseErrorText;
else
fGwip.parseErrorText = "Error occured in ExistsSub::transform()";
return NULL;
}
if (getSelectPlan(gwi, *(fSub->get_select_lex()), csep) != 0)
{
fGwip.fatalParseError = true;
// remove outer query tables
CalpontSelectExecutionPlan::TableList tblist;
if (csep->tableList().size() >= tbCnt)
tblist.insert(tblist.begin(),csep->tableList().begin()+tbCnt, csep->tableList().end());
CalpontSelectExecutionPlan::SelectList derivedTbList;
if (csep->derivedTableList().size() >= gwi.derivedTbCnt)
derivedTbList.insert(derivedTbList.begin(), csep->derivedTableList().begin()+gwi.derivedTbCnt, csep->derivedTableList().end());
if (gwi.fatalParseError && !gwi.parseErrorText.empty())
fGwip.parseErrorText = gwi.parseErrorText;
else
fGwip.parseErrorText = "Error occured in ExistsSub::transform()";
csep->tableList(tblist);
csep->derivedTableList(derivedTbList);
return NULL;
}
ExistsFilter *subFilter = new ExistsFilter();
subFilter->correlated(false);
subFilter->sub(csep);
const ParseTree* pt = csep->filters();
if (pt)
pt->walk(checkCorrelation, subFilter);
// remove outer query tables
CalpontSelectExecutionPlan::TableList tblist;
fGwip.subselectList.push_back(csep);
return new ParseTree(subFilter);
if (csep->tableList().size() >= tbCnt)
tblist.insert(tblist.begin(), csep->tableList().begin() + tbCnt, csep->tableList().end());
CalpontSelectExecutionPlan::SelectList derivedTbList;
if (csep->derivedTableList().size() >= gwi.derivedTbCnt)
derivedTbList.insert(derivedTbList.begin(), csep->derivedTableList().begin() + gwi.derivedTbCnt, csep->derivedTableList().end());
csep->tableList(tblist);
csep->derivedTableList(derivedTbList);
ExistsFilter* subFilter = new ExistsFilter();
subFilter->correlated(false);
subFilter->sub(csep);
const ParseTree* pt = csep->filters();
if (pt)
pt->walk(checkCorrelation, subFilter);
fGwip.subselectList.push_back(csep);
return new ParseTree(subFilter);
}
/**
@ -146,17 +157,20 @@ execplan::ParseTree* ExistsSub::transform()
*/
void ExistsSub::handleNot()
{
ParseTree *pt = fGwip.ptWorkStack.top();
ExistsFilter *subFilter = dynamic_cast<ExistsFilter*>(pt->data());
idbassert(subFilter);
subFilter->notExists(true);
SCSEP csep = subFilter->sub();
const ParseTree* ptsub = csep->filters();
if (ptsub)
ptsub->walk(makeAntiJoin);
ptsub = csep->having();
if (ptsub)
ptsub->walk(makeAntiJoin);
ParseTree* pt = fGwip.ptWorkStack.top();
ExistsFilter* subFilter = dynamic_cast<ExistsFilter*>(pt->data());
idbassert(subFilter);
subFilter->notExists(true);
SCSEP csep = subFilter->sub();
const ParseTree* ptsub = csep->filters();
if (ptsub)
ptsub->walk(makeAntiJoin);
ptsub = csep->having();
if (ptsub)
ptsub->walk(makeAntiJoin);
}
}