use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method TRIGGER_TABLE_USAGE.
Table TRIGGER_TABLE_USAGE() {
Table t = sysTables[TRIGGER_TABLE_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[TRIGGER_TABLE_USAGE]);
addColumn(t, "TRIGGER_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TRIGGER_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TRIGGER_NAME", SQL_IDENTIFIER);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TRIGGER_TABLE_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// column number mappings
final int trigger_catalog = 0;
final int trigger_schema = 1;
final int trigger_name = 2;
final int table_catalog = 3;
final int table_schema = 4;
final int table_name = 5;
Iterator it;
Object[] row;
it = database.schemaManager.databaseObjectIterator(SchemaObject.TRIGGER);
while (it.hasNext()) {
TriggerDef trigger = (TriggerDef) it.next();
if (!session.getGrantee().isAccessible(trigger)) {
continue;
}
OrderedHashSet set = trigger.getReferences();
for (int i = 0; i < set.size(); i++) {
HsqlName refName = (HsqlName) set.get(i);
if (refName.type != SchemaObject.TABLE && refName.type != SchemaObject.VIEW) {
continue;
}
if (!session.getGrantee().isAccessible(refName)) {
continue;
}
row = t.getEmptyRowData();
row[trigger_catalog] = database.getCatalogName().name;
row[trigger_schema] = trigger.getSchemaName().name;
row[trigger_name] = trigger.getName().name;
row[table_catalog] = database.getCatalogName().name;
row[table_schema] = refName.schema.name;
row[table_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
// Initialization
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method TRIGGERS.
Table TRIGGERS() {
Table t = sysTables[TRIGGERS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[TRIGGERS]);
addColumn(t, "TRIGGER_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TRIGGER_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "TRIGGER_NAME", SQL_IDENTIFIER);
addColumn(t, "EVENT_MANIPULATION", SQL_IDENTIFIER);
addColumn(t, "EVENT_OBJECT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "EVENT_OBJECT_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "EVENT_OBJECT_TABLE", SQL_IDENTIFIER);
addColumn(t, "ACTION_ORDER", CHARACTER_DATA);
addColumn(t, "ACTION_CONDITION", CHARACTER_DATA);
addColumn(t, "ACTION_STATEMENT", CHARACTER_DATA);
addColumn(t, "ACTION_ORIENTATION", CHARACTER_DATA);
addColumn(t, "ACTION_TIMING", CHARACTER_DATA);
addColumn(t, "ACTION_REFERENCE_OLD_TABLE", SQL_IDENTIFIER);
addColumn(t, "ACTION_REFERENCE_NEW_TABLE", SQL_IDENTIFIER);
addColumn(t, "ACTION_REFERENCE_OLD_ROW", SQL_IDENTIFIER);
addColumn(t, "ACTION_REFERENCE_NEW_ROW", SQL_IDENTIFIER);
addColumn(t, "CREATED", TIME_STAMP);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TRIGGERS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// column number mappings
final int trigger_catalog = 0;
final int trigger_schema = 1;
final int trigger_name = 2;
final int event_manipulation = 3;
final int event_object_catalog = 4;
final int event_object_schema = 5;
final int event_object_table = 6;
final int action_order = 7;
final int action_condition = 8;
final int action_statement = 9;
final int action_orientation = 10;
final int action_timing = 11;
final int action_reference_old_table = 12;
final int action_reference_new_table = 13;
final int action_reference_old_row = 14;
final int action_reference_new_row = 15;
final int created = 16;
Iterator it;
Object[] row;
it = database.schemaManager.databaseObjectIterator(SchemaObject.TRIGGER);
while (it.hasNext()) {
TriggerDef trigger = (TriggerDef) it.next();
if (!session.getGrantee().isAccessible(trigger)) {
continue;
}
row = t.getEmptyRowData();
row[trigger_catalog] = database.getCatalogName().name;
row[trigger_schema] = trigger.getSchemaName().name;
row[trigger_name] = trigger.getName().name;
row[event_manipulation] = trigger.getEventTypeString();
row[event_object_catalog] = database.getCatalogName().name;
row[event_object_schema] = trigger.getTable().getSchemaName().name;
row[event_object_table] = trigger.getTable().getName().name;
row[action_order] = trigger.getTable().getTriggerIndex(trigger.getName().name);
row[action_condition] = trigger.getConditionSQL();
row[action_statement] = trigger.getProcedureSQL();
row[action_orientation] = trigger.getActionOrientationString();
row[action_timing] = trigger.getActionTimingString();
row[action_reference_old_table] = trigger.getOldTransitionTableName();
row[action_reference_new_table] = trigger.getNewTransitionTableName();
row[action_reference_old_row] = trigger.getOldTransitionRowName();
row[action_reference_new_row] = trigger.getNewTransitionRowName();
row[created] = null;
t.insertSys(store, row);
}
// Initialization
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method DOMAINS.
/**
* The DOMAINS view has one row for each domain. <p>
*
*
* <pre class="SqlCodeExample">
*
* </pre>
*
* @return Table
*/
Table DOMAINS() {
Table t = sysTables[DOMAINS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[DOMAINS]);
addColumn(t, "DOMAIN_CATALOG", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "DOMAIN_NAME", SQL_IDENTIFIER);
addColumn(t, "DATA_TYPE", SQL_IDENTIFIER);
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, "DOMAIN_DEFAULT", CHARACTER_DATA);
addColumn(t, "MAXIMUM_CARDINALITY", SQL_IDENTIFIER);
addColumn(t, "DTD_IDENTIFIER", SQL_IDENTIFIER);
addColumn(t, "DECLARED_DATA_TYPE", CHARACTER_DATA);
addColumn(t, "DECLARED_NUMERIC_PRECISION", CARDINAL_NUMBER);
addColumn(t, "DECLARED_NUMERIC_SCLAE", CARDINAL_NUMBER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[DOMAINS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 4, 5, 6 }, false);
return t;
}
final int domain_catalog = 0;
final int domain_schema = 1;
final int domain_name = 2;
final int data_type = 3;
final int character_maximum_length = 4;
final int character_octet_length = 5;
final int character_set_catalog = 6;
final int character_set_schema = 7;
final int character_set_name = 8;
final int collation_catalog = 9;
final int collation_schema = 10;
final int collation_name = 11;
final int numeric_precision = 12;
final int numeric_precision_radix = 13;
final int numeric_scale = 14;
final int datetime_precision = 15;
final int interval_type = 16;
final int interval_precision = 17;
final int domain_default = 18;
final int maximum_cardinality = 19;
final int dtd_identifier = 20;
final int declared_data_type = 21;
final int declared_numeric_precision = 22;
final int declared_numeric_scale = 23;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
//
Iterator it = database.schemaManager.databaseObjectIterator(SchemaObject.DOMAIN);
while (it.hasNext()) {
Type domain = (Type) it.next();
if (!domain.isDomainType()) {
continue;
}
if (!session.getGrantee().isAccessible(domain)) {
continue;
}
Object[] data = t.getEmptyRowData();
data[domain_catalog] = database.getCatalogName().name;
data[domain_schema] = domain.getSchemaName().name;
data[domain_name] = domain.getName().name;
data[data_type] = domain.getFullNameString();
if (domain.isCharacterType()) {
data[character_maximum_length] = ValuePool.getLong(domain.precision);
data[character_octet_length] = ValuePool.getLong(domain.precision * 2);
data[character_set_catalog] = database.getCatalogName().name;
data[character_set_schema] = ((CharacterType) domain).getCharacterSet().getSchemaName().name;
data[character_set_name] = ((CharacterType) domain).getCharacterSet().getName().name;
data[collation_catalog] = database.getCatalogName().name;
data[collation_schema] = ((CharacterType) domain).getCollation().getSchemaName().name;
data[collation_name] = ((CharacterType) domain).getCollation().getName().name;
} else if (domain.isNumberType()) {
data[numeric_precision] = ValuePool.getLong(((NumberType) domain).getPrecision());
data[declared_numeric_precision] = data[numeric_precision];
if (domain.typeCode != Types.SQL_DOUBLE) {
data[numeric_scale] = ValuePool.getLong(domain.scale);
data[declared_numeric_scale] = data[numeric_scale];
}
data[numeric_precision_radix] = ValuePool.getLong(((NumberType) domain).getPrecisionRadix());
} else if (domain.isBooleanType()) {
} else if (domain.isDateTimeType()) {
data[datetime_precision] = ValuePool.getLong(domain.scale);
} else if (domain.isIntervalType()) {
data[interval_precision] = ValuePool.getLong(domain.precision);
data[interval_type] = domain.getFullNameString();
data[datetime_precision] = ValuePool.getLong(domain.scale);
} else if (domain.isBinaryType()) {
data[character_maximum_length] = ValuePool.getLong(domain.precision);
data[character_octet_length] = ValuePool.getLong(domain.precision);
} else if (domain.isBitType()) {
data[character_maximum_length] = ValuePool.getLong(domain.precision);
data[character_octet_length] = ValuePool.getLong(domain.precision);
}
Expression defaultExpression = domain.userTypeModifier.getDefaultClause();
if (defaultExpression != null) {
data[domain_default] = defaultExpression.getSQL();
}
t.insertSys(store, data);
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method ROLE_USAGE_GRANTS.
Table ROLE_USAGE_GRANTS() {
Table t = sysTables[ROLE_USAGE_GRANTS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROLE_USAGE_GRANTS]);
// not null
addColumn(t, "GRANTOR", SQL_IDENTIFIER);
// not null
addColumn(t, "GRANTEE", SQL_IDENTIFIER);
addColumn(t, "OBJECT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "OBJECT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "OBJECT_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "OBJECT_TYPE", CHARACTER_DATA);
addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
// not null
addColumn(t, "IS_GRANTABLE", YES_OR_NO);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROLE_USAGE_GRANTS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
Result rs = sys.executeDirectStatement("SELECT GRANTOR, GRANTEE, OBJECT_CATALOG, OBJECT_SCHEMA, OBJECT_NAME, " + "OBJECT_TYPE, PRIVILEGE_TYPE, IS_GRANTABLE " + "FROM INFORMATION_SCHEMA.USAGE_PRIVILEGES " + "JOIN INFORMATION_SCHEMA.APPLICABLE_ROLES ON GRANTEE = ROLE_NAME;");
t.insertSys(store, rs);
sys.close();
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method VIEW_COLUMN_USAGE.
/**
* The VIEW_COLUMN_USAGE table has one row for each column of a
* table that is explicitly or implicitly referenced in the
* <query expression> of the view being described. <p>
*
* <b>Definition:</b> <p>
*
* <pre class="SqlCodeExample">
* CREATE TABLE SYSTEM_VIEW_COLUMN_USAGE (
* VIEW_CATALOG VARCHAR NULL,
* VIEW_SCHEMA VARCHAR NULL,
* VIEW_NAME VARCHAR NOT NULL,
* TABLE_CATALOG VARCHAR NULL,
* TABLE_SCHEMA VARCHAR NULL,
* TABLE_NAME VARCHAR NOT NULL,
* COLUMN_NAME VARCHAR NOT NULL,
* UNIQUE ( VIEW_CATALOG, VIEW_SCHEMA, VIEW_NAME,
* TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME,
* COLUMN_NAME )
* )
* </pre>
*
* <b>Description:</b> <p>
*
* <ol>
* <li> The values of VIEW_CATALOG, VIEW_SCHEMA, and VIEW_NAME are the
* catalog name, unqualified schema name, and qualified identifier,
* respectively, of the view being described. <p>
*
* <li> The values of TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and
* COLUMN_NAME are the catalog name, unqualified schema name,
* qualified identifier, and column name, respectively, of a column
* of a table that is explicitly or implicitly referenced in the
* <query expression> of the view being described.
* </ol>
*
* @return Table
*/
Table VIEW_COLUMN_USAGE() {
Table t = sysTables[VIEW_COLUMN_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[VIEW_COLUMN_USAGE]);
addColumn(t, "VIEW_CATALOG", SQL_IDENTIFIER);
addColumn(t, "VIEW_SCHEMA", SQL_IDENTIFIER);
addColumn(t, "VIEW_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[VIEW_COLUMN_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
// Calculated column values
String viewCatalog;
String viewSchema;
String viewName;
// Intermediate holders
Iterator tables;
View view;
Table table;
Object[] row;
Iterator iterator;
// Column number mappings
final int view_catalog = 0;
final int view_schema = 1;
final int view_name = 2;
final int table_catalog = 3;
final int table_schema = 4;
final int table_name = 5;
final int column_name = 6;
// Initialization
tables = database.schemaManager.databaseObjectIterator(SchemaObject.TABLE);
// Do it.
while (tables.hasNext()) {
table = (Table) tables.next();
if (table.isView() && session.getGrantee().isFullyAccessibleByRole(table)) {
// $FALL-THROUGH$
} else {
continue;
}
viewCatalog = database.getCatalogName().name;
viewSchema = table.getSchemaName().name;
viewName = table.getName().name;
view = (View) table;
OrderedHashSet references = view.getReferences();
iterator = references.iterator();
while (iterator.hasNext()) {
HsqlName refName = (HsqlName) iterator.next();
if (refName.type == SchemaObject.COLUMN) {
row = t.getEmptyRowData();
row[view_catalog] = viewCatalog;
row[view_schema] = viewSchema;
row[view_name] = viewName;
row[table_catalog] = viewCatalog;
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;
}
Aggregations