Search in sources :

Example 6 with UserType

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

the class CacheLock method readProperty.

private Serializable readProperty(TransactionController tc, String key) throws StandardException {
    // scan the table for a row with matching "key"
    ScanController scan = openScan(tc, key, 0);
    DataValueDescriptor[] row = makeNewTemplate();
    // did we find at least one row?
    boolean isThere = scan.fetchNext(row);
    scan.close();
    if (!isThere)
        return null;
    return (Serializable) (((UserType) row[1]).getObject());
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) Serializable(java.io.Serializable) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UserType(org.apache.derby.iapi.types.UserType)

Example 7 with UserType

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

the class CacheLock method makeNewTemplate.

/**
 * Create a new empty PropertyConglomerate row, to fetch values into.
 */
private DataValueDescriptor[] makeNewTemplate() {
    DataValueDescriptor[] template = new DataValueDescriptor[2];
    template[0] = new UTF();
    template[1] = new UserType();
    return (template);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UserType(org.apache.derby.iapi.types.UserType)

Example 8 with UserType

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

the class CacheLock method readDbProperties.

/**
 * Read the database properties and add in the service set.
 */
private Dictionary<String, Object> readDbProperties(TransactionController tc) throws StandardException {
    Dictionary<String, Object> set = new Hashtable<String, Object>();
    // scan the table for a row with no matching "key"
    ScanController scan = openScan(tc, (String) null, 0);
    DataValueDescriptor[] row = makeNewTemplate();
    while (scan.fetchNext(row)) {
        Object key = ((UserType) row[0]).getObject();
        Object value = ((UserType) row[1]).getObject();
        if (SanityManager.DEBUG) {
            if (!(key instanceof String))
                SanityManager.THROWASSERT("Key is not a string " + key.getClass().getName());
        }
        set.put((String) key, value);
    }
    scan.close();
    // add the known properties from the service properties set
    String[] servicePropertyList = PropertyUtil.getServicePropertyList();
    for (int i = 0; i < servicePropertyList.length; i++) {
        String value = serviceProperties.getProperty(servicePropertyList[i]);
        if (value != null)
            set.put(servicePropertyList[i], value);
    }
    return set;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) Hashtable(java.util.Hashtable) FormatableHashtable(org.apache.derby.iapi.services.io.FormatableHashtable) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UserType(org.apache.derby.iapi.types.UserType)

Example 9 with UserType

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

the class SYSDEPENDSRowFactory method makeRow.

// ///////////////////////////////////////////////////////////////////////////
// 
// METHODS
// 
// ///////////////////////////////////////////////////////////////////////////
/**
 * Make a SYSDEPENDS row
 *
 * @param td DependencyDescriptor. If its null then we want to make an empty
 * row.
 *
 * @return	Row suitable for inserting into SYSDEPENDS.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException {
    DataValueDescriptor col;
    ExecRow row;
    String dependentID = null;
    DependableFinder dependentBloodhound = null;
    String providerID = null;
    DependableFinder providerBloodhound = null;
    if (td != null) {
        DependencyDescriptor dd = (DependencyDescriptor) td;
        dependentID = dd.getUUID().toString();
        dependentBloodhound = dd.getDependentFinder();
        if (dependentBloodhound == null) {
            throw StandardException.newException(SQLState.DEP_UNABLE_TO_STORE);
        }
        providerID = dd.getProviderID().toString();
        providerBloodhound = dd.getProviderFinder();
        if (providerBloodhound == null) {
            throw StandardException.newException(SQLState.DEP_UNABLE_TO_STORE);
        }
    }
    /* Insert info into sysdepends */
    /* RESOLVE - It would be nice to require less knowledge about sysdepends
		 * and have this be more table driven.
		 */
    /* Build the row to insert  */
    row = getExecutionFactory().getValueRow(SYSDEPENDS_COLUMN_COUNT);
    /* 1st column is DEPENDENTID (UUID - char(36)) */
    row.setColumn(SYSDEPENDS_DEPENDENTID, new SQLChar(dependentID));
    /* 2nd column is DEPENDENTFINDER */
    row.setColumn(SYSDEPENDS_DEPENDENTTYPE, new UserType(dependentBloodhound));
    /* 3rd column is PROVIDERID (UUID - char(36)) */
    row.setColumn(SYSDEPENDS_PROVIDERID, new SQLChar(providerID));
    /* 4th column is PROVIDERFINDER */
    row.setColumn(SYSDEPENDS_PROVIDERTYPE, new UserType(providerBloodhound));
    return row;
}
Also used : DependableFinder(org.apache.derby.catalog.DependableFinder) DependencyDescriptor(org.apache.derby.iapi.sql.dictionary.DependencyDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) SQLChar(org.apache.derby.iapi.types.SQLChar) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UserType(org.apache.derby.iapi.types.UserType)

