Search in sources :

Example 56 with ConglomerateController

use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.

the class StatementNode method lockTableForCompilation.

/* We need to get some kind of table lock (IX here) at the beginning of
	 * compilation of DMLModStatementNode and DDLStatementNode, to prevent the
	 * interference of insert/update/delete/DDL compilation and DDL execution,
	 * see beetle 3976, 4343, and $WS/language/SolutionsToConcurrencyIssues.txt
	 */
protected TableDescriptor lockTableForCompilation(TableDescriptor td) throws StandardException {
    DataDictionary dd = getDataDictionary();
    /* we need to lock only if the data dictionary is in DDL cache mode
		 */
    if (dd.getCacheMode() == DataDictionary.DDL_MODE) {
        ConglomerateController heapCC;
        TransactionController tc = getLanguageConnectionContext().getTransactionCompile();
        heapCC = tc.openConglomerate(td.getHeapConglomerateId(), false, TransactionController.OPENMODE_FORUPDATE | TransactionController.OPENMODE_FOR_LOCK_ONLY, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
        heapCC.close();
        /*
			** Need to get TableDescriptor again after getting the lock, in
			** case for example, a concurrent add column thread commits
			** while we are binding.
			*/
        String tableName = td.getName();
        td = getTableDescriptor(td.getName(), getSchemaDescriptor(td.getSchemaName()));
        if (td == null) {
            throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, tableName);
        }
    }
    return td;
}
Also used : ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 57 with ConglomerateController

use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.

the class ResultColumnList method newRowLocationTemplate.

/**
 * Create a row location template of the right type for the source
 * conglomerate.
 */
private RowLocation newRowLocationTemplate() throws StandardException {
    LanguageConnectionContext lcc = getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    int isolationLevel = (dd.getCacheMode() == DataDictionary.DDL_MODE) ? TransactionController.ISOLATION_READ_COMMITTED : TransactionController.ISOLATION_NOLOCK;
    ConglomerateController cc = lcc.getTransactionCompile().openConglomerate(conglomerateId, false, 0, TransactionController.MODE_RECORD, isolationLevel);
    try {
        return cc.newRowLocationTemplate();
    } finally {
        cc.close();
    }
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary)

Example 58 with ConglomerateController

use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.

the class ConglomInfo method getSpaceInfo.

private void getSpaceInfo(int index) throws StandardException {
    ConglomerateController cc = tc.openConglomerate(conglomTable[index].getConglomId(), false, // not for update
    0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_READ_COMMITTED);
    spaceInfo = cc.getSpaceInfo();
    cc.close();
    cc = null;
}
Also used : ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController)

Example 59 with ConglomerateController

use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.

the class TabInfoImpl method getRow.

/**
 * Given a key row, return the first matching heap row.
 * <p>
 * LOCKING: shared row locking.
 *
 * @param  tc          transaction controller
 * @param  key         key to read by.
 * @param  indexNumber Key is appropriate for this index.
 * @exception StandardException        Thrown on failure
 */
ExecRow getRow(TransactionController tc, ExecIndexRow key, int indexNumber) throws StandardException {
    ConglomerateController heapCC;
    /* Open the heap conglomerate */
    heapCC = tc.openConglomerate(getHeapConglomerate(), false, // for read only
    0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
    try {
        return getRow(tc, heapCC, key, indexNumber);
    } finally {
        heapCC.close();
    }
}
Also used : ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController)

Example 60 with ConglomerateController

use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.

the class TabInfoImpl method getRowLocation.

/**
 * Given an index row and index number return the RowLocation
 * in the heap of the first matching row.
 * Used by the autoincrement code to get the RowLocation in
 * syscolumns given a &lt;tablename, columname&gt; pair.
 *
 * @see DataDictionaryImpl#computeRowLocation(TransactionController, TableDescriptor, String)
 *
 * @param tc		  Transaction Controller to use.
 * @param key		  Index Row to search in the index.
 * @param indexNumber Identifies the index to use.
 *
 * @exception		  StandardException thrown on failure.
 */
RowLocation getRowLocation(TransactionController tc, ExecIndexRow key, int indexNumber) throws StandardException {
    ConglomerateController heapCC;
    heapCC = tc.openConglomerate(getHeapConglomerate(), false, // for read only
    0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
    try {
        RowLocation[] rl = new RowLocation[1];
        ExecRow notUsed = getRowInternal(tc, heapCC, key, indexNumber, rl);
        return rl[0];
    } finally {
        heapCC.close();
    }
}
Also used : ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) RowLocation(org.apache.derby.iapi.types.RowLocation)

Aggregations

ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)73 RowLocation (org.apache.derby.iapi.types.RowLocation)40 ScanController (org.apache.derby.iapi.store.access.ScanController)32 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)32 SQLLongint (org.apache.derby.iapi.types.SQLLongint)24 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)22 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)18 Properties (java.util.Properties)14 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)14 StandardException (org.apache.derby.shared.common.error.StandardException)12 TransactionController (org.apache.derby.iapi.store.access.TransactionController)11 SQLChar (org.apache.derby.iapi.types.SQLChar)9 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)8 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)6 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)5 ColumnOrdering (org.apache.derby.iapi.store.access.ColumnOrdering)5 UUID (org.apache.derby.catalog.UUID)4 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)4 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)4 IndexRowGenerator (org.apache.derby.iapi.sql.dictionary.IndexRowGenerator)4