public class Select extends Query
create, parameters, prepareAlways, session, sqlStatement| Constructor and Description |
|---|
Select(Session session,
Select parentSelect) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
addWindow(java.lang.String name,
Window window)
Adds a named window definition.
|
boolean |
allowGlobalConditions()
Check whether adding condition to the query is allowed.
|
void |
fireBeforeSelectTriggers()
Call the before triggers on all tables.
|
int |
getColumnCount()
Get the column count of this query.
|
Expression |
getCondition() |
double |
getCost()
Calculate the cost to execute this query.
|
java.util.ArrayList<Expression> |
getGroupBy() |
SelectGroups |
getGroupDataIfCurrent(boolean window)
Get the group data if there is currently a group-by active.
|
Expression |
getHaving() |
JoinBatch |
getJoinBatch() |
Select |
getParentSelect()
Returns parent select, or null.
|
java.lang.String |
getPlanSQL()
Get the SQL statement with the execution plan.
|
Expression |
getQualify() |
SortOrder |
getSortOrder() |
java.util.HashSet<Table> |
getTables()
Get all tables that are involved in this query.
|
java.util.ArrayList<TableFilter> |
getTopFilters() |
TableFilter |
getTopTableFilter() |
Window |
getWindow(java.lang.String name)
Returns a window with specified name, or null.
|
void |
init()
Initialize the query.
|
boolean |
isAnyDistinct() |
boolean |
isCacheable() |
boolean |
isEverything(ExpressionVisitor visitor)
Check if this expression and all sub-expressions can fulfill a criteria.
|
boolean |
isGroupQuery()
Checks if this query is a group query.
|
boolean |
isGroupWindowStage2()
Checks if window stage of group window query is performed.
|
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.
|
boolean |
isUnion()
Check if this is a UNION query.
|
boolean |
isWindowQuery()
Checks if this query contains window functions.
|
void |
mapColumns(ColumnResolver resolver,
int level)
Map the columns to the given column resolver.
|
void |
prepare()
Prepare this statement.
|
void |
prepareJoinBatch()
Prepare join batching.
|
ResultInterface |
queryMeta()
Get an empty result set containing the meta data.
|
protected ResultInterface |
queryWithoutCache(int maxRows,
ResultTarget target)
Execute the query without checking the cache.
|
void |
setDistinct()
Set the distinct flag.
|
void |
setDistinct(Expression[] distinctExpressions)
Set the DISTINCT ON expressions.
|
void |
setDistinctIfPossible()
Set the distinct flag only if it is possible, may be used as a possible
optimization only.
|
void |
setEvaluatable(TableFilter tableFilter,
boolean b)
Change the evaluatable flag.
|
void |
setExpressions(java.util.ArrayList<Expression> expressions) |
void |
setForUpdate(boolean b)
Set the 'for update' flag.
|
void |
setGroupBy(java.util.ArrayList<Expression> group) |
void |
setGroupQuery()
Set when SELECT statement contains (non-window) aggregate functions,
GROUP BY clause or HAVING clause.
|
void |
setHaving(Expression having) |
void |
setQualify(Expression qualify) |
void |
setWildcard()
Sets a wildcard expression as in "SELECT * FROM TEST".
|
void |
setWindowQuery()
Called if this query contains window functions.
|
void |
updateAggregate(Session s,
int stage)
Update all aggregate function values.
|
disableCache, getCostAsExpression, getExpressions, getLimit, getMaxDataModificationId, getOffset, getType, hasOrder, isFetchPercent, isNeverLazy, isQuery, isRandomAccessResult, isStandardDistinct, isTransactional, isWithTies, prepareOrder, query, query, setFetchPercent, setLimit, setNeverLazy, setOffset, setOrder, setRandomAccessResult, setSampleSize, setWithTiescheckCanceled, checkParameters, getCteCleanups, getCurrentRowNumber, getObjectId, getParameters, getPersistedObjectId, getSession, getSQL, getSQL, getSQL, needRecompile, setCommand, setCteCleanups, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, toString, updatepublic boolean isUnion()
Querypublic void addTableFilter(TableFilter filter, boolean isTop)
filter - the table to addisTop - if the table can be the first table in the query planpublic java.util.ArrayList<TableFilter> getTopFilters()
public void setExpressions(java.util.ArrayList<Expression> expressions)
public void setWildcard()
public void setGroupQuery()
public void setWindowQuery()
public void setGroupBy(java.util.ArrayList<Expression> group)
public java.util.ArrayList<Expression> getGroupBy()
public SelectGroups getGroupDataIfCurrent(boolean window)
window - is this a window functionpublic void setDistinct()
QuerysetDistinct in class Querypublic void setDistinct(Expression[] distinctExpressions)
distinctExpressions - array of expressionspublic void setDistinctIfPossible()
QuerysetDistinctIfPossible in class Querypublic boolean isAnyDistinct()
isAnyDistinct in class QueryDISTINCT or
DISTINCT ON (...) querypublic boolean addWindow(java.lang.String name,
Window window)
name - namewindow - window definitionpublic Window getWindow(java.lang.String name)
name - name of the windowpublic void addCondition(Expression cond)
cond - the condition to addpublic Expression getCondition()
public ResultInterface queryMeta()
Preparedprotected ResultInterface queryWithoutCache(int maxRows, ResultTarget target)
QueryqueryWithoutCache in class QuerymaxRows - the limit as specified in the JDBC method calltarget - the target to write results topublic void init()
Querypublic void prepare()
Preparedpublic void prepareJoinBatch()
QueryprepareJoinBatch in class Querypublic JoinBatch getJoinBatch()
public double getCost()
Querypublic java.util.HashSet<Table> getTables()
Querypublic void fireBeforeSelectTriggers()
QueryfireBeforeSelectTriggers in class Querypublic java.lang.String getPlanSQL()
PreparedgetPlanSQL in class Preparedpublic void setHaving(Expression having)
public Expression getHaving()
public void setQualify(Expression qualify)
public Expression getQualify()
public int getColumnCount()
QuerygetColumnCount in class Querypublic TableFilter getTopTableFilter()
public void setForUpdate(boolean b)
QuerysetForUpdate in class Queryb - the new settingpublic void mapColumns(ColumnResolver resolver, int level)
QuerymapColumns in class Queryresolver - the resolverlevel - the subquery level (0 is the top level query, 1 is the first
subquery level)public void setEvaluatable(TableFilter tableFilter, boolean b)
QuerysetEvaluatable in class QuerytableFilter - the table filterb - the new valuepublic boolean isQuickAggregateQuery()
public boolean isGroupQuery()
public boolean isWindowQuery()
public boolean isGroupWindowStage2()
public void addGlobalCondition(Parameter param, int columnId, int comparisonType)
QueryaddGlobalCondition in class Queryparam - the parametercolumnId - the column index (0 meaning the first column)comparisonType - the comparison typepublic void updateAggregate(Session s, int stage)
QueryupdateAggregate in class Querys - the sessionstage - select stagepublic boolean isEverything(ExpressionVisitor visitor)
QueryisEverything in class Queryvisitor - the visitorpublic boolean isReadOnly()
PreparedisReadOnly in class Preparedpublic boolean isCacheable()
isCacheable in class Preparedpublic boolean allowGlobalConditions()
QueryallowGlobalConditions in class Querypublic SortOrder getSortOrder()
public Select getParentSelect()