Top Description Fields Constructors Methods
org.hsqldb

public Class Expression

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
org.hsqldb.ExpressionAccessor, org.hsqldb.ExpressionAggregate, org.hsqldb.ExpressionArithmetic, org.hsqldb.ExpressionArrayAggregate, org.hsqldb.ExpressionColumn, org.hsqldb.ExpressionColumnAccessor, org.hsqldb.ExpressionJSON.ExpressionJSONWrapper, org.hsqldb.ExpressionJSON.ExpressionJSONArrayFromQuery, org.hsqldb.ExpressionJSON.ExpressionJSONArrayFromValues, org.hsqldb.ExpressionJSON.ExpressionJSONArrayAgg, org.hsqldb.ExpressionJSON.ExpressionJSONObject, org.hsqldb.ExpressionJSON.ExpressionJSONObjectAgg, org.hsqldb.ExpressionLogical, org.hsqldb.ExpressionOp, org.hsqldb.ExpressionOrderBy, org.hsqldb.ExpressionPeriod, org.hsqldb.ExpressionTable, org.hsqldb.ExpressionValue, org.hsqldb.FunctionSQL, org.hsqldb.FunctionSQLInvoked
Imports
org.hsqldb.HsqlNameManager.HsqlName, .HsqlNameManager.SimpleName, .ParserDQL.CompileContext, .RangeGroup.RangeGroupSimple, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.index.Index, org.hsqldb.lib.ArrayListIdentity, .ArrayUtil, .HsqlArrayList, .List, .OrderedHashSet, .OrderedIntHashSet, .Set, org.hsqldb.navigator.RowSetNavigatorData, org.hsqldb.persist.PersistentStore, org.hsqldb.result.Result, .ResultMetaData, org.hsqldb.types.ArrayType, .CharacterType, .Collation, .NullType, .RowType, .Type, .Types

Expression class.
Authors
Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net)
Since
1.9.0
Version
2.7.3

Field Summary

Modifier and TypeField and Description
pack-priv HsqlNameManager.SimpleName
public static final int
pack-priv Collation
pack-priv int
protected Type
pack-priv static final Expression[]
public static final Expression
public static final Expression
protected int
protected int
private boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
public static final int
pack-priv Type[]
protected Expression[]
pack-priv boolean
pack-priv byte
protected int
pack-priv int
pack-priv RangeGroup
pack-priv RangeGroup[]
pack-priv int
public static final int
pack-priv TableDerived
public static final int
public static final int
public static final int
protected Object

Constructor Summary

AccessConstructor and Description
pack-priv
Expression(int type)

pack-priv
Expression(int type, TableDerived table)

Creates a SUBQUERY expression.

pack-priv
Expression(int type, Expression[] list)

ROW, ARRAY etc.

Method Summary

Modifier and TypeMethod and Description
public void
checkValidCheckConstraint()

checkValidCheckConstraint

public final OrderedHashSet<Expression>
collectAllExpressions(OrderedHashSet<Expression> set, OrderedIntHashSet typeSet, OrderedIntHashSet stopAtTypeSet)

collect all expressions of a set of expression types appearing anywhere in a select statement and its subselects, etc.

pack-priv final OrderedHashSet<TableDerived>
pack-priv void
collectObjectNames(Set<HsqlNameManager.HsqlName> set)

collects all schema objects

pack-priv OrderedHashSet<RangeVariable>
collectRangeVariables(OrderedHashSet<RangeVariable> set)

collects all range variables in expression tree

pack-priv OrderedHashSet<RangeVariable>
pack-priv static void
convertToType(Session session, Object[] data, Type[] dataType, Type[] newType)

pack-priv double
costFactor(Session session, RangeVariable range, int operation)

pack-priv static int
protected String
describe(Session session, int blanks)

public Expression
pack-priv boolean
equals(Expression other)

SIMPLE_COLUMN expressions can be of different Expression subclass types

public final boolean
equals(Object other)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

pack-priv static boolean
pack-priv static boolean
equals(Expression[] row1, Expression[] row2)

public Object
pack-priv String
getAlias()

Get the column alias

pack-priv static QuerySpecification
getCheckSelect(Session session, Table t, Expression e)

Returns a Select object that can be used for checking the contents of an existing table against the given CHECK search condition.

public ColumnSchema
public int
getColumnIndex()

