Skip to content
Permalink
Browse files

[oracle] Compile some expression functions

Greatly speeds up case-insensitive value matches for oracle
expression based feature requests

(cherry-picked from 63e450a)
  • Loading branch information
nyalldawson committed Apr 17, 2018
1 parent b7507fa commit 62aefd7a83238bf155f20cdbc4953d05005a4f5f
@@ -108,3 +108,28 @@ QString QgsOracleExpressionCompiler::quotedValue( const QVariant &value, bool &o
return QgsOracleConn::quotedValue( value );
}
}

static const QMap<QString, QString> FUNCTION_NAMES_SQL_FUNCTIONS_MAP
{
{ "sqrt", "sqrt" },
{ "abs", "abs" },
{ "cos", "cos" },
{ "sin", "sin" },
{ "tan", "tan" },
{ "acos", "acos" },
{ "asin", "asin" },
{ "atan", "atan" },
{ "exp", "exp" },
{ "ln", "ln" },
{ "log", "log" },
{ "round", "round" },
{ "floor", "floor" },
{ "ceil", "ceil" },
{ "lower", "lower" },
{ "upper", "upper" },
};

QString QgsOracleExpressionCompiler::sqlFunctionFromFunctionName( const QString &fnName ) const
{
return FUNCTION_NAMES_SQL_FUNCTIONS_MAP.value( fnName, QString() );
}
@@ -30,6 +30,7 @@ class QgsOracleExpressionCompiler : public QgsSqlExpressionCompiler
virtual Result compileNode( const QgsExpressionNode *node, QString &result ) override;
virtual QString quotedIdentifier( const QString &identifier ) override;
virtual QString quotedValue( const QVariant &value, bool &ok ) override;
QString sqlFunctionFromFunctionName( const QString &fnName ) const override;
};

#endif // QGSORACLEEXPRESSIONCOMPILER_H
@@ -74,34 +74,14 @@ def uncompiledFilters(self):
'NULL or true',
'NULL or NULL',
'not null',
'sqrt(pk) >= 2',
'radians(cnt) < 2',
'degrees(pk) <= 200',
'abs(cnt) <= 200',
'cos(pk) < 0',
'sin(pk) < 0',
'tan(pk) < 0',
'acos(-1) < pk',
'asin(1) < pk',
'atan(3.14) < pk',
'atan2(3.14, pk) < 1',
'exp(pk) < 10',
'ln(pk) <= 1',
'log(3, pk) <= 1',
'log10(pk) < 0.5',
'round(3.14) <= pk',
'round(0.314,1) * 10 = pk',
'floor(3.14) <= pk',
'ceil(3.14) <= pk',
'pk < pi()',
'round(cnt / 66.67) <= 2',
'floor(cnt / 66.67) <= 2',
'ceil(cnt / 66.67) <= 2',
'log10(pk) < 0.5',
'pk < pi() / 2',
'pk = char(51)',
'pk = coalesce(NULL,3,4)',
'lower(name) = \'apple\'',
'upper(name) = \'APPLE\'',
'name = trim(\' Apple \')',
'x($geometry) < -70',
'y($geometry) > 70',

0 comments on commit 62aefd7

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