//--------------------------------------------------------------------------- // @function: // CConstraintConjunction::Pcnstr // // @doc: // Return constraint on a given column // //--------------------------------------------------------------------------- CConstraint * CConstraintConjunction::Pcnstr ( IMemoryPool *mp, const CColRef *colref ) { // all children referencing given column CConstraintArray *pdrgpcnstrCol = m_phmcolconstr->Find(colref); if (NULL == pdrgpcnstrCol) { return NULL; } CConstraintArray *pdrgpcnstr = GPOS_NEW(mp) CConstraintArray(mp); const ULONG length = pdrgpcnstrCol->Size(); for (ULONG ul = 0; ul < length; ul++) { // the part of the child that references this column CConstraint *pcnstrCol = (*pdrgpcnstrCol)[ul]->Pcnstr(mp, colref); if (NULL == pcnstrCol || pcnstrCol->IsConstraintUnbounded()) { CRefCount::SafeRelease(pcnstrCol); continue; } pdrgpcnstr->Append(pcnstrCol); } return CConstraint::PcnstrConjunction(mp, pdrgpcnstr); }
//--------------------------------------------------------------------------- // @function: // CPartConstraint::FCanNegate // // @doc: // Check whether or not the current part constraint can be negated. A part // constraint can be negated only if it has constraints on the first level // //--------------------------------------------------------------------------- BOOL CPartConstraint::FCanNegate() const { // first level cannot be NULL if (NULL == Pcnstr(0)) { return false; } // all levels after the first must be unconstrained for (ULONG ul = 1; ul < m_num_of_part_levels; ul++) { CConstraint *pcnstr = Pcnstr(ul); if (NULL == pcnstr || !pcnstr->IsConstraintUnbounded()) { return false; } } return true; }