提交 dea98a3d 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #7427 from SergDzh/patch-4

Oracle Session New Tab

Former-commit-id: d71cbc4e
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2019 SergDzh (jurasik@bigmir.net)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.oracle.model.session;
import org.jkiss.dbeaver.model.DBPObject;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.meta.Property;
import java.sql.ResultSet;
/**
* Plan
*/
public class OracleServerExecutePlan implements DBPObject {
private String plan;
public OracleServerExecutePlan(ResultSet dbResult) {
this.plan = JDBCUtils.safeGetString(dbResult, "PLAN_TABLE_OUTPUT");
}
@Property(viewable = true, order = 1)
public String getPlan() {
return plan;
}
}
......@@ -154,6 +154,34 @@ public class OracleServerSessionManager implements DBAServerSessionManager<Oracl
return OracleServerLongOp.class;
}
});
extDetails.add(new AbstractServerSessionDetails("Display Exec Plan", "Displays execute plan from dbms_xplan by SqlId and ChildNumber", DBIcon.TYPE_TEXT) {
@Override
public List<OracleServerExecutePlan> getSessionDetails(DBCSession session, DBAServerSession serverSession) throws DBException {
try {
try (JDBCPreparedStatement dbStat = ((JDBCSession) session).prepareStatement(
"SELECT PLAN_TABLE_OUTPUT FROM TABLE(dbms_xplan.display_cursor(sql_id => ?, cursor_child_no => ?))"))
{
dbStat.setString(1, ((OracleServerSession) serverSession).getSqlId());
dbStat.setLong(2, ((OracleServerSession) serverSession).getSqlChildNumber());
try (JDBCResultSet dbResult = dbStat.executeQuery())
{
List<OracleServerExecutePlan> ExecutePlan = new ArrayList<>();
while (dbResult.next()) {
ExecutePlan.add(new OracleServerExecutePlan(dbResult));
}
return ExecutePlan;
}
}
} catch (SQLException e) {
throw new DBException(e, session.getDataSource());
}
}
@Override
public Class<? extends DBPObject> getDetailsType() {
return OracleServerExecutePlan.class;
}
});
return extDetails;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册