Package org.h2.table
Class QueryExpressionTable
- java.lang.Object
-
- org.h2.engine.DbObject
-
- org.h2.schema.SchemaObject
-
- org.h2.table.Table
-
- org.h2.table.QueryExpressionTable
-
- All Implemented Interfaces:
HasSQL
- Direct Known Subclasses:
CTE,DerivedTable,TableView
public abstract class QueryExpressionTable extends Table
A derived table or view.
-
-
Field Summary
-
Fields inherited from class org.h2.table.Table
columns, compareMode, EXCLUSIVE_LOCK, READ_LOCK, TYPE_CACHED, TYPE_MEMORY, WRITE_LOCK
-
Fields inherited from class org.h2.engine.DbObject
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USER
-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDependencies(java.util.HashSet<DbObject> dependencies)Add all objects that this table depends on to the hash set.IndexaddIndex(SessionLocal session, java.lang.String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, java.lang.String indexComment)Create an index for this tablevoidaddRow(SessionLocal session, Row row)Add a row to the table and all indexes.booleancanGetRowCount(SessionLocal session)Check if the row count can be retrieved quickly.booleancanReference()Check if this table can be referenced.voidcheckSupportAlter()Check if this table supports ALTER TABLE.voidclose(SessionLocal session)Close the table object and flush changes.static java.util.List<Column>createQueryColumnTemplateList(java.lang.String[] cols, Query theQuery, boolean cte)Creates a list of column templates from a query (usually from WITH query, but could be any query)PlanItemgetBestPlanItem(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet, boolean isSelectCommand)Get the best plan for the given search mask.java.util.List<Index>getIndexes()Get all indexes for this table.longgetMaxDataModificationId()Get the last data modification id.intgetParameterOffset(java.util.ArrayList<Parameter> additionalParameters)Get the index of the first parameter.QuerygetQuery()abstract QueryScopegetQueryScope()Returns the scope of this tablelonggetRowCount(SessionLocal session)Get the row count for this table.longgetRowCountApproximation(SessionLocal session)Get the approximated row count for this table.IndexgetScanIndex(SessionLocal session)Get the scan index to iterate through all rows.IndexgetScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)Get the scan index for this table.abstract QuerygetTopQuery()booleanisDeterministic()Check if the table is deterministic.booleanisInsertable()Returns whether this table is insertable.booleanisQueryComparable()Check whether the table (or view) contains no columns that prevent index conditions to be used.booleanisView()voidremoveRow(SessionLocal session, Row row)Remove a row from the table and all indexes.longtruncate(SessionLocal session)Remove all rows from the table and indexes.-
Methods inherited from class org.h2.table.Table
addConstraint, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canDrop, canTruncate, checkDeadlock, checkWritingAllowed, compareValues, convertInsertRow, convertUpdateRow, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDependentMaterializedViews, getDependentViews, getDiskSpaceUsed, getIdentityColumn, getIndex, getIndexForColumn, getMainIndexColumn, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRow, getRowFactory, getRowIdColumn, getSQLTableType, getTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isGlobalTemporary, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isRowLockable, lock, lockRow, removeChildrenAndResources, removeColumnExpressionsDependencies, removeConstraint, removeDependentMaterializedView, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setColumns, setOnCommitDrop, setOnCommitTruncate, unlock, updateRow, updateRows
-
Methods inherited from class org.h2.schema.SchemaObject
getSchema, getSQL, getSQL
-
Methods inherited from class org.h2.engine.DbObject
checkRename, equals, getComment, getCreateSQL, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, hashCode, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
-
-
-
Method Detail
-
createQueryColumnTemplateList
public static java.util.List<Column> createQueryColumnTemplateList(java.lang.String[] cols, Query theQuery, boolean cte)
Creates a list of column templates from a query (usually from WITH query, but could be any query)- Parameters:
cols- - an optional list of column names (can be specified by WITH clause overriding usual select names)theQuery- - the query object we want the column list forcte-truefor CTE- Returns:
- a list of column object returned by withQuery
-
getQuery
public final Query getQuery()
-
getTopQuery
public abstract Query getTopQuery()
-
close
public final void close(SessionLocal session)
Description copied from class:TableClose the table object and flush changes.
-
addIndex
public final Index addIndex(SessionLocal session, java.lang.String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, java.lang.String indexComment)
Description copied from class:TableCreate an index for this table- Specified by:
addIndexin classTable- Parameters:
session- the sessionindexName- the name of the indexindexId- the idcols- the index columnsuniqueColumnCount- the count of unique columnsindexType- the index typecreate- whether this is a new indexindexComment- the comment- Returns:
- the index
-
getBestPlanItem
public final PlanItem getBestPlanItem(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet, boolean isSelectCommand)
Description copied from class:TableGet the best plan for the given search mask.- Overrides:
getBestPlanItemin classTable- Parameters:
session- the sessionmasks- per-column comparison bit masks, null means 'always false', see constants in IndexConditionfilters- all joined table filtersfilter- the current table filter indexsortOrder- the sort orderallColumnsSet- the set of all columns- Returns:
- the plan item
-
isQueryComparable
public boolean isQueryComparable()
Description copied from class:TableCheck whether the table (or view) contains no columns that prevent index conditions to be used. For example, a view that contains the ROWNUM() pseudo-column prevents this.- Overrides:
isQueryComparablein classTable- Returns:
- true if the table contains no query-comparable column
-
isInsertable
public final boolean isInsertable()
Description copied from class:TableReturns whether this table is insertable.- Overrides:
isInsertablein classTable- Returns:
- whether this table is insertable
-
removeRow
public final void removeRow(SessionLocal session, Row row)
Description copied from class:TableRemove a row from the table and all indexes.
-
addRow
public final void addRow(SessionLocal session, Row row)
Description copied from class:TableAdd a row to the table and all indexes.
-
checkSupportAlter
public final void checkSupportAlter()
Description copied from class:TableCheck if this table supports ALTER TABLE.- Specified by:
checkSupportAlterin classTable
-
truncate
public final long truncate(SessionLocal session)
Description copied from class:TableRemove all rows from the table and indexes.
-
getRowCount
public final long getRowCount(SessionLocal session)
Description copied from class:TableGet the row count for this table.- Specified by:
getRowCountin classTable- Parameters:
session- the session- Returns:
- the row count
-
canGetRowCount
public final boolean canGetRowCount(SessionLocal session)
Description copied from class:TableCheck if the row count can be retrieved quickly.- Specified by:
canGetRowCountin classTable- Parameters:
session- the session- Returns:
- true if it can
-
getRowCountApproximation
public final long getRowCountApproximation(SessionLocal session)
Description copied from class:TableGet the approximated row count for this table.- Specified by:
getRowCountApproximationin classTable- Parameters:
session- the session- Returns:
- the approximated row count
-
getParameterOffset
public final int getParameterOffset(java.util.ArrayList<Parameter> additionalParameters)
Get the index of the first parameter.- Parameters:
additionalParameters- additional parameters- Returns:
- the index of the first parameter
-
canReference
public final boolean canReference()
Description copied from class:TableCheck if this table can be referenced.- Overrides:
canReferencein classTable- Returns:
- true if it can
-
getIndexes
public final java.util.List<Index> getIndexes()
Description copied from class:TableGet all indexes for this table.- Specified by:
getIndexesin classTable- Returns:
- the list of indexes
-
getMaxDataModificationId
public long getMaxDataModificationId()
Description copied from class:TableGet the last data modification id.- Specified by:
getMaxDataModificationIdin classTable- Returns:
- the modification id
-
getScanIndex
public final Index getScanIndex(SessionLocal session)
Description copied from class:TableGet the scan index to iterate through all rows.- Specified by:
getScanIndexin classTable- Parameters:
session- the session- Returns:
- the index
-
getScanIndex
public Index getScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)
Description copied from class:TableGet the scan index for this table.- Overrides:
getScanIndexin classTable- Parameters:
session- the sessionmasks- the search maskfilters- the table filtersfilter- the filter indexsortOrder- the sort orderallColumnsSet- all columns- Returns:
- the scan index
-
isDeterministic
public boolean isDeterministic()
Description copied from class:TableCheck if the table is deterministic.- Specified by:
isDeterministicin classTable- Returns:
- true if it is
-
addDependencies
public final void addDependencies(java.util.HashSet<DbObject> dependencies)
Description copied from class:TableAdd all objects that this table depends on to the hash set.- Overrides:
addDependenciesin classTable- Parameters:
dependencies- the current set of dependencies
-
getQueryScope
public abstract QueryScope getQueryScope()
Returns the scope of this table- Returns:
- the scope of this table
-
-