Top Description Inners Fields Constructors Methods
org.h2.command.query

public Class SelectUnion

extends Query
Class Inheritance
Imports
java.util.ArrayList, .HashSet, org.h2.api.ErrorCode, org.h2.engine.Database, .SessionLocal, org.h2.expression.Expression, .ExpressionColumn, .ExpressionVisitor, .Parameter, org.h2.message.DbException, org.h2.result.LazyResult, .LocalResult, .ResultInterface, .ResultTarget, org.h2.table.Column, .ColumnResolver, .Table, .TableFilter, org.h2.value.TypeInfo, .Value

Represents a union SELECT statement.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
SelectUnion.LazyResultUnion

Lazy execution for this union.

public static enum

Field Summary

Modifier and TypeField and Description
private ForUpdate
pack-priv final Query
left

The left hand side of the union (the first subquery).

pack-priv final Query
right

The right hand side of the union (the second subquery).

private final SelectUnion.UnionType
Inherited from org.h2.command.query.Query:
checkInitdistinctexpressionArrayexpressionsfetchExprfetchPercentisPreparedoffsetExprorderListrandomAccessResultresultColumnCountsortvisibleColumnCountwithTies

Constructor Summary

AccessConstructor and Description
public
SelectUnion(SessionLocal session, SelectUnion.UnionType unionType, Query query, Query right)

Method Summary

Modifier and TypeMethod and Description
public void
addGlobalCondition(Parameter
the parameter
param
,
int
the column index (0 meaning the first column)
columnId
,
int
the comparison type
comparisonType
)

Implements abstract org.h2.command.query.Query.addGlobalCondition.

Add a condition to the query.

public boolean
allowGlobalConditions()

Implements abstract org.h2.command.query.Query.allowGlobalConditions.

Check whether adding condition to the query is allowed.

private Value[]
convert(Value[] values, int columnCount)

private LocalResult
createLocalResult(int columnCount)

public void
fireBeforeSelectTriggers()

Implements abstract org.h2.command.query.Query.fireBeforeSelectTriggers.

Call the before triggers on all tables.

public double
getCost()

Implements abstract org.h2.command.query.Query.getCost.

Calculate the cost to execute this query.

public LocalResult
public ForUpdate
getForUpdate()

Overrides org.h2.command.query.Query.getForUpdate.

Returns FOR UPDATE clause, if any.

public Query
public StringBuilder
getPlanSQL(StringBuilder
string builder
builder
,
int
formatting flags
sqlFlags
)

Overrides org.h2.command.Prepared.getPlanSQL.

Appends the SQL statement with the execution plan.

public Query
public HashSet<Table>
getTables()

Implements abstract org.h2.command.query.Query.getTables.

Get all tables that are involved in this query.

public SelectUnion.UnionType
public void
init()

Implements abstract org.h2.command.query.Query.init.

Initialize the query.

public boolean
isConstantQuery()

Overrides org.h2.command.query.Query.isConstantQuery.

Check if this query will always return the same value and has no side effects.

public boolean
isEverything(ExpressionVisitor
the visitor
visitor
)

Implements abstract org.h2.command.query.Query.isEverything.

Check if this expression and all sub-expressions can fulfill a criteria.

public boolean
isUnion()

Implements abstract org.h2.command.query.Query.isUnion.

Check if this is a UNION query.

public void
mapColumns(ColumnResolver
the resolver
resolver
,
int
the subquery level (0 is the top level query, 1 is the first subquery level)
level
,
boolean
whether this method was called from the outer query
outer
)

Implements abstract org.h2.command.query.Query.mapColumns.

Map the columns to the given column resolver.

public void
public void
protected ResultInterface
queryWithoutCache(long
the limit as specified in the JDBC method call
maxRows
,
ResultTarget
the target to write results to
target
)

Implements abstract org.h2.command.query.Query.queryWithoutCache.

Execute the query without checking the cache.

public void
setEvaluatable(TableFilter
the table filter
tableFilter
,
boolean
the new value
b
)

