1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

chore(plugin): move projection processing into a separate part.

This commit is contained in:
drrtuy
2025-05-29 16:01:37 +00:00
parent bb833ac9f6
commit bb13688ccf

View File

@ -7674,57 +7674,18 @@ void buildInToExistsFilter(gp_walk_info& gwi, SELECT_LEX& select_lex)
}
}
/*@brief Translates SELECT_LEX into CSEP */
/*@brief Process SELECT part of a query or sub-query */
/***********************************************************
* DESCRIPTION:
* This function takes SELECT_LEX and tries to produce
* a corresponding CSEP out of it. It is made of parts that
* process parts of the query, e.g. FROM, WHERE, SELECT,
* HAVING, GROUP BY, ORDER BY. FROM, WHERE, LIMIT are processed
* by corresponding methods. CS calls getSelectPlan()
* recursively to process subqueries.
* ARGS
* isUnion if true CS processes UNION unit now
* isSelectHandlerTop removes offset at the top of SH query.
* Processes SELECT part of a query or sub-query
* RETURNS
* error id as an int
***********************************************************/
int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool isUnion,
bool isSelectHandlerTop, bool isSelectLexUnit, const std::vector<COND*>& condStack)
int processSelect(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep,
vector<Item_field*>& funcFieldVec,
CalpontSelectExecutionPlan::SelectList& selectSubList)
{
#ifdef DEBUG_WALK_COND
cerr << "getSelectPlan()" << endl;
#endif
int rc = 0;
// rollup is currently not supported
bool withRollup = select_lex.olap == ROLLUP_TYPE;
setExecutionParams(gwi, csep);
gwi.subSelectType = csep->subType();
uint32_t sessionID = csep->sessionID();
gwi.sessionid = sessionID;
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
csc->identity(CalpontSystemCatalog::FE);
csep->timeZone(gwi.timeZone);
gwi.csc = csc;
CalpontSelectExecutionPlan::SelectList derivedTbList;
// @bug 1796. Remember table order on the FROM list.
gwi.clauseType = FROM;
if ((rc = processFrom(isUnion, select_lex, gwi, csep, isSelectHandlerTop, isSelectLexUnit)))
{
return rc;
}
gwi.clauseType = WHERE;
if ((rc = processWhere(select_lex, gwi, csep, condStack)))
{
return rc;
}
gwi.clauseType = SELECT;
SELECT_LEX* oldSelectLex = gwi.select_lex; // XXX: SZ: should it be restored in case of error return?
gwi.select_lex = &select_lex;
#ifdef DEBUG_WALK_COND
{
@ -7770,7 +7731,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
// populate returnedcolumnlist and columnmap
List_iterator_fast<Item> it(select_lex.item_list);
Item* item;
vector<Item_field*> funcFieldVec;
// empty rcWorkStack and ptWorkStack. They should all be empty by now.
clearStacks(gwi, false, true);
@ -7785,7 +7745,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
scalar->returnedColPos(gwi.additionalRetCols.size());
}
CalpontSelectExecutionPlan::SelectList selectSubList;
while ((item = it++))
{
@ -8220,6 +8179,67 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
}
}
}
return 0;
}
/*@brief Translates SELECT_LEX into CSEP */
/***********************************************************
* DESCRIPTION:
* This function takes SELECT_LEX and tries to produce
* a corresponding CSEP out of it. It is made of parts that
* process parts of the query, e.g. FROM, WHERE, SELECT,
* HAVING, GROUP BY, ORDER BY. FROM, WHERE, LIMIT are processed
* by corresponding methods. CS calls getSelectPlan()
* recursively to process subqueries.
* ARGS
* isUnion if true CS processes UNION unit now
* isSelectHandlerTop removes offset at the top of SH query.
* RETURNS
* error id as an int
***********************************************************/
int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool isUnion,
bool isSelectHandlerTop, bool isSelectLexUnit, const std::vector<COND*>& condStack)
{
#ifdef DEBUG_WALK_COND
cerr << "getSelectPlan()" << endl;
#endif
int rc = 0;
// rollup is currently not supported
bool withRollup = select_lex.olap == ROLLUP_TYPE;
setExecutionParams(gwi, csep);
gwi.subSelectType = csep->subType();
uint32_t sessionID = csep->sessionID();
gwi.sessionid = sessionID;
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
csc->identity(CalpontSystemCatalog::FE);
csep->timeZone(gwi.timeZone);
gwi.csc = csc;
CalpontSelectExecutionPlan::SelectList derivedTbList;
// @bug 1796. Remember table order on the FROM list.
gwi.clauseType = FROM;
if ((rc = processFrom(isUnion, select_lex, gwi, csep, isSelectHandlerTop, isSelectLexUnit)))
{
return rc;
}
gwi.clauseType = WHERE;
if ((rc = processWhere(select_lex, gwi, csep, condStack)))
{
return rc;
}
gwi.clauseType = SELECT;
SELECT_LEX* originalSelectLex = gwi.select_lex; // XXX: SZ: should it be restored in case of error return?
vector<Item_field*> funcFieldVec;
CalpontSelectExecutionPlan::SelectList selectSubList;
if ((rc = processSelect(select_lex, gwi, csep, funcFieldVec, selectSubList)))
{
return rc;
}
// Having clause handling
gwi.clauseType = HAVING;
@ -8994,7 +9014,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, bool i
for (uint32_t i = 0; i < gwi.localCols.size(); i++)
gwi.localCols[i]->sequence(i);
gwi.select_lex = oldSelectLex;
gwi.select_lex = originalSelectLex;
// append additionalRetCols to returnedCols
gwi.returnedCols.insert(gwi.returnedCols.begin(), gwi.additionalRetCols.begin(),
gwi.additionalRetCols.end());