TableView

A view is a virtual table that is defined by a query.

Methods
static void clearIndexCaches(Database database)
Clear the cached indexes for all sessions.
static void clearIndexCaches(Database database)
Clear the cached indexes for all sessions.
Parameters:
database - the database
static List createQueryColumnTemplateList(String[] cols, Query theQuery, String[] querySQLOutput)
Creates a list of column templates from a query (usually from WITH query, but could be any query)
static List createQueryColumnTemplateList(String[] cols, Query theQuery, String[] querySQLOutput)
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 for
querySQLOutput - - array of length 1 to receive extra 'output' field in addition to return value - containing the SQL query of the Query object
Returns:
a list of column object returned by withQuery
static Table createShadowTableForRecursiveTableExpression(boolean isPersistent, Session targetSession, String cteViewName, Schema schema, List columns, Database db)
Create a table for a recursive query.
static Table createShadowTableForRecursiveTableExpression(boolean isPersistent, Session targetSession, String cteViewName, Schema schema, List columns, Database db)
Create a table for a recursive query.
Parameters:
isPersistent - whether the table is persisted
targetSession - the session
cteViewName - the name
schema - the schema
columns - the columns
db - the database
Returns:
the table
static TableView createTableViewMaybeRecursive(Schema schema, int id, String name, String querySQL, ArrayList parameters, Column[] columnTemplates, Session session, boolean literalsChecked, boolean isTableExpression, boolean isPersistent, Database db)
Create a view.
static TableView createTableViewMaybeRecursive(Schema schema, int id, String name, String querySQL, ArrayList parameters, Column[] columnTemplates, Session session, boolean literalsChecked, boolean isTableExpression, boolean isPersistent, Database db)
Create a view.
Parameters:
schema - the schema
id - the view id
name - the view name
querySQL - the query
parameters - the parameters
columnTemplates - the columns
session - the session
literalsChecked - whether literals in the query are checked
isTableExpression - if this is a table expression
isPersistent - whether the view is persisted
db - the database
Returns:
the view
static TableView createTempView(Session session, User owner, String name, Query query, Query topQuery)
Create a temporary view out of the given query.
static TableView createTempView(Session session, User owner, String name, Query query, Query topQuery)
Create a temporary view out of the given query.
Parameters:
session - the session
owner - the owner of the query
name - the view name
query - the query
topQuery - the top level query
Returns:
the view table
static void destroyShadowTableForRecursiveExpression(boolean isPersistent, Session targetSession, Table recursiveTable)
Remove a table for a recursive query.
static void destroyShadowTableForRecursiveExpression(boolean isPersistent, Session targetSession, Table recursiveTable)
Remove a table for a recursive query.
Parameters:
isPersistent - whether the table is persisted
targetSession - the session
recursiveTable - the table
void addDependencies(HashSet dependencies)
void addDependencies(HashSet dependencies)
Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols, IndexType indexType, boolean create, String indexComment)
Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols, IndexType indexType, boolean create, String indexComment)
void addRow(Session session, Row row)
void addRow(Session session, Row row)
boolean canDrop()
boolean canDrop()
boolean canGetRowCount()
boolean canGetRowCount()
boolean canReference()
boolean canReference()
void checkRename()
void checkRename()
void checkSupportAlter()
void checkSupportAlter()
void close(Session session)
void close(Session session)
PlanItem getBestPlanItem(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet allColumnsSet)
PlanItem getBestPlanItem(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet allColumnsSet)
String getCreateSQL()
String getCreateSQL()
String getCreateSQL(boolean orReplace, boolean force)
Generate "CREATE" SQL statement for the view.
String getCreateSQL(boolean orReplace, boolean force)
Generate "CREATE" SQL statement for the view.
Parameters:
orReplace - if true, then include the OR REPLACE clause
force - if true, then include the FORCE clause
Returns:
the SQL statement
String getCreateSQLForCopy(Table table, String quotedName)
String getCreateSQLForCopy(Table table, String quotedName)
long getDiskSpaceUsed()
long getDiskSpaceUsed()
String getDropSQL()
String getDropSQL()
ArrayList getIndexes()
ArrayList getIndexes()
long getMaxDataModificationId()
long getMaxDataModificationId()
User getOwner()
User getOwner()
int getParameterOffset(ArrayList additionalParameters)
Get the index of the first parameter.
int getParameterOffset(ArrayList additionalParameters)
Get the index of the first parameter.
Parameters:
additionalParameters - additional parameters
Returns:
the index of the first parameter
String getQuery()
String getQuery()
ResultInterface getRecursiveResult()
ResultInterface getRecursiveResult()
long getRowCount(Session session)
long getRowCount(Session session)
long getRowCountApproximation()
long getRowCountApproximation()
String getSQL()
String getSQL()
Index getScanIndex(Session session)
Index getScanIndex(Session session)
Index getScanIndex(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet allColumnsSet)
Index getScanIndex(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet allColumnsSet)
TableType getTableType()
TableType getTableType()
List getTables()
List getTables()
Query getTopQuery()
Query getTopQuery()
Index getUniqueIndex()
Index getUniqueIndex()
boolean isDeterministic()
boolean isDeterministic()
boolean isInvalid()
Check if this view is currently invalid.
boolean isInvalid()
Check if this view is currently invalid.
Returns:
true if it is
boolean isLockedExclusively()
boolean isLockedExclusively()
boolean isPersistent()
boolean isPersistent()
boolean isQueryComparable()
boolean isQueryComparable()
boolean isRecursive()
boolean isRecursive()
boolean isRecursiveQueryDetected()
Was query recursion detected during compiling.
boolean isRecursiveQueryDetected()
Was query recursion detected during compiling.
Returns:
true if yes
boolean isView()
boolean isView()
boolean lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc)
boolean lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc)
DbException recompile(Session session, boolean force, boolean clearIndexCache)
Re-compile the view query and all views that depend on this object.
DbException recompile(Session session, boolean force, boolean clearIndexCache)
Re-compile the view query and all views that depend on this object.
Parameters:
session - the session
force - if exceptions should be ignored
clearIndexCache - if we need to clear view index cache
Returns:
the exception if re-compiling this or any dependent view failed (only when force is disabled)
void removeChildrenAndResources(Session session)
void removeChildrenAndResources(Session session)
void removeRow(Session session, Row row)
void removeRow(Session session, Row row)
void replace(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 replace(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.
Parameters:
querySQL - the SQL statement
newColumnTemplates - the columns
session - the session
recursive - whether this is a recursive view
force - if errors should be ignored
literalsChecked - if literals have been checked
void setRecursiveResult(ResultInterface value)
void setRecursiveResult(ResultInterface value)
void truncate(Session session)
void truncate(Session session)
void unlock(Session s)
void unlock(Session s)