Implements abstract org.h2.command.query.Query.setEvaluatable.

Change the evaluatable flag.

public void
setForUpdate(ForUpdate
the new FOR UPDATE clause
forUpdate
)

Implements abstract org.h2.command.query.Query.setForUpdate.

Set the FOR UPDATE clause.

public void
updateAggregate(SessionLocal
the session
s
,
int
select stage
stage
)

Implements abstract org.h2.command.query.Query.updateAggregate.

Update all aggregate function values.

Inherited from org.h2.command.query.Query:
addParameterappendEndOfQueryToSQLcleanupOrdercollectDependenciesconvertToDistinctdisableCacheexistsfinishResultgetColumnCountgetCostAsExpressiongetExpressionsgetFetchgetIfSingleRowgetMaxDataModificationIdgetOffsetgetOffsetFetchgetOuterQueryScopegetRowDataTypegetTypehasOrderinitExpressioninitOrderisAnyDistinctisFetchPercentisNeverLazyisQueryisRandomAccessResultisReadOnlyisRetryableisStandardDistinctisTransactionalisWithTiesprepareprepareOrderqueryqueryqueryMetasetDistinctIfPossiblesetFetchsetFetchPercentsetNeverLazysetOffsetsetOrdersetOuterQueryScopesetRandomAccessResultsetWithClausesetWithTiestoTablewriteWithList

Field Detail

forUpdateback to summary
private ForUpdate forUpdate
leftback to summary
pack-priv final Query left

The left hand side of the union (the first subquery).

unionTypeback to summary
private final SelectUnion.UnionType unionType

Constructor Detail

SelectUnionback to summary
public SelectUnion(SessionLocal session, SelectUnion.UnionType unionType, Query query, Query right)

Method Detail

addGlobalConditionback to summary
public void addGlobalCondition(Parameter param, int columnId, int comparisonType)

Implements abstract org.h2.command.query.Query.addGlobalCondition.

Doc from org.h2.command.query.Query.addGlobalCondition.

Add a condition to the query. This is used for views.

Parameters
param:Parameter

the parameter

columnId:int

the column index (0 meaning the first column)

comparisonType:int

the comparison type

Annotations
@Override
allowGlobalConditionsback to summary
public boolean allowGlobalConditions()

Implements abstract org.h2.command.query.Query.allowGlobalConditions.

Doc from org.h2.command.query.Query.allowGlobalConditions.

Check whether adding condition to the query is allowed. This is not allowed for views that have an order by and a limit, as it would affect the returned results.

Returns:boolean

true if adding global conditions is allowed

Annotations
@Override
convertback to summary
private Value[] convert(Value[] values, int columnCount)
createLocalResultback to summary
private LocalResult createLocalResult(int columnCount)
fireBeforeSelectTriggersback to summary
public void fireBeforeSelectTriggers()

Implements abstract org.h2.command.query.Query.fireBeforeSelectTriggers.

Doc from org.h2.command.query.Query.fireBeforeSelectTriggers.

Call the before triggers on all tables.

Annotations
@Override
getCostback to summary
public double getCost()

Implements abstract org.h2.command.query.Query.getCost.

Doc from org.h2.command.query.Query.getCost.

Calculate the cost to execute this query.

Returns:double

the cost

Annotations
@Override
getEmptyResultback to summary
public LocalResult getEmptyResult()
getForUpdateback to summary
public ForUpdate getForUpdate()

Overrides org.h2.command.query.Query.getForUpdate.

Doc from org.h2.command.query.Query.getForUpdate.

Returns FOR UPDATE clause, if any.

Returns:ForUpdate

FOR UPDATE clause or null

Annotations
@Override
getLeftback to summary
public Query getLeft()
getPlanSQLback to summary
public StringBuilder getPlanSQL(StringBuilder builder, int sqlFlags)

Overrides org.h2.command.Prepared.getPlanSQL.

Doc from org.h2.command.Prepared.getPlanSQL.

Appends the SQL statement with the execution plan.

Parameters
builder:StringBuilder

string builder

