Package org.h2.command.query
Class TableValueConstructor
- java.lang.Object
-
- org.h2.command.Prepared
-
- org.h2.command.query.Query
-
- org.h2.command.query.TableValueConstructor
-
public class TableValueConstructor extends Query
Table value constructor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classTableValueConstructor.TableValueColumnResolver-
Nested classes/interfaces inherited from class org.h2.command.query.Query
Query.OffsetFetch
-
-
Field Summary
Fields Modifier and Type Field Description private TableValueConstructor.TableValueColumnResolvercolumnResolverprivate doublecostprivate java.util.ArrayList<java.util.ArrayList<Expression>>rows(package private) TableValueConstructorTabletableThe table.-
Fields inherited from class org.h2.command.query.Query
checkInit, distinct, expressionArray, expressions, fetchExpr, fetchPercent, isPrepared, offsetExpr, orderList, randomAccessResult, resultColumnCount, sort, visibleColumnCount, withTies
-
Fields inherited from class org.h2.command.Prepared
create, parameters, prepareAlways, session, sqlStatement, sqlTokens
-
-
Constructor Summary
Constructors Constructor Description TableValueConstructor(SessionLocal session, java.util.ArrayList<java.util.ArrayList<Expression>> rows)Creates new instance of table value constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGlobalCondition(Parameter param, int columnId, int comparisonType)Add a condition to the query.booleanallowGlobalConditions()Check whether adding condition to the query is allowed.private voidcreateTable()voidfireBeforeSelectTriggers()Call the before triggers on all tables.doublegetCost()Calculate the cost to execute this query.ExpressiongetIfSingleRow()If this query is determined as a single-row query, returns a replacement expression.java.lang.StringgetPlanSQL(int sqlFlags)Get the SQL statement with the execution plan.java.util.HashSet<Table>getTables()Get all tables that are involved in this query.static voidgetValuesSQL(java.lang.StringBuilder builder, int sqlFlags, java.util.ArrayList<java.util.ArrayList<Expression>> rows)Appends the SQL of the values to the specified string builder..static voidgetVisibleResult(SessionLocal session, ResultTarget result, Column[] columns, java.util.ArrayList<java.util.ArrayList<Expression>> rows)Appends visible columns of all rows to the specified result.voidinit()Initialize the query.booleanisConstantQuery()Check if this query will always return the same value and has no side effects.booleanisEverything(ExpressionVisitor visitor)Check if this expression and all sub-expressions can fulfill a criteria.booleanisUnion()Check if this is a UNION query.voidmapColumns(ColumnResolver resolver, int level)Map the columns to the given column resolver.voidprepare()Prepare this statement.protected ResultInterfacequeryWithoutCache(long limit, ResultTarget target)Execute the query without checking the cache.voidsetEvaluatable(TableFilter tableFilter, boolean b)Change the evaluatable flag.voidsetForUpdate(boolean forUpdate)Set the 'for update' flag.TabletoTable(java.lang.String alias, Column[] columnTemplates, java.util.ArrayList<Parameter> parameters, boolean forCreateView, Query topQuery)Converts this query to a table or a view.voidupdateAggregate(SessionLocal s, int stage)Update all aggregate function values.-
Methods inherited from class org.h2.command.query.Query
addParameter, appendEndOfQueryToSQL, cleanupOrder, collectDependencies, convertToDistinct, disableCache, exists, finishResult, getColumnCount, getCostAsExpression, getExpressions, getFetch, getMaxDataModificationId, getOffset, getOffsetFetch, getRowDataType, getType, hasOrder, initExpression, initOrder, isAnyDistinct, isFetchPercent, isNeverLazy, isQuery, isRandomAccessResult, isReadOnly, isStandardDistinct, isTransactional, isWithTies, prepareOrder, query, query, queryMeta, setDistinctIfPossible, setFetch, setFetchPercent, setNeverLazy, setOffset, setOrder, setRandomAccessResult, setWithTies
-
Methods inherited from class org.h2.command.Prepared
checkCanceled, checkParameters, getCteCleanups, getCurrentRowNumber, getObjectId, getParameters, getPersistedObjectId, getSession, getSimpleSQL, getSQL, getSQLTokens, isCacheable, needRecompile, setCommand, setCteCleanups, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, toString, update
-
-
-
-
Field Detail
-
rows
private final java.util.ArrayList<java.util.ArrayList<Expression>> rows
-
table
TableValueConstructorTable table
The table.
-
columnResolver
private TableValueConstructor.TableValueColumnResolver columnResolver
-
cost
private double cost
-
-
Constructor Detail
-
TableValueConstructor
public TableValueConstructor(SessionLocal session, java.util.ArrayList<java.util.ArrayList<Expression>> rows)
Creates new instance of table value constructor.- Parameters:
session- the sessionrows- the rows
-
-
Method Detail
-
getVisibleResult
public static void getVisibleResult(SessionLocal session, ResultTarget result, Column[] columns, java.util.ArrayList<java.util.ArrayList<Expression>> rows)
Appends visible columns of all rows to the specified result.- Parameters:
session- the sessionresult- the resultcolumns- the columnsrows- the rows with data
-
getValuesSQL
public static void getValuesSQL(java.lang.StringBuilder builder, int sqlFlags, java.util.ArrayList<java.util.ArrayList<Expression>> rows)Appends the SQL of the values to the specified string builder..- Parameters:
builder- string buildersqlFlags- formatting flagsrows- the values
-
isUnion
public boolean isUnion()
Description copied from class:QueryCheck if this is a UNION query.
-
queryWithoutCache
protected ResultInterface queryWithoutCache(long limit, ResultTarget target)
Description copied from class:QueryExecute 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.- Specified by:
queryWithoutCachein classQuery- Parameters:
limit- the limit as specified in the JDBC method calltarget- the target to write results to- Returns:
- the result
-
init
public void init()
Description copied from class:QueryInitialize the query.
-
prepare
public void prepare()
Description copied from class:PreparedPrepare this statement.
-
createTable
private void createTable()
-
getCost
public double getCost()
Description copied from class:QueryCalculate the cost to execute this query.
-
getTables
public java.util.HashSet<Table> getTables()
Description copied from class:QueryGet all tables that are involved in this query.
-
setForUpdate
public void setForUpdate(boolean forUpdate)
Description copied from class:QuerySet the 'for update' flag.- Specified by:
setForUpdatein classQuery- Parameters:
forUpdate- the new setting
-
mapColumns
public void mapColumns(ColumnResolver resolver, int level)
Description copied from class:QueryMap the columns to the given column resolver.- Specified by:
mapColumnsin classQuery- Parameters:
resolver- the resolverlevel- the subquery level (0 is the top level query, 1 is the first subquery level)
-
setEvaluatable
public void setEvaluatable(TableFilter tableFilter, boolean b)
Description copied from class:QueryChange the evaluatable flag. This is used when building the execution plan.- Specified by:
setEvaluatablein classQuery- Parameters:
tableFilter- the table filterb- the new value
-
addGlobalCondition
public void addGlobalCondition(Parameter param, int columnId, int comparisonType)
Description copied from class:QueryAdd a condition to the query. This is used for views.- Specified by:
addGlobalConditionin classQuery- Parameters:
param- the parametercolumnId- the column index (0 meaning the first column)comparisonType- the comparison type
-
allowGlobalConditions
public boolean allowGlobalConditions()
Description copied from class:QueryCheck 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.- Specified by:
allowGlobalConditionsin classQuery- Returns:
- true if adding global conditions is allowed
-
isEverything
public boolean isEverything(ExpressionVisitor visitor)
Description copied from class:QueryCheck if this expression and all sub-expressions can fulfill a criteria. If any part returns false, the result is false.- Specified by:
isEverythingin classQuery- Parameters:
visitor- the visitor- Returns:
- if the criteria can be fulfilled
-
updateAggregate
public void updateAggregate(SessionLocal s, int stage)
Description copied from class:QueryUpdate all aggregate function values.- Specified by:
updateAggregatein classQuery- Parameters:
s- the sessionstage- select stage
-
fireBeforeSelectTriggers
public void fireBeforeSelectTriggers()
Description copied from class:QueryCall the before triggers on all tables.- Specified by:
fireBeforeSelectTriggersin classQuery
-
getPlanSQL
public java.lang.String getPlanSQL(int sqlFlags)
Description copied from class:PreparedGet the SQL statement with the execution plan.- Overrides:
getPlanSQLin classPrepared- Parameters:
sqlFlags- formatting flags- Returns:
- the execution plan
-
toTable
public Table toTable(java.lang.String alias, Column[] columnTemplates, java.util.ArrayList<Parameter> parameters, boolean forCreateView, Query topQuery)
Description copied from class:QueryConverts this query to a table or a view.
-
isConstantQuery
public boolean isConstantQuery()
Description copied from class:QueryCheck if this query will always return the same value and has no side effects.- Overrides:
isConstantQueryin classQuery- Returns:
- if this query will always return the same value and has no side effects.
-
getIfSingleRow
public Expression getIfSingleRow()
Description copied from class:QueryIf this query is determined as a single-row query, returns a replacement expression.- Overrides:
getIfSingleRowin classQuery- Returns:
- the expression, or
null
-
-