Search in sources :

Example 11 with UserType

use of org.apache.derby.iapi.types.UserType in project derby by apache.

the class SYSSTATISTICSRowFactory method makeRow.

/**
 * Make a SYSSTATISTICS row
 *
 * @return	Row suitable for inserting into SYSSTATISTICS.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    String myID = null, referenceID = null, tableID = null;
    String statName = null, colMap = null, statType = null;
    Timestamp updateTime = null;
    int columnCount = 0;
    Statistics statisticsObject = null;
    boolean validStat = false;
    ExecRow row = getExecutionFactory().getValueRow(SYSSTATISTICS_COLUMN_COUNT);
    if (td != null) {
        StatisticsDescriptor statDesc = (StatisticsDescriptor) td;
        myID = statDesc.getUUID().toString();
        tableID = statDesc.getTableUUID().toString();
        referenceID = statDesc.getReferenceID().toString();
        updateTime = statDesc.getUpdateTimestamp();
        statType = statDesc.getStatType();
        validStat = statDesc.isValid();
        statisticsObject = statDesc.getStatistic();
        columnCount = statDesc.getColumnCount();
    }
    row.setColumn(1, new SQLChar(myID));
    row.setColumn(2, new SQLChar(referenceID));
    row.setColumn(3, new SQLChar(tableID));
    row.setColumn(4, new SQLTimestamp(updateTime));
    row.setColumn(5, new SQLChar(statType));
    row.setColumn(6, new SQLBoolean(validStat));
    row.setColumn(7, new SQLInteger(columnCount));
    row.setColumn(8, new UserType(statisticsObject));
    return row;
}
Also used : StatisticsDescriptor(org.apache.derby.iapi.sql.dictionary.StatisticsDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) Timestamp(java.sql.Timestamp) Statistics(org.apache.derby.catalog.Statistics) UserType(org.apache.derby.iapi.types.UserType)

Example 12 with UserType

use of org.apache.derby.iapi.types.UserType 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)

Example 13 with UserType

use of org.apache.derby.iapi.types.UserType in project derby by apache.

the class SYSCOLPERMSRowFactory method makeRow.

public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    UUID oid;
    String colPermID = null;
    DataValueDescriptor grantee = null;
    DataValueDescriptor grantor = null;
    String tableID = null;
    String type = null;
    FormatableBitSet columns = null;
    if (td == null) {
        grantee = getNullAuthorizationID();
        grantor = getNullAuthorizationID();
    } else {
        ColPermsDescriptor cpd = (ColPermsDescriptor) td;
        oid = cpd.getUUID();
        if (oid == null) {
            oid = getUUIDFactory().createUUID();
            cpd.setUUID(oid);
        }
        colPermID = oid.toString();
        grantee = getAuthorizationID(cpd.getGrantee());
        grantor = getAuthorizationID(cpd.getGrantor());
        tableID = cpd.getTableUUID().toString();
        type = cpd.getType();
        columns = cpd.getColumns();
    }
    ExecRow row = getExecutionFactory().getValueRow(COLUMN_COUNT);
    row.setColumn(COLPERMSID_COL_NUM, new SQLChar(colPermID));
    row.setColumn(GRANTEE_COL_NUM, grantee);
    row.setColumn(GRANTOR_COL_NUM, grantor);
    row.setColumn(TABLEID_COL_NUM, new SQLChar(tableID));
    row.setColumn(TYPE_COL_NUM, new SQLChar(type));
    row.setColumn(COLUMNS_COL_NUM, new UserType((Object) columns));
    return row;
}
Also used : ColPermsDescriptor(org.apache.derby.iapi.sql.dictionary.ColPermsDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) UserType(org.apache.derby.iapi.types.UserType)

Example 14 with UserType

use of org.apache.derby.iapi.types.UserType in project derby by apache.

the class SYSCONGLOMERATESRowFactory method makeRow.

/**
 * Make a SYSCONGLOMERATES row
 *
 * @return	Row suitable for inserting into SYSCONGLOMERATES.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    ExecRow row;
    DataValueDescriptor col;
    String tabID = null;
    Long conglomNumber = null;
    String conglomName = null;
    Boolean supportsIndex = null;
    IndexRowGenerator indexRowGenerator = null;
    Boolean supportsConstraint = null;
    String conglomUUIDString = null;
    String schemaID = null;
    ConglomerateDescriptor conglomerate = (ConglomerateDescriptor) td;
    if (td != null) {
        /* Sometimes the SchemaDescriptor is non-null and sometimes it
			 * is null.  (We can't just rely on getting the schema id from 
			 * the ConglomerateDescriptor because it can be null when
			 * we are creating a new conglomerate.
			 */
        if (parent != null) {
            SchemaDescriptor sd = (SchemaDescriptor) parent;
            schemaID = sd.getUUID().toString();
        } else {
            schemaID = conglomerate.getSchemaID().toString();
        }
        tabID = conglomerate.getTableID().toString();
        conglomNumber = conglomerate.getConglomerateNumber();
        conglomName = conglomerate.getConglomerateName();
        conglomUUIDString = conglomerate.getUUID().toString();
        supportsIndex = conglomerate.isIndex();
        indexRowGenerator = conglomerate.getIndexDescriptor();
        supportsConstraint = conglomerate.isConstraint();
    }
    /* RESOLVE - It would be nice to require less knowledge about sysconglomerates
		 * and have this be more table driven.
		 */
    /* Build the row to insert */
    row = getExecutionFactory().getValueRow(SYSCONGLOMERATES_COLUMN_COUNT);
    /* 1st column is SCHEMAID (UUID - char(36)) */
    row.setColumn(1, new SQLChar(schemaID));
    /* 2nd column is TABLEID (UUID - char(36)) */
    row.setColumn(2, new SQLChar(tabID));
    /* 3rd column is CONGLOMERATENUMBER (long) */
    row.setColumn(3, new SQLLongint(conglomNumber));
    /* 4th column is CONGLOMERATENAME (varchar(128)) 
		** If null, use the tableid so we always
		** have a unique column
		*/
    row.setColumn(4, (conglomName == null) ? new SQLVarchar(tabID) : new SQLVarchar(conglomName));
    /* 5th  column is ISINDEX (boolean) */
    row.setColumn(5, new SQLBoolean(supportsIndex));
    /* 6th column is DESCRIPTOR
		*  (user type org.apache.derby.catalog.IndexDescriptor)
		*/
    row.setColumn(6, new UserType((indexRowGenerator == null ? (IndexDescriptor) null : indexRowGenerator.getIndexDescriptor())));
    /* 7th column is ISCONSTRAINT (boolean) */
    row.setColumn(7, new SQLBoolean(supportsConstraint));
    /* 8th column is CONGLOMERATEID (UUID - char(36)) */
    row.setColumn(8, new SQLChar(conglomUUIDString));
    return row;
}
Also used : SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) IndexDescriptor(org.apache.derby.catalog.IndexDescriptor) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) IndexRowGenerator(org.apache.derby.iapi.sql.dictionary.IndexRowGenerator) SQLLongint(org.apache.derby.iapi.types.SQLLongint) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean) UserType(org.apache.derby.iapi.types.UserType) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean)