Returns the column index in the table

pack-priv String

Returns:

column name
getColumnName
()

Returns the name of a column as string

public Expression
public Object
pack-priv static String
public Type
getDataType()

Returns the data type

pack-priv int
pack-priv Expression
pack-priv void
public Expression
getLeftNode()

Returns the left node

pack-priv Type
pack-priv Type[]
pack-priv byte
pack-priv RangeVariable
getRangeVariable()

Returns the range variable for a COLUMN or PERIOD expression

public Result
getResult(Session session)

public Expression
getRightNode()

Returns the right node

public Object[]
pack-priv HsqlNameManager.SimpleName
public String
getSQL()

For use with CHECK constraints.

public final OrderedHashSet<TableDerived>
pack-priv int
public Table
public int
getType()

Returns the type of expression

public OrderedHashSet<Expression>
public Object
getValue(Session session, Type type)

public Object
getValue(Session session)

pack-priv String
pack-priv boolean
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv boolean
pack-priv boolean
hasReference(RangeVariable range)

return true if given RangeVariable is used in expression tree

pack-priv boolean
hasReference(RangeVariable[] ranges, int exclude)

return true if given RangeVariable is used in expression tree

pack-priv void
insertValuesIntoSubqueryTable(Session session, PersistentStore store)

Details of IN condition optimisation for 1.9.0 Predicates with SELECT are QUERY expressions Predicates with IN list Parser adds a SubQuery to the list for each predicate At type resolution IN lists that are entirely fixed constant or parameter values are selected for possible optimisation.

pack-priv boolean
isComposedOf(Expression[] exprList, int start, int end, OrderedIntHashSet excludeSet)

For GROUP only.

pack-priv boolean
isComposedOf(OrderedHashSet<Expression> expressions, RangeGroup[] rangeGroups, OrderedIntHashSet excludeSet)

For HAVING only.

pack-priv boolean
public boolean
isCorrelated()

isCorrelated

pack-priv boolean
pack-priv boolean
public boolean
public boolean
public boolean
public boolean
pack-priv boolean
public void
pack-priv void
prepareTable(Session session, Expression row, int degree)

pack-priv Expression
replaceAliasInOrderBy(Session session, List<Expression> columns, int length)

return the expression for an alias used in an ORDER BY clause

pack-priv Expression
pack-priv Expression
replaceExpressions(OrderedHashSet<Expression> expressions, int resultRangePosition)

pack-priv void
replaceNode(Expression existing, Expression replacement)

pack-priv void
pack-priv void
public void
resolveCheckOrGenExpression(Session session, RangeGroup rangeGroup, boolean isCheck)

public List<Expression>
resolveColumnReferences(Session session, RangeGroup rangeGroup, RangeGroup[] rangeGroups, List<Expression> unresolvedSet)

resolve tables and collect unresolved column expressions

public List<Expression>
resolveColumnReferences(Session session, RangeGroup rangeGroup, int rangeCount, RangeGroup[] rangeGroups, List<Expression> unresolvedSet, boolean acceptsSequences)

pack-priv static List<Expression>
resolveColumnSet(Session session, RangeVariable[] rangeVars, RangeGroup[] rangeGroups, List<Expression> sourceSet)

pack-priv static List<Expression>
resolveColumnSet(Session session, RangeVariable[] rangeVars, int rangeCount, RangeGroup[] rangeGroups, List<Expression> sourceSet, List<Expression> targetSet)

public void
public void
resolveTypes(Session session, Expression parent)

public void
pack-priv void
setAlias(HsqlNameManager.SimpleName name)

Set the column alias

pack-priv void
pack-priv void
pack-priv void
public void
public void
public void
setCorrelatedReferences(RangeGroup resolvedRangeGroup)

public void
setDataType(Session session, Type type)

Set the data type

pack-priv void
public void
public void
pack-priv void
setSubType(int subType)

pack-priv void
public boolean
public SetFunction
public SetFunction
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