sqlFlags:int

formatting flags

Returns:StringBuilder

the execution plan

Annotations
@Override
getRightback to summary
public Query getRight()
getTablesback to summary
public HashSet<Table> getTables()

Implements abstract org.h2.command.query.Query.getTables.

Doc from org.h2.command.query.Query.getTables.

Get all tables that are involved in this query.

Returns:HashSet<Table>

the set of tables

Annotations
@Override
getUnionTypeback to summary
public SelectUnion.UnionType getUnionType()
initback to summary
public void init()

Implements abstract org.h2.command.query.Query.init.

Doc from org.h2.command.query.Query.init.

Initialize the query.

Annotations
@Override
isConstantQueryback to summary
public boolean isConstantQuery()

Overrides org.h2.command.query.Query.isConstantQuery.

Doc from org.h2.command.query.Query.isConstantQuery.

Check if this query will always return the same value and has no side effects.

Returns:boolean

if this query will always return the same value and has no side effects.

Annotations
@Override
isEverythingback to summary
public boolean isEverything(ExpressionVisitor visitor)

Implements abstract org.h2.command.query.Query.isEverything.

Doc from org.h2.command.query.Query.isEverything.

Check if this expression and all sub-expressions can fulfill a criteria. If any part returns false, the result is false.

Parameters
visitor:ExpressionVisitor

the visitor

Returns:boolean

if the criteria can be fulfilled

Annotations
@Override
isUnionback to summary
public boolean isUnion()

Implements abstract org.h2.command.query.Query.isUnion.

Doc from org.h2.command.query.Query.isUnion.

Check if this is a UNION query.

Returns:boolean

true if this is a UNION query

Annotations
@Override
mapColumnsback to summary
public void mapColumns(ColumnResolver resolver, int level, boolean outer)

Implements abstract org.h2.command.query.Query.mapColumns.

Doc from org.h2.command.query.Query.mapColumns.

Map the columns to the given column resolver.

Parameters
resolver:ColumnResolver

the resolver

level:int

the subquery level (0 is the top level query, 1 is the first subquery level)

outer:boolean

whether this method was called from the outer query

Annotations
@Override
prepareExpressionsback to summary
public void prepareExpressions()

Implements abstract org.h2.command.query.Query.prepareExpressions.

Annotations
@Override
preparePlanback to summary
public void preparePlan()

Implements abstract org.h2.command.query.Query.preparePlan.

Annotations
@Override
queryWithoutCacheback to summary
protected ResultInterface queryWithoutCache(long maxRows, ResultTarget target)

Implements abstract org.h2.command.query.Query.queryWithoutCache.

Doc from org.h2.command.query.Query.queryWithoutCache.

Execute the query without checking the cache. If a target is specified, the results are written to it, and the method returns null. If no target is specified, a new LocalResult is created and returned.

Parameters
maxRows:long

the limit as specified in the JDBC method call

target:ResultTarget

the target to write results to

Returns:ResultInterface

the result

Annotations
@Override
setEvaluatableback to summary
public void setEvaluatable(TableFilter tableFilter, boolean b)

Implements abstract org.h2.command.query.Query.setEvaluatable.

Doc from org.h2.command.query.Query.setEvaluatable.

Change the evaluatable flag. This is used when building the execution plan.

Parameters
tableFilter:TableFilter

the table filter

b:boolean

the new value

Annotations
@Override
setForUpdateback to summary
public void setForUpdate(ForUpdate forUpdate)

Implements abstract org.h2.command.query.Query.setForUpdate.

Doc from org.h2.command.query.Query.setForUpdate.

Set the FOR UPDATE clause.

Parameters
forUpdate:ForUpdate

the new FOR UPDATE clause

Annotations
@Override
updateAggregateback to summary
public void updateAggregate(SessionLocal s, int stage)

Implements abstract org.h2.command.query.Query.updateAggregate.

Doc from org.h2.command.query.Query.updateAggregate.

Update all aggregate function values.

Parameters
s:SessionLocal

the session

stage:int

select stage

