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

MCOL-4617 Move in-to-exists predicate creation and injection into the engine.

We earlier leveraged the server functionality provided by

Item_in_subselect::create_in_to_exists_cond and
Item_in_subselect::inject_in_to_exists_cond

to create and inject the in-to-exists predicate into an IN
subquery's JOIN struct. With this patch, we leave the IN subquery's
JOIN unaltered and instead directly perform this predicate creation
and injection into ColumnStore's select execution plan.
This commit is contained in:
Gagan Goel
2021-03-26 15:41:01 +00:00
parent 374103220c
commit f167a6e505
6 changed files with 1373 additions and 186 deletions

View File

@ -41,6 +41,7 @@ using namespace std;
#include "simplefilter.h"
#include "predicateoperator.h"
#include "rowcolumn.h"
#include "constantcolumn.h"
using namespace execplan;
#include "errorids.h"
@ -101,6 +102,17 @@ InSub::InSub(const InSub& rhs) :
InSub::~InSub()
{}
inline void setCorrelatedFlag(execplan::ReturnedColumn* col, gp_walk_info* gwip)
{
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(col);
if (!cc)
{
col->joinInfo(col->joinInfo() | JOIN_CORRELATED | JOIN_NULLMATCH_CANDIDATE);
gwip->subQuery->correlated(true);
}
}
/** MySQL transform (NOT) IN subquery to (NOT) EXIST
*
*/
@ -125,10 +137,9 @@ execplan::ParseTree* InSub::transform()
delete rhs;
ReturnedColumn* lhs = fGwip.rcWorkStack.top();
fGwip.rcWorkStack.pop();
delete lhs;
fSub = (Item_subselect*)(fFunc->arguments()[1]);
idbassert(fSub && fFunc);
idbassert(fSub);
SCSEP csep (new CalpontSelectExecutionPlan());
csep->sessionID(fGwip.sessionid);
@ -140,6 +151,24 @@ execplan::ParseTree* InSub::transform()
gwi.thd = fGwip.thd;
gwi.subQuery = this;
// The below 2 fields are used later on in buildInToExistsFilter()
gwi.inSubQueryLHS = lhs;
gwi.inSubQueryLHSItem = fFunc->arguments()[0];
RowColumn* rlhs = dynamic_cast<RowColumn*>(lhs);
if (rlhs)
{
for (auto& col : rlhs->columnVec())
{
setCorrelatedFlag(col.get(), &gwi);
}
}
else
{
setCorrelatedFlag(lhs, &gwi);
}
// @4827 merge table list to gwi in case there is FROM sub to be referenced
// in the FROM sub
gwi.derivedTbCnt = fGwip.derivedTbList.size();