use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class SchemaManager method getSQLArray.
public String[] getSQLArray() {
OrderedHashSet resolved = new OrderedHashSet();
OrderedHashSet unresolved = new OrderedHashSet();
HsqlArrayList list = new HsqlArrayList();
Iterator schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (isSystemSchema(schema.name.name)) {
continue;
}
if (isLobsSchema(schema.name.name)) {
continue;
}
list.addAll(schema.getSQLArray(resolved, unresolved));
}
while (true) {
Iterator it = unresolved.iterator();
if (!it.hasNext()) {
break;
}
while (it.hasNext()) {
SchemaObject object = (SchemaObject) it.next();
OrderedHashSet references = object.getReferences();
boolean isResolved = true;
for (int j = 0; j < references.size(); j++) {
HsqlName name = (HsqlName) references.get(j);
if (name.type == SchemaObject.COLUMN || name.type == SchemaObject.CONSTRAINT) {
name = name.parent;
}
if (!resolved.contains(name)) {
isResolved = false;
break;
}
}
if (isResolved) {
if (object.getType() == SchemaObject.TABLE) {
list.addAll(((Table) object).getSQL(resolved, unresolved));
} else {
list.add(object.getSQL());
resolved.add(object.getName());
}
it.remove();
}
}
}
schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (database.schemaManager.isSystemSchema(schema.name.name)) {
continue;
}
if (database.schemaManager.isLobsSchema(schema.name.name)) {
// continue;
}
list.addAll(schema.getTriggerSQL());
list.addAll(schema.getSequenceRestartSQL());
}
if (defaultSchemaHsqlName != null) {
StringBuffer sb = new StringBuffer();
sb.append(Tokens.T_SET).append(' ').append(Tokens.T_DATABASE);
sb.append(' ').append(Tokens.T_DEFAULT).append(' ');
sb.append(Tokens.T_INITIAL).append(' ').append(Tokens.T_SCHEMA);
sb.append(' ').append(defaultSchemaHsqlName.statementName);
list.add(sb.toString());
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class RoutineSchema method addSpecificRoutine.
public void addSpecificRoutine(Database database, Routine routine) {
int signature = routine.getParameterSignature();
Type[] types = routine.getParameterTypes();
for (int i = 0; i < this.routines.length; i++) {
if (routines[i].parameterTypes.length == types.length) {
if (routineType == SchemaObject.PROCEDURE) {
throw Error.error(ErrorCode.X_42605);
}
boolean match = true;
for (int j = 0; j < types.length; j++) {
if (!routines[i].parameterTypes[j].equals(types[j])) {
match = false;
break;
}
}
if (match) {
throw Error.error(ErrorCode.X_42605);
}
}
}
if (routine.getSpecificName() == null) {
HsqlName specificName = database.nameManager.newAutoName("", name.name, name.schema, name, name.type);
routine.setSpecificName(specificName);
}
routines = (Routine[]) ArrayUtil.resizeArray(routines, routines.length + 1);
routines[routines.length - 1] = routine;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class SchemaManager method getCascadingSchemaReferences.
//
private void getCascadingSchemaReferences(HsqlName schema, OrderedHashSet set) {
Iterator mainIterator = referenceMap.keySet().iterator();
while (mainIterator.hasNext()) {
HsqlName name = (HsqlName) mainIterator.next();
if (name.schema != schema) {
continue;
}
getCascadingReferences(name, set);
}
for (int i = 0; i < set.size(); i++) {
HsqlName name = (HsqlName) set.get(i);
if (name.schema == schema) {
set.remove(i);
i--;
}
}
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class SchemaManager method checkObjectIsReferenced.
void checkObjectIsReferenced(HsqlName name) {
OrderedHashSet set = getReferencingObjects(name);
HsqlName refName = null;
for (int i = 0; i < set.size(); i++) {
refName = (HsqlName) set.get(i);
if (refName.parent != name) {
break;
}
refName = null;
}
if (refName == null) {
return;
}
throw Error.error(ErrorCode.X_42502, refName.getSchemaQualifiedStatementName());
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class SchemaManager method findSchemaObject.
public SchemaObject findSchemaObject(String name, String schemaName, int type) {
Schema schema = (Schema) schemaMap.get(schemaName);
if (schema == null) {
return null;
}
SchemaObjectSet set = null;
HsqlName objectName;
Table table;
switch(type) {
case SchemaObject.SEQUENCE:
return schema.sequenceLookup.getObject(name);
case SchemaObject.TABLE:
case SchemaObject.VIEW:
return schema.sequenceLookup.getObject(name);
case SchemaObject.CHARSET:
if (name.equals("SQL_IDENTIFIER")) {
return SqlInvariants.SQL_IDENTIFIER_CHARSET;
}
if (name.equals("SQL_TEXT")) {
return SqlInvariants.SQL_TEXT;
}
if (name.equals("LATIN1")) {
return SqlInvariants.LATIN1;
}
if (name.equals("ASCII_GRAPHIC")) {
return SqlInvariants.ASCII_GRAPHIC;
}
return schema.charsetLookup.getObject(name);
case SchemaObject.COLLATION:
return schema.collationLookup.getObject(name);
case SchemaObject.PROCEDURE:
return schema.procedureLookup.getObject(name);
case SchemaObject.FUNCTION:
return schema.functionLookup.getObject(name);
case SchemaObject.DOMAIN:
case SchemaObject.TYPE:
return schema.typeLookup.getObject(name);
case SchemaObject.INDEX:
set = schema.indexLookup;
objectName = set.getName(name);
if (objectName == null) {
return null;
}
table = (Table) schema.tableList.get(objectName.parent.name);
return table.getIndex(name);
case SchemaObject.CONSTRAINT:
set = schema.constraintLookup;
objectName = set.getName(name);
if (objectName == null) {
return null;
}
table = (Table) schema.tableList.get(objectName.parent.name);
if (table == null) {
return null;
}
return table.getConstraint(name);
case SchemaObject.TRIGGER:
set = schema.indexLookup;
objectName = set.getName(name);
if (objectName == null) {
return null;
}
table = (Table) schema.tableList.get(objectName.parent.name);
return table.getTrigger(name);
default:
throw Error.runtimeError(ErrorCode.U_S0500, "SchemaManager");
}
}
Aggregations