public abstract class Query extends Prepared
create, parameters, prepareAlways, session, sqlStatement, sqlTokens| Modifier and Type | Method and Description |
|---|---|
abstract void |
addGlobalCondition(Parameter param,
int columnId,
int comparisonType)
Add a condition to the query.
|
abstract boolean |
allowGlobalConditions()
Check whether adding condition to the query is allowed.
|
void |
collectDependencies(java.util.HashSet<DbObject> dependencies)
Find and collect all DbObjects, this Prepared depends on.
|
void |
disableCache()
Disable caching of result sets.
|
boolean |
exists()
Execute the EXISTS predicate over the query.
|
abstract void |
fireBeforeSelectTriggers()
Call the before triggers on all tables.
|
int |
getColumnCount()
Get the column count of this query.
|
abstract double |
getCost()
Calculate the cost to execute this query.
|
int |
getCostAsExpression()
Calculate the cost when used as a subquery.
|
java.util.ArrayList<Expression> |
getExpressions()
The the list of select expressions.
|
Expression |
getFetch() |
Expression |
getIfSingleRow()
If this query is determined as a single-row query, returns a replacement
expression.
|
long |
getMaxDataModificationId() |
Expression |
getOffset() |
TypeInfo |
getRowDataType()
Returns data type of rows.
|
abstract java.util.HashSet<Table> |
getTables()
Get all tables that are involved in this query.
|
int |
getType()
Get the command type as defined in CommandInterface
|
boolean |
hasOrder()
Whether the query has an order.
|
abstract void |
init()
Initialize the query.
|
boolean |
isAnyDistinct() |
boolean |
isConstantQuery()
Check if this query will always return the same value and has no side
effects.
|
abstract boolean |
isEverything(ExpressionVisitor visitor)
Check if this expression and all sub-expressions can fulfill a criteria.
|
boolean |
isFetchPercent() |
boolean |
isNeverLazy() |
boolean |
isQuery()
Check if this object is a query.
|
boolean |
isRandomAccessResult()
Returns whether results support random access.
|
boolean |
isReadOnly()
Check if this command is read only.
|
boolean |
isStandardDistinct() |
boolean |
isTransactional()
Check if this command is transactional.
|
abstract boolean |
isUnion()
Check if this is a UNION query.
|
boolean |
isWithTies() |
abstract void |
mapColumns(ColumnResolver resolver,
int level)
Map the columns to the given column resolver.
|
void |
prepare()
Prepare this statement.
|
abstract void |
prepareExpressions() |
abstract void |
preparePlan() |
ResultInterface |
query(long maxrows)
Execute the query.
|
ResultInterface |
query(long limit,
ResultTarget target)
Execute the query, writing the result to the target result.
|
ResultInterface |
queryMeta()
Get an empty result set containing the meta data.
|
protected abstract ResultInterface |
queryWithoutCache(long limit,
ResultTarget target)
Execute the query without checking the cache.
|
void |
setDistinctIfPossible()
Set the distinct flag only if it is possible, may be used as a possible
optimization only.
|
abstract void |
setEvaluatable(TableFilter tableFilter,
boolean b)
Change the evaluatable flag.
|
void |
setFetch(Expression fetch) |
void |
setFetchPercent(boolean fetchPercent) |
abstract void |
setForUpdate(boolean forUpdate)
Set the 'for update' flag.
|
void |
setNeverLazy(boolean b) |
void |
setOffset(Expression offset) |
void |
setOrder(java.util.ArrayList<QueryOrderBy> order)
Set the order by list.
|
void |
setRandomAccessResult(boolean b)
Whether results need to support random access.
|
void |
setWithTies(boolean withTies) |
Table |
toTable(java.lang.String alias,
Column[] columnTemplates,
java.util.ArrayList<Parameter> parameters,
boolean forCreateView,
Query topQuery)
Converts this query to a table or a view.
|
abstract void |
updateAggregate(SessionLocal s,
int stage)
Update all aggregate function values.
|
checkCanceled, checkParameters, getCteCleanups, getCurrentRowNumber, getObjectId, getParameters, getPersistedObjectId, getPlanSQL, getSession, getSimpleSQL, getSQL, getSQLTokens, isCacheable, needRecompile, setCommand, setCteCleanups, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, toString, updatepublic void setNeverLazy(boolean b)
public boolean isNeverLazy()
public abstract boolean isUnion()
true if this is a UNION querypublic ResultInterface queryMeta()
Preparedprotected abstract ResultInterface queryWithoutCache(long limit, ResultTarget target)
limit - the limit as specified in the JDBC method calltarget - the target to write results topublic abstract void init()
public final void prepare()
Preparedpublic abstract void prepareExpressions()
public abstract void preparePlan()
public java.util.ArrayList<Expression> getExpressions()
public abstract double getCost()
public int getCostAsExpression()
public abstract java.util.HashSet<Table> getTables()
public void setOrder(java.util.ArrayList<QueryOrderBy> order)
order - the order by listpublic boolean hasOrder()
public abstract void setForUpdate(boolean forUpdate)
forUpdate - the new settingpublic int getColumnCount()
public TypeInfo getRowDataType()
public abstract void mapColumns(ColumnResolver resolver, int level)
resolver - the resolverlevel - the subquery level (0 is the top level query, 1 is the first
subquery level)public abstract void setEvaluatable(TableFilter tableFilter, boolean b)
tableFilter - the table filterb - the new valuepublic abstract void addGlobalCondition(Parameter param, int columnId, int comparisonType)
param - the parametercolumnId - the column index (0 meaning the first column)comparisonType - the comparison typepublic abstract boolean allowGlobalConditions()
public abstract boolean isEverything(ExpressionVisitor visitor)
visitor - the visitorpublic boolean isReadOnly()
PreparedisReadOnly in class Preparedpublic abstract void updateAggregate(SessionLocal s, int stage)
s - the sessionstage - select stagepublic abstract void fireBeforeSelectTriggers()
public void setDistinctIfPossible()
public boolean isStandardDistinct()
DISTINCT querypublic boolean isAnyDistinct()
DISTINCT or
DISTINCT ON (...) querypublic boolean isRandomAccessResult()
public void setRandomAccessResult(boolean b)
b - the new valuepublic boolean isQuery()
Preparedpublic boolean isTransactional()
PreparedisTransactional in class Preparedpublic void disableCache()
public final ResultInterface query(long maxrows)
Preparedpublic final ResultInterface query(long limit, ResultTarget target)
limit - the maximum number of rows to returntarget - the target result (null will return the result)public final boolean exists()
public int getType()
Preparedpublic void setOffset(Expression offset)
public Expression getOffset()
public void setFetch(Expression fetch)
public Expression getFetch()
public void setFetchPercent(boolean fetchPercent)
public boolean isFetchPercent()
public void setWithTies(boolean withTies)
public boolean isWithTies()
public final long getMaxDataModificationId()
public Table toTable(java.lang.String alias, Column[] columnTemplates, java.util.ArrayList<Parameter> parameters, boolean forCreateView, Query topQuery)
alias - alias name for the viewcolumnTemplates - column templates, or nullparameters - the parametersforCreateView - if true, a system session will be used for the viewtopQuery - the top level querypublic void collectDependencies(java.util.HashSet<DbObject> dependencies)
PreparedcollectDependencies in class Prepareddependencies - collection of dependencies to populatepublic boolean isConstantQuery()
public Expression getIfSingleRow()
null