[fdo-trac] #802: mUseNesting is not right
FDO
trac_fdo at osgeo.org
Mon Dec 12 03:22:30 EST 2011
#802: mUseNesting is not right
-----------------------------+----------------------------------------------
Reporter: ChristineBao | Owner: thomasknoell
Type: defect | Status: new
Priority: critical | Milestone: 3.7.0
Component: ODBC Provider | Version: 3.7.0
Severity: 2 | Keywords:
External_id: |
-----------------------------+----------------------------------------------
Comment(by ChristineBao):
This defect is caused by the mUseNesting flag. It's set to true if the
filter contains both AND and OR operation
{{{
FdoRdbmsFilterProcessor.cpp:
// Initialize the member variables that are set by this routine. The
default
// value should reflect the current behavior.
mUseNesting = true;
mUseGrouping = false;
mAddNegationBracket = false;
// Analyze the filter.
FilterAnalyzer filterAnalyzer;
filter->Process(&filterAnalyzer);
// Check the result of the analyzing process and set the corresponding
// member variables that control the generation of the SQL statement
// from the given filter.
if ((filterAnalyzer.containsBinaryLogicalOperatorAnd) ||
(filterAnalyzer.containsBinaryLogicalOperatorOr) )
{
if (filterAnalyzer.isSpatialObjectFilter)
{
mUseNesting = false;
mUseGrouping = true;
}
else
{
mUseNesting = filterAnalyzer.containsBinaryLogicalOperatorAnd
&&
filterAnalyzer.containsBinaryLogicalOperatorOr;
}
mAddNegationBracket =
!mUseNesting &&
filterAnalyzer.containsUnaryLogicalOperatorNot;
}
}}}
And when the mUseNesting is true, ( is added again and again for the OR
operator.
{{{
FdoRdbmsFilterProcessor.cpp:
if (mUseNesting)
AppendString (OPEN_PARENTH, 3);
if( filter.GetOperation() == FdoBinaryLogicalOperations_And )
{
useGrouping = mUseGrouping;
mUseGrouping = false;
if (useGrouping)
AppendString (OPEN_PARENTH, 3);
HandleFilter( leftOperand );
if (useGrouping)
AppendString (CLOSE_PARENTH, 3);
AppendString( LOGICAL_AND );
if (useGrouping)
AppendString (OPEN_PARENTH, 3);
HandleFilter( rightOperand );
if (useGrouping)
AppendString (CLOSE_PARENTH, 3);
}
else
{
mProcessingOrOperator = true;
HandleFilter( leftOperand );
AppendString (LOGICAL_OR, 4);
HandleFilter( rightOperand );
FdoSpatialCondition* leftSpCond =
dynamic_cast<FdoSpatialCondition*>(leftOperand.p);
FdoSpatialCondition* rightSpCond =
dynamic_cast<FdoSpatialCondition*>(rightOperand.p);
if ( !SupportsSpatialOrNonSpatialOperator() )
{
if ((leftSpCond || rightSpCond) && !(leftSpCond &&
rightSpCond))
throw FdoCommandException::Create( NlsMsgGet(FDORDBMS_532,
"OR not supported in a query when mixing property with spatial filters" )
);
}
}
if (mUseNesting)
AppendString (CLOSE_PARENTH, 3);
}}}
In this test case, there are a lot of OR operation, so too many ( is added
into filter string and caused the error.
--
Ticket URL: <http://trac.osgeo.org/fdo/ticket/802#comment:1>
FDO <http://fdo.osgeo.org/>
Feature Data Objects
More information about the fdo-trac
mailing list