Annotations
@Override
org.h2.command.query back to summary

private final Class SelectUnion.LazyResultUnion

extends LazyResult
Class Inheritance

Lazy execution for this union.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv ResultInterface
l

pack-priv boolean
pack-priv ResultInterface
r

pack-priv boolean

Constructor Summary

AccessConstructor and Description
pack-priv
LazyResultUnion(Expression[] expressions, int columnCount)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides org.h2.result.LazyResult.close.

Implements org.h2.result.ResultInterface.close.

Close the result and delete any temporary files

protected Value[]
fetchNextRow()

Implements abstract org.h2.result.LazyResult.fetchNextRow.

Fetch next row or null if none available.

public int
getVisibleColumnCount()

Implements org.h2.result.ResultInterface.getVisibleColumnCount.

Get the number of visible columns.

public void
reset()

Overrides org.h2.result.LazyResult.reset.

Implements org.h2.result.ResultInterface.reset.

Go to the beginning of the result, that means before the first row.

Inherited from org.h2.result.LazyResult:
getAliasgetColumnNamegetColumnTypegetFetchSizegetNullablegetRowCountgetSchemaNamegetTableNamehasNextisClosedisIdentityisLazysetFetchSizesetLimitskipskipNextRow

Field Detail

columnCountback to summary
pack-priv int columnCount
lback to summary
pack-priv ResultInterface l
leftDoneback to summary
pack-priv boolean leftDone
rback to summary
pack-priv ResultInterface r
rightDoneback to summary
pack-priv boolean rightDone

Constructor Detail

LazyResultUnionback to summary
pack-priv LazyResultUnion(Expression[] expressions, int columnCount)

Method Detail

closeback to summary
public void close()

Overrides org.h2.result.LazyResult.close.

Implements org.h2.result.ResultInterface.close.

Doc from org.h2.result.ResultInterface.close.

Close the result and delete any temporary files

Annotations
@Override
fetchNextRowback to summary
protected Value[] fetchNextRow()

Implements abstract org.h2.result.LazyResult.fetchNextRow.

Doc from org.h2.result.LazyResult.fetchNextRow.

Fetch next row or null if none available.

Returns:Value[]

next row or null

Annotations
@Override
getVisibleColumnCountback to summary
public int getVisibleColumnCount()

Implements org.h2.result.ResultInterface.getVisibleColumnCount.

Doc from org.h2.result.ResultInterface.getVisibleColumnCount.

Get the number of visible columns. More columns may exist internally for sorting or grouping.

Returns:int

the number of columns

Annotations
@Override
resetback to summary
public void reset()

Overrides org.h2.result.LazyResult.reset.

Implements org.h2.result.ResultInterface.reset.

Doc from org.h2.result.ResultInterface.reset.

Go to the beginning of the result, that means before the first row.

Annotations
@Override
org.h2.command.query back to summary

public final Enum SelectUnion.UnionType

extends Enum<SelectUnion.UnionType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final SelectUnion.UnionType
EXCEPT

The type of an EXCEPT statement.

public static final SelectUnion.UnionType
INTERSECT

The type of an INTERSECT statement.

public static final SelectUnion.UnionType
UNION

The type of a UNION statement.

public static final SelectUnion.UnionType
UNION_ALL

The type of a UNION ALL statement.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SelectUnion.UnionType
public static SelectUnion.UnionType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

EXCEPTback to summary
public static final SelectUnion.UnionType EXCEPT

The type of an EXCEPT statement.

INTERSECTback to summary
public static final SelectUnion.UnionType INTERSECT

The type of an INTERSECT statement.

UNIONback to summary
public static final SelectUnion.UnionType UNION

The type of a UNION statement.

UNION_ALLback to summary
public static final SelectUnion.UnionType UNION_ALL

The type of a UNION ALL statement.

Constructor Detail

UnionTypeback to summary
private UnionType()

Method Detail

valueOfback to summary
public static SelectUnion.UnionType valueOf(String name)
valuesback to summary
public static SelectUnion.UnionType[] values()