Top Description Inners Fields Constructors Methods
org.hsqldb

public Class SchemaManager

extends Object
Class Inheritance
Imports
java.util.concurrent.locks.Lock, .ReadWriteLock, .ReentrantReadWriteLock, org.hsqldb.HsqlNameManager.HsqlName, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.FilteredIterator, .HsqlArrayList, .Iterator, .List, .MultiValueHashMap, .OrderedHashMap, .OrderedHashSet, .WrapperIterator, org.hsqldb.navigator.RowIterator, org.hsqldb.rights.Grantee, org.hsqldb.types.Charset, .Collation, .Type

Manages all SCHEMA related database objects
Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.8.0
Version
2.7.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv HsqlNameManager.HsqlName[]
pack-priv Database
pack-priv HsqlNameManager.HsqlName
pack-priv int
pack-priv Table
pack-priv ReadWriteLock
pack-priv Lock
pack-priv MultiValueHashMap<HsqlNameManager.HsqlName, HsqlNameManager.HsqlName>
pack-priv long
pack-priv OrderedHashMap<String, Schema>
pack-priv long[][]
pack-priv SchemaManager.UserSchemaFilter
pack-priv Lock

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public void
public void
public void
public void
public void
public void
public void
createSchema(HsqlNameManager.HsqlName name, Grantee owner)

Creates a schema belonging to the given grantee.

public void
public Iterator<Constraint>
public Iterator<SchemaObject>
databaseObjectIterator(String schemaName, int type)

public Iterator<SchemaObject>
public Iterator<Table>
pack-priv void
dropConstraint(Session session, HsqlNameManager.HsqlName name, boolean cascade)

Drops the constraint with the specified name.

pack-priv void
dropIndex(Session session, HsqlNameManager.HsqlName name)

Drops the index with the specified name.

public void
dropSchema(Session session, String name, boolean cascade)

public void
dropSchemas(Session session, Grantee grantee, boolean cascade)

drop all schemas with the given authorisation

private void
dropTable(Session session, Table table, boolean cascade)

public void
dropTableOrView(Session
the connected context in which to perform this operation
session
,
Table
if true and if the Table to drop does not exist, fail silently, else throw
table
,
boolean
true if the name argument refers to a View
cascade
)

Drops the specified user-defined view or table from this Database object.

private void
dropView(Table table, boolean cascade)

public SchemaObject
public Type
findDomainOrUDT(Session session, String name, String prefix, String prePrefix, String prePrePrefix)

public Schema
public HsqlNameManager.HsqlName
public SchemaObject
findSchemaObject(Session session, String name, String prefix, String prePrefix, int type)

public SchemaObject
findSchemaObject(String name, String schemaName, int type)

public SchemaObject
public NumberSequence
findSequence(Session session, String name, String schemaName)

public Table
findSessionTable(Session session, String name)

Returns the specified session context table.

public ReferenceObject
findSynonym(String name, String schemaName, int type)

public Table
findTable(Session session, String name, String prefix, String prePrefix)

public Table
findUserTable(String name, String schemaName)

Returns the specified user-defined table or view visible within the context of the specified schema.

pack-priv Table
findUserTableForIndex(Session session, String name, String schemaName)

Returns the table that has an index with the given name and schema.

public Schema[]
public HsqlArrayList<Table>
getAllTables(boolean withLobTables)

Returns an HsqlArrayList containing references to all non-system tables and views of the given type.

public void
public void
public HsqlNameManager.HsqlName[]
public HsqlNameManager.HsqlName[]
public HsqlNameManager.HsqlName[]
public SchemaObject
getCharacterSet(Session session, String name, String schemaName)

public Collation
getCollation(Session session, String name, String schemaName)

public HsqlNameManager.HsqlName
public int
public Type
getDistinctType(String name, String schemaName, boolean raise)

public Type
getDomain(String name, String schemaName, boolean raise)