Example 10 with UserType

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

the class SYSSTATEMENTSRowFactory method makeSYSSTATEMENTSrow.

// ///////////////////////////////////////////////////////////////////////////
// 
// METHODS
// 
// ///////////////////////////////////////////////////////////////////////////
/**
 * Make a SYSSTATEMENTS row.
 * <p>
 * <B>WARNING</B>: When empty row is true, this method takes
 * a snapshot of the SPSD and creates a row.  It is imperative
 * that that row remain consistent with the descriptor (the
 * valid and StorablePreparedStatement fields must be in sync).
 * If this row is to be written out and valid is true, then
 * this call and the insert should be synchronized on the
 * SPSD. This method has <B>NO</B> synchronization.
 *
 * @param compileMe			passed into SPSDescriptorImpl.getPreparedStatement().
 *							if true, we (re)compile the stmt
 * @param spsDescriptor		In-memory tuple to be converted to a disk row.
 *
 * @return	Row suitable for inserting into SYSSTATEMENTS.
 *
 * @exception   StandardException thrown on failure
 */
public ExecRow makeSYSSTATEMENTSrow(boolean compileMe, SPSDescriptor spsDescriptor) throws StandardException {
    DataTypeDescriptor dtd;
    ExecRow row;
    DataValueDescriptor col;
    String name = null;
    UUID uuid = null;
    String uuidStr = null;
    // schema
    String suuidStr = null;
    // compilation schema
    String compUuidStr = null;
    String text = null;
    String usingText = null;
    ExecPreparedStatement preparedStatement = null;
    String typeStr = null;
    boolean valid = true;
    Timestamp time = null;
    boolean initiallyCompilable = true;
    if (spsDescriptor != null) {
        name = spsDescriptor.getName();
        uuid = spsDescriptor.getUUID();
        suuidStr = spsDescriptor.getSchemaDescriptor().getUUID().toString();
        uuidStr = uuid.toString();
        text = spsDescriptor.getText();
        valid = spsDescriptor.isValid();
        time = spsDescriptor.getCompileTime();
        typeStr = spsDescriptor.getTypeAsString();
        initiallyCompilable = spsDescriptor.initiallyCompilable();
        preparedStatement = spsDescriptor.getPreparedStatement(compileMe);
        compUuidStr = (spsDescriptor.getCompSchemaId() != null) ? spsDescriptor.getCompSchemaId().toString() : null;
        usingText = spsDescriptor.getUsingText();
    }
    /* Build the row to insert */
    row = getExecutionFactory().getValueRow(SYSSTATEMENTS_COLUMN_COUNT);
    /* 1st column is STMTID */
    row.setColumn(1, new SQLChar(uuidStr));
    /* 2nd column is STMTNAME */
    row.setColumn(2, new SQLVarchar(name));
    /* 3rd column is SCHEMAID */
    row.setColumn(3, new SQLChar(suuidStr));
    /* 4th column is TYPE */
    row.setColumn(4, new SQLChar(typeStr));
    /* 5th column is VALID */
    row.setColumn(5, new SQLBoolean(valid));
    /* 6th column is TEXT */
    row.setColumn(6, dvf.getLongvarcharDataValue(text));
    /* 7th column is LASTCOMPILED */
    row.setColumn(7, new SQLTimestamp(time));
    /* 8th column is COMPILATIONSCHEMAID */
    row.setColumn(8, new SQLChar(compUuidStr));
    /* 9th column is USINGTEXT */
    row.setColumn(9, dvf.getLongvarcharDataValue(usingText));
    /* 
		** 10th column is CONSTANTSTATE
		**
		** CONSTANTSTATE is really a formatable StorablePreparedStatement.
		*/
    row.setColumn(10, new UserType(preparedStatement));
    /* 11th column is INITIALLY_COMPILABLE */
    row.setColumn(11, new SQLBoolean(initiallyCompilable));
    return row;
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) Timestamp(java.sql.Timestamp) ExecPreparedStatement(org.apache.derby.iapi.sql.execute.ExecPreparedStatement) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) UserType(org.apache.derby.iapi.types.UserType) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean)

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