if ((mode & ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY) != 0)
{
// Open a container for lock only, we don't care if it exists, is
// deleted or anything about it. The container handle we return is
// closed and cannot be used for fetch or update etc.
BaseContainerHandle lockOnlyHandle =
new BaseContainerHandle(
getIdentifier(), t, identity, locking, mode);
if (lockOnlyHandle.useContainer(true, waitForLock))
return lockOnlyHandle;
else
return null;
}
BaseContainerHandle c;
// see if the container exists
FileContainer container = (FileContainer) containerCache.find(identity);
if (container == null)
return null;
if (identity.getSegmentId() == ContainerHandle.TEMPORARY_SEGMENT)
{
if (SanityManager.DEBUG)
{
SanityManager.ASSERT(container instanceof TempRAFContainer);
}
if ((mode & ContainerHandle.MODE_TEMP_IS_KEPT) ==
ContainerHandle.MODE_TEMP_IS_KEPT)
{
// if the mode is kept, then, we do not want to truncate
mode |= ContainerHandle.MODE_UNLOGGED;
}
else
{
// this should be OK even if the table was opened read-only
mode |=
(ContainerHandle.MODE_UNLOGGED |
ContainerHandle.MODE_TRUNCATE_ON_ROLLBACK);
}
locking =
t.newLockingPolicy(
LockingPolicy.MODE_NONE,
TransactionController.ISOLATION_NOLOCK, true);
}
else
{
// real tables
if (inCreateNoLog)
{
mode |=
(ContainerHandle.MODE_UNLOGGED |
ContainerHandle.MODE_CREATE_UNLOGGED);
} else {
// make sure everything is logged if logArchived is turn on
// clear all UNLOGGED flag
if (logFactory.logArchived() ||
logFactory.inReplicationMasterMode()) {
mode &= ~(ContainerHandle.MODE_UNLOGGED |
ContainerHandle.MODE_CREATE_UNLOGGED);
} else {
// block the online backup if the container is being
// opened in unlogged mode, if the backup is already
// running then convert all unlogged opens to logged ones,
// otherwise online backup copy will be inconsistent.
if (((mode & ContainerHandle.MODE_UNLOGGED) ==
ContainerHandle.MODE_UNLOGGED) ||
((mode & ContainerHandle.MODE_CREATE_UNLOGGED) ==
ContainerHandle.MODE_CREATE_UNLOGGED))
{
if (!t.blockBackup(false)) {
// when a backup is in progress transaction can not
// block the backup, so convert unlogged opens
// to logged mode.
mode &= ~(ContainerHandle.MODE_UNLOGGED |
ContainerHandle.MODE_CREATE_UNLOGGED);
}
}
}
}
// if mode is UNLOGGED but not CREATE_UNLOGGED, then force the
// container from cache when the transaction commits. For
// CREATE_UNLOGGED, client has the responsibility of forcing the
// cache.
if (((mode & ContainerHandle.MODE_UNLOGGED) ==
ContainerHandle.MODE_UNLOGGED) &&
((mode & ContainerHandle.MODE_CREATE_UNLOGGED) == 0))
{
mode |= ContainerHandle.MODE_FLUSH_ON_COMMIT;
}
}
PageActions pageActions = null;
AllocationActions allocActions = null;
if ((mode & ContainerHandle.MODE_FORUPDATE) ==
ContainerHandle.MODE_FORUPDATE)
{
if ((mode & ContainerHandle.MODE_UNLOGGED) == 0)
{
// get the current loggable actions
pageActions = getLoggablePageActions();
allocActions = getLoggableAllocationActions();
}
else
{
// unlogged
pageActions = new DirectActions();
allocActions = new DirectAllocActions();
}
}
c = new BaseContainerHandle(
getIdentifier(), t, pageActions,
allocActions, locking, container, mode);
// see if we can use the container
try
{
if (!c.useContainer(droppedOK, waitForLock))
{
containerCache.release(container);
return null;
}
}