public class TableView extends Table
columns, compareMode, isHidden, TYPE_CACHED, TYPE_MEMORYcomment, database, traceAGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE| Constructor and Description |
|---|
TableView(Schema schema,
int id,
java.lang.String name,
java.lang.String querySQL,
java.util.ArrayList<Parameter> params,
Column[] columnTemplates,
Session session,
boolean allowRecursive,
boolean literalsChecked,
boolean isTableExpression,
boolean isPersistent) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDependencies(java.util.HashSet<DbObject> dependencies)
Add all objects that this table depends on to the hash set.
|
Index |
addIndex(Session session,
java.lang.String indexName,
int indexId,
IndexColumn[] cols,
IndexType indexType,
boolean create,
java.lang.String indexComment)
Create an index for this table
|
void |
addRow(Session session,
Row row)
Add a row to the table and all indexes.
|
boolean |
canDrop()
Check if this table can be dropped.
|
boolean |
canGetRowCount()
Check if the row count can be retrieved quickly.
|
boolean |
canReference()
Check if this table can be referenced.
|
void |
checkRename()
Check if this object can be renamed.
|
void |
checkSupportAlter()
Check if this table supports ALTER TABLE.
|
static void |
clearIndexCaches(Database database)
Clear the cached indexes for all sessions.
|
void |
close(Session session)
Close the table object and flush changes.
|
static java.util.List<Column> |
createQueryColumnTemplateList(java.lang.String[] cols,
Query theQuery,
java.lang.String[] querySQLOutput)
Creates a list of column templates from a query (usually from WITH query,
but could be any query)
|
static Table |
createShadowTableForRecursiveTableExpression(boolean isPersistent,
Session targetSession,
java.lang.String cteViewName,
Schema schema,
java.util.List<Column> columns,
Database db)
Create a table for a recursive query.
|
static TableView |
createTableViewMaybeRecursive(Schema schema,
int id,
java.lang.String name,
java.lang.String querySQL,
java.util.ArrayList<Parameter> parameters,
Column[] columnTemplates,
Session session,
boolean literalsChecked,
boolean isTableExpression,
boolean isPersistent,
Database db)
Create a view.
|
static TableView |
createTempView(Session session,
User owner,
java.lang.String name,
Query query,
Query topQuery)
Create a temporary view out of the given query.
|
static void |
destroyShadowTableForRecursiveExpression(boolean isPersistent,
Session targetSession,
Table recursiveTable)
Remove a table for a recursive query.
|
PlanItem |
getBestPlanItem(Session session,
int[] masks,
TableFilter[] filters,
int filter,
SortOrder sortOrder,
java.util.HashSet<Column> allColumnsSet)
Get the best plan for the given search mask.
|
java.lang.String |
getCreateSQL()
Build a SQL statement to re-create this object.
|
java.lang.String |
getCreateSQL(boolean orReplace,
boolean force)
Generate "CREATE" SQL statement for the view.
|
java.lang.String |
getCreateSQLForCopy(Table table,
java.lang.String quotedName)
Build a SQL statement to re-create the object, or to create a copy of the
object with a different name or referencing a different table
|
long |
getDiskSpaceUsed() |
java.lang.String |
getDropSQL()
Build a SQL statement to drop this object.
|
java.util.ArrayList<Index> |
getIndexes()
Get all indexes for this table.
|
long |
getMaxDataModificationId()
Get the last data modification id.
|
User |
getOwner() |
int |
getParameterOffset(java.util.ArrayList<Parameter> additionalParameters)
Get the index of the first parameter.
|
java.lang.String |
getQuery() |
ResultInterface |
getRecursiveResult() |
long |
getRowCount(Session session)
Get the row count for this table.
|
long |
getRowCountApproximation()
Get the approximated row count for this table.
|
Index |
getScanIndex(Session session)
Get the scan index to iterate through all rows.
|
Index |
getScanIndex(Session session,
int[] masks,
TableFilter[] filters,
int filter,
SortOrder sortOrder,
java.util.HashSet<Column> allColumnsSet)
Get the scan index for this table.
|
java.lang.String |
getSQL()
Get the SQL name of this object (may be quoted).
|
java.util.List<Table> |
getTables() |
TableType |
getTableType()
Get the table type name
|
Query |
getTopQuery() |
Index |
getUniqueIndex()
Get any unique index for this table if one exists.
|
boolean |
isDeterministic()
Check if the table is deterministic.
|
boolean |
isInvalid()
Check if this view is currently invalid.
|
boolean |
isLockedExclusively()
Check if this table is locked exclusively.
|
boolean |
isPersistent() |
boolean |
isQueryComparable()
Check whether the table (or view) contains no columns that prevent index
conditions to be used.
|
boolean |
isRecursive() |
boolean |
isRecursiveQueryDetected()
Was query recursion detected during compiling.
|
boolean |
isView() |
boolean |
lock(Session session,
boolean exclusive,
boolean forceLockEvenInMvcc)
Lock the table for the given session.
|
DbException |
recompile(Session session,
boolean force,
boolean clearIndexCache)
Re-compile the view query and all views that depend on this object.
|
void |
removeChildrenAndResources(Session session)
Remove all dependent objects and free all resources (files, blocks in
files) of this object.
|
void |
removeRow(Session session,
Row row)
Remove a row from the table and all indexes.
|
void |
replace(java.lang.String querySQL,
Column[] newColumnTemplates,
Session session,
boolean recursive,
boolean force,
boolean literalsChecked)
Try to replace the SQL statement of the view and re-compile this and all
dependent views.
|
void |
setRecursiveResult(ResultInterface value) |
void |
truncate(Session session)
Remove all rows from the table and indexes.
|
void |
unlock(Session s)
Release the lock for this session.
|
addConstraint, addDependentView, addSequence, addSynonym, addTrigger, canTruncate, checkDeadlock, checkWritingAllowed, commit, compareTypeSafe, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDefaultValue, getDependentViews, getIndex, getIndexForColumn, getOnCommitDrop, getOnCommitTruncate, getOnUpdateValue, getPrimaryKey, getRow, getRowIdColumn, getTemplateRow, getTemplateSimpleRow, getType, hasSelectTrigger, isGlobalTemporary, isHidden, isLockedExclusivelyBy, isMVStore, isPersistData, isPersistIndexes, isTableExpression, removeConstraint, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setColumns, setHidden, setOnCommitDrop, setOnCommitTruncate, setTableExpression, updateRows, validateConvertUpdateSequencegetSchema, initSchemaObjectBasegetComment, getDatabase, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetComment, getDatabase, getId, getName, isTemporary, setComment, setTemporarypublic void replace(java.lang.String querySQL,
Column[] newColumnTemplates,
Session session,
boolean recursive,
boolean force,
boolean literalsChecked)
querySQL - the SQL statementnewColumnTemplates - the columnssession - the sessionrecursive - whether this is a recursive viewforce - if errors should be ignoredliteralsChecked - if literals have been checkedpublic DbException recompile(Session session, boolean force, boolean clearIndexCache)
session - the sessionforce - if exceptions should be ignoredclearIndexCache - if we need to clear view index cachepublic boolean isInvalid()
public PlanItem getBestPlanItem(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, java.util.HashSet<Column> allColumnsSet)
TablegetBestPlanItem in class Tablesession - 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 columnspublic boolean isQueryComparable()
TableisQueryComparable in class Tablepublic Query getTopQuery()
public java.lang.String getDropSQL()
DbObjectBasegetDropSQL in interface DbObjectgetDropSQL in class DbObjectBasepublic java.lang.String getCreateSQLForCopy(Table table, java.lang.String quotedName)
DbObjectgetCreateSQLForCopy in interface DbObjectgetCreateSQLForCopy in class Tabletable - the new tablequotedName - the quoted namepublic java.lang.String getCreateSQL()
DbObjectBasegetCreateSQL in interface DbObjectgetCreateSQL in class DbObjectBasepublic java.lang.String getCreateSQL(boolean orReplace,
boolean force)
orReplace - if true, then include the OR REPLACE clauseforce - if true, then include the FORCE clausepublic void checkRename()
DbObjectBasecheckRename in interface DbObjectcheckRename in class DbObjectBasepublic boolean lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc)
Tablepublic void close(Session session)
Tablepublic void unlock(Session s)
Tablepublic boolean isLockedExclusively()
TableisLockedExclusively in class Tablepublic Index addIndex(Session session, java.lang.String indexName, int indexId, IndexColumn[] cols, IndexType indexType, boolean create, java.lang.String indexComment)
Tablepublic void removeRow(Session session, Row row)
Tablepublic void addRow(Session session, Row row)
Tablepublic void checkSupportAlter()
TablecheckSupportAlter in class Tablepublic void truncate(Session session)
Tablepublic long getRowCount(Session session)
TablegetRowCount in class Tablesession - the sessionpublic boolean canGetRowCount()
TablecanGetRowCount in class Tablepublic boolean canDrop()
Tablepublic TableType getTableType()
TablegetTableType in class Tablepublic void removeChildrenAndResources(Session session)
DbObjectBaseremoveChildrenAndResources in interface DbObjectremoveChildrenAndResources in class Tablesession - the sessionpublic static void clearIndexCaches(Database database)
database - the databasepublic java.lang.String getSQL()
DbObjectgetSQL in interface DbObjectgetSQL in class SchemaObjectBasepublic java.lang.String getQuery()
public Index getScanIndex(Session session)
TablegetScanIndex in class Tablesession - the sessionpublic Index getScanIndex(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, java.util.HashSet<Column> allColumnsSet)
TablegetScanIndex in class Tablesession - the sessionmasks - the search maskfilters - the table filtersfilter - the filter indexsortOrder - the sort orderallColumnsSet - all columnspublic boolean canReference()
TablecanReference in class Tablepublic java.util.ArrayList<Index> getIndexes()
TablegetIndexes in class Tablepublic long getMaxDataModificationId()
TablegetMaxDataModificationId in class Tablepublic Index getUniqueIndex()
TablegetUniqueIndex in class Tablepublic User getOwner()
public static TableView createTempView(Session session, User owner, java.lang.String name, Query query, Query topQuery)
session - the sessionowner - the owner of the queryname - the view namequery - the querytopQuery - the top level querypublic long getRowCountApproximation()
TablegetRowCountApproximation in class Tablepublic long getDiskSpaceUsed()
getDiskSpaceUsed in class Tablepublic int getParameterOffset(java.util.ArrayList<Parameter> additionalParameters)
additionalParameters - additional parameterspublic boolean isRecursive()
public boolean isDeterministic()
TableisDeterministic in class Tablepublic void setRecursiveResult(ResultInterface value)
public ResultInterface getRecursiveResult()
public void addDependencies(java.util.HashSet<DbObject> dependencies)
TableaddDependencies in class Tabledependencies - the current set of dependenciespublic boolean isRecursiveQueryDetected()
public java.util.List<Table> getTables()
public boolean isPersistent()
public static TableView createTableViewMaybeRecursive(Schema schema, int id, java.lang.String name, java.lang.String querySQL, java.util.ArrayList<Parameter> parameters, Column[] columnTemplates, Session session, boolean literalsChecked, boolean isTableExpression, boolean isPersistent, Database db)
schema - the schemaid - the view idname - the view namequerySQL - the queryparameters - the parameterscolumnTemplates - the columnssession - the sessionliteralsChecked - whether literals in the query are checkedisTableExpression - if this is a table expressionisPersistent - whether the view is persisteddb - the databasepublic static java.util.List<Column> createQueryColumnTemplateList(java.lang.String[] cols, Query theQuery, java.lang.String[] querySQLOutput)
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 forquerySQLOutput - - array of length 1 to receive extra 'output' field
in addition to return value - containing the SQL query of the
Query objectpublic static Table createShadowTableForRecursiveTableExpression(boolean isPersistent, Session targetSession, java.lang.String cteViewName, Schema schema, java.util.List<Column> columns, Database db)
isPersistent - whether the table is persistedtargetSession - the sessioncteViewName - the nameschema - the schemacolumns - the columnsdb - the databasepublic static void destroyShadowTableForRecursiveExpression(boolean isPersistent,
Session targetSession,
Table recursiveTable)
isPersistent - whether the table is persistedtargetSession - the sessionrecursiveTable - the table