Search in sources :

Example 1 with XPLAINResultSetDescriptor

use of org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor in project derby by apache.

the class XPLAINSystemTableVisitor method addArraysToSystemCatalogs.

/**
 * This method writes the created descriptor arrays
 * to the cooresponding system catalogs.
 */
private void addArraysToSystemCatalogs() throws StandardException, SQLException {
    boolean statsSave = lcc.getRunTimeStatisticsMode();
    lcc.setRunTimeStatisticsMode(false);
    Connection conn = getDefaultConn();
    PreparedStatement ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_RESULTSETS"));
    Iterator<XPLAINResultSetDescriptor> rsetsiter = rsets.iterator();
    while (rsetsiter.hasNext()) {
        XPLAINResultSetDescriptor rset = rsetsiter.next();
        rset.setStatementParameters(ps);
        ps.executeUpdate();
    }
    ps.close();
    // add the resultset timings descriptors, if timing is on
    if (considerTimingInformation) {
        ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_RESULTSET_TIMINGS"));
        Iterator<Object> timingsiter = rsetsTimings.iterator();
        while (timingsiter.hasNext()) {
            XPLAINResultSetTimingsDescriptor rsetT = (XPLAINResultSetTimingsDescriptor) timingsiter.next();
            rsetT.setStatementParameters(ps);
            ps.executeUpdate();
        }
        ps.close();
    }
    ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_SCAN_PROPS"));
    Iterator<XPLAINScanPropsDescriptor> scaniter = scanrsets.iterator();
    while (scaniter.hasNext()) {
        XPLAINScanPropsDescriptor scanProps = scaniter.next();
        scanProps.setStatementParameters(ps);
        ps.executeUpdate();
    }
    ps.close();
    ps = conn.prepareStatement((String) lcc.getXplainStatement("SYSXPLAIN_SORT_PROPS"));
    Iterator<XPLAINSortPropsDescriptor> sortiter = sortrsets.iterator();
    while (sortiter.hasNext()) {
        XPLAINSortPropsDescriptor sortProps = sortiter.next();
        sortProps.setStatementParameters(ps);
        ps.executeUpdate();
    }
    ps.close();
    conn.close();
    lcc.setRunTimeStatisticsMode(statsSave);
}
Also used : XPLAINResultSetDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor) XPLAINScanPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) XPLAINResultSetTimingsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor) XPLAINSortPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor)

Example 2 with XPLAINResultSetDescriptor

use of org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor in project derby by apache.

the class SystemProcedures method SYSCS_SET_XPLAIN_SCHEMA.

/**
 * This procedure sets the current xplain schema.
 * If the schema is not set, runtime statistics are captured as a
 * textual stream printout. If it is set, statisitcs information is
 * stored in that schema in user tables.
 * @param schemaName May be an empty string.
 * @throws SQLException
 */
public static void SYSCS_SET_XPLAIN_SCHEMA(String schemaName) throws SQLException, StandardException {
    try {
        // make sure that application code doesn't bypass security checks
        // by calling this public entry point
        SecurityUtil.authorize(Securable.SET_XPLAIN_SCHEMA);
    } catch (StandardException se) {
        throw PublicAPI.wrapStandardException(se);
    }
    LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
    TransactionController tc = lcc.getTransactionExecute();
    if (schemaName == null || schemaName.trim().length() == 0) {
        lcc.setXplainSchema(null);
        return;
    }
    boolean statsSave = lcc.getRunTimeStatisticsMode();
    lcc.setRunTimeStatisticsMode(false);
    createXplainSchema(schemaName);
    createXplainTable(lcc, schemaName, new XPLAINStatementDescriptor());
    createXplainTable(lcc, schemaName, new XPLAINStatementTimingsDescriptor());
    createXplainTable(lcc, schemaName, new XPLAINResultSetDescriptor());
    createXplainTable(lcc, schemaName, new XPLAINResultSetTimingsDescriptor());
    createXplainTable(lcc, schemaName, new XPLAINScanPropsDescriptor());
    createXplainTable(lcc, schemaName, new XPLAINSortPropsDescriptor());
    lcc.setRunTimeStatisticsMode(statsSave);
    lcc.setXplainSchema(schemaName);
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) XPLAINSortPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor) XPLAINStatementDescriptor(org.apache.derby.impl.sql.catalog.XPLAINStatementDescriptor) XPLAINResultSetDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) XPLAINScanPropsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor) XPLAINStatementTimingsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINStatementTimingsDescriptor) TransactionController(org.apache.derby.iapi.store.access.TransactionController) XPLAINResultSetTimingsDescriptor(org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor)

Aggregations

XPLAINResultSetDescriptor (org.apache.derby.impl.sql.catalog.XPLAINResultSetDescriptor)2 XPLAINResultSetTimingsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor)2 XPLAINScanPropsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINScanPropsDescriptor)2 XPLAINSortPropsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINSortPropsDescriptor)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)1 TransactionController (org.apache.derby.iapi.store.access.TransactionController)1 XPLAINStatementDescriptor (org.apache.derby.impl.sql.catalog.XPLAINStatementDescriptor)1 XPLAINStatementTimingsDescriptor (org.apache.derby.impl.sql.catalog.XPLAINStatementTimingsDescriptor)1 StandardException (org.apache.derby.shared.common.error.StandardException)1