Package org.h2.table
Class MetaTable
java.lang.Object
org.h2.engine.DbObject
org.h2.schema.SchemaObject
org.h2.table.Table
org.h2.table.MetaTable
- All Implemented Interfaces:
HasSQL
- Direct Known Subclasses:
InformationSchemaTable,InformationSchemaTableLegacy,PgCatalogTable
This class is responsible to build the database metadata pseudo tables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe indexed column.protected MetaIndexThe index for this table.static final longThe approximate number of rows of a meta table.protected final intThe table type.Fields inherited from class org.h2.table.Table
columns, compareMode, EXCLUSIVE_LOCK, READ_LOCK, TYPE_CACHED, TYPE_MEMORY, WRITE_LOCKFields 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, USERFields 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidadd(SessionLocal session, ArrayList<Row> rows, Object... stringsOrValues) Add a row to a list.final IndexaddIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment) Create an index for this tablefinal voidaddRow(SessionLocal session, Row row) Add a row to the table and all indexes.final booleancanDrop()Check if this table can be dropped.booleancanGetRowCount(SessionLocal session) Check if the row count can be retrieved quickly.final booleanCheck if this table can be referenced.protected final booleancheckIndex(SessionLocal session, String value, Value indexFrom, Value indexTo) Checks index conditions.final voidCheck if renaming is allowed.final voidCheck if this table supports ALTER TABLE.final voidclose(SessionLocal session) Close the table object and flush changes.protected final ColumnCreates a column with the specified name and data type.generateRows(SessionLocal session, SearchRow first, SearchRow last) Generate the data for the given metadata table using the given first and last row filters.protected final Stream<Constraint> getAllConstraints(SessionLocal session) Get all constraints of this database, including constraints of local temporary tables for the session.getAllTables(SessionLocal session, Value indexFrom, Value indexTo) Get all tables of this database, including local temporary tables for the session.final StringConstruct the CREATE ...Get all indexes for this table.longgetRowCount(SessionLocal session) Get the row count for this table.longgetRowCountApproximation(SessionLocal session) Get the approximated row count for this table.final IndexgetScanIndex(SessionLocal session) Get the scan index to iterate through all rows.final TableTypeGet the table type nameprotected final Stringidentifier(String s) If needed, convert the identifier to lower case.final booleanCheck if the table is deterministic.booleanReturns whether this table is insertable.final voidremoveChildrenAndResources(SessionLocal session) Delete all dependent children objects and resources of this object.final voidremoveRow(SessionLocal session, Row row) Remove a row from the table and all indexes.protected voidsetColumns(Column[] columns) protected final voidsetMetaTableName(String upperName) final longtruncate(SessionLocal session) Remove all rows from the table and indexes.Methods inherited from class org.h2.table.Table
addConstraint, addDependencies, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canTruncate, checkDeadlock, checkWritingAllowed, compareValues, convertInsertRow, convertUpdateRow, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getBestPlanItem, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDependentMaterializedViews, getDependentViews, getDiskSpaceUsed, getIdentityColumn, getIndex, getIndexForColumn, getMainIndexColumn, getMaxDataModificationId, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRow, getRowFactory, getRowIdColumn, getScanIndex, getSQLTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isGlobalTemporary, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isQueryComparable, isRowLockable, isView, lock, lockRow, removeColumnExpressionsDependencies, removeConstraint, removeDependentMaterializedView, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setOnCommitDrop, setOnCommitTruncate, unlock, updateRow, updateRowsMethods inherited from class org.h2.schema.SchemaObject
getSchema, getSQL, getSQLMethods inherited from class org.h2.engine.DbObject
equals, getComment, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, hashCode, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
Field Details
-
ROW_COUNT_APPROXIMATION
public static final long ROW_COUNT_APPROXIMATIONThe approximate number of rows of a meta table.- See Also:
-
type
protected final int typeThe table type. -
indexColumn
protected int indexColumnThe indexed column. -
metaIndex
The index for this table.
-
-
Constructor Details
-
MetaTable
Create a new metadata table.- Parameters:
schema- the schemaid- the object idtype- the meta table type
-
-
Method Details
-
setColumns
- Overrides:
setColumnsin classTable
-
setMetaTableName
-
column
Creates a column with the specified name and data type.- Parameters:
name- the uppercase column nametype- the data type- Returns:
- the column
-
getCreateSQL
Description copied from class:DbObjectConstruct the CREATE ... SQL statement for this object.- Specified by:
getCreateSQLin classDbObject- Returns:
- the SQL statement
-
addIndex
public final Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, 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
-
identifier
If needed, convert the identifier to lower case.- Parameters:
s- the identifier to convert- Returns:
- the converted identifier
-
checkIndex
protected final boolean checkIndex(SessionLocal session, String value, Value indexFrom, Value indexTo) Checks index conditions.- Parameters:
session- the sessionvalue- the valueindexFrom- the lower bound of value, ornullindexTo- the higher bound of value, ornull- Returns:
- whether row should be included into result
-
getAllTables
Get all tables of this database, including local temporary tables for the session.- Parameters:
session- the sessionindexFrom- first value ornullindexTo- last value ornull- Returns:
- the stream of tables
-
getAllConstraints
Get all constraints of this database, including constraints of local temporary tables for the session.- Parameters:
session- the session- Returns:
- the stream of constraints
-
generateRows
Generate the data for the given metadata table using the given first and last row filters.- Parameters:
session- the sessionfirst- the first row to returnlast- the last row to return- Returns:
- the generated rows
-
isInsertable
public boolean isInsertable()Description copied from class:TableReturns whether this table is insertable.- Overrides:
isInsertablein classTable- Returns:
- whether this table is insertable
-
removeRow
Description copied from class:TableRemove a row from the table and all indexes. -
addRow
Description copied from class:TableAdd a row to the table and all indexes. -
removeChildrenAndResources
Description copied from class:DbObjectDelete all dependent children objects and resources of this object.- Overrides:
removeChildrenAndResourcesin classTable- Parameters:
session- the session
-
close
Description copied from class:TableClose the table object and flush changes. -
add
Add a row to a list.- Parameters:
session- the sessionrows- the original row liststringsOrValues- the values, or strings
-
checkRename
public final void checkRename()Description copied from class:DbObjectCheck if renaming is allowed. Does nothing when allowed.- Overrides:
checkRenamein classDbObject
-
checkSupportAlter
public final void checkSupportAlter()Description copied from class:TableCheck if this table supports ALTER TABLE.- Specified by:
checkSupportAlterin classTable
-
truncate
Description copied from class:TableRemove all rows from the table and indexes. -
getRowCount
Description copied from class:TableGet the row count for this table.- Specified by:
getRowCountin classTable- Parameters:
session- the session- Returns:
- the row count
-
canGetRowCount
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
-
canDrop
public final boolean canDrop()Description copied from class:TableCheck if this table can be dropped. -
getTableType
Description copied from class:TableGet the table type name- Specified by:
getTableTypein classTable- Returns:
- the table type name
-
getScanIndex
Description copied from class:TableGet the scan index to iterate through all rows.- Specified by:
getScanIndexin classTable- Parameters:
session- the session- Returns:
- the index
-
getIndexes
Description copied from class:TableGet all indexes for this table.- Specified by:
getIndexesin classTable- Returns:
- the list of indexes
-
getRowCountApproximation
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
-
isDeterministic
public final boolean isDeterministic()Description copied from class:TableCheck if the table is deterministic.- Specified by:
isDeterministicin classTable- Returns:
- true if it is
-
canReference
public final boolean canReference()Description copied from class:TableCheck if this table can be referenced.- Overrides:
canReferencein classTable- Returns:
- true if it can
-