//
// The function checks whether or not the function has a correct set of arguments.
bool FdoRdbmsMySqlFilterProcessor::HasNativeSupportedFunctionArguments(FdoFunction& expr) const
{
    // If the function needs argument checking, execute the verification and return
    // the result back to the calling routine. Otherwise, the arguments are always 
    // deemed valid and the corresponding indication is returned.

    if (FdoCommonOSUtil::wcsicmp(L"STDDEV", expr.GetName()) == 0)
    {
        // The signatures for the function STDDEV allow an optional first
        // parameter that identifies the operation type (ALL, DISTINCT). In
        // MySQL this is not natively supported. Therefore, instead of sending
        // the request to MySQL it needs to be redirected to the Expression
        // Engine.
        // The following checks for the number of arguments. If there are two
        // arguments, the request needs to be redirected to the Expression
        // Engine. 
        return (expr.GetArguments()->GetCount() > 1) ? false : true;
    }

    if (FdoCommonOSUtil::wcsicmp(L"TRUNC", expr.GetName()) == 0)
    {
        // The signatures for the function TRUNC allow the truncation of date
        // and numeric data. If the input is data then the request cannot be
        // handled by MySQL as this is not supported. In this case the request
        // needs to be handed to the Expression Engine.
        // NOTE: The current implementation hands the request to the Expression
        //       Engine in all cases. This needs to be updated later.
        return false;
    }

    return true;;
}
Beispiel #2
0
ThemeParameters* ThemeParameters::Parse(const wchar_t* expressionString)
{
    // parse the expression and see if it consists of one of our theming functions
    FdoPtr<FdoExpression> expression;
    try
    {
        expression = FdoExpression::Parse(expressionString);
    }
    catch (FdoException* e)
    {
        ProcessStylizerException(e, __LINE__, __WFILE__);
    }

    FdoFunction* function = dynamic_cast<FdoFunction*>(expression.p);
    if (function != NULL)
    {
        FdoString* name = function->GetName();
        FdoPtr<FdoExpressionCollection> exprColl = function->GetArguments();

        if (_wcsicmp(name, L"lookup") == 0)
            return new LookupThemeParameters(exprColl);

        if (_wcsicmp(name, L"range") == 0)
            return new RangeThemeParameters(exprColl);
    }

    // not one of our functions
    return NULL;
}
void FdoRdbmsMySqlFilterProcessor::ProcessFunction (FdoFunction &expr)
{
    FdoStringP funcName = expr.GetName();

    // Some of the FDO expression function require special processing. Those
    // functions are handled next.

    if ((FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_AVG   ) == 0) ||
        (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_COUNT ) == 0) ||
        (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_MAX   ) == 0) ||
        (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_MIN   ) == 0) ||
        (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_STDDEV) == 0) ||
        (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_SUM   ) == 0)    )
        return ProcessAggregateFunction(expr);

    if ((FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_TODOUBLE ) == 0) ||
        (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_TOFLOAT  ) == 0)    )
        return ProcessToDoubleFloatFunction(expr);

    if ((FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_TOINT32 ) == 0) ||
        (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_TOINT64 ) == 0)    )
        return ProcessToInt32Int64Function(expr);

    if (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_CURRENTDATE) == 0)
        return ProcessCurrentDateFunction(expr);

    if (FdoCommonOSUtil::wcsicmp(funcName, FDO_FUNCTION_TRIM) == 0)
        return ProcessTrimFunction(expr);

    // The functions that do not require special handling use the
    // standard processing
    FdoRdbmsFilterProcessor::ProcessFunction(expr);
}
void UnitTestProcessor::ProcessFunction(FdoFunction& expr)
{
    prependTabs();
    wprintf(L"Function : %s\n", expr.GetName());
    FdoExpressionCollection* pColl = expr.GetArguments();
    m_tabLevel++;
    for (FdoInt32 i = 0; i < pColl->GetCount(); i++)
    {
        FdoExpression*   pExpr;

        pExpr = pColl->GetItem(i);
        pExpr->Process(this);
        pExpr->Release();
    }
    m_tabLevel--;
    pColl->Release();
}
FdoRdbmsFeatureReader *FdoRdbmsSelectCommand::GetOptimizedFeatureReader( const FdoSmLpClassDefinition *classDefinition )
{

	// Verify if this is a special case we can optimize (no grouping filter,
	// and only aggregate functions Count() and/or SpatialExtents())
    FdoRdbmsFeatureReader *reader = NULL;
	bool        bOtherAggrSelected = false;
	aggr_list   *selAggrList = new aggr_list;

	if ( (classDefinition->GetClassType() == FdoClassType_FeatureClass ) && mIdentifiers && 
		!mGroupingCol)
	{
        for (int i = 0; i < mIdentifiers->GetCount() && !bOtherAggrSelected; i++ )
        {
			FdoPtr<FdoIdentifier> identifier = mIdentifiers->GetItem(i);
			FdoComputedIdentifier* computedIdentifier = dynamic_cast<FdoComputedIdentifier*>(identifier.p);
              
            if (computedIdentifier) 
            {
				FdoPtr<FdoExpression> expr = computedIdentifier->GetExpression();
                FdoFunction* func = dynamic_cast<FdoFunction*>(expr.p);

                if (func && 0==FdoCommonOSUtil::wcsicmp(func->GetName(), FDO_FUNCTION_SPATIALEXTENTS))
                {
					FdoPtr<FdoExpressionCollection> args = func->GetArguments();
                    FdoPtr<FdoExpression> arg = args->GetItem(0);
                    FdoIdentifier* argId = dynamic_cast<FdoIdentifier*>(arg.p);

					AggregateElement *id = new AggregateElement;
					id->propName = argId->GetName();
                    id->name = computedIdentifier->GetName();
                    id->type = FdoPropertyType_GeometricProperty;

                    selAggrList->push_back( id );
				}
                else if (func && 0 == FdoCommonOSUtil::wcsicmp(func->GetName(), FDO_FUNCTION_COUNT))
                {
                    // Only if the argument count for the function is 1 do some
                    // special handling.

                    FdoPtr<FdoExpressionCollection> exprArgColl = func->GetArguments();
                    if (exprArgColl->GetCount() == 1)
					{
                        AggregateElement *id = new AggregateElement;
					    id->name = computedIdentifier->GetName();
					    id->type = FdoPropertyType_DataProperty;

					    selAggrList->push_back( id );
                    }
                    else
                    {
                        bOtherAggrSelected = true;
                    }
                }
                else
                {
                    bOtherAggrSelected = true;
                }			
			}
		}
	}

	// Now perform the actual select aggregates and return the data reader:
	if ( !bOtherAggrSelected && ( selAggrList->size() > 0 ))
    {
		reader = mFdoConnection->GetOptimizedAggregateReader( classDefinition, selAggrList, GetFilterRef() ); // The reader takes ownership of the selAggrList
    }
    else
    {
		// Sorry, no optimization. Clean up.
        for ( size_t j = 0; j < selAggrList->size(); j++ )
			delete selAggrList->at(j);

        delete selAggrList;
    }

    return reader;
}