public abstract class Table extends SchemaObject
| Modifier and Type | Field and Description |
|---|---|
protected Column[] |
columns
The columns of this table.
|
protected CompareMode |
compareMode
The compare mode used for this table.
|
static int |
EXCLUSIVE_LOCK
Exclusive lock.
|
protected boolean |
isHidden
Protected tables are not listed in the meta data and are excluded when
using the SCRIPT command.
|
static int |
READ_LOCK
Read lock.
|
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.
|
static int |
WRITE_LOCK
Write lock.
|
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USERADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS| Modifier | Constructor and Description |
|---|---|
protected |
Table(Schema schema,
int id,
java.lang.String name,
boolean persistIndexes,
boolean persistData) |
| Modifier and Type | Method and Description |
|---|---|
void |
addConstraint(Constraint constraint)
Add a constraint to the table.
|
void |
addDependencies(java.util.HashSet<DbObject> dependencies)
Add all objects that this table depends on to the hash set.
|
void |
addDependentMaterializedView(MaterializedView view)
Add a materialized view to this table.
|
void |
addDependentView(TableView view)
Add a view to this table.
|
abstract Index |
addIndex(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 table
|
abstract void |
addRow(SessionLocal 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(SessionLocal session)
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.
|
java.util.ArrayList<SessionLocal> |
checkDeadlock(SessionLocal session,
SessionLocal clash,
java.util.Set<SessionLocal> 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(SessionLocal session)
Close the table object and flush changes.
|
int |
compareValues(CastDataProvider provider,
Value a,
Value b)
Compare two values with the current comparison mode.
|
void |
convertInsertRow(SessionLocal session,
Row row,
java.lang.Boolean overridingSystem)
Prepares the specified row for INSERT operation.
|
void |
convertUpdateRow(SessionLocal session,
Row row,
boolean fromTrigger)
Prepares the specified row for UPDATE operation.
|
Row |
createRow(Value[] data,
int memory)
Create a new row for this table.
|
boolean |
doesColumnExist(java.lang.String columnName)
Does the column with the given name exist?
|
void |
dropMultipleColumnsConstraintsAndIndexes(SessionLocal session,
java.util.ArrayList<Column> columnsToDrop)
Check that these columns are not referenced by a multi-column constraint
or multi-column index.
|
Column |
findColumn(java.lang.String columnName)
Get the column with the given name if it exists.
|
Index |
findPrimaryKey()
Get the primary key index if there is one, or null if there is none.
|
void |
fire(SessionLocal session,
int type,
boolean beforeAction)
Fire the triggers for this table.
|
void |
fireAfterRow(SessionLocal session,
Row oldRow,
Row newRow,
boolean rollback)
Fire all triggers that need to be called after a row is updated.
|
boolean |
fireBeforeRow(SessionLocal 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(SessionLocal session,
int[] masks,
TableFilter[] filters,
int filter,
SortOrder sortOrder,
AllColumnsForPlan allColumnsSet)
Get the best plan for the given search mask.
|
boolean |
getCheckForeignKeyConstraints() |
java.util.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(java.lang.String columnName)
Get the column with the given name.
|
Column |
getColumn(java.lang.String columnName,
boolean ifExists)
Get the column with the given name.
|
Column[] |
getColumns() |
CompareMode |
getCompareMode() |
java.util.ArrayList<Constraint> |
getConstraints() |
java.util.concurrent.CopyOnWriteArrayList<MaterializedView> |
getDependentMaterializedViews() |
java.util.concurrent.CopyOnWriteArrayList<TableView> |
getDependentViews() |
long |
getDiskSpaceUsed() |
Column |
getIdentityColumn()
Returns first identity column, or
null. |
Index |
getIndex(java.lang.String indexName)
Get an index by name.
|
abstract java.util.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.
|
int |
getMainIndexColumn()
Returns ID of main index column, or
SearchRow.ROWID_INDEX. |
abstract long |
getMaxDataModificationId()
Get the last data modification id.
|
Row |
getNullRow() |
boolean |
getOnCommitDrop() |
boolean |
getOnCommitTruncate() |
Index |
getPrimaryKey() |
Row |
getRow(SessionLocal session,
long key)
Get the given row.
|
abstract long |
getRowCount(SessionLocal session)
Get the row count for this table.
|
abstract long |
getRowCountApproximation(SessionLocal session)
Get the approximated row count for this table.
|
RowFactory |
getRowFactory() |
Column |
getRowIdColumn()
Get the row id column if this table has one.
|
abstract Index |
getScanIndex(SessionLocal session)
Get the scan index to iterate through all rows.
|
Index |
getScanIndex(SessionLocal session,
int[] masks,
TableFilter[] filters,
int filter,
SortOrder sortOrder,
AllColumnsForPlan allColumnsSet)
Get the scan index for this table.
|
java.lang.String |
getSQLTableType()
Return SQL table type for INFORMATION_SCHEMA.
|
abstract TableType |
getTableType()
Get the table type name
|
Row |
getTemplateRow() |
SearchRow |
getTemplateSimpleRow(boolean singleColumn)
Get a new simple row object.
|
java.util.ArrayList<TriggerObject> |
getTriggers()
Return list of triggers.
|
int |
getType()
Get the object type.
|
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.
|
boolean |
isInsertable()
Returns whether this table is insertable.
|
boolean |
isLockedExclusively()
Check if this table is locked exclusively.
|
boolean |
isLockedExclusivelyBy(SessionLocal session)
Check if the table is exclusively locked by this session.
|
boolean |
isPersistData() |
boolean |
isPersistIndexes() |
boolean |
isQueryComparable()
Check whether the table (or view) contains no columns that prevent index
conditions to be used.
|
boolean |
isRowLockable()
Views, function tables, links, etc.
|
boolean |
isTableExpression() |
boolean |
isView() |
boolean |
lock(SessionLocal session,
int lockType)
Lock the table for the given session.
|
Row |
lockRow(SessionLocal session,
Row row,
int timeoutMillis)
Locks row, preventing any updated to it, except from the session specified.
|
void |
removeChildrenAndResources(SessionLocal session)
Delete all dependent children objects and resources of this object.
|
void |
removeColumnExpressionsDependencies(SessionLocal session)
Removes dependencies of column expressions, used for tables with circular
dependencies.
|
void |
removeConstraint(Constraint constraint)
Remove the given constraint from the list.
|
void |
removeDependentMaterializedView(MaterializedView view)
Remove the given view from the dependent views 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(SessionLocal session,
Index index)
If the index is still required by a constraint, transfer the ownership to
it.
|
abstract void |
removeRow(SessionLocal 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(java.lang.String newName)
Rename the object.
|
void |
renameColumn(Column column,
java.lang.String newName)
Rename a column of this table.
|
void |
setCheckForeignKeyConstraints(SessionLocal 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 long |
truncate(SessionLocal session)
Remove all rows from the table and indexes.
|
void |
unlock(SessionLocal s)
Release the lock for this session.
|
void |
updateRow(SessionLocal session,
Row oldRow,
Row newRow)
Update a row to the table and all indexes.
|
void |
updateRows(Prepared prepared,
SessionLocal session,
LocalResult rows)
Update a list of rows in this table.
|
getSchema, getSQL, getSQLcheckRename, getComment, getCreateSQL, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetTraceSQLpublic static final int TYPE_CACHED
public static final int TYPE_MEMORY
public static final int READ_LOCK
public static final int WRITE_LOCK
public static final int EXCLUSIVE_LOCK
protected Column[] columns
protected CompareMode compareMode
protected boolean isHidden
protected Table(Schema schema, int id, java.lang.String name, boolean persistIndexes, boolean persistData)
public void rename(java.lang.String newName)
DbObjectpublic boolean isView()
public boolean lock(SessionLocal session, int lockType)
session - the sessionlockType - the type of lockDbException - if a lock timeout occurredpublic abstract void close(SessionLocal session)
session - the sessionpublic void unlock(SessionLocal s)
s - the sessionpublic abstract Index addIndex(SessionLocal session, java.lang.String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, java.lang.String indexComment)
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 commentpublic Row getRow(SessionLocal session, long key)
session - the sessionkey - the primary keypublic boolean isInsertable()
public abstract void removeRow(SessionLocal session, Row row)
session - the sessionrow - the rowpublic Row lockRow(SessionLocal session, Row row, int timeoutMillis)
session - the sessionrow - to locktimeoutMillis - timeout in milliseconds, -1 for default, -2 to
skip locking if row is already locked by another sessionpublic abstract long truncate(SessionLocal session)
session - the sessionpublic abstract void addRow(SessionLocal session, Row row)
session - the sessionrow - the rowDbException - if a constraint was violatedpublic void updateRow(SessionLocal session, Row oldRow, Row newRow)
session - the sessionoldRow - the row to updatenewRow - the row with updated values (_rowid_ suppose to be the same)DbException - if a constraint was violatedpublic abstract void checkSupportAlter()
DbException - if it is not supportedpublic abstract TableType getTableType()
public java.lang.String getSQLTableType()
public abstract Index getScanIndex(SessionLocal session)
session - the sessionpublic Index getScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)
session - the sessionmasks - the search maskfilters - the table filtersfilter - the filter indexsortOrder - the sort orderallColumnsSet - all columnspublic abstract java.util.ArrayList<Index> getIndexes()
public Index getIndex(java.lang.String indexName)
indexName - the index name to search forpublic boolean isLockedExclusively()
public abstract long getMaxDataModificationId()
public abstract boolean isDeterministic()
public abstract boolean canGetRowCount(SessionLocal session)
session - the sessionpublic boolean canReference()
public abstract boolean canDrop()
public abstract long getRowCount(SessionLocal session)
session - the sessionpublic abstract long getRowCountApproximation(SessionLocal session)
session - the sessionpublic long getDiskSpaceUsed()
public Column getRowIdColumn()
public boolean isQueryComparable()
public void addDependencies(java.util.HashSet<DbObject> dependencies)
dependencies - the current set of dependenciespublic java.util.ArrayList<DbObject> getChildren()
DbObjectgetChildren in class DbObjectnullprotected void setColumns(Column[] columns)
public void renameColumn(Column column, java.lang.String newName)
column - the column to renamenewName - the new column namepublic boolean isLockedExclusivelyBy(SessionLocal session)
session - the sessionpublic void updateRows(Prepared prepared, SessionLocal session, LocalResult rows)
prepared - the prepared statementsession - the sessionrows - a list of row pairs of the form old row, new row, old row,
new row,...public java.util.concurrent.CopyOnWriteArrayList<TableView> getDependentViews()
public java.util.concurrent.CopyOnWriteArrayList<MaterializedView> getDependentMaterializedViews()
public void removeChildrenAndResources(SessionLocal session)
DbObjectremoveChildrenAndResources in class DbObjectsession - the sessionpublic void dropMultipleColumnsConstraintsAndIndexes(SessionLocal session, java.util.ArrayList<Column> columnsToDrop)
session - the sessioncolumnsToDrop - the columns to dropDbException - if the column is referenced by multi-column
constraints or indexespublic RowFactory getRowFactory()
public Row createRow(Value[] data, int memory)
data - the valuesmemory - the estimated memory usage in bytespublic Row getTemplateRow()
public SearchRow getTemplateSimpleRow(boolean singleColumn)
singleColumn - if only one value need to be storedpublic Row getNullRow()
public Column[] getColumns()
public int getType()
DbObjectpublic Column getColumn(int index)
index - the column index (0, 1,...)public Column getColumn(java.lang.String columnName)
columnName - the column nameDbException - if the column was not foundpublic Column getColumn(java.lang.String columnName, boolean ifExists)
columnName - the column nameifExists - if true return null if column does not existDbException - if the column was not foundpublic Column findColumn(java.lang.String columnName)
columnName - the column name, or nullpublic boolean doesColumnExist(java.lang.String columnName)
columnName - the column namepublic Column getIdentityColumn()
null.nullpublic PlanItem getBestPlanItem(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan 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 convertInsertRow(SessionLocal session, Row row, java.lang.Boolean overridingSystem)
session - the sessionoverridingSystem - Boolean.TRUE for OVERRIDING SYSTEM VALUES,
Boolean.FALSE for OVERRIDING USER VALUES,
null if override clause is not specifiedrow - the rowpublic void convertUpdateRow(SessionLocal session, Row row, boolean fromTrigger)
session - the sessionrow - the rowfromTrigger - true if row was modified by INSERT or UPDATE triggerpublic void removeIndex(Index index)
index - the index to removepublic void removeDependentView(TableView view)
view - the view to removepublic void removeDependentMaterializedView(MaterializedView 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 addDependentMaterializedView(MaterializedView view)
view - the view to addpublic void addSynonym(TableSynonym synonym)
synonym - the synonym to addpublic void addConstraint(Constraint constraint)
constraint - the constraint to addpublic java.util.ArrayList<Constraint> getConstraints()
public void addSequence(Sequence sequence)
sequence - the sequence to addpublic void addTrigger(TriggerObject trigger)
trigger - the trigger to addpublic void fire(SessionLocal 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(SessionLocal 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(SessionLocal 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(SessionLocal 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(SessionLocal, SearchRow, SearchRow)public boolean getOnCommitDrop()
public void setOnCommitDrop(boolean onCommitDrop)
public boolean getOnCommitTruncate()
public void setOnCommitTruncate(boolean onCommitTruncate)
public void removeIndexOrTransferOwnership(SessionLocal session, Index index)
session - the sessionindex - the index that is no longer requiredpublic void removeColumnExpressionsDependencies(SessionLocal session)
session - the sessionpublic java.util.ArrayList<SessionLocal> checkDeadlock(SessionLocal session, SessionLocal clash, java.util.Set<SessionLocal> 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 compareValues(CastDataProvider provider, Value a, Value b)
provider - the cast information providera - the first valueb - the second valuepublic CompareMode getCompareMode()
public void checkWritingAllowed()
public boolean isHidden()
SchemaObjectisHidden in class SchemaObjectpublic void setHidden(boolean hidden)
public boolean isRowLockable()
public void setTableExpression(boolean tableExpression)
public boolean isTableExpression()
public java.util.ArrayList<TriggerObject> getTriggers()
public int getMainIndexColumn()
SearchRow.ROWID_INDEX.SearchRow.ROWID_INDEX