Package org.h2.expression
Class IntervalOperation
- java.lang.Object
-
- org.h2.expression.Expression
-
- org.h2.expression.Operation2
-
- org.h2.expression.IntervalOperation
-
public class IntervalOperation extends Operation2
A mathematical operation with intervals.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntervalOperation.IntervalOpType
-
Field Summary
Fields Modifier and Type Field Description private TypeInfoforcedTypeprivate static intINTERVAL_DAY_DIGITSNumber of digits enough to holdINTERVAL '999999999999999999' DAY / INTERVAL '0.000000001' SECOND.private static TypeInfoINTERVAL_DIVIDE_INTERVAL_DAY_TYPEprivate static TypeInfoINTERVAL_DIVIDE_INTERVAL_YEAR_TYPEprivate static intINTERVAL_YEAR_DIGITSNumber of digits enough to holdINTERVAL '999999999999999999' YEAR / INTERVAL '1' MONTH.private IntervalOperation.IntervalOpTypeopType-
Fields inherited from class org.h2.expression.Operation2
left, right, type
-
Fields inherited from class org.h2.expression.Expression
AUTO_PARENTHESES, MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL, WITH_PARENTHESES, WITHOUT_PARENTHESES
-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Constructor Summary
Constructors Constructor Description IntervalOperation(IntervalOperation.IntervalOpType opType, Expression left, Expression right)IntervalOperation(IntervalOperation.IntervalOpType opType, Expression left, Expression right, TypeInfo forcedType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private ValuegetDateTimeWithInterval(SessionLocal session, Value l, Value r, int lType, int rType)(package private) static java.lang.StringBuildergetForcedTypeSQL(java.lang.StringBuilder builder, TypeInfo forcedType)private voidgetInnerSQL2(java.lang.StringBuilder builder, int sqlFlags)private chargetOperationToken()private longgetTimeWithInterval(Value r, long nanos)java.lang.StringBuildergetUnenclosedSQL(java.lang.StringBuilder builder, int sqlFlags)Get the SQL statement of this expression.ValuegetValue(SessionLocal session)Return the resulting value for the current row.private static java.math.BigIntegernanosFromValue(SessionLocal session, Value v)booleanneedParentheses()Returns whether this expressions needs to be wrapped in parentheses when it is used as an argument of other expressions.Expressionoptimize(SessionLocal session)Try to optimize the expression.-
Methods inherited from class org.h2.expression.Operation2
getCost, getSubexpression, getSubexpressionCount, getType, isEverything, mapColumns, setEvaluatable, updateAggregate
-
Methods inherited from class org.h2.expression.Expression
addFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getColumnNameForView, getEnclosedSQL, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSQL, getSQL, getSQL, getTableAlias, getTableName, getWhenSQL, getWhenValue, isConstant, isIdentity, isNullConstant, isValueSet, isWhenConditionOperand, optimizeCondition, toString, writeExpressions, writeExpressions
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
-
-
-
Field Detail
-
INTERVAL_YEAR_DIGITS
private static final int INTERVAL_YEAR_DIGITS
Number of digits enough to holdINTERVAL '999999999999999999' YEAR / INTERVAL '1' MONTH.- See Also:
- Constant Field Values
-
INTERVAL_DAY_DIGITS
private static final int INTERVAL_DAY_DIGITS
Number of digits enough to holdINTERVAL '999999999999999999' DAY / INTERVAL '0.000000001' SECOND.- See Also:
- Constant Field Values
-
INTERVAL_DIVIDE_INTERVAL_YEAR_TYPE
private static final TypeInfo INTERVAL_DIVIDE_INTERVAL_YEAR_TYPE
-
INTERVAL_DIVIDE_INTERVAL_DAY_TYPE
private static final TypeInfo INTERVAL_DIVIDE_INTERVAL_DAY_TYPE
-
opType
private final IntervalOperation.IntervalOpType opType
-
forcedType
private TypeInfo forcedType
-
-
Constructor Detail
-
IntervalOperation
public IntervalOperation(IntervalOperation.IntervalOpType opType, Expression left, Expression right, TypeInfo forcedType)
-
IntervalOperation
public IntervalOperation(IntervalOperation.IntervalOpType opType, Expression left, Expression right)
-
-
Method Detail
-
nanosFromValue
private static java.math.BigInteger nanosFromValue(SessionLocal session, Value v)
-
needParentheses
public boolean needParentheses()
Description copied from class:ExpressionReturns whether this expressions needs to be wrapped in parentheses when it is used as an argument of other expressions.- Overrides:
needParenthesesin classExpression- Returns:
trueif it is
-
getUnenclosedSQL
public java.lang.StringBuilder getUnenclosedSQL(java.lang.StringBuilder builder, int sqlFlags)Description copied from class:ExpressionGet the SQL statement of this expression. This may not always be the original SQL statement, especially after optimization. Enclosing '(' and ')' are never appended.- Specified by:
getUnenclosedSQLin classExpression- Parameters:
builder- string buildersqlFlags- formatting flags- Returns:
- the specified string builder
-
getInnerSQL2
private void getInnerSQL2(java.lang.StringBuilder builder, int sqlFlags)
-
getForcedTypeSQL
static java.lang.StringBuilder getForcedTypeSQL(java.lang.StringBuilder builder, TypeInfo forcedType)
-
getOperationToken
private char getOperationToken()
-
getValue
public Value getValue(SessionLocal session)
Description copied from class:ExpressionReturn the resulting value for the current row.- Specified by:
getValuein classExpression- Parameters:
session- the session- Returns:
- the result
-
getDateTimeWithInterval
private Value getDateTimeWithInterval(SessionLocal session, Value l, Value r, int lType, int rType)
-
getTimeWithInterval
private long getTimeWithInterval(Value r, long nanos)
-
optimize
public Expression optimize(SessionLocal session)
Description copied from class:ExpressionTry to optimize the expression.- Specified by:
optimizein classExpression- Parameters:
session- the session- Returns:
- the optimized expression
-
-