public long[][]
public List<String>
public OrderedHashSet<HsqlNameManager.HsqlName>
public OrderedHashSet<HsqlNameManager.HsqlName>
public MultiValueHashMap<HsqlNameManager.HsqlName, HsqlNameManager.HsqlName>
public long
public HsqlNameManager.HsqlName
getSchemaHsqlName(String name)

If schemaName is null, return the default schema name, else return the HsqlName object for the schema.

public String
getSchemaName(String name)

Same as above, but return string

public String[]
public SchemaObject
getSchemaObject(String name, String schemaName, int type)

public HsqlNameManager.HsqlName
getSchemaObjectName(HsqlNameManager.HsqlName schemaName, String name, int type, boolean raise)

public HsqlArrayList<Schema>
public NumberSequence
getSequence(String name, String schemaName, boolean raise)

public List<String>
public HsqlNameManager.HsqlName
public int

Returns:

the index of the specified table or view, or -1 if not found
getTableIndex
(Table
the Table object
table
)

Returns index of a table or view in the HashMappedList that contains the table objects for this Database.

public List<String>
getTablePropsSQLArray(boolean withHeader)

public OrderedHashMap<String, Table>
getTables(String schema)

public List<String>
public Type
getUserDefinedType(String name, String schemaName, boolean raise)

public HsqlNameManager.HsqlName
public Iterator<Schema>
public Table
public Table
getUserTable(String name, String schema)

Returns the specified user-defined table or view visible within the context of the specified Session.

public boolean
private boolean
public void
public void
recompileDependentObjects(Table table)

After addition or removal of columns and indexes all views that reference the table should be recompiled.

public void
pack-priv void
pack-priv void
removeExportedKeys(Table
The table to which other tables may be holding keys. This is a table that is in the process of being dropped.
toDrop
)

Removes any foreign key Constraint objects (exported keys) held by any tables referenced by the specified table.

private void
private void
private void
public void
public void
public void
private void
removeTable(Session session, Table table)

private void
public void
public void
public void
public boolean
public void
public void
public void
setIndexRoots(long[][] roots)

called after the completion of defrag

public void
public void
setTable(int index, Table table)

public void
setTempIndexRoots(long[][] roots)

public Grantee
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

catalogNameArrayback to summary
pack-priv HsqlNameManager.HsqlName[] catalogNameArray
databaseback to summary
pack-priv Database database
defaultSchemaHsqlNameback to summary
pack-priv HsqlNameManager.HsqlName defaultSchemaHsqlName
defaultTableTypeback to summary
pack-priv int defaultTableType
dualTableback to summary
pack-priv Table dualTable
lockback to summary
pack-priv ReadWriteLock lock
readLockback to summary
pack-priv Lock readLock
referenceMapback to summary
pack-priv MultiValueHashMap<HsqlNameManager.HsqlName, HsqlNameManager.HsqlName> referenceMap
schemaChangeTimestampback to summary
pack-priv long schemaChangeTimestamp
schemaMapback to summary
pack-priv OrderedHashMap<String, Schema> schemaMap
tempIndexRootsback to summary
pack-priv long[][] tempIndexRoots
userSchemaFilterback to summary
pack-priv SchemaManager.UserSchemaFilter userSchemaFilter
writeLockback to summary
pack-priv Lock writeLock

Constructor Detail

SchemaManagerback to summary
public SchemaManager(Database database)

Method Detail

addReferencesFromback to summary
private void addReferencesFrom(SchemaObject object)
addSchemaObjectback to summary
public void addSchemaObject(SchemaObject object)
checkColumnIsReferencedback to summary
public void checkColumnIsReferenced(HsqlNameManager.HsqlName tableName, HsqlNameManager.HsqlName name)
checkObjectIsReferencedback to summary
public void checkObjectIsReferenced(HsqlNameManager.HsqlName name)
checkSchemaNameCanChangeback to summary
public void checkSchemaNameCanChange(HsqlNameManager.HsqlName name)
checkSchemaObjectNotExistsback to summary
public void checkSchemaObjectNotExists(HsqlNameManager.HsqlName name)
createPublicSchemaback to summary
public void createPublicSchema()
createSchemaback to summary
public void createSchema(HsqlNameManager.HsqlName name, Grantee owner)

