use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method DATA_TYPE_PRIVILEGES.
Table DATA_TYPE_PRIVILEGES() {
Table t = sysTables[DATA_TYPE_PRIVILEGES];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[DATA_TYPE_PRIVILEGES]);
addColumn(t, "OBJECT_CATALOG", SQL_IDENTIFIER);
addColumn(t, "OBJECT_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "OBJECT_NAME", SQL_IDENTIFIER);
addColumn(t, "OBJECT_TYPE", SQL_IDENTIFIER);
addColumn(t, "DTD_IDENTIFIER", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[DATA_TYPE_PRIVILEGES].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4 }, false);
return t;
}
PersistentStore store = database.persistentStoreCollection.getStore(t);
//
Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
String sql = (String) statementMap.get("/*data_type_privileges*/");
Result rs = sys.executeDirectStatement(sql);
t.insertSys(store, rs);
sys.close();
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method ROLE_TABLE_GRANTS.
Table ROLE_TABLE_GRANTS() {
Table t = sysTables[ROLE_TABLE_GRANTS];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROLE_TABLE_GRANTS]);
// not null
addColumn(t, "GRANTOR", SQL_IDENTIFIER);
// not null
addColumn(t, "GRANTEE", SQL_IDENTIFIER);
addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
// not null
addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
// not null
addColumn(t, "IS_GRANTABLE", YES_OR_NO);
addColumn(t, "WITH_HIERARCHY", YES_OR_NO);
// order: TABLE_SCHEM, TABLE_NAME, and PRIVILEGE,
// added for unique: GRANTEE, GRANTOR,
// false PK, as TABLE_SCHEM and/or TABLE_CAT may be null
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROLE_TABLE_GRANTS].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 3, 4, 5, 0, 1 }, 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, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, PRIVILEGE_TYPE, IS_GRANTABLE, 'NO' " + "FROM INFORMATION_SCHEMA.TABLE_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 ROUTINE_ROUTINE_USAGE.
/**
* needs to provide list of specific referenced routines
*/
Table ROUTINE_ROUTINE_USAGE() {
Table t = sysTables[ROUTINE_ROUTINE_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROUTINE_ROUTINE_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);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_ROUTINE_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 routine_catalog = 3;
final int routine_schema = 4;
final int routine_name = 5;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
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.FUNCTION && refName.type != SchemaObject.PROCEDURE) {
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] = refName.schema.name;
row[routine_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method ROUTINE_TABLE_USAGE.
Table ROUTINE_TABLE_USAGE() {
Table t = sysTables[ROUTINE_TABLE_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[ROUTINE_TABLE_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);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_TABLE_USAGE].name, false, SchemaObject.INDEX);
t.createPrimaryKey(name, new int[] { 3, 4, 5, 0, 1, 2, 6, 7, 8 }, false);
return 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;
//
PersistentStore store = database.persistentStoreCollection.getStore(t);
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.TABLE && refName.type != SchemaObject.VIEW) {
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.schema.name;
row[table_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
}
return t;
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class DatabaseInformationFull method TRIGGER_ROUTINE_USAGE.
Table TRIGGER_ROUTINE_USAGE() {
Table t = sysTables[TRIGGER_ROUTINE_USAGE];
if (t == null) {
t = createBlankTable(sysTableHsqlNames[TRIGGER_ROUTINE_USAGE]);
addColumn(t, "TRIGGER_CATALOG", SQL_IDENTIFIER);
addColumn(t, "TRIGGER_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "TRIGGER_NAME", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
// not null
addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[TRIGGER_ROUTINE_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 specific_catalog = 3;
final int specific_schema = 4;
final int specific_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.FUNCTION && refName.type != SchemaObject.PROCEDURE) {
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[specific_catalog] = database.getCatalogName().name;
row[specific_schema] = refName.schema.name;
row[specific_name] = refName.name;
try {
t.insertSys(store, row);
} catch (HsqlException e) {
}
}
}
return t;
}
Aggregations