Search in sources :

Example 31 with AliasDescriptor

use of org.apache.derby.iapi.sql.dictionary.AliasDescriptor 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;
}
Also used : AliasInfo(org.apache.derby.catalog.AliasInfo) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) AliasDescriptor(org.apache.derby.iapi.sql.dictionary.AliasDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) UserType(org.apache.derby.iapi.types.UserType) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean)

Aggregations

AliasDescriptor (org.apache.derby.iapi.sql.dictionary.AliasDescriptor)31 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)11 RoutineAliasInfo (org.apache.derby.catalog.types.RoutineAliasInfo)9 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)9 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)7 UUID (org.apache.derby.catalog.UUID)6 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)6 TypeDescriptor (org.apache.derby.catalog.TypeDescriptor)5 TransactionController (org.apache.derby.iapi.store.access.TransactionController)5 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)4 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)4 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)4 AliasInfo (org.apache.derby.catalog.AliasInfo)3 AggregateAliasInfo (org.apache.derby.catalog.types.AggregateAliasInfo)3 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)3 SQLChar (org.apache.derby.iapi.types.SQLChar)3 SQLLongint (org.apache.derby.iapi.types.SQLLongint)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 SynonymAliasInfo (org.apache.derby.catalog.types.SynonymAliasInfo)2