Search in sources :

Example 1 with XPLAINVisitor

use of org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor in project derby by apache.

the class NoPutResultSetImpl method close.

/**
 *		Close needs to invalidate any dependent statements, if this is a cursor.
 *		Must be called by any subclasses that override close().
 *		@exception StandardException on error
 */
public void close() throws StandardException {
    if (!isOpen)
        return;
    /* If this is the top ResultSet then we must
		 * close all of the open subqueries for the
		 * entire query.
		 */
    if (isTopResultSet) {
        /*
			** If run time statistics tracing is turned on, then now is the
			** time to dump out the information.
			*/
        LanguageConnectionContext lcc = getLanguageConnectionContext();
        // only if statistics is switched on, collect & derive them
        if (lcc.getRunTimeStatisticsMode() && !lcc.getStatementContext().getStatementWasInvalidated()) {
            endExecutionTime = getCurrentTimeMillis();
            // get the ResultSetStatisticsFactory, which gathers RuntimeStatistics
            ExecutionFactory ef = lcc.getLanguageConnectionFactory().getExecutionFactory();
            ResultSetStatisticsFactory rssf;
            rssf = ef.getResultSetStatisticsFactory();
            // get the RuntimeStatisticsImpl object which is the wrapper for all
            // gathered statistics about all the different resultsets
            RunTimeStatistics rsImpl = rssf.getRunTimeStatistics(activation, this, subqueryTrackingArray);
            // save the RTW (wrapper)object in the lcc
            lcc.setRunTimeStatisticsObject(rsImpl);
            // now explain gathered statistics, using an appropriate visitor
            XPLAINVisitor visitor = ef.getXPLAINFactory().getXPLAINVisitor();
            visitor.doXPLAIN(rsImpl, activation);
        }
        int staLength = (subqueryTrackingArray == null) ? 0 : subqueryTrackingArray.length;
        for (int index = 0; index < staLength; index++) {
            if (subqueryTrackingArray[index] == null) {
                continue;
            }
            if (subqueryTrackingArray[index].isClosed()) {
                continue;
            }
            subqueryTrackingArray[index].close();
        }
    }
    isOpen = false;
}
Also used : RunTimeStatistics(org.apache.derby.iapi.sql.execute.RunTimeStatistics) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) ResultSetStatisticsFactory(org.apache.derby.iapi.sql.execute.ResultSetStatisticsFactory) ExecutionFactory(org.apache.derby.iapi.sql.execute.ExecutionFactory) XPLAINVisitor(org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor)

Aggregations

LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)1 ExecutionFactory (org.apache.derby.iapi.sql.execute.ExecutionFactory)1 ResultSetStatisticsFactory (org.apache.derby.iapi.sql.execute.ResultSetStatisticsFactory)1 RunTimeStatistics (org.apache.derby.iapi.sql.execute.RunTimeStatistics)1 XPLAINVisitor (org.apache.derby.iapi.sql.execute.xplain.XPLAINVisitor)1