예제 #1
0
//---------------------------------------------------------------------------
//	@function:
//		CColumnFactory::PcrCopy
//
//	@doc:
//		Create a copy of the given colref
//
//---------------------------------------------------------------------------
CColRef *
CColumnFactory::PcrCopy
	(
	const CColRef* colref
	)
{
	CName name(colref->Name());
	if (CColRef::EcrtComputed == colref->Ecrt())
	{
		return PcrCreate(colref->RetrieveType(), colref->TypeModifier(), name);
	}

	GPOS_ASSERT(CColRef::EcrtTable == colref->Ecrt());
	ULONG id = m_aul.Incr();
	CColRefTable *pcrTable = CColRefTable::PcrConvert(const_cast<CColRef*>(colref));

	return PcrCreate
			(
			colref->RetrieveType(),
			colref->TypeModifier(),
			pcrTable->AttrNum(),
			pcrTable->IsNullable(),
			id,
			name,
			pcrTable->UlSourceOpId(),
			pcrTable->Width()
			);
}
예제 #2
0
//---------------------------------------------------------------------------
//	@function:
//		CLogicalGet::PcrsDeriveNotNull
//
//	@doc:
//		Derive not null output columns
//
//---------------------------------------------------------------------------
CColRefSet *
CLogicalGet::PcrsDeriveNotNull
	(
	IMemoryPool *mp,
	CExpressionHandle &exprhdl
	)
	const
{
	// get all output columns
	CColRefSet *pcrs = GPOS_NEW(mp) CColRefSet(mp);
	pcrs->Include(CDrvdPropRelational::GetRelationalProperties(exprhdl.Pdp())->PcrsOutput());

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

	return pcrs;
}