//--------------------------------------------------------------------------- // @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() ); }
//--------------------------------------------------------------------------- // @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; }
//--------------------------------------------------------------------------- // @function: // CLogicalConstTableGet::PdrgpcoldescMapping // // @doc: // Construct column descriptors from column references // //--------------------------------------------------------------------------- DrgPcoldesc * CLogicalConstTableGet::PdrgpcoldescMapping ( IMemoryPool *pmp, DrgPcr *pdrgpcr ) const { GPOS_ASSERT(NULL != pdrgpcr); DrgPcoldesc *pdrgpcoldesc = GPOS_NEW(pmp) DrgPcoldesc(pmp); const ULONG ulLen = pdrgpcr->UlLength(); for (ULONG ul = 0; ul < ulLen; ul++) { CColRef *pcr = (*pdrgpcr)[ul]; ULONG ulLength = ULONG_MAX; if (CColRef::EcrtTable == pcr->Ecrt()) { CColRefTable *pcrTable = CColRefTable::PcrConvert(pcr); ulLength = pcrTable->UlWidth(); } CColumnDescriptor *pcoldesc = GPOS_NEW(pmp) CColumnDescriptor ( pmp, pcr->Pmdtype(), pcr->Name(), ul + 1, //iAttno true, // FNullable ulLength ); pdrgpcoldesc->Append(pcoldesc); } return pdrgpcoldesc; }