//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalRandomMotion::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalRandomMotion::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);

	GPOS_ASSERT(m_pdrgpiInputSegIds != NULL);
	GPOS_ASSERT(0 < m_pdrgpiInputSegIds->UlLength());
	GPOS_ASSERT(m_pdrgpiOutputSegIds != NULL);
	GPOS_ASSERT(0 < m_pdrgpiOutputSegIds->UlLength());

	GPOS_ASSERT(EdxlrandommIndexSentinel == pdxln->UlArity());
	
	CDXLNode *pdxlnChild = (*pdxln)[EdxlrandommIndexChild];
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());
	
	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarWindowFrameEdge::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarWindowFrameEdge::AssertValid
(
    const CDXLNode *pdxln,
    BOOL fValidateChildren
)
const
{
    const ULONG ulArity = pdxln->UlArity();
    GPOS_ASSERT(1 >= ulArity);

    GPOS_ASSERT_IMP((m_edxlfb == EdxlfbBoundedPreceding || m_edxlfb == EdxlfbBoundedFollowing
                     || m_edxlfb == EdxlfbDelayedBoundedPreceding || m_edxlfb == EdxlfbDelayedBoundedFollowing), 1 == ulArity);
    GPOS_ASSERT_IMP((m_edxlfb == EdxlfbUnboundedPreceding || m_edxlfb == EdxlfbUnboundedFollowing || m_edxlfb == EdxlfbCurrentRow), 0 == ulArity);

    for (ULONG ul = 0; ul < ulArity; ++ul)
    {
        CDXLNode *pdxlnArg = (*pdxln)[ul];
        GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());

        if (fValidateChildren)
        {
            pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
        }
    }
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarBitmapBoolOp::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarBitmapBoolOp::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	EdxlBitmapBoolOp edxlbitmapboolop = ((CDXLScalarBitmapBoolOp *) pdxln->Pdxlop())->Edxlbitmapboolop();

	GPOS_ASSERT( (edxlbitmapboolop == EdxlbitmapAnd) || (edxlbitmapboolop == EdxlbitmapOr));

	ULONG ulArity = pdxln->UlArity();
	GPOS_ASSERT(2 == ulArity);
	

	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnArg = (*pdxln)[ul];
		Edxlopid edxlop = pdxlnArg->Pdxlop()->Edxlop();
		
		GPOS_ASSERT(EdxlopScalarBitmapBoolOp == edxlop || EdxlopScalarBitmapIndexProbe == edxlop);
		
		if (fValidateChildren)
		{
			pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
		}
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarBoolExpr::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarBoolExpr::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	EdxlBoolExprType edxlbooltype = ((CDXLScalarBoolExpr *) pdxln->Pdxlop())->EdxlBoolType();

	GPOS_ASSERT( (edxlbooltype == Edxlnot) || (edxlbooltype == Edxlor) || (edxlbooltype == Edxland));

	const ULONG ulArity = pdxln->UlArity();
	if(edxlbooltype == Edxlnot)
	{
		GPOS_ASSERT(1 == ulArity);
	}
	else
	{
		GPOS_ASSERT(2 <= ulArity);
	}

	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnArg = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());
		
		if (fValidateChildren)
		{
			pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
		}
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLLogicalWindow::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLLogicalWindow::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	GPOS_ASSERT(2 == pdxln->UlArity());

	CDXLNode *pdxlnProjList = (*pdxln)[0];
	CDXLNode *pdxlnChild = (*pdxln)[1];

	GPOS_ASSERT(EdxlopScalarProjectList == pdxlnProjList->Pdxlop()->Edxlop());
	GPOS_ASSERT(EdxloptypeLogical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnProjList->Pdxlop()->AssertValid(pdxlnProjList, fValidateChildren);
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}

	const ULONG ulArity = pdxlnProjList->UlArity();
	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnPrEl = (*pdxlnProjList)[ul];
		GPOS_ASSERT(EdxlopScalarIdent != pdxlnPrEl->Pdxlop()->Edxlop());
	}

	GPOS_ASSERT(NULL != m_pdrgpdxlws);
	GPOS_ASSERT(0 < m_pdrgpdxlws->UlLength());
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalResult::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalResult::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{

	GPOS_ASSERT(EdxlresultIndexSentinel >= pdxln->UlArity());
	
	// check that one time filter is valid
	CDXLNode *pdxlnOneTimeFilter = (*pdxln)[EdxlresultIndexOneTimeFilter];
	GPOS_ASSERT(EdxlopScalarOneTimeFilter == pdxlnOneTimeFilter->Pdxlop()->Edxlop());
	
	if (fValidateChildren)
	{
		pdxlnOneTimeFilter->Pdxlop()->AssertValid(pdxlnOneTimeFilter, fValidateChildren);
	}
	
	if (EdxlresultIndexSentinel == pdxln->UlArity())
	{
		CDXLNode *pdxlnChild = (*pdxln)[EdxlresultIndexChild];
		GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

		if (fValidateChildren)
		{
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}

}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalIndexScan::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalIndexScan::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);

	// index scan has only 3 children
	GPOS_ASSERT(3 == pdxln->UlArity());

	// assert validity of the index descriptor
	GPOS_ASSERT(NULL != m_pdxlid);
	GPOS_ASSERT(NULL != m_pdxlid->Pmdname());
	GPOS_ASSERT(m_pdxlid->Pmdname()->Pstr()->FValid());

	// assert validity of the table descriptor
	GPOS_ASSERT(NULL != m_pdxltabdesc);
	GPOS_ASSERT(NULL != m_pdxltabdesc->Pmdname());
	GPOS_ASSERT(m_pdxltabdesc->Pmdname()->Pstr()->FValid());

	CDXLNode *pdxlnIndexConds = (*pdxln)[EdxlisIndexCondition];

	// assert children are of right type (physical/scalar)
	GPOS_ASSERT(EdxlopScalarIndexCondList == pdxlnIndexConds->Pdxlop()->Edxlop());

	if (fValidateChildren)
	{
		pdxlnIndexConds->Pdxlop()->AssertValid(pdxlnIndexConds, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalLimit::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalLimit::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	GPOS_ASSERT(4 == pdxln->UlArity());

	// Assert proj list is valid
	CDXLNode *pdxlnProjList = (*pdxln)[EdxllimitIndexProjList];
	GPOS_ASSERT(EdxlopScalarProjectList == pdxlnProjList->Pdxlop()->Edxlop());

	// assert child plan is a physical plan and is valid

	CDXLNode *pdxlnChild = (*pdxln)[EdxllimitIndexChildPlan];
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

	// Assert the validity of Count and Offset

	CDXLNode *pdxlnCount = (*pdxln)[EdxllimitIndexLimitCount];
	GPOS_ASSERT(EdxlopScalarLimitCount == pdxlnCount->Pdxlop()->Edxlop());

	CDXLNode *pdxlnOffset = (*pdxln)[EdxllimitIndexLimitOffset];
	GPOS_ASSERT(EdxlopScalarLimitOffset == pdxlnOffset->Pdxlop()->Edxlop());

	if (fValidateChildren)
	{
		pdxlnProjList->Pdxlop()->AssertValid(pdxlnProjList, fValidateChildren);
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		pdxlnCount->Pdxlop()->AssertValid(pdxlnCount, fValidateChildren);
		pdxlnOffset->Pdxlop()->AssertValid(pdxlnOffset, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalMergeJoin::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalMergeJoin::AssertValid
(
    const CDXLNode *pdxln,
    BOOL fValidateChildren
)
const
{
    // assert proj list and filter are valid
    CDXLPhysical::AssertValid(pdxln, fValidateChildren);

    GPOS_ASSERT(EdxlmjIndexSentinel == pdxln->UlArity());
    GPOS_ASSERT(EdxljtSentinel > Edxltype());

    CDXLNode *pdxlnJoinFilter = (*pdxln)[EdxlmjIndexJoinFilter];
    CDXLNode *pdxlnMergeClauses = (*pdxln)[EdxlmjIndexMergeCondList];
    CDXLNode *pdxlnLeft = (*pdxln)[EdxlmjIndexLeftChild];
    CDXLNode *pdxlnRight = (*pdxln)[EdxlmjIndexRightChild];

    // assert children are of right type (physical/scalar)
    GPOS_ASSERT(EdxlopScalarJoinFilter == pdxlnJoinFilter->Pdxlop()->Edxlop());
    GPOS_ASSERT(EdxlopScalarMergeCondList == pdxlnMergeClauses->Pdxlop()->Edxlop());
    GPOS_ASSERT(EdxloptypePhysical == pdxlnLeft->Pdxlop()->Edxloperatortype());
    GPOS_ASSERT(EdxloptypePhysical == pdxlnRight->Pdxlop()->Edxloperatortype());

    if (fValidateChildren)
    {
        pdxlnJoinFilter->Pdxlop()->AssertValid(pdxlnJoinFilter, fValidateChildren);
        pdxlnMergeClauses->Pdxlop()->AssertValid(pdxlnMergeClauses, fValidateChildren);
        pdxlnLeft->Pdxlop()->AssertValid(pdxlnLeft, fValidateChildren);
        pdxlnRight->Pdxlop()->AssertValid(pdxlnRight, fValidateChildren);
    }
}
Beispiel #10
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalDML::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalDML::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	GPOS_ASSERT(2 == pdxln->UlArity());
	CDXLNode *pdxlnChild = (*pdxln)[1];
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Beispiel #11
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarCoerceViaIO::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarCoerceViaIO::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	GPOS_ASSERT(1 == pdxln->UlArity());

	CDXLNode *pdxlnChild = (*pdxln)[0];
	GPOS_ASSERT(EdxloptypeScalar == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLLogicalDelete::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLLogicalDelete::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	GPOS_ASSERT(1 == pdxln->UlArity());

	CDXLNode *pdxlnChild = (*pdxln)[0];
	GPOS_ASSERT(EdxloptypeLogical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalCTEConsumer::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalCTEConsumer::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	GPOS_ASSERT(1 == pdxln->UlArity());

	CDXLNode *pdxlnPrL = (*pdxln)[0];
	GPOS_ASSERT(EdxlopScalarProjectList == pdxlnPrL->Pdxlop()->Edxlop());

	if (fValidateChildren)
	{
		pdxlnPrL->Pdxlop()->AssertValid(pdxlnPrL, fValidateChildren);
	}

}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalMaterialize::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalMaterialize::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	GPOS_ASSERT(EdxlspoolNone == m_edxlsptype || EdxlspoolMaterialize == m_edxlsptype);
	GPOS_ASSERT(EdxlmatIndexSentinel == pdxln->UlArity());

	CDXLNode *pdxlnChild = (*pdxln)[EdxlmatIndexChild];
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarSortColList::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLScalarSortColList::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	const ULONG ulArity = pdxln->UlArity();
	for (ULONG ul = 0; ul < ulArity; ul++)
	{
		CDXLNode *pdxlnChild = (*pdxln)[ul];
		GPOS_ASSERT(EdxlopScalarSortCol == pdxlnChild->Pdxlop()->Edxlop());
		
		if (fValidateChildren)
		{
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarIndexCondList::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarIndexCondList::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	GPOS_ASSERT(NULL != pdxln);

	if (fValidateChildren)
	{
		const ULONG ulArity = pdxln->UlArity();
		for (ULONG ul = 0; ul < ulArity; ul++)
		{
			CDXLNode *pdxlnChild = (*pdxln)[ul];
			GPOS_ASSERT(EdxloptypeScalar == pdxlnChild->Pdxlop()->Edxloperatortype());
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}
}
Beispiel #17
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalSort::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalSort::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);
	
	GPOS_ASSERT(EdxlsortIndexSentinel == pdxln->UlArity());
	
	CDXLNode *pdxlnSortColList = (*pdxln)[EdxlsortIndexSortColList];
	CDXLNode *pdxlnChild = (*pdxln)[EdxlsortIndexChild];
	CDXLNode *pdxlnLimitCount = (*pdxln)[EdxlsortIndexLimitCount];
	CDXLNode *pdxlnLimitOffset = (*pdxln)[EdxlsortIndexLimitOffset];
	
	// assert children are of right type (physical/scalar)
	GPOS_ASSERT(EdxloptypeScalar == pdxlnSortColList->Pdxlop()->Edxloperatortype());
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());
	GPOS_ASSERT(EdxlopScalarLimitCount == pdxlnLimitCount->Pdxlop()->Edxlop());
	GPOS_ASSERT(EdxlopScalarLimitOffset == pdxlnLimitOffset->Pdxlop()->Edxlop());
	
	// there must be at least one sorting column
	GPOS_ASSERT(pdxlnSortColList->UlArity() > 0);
	
	if (fValidateChildren)
	{
		pdxlnSortColList->Pdxlop()->AssertValid(pdxlnSortColList, fValidateChildren);
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarSubPlan::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarSubPlan::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	GPOS_ASSERT(EdxlSubPlanIndexSentinel == pdxln->UlArity());

	// assert child plan is a physical plan and is valid

	CDXLNode *pdxlnChild = (*pdxln)[EdxlSubPlanIndexChildPlan];
	GPOS_ASSERT(NULL != pdxlnChild);
	GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());
	GPOS_ASSERT_IMP(NULL != m_pdxlnTestExpr, EdxloptypeScalar == m_pdxlnTestExpr->Pdxlop()->Edxloperatortype());

	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Beispiel #19
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarIfStmt::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarIfStmt::AssertValid
(
    const CDXLNode *pdxln,
    BOOL fValidateChildren
)
const
{
    const ULONG ulArity = pdxln->UlArity();
    GPOS_ASSERT(3 == ulArity);

    for (ULONG ul = 0; ul < ulArity; ++ul)
    {
        CDXLNode *pdxlnArg = (*pdxln)[ul];
        GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());

        if (fValidateChildren)
        {
            pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
        }
    }
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalAppend::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLPhysicalAppend::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);
	
	const ULONG ulChildren = pdxln->UlArity();
	for (ULONG ul = EdxlappendIndexFirstChild; ul < ulChildren; ul++)
	{
		CDXLNode *pdxlnChild = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());
		
		if (fValidateChildren)
		{
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}
	
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalSequence::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalSequence::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{

	const ULONG ulArity = pdxln->UlArity();  
	GPOS_ASSERT(1 < ulArity);

	for (ULONG ul = 1; ul < ulArity; ul++)
	{
		CDXLNode *pdxlnChild = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypePhysical == pdxlnChild->Pdxlop()->Edxloperatortype());

		if (fValidateChildren)
		{
			pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
		}
	}

}
Beispiel #22
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarAggref::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarAggref::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	) 
	const
{
	EdxlAggrefStage edxlaggrefstage = ((CDXLScalarAggref*) pdxln->Pdxlop())->Edxlaggstage();

	GPOS_ASSERT((EdxlaggstageFinal >= edxlaggrefstage) && (EdxlaggstageNormal <= edxlaggrefstage));

	const ULONG ulArity = pdxln->UlArity();
	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnAggrefArg = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypeScalar == pdxlnAggrefArg->Pdxlop()->Edxloperatortype());
		
		if (fValidateChildren)
		{
			pdxlnAggrefArg->Pdxlop()->AssertValid(pdxlnAggrefArg, fValidateChildren);
		}
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLScalarWindowRef::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLScalarWindowRef::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	EdxlWinStage edxlwinrefstage = ((CDXLScalarWindowRef*) pdxln->Pdxlop())->Edxlwinstage();

	GPOS_ASSERT((EdxlwinstageSentinel >= edxlwinrefstage));

	const ULONG ulArity = pdxln->UlArity();
	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnWinrefArg = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypeScalar == pdxlnWinrefArg->Pdxlop()->Edxloperatortype());

		if (fValidateChildren)
		{
			pdxlnWinrefArg->Pdxlop()->AssertValid(pdxlnWinrefArg, fValidateChildren);
		}
	}
}
Beispiel #24
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalTVF::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalTVF::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	// assert validity of function id and return type
	GPOS_ASSERT(NULL != m_pmdidFunc);
	GPOS_ASSERT(NULL != m_pmdidRetType);

	const ULONG ulArity = pdxln->UlArity();
	for (ULONG ul = 0; ul < ulArity; ++ul)
	{
		CDXLNode *pdxlnArg = (*pdxln)[ul];
		GPOS_ASSERT(EdxloptypeScalar == pdxlnArg->Pdxlop()->Edxloperatortype());

		if (fValidateChildren)
		{
			pdxlnArg->Pdxlop()->AssertValid(pdxlnArg, fValidateChildren);
		}
	}
}
Beispiel #25
0
//---------------------------------------------------------------------------
//	@function:
//		CDXLNode::AssertValid
//
//	@doc:
//		Checks whether node is well-structured 
//
//---------------------------------------------------------------------------
void
CDXLNode::AssertValid
	(
	BOOL fValidateChildren
	) 
	const
{
	if (!fValidateChildren)
	{
		return;
	}
	
	const ULONG ulArity = UlArity();
	for (ULONG ul = 0; ul < ulArity; ul++)
	{
		CDXLNode *pdxlnChild = (*this)[ul];
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CDXLPhysicalWindow::AssertValid
//
//	@doc:
//		Checks whether operator node is well-structured
//
//---------------------------------------------------------------------------
void
CDXLPhysicalWindow::AssertValid
	(
	const CDXLNode *pdxln,
	BOOL fValidateChildren
	)
	const
{
	// assert proj list and filter are valid
	CDXLPhysical::AssertValid(pdxln, fValidateChildren);
	GPOS_ASSERT(NULL != m_pdrgpulPartCols);
	GPOS_ASSERT(NULL != m_pdrgpdxlwk);
	GPOS_ASSERT(EdxlwindowIndexSentinel == pdxln->UlArity());
	CDXLNode *pdxlnChild = (*pdxln)[EdxlwindowIndexChild];
	if (fValidateChildren)
	{
		pdxlnChild->Pdxlop()->AssertValid(pdxlnChild, fValidateChildren);
	}
}
Beispiel #27
0
//---------------------------------------------------------------------------
//	@function:
//		CTranslatorDXLToQuery::TranslateProjList
//
//	@doc:
//		Translates a DXL projection list
//
//---------------------------------------------------------------------------
void
CTranslatorDXLToQuery::TranslateProjList
	(
	const CDXLNode *pdxlnPrL,
	CStateDXLToQuery *pstatedxltoquery,
	CMappingColIdVarQuery *pmapcidvarquery,
	ULONG ulTargetEntryIndex
	)
{
	if (NULL != pdxlnPrL)
	{
		// translate each DXL project element into a target entry
		const ULONG ulArity = pdxlnPrL->UlArity();
		for (ULONG ul = 0; ul < ulArity; ++ul)
		{
			CDXLNode *pdxlnPrEl = (*pdxlnPrL)[ul];
			CDXLScalarProjElem *pdxlopPrEl = CDXLScalarProjElem::PdxlopConvert(pdxlnPrEl->Pdxlop());

			GPOS_ASSERT(1 == pdxlnPrEl->UlArity());
			// translate proj element expression
			CDXLNode *pdxlnExpr = (*pdxlnPrEl)[0];

			Expr *pexpr = m_pdxlsctranslator->PexprFromDXLNodeScalar(pdxlnExpr, pmapcidvarquery);

			GPOS_ASSERT(NULL != pexpr);

			TargetEntry *pte = MakeNode(TargetEntry);
			pte->expr = pexpr;
			pte->resname = CTranslatorUtils::SzFromWsz(pdxlopPrEl->PmdnameAlias()->Pstr()->Wsz());
			pte->resno = (AttrNumber) (ulTargetEntryIndex + ul + 1);

			pstatedxltoquery->AddOutputColumnEntry(pte, pte->resname, pdxlopPrEl->UlId());
			//save mapping col id -> Var in the query translation context
			pmapcidvarquery->FInsertMapping(pdxlopPrEl->UlId(), pte);
		}
	}
}
//---------------------------------------------------------------------------
//	@function:
//		CConstExprEvaluatorDXL::PexprEval
//
//	@doc:
//		Evaluate the given expression and return the result as a new expression.
//		Caller takes ownership of returned expression
//
//---------------------------------------------------------------------------
CExpression *
CConstExprEvaluatorDXL::PexprEval
	(
	CExpression *pexpr
	)
{
	GPOS_ASSERT(NULL != pexpr);

	const CHAR *szErrorMsg = "";
	if (!FValidInput(pexpr, &szErrorMsg))
	{
		GPOS_RAISE(gpopt::ExmaGPOPT, gpopt::ExmiEvalUnsupportedScalarExpr, szErrorMsg);
	}
	CDXLNode *pdxlnExpr = m_trexpr2dxl.PdxlnScalar(pexpr);
	CDXLNode *pdxlnResult = m_pconstdxleval->PdxlnEvaluateExpr(pdxlnExpr);

	GPOS_ASSERT(EdxloptypeScalar == pdxlnResult->Pdxlop()->Edxloperatortype());

	CExpression *pexprResult = m_trdxl2expr.PexprTranslateScalar(pdxlnResult, NULL /*pdrgpcr*/);
	pdxlnResult->Release();
	pdxlnExpr->Release();

	return pexprResult;
}
Beispiel #29
0
//---------------------------------------------------------------------------
//	@function:
//		CTranslatorDXLToQuery::SetQueryOutput
//
//	@doc:
//		Set query target list based on the DXL query output
//
//---------------------------------------------------------------------------
void
CTranslatorDXLToQuery::SetQueryOutput
	(
	const DrgPdxln *pdrgpdxlnQueryOutput,
	Query *pquery,
	CStateDXLToQuery *pstatedxltoquery,
	CMappingColIdVarQuery *pmapcidvarquery
	)
{
	GPOS_ASSERT(NULL != pdrgpdxlnQueryOutput && NULL != pquery);

	CStateDXLToQuery *pstatedxltoqueryOutput = New(m_pmp) CStateDXLToQuery(m_pmp);

	List *plTE = NIL;

	ULONG ulResno = 0;
	const ULONG ulLen = pdrgpdxlnQueryOutput->UlLength();
	// translate each DXL scalar ident into a target entry
	for (ULONG ul = 0; ul < ulLen; ul++)
	{
		CDXLNode *pdxlnIdent = (*pdrgpdxlnQueryOutput)[ul];
		CDXLScalarIdent *pdxlop = CDXLScalarIdent::PdxlopConvert(pdxlnIdent->Pdxlop());
		const CDXLColRef *pdxlcr = pdxlop->Pdxlcr();

		GPOS_ASSERT(NULL != pdxlcr);
		const ULONG ulColId = pdxlcr->UlID();
		const CMDName *pmdname = pdxlcr->Pmdname();
		const TargetEntry *pte = pmapcidvarquery->Pte(ulColId);

		ulResno++;
		TargetEntry *pteCopy =  (TargetEntry*) gpdb::PvCopyObject(const_cast<TargetEntry*>(pte));
		pteCopy->resname = CTranslatorUtils::SzFromWsz(pmdname->Pstr()->Wsz());
		pteCopy->resno = (AttrNumber) ulResno;

		pstatedxltoqueryOutput->AddOutputColumnEntry(pteCopy, pteCopy->resname, ulColId);
		plTE = gpdb::PlAppendElement(plTE, pteCopy);
	}

	const ULONG ulSize = pstatedxltoquery->UlLength();

	// Add grouping and ordering columns that are not in the query output in the
	// target list as resjunk entries.

	ULONG ulCounter = 0;

	for (ULONG ul = 0; ul < ulSize ; ul++)
	{
		TargetEntry *pte = pstatedxltoquery->PteColumn(ul);
		GPOS_ASSERT(NULL != pte);

		// we are only interested in grouping and ordering columns
		if(pte->ressortgroupref > 0)
		{
			// check if we have already added the corresponding pte entry in pplTE
			BOOL fres = pstatedxltoqueryOutput->FTEFound(pte);

			if(!fres)
			{
				ULONG ulColId = pstatedxltoquery->UlColId(ul);

				ulResno++;
				// copy the entries
				TargetEntry *pteCopy =  (TargetEntry*) gpdb::PvCopyObject(pte);
				pteCopy->resno = (AttrNumber) ulResno;
				pteCopy->resjunk = true;

				pstatedxltoqueryOutput->AddOutputColumnEntry(pteCopy, pteCopy->resname, ulColId);
				plTE = gpdb::PlAppendElement(plTE, pteCopy);
			}
		}
		ulCounter++;
	}

	pstatedxltoquery->Reload(pstatedxltoqueryOutput);
	delete pstatedxltoqueryOutput;

	pquery->targetList = plTE;
}
Beispiel #30
0
//---------------------------------------------------------------------------
//	@function:
//		CTranslatorDXLToQuery::TranslateLimit
//
//	@doc:
//		Translate a logical limit operator
//
//---------------------------------------------------------------------------
void
CTranslatorDXLToQuery::TranslateLimit
	(
	const CDXLNode *pdxln,
	Query *pquery,
	CStateDXLToQuery *pstatedxltoquery,
	CMappingColIdVarQuery *pmapcidvarquery
	)
{
	List *plSortCl = NIL;

	GPOS_ASSERT(4 == pdxln->UlArity());

	// get children
	CDXLNode *pdxlnSortColList = (*pdxln)[0];
	CDXLNode *pdxlnLimitCount = (*pdxln)[1];
	CDXLNode *pdxlnLimitOffset = (*pdxln)[2];
	CDXLNode *pdxlnChild = (*pdxln)[3];

	// translate child node
	TranslateLogicalOp(pdxlnChild, pquery, pstatedxltoquery, pmapcidvarquery);

	// translate sorting column lists
	const ULONG ulNumSortCols = pdxlnSortColList->UlArity();
	if (0 < ulNumSortCols)
	{
		for (ULONG ul = 0; ul < ulNumSortCols; ul++)
		{
			CDXLNode *pdxlnSortCol = (*pdxlnSortColList)[ul];
			CDXLScalarSortCol *pdxlopSortCol = CDXLScalarSortCol::PdxlopConvert(pdxlnSortCol->Pdxlop());

			// get the target entry and the set the sortgroupref
			ULONG ulSortColId = pdxlopSortCol->UlColId();
			TargetEntry *pte = const_cast<TargetEntry *>(pmapcidvarquery->Pte(ulSortColId));
			GPOS_ASSERT(NULL != pte);

			// create the sort clause
			SortClause *psortcl = MakeNode(SortClause);
			psortcl->sortop = CMDIdGPDB::PmdidConvert(pdxlopSortCol->PmdidSortOp())->OidObjectId();
			plSortCl = gpdb::PlAppendElement(plSortCl, psortcl);

			// If ressortgroupref is not set then this column
			// was not used as a grouping column.
			if(0 == pte->ressortgroupref)
			{
				m_ulSortgrouprefCounter++;
				pte->ressortgroupref = m_ulSortgrouprefCounter;
			}

			psortcl->tleSortGroupRef = pte->ressortgroupref;

			if(!pstatedxltoquery->FTEFound(pte))
			{
				pstatedxltoquery->AddOutputColumnEntry(pte, pte->resname, ulSortColId);
			}
		}
	}

	GPOS_ASSERT(NULL != pdxlnLimitCount && NULL != pdxlnLimitOffset);

	// translate the limit count and offset;
	if(pdxlnLimitCount->UlArity() >0)
	{
		Expr *pexprCount = m_pdxlsctranslator->PexprFromDXLNodeScalar
												(
												(*pdxlnLimitCount)[0],
												pmapcidvarquery
												);

		pquery->limitCount = (Node *) pexprCount;
	}

	if(pdxlnLimitOffset->UlArity() >0)
	{
		Expr *pexprOffset = m_pdxlsctranslator->PexprFromDXLNodeScalar
												(
												(*pdxlnLimitOffset)[0],
												pmapcidvarquery
												);

		pquery->limitOffset = (Node *) pexprOffset;
	}

	pquery->sortClause = plSortCl;
}