public abstract class Table extends SchemaObjectBase
Modifier and Type | Field and Description |
---|---|
protected Column[] |
columns
The columns of this table.
|
protected CompareMode |
compareMode
The compare mode used for this table.
|
protected boolean |
isHidden
Protected tables are not listed in the meta data and are excluded when
using the SCRIPT command.
|
static int |
TYPE_CACHED
The table type that means this table is a regular persistent table.
|
static int |
TYPE_MEMORY
The table type that means this table is a regular persistent table.
|
comment, database, trace
AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE
Constructor and Description |
---|
Table(Schema schema,
int id,
String name,
boolean persistIndexes,
boolean persistData) |
Modifier and Type | Method and Description |
---|---|
void |
addConstraint(Constraint constraint)
Add a constraint to the table.
|
void |
addDependencies(HashSet<DbObject> dependencies)
Add all objects that this table depends on to the hash set.
|
void |
addDependentView(TableView view)
Add a view to this table.
|
abstract Index |
addIndex(Session session,
String indexName,
int indexId,
IndexColumn[] cols,
IndexType indexType,
boolean create,
String indexComment)
Create an index for this table
|
abstract void |
addRow(Session session,
Row row)
Add a row to the table and all indexes.
|
void |
addSequence(Sequence sequence)
Add a sequence to this table.
|
void |
addSynonym(TableSynonym synonym)
Add a synonym to this table.
|
void |
addTrigger(TriggerObject trigger)
Add a trigger to this table.
|
abstract boolean |
canDrop()
Check if this table can be dropped.
|
abstract boolean |
canGetRowCount()
Check if the row count can be retrieved quickly.
|
boolean |
canReference()
Check if this table can be referenced.
|
boolean |
canTruncate()
Check if this table can be truncated.
|
ArrayList<Session> |
checkDeadlock(Session session,
Session clash,
Set<Session> visited)
Check if a deadlock occurred.
|
abstract void |
checkSupportAlter()
Check if this table supports ALTER TABLE.
|
void |
checkWritingAllowed()
Tests if the table can be written.
|
abstract void |
close(Session session)
Close the table object and flush changes.
|
void |
commit(short operation,
Row row)
Commit an operation (when using multi-version concurrency).
|
int |
compareTypeSafe(Value a,
Value b)
Compare two values with the current comparison mode.
|
boolean |
doesColumnExist(String columnName)
Does the column with the given name exist?
|
void |
dropMultipleColumnsConstraintsAndIndexes(Session session,
ArrayList<Column> columnsToDrop)
Check that these columns are not referenced by a multi-column constraint
or multi-column index.
|
Index |
findPrimaryKey()
Get the primary key index if there is one, or null if there is none.
|
void |
fire(Session session,
int type,
boolean beforeAction)
Fire the triggers for this table.
|
void |
fireAfterRow(Session session,
Row oldRow,
Row newRow,
boolean rollback)
Fire all triggers that need to be called after a row is updated.
|
boolean |
fireBeforeRow(Session session,
Row oldRow,
Row newRow)
Fire all triggers that need to be called before a row is updated.
|
boolean |
fireRow()
Check if row based triggers or constraints are defined.
|
PlanItem |
getBestPlanItem(Session session,
int[] masks,
TableFilter[] filters,
int filter,
SortOrder sortOrder,
HashSet<Column> allColumnsSet)
Get the best plan for the given search mask.
|
boolean |
getCheckForeignKeyConstraints() |
ArrayList<DbObject> |
getChildren()
Get the list of dependent children (for tables, this includes indexes and
so on).
|
Column |
getColumn(int index)
Get the column at the given index.
|
Column |
getColumn(String columnName)
Get the column with the given name.
|
Column[] |
getColumns() |
CompareMode |
getCompareMode() |
ArrayList<Constraint> |
getConstraints() |
String |
getCreateSQLForCopy(Table table,
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
|
Value |
getDefaultValue(Session session,
Column column)
Get or generate a default value for the given column.
|
CopyOnWriteArrayList<TableView> |
getDependentViews() |
abstract long |
getDiskSpaceUsed() |
Index |
getIndex(String indexName)
Get an index by name.
|
abstract ArrayList<Index> |
getIndexes()
Get all indexes for this table.
|
Index |
getIndexForColumn(Column column,
boolean needGetFirstOrLast,
boolean needFindNext)
Get the index that has the given column as the first element.
|
abstract long |
getMaxDataModificationId()
Get the last data modification id.
|
boolean |
getOnCommitDrop() |
boolean |
getOnCommitTruncate() |
Value |
getOnUpdateValue(Session session,
Column column)
Generates on update value for the given column.
|
Index |
getPrimaryKey() |
Row |
getRow(Session session,
long key)
Get the given row.
|
abstract long |
getRowCount(Session session)
Get the row count for this table.
|
abstract long |
getRowCountApproximation()
Get the approximated row count for this table.
|
Column |
getRowIdColumn()
Get the row id column if this table has one.
|
abstract 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,
HashSet<Column> allColumnsSet)
Get the scan index for this table.
|
abstract TableType |
getTableType()
Get the table type name
|
Row |
getTemplateRow() |
SearchRow |
getTemplateSimpleRow(boolean singleColumn)
Get a new simple row object.
|
int |
getType()
Get the object type.
|
abstract Index |
getUniqueIndex()
Get any unique index for this table if one exists.
|
boolean |
hasSelectTrigger()
Check whether this table has a select trigger.
|
abstract boolean |
isDeterministic()
Check if the table is deterministic.
|
boolean |
isGlobalTemporary() |
boolean |
isHidden()
Check whether this is a hidden object that doesn't appear in the meta
data and in the script, and is not dropped on DROP ALL OBJECTS.
|
abstract boolean |
isLockedExclusively()
Check if this table is locked exclusively.
|
boolean |
isLockedExclusivelyBy(Session session)
Check if the table is exclusively locked by this session.
|
boolean |
isMVStore() |
boolean |
isPersistData() |
boolean |
isPersistIndexes() |
boolean |
isQueryComparable()
Check whether the table (or view) contains no columns that prevent index
conditions to be used.
|
boolean |
isTableExpression() |
boolean |
isView() |
abstract boolean |
lock(Session session,
boolean exclusive,
boolean forceLockEvenInMvcc)
Lock the table for the given session.
|
void |
removeChildrenAndResources(Session session)
Remove all dependent objects and free all resources (files, blocks in
files) of this object.
|
void |
removeConstraint(Constraint constraint)
Remove the given constraint from the list.
|
void |
removeDependentView(TableView view)
Remove the given view from the dependent views list.
|
void |
removeIndex(Index index)
Remove the given index from the list.
|
void |
removeIndexOrTransferOwnership(Session session,
Index index)
If the index is still required by a constraint, transfer the ownership to
it.
|
abstract void |
removeRow(Session session,
Row row)
Remove a row from the table and all indexes.
|
void |
removeSequence(Sequence sequence)
Remove a sequence from the table.
|
void |
removeSynonym(TableSynonym synonym)
Remove the given view from the list.
|
void |
removeTrigger(TriggerObject trigger)
Remove the given trigger from the list.
|
void |
rename(String newName)
Rename the object.
|
void |
renameColumn(Column column,
String newName)
Rename a column of this table.
|
void |
setCheckForeignKeyConstraints(Session session,
boolean enabled,
boolean checkExisting)
Enable or disable foreign key constraint checking for this table.
|
protected void |
setColumns(Column[] columns) |
void |
setHidden(boolean hidden) |
void |
setOnCommitDrop(boolean onCommitDrop) |
void |
setOnCommitTruncate(boolean onCommitTruncate) |
void |
setTableExpression(boolean tableExpression) |
abstract void |
truncate(Session session)
Remove all rows from the table and indexes.
|
abstract void |
unlock(Session s)
Release the lock for this session.
|
void |
updateRows(Prepared prepared,
Session session,
RowList rows)
Update a list of rows in this table.
|
void |
validateConvertUpdateSequence(Session session,
Row row)
Validate all values in this row, convert the values if required, and
update the sequence values if required.
|
getSchema, getSQL, initSchemaObjectBase
checkRename, getComment, getCreateSQL, getDatabase, getDropSQL, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
checkRename, getComment, getCreateSQL, getDatabase, getDropSQL, getId, getName, isTemporary, setComment, setTemporary
public static final int TYPE_CACHED
public static final int TYPE_MEMORY
protected Column[] columns
protected CompareMode compareMode
protected boolean isHidden
public void rename(String newName)
DbObject
rename
in interface DbObject
rename
in class DbObjectBase
newName
- the new namepublic boolean isView()
public abstract boolean lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc)
session
- the sessionexclusive
- true for write locks, false for read locksforceLockEvenInMvcc
- lock even in the MVCC modeDbException
- if a lock timeout occurredpublic abstract void close(Session session)
session
- the sessionpublic abstract void unlock(Session s)
s
- the sessionpublic abstract Index addIndex(Session session, String indexName, int indexId, IndexColumn[] cols, IndexType indexType, boolean create, String indexComment)
session
- the sessionindexName
- the name of the indexindexId
- the idcols
- the index columnsindexType
- the index typecreate
- whether this is a new indexindexComment
- the commentpublic Row getRow(Session session, long key)
session
- the sessionkey
- the primary keypublic abstract void removeRow(Session session, Row row)
session
- the sessionrow
- the rowpublic abstract void truncate(Session session)
session
- the sessionpublic abstract void addRow(Session session, Row row)
session
- the sessionrow
- the rowDbException
- if a constraint was violatedpublic void commit(short operation, Row row)
operation
- the operationrow
- the rowpublic abstract void checkSupportAlter()
DbException
- if it is not supportedpublic abstract TableType getTableType()
public abstract Index getScanIndex(Session session)
session
- the sessionpublic Index getScanIndex(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet<Column> allColumnsSet)
session
- the sessionmasks
- the search maskfilters
- the table filtersfilter
- the filter indexsortOrder
- the sort orderallColumnsSet
- all columnspublic abstract Index getUniqueIndex()
public abstract ArrayList<Index> getIndexes()
public Index getIndex(String indexName)
indexName
- the index name to search forpublic abstract boolean isLockedExclusively()
public abstract long getMaxDataModificationId()
public abstract boolean isDeterministic()
public abstract boolean canGetRowCount()
public boolean canReference()
public abstract boolean canDrop()
public abstract long getRowCount(Session session)
session
- the sessionpublic abstract long getRowCountApproximation()
public abstract long getDiskSpaceUsed()
public Column getRowIdColumn()
public String getCreateSQLForCopy(Table table, String quotedName)
DbObject
table
- the new tablequotedName
- the quoted namepublic boolean isQueryComparable()
public void addDependencies(HashSet<DbObject> dependencies)
dependencies
- the current set of dependenciespublic ArrayList<DbObject> getChildren()
DbObject
getChildren
in interface DbObject
getChildren
in class DbObjectBase
protected void setColumns(Column[] columns)
public void renameColumn(Column column, String newName)
column
- the column to renamenewName
- the new column namepublic boolean isLockedExclusivelyBy(Session session)
session
- the sessionpublic void updateRows(Prepared prepared, Session session, RowList rows)
prepared
- the prepared statementsession
- the sessionrows
- a list of row pairs of the form old row, new row, old row,
new row,...public CopyOnWriteArrayList<TableView> getDependentViews()
public void removeChildrenAndResources(Session session)
DbObjectBase
removeChildrenAndResources
in interface DbObject
removeChildrenAndResources
in class DbObjectBase
session
- the sessionpublic void dropMultipleColumnsConstraintsAndIndexes(Session session, ArrayList<Column> columnsToDrop)
session
- the sessioncolumnsToDrop
- the columns to dropDbException
- if the column is referenced by multi-column
constraints or indexespublic Row getTemplateRow()
public SearchRow getTemplateSimpleRow(boolean singleColumn)
singleColumn
- if only one value need to be storedpublic Column[] getColumns()
public int getType()
DbObject
public Column getColumn(int index)
index
- the column index (0, 1,...)public Column getColumn(String columnName)
columnName
- the column nameDbException
- if the column was not foundpublic boolean doesColumnExist(String columnName)
columnName
- the column namepublic PlanItem getBestPlanItem(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet<Column> allColumnsSet)
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 columnspublic Index findPrimaryKey()
public Index getPrimaryKey()
public void validateConvertUpdateSequence(Session session, Row row)
session
- the sessionrow
- the rowpublic void removeIndex(Index index)
index
- the index to removepublic void removeDependentView(TableView view)
view
- the view to removepublic void removeSynonym(TableSynonym synonym)
synonym
- the synonym to removepublic void removeConstraint(Constraint constraint)
constraint
- the constraint to removepublic final void removeSequence(Sequence sequence)
sequence
- the sequence to removepublic void removeTrigger(TriggerObject trigger)
trigger
- the trigger to removepublic void addDependentView(TableView view)
view
- the view to addpublic void addSynonym(TableSynonym synonym)
synonym
- the synonym to addpublic void addConstraint(Constraint constraint)
constraint
- the constraint to addpublic ArrayList<Constraint> getConstraints()
public void addSequence(Sequence sequence)
sequence
- the sequence to addpublic void addTrigger(TriggerObject trigger)
trigger
- the trigger to addpublic void fire(Session session, int type, boolean beforeAction)
session
- the sessiontype
- the trigger typebeforeAction
- whether 'before' triggers should be calledpublic boolean hasSelectTrigger()
public boolean fireRow()
public boolean fireBeforeRow(Session session, Row oldRow, Row newRow)
session
- the sessionoldRow
- the old data or null for an insertnewRow
- the new data or null for a deletepublic void fireAfterRow(Session session, Row oldRow, Row newRow, boolean rollback)
session
- the sessionoldRow
- the old data or null for an insertnewRow
- the new data or null for a deleterollback
- when the operation occurred within a rollbackpublic boolean isGlobalTemporary()
public boolean canTruncate()
public void setCheckForeignKeyConstraints(Session session, boolean enabled, boolean checkExisting)
session
- the sessionenabled
- true if checking should be enabledcheckExisting
- true if existing rows must be checked during this
callpublic boolean getCheckForeignKeyConstraints()
public Index getIndexForColumn(Column column, boolean needGetFirstOrLast, boolean needFindNext)
column
- the columnneedGetFirstOrLast
- if the returned index must be able
to do Index.canGetFirstOrLast()
needFindNext
- if the returned index must be able to do
Index.findNext(Session, SearchRow, SearchRow)
public boolean getOnCommitDrop()
public void setOnCommitDrop(boolean onCommitDrop)
public boolean getOnCommitTruncate()
public void setOnCommitTruncate(boolean onCommitTruncate)
public void removeIndexOrTransferOwnership(Session session, Index index)
session
- the sessionindex
- the index that is no longer requiredpublic ArrayList<Session> checkDeadlock(Session session, Session clash, Set<Session> visited)
session
- the session to be tested forclash
- set with sessions already visited, and null when starting
verificationvisited
- set with sessions already visited, and null when starting
verificationpublic boolean isPersistIndexes()
public boolean isPersistData()
public int compareTypeSafe(Value a, Value b)
a
- the first valueb
- the second valuepublic CompareMode getCompareMode()
public void checkWritingAllowed()
public Value getDefaultValue(Session session, Column column)
session
- the sessioncolumn
- the columnpublic Value getOnUpdateValue(Session session, Column column)
session
- the sessioncolumn
- the columnpublic boolean isHidden()
SchemaObject
isHidden
in interface SchemaObject
isHidden
in class SchemaObjectBase
public void setHidden(boolean hidden)
public boolean isMVStore()
public void setTableExpression(boolean tableExpression)
public boolean isTableExpression()
Copyright © 2020 JBoss by Red Hat. All rights reserved.