Search in sources :

Example 31 with DataValueDescriptor

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

the class DataDictionaryImpl method existsSchemaOwnedBy.

/**
 * Return true of there exists a schema whose authorizationId equals
 * authid, i.e.  SYS.SYSSCHEMAS contains a row whose column
 * (AUTHORIZATIONID) equals authid.
 *
 * @param authid authorizationId
 * @param tc TransactionController
 * @return true iff there is a matching schema
 * @exception StandardException
 */
public boolean existsSchemaOwnedBy(String authid, TransactionController tc) throws StandardException {
    TabInfoImpl ti = coreInfo[SYSSCHEMAS_CORE_NUM];
    SYSSCHEMASRowFactory rf = (SYSSCHEMASRowFactory) ti.getCatalogRowFactory();
    ConglomerateController heapCC = tc.openConglomerate(ti.getHeapConglomerate(), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
    DataValueDescriptor authIdOrderable = new SQLVarchar(authid);
    ScanQualifier[][] scanQualifier = exFactory.getScanQualifier(1);
    scanQualifier[0][0].setQualifier(SYSSCHEMASRowFactory.SYSSCHEMAS_SCHEMAAID - 1, /* to zero-based */
    authIdOrderable, Orderable.ORDER_OP_EQUALS, false, false, false);
    ScanController sc = tc.openScan(ti.getHeapConglomerate(), // don't hold open across commit
    false, // for update
    0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, // all fields as objects
    (FormatableBitSet) null, // start position -
    (DataValueDescriptor[]) null, // startSearchOperation - none
    0, // 
    scanQualifier, // stop position -through last row
    (DataValueDescriptor[]) null, // stopSearchOperation - none
    0);
    boolean result = false;
    try {
        ExecRow outRow = rf.makeEmptyRow();
        if (sc.fetchNext(outRow.getRowArray())) {
            result = true;
        }
    } finally {
        if (sc != null) {
            sc.close();
        }
        if (heapCC != null) {
            heapCC.close();
        }
    }
    return result;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar)

Example 32 with DataValueDescriptor

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

the class DataDictionaryImpl method dropStatisticsDescriptors.

/**
 * @see DataDictionary#dropStatisticsDescriptors
 */
public void dropStatisticsDescriptors(UUID tableUUID, UUID referenceUUID, TransactionController tc) throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSSTATISTICS_CATALOG_NUM);
    DataValueDescriptor first, second;
    first = getIDValueAsCHAR(tableUUID);
    ExecIndexRow keyRow;
    if (referenceUUID != null) {
        keyRow = exFactory.getIndexableRow(2);
        second = getIDValueAsCHAR(referenceUUID);
        keyRow.setColumn(2, second);
    } else {
        keyRow = exFactory.getIndexableRow(1);
    }
    keyRow.setColumn(1, first);
    ti.deleteRow(tc, keyRow, SYSSTATISTICSRowFactory.SYSSTATISTICS_INDEX1_ID);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 33 with DataValueDescriptor

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

the class DataDictionaryImpl method updateTriggerDescriptor.

/**
 * Update the trigger descriptor in question.  Updates
 * every row in the base conglomerate that matches the uuid.
 *
 * @param triggerd				The Trigger descriptor
 * @param formerUUID			The UUID for this column in SYSTRIGGERS,
 *								may differ from what is in triggerd if this
 *								is the column that is being set.
 * @param colsToSet 			Array of ints of columns to be modified,
 *								1 based.  May be null (all cols).
 * @param tc					The TransactionController to use
 *
 * @exception StandardException		Thrown on failure
 */
