use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class DatabaseInformationFull method ROUTINE_COLUMN_USAGE.
Table ROUTINE_COLUMN_USAGE() {
Table t = sysTables[ROUTINE_COLUMN_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROUTINE_COLUMN_USAGE]);
addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "ROUTINE_NAME", SQL_IDENTIFIER);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_COLUMN_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 3, 4, 5, 0, 1, 2, 6, 7, 8, 9 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// column number mappings
final int specific_catalog = 0;
final int specific_schema = 1;
final int specific_name = 2;
final int routine_catalog = 3;
final int routine_schema = 4;
final int routine_name = 5;
final int table_catalog = 6;
final int table_schema = 7;
final int table_name = 8;
final int column_name = 9;
//
Iterator it;
Object[] row;
it = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
while (it.hasNext()) {
RoutineSchema routine = (RoutineSchema) it.next();
if (!session.getGrantee().isAccessible(routine)) {
continue;
}
Routine[] specifics = routine.getSpecificRoutines();
for (int m = 0; m < specifics.length; m++) {
OrderedHashSet set = specifics[m].getReferences();
for (int i = 0; i < set.size(); i++) {
HsqlName refName = (HsqlName) set.get(i);
if (refName.type != SchemaObject.COLUMN) {
continue;
}
if (!session.getGrantee().isAccessible(refName)) {
continue;
}
row = t.getEmptyRowData();
//
row[specific_catalog] = database.getCatalogName().name;
row[specific_schema] = specifics[m].getSchemaName().name;
row[specific_name] = specifics[m].getName().name;
row[routine_catalog] = database.getCatalogName().name;
row[routine_schema] = routine.getSchemaName().name;
row[routine_name] = routine.getName().name;
row[table_catalog] = database.getCatalogName().name;
row[table_schema] = refName.parent.schema.name;
row[table_name] = refName.parent.name;
row[column_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
}
return t;
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class DatabaseInformationFull method USER_DEFINED_TYPES.
Table USER_DEFINED_TYPES() {
Table t = sysTables[USER_DEFINED_TYPES];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[USER_DEFINED_TYPES]);
addColumn(t, "USER_DEFINED_TYPE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_NAME", SQL_IDENTIFIER);
addColumn(t, "USER_DEFINED_TYPE_CATEGORY", SQL_IDENTIFIER);
addColumn(t, "IS_INSTANTIABLE", YES_OR_NO);
addColumn(t, "IS_FINAL", YES_OR_NO);
addColumn(t, "ORDERING_FORM", SQL_IDENTIFIER);
addColumn(t, "ORDERING_CATEGORY", SQL_IDENTIFIER);
addColumn(t, "ORDERING_ROUTINE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "ORDERING_ROUTINE_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "ORDERING_ROUTINE_NAME", SQL_IDENTIFIER);
addColumn(t, "REFERENCE_TYPE", SQL_IDENTIFIER);
addColumn(t, "DATA_TYPE", CHARACTER_DATA);
addColumn(t, "CHARACTER_MAXIMUM_LENGTH", CARDINAL_NUMBER);
addColumn(t, "CHARACTER_OCTET_LENGTH", CARDINAL_NUMBER);
addColumn(t, "CHARACTER_SET_CATALOG", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_SET_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "CHARACTER_SET_NAME", SQL_IDENTIFIER);
addColumn(t, "COLLATION_CATALOG", SQL_IDENTIFIER);
addColumn(t, "COLLATION_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "COLLATION_NAME", SQL_IDENTIFIER);
addColumn(t, "NUMERIC_PRECISION", CARDINAL_NUMBER);
addColumn(t, "NUMERIC_PRECISION_RADIX", CARDINAL_NUMBER);
addColumn(t, "NUMERIC_SCALE", CARDINAL_NUMBER);
addColumn(t, "DATETIME_PRECISION", CARDINAL_NUMBER);
addColumn(t, "INTERVAL_TYPE", CHARACTER_DATA);
addColumn(t, "INTERVAL_PRECISION", CARDINAL_NUMBER);
addColumn(t, "SOURCE_DTD_IDENTIFIER", CHARACTER_DATA);
addColumn(t, "REF_DTD_IDENTIFIER", CHARACTER_DATA);
addColumn(t, "DECLARED_DATA_TYPE", CHARACTER_DATA);
addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
addColumn(t, "DECLARED_NUMERIC_SCALE", CARDINAL_NUMBER);
addColumn(t, "EXTERNAL_NAME", CHARACTER_DATA);
addColumn(t, "EXTERNAL_LANGUAGE", CHARACTER_DATA);
addColumn(t, "JAVA_INTERFACE", CHARACTER_DATA);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[USER_DEFINED_TYPES].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 4, 5, 6 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
final int user_defined_type_catalog = 0;
final int user_defined_type_schema = 1;
final int user_defined_type_name = 2;
final int user_defined_type_category = 3;
final int is_instantiable = 4;
final int is_final = 5;
final int ordering_form = 6;
final int ordering_category = 7;
final int ordering_routine_catalog = 8;
final int ordering_routine_schema = 9;
final int ordering_routine_name = 10;
final int reference_type = 11;
final int data_type = 12;
final int character_maximum_length = 13;
final int character_octet_length = 14;
final int character_set_catalog = 15;
final int character_set_schema = 16;
final int character_set_name = 17;
final int collation_catalog = 18;
final int collation_schema = 19;
final int collation_name = 20;
final int numeric_precision = 21;
final int numeric_precision_radix = 22;
final int numeric_scale = 23;
final int datetime_precision = 24;
final int interval_type = 25;
final int interval_precision = 26;
final int source_dtd_identifier = 27;
final int ref_dtd_identifier = 28;
final int declared_data_type = 29;
final int declared_numeric_precision = 30;
final int declared_numeric_scale = 31;
Iterator it = database.schemaManager.databaseObjectIterator(SchemaObject.DOMAIN);
while (it.hasNext()) {
Type distinct = (Type) it.next();
if (!distinct.isDistinctType()) {
continue;
}
Object[] data = t.getEmptyRowData();
data[user_defined_type_catalog] = database.getCatalogName().name;
data[user_defined_type_schema] = distinct.getSchemaName().name;
data[user_defined_type_name] = distinct.getName().name;
data[data_type] = distinct.getFullNameString();
data[declared_data_type] = distinct.getFullNameString();
data[user_defined_type_category] = "DISTINCT";
data[is_instantiable] = "YES";
data[is_final] = "YES";
data[ordering_form] = "FULL";
data[source_dtd_identifier] = distinct.getFullNameString();
if (distinct.isCharacterType()) {
data[character_maximum_length] = ValuePool.getLong(distinct.precision);
data[character_octet_length] = ValuePool.getLong(distinct.precision * 2);
data[character_set_catalog] = database.getCatalogName().name;
data[character_set_schema] = ((CharacterType) distinct).getCharacterSet().getSchemaName().name;
data[character_set_name] = ((CharacterType) distinct).getCharacterSet().getName().name;
data[collation_catalog] = database.getCatalogName().name;
data[collation_schema] = ((CharacterType) distinct).getCollation().getSchemaName().name;
data[collation_name] = ((CharacterType) distinct).getCollation().getName().name;
} else if (distinct.isNumberType()) {
data[numeric_precision] = ValuePool.getLong(((NumberType) distinct).getPrecision());
data[declared_numeric_precision] = ValuePool.getLong(((NumberType) distinct).getPrecision());
if (distinct.typeCode != Types.SQL_DOUBLE) {
data[numeric_scale] = ValuePool.getLong(distinct.scale);
data[declared_numeric_scale] = ValuePool.getLong(distinct.scale);
}
data[numeric_precision_radix] = ValuePool.getLong(((NumberType) distinct).getPrecisionRadix());
} else if (distinct.isBooleanType()) {
} else if (distinct.isDateTimeType()) {
data[datetime_precision] = ValuePool.getLong(distinct.scale);
} else if (distinct.isIntervalType()) {
data[interval_precision] = ValuePool.getLong(distinct.precision);
data[interval_type] = distinct.getFullNameString();
data[datetime_precision] = ValuePool.getLong(distinct.scale);
} else if (distinct.isBinaryType()) {
data[character_maximum_length] = ValuePool.getLong(distinct.precision);
data[character_octet_length] = ValuePool.getLong(distinct.precision);
} else if (distinct.isBitType()) {
data[character_maximum_length] = ValuePool.getLong(distinct.precision);
data[character_octet_length] = ValuePool.getLong(distinct.precision);
}
}
return t;
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class DatabaseInformationFull method VIEWS.
/**
* The VIEWS view contains one row for each VIEW definition. <p>
*
* Each row is a description of the query expression that defines its view,
* with the following columns:
*
* <pre class="SqlCodeExample">
* TABLE_CATALOG VARCHAR name of view's defining catalog.
* TABLE_SCHEMA VARCHAR name of view's defining schema.
* TABLE_NAME VARCHAR the simple name of the view.
* VIEW_DEFINITION VARCHAR the character representation of the
* <query expression> contained in the
* corresponding <view descriptor>.
* CHECK_OPTION VARCHAR {"CASCADED" | "LOCAL" | "NONE"}
* IS_UPDATABLE VARCHAR {"YES" | "NO"}
* INSERTABLE_INTO VARCHAR {"YES" | "NO"}
* IS_TRIGGER_UPDATABLE VARCHAR {"YES" | "NO"}
* IS_TRIGGER_DELETEABLE VARCHAR {"YES" | "NO"}
* IS_TRIGGER_INSERTABLE_INTO VARCHAR {"YES" | "NO"}
* </pre> <p>
*
* @return a tabular description of the text source of all
* <code>View</code> objects accessible to
* the user.
*/
Table VIEWS() {
Table t = sysTables[VIEWS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[VIEWS]);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "VIEW_DEFINITION", CHARACTER_DATA);
// not null
addColumn(t, "CHECK_OPTION", CHARACTER_DATA);
// not null
addColumn(t, "IS_UPDATABLE", YES_OR_NO);
// not null
addColumn(t, "INSERTABLE_INTO", YES_OR_NO);
// not null
addColumn(t, "IS_TRIGGER_UPDATABLE", YES_OR_NO);
// not null
addColumn(t, "IS_TRIGGER_DELETABLE", YES_OR_NO);
// not null
addColumn(t, "IS_TRIGGER_INSERTABLE_INTO", YES_OR_NO);
// order TABLE_NAME
// added for unique: TABLE_SCHEMA, TABLE_CATALOG
// false PK, as TABLE_SCHEMA and/or TABLE_CATALOG may be null
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[VIEWS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 1, 2, 0 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
Iterator tables;
Table table;
Object[] row;
final int table_catalog = 0;
final int table_schema = 1;
final int table_name = 2;
final int view_definition = 3;
final int check_option = 4;
final int is_updatable = 5;
final int insertable_into = 6;
final int is_trigger_updatable = 7;
final int is_trigger_deletable = 8;
final int is_trigger_insertable_into = 9;
tables = allTables();
while (tables.hasNext()) {
table = (Table) tables.next();
if ((table.getSchemaName() != SqlInvariants.INFORMATION_SCHEMA_HSQLNAME && !table.isView()) || !isAccessibleTable(table)) {
continue;
}
row = t.getEmptyRowData();
row[table_catalog] = database.getCatalogName().name;
row[table_schema] = table.getSchemaName().name;
row[table_name] = table.getName().name;
String check = Tokens.T_NONE;
if (table instanceof View) {
if (session.getGrantee().isFullyAccessibleByRole(table)) {
row[view_definition] = ((View) table).getStatement();
}
switch(((View) table).getCheckOption()) {
case SchemaObject.ViewCheckModes.CHECK_NONE:
break;
case SchemaObject.ViewCheckModes.CHECK_LOCAL:
check = Tokens.T_LOCAL;
break;
case SchemaObject.ViewCheckModes.CHECK_CASCADE:
check = Tokens.T_CASCADED;
break;
}
}
row[check_option] = check;
row[is_updatable] = table.isUpdatable() ? Tokens.T_YES : Tokens.T_NO;
row[insertable_into] = table.isInsertable() ? Tokens.T_YES : Tokens.T_NO;
// only applies to INSTEAD OF triggers
row[is_trigger_updatable] = null;
row[is_trigger_deletable] = null;
row[is_trigger_insertable_into] = null;
t.insertSys(store, row);
}
return t;
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class DatabaseInformationFull method ROUTINE_JAR_USAGE.
Table ROUTINE_JAR_USAGE() {
Table t = sysTables[ROUTINE_JAR_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROUTINE_JAR_USAGE]);
addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
addColumn(t, "JAR_CATALOG", SQL_IDENTIFIER);
addColumn(t, "JAR_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "JAR_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_JAR_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
return t;
}
// column number mappings
final int specific_catalog = 0;
final int specific_schema = 1;
final int specific_name = 2;
final int jar_catalog = 3;
final int jar_schema = 4;
final int jar_name = 5;
//
Iterator it;
Object[] row;
PersistentStore store = database.persistentStoreCollection.getStore(t);
it = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
while (it.hasNext()) {
RoutineSchema routine = (RoutineSchema) it.next();
if (!session.getGrantee().isAccessible(routine)) {
continue;
}
Routine[] specifics = routine.getSpecificRoutines();
for (int m = 0; m < specifics.length; m++) {
if (specifics[m].getLanguage() != Routine.LANGUAGE_JAVA) {
continue;
}
row = t.getEmptyRowData();
row[specific_catalog] = database.getCatalogName().name;
row[specific_schema] = routine.getSchemaName().name;
row[specific_name] = routine.getName().name;
row[jar_catalog] = database.getCatalogName().name;
row[jar_schema] = database.schemaManager.getSQLJSchemaHsqlName();
row[jar_name] = "CLASSPATH";
t.insertSys(store, row);
}
}
return t;
}
use of org.hsqldb_voltpatches.lib.Iterator in project voltdb by VoltDB.
the class TransactionManager method unlockTablesTPL.
void unlockTablesTPL(Session session) {
Iterator it = tableWriteLocks.values().iterator();
while (it.hasNext()) {
Session s = (Session) it.next();
if (s == session) {
it.setValue(null);
}
}
it = tableReadLocks.values().iterator();
while (it.hasNext()) {
Session s = (Session) it.next();
if (s == session) {
it.remove();
}
}
}
Aggregations