Example 15 with UserType

use of org.apache.derby.iapi.types.UserType in project derby by apache.

the class CacheLock method makeNewTemplate.

/* Private/Protected methods of This class: */
/**
 * Create a new PropertyConglomerate row, with values in it.
 */
private DataValueDescriptor[] makeNewTemplate(String key, Serializable value) {
    DataValueDescriptor[] template = new DataValueDescriptor[2];
    template[0] = new UTF(key);
    template[1] = new UserType(value);
    return (template);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UserType(org.apache.derby.iapi.types.UserType)

Aggregations

UserType (org.apache.derby.iapi.types.UserType)16 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)13 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)9 SQLChar (org.apache.derby.iapi.types.SQLChar)7 SQLBoolean (org.apache.derby.iapi.types.SQLBoolean)5 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)5 UUID (org.apache.derby.catalog.UUID)4 ScanController (org.apache.derby.iapi.store.access.ScanController)4 Timestamp (java.sql.Timestamp)3 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)3 SQLLongint (org.apache.derby.iapi.types.SQLLongint)3 ReferencedColumns (org.apache.derby.catalog.ReferencedColumns)2 ColPermsDescriptor (org.apache.derby.iapi.sql.dictionary.ColPermsDescriptor)2 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)2 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)2 Serializable (java.io.Serializable)1 Hashtable (java.util.Hashtable)1 AliasInfo (org.apache.derby.catalog.AliasInfo)1 DependableFinder (org.apache.derby.catalog.DependableFinder)1 IndexDescriptor (org.apache.derby.catalog.IndexDescriptor)1