public void updateTriggerDescriptor(TriggerDescriptor triggerd, UUID formerUUID, int[] colsToSet, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow1 = null;
    ExecRow row;
    DataValueDescriptor IDOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSTRIGGERS_CATALOG_NUM);
    SYSTRIGGERSRowFactory rf = (SYSTRIGGERSRowFactory) ti.getCatalogRowFactory();
    /* Use objectID in both start 
		 * and stop position for index 1 scan. 
		 */
    IDOrderable = getIDValueAsCHAR(formerUUID);
    /* Set up the start/stop position for the scan */
    keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow1.setColumn(1, IDOrderable);
    // build the row to be stuffed into SYSTRIGGERS.
    row = rf.makeRow(triggerd, null);
    /*
		** Figure out if the index in systriggers needs 
		** to be updated. 
		*/
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(rf.getNumIndexes() == 3, "There are more indexes on systriggers than expected, the code herein needs to change");
    }
    boolean[] bArray = new boolean[3];
    /*
		** Do we need to update indexes?
		*/
    if (colsToSet == null) {
        bArray[0] = true;
        bArray[1] = true;
        bArray[2] = true;
    } else {
        /*
			** Check the specific columns for indexed
			** columns.
			*/
        for (int i = 0; i < colsToSet.length; i++) {
            switch(colsToSet[i]) {
                case SYSTRIGGERSRowFactory.SYSTRIGGERS_TRIGGERID:
                    bArray[0] = true;
                    break;
                case SYSTRIGGERSRowFactory.SYSTRIGGERS_TRIGGERNAME:
                case SYSTRIGGERSRowFactory.SYSTRIGGERS_SCHEMAID:
                    bArray[1] = true;
                    break;
                case SYSTRIGGERSRowFactory.SYSTRIGGERS_TABLEID:
                    bArray[2] = true;
                    break;
            }
        }
    }
    ti.updateRow(keyRow1, row, SYSTRIGGERSRowFactory.SYSTRIGGERS_INDEX1_ID, bArray, colsToSet, tc);
}
Also used : ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 34 with DataValueDescriptor

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

the class DataDictionaryImpl method getRoleDefinitionDescriptor.

/**
 * Get the target role definition by searching for a matching row
 * in SYSROLES by rolename where isDef==true.  Read only scan.
 * Uses index on (rolename, isDef) columns.
 *
 * @param roleName The name of the role we're interested in.
 *
 * @return The descriptor (row) for the role
 * @exception StandardException Thrown on error
 *
 * @see DataDictionary#getRoleDefinitionDescriptor
 */
public RoleGrantDescriptor getRoleDefinitionDescriptor(String roleName) throws StandardException {
    DataValueDescriptor roleNameOrderable;
    DataValueDescriptor isDefOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSROLES_CATALOG_NUM);
    /* Use aliasNameOrderable , isDefOrderable in both start
		 * and stop position for scan.
		 */
    roleNameOrderable = new SQLVarchar(roleName);
    isDefOrderable = new SQLVarchar("Y");
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(2);
    keyRow.setColumn(1, roleNameOrderable);
    keyRow.setColumn(2, isDefOrderable);
    return getDescriptorViaIndex(SYSROLESRowFactory.SYSROLES_INDEX_ID_DEF_IDX, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, RoleGrantDescriptor.class, false);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 35 with DataValueDescriptor

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

the class DataDictionaryImpl method dropSubCheckConstraint.

/**
 * Drop the matching row from syschecks when dropping a check constraint.
 *
 * @param constraintId	The constraint id.
 * @param tc			The TransactionController
 *
 * @exception StandardException		Thrown on failure
 */
private void dropSubCheckConstraint(UUID constraintId, TransactionController tc) throws StandardException {
    ExecIndexRow checkRow1 = null;
    DataValueDescriptor constraintIdOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSCHECKS_CATALOG_NUM);
    /* Use constraintIdOrderable in both start 
		 * and stop position for index 1 scan. 
		 */
    constraintIdOrderable = getIDValueAsCHAR(constraintId);
    /* Set up the start/stop position for the scan */
    checkRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
    checkRow1.setColumn(1, constraintIdOrderable);
    ti.deleteRow(tc, checkRow1, SYSCHECKSRowFactory.SYSCHECKS_INDEX1_ID);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Aggregations

DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)328 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)72 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)62 RowLocation (org.apache.derby.iapi.types.RowLocation)54 SQLLongint (org.apache.derby.iapi.types.SQLLongint)51 StandardException (org.apache.derby.shared.common.error.StandardException)43 SQLChar (org.apache.derby.iapi.types.SQLChar)42 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)36 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)36 ScanController (org.apache.derby.iapi.store.access.ScanController)35 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)32 UUID (org.apache.derby.catalog.UUID)31 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)24 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)16 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)15 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)15 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)15 Properties (java.util.Properties)14 UserType (org.apache.derby.iapi.types.UserType)13 Page (org.apache.derby.iapi.store.raw.Page)11