aliasback to summary
pack-priv HsqlNameManager.SimpleName alias
BINARYback to summary
public static final int BINARY
collationback to summary
pack-priv Collation collation
columnIndexback to summary
pack-priv int columnIndex
dataTypeback to summary
protected Type dataType
emptyArrayback to summary
pack-priv static final Expression[] emptyArray
EXPR_FALSEback to summary
public static final Expression EXPR_FALSE
EXPR_TRUEback to summary
public static final Expression EXPR_TRUE
exprSubTypeback to summary
protected int exprSubType
groupingTypeback to summary
protected int groupingType
hasAggregateback to summary
private boolean hasAggregate
isColumnConditionback to summary
pack-priv boolean isColumnCondition
isColumnEqualback to summary
pack-priv boolean isColumnEqual
isCorrelatedback to summary
pack-priv boolean isCorrelated
isDistinctAggregateback to summary
pack-priv boolean isDistinctAggregate
isSingleColumnConditionback to summary
pack-priv boolean isSingleColumnCondition
isSingleColumnEqualback to summary
pack-priv boolean isSingleColumnEqual
isSingleColumnNotNullback to summary
pack-priv boolean isSingleColumnNotNull
isSingleColumnNullback to summary
pack-priv boolean isSingleColumnNull
LEFTback to summary
public static final int LEFT
nodeDataTypesback to summary
pack-priv Type[] nodeDataTypes
nodesback to summary
protected Expression[] nodes
noOptimisationback to summary
pack-priv boolean noOptimisation
nullabilityback to summary
pack-priv byte nullability
opTypeback to summary
protected int opType
parameterIndexback to summary
pack-priv int parameterIndex
rangeGroupback to summary
pack-priv RangeGroup rangeGroup
rangeGroupsback to summary
pack-priv RangeGroup[] rangeGroups
resultTableColumnIndexback to summary
pack-priv int resultTableColumnIndex
tableback to summary
pack-priv TableDerived table
TERNARYback to summary
public static final int TERNARY
THIRDback to summary
public static final int THIRD
UNARYback to summary
public static final int UNARY
valueDataback to summary
protected Object valueData

Constructor Detail

Expressionback to summary
pack-priv Expression(int type)
Expressionback to summary
pack-priv Expression(int type, TableDerived table)

Creates a SUBQUERY expression.

Expressionback to summary
pack-priv Expression(int type, Expression[] list)

ROW, ARRAY etc.

Method Detail

checkValidCheckConstraintback to summary
public void checkValidCheckConstraint()

checkValidCheckConstraint

collectAllExpressionsback to summary
public final OrderedHashSet<Expression> collectAllExpressions(OrderedHashSet<Expression> set, OrderedIntHashSet typeSet, OrderedIntHashSet stopAtTypeSet)

collect all expressions of a set of expression types appearing anywhere in a select statement and its subselects, etc.

collectAllSubqueriesback to summary
pack-priv final OrderedHashSet<TableDerived> collectAllSubqueries(OrderedHashSet<TableDerived> set)
collectObjectNamesback to summary
pack-priv void collectObjectNames(Set<HsqlNameManager.HsqlName> set)

collects all schema objects

collectRangeVariablesback to summary
pack-priv OrderedHashSet<RangeVariable> collectRangeVariables(OrderedHashSet<RangeVariable> set)

collects all range variables in expression tree

collectRangeVariablesback to summary
pack-priv OrderedHashSet<RangeVariable> collectRangeVariables(RangeVariable[] rangeVariables, OrderedHashSet<RangeVariable> set)
convertToTypeback to summary
pack-priv static void convertToType(Session session, Object[] data, Type[] dataType, Type[] newType)
costFactorback to summary
pack-priv double costFactor(Session session, RangeVariable range, int operation)
countNullsback to summary
pack-priv static int countNulls(Object[] a)
describeback to summary
protected String describe(Session session, int blanks)
duplicateback to summary
public Expression duplicate()
equalsback to summary
pack-priv boolean equals(Expression other)

SIMPLE_COLUMN expressions can be of different Expression subclass types

equalsback to summary
public final boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

equalsback to summary
pack-priv static boolean equals(Object o1, Object o2)
equalsback to summary
pack-priv static boolean equals(Expression[] row1, Expression[] row2)
getAggregatedValueback to summary
public Object getAggregatedValue(Session session, SetFunction currValue)
getAliasback to summary
pack-priv String getAlias()

Get the column alias

getCheckSelectback to summary
pack-priv static QuerySpecification getCheckSelect(Session session, Table t, Expression e)

Returns a Select object that can be used for checking the contents of an existing table against the given CHECK search condition.

getColumnback to summary
public ColumnSchema getColumn()
getColumnIndexback to summary
public int getColumnIndex()

