Exemple #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()
			);
}
//---------------------------------------------------------------------------
//	@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()
			);
}