Search in sources :

Example 76 with LanguageConnectionContext

use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.

the class T_ConsistencyChecker method countOpens.

/**
 * Check to make sure that there are no open conglomerates, scans or sorts.
 *
 * @return String       If an inconsistency is found, and if DEBUG is on,
 *                      then a string will be returned with more info.
 *                      If DEBUG is off, then a simple string will be
 *                      returned stating whether or not there are open scans.
 *
 * @exception StandardException     Thrown on error
 */
public static String countOpens() throws StandardException {
    int numOpens = 0;
    LanguageConnectionContext lcc;
    String output = "No open scans, etc.\n";
    TransactionController tc;
    lcc = (LanguageConnectionContext) getContext(LanguageConnectionContext.CONTEXT_ID);
    tc = lcc.getTransactionExecute();
    numOpens = tc.countOpens(TransactionController.OPEN_TOTAL);
    if (numOpens > 0) {
        output = numOpens + " conglomerates/scans/sorts found open\n";
    }
    return output;
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 77 with LanguageConnectionContext

use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.

the class T_ConsistencyChecker method countDependencies.

/**
 * Check to make sure that there are no active dependencies (stored or
 * in memory).
 *
 * @return String       If an inconsistency is found, and if DEBUG is on,
 *                      then a string will be returned with more info.
 *                      If DEBUG is off, then a simple string will be
 *                      returned stating whether or not there are open scans.
 *
 * @exception StandardException     Thrown on error
 * @exception java.sql.SQLException     Thrown on error
 */
public static String countDependencies() throws StandardException, java.sql.SQLException {
    int numDependencies = 0;
    DataDictionary dd;
    DependencyManager dm;
    StringBuffer debugBuf = new StringBuffer();
    LanguageConnectionContext lcc = (LanguageConnectionContext) getContext(LanguageConnectionContext.CONTEXT_ID);
    dd = lcc.getDataDictionary();
    dm = dd.getDependencyManager();
    numDependencies = dm.countDependencies();
    if (numDependencies > 0) {
        debugBuf.append(numDependencies + " dependencies found");
    } else {
        debugBuf.append("No outstanding dependencies.\n");
    }
    return debugBuf.toString();
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) DependencyManager(org.apache.derby.iapi.sql.depend.DependencyManager) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary)

Example 78 with LanguageConnectionContext

use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.

the class PropertyUtil method setDatabasePropertyDefault.

public static void setDatabasePropertyDefault(String k, Serializable v) throws Exception {
    LanguageConnectionContext lcc = (LanguageConnectionContext) getContextOrNull(LanguageConnectionContext.CONTEXT_ID);
    if (lcc == null)
        throw new Exception("getPropertyDefault only works in a connection");
    lcc.getTransactionExecute().setPropertyDefault(k, v);
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext)

Example 79 with LanguageConnectionContext

use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.

the class TestPropertyInfo method getConglomerateProperties.

private static Properties getConglomerateProperties(String schemaName, String conglomerateName, boolean isIndex) throws java.sql.SQLException {
    ConglomerateController cc;
    ConglomerateDescriptor cd;
    DataDictionary dd;
    Properties properties;
    SchemaDescriptor sd;
    TableDescriptor td;
    TransactionController tc;
    long conglomerateNumber;
    // find the language context.
    LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
    // Get the current transaction controller
    tc = lcc.getTransactionExecute();
    try {
        // find the DataDictionary
        dd = lcc.getDataDictionary();
        // get the SchemaDescriptor
        sd = dd.getSchemaDescriptor(schemaName, tc, true);
        if (!isIndex) {
            // get the TableDescriptor for the table
            td = dd.getTableDescriptor(conglomerateName, sd, tc);
            // Return an empty Properties if table does not exist or if it is for a view.
            if ((td == null) || td.getTableType() == TableDescriptor.VIEW_TYPE) {
                return new Properties();
            }
            conglomerateNumber = td.getHeapConglomerateId();
        } else {
            // get the ConglomerateDescriptor for the index
            cd = dd.getConglomerateDescriptor(conglomerateName, sd, false);
            // Return an empty Properties if index does not exist
            if (cd == null) {
                return new Properties();
            }
            conglomerateNumber = cd.getConglomerateNumber();
        }
        cc = tc.openConglomerate(conglomerateNumber, false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
        properties = cc.getInternalTablePropertySet(new Properties());
        cc.close();
    } catch (StandardException se) {
        throw PublicAPI.wrapStandardException(se);
    }
    return properties;
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) SchemaDescriptor(org.apache.derby.iapi.sql.dictionary.SchemaDescriptor) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataDictionary(org.apache.derby.iapi.sql.dictionary.DataDictionary) Properties(java.util.Properties) TransactionController(org.apache.derby.iapi.store.access.TransactionController) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 80 with LanguageConnectionContext

use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.

the class InterruptStatus method restoreIntrFlagIfSeen.

/**
 * Same purpose as {@code restoreIntrFlagIfSeen()}. This variant presumes
 * we are sure we have a {@code lcc != null}, i.e. {@code
 * setupContextStack} has been called and not yet restored.  Note that we
 * cannot merge this code with {@code restoreContextStack}, since that is
 * typically called in a {@code finally} block, at which point in time, the
 * {@code lcc} may be gone due to errors of severity {@code
 * SESSION_SEVERITY} or {@code DATABASE_SEVERITY}.
 * <p/>
 * If no {@code lcc} is available, use the zero-arg variant. We only need
 * this variant for performance reasons.
 *
 * @param lcc the language connection context for this session
 */
public static void restoreIntrFlagIfSeen(LanguageConnectionContext lcc) {
    if (SanityManager.DEBUG) {
        LanguageConnectionContext ctxLcc = null;
        try {
            ctxLcc = (LanguageConnectionContext) getContextOrNull(LanguageConnectionContext.CONTEXT_ID);
            SanityManager.ASSERT(lcc == ctxLcc, "lcc=" + lcc + " getContextOrNull=" + ctxLcc);
        } catch (ShutdownException e) {
        // ignore
        }
    }
    if (lcc.getInterruptedException() != null) {
        lcc.setInterruptedException(null);
        // Set thread's interrupt status flag back on.
        Thread.currentThread().interrupt();
    }
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) ShutdownException(org.apache.derby.shared.common.error.ShutdownException)

Aggregations

LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)126 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)57 TransactionController (org.apache.derby.iapi.store.access.TransactionController)47 StandardException (org.apache.derby.shared.common.error.StandardException)36 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)20 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 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)13 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)11 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)7 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)7 RoleGrantDescriptor (org.apache.derby.iapi.sql.dictionary.RoleGrantDescriptor)7 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)6 SQLException (java.sql.SQLException)5 Iterator (java.util.Iterator)5 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)5 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)5 ArrayList (java.util.ArrayList)4