use of org.apache.derby.catalog.AliasInfo in project derby by apache.
the class AggregateNode method resolveBuiltinAggregate.
/**
* Construct an AliasDescriptor for a modern builtin aggregate.
*/
private static AliasDescriptor resolveBuiltinAggregate(DataDictionary dd, String rawName, boolean noSchema) throws StandardException {
// builtin aggregates may not be schema-qualified
if (!noSchema) {
return null;
}
BuiltinAggDescriptor bad = null;
for (BuiltinAggDescriptor aggDescriptor : BUILTIN_MODERN_AGGS) {
if (aggDescriptor.aggName.equals(rawName)) {
bad = aggDescriptor;
break;
}
}
if (bad == null) {
return null;
}
AliasInfo aliasInfo = new AggregateAliasInfo(bad.argType, bad.returnType);
return new AliasDescriptor(dd, null, rawName, dd.getSystemSchemaDescriptor().getUUID(), bad.aggClassName, AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR, AliasInfo.ALIAS_NAME_SPACE_AGGREGATE_AS_CHAR, false, aliasInfo, null);
}
use of org.apache.derby.catalog.AliasInfo in project derby by apache.
the class SYSALIASESRowFactory method buildDescriptor.
// /////////////////////////////////////////////////////////////////////////
//
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
//
// /////////////////////////////////////////////////////////////////////////
/**
* Make a AliasDescriptor out of a SYSALIASES row
*
* @param row a SYSALIASES row
* @param parentTupleDescriptor Null for this kind of descriptor.
* @param dd dataDictionary
*
* @exception StandardException thrown on failure
*/
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(row.nColumns() == SYSALIASES_COLUMN_COUNT, "Wrong number of columns for a SYSALIASES row");
}
char cAliasType;
char cNameSpace;
DataValueDescriptor col;
String aliasID;
UUID aliasUUID;
String aliasName;
String javaClassName;
String sAliasType;
String sNameSpace;
String typeStr;
boolean systemAlias = false;
AliasInfo aliasInfo = null;
/* 1st column is ALIASID (UUID - char(36)) */
col = row.getColumn(SYSALIASES_ALIASID);
aliasID = col.getString();
aliasUUID = getUUIDFactory().recreateUUID(aliasID);
/* 2nd column is ALIAS (varchar(128)) */
col = row.getColumn(SYSALIASES_ALIAS);
aliasName = col.getString();
/* 3rd column is SCHEMAID (UUID - char(36)) */
col = row.getColumn(SYSALIASES_SCHEMAID);
UUID schemaUUID = col.isNull() ? null : getUUIDFactory().recreateUUID(col.getString());
/* 4th column is JAVACLASSNAME (longvarchar) */
col = row.getColumn(SYSALIASES_JAVACLASSNAME);
javaClassName = col.getString();
/* 5th column is ALIASTYPE (char(1)) */
col = row.getColumn(SYSALIASES_ALIASTYPE);
sAliasType = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(sAliasType.length() == 1, "Fifth column (aliastype) type incorrect");
switch(sAliasType.charAt(0)) {
case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Invalid type value '" + sAliasType + "' for alias");
}
}
cAliasType = sAliasType.charAt(0);
/* 6th column is NAMESPACE (char(1)) */
col = row.getColumn(SYSALIASES_NAMESPACE);
sNameSpace = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(sNameSpace.length() == 1, "Sixth column (namespace) type incorrect");
switch(sNameSpace.charAt(0)) {
case AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Invalid type value '" + sNameSpace + "' for alias");
}
}
cNameSpace = sNameSpace.charAt(0);
/* 7th column is SYSTEMALIAS (boolean) */
col = row.getColumn(SYSALIASES_SYSTEMALIAS);
systemAlias = col.getBoolean();
/* 8th column is ALIASINFO (org.apache.derby.catalog.AliasInfo) */
col = row.getColumn(SYSALIASES_ALIASINFO);
aliasInfo = (AliasInfo) col.getObject();
/* 9th column is specific name */
col = row.getColumn(SYSALIASES_SPECIFIC_NAME);
String specificName = col.getString();
/* now build and return the descriptor */
return new AliasDescriptor(dd, aliasUUID, aliasName, schemaUUID, javaClassName, cAliasType, cNameSpace, systemAlias, aliasInfo, specificName);
}
use of org.apache.derby.catalog.AliasInfo in project derby by apache.
the class SYSALIASESRowFactory method makeRow.
// ///////////////////////////////////////////////////////////////////////////
//
// METHODS
//
// ///////////////////////////////////////////////////////////////////////////
/**
* Make a SYSALIASES row
*
* @return Row suitable for inserting into SYSALIASES.
*
* @exception StandardException thrown on failure
*/
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
DataValueDescriptor col;
String schemaID = null;
String javaClassName = null;
String sAliasType = null;
String aliasID = null;
String aliasName = null;
String specificName = null;
char cAliasType = AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR;
char cNameSpace = AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR;
boolean systemAlias = false;
AliasInfo aliasInfo = null;
if (td != null) {
AliasDescriptor ad = (AliasDescriptor) td;
aliasID = ad.getUUID().toString();
aliasName = ad.getDescriptorName();
schemaID = ad.getSchemaUUID().toString();
javaClassName = ad.getJavaClassName();
cAliasType = ad.getAliasType();
cNameSpace = ad.getNameSpace();
systemAlias = ad.getSystemAlias();
aliasInfo = ad.getAliasInfo();
specificName = ad.getSpecificName();
char[] charArray = new char[1];
charArray[0] = cAliasType;
sAliasType = new String(charArray);
if (SanityManager.DEBUG) {
switch(cAliasType) {
case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Unexpected value (" + cAliasType + ") for aliasType");
}
}
}
/* Insert info into sysaliases */
/* RESOLVE - It would be nice to require less knowledge about sysaliases
* and have this be more table driven.
*/
/* Build the row to insert */
ExecRow row = getExecutionFactory().getValueRow(SYSALIASES_COLUMN_COUNT);
/* 1st column is ALIASID (UUID - char(36)) */
row.setColumn(SYSALIASES_ALIASID, new SQLChar(aliasID));
/* 2nd column is ALIAS (varchar(128))) */
row.setColumn(SYSALIASES_ALIAS, new SQLVarchar(aliasName));
// System.out.println(" added row-- " + aliasName);
/* 3rd column is SCHEMAID (UUID - char(36)) */
row.setColumn(SYSALIASES_SCHEMAID, new SQLChar(schemaID));
/* 4th column is JAVACLASSNAME (longvarchar) */
row.setColumn(SYSALIASES_JAVACLASSNAME, dvf.getLongvarcharDataValue(javaClassName));
/* 5th column is ALIASTYPE (char(1)) */
row.setColumn(SYSALIASES_ALIASTYPE, new SQLChar(sAliasType));
/* 6th column is NAMESPACE (char(1)) */
String sNameSpace = new String(new char[] { cNameSpace });
row.setColumn(SYSALIASES_NAMESPACE, new SQLChar(sNameSpace));
/* 7th column is SYSTEMALIAS (boolean) */
row.setColumn(SYSALIASES_SYSTEMALIAS, new SQLBoolean(systemAlias));
/* 8th column is ALIASINFO (org.apache.derby.catalog.AliasInfo) */
row.setColumn(SYSALIASES_ALIASINFO, new UserType(aliasInfo));
/* 9th column is specific name */
row.setColumn(SYSALIASES_SPECIFIC_NAME, new SQLVarchar(specificName));
return row;
}
Aggregations