Search in sources :

Example 1 with RawTransaction

use of org.apache.derby.iapi.store.raw.xact.RawTransaction in project derby by apache.

the class BasePage method updateAtSlot.

/**
 * @see Page#updateAtSlot
 *		@exception StandardException	Standard Derby error policy
 *		@exception StandardException	StandardException.newException(SQLState.UPDATE_DELETED_RECORD
 *		if the record is already deleted
 *		@exception StandardException	StandardException.newException(SQLState.CONTAINER_READ_ONLY
 *		if the container is read only
 */
public final RecordHandle updateAtSlot(int slot, Object[] row, FormatableBitSet validColumns) throws StandardException {
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(isLatched());
    }
    if (!owner.updateOK()) {
        throw StandardException.newException(SQLState.DATA_CONTAINER_READ_ONLY);
    }
    if (isDeletedAtSlot(slot)) {
        throw StandardException.newException(SQLState.DATA_UPDATE_DELETED_RECORD);
    }
    RecordHandle handle = getRecordHandleAtSlot(slot);
    RawTransaction t = owner.getTransaction();
    doUpdateAtSlot(t, slot, handle.getId(), row, validColumns);
    return handle;
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) RecordHandle(org.apache.derby.iapi.store.raw.RecordHandle)

Example 2 with RawTransaction

use of org.apache.derby.iapi.store.raw.xact.RawTransaction in project derby by apache.

the class BasePage method updateFieldAtSlot.

/**
 * @see Page#updateFieldAtSlot
 *		@exception StandardException	Standard Derby error policy
 *		@exception StandardException	StandardException.newException(SQLState.UPDATE_DELETED_RECORD
 *		if the record is already deleted
 *		@exception StandardException	StandardException.newException(SQLState.CONTAINER_READ_ONLY
 *		if the container is read only
 */
public RecordHandle updateFieldAtSlot(int slot, int fieldId, Object newValue, LogicalUndo undo) throws StandardException {
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(isLatched());
        SanityManager.ASSERT(newValue != null);
    }
    if (!owner.updateOK()) {
        throw StandardException.newException(SQLState.DATA_CONTAINER_READ_ONLY);
    }
    if (isDeletedAtSlot(slot)) {
        throw StandardException.newException(SQLState.DATA_UPDATE_DELETED_RECORD);
    }
    RawTransaction t = owner.getTransaction();
    RecordHandle handle = getRecordHandleAtSlot(slot);
    owner.getActionSet().actionUpdateField(t, this, slot, handle.getId(), fieldId, newValue, undo);
    return handle;
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) RecordHandle(org.apache.derby.iapi.store.raw.RecordHandle)

Example 3 with RawTransaction

use of org.apache.derby.iapi.store.raw.xact.RawTransaction in project derby by apache.

the class BasePage method deleteAtSlot.

/**
 *		@see Page#deleteAtSlot
 *
 *		@param slot		the slot number
 *		@param delete	true if this record is to be deleted, false if this
 *						deleted record is to be marked undeleted
 *		@param undo		logical undo logic if necessary
 *
 *		@exception StandardException Standard exception policy.
 *		@exception StandardException	StandardException.newException(SQLState.UPDATE_DELETED_RECORD
 *		if an attempt to delete a record that is already deleted
 *		@exception StandardException	StandardException.newException(SQLState.UNDELETE_RECORD
 *		if an attempt to undelete a record that is not deleted
 */
public RecordHandle deleteAtSlot(int slot, boolean delete, LogicalUndo undo) throws StandardException {
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(isLatched());
    }
    if (!owner.updateOK()) {
        throw StandardException.newException(SQLState.DATA_CONTAINER_READ_ONLY);
    }
    if (delete) {
        if (isDeletedAtSlot(slot)) {
            throw StandardException.newException(SQLState.DATA_UPDATE_DELETED_RECORD);
        }
    } else // undelete a deleted record
    {
        if (!isDeletedAtSlot(slot)) {
            throw StandardException.newException(SQLState.DATA_UNDELETE_RECORD);
        }
    }
    RawTransaction t = owner.getTransaction();
    // logical operations not allowed in internal transactions.
    if (undo != null) {
        t.checkLogicalOperationOk();
    }
    RecordHandle handle = getRecordHandleAtSlot(slot);
    owner.getActionSet().actionDelete(t, this, slot, handle.getId(), delete, undo);
    return handle;
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) RecordHandle(org.apache.derby.iapi.store.raw.RecordHandle)

