Example #1
0
   INT32 upAAttrByFieldAlias( qgmDbAttr & attr,
                              const qgmOPFieldPtrVec & fieldAlias )
   {
      PD_TRACE_ENTRY( SDB__QGMUPAATTRBYFIELDALIAS ) ;
      INT32 rc = SDB_OK ;
      qgmOPFieldPtrVec::const_iterator cit = fieldAlias.begin() ;
      while ( cit != fieldAlias.end() )
      {
         if ( attr == (*cit)->value )
         {
            if ( (*cit)->alias.empty() )
            {
               attr.relegation().clear() ;
            }
            else
            {
               attr.attr() = (*cit)->alias ;
            }
            break ;
         }
         ++cit ;
      }

      PD_TRACE_EXITRC( SDB__QGMUPAATTRBYFIELDALIAS, rc ) ;
      return rc ;
   }
Example #2
0
 BOOLEAN isFrom( const _qgmOpField &right, BOOLEAN useAlias = TRUE ) const
 {
    if ( value == right.value || right.type == SQL_GRAMMAR::WILDCARD
         || ( useAlias && value.attr() == right.alias ) )
    {
       return TRUE ;
    }
    return FALSE ;
 }
Example #3
0
 INT32 downAAttrByFieldAlias( qgmDbAttr & attr,
                               const qgmOPFieldPtrVec & fieldAlias)
 {
    PD_TRACE_ENTRY( SDB__QGMDOWNAATTRBYFIELDALIAS ) ;
    INT32 rc = SDB_OK ;
    qgmOPFieldPtrVec::const_iterator cit = fieldAlias.begin() ;
    while ( cit != fieldAlias.end() )
    {
       if ( ( (*cit)->alias.empty() && attr.attr() == (*cit)->value.attr() )
            || ( !(*cit)->alias.empty() && attr.attr() == (*cit)->alias ) )
       {
          attr = (*cit)->value ;
          break ;
       }
       ++cit ;
    }
    PD_TRACE_EXITRC( SDB__QGMDOWNAATTRBYFIELDALIAS, rc ) ;
    return rc ;
 }
Example #4
0
 BOOLEAN isFrom( const qgmDbAttr &left, const qgmOpField &right,
                 BOOLEAN useAlias )
 {
    if ( ( useAlias && left.attr() == right.alias )
         || left == right.value || right.type == SQL_GRAMMAR::WILDCARD )
    {
       return TRUE ;
    }
    return FALSE ;
 }
Example #5
0
 string toString() const
 {
    stringstream ss ;
    ss << "value:" << value.toString() ;
    ss << ",type:" << type ;
    if ( !alias.empty() )
    {
       ss << ",alias:" << alias.toString() ;
    }
    return ss.str() ;
 }
Example #6
0
   // PD_TRACE_DECLARE_FUNCTION( SDB__QGMPTRTABLE_GETOWNATTR, "_qgmPtrTable::getOwnAttr" )
   INT32 _qgmPtrTable::getOwnAttr( const CHAR *begin,
                                   UINT32 size,
                                   qgmDbAttr &attr )
   {
      INT32 rc = SDB_OK ;

      PD_TRACE_ENTRY( SDB__QGMPTRTABLE_GETOWNATTR ) ;

      UINT32 pos = 0 ;
      BOOLEAN hasDot = qgmUtilFirstDot( begin, size, pos ) ;
      if ( hasDot && ( 0 == pos || size - 1 == pos ) )
      {
         PD_LOG( PDERROR,
                 "the first char and the last char can not be '.'" ) ;
         rc = SDB_INVALIDARG ;
         goto error ;
      }

      if ( hasDot )
      {
         rc = getOwnField( begin, pos, attr.relegation() ) ;
         if ( SDB_OK != rc )
         {
            goto error ;
         }
         ++pos ;
      }

      rc = getOwnField( begin + pos, size - pos, attr.attr() ) ;
      if ( SDB_OK != rc )
      {
         goto error ;
      }

   done:
      PD_TRACE_EXITRC( SDB__QGMPTRTABLE_GETOWNATTR, rc ) ;
      return rc ;
   error:
      goto done ;
   }
 BOOLEAN _qgmOptiAggregation::isInAggrFieldAlias( const qgmDbAttr & field ) const
 {
    qgmAggrSelectorVec::const_iterator cit = _selector.begin() ;
    while ( cit != _selector.end() )
    {
       const qgmAggrSelector &aggrSel = *cit ;
       if ( SQL_GRAMMAR::FUNC == aggrSel.value.type &&
            aggrSel.value.alias == field.attr() )
       {
          return TRUE ;
       }
       ++cit ;
    }
    return FALSE ;
 }
Example #8
0
   INT32 _qgmPtrTable::getAttr( const CHAR *begin, UINT32 size,
                                qgmDbAttr &attr )
   {
      PD_TRACE_ENTRY( SDB__QGMPTRTABLE_GETATTR ) ;
      INT32 rc = SDB_OK ;
      UINT32 num = 0 ;
      BOOLEAN hasDot = qgmUtilFirstDot( begin, size, num ) ;
      if ( 1 == num || size == num )
      {
         PD_LOG( PDERROR,
                 "the first char and the last char can not be '.'" ) ;
         rc = SDB_INVALIDARG ;
         goto error ;
      }

      if ( hasDot )
      {
         rc = getField( begin, num - 1, attr.relegation() ) ;
         if ( SDB_OK != rc )
         {
            goto error ;
         }
      }

      rc = getField( begin + num, size - num, attr.attr() ) ;
      if ( SDB_OK != rc )
      {
         goto error ;
      }

   done:
      PD_TRACE_EXITRC( SDB__QGMPTRTABLE_GETATTR, rc ) ;
      return rc ;
   error:
      goto done ;
   }
Example #9
0
 BOOLEAN empty() const
 {
    return value.empty() && alias.empty() ;
 }