Returns the column index in the table

getColumnNameback to summary
pack-priv String getColumnName()

Returns the name of a column as string

Returns:String

column name

getConditionback to summary
public Expression getCondition()
getConstantValueNoCheckback to summary
public Object getConstantValueNoCheck(Session session)
getContextSQLback to summary
pack-priv static String getContextSQL(Expression expression)
getDataTypeback to summary
public Type getDataType()

Returns the data type

getDegreeback to summary
pack-priv int getDegree()
getIndexableExpressionback to summary
pack-priv Expression getIndexableExpression(RangeVariable rangeVar)
getJoinRangeVariablesback to summary
pack-priv void getJoinRangeVariables(RangeVariable[] ranges, List<RangeVariable> list)
getLeftNodeback to summary
public Expression getLeftNode()

Returns the left node

getNodeDataTypeback to summary
pack-priv Type getNodeDataType(int i)
getNodeDataTypesback to summary
pack-priv Type[] getNodeDataTypes()
getNullabilityback to summary
pack-priv byte getNullability()
getRangeVariableback to summary
pack-priv RangeVariable getRangeVariable()

Returns the range variable for a COLUMN or PERIOD expression

getResultback to summary
public Result getResult(Session session)
getRightNodeback to summary
public Expression getRightNode()

Returns the right node

getRowValueback to summary
public Object[] getRowValue(Session session)
getSimpleNameback to summary
pack-priv HsqlNameManager.SimpleName getSimpleName()
getSQLback to summary
public String getSQL()

For use with CHECK constraints. Under development. Currently supports a subset of expressions and is suitable for CHECK search conditions that refer only to the inserted/updated row. For full DDL reporting of VIEW select queries and CHECK search conditions, future improvements here are dependent upon improvements to SELECT query parsing, so that it is performed in a number of passes. An early pass should result in the query turned into an Expression tree that contains the information in the original SQL without any alterations, and with tables and columns all resolved. This Expression can then be preserved for future use. Table and column names that are not user-defined aliases should be kept as the HsqlName structures so that table or column renaming is reflected in the precompiled query.

getSubqueriesback to summary
public final OrderedHashSet<TableDerived> getSubqueries()
getSubTypeback to summary
pack-priv int getSubType()
getTableback to summary
public Table getTable()
getTypeback to summary
public int getType()

Returns the type of expression

getUnkeyedColumnsback to summary
public OrderedHashSet<Expression> getUnkeyedColumns(OrderedHashSet<Expression> unresolvedSet)
getValueback to summary
public Object getValue(Session session, Type type)
getValueback to summary
public Object getValue(Session session)
getValueClassNameback to summary
pack-priv String getValueClassName()
hasAggregateback to summary
pack-priv boolean hasAggregate()
hasConditionback to summary
public boolean hasCondition()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
hasNonDeterministicFunctionback to summary
pack-priv boolean hasNonDeterministicFunction()
hasReferenceback to summary
pack-priv boolean hasReference(RangeVariable range)

return true if given RangeVariable is used in expression tree

hasReferenceback to summary
pack-priv boolean hasReference(RangeVariable[] ranges, int exclude)

return true if given RangeVariable is used in expression tree

insertValuesIntoSubqueryTableback to summary
pack-priv void insertValuesIntoSubqueryTable(Session session, PersistentStore store)

Details of IN condition optimisation for 1.9.0 Predicates with SELECT are QUERY expressions Predicates with IN list Parser adds a SubQuery to the list for each predicate At type resolution IN lists that are entirely fixed constant or parameter values are selected for possible optimisation. The flags: IN expression right side isCorrelated == true if there are non-constant, non-param expressions in the list (Expressions may have to be resolved against the full set of columns of the query, so must be re-evaluated for each row and evaluated after all the joins have been made) VALUELIST expression isFixedConstantValueList == true when all expressions are fixed constant and none is a param. With this flag, a single-column VALUELIST can be accessed as a HashMap. Predicates may be optimised as joins if isCorrelated == false

isComposedOfback to summary
pack-priv boolean isComposedOf(Expression[] exprList, int start, int end, OrderedIntHashSet excludeSet)

For GROUP only.

isComposedOfback to summary
pack-priv boolean isComposedOf(OrderedHashSet<Expression> expressions, RangeGroup[] rangeGroups, OrderedIntHashSet excludeSet)

