use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class DataDictionaryImpl method debugGenerateInfo.
private void debugGenerateInfo(StringBuffer strbuf, TransactionController tc, ConglomerateController heapCC, TabInfoImpl ti, int indexId) {
if (SanityManager.DEBUG) {
try {
strbuf.append("\nadditional information: ");
// print the lock table
// will get a NullPointerException if lcc doesn't yet exist e.g. at boot time
LanguageConnectionContext lcc = (LanguageConnectionContext) getContext(LanguageConnectionContext.CONTEXT_ID);
if (lcc != null) {
long currentTime = System.currentTimeMillis();
// EXCLUDE-START-lockdiag-
Enumeration lockTable = lockFactory.makeVirtualLockTable();
String lockTableString = Timeout.buildString(lockTable, currentTime);
strbuf.append("lock table at time of failure\n\n");
strbuf.append(lockTableString);
// EXCLUDE-END-lockdiag-
}
// consistency checking etc.
ConglomerateController btreeCC = tc.openConglomerate(ti.getIndexConglomerate(indexId), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
btreeCC.debugConglomerate();
heapCC.debugConglomerate();
heapCC.checkConsistency();
strbuf.append("\nheapCC.checkConsistency() = true");
ConglomerateController indexCC = tc.openConglomerate(ti.getIndexConglomerate(indexId), false, 0, TransactionController.MODE_TABLE, TransactionController.ISOLATION_REPEATABLE_READ);
indexCC.checkConsistency();
strbuf.append("\nindexCC.checkConsistency() = true");
System.err.println("ASSERT FAILURE: " + strbuf.toString());
System.out.println("ASSERT FAILURE: " + strbuf.toString());
SanityManager.DEBUG_PRINT("ASSERT FAILURE", strbuf.toString());
} catch (StandardException se) {
strbuf.append("\ngot the following error when doing extra consistency checks:\n" + se.toString());
}
}
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class DataDictionaryImpl method invalidateAllSPSPlans.
/**
* @see DataDictionary#invalidateAllSPSPlans
* @exception StandardException Thrown on error
*/
public void invalidateAllSPSPlans() throws StandardException {
LanguageConnectionContext lcc = (LanguageConnectionContext) getContext(LanguageConnectionContext.CONTEXT_ID);
invalidateAllSPSPlans(lcc);
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class GenericStorablePreparedStatement method loadGeneratedClass.
// ///////////////////////////////////////////////////////////
//
// STORABLEPREPAREDSTATEMENT INTERFACE
//
// ///////////////////////////////////////////////////////////
/**
* Load up the class from the saved bytes.
*
* @exception StandardException on error
*/
public void loadGeneratedClass() throws StandardException {
LanguageConnectionContext lcc = (LanguageConnectionContext) getContext(LanguageConnectionContext.CONTEXT_ID);
ClassFactory classFactory = lcc.getLanguageConnectionFactory().getClassFactory();
GeneratedClass gc = classFactory.loadGeneratedClass(className, byteCode);
/*
** No special try catch logic to write out bad classes
** here. We don't expect any problems, and in any
** event, we don't have the class builder available
** here.
*/
setActivationClass(gc);
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class QueryTreeNode method parseStatementOrSearchCondition.
/**
* Parse a full SQL statement or a fragment representing a {@code <search
* condition>}. This is a worker method that contains common logic for
* {@link #parseStatement} and {@link #parseSearchCondition}.
*
* @param sql the SQL statement or fragment to parse
* @param internalSQL {@code true} if it is allowed to contain internal
* syntax, {@code false} otherwise
* @param isStatement {@code true} if {@code sql} is a full SQL statement,
* {@code false} if it is a fragment
* @return a parse tree
* @throws StandardException if an error happens while parsing
*/
private Visitable parseStatementOrSearchCondition(String sql, boolean internalSQL, boolean isStatement) throws StandardException {
/*
** Get a new compiler context, so the parsing of the text
** doesn't mess up anything in the current context
*/
LanguageConnectionContext lcc = getLanguageConnectionContext();
CompilerContext newCC = lcc.pushCompilerContext();
if (internalSQL)
newCC.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);
try {
Parser p = newCC.getParser();
return isStatement ? p.parseStatement(sql) : p.parseSearchCondition(sql);
} finally {
lcc.popCompilerContext(newCC);
}
}
use of org.apache.derby.iapi.sql.conn.LanguageConnectionContext in project derby by apache.
the class ResultSetNode method parseDefault.
/**
* Parse a default and turn it into a query tree.
*
* @param defaultText Text of Default.
*
* @return The parsed default as a query tree.
*
* @exception StandardException Thrown on failure
*/
public ValueNode parseDefault(String defaultText) throws StandardException {
Parser p;
ValueNode defaultTree;
LanguageConnectionContext lcc = getLanguageConnectionContext();
/* Get a Statement to pass to the parser */
/* We're all set up to parse. We have to build a compilable SQL statement
* before we can parse - So, we goober up a VALUES defaultText.
*/
String values = "VALUES " + defaultText;
/*
** Get a new compiler context, so the parsing of the select statement
** doesn't mess up anything in the current context (it could clobber
** the ParameterValueSet, for example).
*/
CompilerContext newCC = lcc.pushCompilerContext();
p = newCC.getParser();
/* Finally, we can call the parser */
// Since this is always nested inside another SQL statement, so topLevel flag
// should be false
Visitable qt = p.parseStatement(values);
if (SanityManager.DEBUG) {
if (!(qt instanceof CursorNode)) {
SanityManager.THROWASSERT("qt expected to be instanceof CursorNode, not " + qt.getClass().getName());
}
CursorNode cn = (CursorNode) qt;
if (!(cn.getResultSetNode() instanceof RowResultSetNode)) {
SanityManager.THROWASSERT("cn.getResultSetNode() expected to be instanceof RowResultSetNode, not " + cn.getResultSetNode().getClass().getName());
}
}
defaultTree = ((CursorNode) qt).getResultSetNode().getResultColumns().elementAt(0).getExpression();
lcc.popCompilerContext(newCC);
return defaultTree;
}
Aggregations