use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class Schema method getSQLArray.
public String[] getSQLArray(OrderedHashSet resolved, OrderedHashSet unresolved) {
HsqlArrayList list = new HsqlArrayList();
StringBuffer sb = new StringBuffer(128);
sb.append(Tokens.T_CREATE).append(' ');
sb.append(Tokens.T_SCHEMA).append(' ');
sb.append(name.statementName).append(' ');
sb.append(Tokens.T_AUTHORIZATION).append(' ');
sb.append(owner.getStatementName());
list.add(sb.toString());
sb.setLength(0);
sb.append(Tokens.T_SET).append(' ');
sb.append(Tokens.T_SCHEMA).append(' ');
sb.append(name.statementName);
list.add(sb.toString());
//
String[] subList;
subList = charsetLookup.getSQL(resolved, unresolved);
list.addAll(subList);
subList = collationLookup.getSQL(resolved, unresolved);
list.addAll(subList);
subList = typeLookup.getSQL(resolved, unresolved);
list.addAll(subList);
subList = sequenceLookup.getSQL(resolved, unresolved);
list.addAll(subList);
subList = tableLookup.getSQL(resolved, unresolved);
list.addAll(subList);
subList = functionLookup.getSQL(resolved, unresolved);
list.addAll(subList);
subList = procedureLookup.getSQL(resolved, unresolved);
list.addAll(subList);
subList = assertionLookup.getSQL(resolved, unresolved);
list.addAll(subList);
//
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class SchemaManager method recompileDependentObjects.
/**
* After addition or removal of columns and indexes all views that
* reference the table should be recompiled.
*/
void recompileDependentObjects(Table table) {
OrderedHashSet set = getReferencingObjects(table.getName());
Session session = database.sessionManager.getSysSession();
for (int i = 0; i < set.size(); i++) {
HsqlName name = (HsqlName) set.get(i);
switch(name.type) {
case SchemaObject.VIEW:
case SchemaObject.CONSTRAINT:
case SchemaObject.ASSERTION:
SchemaObject object = getSchemaObject(name);
object.compile(session);
break;
}
}
HsqlArrayList list = getAllTables();
for (int i = 0; i < list.size(); i++) {
Table t = (Table) list.get(i);
t.updateConstraintPath();
}
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class SchemaManager method getSchemas.
HsqlArrayList getSchemas(Grantee grantee) {
HsqlArrayList list = new HsqlArrayList();
Iterator it = schemaMap.values().iterator();
while (it.hasNext()) {
Schema schema = (Schema) it.next();
if (grantee.equals(schema.owner)) {
list.add(schema);
}
}
return list;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class Schema method getTriggerSQL.
public String[] getTriggerSQL() {
HsqlArrayList list = new HsqlArrayList();
Iterator it = tableLookup.map.values().iterator();
while (it.hasNext()) {
Table table = (Table) it.next();
String[] ddl = table.getTriggerSQL();
list.addAll(ddl);
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
use of org.hsqldb_voltpatches.lib.HsqlArrayList in project voltdb by VoltDB.
the class Grantee method getRightsSQL.
public HsqlArrayList getRightsSQL() {
HsqlArrayList list = new HsqlArrayList();
String roleString = getDirectRolesAsString();
if (roleString.length() != 0) {
list.add("GRANT " + roleString + " TO " + getStatementName());
}
MultiValueHashMap rightsMap = getRights();
Iterator dbObjects = rightsMap.keySet().iterator();
while (dbObjects.hasNext()) {
Object nameObject = dbObjects.next();
Iterator rights = rightsMap.get(nameObject);
while (rights.hasNext()) {
Right right = (Right) rights.next();
StringBuffer sb = new StringBuffer(128);
HsqlName hsqlname = (HsqlName) nameObject;
switch(hsqlname.type) {
case SchemaObject.TABLE:
case SchemaObject.VIEW:
Table table = granteeManager.database.schemaManager.findUserTable(null, hsqlname.name, hsqlname.schema.name);
if (table != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(right.getTableRightsSQL(table));
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("TABLE ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
case SchemaObject.SEQUENCE:
NumberSequence sequence = (NumberSequence) granteeManager.database.schemaManager.findSchemaObject(hsqlname.name, hsqlname.schema.name, SchemaObject.SEQUENCE);
if (sequence != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(Tokens.T_USAGE);
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("SEQUENCE ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
case SchemaObject.DOMAIN:
Type domain = (Type) granteeManager.database.schemaManager.findSchemaObject(hsqlname.name, hsqlname.schema.name, SchemaObject.DOMAIN);
if (domain != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(Tokens.T_USAGE);
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("DOMAIN ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
case SchemaObject.TYPE:
Type type = (Type) granteeManager.database.schemaManager.findSchemaObject(hsqlname.name, hsqlname.schema.name, SchemaObject.DOMAIN);
if (type != null) {
sb.append(Tokens.T_GRANT).append(' ');
sb.append(Tokens.T_USAGE);
sb.append(' ').append(Tokens.T_ON).append(' ');
sb.append("TYPE ").append(hsqlname.getSchemaQualifiedStatementName());
}
break;
}
if (sb.length() == 0) {
continue;
}
sb.append(' ').append(Tokens.T_TO).append(' ');
sb.append(getStatementName());
list.add(sb.toString());
}
}
return list;
}
Aggregations