Search in sources :

Example 91 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method computeRowLocation.

/**
 * Computes the RowLocation in SYSCOLUMNS for a particular
 * autoincrement column.
 *
 * @param tc			Transaction Controller to use.
 * @param td			Table Descriptor.
 * @param columnName	Name of column which has autoincrement column.
 *
 * @exception StandardException thrown on failure.
 */
private RowLocation computeRowLocation(TransactionController tc, TableDescriptor td, String columnName) throws StandardException {
    TabInfoImpl ti = coreInfo[SYSCOLUMNS_CORE_NUM];
    ExecIndexRow keyRow = null;
    UUID tableUUID = td.getUUID();
    keyRow = (ExecIndexRow) exFactory.getIndexableRow(2);
    keyRow.setColumn(1, getIDValueAsCHAR(tableUUID));
    keyRow.setColumn(2, new SQLChar(columnName));
    return ti.getRowLocation(tc, keyRow, SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID);
}
Also used : SQLChar(org.apache.derby.iapi.types.SQLChar) UUID(org.apache.derby.catalog.UUID) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 92 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DropDependencyFilter method execute.

/**
 *	Pump a SYSDEPENDS row through the Filter. If the providerID of the
 * row matches our providerID, we return true. Otherwise we return false.
 *
 *	@param	currentRow		SYSDEPENDS row
 *
 *	@return	True if the row has our providerID. False otherwise.
 *
 * @exception StandardException		Thrown on error
 */
public BooleanDataValue execute(ExecRow currentRow) throws StandardException {
    /* 3rd column is PROVIDERID (UUID - char(36)) */
    DataValueDescriptor col = currentRow.getColumn(SYSDEPENDSRowFactory.SYSDEPENDS_PROVIDERID);
    String providerIDstring = col.getString();
    UUID providerUUID = getUUIDFactory().recreateUUID(providerIDstring);
    if (providerID.equals(providerUUID)) {
        return getTrueValue();
    } else {
        return getFalseValue();
    }
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 93 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method addSPSParams.

/**
 * Add a column in SYS.SYSCOLUMNS for each parameter in the
 * parameter list.
 */
private void addSPSParams(SPSDescriptor spsd, TransactionController tc) throws StandardException {
    UUID uuid = spsd.getUUID();
    DataTypeDescriptor[] params = spsd.getParams();
    Object[] parameterDefaults = spsd.getParameterDefaults();
    if (params == null)
        return;
    /* Create the columns */
    int pdlSize = params.length;
    for (int index = 0; index < pdlSize; index++) {
        int parameterId = index + 1;
        // RESOLVEAUTOINCREMENT
        ColumnDescriptor cd = new ColumnDescriptor("PARAM" + parameterId, // position
        parameterId, params[index], (// default
        (parameterDefaults == null) || (index >= parameterDefaults.length)) ? (DataValueDescriptor) null : (DataValueDescriptor) parameterDefaults[index], (DefaultInfo) null, uuid, (UUID) null, 0, 0, 0, false);
        addDescriptor(cd, null, SYSCOLUMNS_CATALOG_NUM, // no chance of duplicates here
        false, tc);
    }
}
Also used : DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 94 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method getConstraints.

/**
 * Return an List which of the relevant column matching
 * the indexed criteria.  If nothing matches, returns an
 * empty List (never returns null).
 *
 * @param uuid	The id of the constraint
 * @param indexId		The index id in SYS.SYSCONSTRAINTS
 * @param columnNum		The column to retrieve
 *
 * @return a list of UUIDs in an List.
 *
 * @exception StandardException		Thrown on error
 */
public List<UUID> getConstraints(UUID uuid, int indexId, int columnNum) throws StandardException {
    ExecIndexRow indexRow1;
    ExecRow outRow;
    RowLocation baseRowLocation;
    ConglomerateController heapCC = null;
    ScanController scanController = null;
    TransactionController tc;
    TabInfoImpl ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
    SYSCONSTRAINTSRowFactory rf = (SYSCONSTRAINTSRowFactory) ti.getCatalogRowFactory();
    TableDescriptor td = null;
    List<UUID> slist = new ArrayList<UUID>();
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX1_ID || indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX3_ID, "bad index id, must be one of the indexes on a uuid");
        SanityManager.ASSERT(columnNum > 0 && columnNum <= SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT, "invalid column number for column to be retrieved");
    }
    try {
        /* Use tableIDOrderable in both start and stop positions for scan */
        DataValueDescriptor orderable = getIDValueAsCHAR(uuid);
        /* Set up the start/stop position for the scan */
        ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
        keyRow.setColumn(1, orderable);
        // Get the current transaction controller
        tc = getTransactionCompile();
        outRow = rf.makeEmptyRow();
        heapCC = tc.openConglomerate(ti.getHeapConglomerate(), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
        // create an index row template
        indexRow1 = getIndexRowFromHeapRow(ti.getIndexRowGenerator(indexId), heapCC.newRowLocationTemplate(), outRow);
        // just interested in one column
        DataValueDescriptor[] rowTemplate = new DataValueDescriptor[SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT];
        FormatableBitSet columnToGetSet = new FormatableBitSet(SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT);
        columnToGetSet.set(columnNum - 1);
        rowTemplate[columnNum - 1] = new SQLChar();
        // Scan the index and go to the data pages for qualifying rows
        scanController = tc.openScan(// conglomerate to open
        ti.getIndexConglomerate(indexId), // don't hold open across commit
        false, // for read
        0, TransactionController.MODE_RECORD, // RESOLVE: should be level 2
        TransactionController.ISOLATION_REPEATABLE_READ, // all fields as objects
        (FormatableBitSet) null, // start position - exact key match.
        keyRow.getRowArray(), // startSearchOperation
        ScanController.GE, // scanQualifier (none)
        null, // stop position - exact key match.
        keyRow.getRowArray(), // stopSearchOperation
        ScanController.GT);
        while (scanController.fetchNext(indexRow1.getRowArray())) {
            baseRowLocation = (RowLocation) indexRow1.getColumn(indexRow1.nColumns());
            // get the row and grab the uuid
            boolean base_row_exists = heapCC.fetch(baseRowLocation, rowTemplate, columnToGetSet);
            if (SanityManager.DEBUG) {
                // it can not be possible for heap row to disappear while
                // holding scan cursor on index at ISOLATION_REPEATABLE_READ.
                SanityManager.ASSERT(base_row_exists, "base row not found");
            }
            slist.add(uuidFactory.recreateUUID((String) ((DataValueDescriptor) rowTemplate[columnNum - 1]).getObject()));
        }
    } finally {
        if (heapCC != null) {
            heapCC.close();
        }
        if (scanController != null) {
            scanController.close();
        }
    }
    return slist;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) ArrayList(java.util.ArrayList) SQLChar(org.apache.derby.iapi.types.SQLChar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) TransactionController(org.apache.derby.iapi.store.access.TransactionController) UUID(org.apache.derby.catalog.UUID) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 95 with UUID

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

Aggregations

UUID (org.apache.derby.catalog.UUID)101 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)31 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)23 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)22 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)21 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)19 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)15 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)15 SQLChar (org.apache.derby.iapi.types.SQLChar)15 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)14 TransactionController (org.apache.derby.iapi.store.access.TransactionController)14 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)12 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)12 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)11 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)10 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)10 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 ArrayList (java.util.ArrayList)9 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)9 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)8