Search in sources :

Example 31 with LanguageConnectionContext

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

Example 32 with LanguageConnectionContext

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

Example 33 with LanguageConnectionContext

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);
}
Also used : GeneratedClass(org.apache.derby.iapi.services.loader.GeneratedClass) ClassFactory(org.apache.derby.iapi.services.loader.ClassFactory) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext)

Example 34 with LanguageConnectionContext

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);
    }
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) CompilerContext(org.apache.derby.iapi.sql.compile.CompilerContext) Parser(org.apache.derby.iapi.sql.compile.Parser)

Example 35 with LanguageConnectionContext

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;
}
Also used : LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) CompilerContext(org.apache.derby.iapi.sql.compile.CompilerContext) Visitable(org.apache.derby.iapi.sql.compile.Visitable) Parser(org.apache.derby.iapi.sql.compile.Parser)

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