|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.h2.command.Prepared
org.h2.command.dml.Query
org.h2.command.dml.Select
public class Select
This class represents a simple SELECT statement. For each select statement, visibleColumnCount <= distinctColumnCount <= expressionCount. The expression list count could include ORDER BY and GROUP BY expressions that are not in the select list. The call sequence is init(), mapColumns() if it's a subquery, prepare().
| Field Summary |
|---|
| Fields inherited from class org.h2.command.dml.Query |
|---|
limitExpr, offsetExpr, sampleSize |
| Fields inherited from class org.h2.command.Prepared |
|---|
headPos, parameters, prepareAlways, session, sqlStatement |
| Constructor Summary | |
|---|---|
Select(Session session)
|
|
| Method Summary | |
|---|---|
void |
addCondition(Expression cond)
Add a condition to the list of conditions. |
void |
addGlobalCondition(Parameter param,
int columnId,
int comparisonType)
Add a condition to the query. |
void |
addTableFilter(TableFilter filter,
boolean isTop)
Add a table to the query. |
int |
getColumnCount()
Get the column count of this query. |
double |
getCost()
Calculate the cost to execute this query. |
java.util.HashMap<Expression,java.lang.Object> |
getCurrentGroup()
|
int |
getCurrentGroupRowId()
|
ObjectArray<Expression> |
getExpressions()
The the list of select expressions. |
java.lang.String |
getFirstColumnAlias(Session s)
Get the alias (or column name) of the first column. |
java.lang.String |
getPlanSQL()
Get the SQL statement with the execution plan. |
java.util.HashSet<Table> |
getTables()
Get all tables that are involved in this query. |
ObjectArray<TableFilter> |
getTopFilters()
|
TableFilter |
getTopTableFilter()
|
void |
init()
Initialize the query. |
boolean |
isEverything(ExpressionVisitor visitor)
Check if this expression and all sub-expressions can fulfill a criteria. |
boolean |
isQuickAggregateQuery()
Check if this is an aggregate query with direct lookup, for example a query of the type SELECT COUNT(*) FROM TEST or SELECT MAX(ID) FROM TEST. |
boolean |
isReadOnly()
Check if this command is read only. |
void |
mapColumns(ColumnResolver resolver,
int level)
Map the columns to the given column resolver. |
void |
prepare()
Prepare this statement. |
LocalResult |
queryMeta()
Get an empty result set containing the meta data. |
protected LocalResult |
queryWithoutCache(int maxRows)
Execute the query without checking the cache. |
void |
setDistinct(boolean b)
Set the distinct flag. |
void |
setEvaluatable(TableFilter tableFilter,
boolean b)
Change the evaluatable flag. |
void |
setExpressions(ObjectArray<Expression> expressions)
|
void |
setForUpdate(boolean b)
Set the 'for update' flag. |
void |
setGroupBy(ObjectArray<Expression> group)
|
void |
setGroupQuery()
Called if this query contains aggregate functions. |
void |
setHaving(Expression having)
|
void |
setOrder(ObjectArray<SelectOrderBy> order)
Set the order by list. |
void |
updateAggregate(Session s)
Update all aggregate function values. |
| Methods inherited from class org.h2.command.dml.Query |
|---|
getMaxDataModificationId, getParameterValues, isEverything, isQuery, isTransactional, prepareOrder, query, setLimit, setOffset, setSampleSize |
| Methods inherited from class org.h2.command.Prepared |
|---|
checkCanceled, checkParameters, getCurrentObjectId, getCurrentRowNumber, getObjectId, getParameters, getSQL, getSQL, getSQL, needRecompile, setCommand, setCurrentRowNumber, setHeadPos, setObjectId, setParameterList, setPrepareAlways, setRow, setSession, setSQL, toString, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Select(Session session)
| Method Detail |
|---|
public void addTableFilter(TableFilter filter,
boolean isTop)
filter - the table to addisTop - if the table can be the first table in the query planpublic ObjectArray<TableFilter> getTopFilters()
public void setExpressions(ObjectArray<Expression> expressions)
public void setGroupQuery()
public void setGroupBy(ObjectArray<Expression> group)
public java.util.HashMap<Expression,java.lang.Object> getCurrentGroup()
public int getCurrentGroupRowId()
public void setOrder(ObjectArray<SelectOrderBy> order)
Query
setOrder in class Queryorder - the order by listpublic void addCondition(Expression cond)
cond - the condition to add
public LocalResult queryMeta()
throws java.sql.SQLException
Prepared
queryMeta in class Preparedjava.sql.SQLException
protected LocalResult queryWithoutCache(int maxRows)
throws java.sql.SQLException
Query
queryWithoutCache in class QuerymaxRows - the limit as specified in the JDBC method call
java.sql.SQLException
public void init()
throws java.sql.SQLException
Query
init in class Queryjava.sql.SQLException
public void prepare()
throws java.sql.SQLException
Prepared
prepare in class Preparedjava.sql.SQLExceptionpublic double getCost()
Query
getCost in class Querypublic java.util.HashSet<Table> getTables()
Query
getTables in class Querypublic java.lang.String getPlanSQL()
Prepared
getPlanSQL in class Preparedpublic void setDistinct(boolean b)
Query
setDistinct in class Queryb - the new valuepublic void setHaving(Expression having)
public int getColumnCount()
Query
getColumnCount in class Querypublic TableFilter getTopTableFilter()
public ObjectArray<Expression> getExpressions()
Query
getExpressions in class Querypublic void setForUpdate(boolean b)
Query
setForUpdate in class Queryb - the new setting
public void mapColumns(ColumnResolver resolver,
int level)
throws java.sql.SQLException
Query
mapColumns in class Queryresolver - the resolverlevel - the subquery level (0 is the top level query, 1 is the first
subquery level)
java.sql.SQLException
public void setEvaluatable(TableFilter tableFilter,
boolean b)
Query
setEvaluatable in class QuerytableFilter - the table filterb - the new valuepublic boolean isQuickAggregateQuery()
public void addGlobalCondition(Parameter param,
int columnId,
int comparisonType)
throws java.sql.SQLException
Query
addGlobalCondition in class Queryparam - the parametercolumnId - the column index (0 meaning the first column)comparisonType - the comparison type
java.sql.SQLException
public void updateAggregate(Session s)
throws java.sql.SQLException
Query
updateAggregate in class Querys - the session
java.sql.SQLExceptionpublic boolean isEverything(ExpressionVisitor visitor)
Query
isEverything in class Queryvisitor - the visitor
public boolean isReadOnly()
Prepared
isReadOnly in class Preparedpublic java.lang.String getFirstColumnAlias(Session s)
Query
getFirstColumnAlias in class Querys - the session
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||