提交 d8eeb424 编写于 作者: A Alexander Fedorov

#2556 move DBGBreakpoint.drop to the DBGSession

上级 23102da3
......@@ -24,6 +24,4 @@ public interface DBGBreakpoint {
DBGBreakpointProperties getProperties();
void drop() throws DBGException;
}
......@@ -35,7 +35,6 @@ public class PostgreDebugBreakpoint implements DBGBreakpoint {
private static final String SQL_SET_GLOBAL = "select pldbg_set_global_breakpoint(?sessionid, ?obj, ?line, ?target)";
private static final String SQL_SET = "select pldbg_set_breakpoint(?sessionid, ?obj, ?line)";
private static final String SQL_DROP = "select pldbg_drop_breakpoint(?sessionid, ?obj, ?line)";
public PostgreDebugBreakpoint(PostgreDebugSession session, PostgreObjectDescriptor obj,
PostgreDebugBreakpointProperties properties) throws DBGException {
......@@ -64,20 +63,6 @@ public class PostgreDebugBreakpoint implements DBGBreakpoint {
return obj;
}
@Override
public void drop() throws DBGException {
try (Statement stmt = session.getConnection().createStatement()) {
stmt.executeQuery(SQL_DROP.replaceAll("\\?sessionid", String.valueOf(session.getSessionId()))
.replaceAll("\\?obj", String.valueOf(obj.getID()))
.replaceAll("\\?line", properties.isOnStart() ? "-1" : String.valueOf(properties.getLineNo())));
} catch (SQLException e) {
throw new DBGException("SQL error", e);
}
}
@Override
public PostgreDebugBreakpointProperties getProperties() {
return properties;
......
......@@ -88,6 +88,8 @@ public class PostgreDebugSession implements DBGSession {
private static final String SQL_ABORT = "select pldbg_abort_target(?sessionid)";
private static final String SQL_DROP_BREAKPOINT = "select pldbg_drop_breakpoint(?sessionid, ?obj, ?line)";
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
private List<PostgreDebugBreakpoint> breakpoints = new ArrayList<PostgreDebugBreakpoint>(1);
......@@ -211,7 +213,16 @@ public class PostgreDebugSession implements DBGSession {
try {
bp.drop();
try (Statement stmt = getConnection().createStatement()) {
PostgreDebugBreakpointProperties properties = (PostgreDebugBreakpointProperties) bp.getProperties();
stmt.executeQuery(SQL_DROP_BREAKPOINT.replaceAll("\\?sessionid", String.valueOf(getSessionId()))
.replaceAll("\\?obj", String.valueOf(bp.getObjectDescriptor().getID()))
.replaceAll("\\?line", properties.isOnStart() ? "-1" : String.valueOf(properties.getLineNo())));
} catch (SQLException e) {
throw new DBGException("SQL error", e);
}
breakpoints.remove(bp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册