//
// Create a new method alias descriptor with aliasID filled in.
//
UUID aliasID = dd.getUUIDFactory().createUUID();
AliasDescriptor ads = new AliasDescriptor(dd, aliasID,
aliasName,
sd != null ? sd.getUUID() : null,
javaClassName,
aliasType,
nameSpace,
false,
aliasInfo, null);
// perform duplicate rule checking
switch (aliasType) {
case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR:
{
java.util.List list = dd.getRoutineList(
sd.getUUID().toString(), aliasName, aliasType);
for (int i = list.size() - 1; i >= 0; i--) {
AliasDescriptor proc = (AliasDescriptor) list.get(i);
RoutineAliasInfo procedureInfo = (RoutineAliasInfo) proc.getAliasInfo();
int parameterCount = procedureInfo.getParameterCount();
if (parameterCount != ((RoutineAliasInfo) aliasInfo).getParameterCount())
continue;
// procedure duplicate checking is simple, only
// one procedure with a given number of parameters.
throw StandardException.newException(SQLState.LANG_OBJECT_ALREADY_EXISTS,
ads.getDescriptorType(),
aliasName);
}
}
break;
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
// If target table/view exists already, error.
TableDescriptor targetTD = dd.getTableDescriptor(aliasName, sd);
if (targetTD != null)
{
throw StandardException.newException(
SQLState.LANG_OBJECT_ALREADY_EXISTS,
targetTD.getDescriptorType(),
targetTD.getDescriptorName());
}
// Detect synonym cycles, if present.
String nextSynTable = ((SynonymAliasInfo)aliasInfo).getSynonymTable();
String nextSynSchema = ((SynonymAliasInfo)aliasInfo).getSynonymSchema();
SchemaDescriptor nextSD;
for (;;)
{
nextSD = dd.getSchemaDescriptor(nextSynSchema, tc, false);
if (nextSD == null)
break;
AliasDescriptor nextAD = dd.getAliasDescriptor(nextSD.getUUID().toString(),
nextSynTable, nameSpace);
if (nextAD == null)
break;
SynonymAliasInfo info = (SynonymAliasInfo) nextAD.getAliasInfo();
nextSynTable = info.getSynonymTable();
nextSynSchema = info.getSynonymSchema();
if (aliasName.equals(nextSynTable) && schemaName.equals(nextSynSchema))
throw StandardException.newException(SQLState.LANG_SYNONYM_CIRCULAR,