Search in sources :

Example 16 with TransactionController

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;
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) ExecutionFactory(org.apache.derby.iapi.sql.execute.ExecutionFactory) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 17 with TransactionController

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);
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) SQLException(java.sql.SQLException) TransactionController(org.apache.derby.iapi.store.access.TransactionController) XATransactionController(org.apache.derby.iapi.store.access.XATransactionController)

Example 18 with TransactionController

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;
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) CacheFactory(org.apache.derby.iapi.services.cache.CacheFactory) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 19 with TransactionController

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;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) CatalogRowFactory(org.apache.derby.iapi.sql.dictionary.CatalogRowFactory) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 20 with TransactionController

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();
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) TransactionController(org.apache.derby.iapi.store.access.TransactionController) UserType(org.apache.derby.iapi.types.UserType) SQLBoolean(org.apache.derby.iapi.types.SQLBoolean)

Aggregations

TransactionController (org.apache.derby.iapi.store.access.TransactionController)124 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)47 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)40 StandardException (org.apache.derby.shared.common.error.StandardException)26 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)23 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)20 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)20 UUID (org.apache.derby.catalog.UUID)14 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)13 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)12 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)12 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)12 Properties (java.util.Properties)11 AccessFactory (org.apache.derby.iapi.store.access.AccessFactory)11 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)11 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 XATransactionController (org.apache.derby.iapi.store.access.XATransactionController)9 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)8 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)8 ScanController (org.apache.derby.iapi.store.access.ScanController)8