Skip to content
Permalink
Browse files

[mssql] Fix inefficiencies in expression compiler, resulting in

apparent hangs when compiling complex expressions

Fixes #15404
  • Loading branch information
nyalldawson committed Oct 8, 2018
1 parent f928c2e commit f630c93816d95fb7c85c718a332f3fd9043703f6
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/providers/mssql/qgsmssqlexpressioncompiler.cpp
@@ -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 );
@@ -51,7 +64,6 @@ QgsSqlExpressionCompiler::Result QgsMssqlExpressionCompiler::compileNode( const
default:
break;
}

}

//fallback to default handling
@@ -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 );

0 comments on commit f630c93

Please sign in to comment.
You can’t perform that action at this time.