Creates a schema belonging to the given grantee.

createSystemTablesback to summary
public void createSystemTables()
databaseCheckConstraintIteratorback to summary
public Iterator<Constraint> databaseCheckConstraintIterator()
databaseObjectIteratorback to summary
public Iterator<SchemaObject> databaseObjectIterator(String schemaName, int type)
databaseObjectIteratorback to summary
public Iterator<SchemaObject> databaseObjectIterator(int type)
databaseTableIteratorback to summary
public Iterator<Table> databaseTableIterator()
dropConstraintback to summary
pack-priv void dropConstraint(Session session, HsqlNameManager.HsqlName name, boolean cascade)

Drops the constraint with the specified name.

dropIndexback to summary
pack-priv void dropIndex(Session session, HsqlNameManager.HsqlName name)

Drops the index with the specified name.

dropSchemaback to summary
public void dropSchema(Session session, String name, boolean cascade)
dropSchemasback to summary
public void dropSchemas(Session session, Grantee grantee, boolean cascade)

drop all schemas with the given authorisation

dropTableback to summary
private void dropTable(Session session, Table table, boolean cascade)
dropTableOrViewback to summary
public void dropTableOrView(Session session, Table table, boolean cascade)

Drops the specified user-defined view or table from this Database object.

The process of dropping a table or view includes:

  1. checking that the specified Session's currently connected User has the right to perform this operation and refusing to proceed if not by throwing.
  2. checking for referential constraints that conflict with this operation and refusing to proceed if they exist by throwing.
  3. removing the specified Table from this Database object.
  4. removing any exported foreign keys Constraint objects held by any tables referenced by the table to be dropped. This is especially important so that the dropped Table ceases to be referenced, eventually allowing its full garbage collection.

Parameters
session:Session

the connected context in which to perform this operation

table:Table

if true and if the Table to drop does not exist, fail silently, else throw

cascade:boolean

true if the name argument refers to a View

dropViewback to summary
private void dropView(Table table, boolean cascade)
findAnySchemaObjectForSynonymback to summary
public SchemaObject findAnySchemaObjectForSynonym(String name, String schemaName)
findDomainOrUDTback to summary
public Type findDomainOrUDT(Session session, String name, String prefix, String prePrefix, String prePrePrefix)
findSchemaback to summary
public Schema findSchema(String name)
findSchemaHsqlNameback to summary
public HsqlNameManager.HsqlName findSchemaHsqlName(String name)
findSchemaObjectback to summary
public SchemaObject findSchemaObject(Session session, String name, String prefix, String prePrefix, int type)
findSchemaObjectback to summary
public SchemaObject findSchemaObject(String name, String schemaName, int type)
findSchemaObjectback to summary
public SchemaObject findSchemaObject(HsqlNameManager.HsqlName name)
findSequenceback to summary
public NumberSequence findSequence(Session session, String name, String schemaName)
findSessionTableback to summary
public Table findSessionTable(Session session, String name)

Returns the specified session context table. Returns null if the table does not exist in the context.

findSynonymback to summary
public ReferenceObject findSynonym(String name, String schemaName, int type)
findTableback to summary
public Table findTable(Session session, String name, String prefix, String prePrefix)
findUserTableback to summary
public Table findUserTable(String name, String schemaName)

Returns the specified user-defined table or view visible within the context of the specified schema. It excludes system tables. Returns null if the table does not exist in the context.

findUserTableForIndexback to summary
pack-priv Table findUserTableForIndex(Session session, String name, String schemaName)

Returns the table that has an index with the given name and schema.

getAllSchemasback to summary
public Schema[] getAllSchemas()
getAllTablesback to summary
public HsqlArrayList<Table> getAllTables(boolean withLobTables)