Example 4 with RawTransaction

use of org.apache.derby.iapi.store.raw.xact.RawTransaction in project derby by apache.

the class BasePage method copyAndPurge.

/**
 * @see Page#copyAndPurge
 *		@exception StandardException Standard exception policy.
 */
public void copyAndPurge(Page destPage, int src_slot, int num_rows, int dest_slot) throws StandardException {
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(isLatched());
    }
    if (num_rows <= 0) {
        throw StandardException.newException(SQLState.DATA_NO_ROW_COPIED);
    }
    if (!owner.updateOK()) {
        throw StandardException.newException(SQLState.DATA_CONTAINER_READ_ONLY);
    }
    if ((src_slot < 0) || ((src_slot + num_rows) > recordCount)) {
        throw StandardException.newException(SQLState.DATA_SLOT_NOT_ON_PAGE);
    }
    if (SanityManager.DEBUG) {
        // first copy into the destination page, let it do the work
        // if no problem, then purge from this page
        SanityManager.ASSERT((destPage instanceof BasePage), "must copy from BasePage to BasePage");
    }
    BasePage dpage = (BasePage) destPage;
    // make sure they are from the same container - this means they are of
    // the same size and have the same page and record format.
    // RESOLVE: MT problem ?
    PageKey pageId = getPageId();
    if (!pageId.getContainerId().equals(dpage.getPageId().getContainerId())) {
        throw StandardException.newException(SQLState.DATA_DIFFERENT_CONTAINER, pageId.getContainerId(), dpage.getPageId().getContainerId());
    }
    int[] recordIds = new int[num_rows];
    RawTransaction t = owner.getTransaction();
    // lock the records to be purged and calculate total space needed
    for (int i = 0; i < num_rows; i++) {
        RecordHandle handle = getRecordHandleAtSlot(src_slot + i);
        owner.getLockingPolicy().lockRecordForWrite(t, handle, false, true);
        recordIds[i] = getHeaderAtSlot(src_slot + i).getId();
    }
    // first copy num_rows into destination page
    dpage.copyInto(this, src_slot, num_rows, dest_slot);
    // Now purge num_rows from this page
    // Do NOT purge overflow rows, if it has such a thing.  This operation
    // is called by split and if the key has overflow, spliting the head
    // page does not copy over the remaining pieces, i.e.,the new head page
    // still points to those pieces.
    owner.getActionSet().actionPurge(t, this, src_slot, num_rows, recordIds, true);
}
Also used : PageKey(org.apache.derby.iapi.store.raw.PageKey) RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) RecordHandle(org.apache.derby.iapi.store.raw.RecordHandle)

Example 5 with RawTransaction

use of org.apache.derby.iapi.store.raw.xact.RawTransaction in project derby by apache.

the class BasePage method initPage.

/**
 *		Mark this page as being allocated and initialize it to a pristine page
 *		@exception StandardException Derby Standard error policy
 */
public void initPage(int initFlag, long pageOffset) throws StandardException {
    if (SanityManager.DEBUG) {
        SanityManager.ASSERT(isLatched());
    }
    if (!owner.updateOK()) {
        throw StandardException.newException(SQLState.DATA_CONTAINER_READ_ONLY);
    }
    RawTransaction t = owner.getTransaction();
    owner.getActionSet().actionInitPage(t, this, initFlag, getTypeFormatId(), pageOffset);
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction)

Aggregations

RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)40 RecordHandle (org.apache.derby.iapi.store.raw.RecordHandle)10 LockingPolicy (org.apache.derby.iapi.store.raw.LockingPolicy)6 PageKey (org.apache.derby.iapi.store.raw.PageKey)6 StandardException (org.apache.derby.shared.common.error.StandardException)6 ContextManager (org.apache.derby.iapi.services.context.ContextManager)5 StorageFile (org.apache.derby.io.StorageFile)5 IOException (java.io.IOException)4 DynamicByteArrayOutputStream (org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream)3 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)3 Serviceable (org.apache.derby.iapi.services.daemon.Serviceable)2 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)2 CompatibilitySpace (org.apache.derby.iapi.services.locks.CompatibilitySpace)2 LogicalUndo (org.apache.derby.iapi.store.access.conglomerate.LogicalUndo)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Properties (java.util.Properties)1