Skip to content

Commit

Permalink
[mssql] Fix inefficiencies in expression compiler, resulting in
Browse files Browse the repository at this point in the history
apparent hangs when compiling complex expressions

Fixes #15404
  • Loading branch information
nyalldawson committed Oct 8, 2018
1 parent f928c2e commit f630c93
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/providers/mssql/qgsmssqlexpressioncompiler.cpp
Expand Up @@ -28,6 +28,19 @@ QgsSqlExpressionCompiler::Result QgsMssqlExpressionCompiler::compileNode( const
if ( node->nodeType() == QgsExpressionNode::ntBinaryOperator )
{
const QgsExpressionNodeBinaryOperator *bin( static_cast<const QgsExpressionNodeBinaryOperator *>( node ) );
switch ( bin->op() )
{
// special handling
case QgsExpressionNodeBinaryOperator::boPow:
case QgsExpressionNodeBinaryOperator::boRegexp:
case QgsExpressionNodeBinaryOperator::boConcat:
break;

default:
// fallback to default handling
return QgsSqlExpressionCompiler::compileNode( node, result );;
}

QString op1, op2;

Result result1 = compileNode( bin->opLeft(), op1 );
Expand All @@ -51,7 +64,6 @@ QgsSqlExpressionCompiler::Result QgsMssqlExpressionCompiler::compileNode( const
default:
break;
}

}

//fallback to default handling
Expand All @@ -72,7 +84,7 @@ QString QgsMssqlExpressionCompiler::quotedValue( const QVariant &value, bool &ok
{
case QVariant::Bool:
//no boolean literal support in mssql, so fake it
return value.toBool() ? "(1=1)" : "(1=0)";
return value.toBool() ? QStringLiteral( "(1=1)" ) : QStringLiteral( "(1=0)" );

default:
return QgsSqlExpressionCompiler::quotedValue( value, ok );
Expand Down

0 comments on commit f630c93

Please sign in to comment.