Returns an HsqlArrayList containing references to all non-system tables and views of the given type.

getCascadingReferencesToback to summary
public void getCascadingReferencesTo(HsqlNameManager.HsqlName object, OrderedHashSet<HsqlNameManager.HsqlName> set)
getCascadingReferencesToSchemaback to summary
public void getCascadingReferencesToSchema(HsqlNameManager.HsqlName schema, OrderedHashSet<HsqlNameManager.HsqlName> set)
getCatalogAndBaseTableNamesback to summary
public HsqlNameManager.HsqlName[] getCatalogAndBaseTableNames()
getCatalogAndBaseTableNamesback to summary
public HsqlNameManager.HsqlName[] getCatalogAndBaseTableNames(HsqlNameManager.HsqlName name)
getCatalogNameArrayback to summary
public HsqlNameManager.HsqlName[] getCatalogNameArray()
getCharacterSetback to summary
public SchemaObject getCharacterSet(Session session, String name, String schemaName)
getCollationback to summary
public Collation getCollation(Session session, String name, String schemaName)
getDefaultSchemaHsqlNameback to summary
public HsqlNameManager.HsqlName getDefaultSchemaHsqlName()
getDefaultTableTypeback to summary
public int getDefaultTableType()
getDistinctTypeback to summary
public Type getDistinctType(String name, String schemaName, boolean raise)
getDomainback to summary
public Type getDomain(String name, String schemaName, boolean raise)
getIndexRootsback to summary
public long[][] getIndexRoots()
getIndexRootsSQLArrayback to summary
public List<String> getIndexRootsSQLArray()
getReferencesToback to summary
public OrderedHashSet<HsqlNameManager.HsqlName> getReferencesTo(HsqlNameManager.HsqlName object)
getReferencesToback to summary
public OrderedHashSet<HsqlNameManager.HsqlName> getReferencesTo(HsqlNameManager.HsqlName table, HsqlNameManager.HsqlName column)
getReferencesToSchemaback to summary
public MultiValueHashMap<HsqlNameManager.HsqlName, HsqlNameManager.HsqlName> getReferencesToSchema(String schemaName)
getSchemaChangeTimestampback to summary
public long getSchemaChangeTimestamp()
getSchemaHsqlNameback to summary
public HsqlNameManager.HsqlName getSchemaHsqlName(String name)

If schemaName is null, return the default schema name, else return the HsqlName object for the schema. If schemaName does not exist, throw.

getSchemaNameback to summary
public String getSchemaName(String name)

Same as above, but return string

getSchemaNamesArrayback to summary
public String[] getSchemaNamesArray()
getSchemaObjectback to summary
public SchemaObject getSchemaObject(String name, String schemaName, int type)
getSchemaObjectNameback to summary
public HsqlNameManager.HsqlName getSchemaObjectName(HsqlNameManager.HsqlName schemaName, String name, int type, boolean raise)
getSchemasback to summary
public HsqlArrayList<Schema> getSchemas(Grantee grantee)
getSequenceback to summary
public NumberSequence getSequence(String name, String schemaName, boolean raise)
getSQLArrayback to summary
public List<String> getSQLArray()
getSQLJSchemaHsqlNameback to summary
public HsqlNameManager.HsqlName getSQLJSchemaHsqlName()
getTableIndexback to summary
public int getTableIndex(Table table)

Returns index of a table or view in the HashMappedList that contains the table objects for this Database.

Parameters
table:Table

the Table object

Returns:int

the index of the specified table or view, or -1 if not found

