use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class BasicDatabase method setupConnection.
public LanguageConnectionContext setupConnection(ContextManager cm, String user, String drdaID, String dbname) throws StandardException {
TransactionController tc = getConnectionTransaction(cm);
cm.setLocaleFinder(this);
pushDbContext(cm);
// push a database shutdown context
// we also need to push a language connection context.
LanguageConnectionContext lctx = lcf.newLanguageConnectionContext(cm, tc, lf, this, user, drdaID, dbname);
// push the context that defines our class factory
pushClassFactoryContext(cm, lcf.getClassFactory());
// we also need to push an execution context.
ExecutionFactory ef = lcf.getExecutionFactory();
ef.newExecutionContext(cm);
//
// Initialize our language connection context. Note: This is
// a bit of a hack. Unfortunately, we can't initialize this
// when we push it. We first must push a few more contexts.
lctx.initialize();
// Need to commit this to release locks gotten in initialize.
// Commit it but make sure transaction not have any updates.
lctx.internalCommitNoSync(TransactionController.RELEASE_LOCKS | TransactionController.READONLY_TRANSACTION_INITIALIZATION);
return lctx;
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class EmbedXAResource method getDefaultXATransactionTimeout.
/**
* Returns the default value for the transaction timeout in milliseconds
* setted up by the system properties.
*/
private long getDefaultXATransactionTimeout() throws XAException {
try {
LanguageConnectionContext lcc = getLanguageConnectionContext(con);
TransactionController tc = lcc.getTransactionExecute();
long timeoutMillis = 1000 * (long) PropertyUtil.getServiceInt(tc, Property.PROP_XA_TRANSACTION_TIMEOUT, 0, Integer.MAX_VALUE, Property.DEFAULT_XA_TRANSACTION_TIMEOUT);
return timeoutMillis;
} catch (SQLException sqle) {
throw wrapInXAException(sqle);
} catch (StandardException se) {
throw wrapInXAException(se);
}
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class DataDictionaryImpl method getPermissionsCache.
private CacheManager getPermissionsCache() throws StandardException {
if (permissionsCache == null) {
CacheFactory cf = (CacheFactory) startSystemModule(org.apache.derby.shared.common.reference.Module.CacheFactory);
LanguageConnectionContext lcc = getLCC();
TransactionController tc = lcc.getTransactionExecute();
permissionsCacheSize = PropertyUtil.getServiceInt(tc, Property.LANG_PERMISSIONS_CACHE_SIZE, 40, /* min value */
Integer.MAX_VALUE, permissionsCacheSize);
permissionsCache = cf.newCacheManager(this, "PermissionsCache", permissionsCacheSize, permissionsCacheSize);
}
return permissionsCache;
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class DataDictionaryImpl method getDescriptorViaHeap.
/**
* Return a (single or list of) catalog row descriptor(s) from a
* system table where the access a heap scan
*
* @param columns which columns to fetch from the system
* table, or null to fetch all columns
* @param scanQualifiers qualifiers
* @param ti The TabInfoImpl to use
* @param parentTupleDescriptor The parentDescriptor, if applicable.
* @param list The list to build, if supplied.
* If null, then caller expects a single descriptor
* @param returnType The type of descriptor to look for
*
* @return The last matching descriptor
*
* @exception StandardException Thrown on error
*/
protected <T extends TupleDescriptor> T getDescriptorViaHeap(FormatableBitSet columns, ScanQualifier[][] scanQualifiers, TabInfoImpl ti, TupleDescriptor parentTupleDescriptor, List<? super T> list, Class<T> returnType) throws StandardException {
CatalogRowFactory rf = ti.getCatalogRowFactory();
ExecRow outRow;
ScanController scanController;
TransactionController tc;
T td = null;
// Get the current transaction controller
tc = getTransactionCompile();
outRow = rf.makeEmptyRow();
/*
** Table scan
*/
scanController = tc.openScan(// conglomerate to open
ti.getHeapConglomerate(), // don't hold open across commit
false, // for read
0, TransactionController.MODE_TABLE, TransactionController.ISOLATION_REPEATABLE_READ, columns, // start position - first row
(DataValueDescriptor[]) null, // startSearchOperation - none
0, // scanQualifier,
scanQualifiers, // stop position - through last row
(DataValueDescriptor[]) null, // stopSearchOperation - none
0);
while (scanController.fetchNext(outRow.getRowArray())) {
td = returnType.cast(rf.buildDescriptor(outRow, parentTupleDescriptor, this));
/* If dList is null, then caller only wants a single descriptor - we're done
* else just add the current descriptor to the list.
*/
if (list == null) {
break;
} else {
list.add(td);
}
}
scanController.close();
return td;
}
use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.
the class DataDictionaryImpl method clearSPSPlans.
/**
* Mark all SPS plans in the data dictionary invalid. This does
* not invalidate cached plans. This function is for use by
* the boot-up code.
* @exception StandardException Thrown on error
*/
void clearSPSPlans() throws StandardException {
TabInfoImpl ti = getNonCoreTI(SYSSTATEMENTS_CATALOG_NUM);
faultInTabInfo(ti);
TransactionController tc = getTransactionExecute();
FormatableBitSet columnToReadSet = new FormatableBitSet(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_COLUMN_COUNT);
FormatableBitSet columnToUpdateSet = new FormatableBitSet(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_COLUMN_COUNT);
columnToUpdateSet.set(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_VALID - 1);
columnToUpdateSet.set(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_CONSTANTSTATE - 1);
DataValueDescriptor[] replaceRow = new DataValueDescriptor[SYSSTATEMENTSRowFactory.SYSSTATEMENTS_COLUMN_COUNT];
/* Set up a couple of row templates for fetching CHARS */
replaceRow[SYSSTATEMENTSRowFactory.SYSSTATEMENTS_VALID - 1] = new SQLBoolean(false);
replaceRow[SYSSTATEMENTSRowFactory.SYSSTATEMENTS_CONSTANTSTATE - 1] = new UserType((Object) null);
/* Scan the entire heap */
ScanController sc = tc.openScan(ti.getHeapConglomerate(), false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_REPEATABLE_READ, columnToReadSet, (DataValueDescriptor[]) null, ScanController.NA, (Qualifier[][]) null, (DataValueDescriptor[]) null, ScanController.NA);
while (sc.fetchNext((DataValueDescriptor[]) null)) {
/* Replace the column in the table */
sc.replace(replaceRow, columnToUpdateSet);
}
sc.close();
}
Aggregations