Esempio n. 1
0
//---------------------------------------------------------------------------
//	@function:
//		CColumnFactory::PcrCopy
//
//	@doc:
//		Create a copy of the given colref
//
//---------------------------------------------------------------------------
CColRef *
CColumnFactory::PcrCopy
	(
	const CColRef* pcr
	)
{
	CName name(pcr->Name());
	if (CColRef::EcrtComputed == pcr->Ecrt())
	{
		return PcrCreate(pcr->Pmdtype(), name);
	}

	GPOS_ASSERT(CColRef::EcrtTable == pcr->Ecrt());
	ULONG ulId = m_aul.TIncr();
	CColRefTable *pcrTable = CColRefTable::PcrConvert(const_cast<CColRef*>(pcr));

	return PcrCreate
			(
			pcr->Pmdtype(),
			pcrTable->IAttno(),
			pcrTable->FNullable(),
			ulId,
			name,
			pcrTable->UlSourceOpId(),
			pcrTable->UlWidth()
			);
}
Esempio n. 2
0
//---------------------------------------------------------------------------
//	@function:
//		CLogicalGet::PcrsDeriveNotNull
//
//	@doc:
//		Derive not null output columns
//
//---------------------------------------------------------------------------
CColRefSet *
CLogicalGet::PcrsDeriveNotNull
	(
	IMemoryPool *pmp,
	CExpressionHandle &exprhdl
	)
	const
{
	// get all output columns
	CColRefSet *pcrs = GPOS_NEW(pmp) CColRefSet(pmp);
	pcrs->Include(CDrvdPropRelational::Pdprel(exprhdl.Pdp())->PcrsOutput());

	// filters out nullable columns
	CColRefSetIter crsi(*CDrvdPropRelational::Pdprel(exprhdl.Pdp())->PcrsOutput());
	while (crsi.FAdvance())
	{
		CColRefTable *pcrtable = CColRefTable::PcrConvert(const_cast<CColRef*>(crsi.Pcr()));
		if (pcrtable->FNullable())
		{
			pcrs->Exclude(pcrtable);
		}
	}

	return pcrs;
}