示例#1
0
//---------------------------------------------------------------------------
//	@function:
//		CPhysical::PrsDerivePassThruOuter
//
//	@doc:
//		Helper for common case of rewindability derivation
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysical::PrsDerivePassThruOuter
	(
	CExpressionHandle &exprhdl
	)
{
	CRewindabilitySpec *prs = exprhdl.Pdpplan(0 /*child_index*/)->Prs();
	prs->AddRef();

	return prs;
}
示例#2
0
//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSpool::PrsDerive
//
//	@doc:
//		Derive rewindability
//
//--------------------------------------------------------------------------
CRewindabilitySpec *
CPhysicalSpool::PrsDerive
	(
	IMemoryPool *mp,
	CExpressionHandle &exprhdl
	)
	const
{
	CRewindabilitySpec *prsChild = PrsDerivePassThruOuter(exprhdl);
	CRewindabilitySpec::EMotionHazardType motion_hazard = (!FEager() && prsChild->HasMotionHazard()) ?
														  CRewindabilitySpec::EmhtMotion :
														  CRewindabilitySpec::EmhtNoMotion;
	prsChild->Release();

	return GPOS_NEW(mp) CRewindabilitySpec(CRewindabilitySpec::ErtRewindable, motion_hazard);
}
示例#3
0
//---------------------------------------------------------------------------
//	@function:
//		CPhysicalJoin::PrsDerive
//
//	@doc:
//		Derive rewindability
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysicalJoin::PrsDerive
	(
	IMemoryPool *pmp,
	CExpressionHandle &exprhdl
	)
	const
{
	CRewindabilitySpec *prsOuter = exprhdl.Pdpplan(0 /*ulChildIndex*/)->Prs();
	GPOS_ASSERT(NULL != prsOuter);

	CRewindabilitySpec *prsInner = exprhdl.Pdpplan(1 /*ulChildIndex*/)->Prs();
	GPOS_ASSERT(NULL != prsInner);

	if (CUtils::FCorrelatedNLJoin(exprhdl.Pop()))
	{
		// rewindability is not established if correlated join
		return GPOS_NEW(pmp) CRewindabilitySpec(CRewindabilitySpec::ErtNone /*ert*/);
	}

	if (CRewindabilitySpec::ErtNone == prsOuter->Ert() ||
		CRewindabilitySpec::ErtNone == prsInner->Ert())
	{
		// rewindability is not established if any child is non-rewindable
		return GPOS_NEW(pmp) CRewindabilitySpec(CRewindabilitySpec::ErtNone /*ert*/);
	}

	// check if both children have the same rewindability spec
	if (prsOuter->Ert() ==  prsInner->Ert())
	{
		prsOuter->AddRef();
		return prsOuter;
	}

	// one of the two children has general rewindability while the other child has
	// mark-restore  rewindability
	return GPOS_NEW(pmp) CRewindabilitySpec(CRewindabilitySpec::ErtGeneral /*ert*/);
}