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;
}
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();
}
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);
}
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;
}
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();
}
}
Aggregations