use of org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor 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);
}
use of org.apache.derby.impl.sql.catalog.XPLAINResultSetTimingsDescriptor 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);
}
Aggregations