For HAVING only.

isConditionRangeVariableback to summary
pack-priv boolean isConditionRangeVariable(RangeVariable range)
isCorrelatedback to summary
public boolean isCorrelated()

isCorrelated

isDistinctAggregateback to summary
pack-priv boolean isDistinctAggregate()
isDynamicParamback to summary
pack-priv boolean isDynamicParam()
isFalseback to summary
public boolean isFalse()
isIndexableback to summary
public boolean isIndexable(RangeVariable range)
isSelfAggregateback to summary
public boolean isSelfAggregate()
isTrueback to summary
public boolean isTrue()
isUnresolvedParamback to summary
pack-priv boolean isUnresolvedParam()
materialiseback to summary
public void materialise(Session session)
prepareTableback to summary
pack-priv void prepareTable(Session session, Expression row, int degree)
replaceAliasInOrderByback to summary
pack-priv Expression replaceAliasInOrderBy(Session session, List<Expression> columns, int length)

return the expression for an alias used in an ORDER BY clause

replaceColumnReferencesback to summary
pack-priv Expression replaceColumnReferences(Session session, RangeVariable range, Expression[] list)
replaceExpressionsback to summary
pack-priv Expression replaceExpressions(OrderedHashSet<Expression> expressions, int resultRangePosition)
replaceNodeback to summary
pack-priv void replaceNode(Expression existing, Expression replacement)
replaceRangeVariablesback to summary
pack-priv void replaceRangeVariables(RangeVariable[] ranges, RangeVariable[] newRanges)
resetColumnReferencesback to summary
pack-priv void resetColumnReferences()
resolveCheckOrGenExpressionback to summary
public void resolveCheckOrGenExpression(Session session, RangeGroup rangeGroup, boolean isCheck)
resolveColumnReferencesback to summary
public List<Expression> resolveColumnReferences(Session session, RangeGroup rangeGroup, RangeGroup[] rangeGroups, List<Expression> unresolvedSet)

resolve tables and collect unresolved column expressions

resolveColumnReferencesback to summary
public List<Expression> resolveColumnReferences(Session session, RangeGroup rangeGroup, int rangeCount, RangeGroup[] rangeGroups, List<Expression> unresolvedSet, boolean acceptsSequences)
resolveColumnSetback to summary
pack-priv static List<Expression> resolveColumnSet(Session session, RangeVariable[] rangeVars, RangeGroup[] rangeGroups, List<Expression> sourceSet)
resolveColumnSetback to summary
pack-priv static List<Expression> resolveColumnSet(Session session, RangeVariable[] rangeVars, int rangeCount, RangeGroup[] rangeGroups, List<Expression> sourceSet, List<Expression> targetSet)
resolveGrantFilterback to summary
public void resolveGrantFilter(Session session, Table table)
resolveTypesback to summary
public void resolveTypes(Session session, Expression parent)
setAggregateback to summary
public void setAggregate()
setAliasback to summary
pack-priv void setAlias(HsqlNameManager.SimpleName name)

Set the column alias

setAsConstantValueback to summary
pack-priv void setAsConstantValue(Session session, Expression parent)
setAsConstantValueback to summary
pack-priv void setAsConstantValue(Object value, Expression parent)
setAttributesAsColumnback to summary
pack-priv void setAttributesAsColumn(ColumnSchema column)
setCollationback to summary
public void setCollation(Collation collation)
setConditionback to summary
public void setCondition(Expression e)
setCorrelatedReferencesback to summary
public void setCorrelatedReferences(RangeGroup resolvedRangeGroup)
setDataTypeback to summary
public void setDataType(Session session, Type type)

Set the data type

setLeftNodeback to summary
pack-priv void setLeftNode(Expression e)
setNoOptimisationback to summary
public void setNoOptimisation()
setRightNodeback to summary
public void setRightNode(Expression e)
setSubTypeback to summary
pack-priv void setSubType(int subType)
swapLeftAndRightNodesback to summary
pack-priv void swapLeftAndRightNodes()
testConditionback to summary
public boolean testCondition(Session session)
updateAggregatingValueback to summary
public SetFunction updateAggregatingValue(Session session, SetFunction currValue)
updateAggregatingValueback to summary
public SetFunction updateAggregatingValue(Session session, SetFunction currValue, SetFunction value)