getTablePropsSQLArrayback to summary
public List<String> getTablePropsSQLArray(boolean withHeader)
getTablesback to summary
public OrderedHashMap<String, Table> getTables(String schema)
getTableSpaceSQLArrayback to summary
public List<String> getTableSpaceSQLArray()
getUserDefinedTypeback to summary
public Type getUserDefinedType(String name, String schemaName, boolean raise)
getUserSchemaHsqlNameback to summary
public HsqlNameManager.HsqlName getUserSchemaHsqlName(String name)
getUserSchemaIteratorback to summary
public Iterator<Schema> getUserSchemaIterator()
getUserTableback to summary
public Table getUserTable(HsqlNameManager.HsqlName name)
getUserTableback to summary
public Table getUserTable(String name, String schema)

Returns the specified user-defined table or view visible within the context of the specified Session. Throws if the table does not exist in the context.

hasSchemasback to summary
public boolean hasSchemas(Grantee grantee)
isReferencedback to summary
private boolean isReferenced(HsqlNameManager.HsqlName object)
recompileDependentObjectsback to summary
public void recompileDependentObjects(OrderedHashSet<Table> tableSet)
recompileDependentObjectsback to summary
public void recompileDependentObjects(Table table)

After addition or removal of columns and indexes all views that reference the table should be recompiled.

releaseback to summary
public void release()
removeDependentObjectsback to summary
pack-priv void removeDependentObjects(HsqlNameManager.HsqlName name)
removeExportedKeysback to summary
pack-priv void removeExportedKeys(Table toDrop)

Removes any foreign key Constraint objects (exported keys) held by any tables referenced by the specified table.

This method is called as the last step of a successful call to dropTable() in order to ensure that the dropped Table ceases to be referenced when enforcing referential integrity.

Parameters
toDrop:Table

The table to which other tables may be holding keys. This is a table that is in the process of being dropped.

removeReferencesFromback to summary
private void removeReferencesFrom(SchemaObject object)
removeReferencesToback to summary
private void removeReferencesTo(OrderedHashSet<HsqlNameManager.HsqlName> set)
removeReferencesToback to summary
private void removeReferencesTo(HsqlNameManager.HsqlName referenced)
removeSchemaObjectback to summary
public void removeSchemaObject(HsqlNameManager.HsqlName name, boolean cascade)
removeSchemaObjectback to summary
public void removeSchemaObject(HsqlNameManager.HsqlName name)
removeSchemaObjectsback to summary
public void removeSchemaObjects(OrderedHashSet<HsqlNameManager.HsqlName> set)
removeTableback to summary
private void removeTable(Session session, Table table)
removeTableDependentReferencesback to summary
private void removeTableDependentReferences(Table table)
renameSchemaback to summary
public void renameSchema(HsqlNameManager.HsqlName name, HsqlNameManager.HsqlName newName)
renameSchemaObjectback to summary
public void renameSchemaObject(HsqlNameManager.HsqlName name, HsqlNameManager.HsqlName newName)
replaceReferencesback to summary
public void replaceReferences(SchemaObject oldObject, SchemaObject newObject)
schemaExistsback to summary
public boolean schemaExists(String name)
setDefaultSchemaHsqlNameback to summary
public void setDefaultSchemaHsqlName(HsqlNameManager.HsqlName name)
setDefaultTableTypeback to summary
public void setDefaultTableType(int type)
setIndexRootsback to summary
public void setIndexRoots(long[][] roots)

called after the completion of defrag

setSchemaChangeTimestampback to summary
public void setSchemaChangeTimestamp()
setTableback to summary
public void setTable(int index, Table table)
setTempIndexRootsback to summary
public void setTempIndexRoots(long[][] roots)
toSchemaOwnerback to summary
public Grantee toSchemaOwner(String name)
org.hsqldb back to summary

pack-priv Class SchemaManager.UserSchemaFilter

extends Object
implements FilteredIterator.Filter<Schema>
Class Inheritance
All Implemented Interfaces
org.hsqldb.lib.FilteredIterator.Filter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

UserSchemaFilterback to summary
pack-priv UserSchemaFilter()

Method Detail

testback to summary
public boolean test(Schema schema)

Implements org.hsqldb.lib.FilteredIterator.Filter.test.