提交 8315814b 编写于 作者: S serge-rider

#3256 PG debugger: check plugin installation and report to user. Error handling improvements.

上级 a15c6189
......@@ -153,8 +153,9 @@ public class NavigatorHandlerObjectOpen extends NavigatorHandlerObjectBase imple
IEditorPart editor = findEntityEditor(workbenchWindow, selectedNode);
if (editor != null) {
boolean settingsChanged = false;
if (editor.getEditorInput() instanceof IDatabaseEditorInput) {
settingsChanged = setInputAttributes((DatabaseEditorInput<?>) editor.getEditorInput(), defaultPageId, defaultFolderId, attributes);
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IDatabaseEditorInput) {
settingsChanged = setInputAttributes((DatabaseEditorInput<?>) editorInput, defaultPageId, defaultFolderId, attributes);
}
if (editor instanceof ITabbedFolderContainer && defaultFolderId != null) {
// Activate default folder
......
......@@ -67,13 +67,7 @@ public abstract class DBGBaseController implements DBGController {
if (!dataSourceContainer.isConnected()) {
throw new DBGException("Not connected to database");
}
try {
return createSession(monitor, configuration);
} catch (DBException e) {
String message = NLS.bind(DebugMessages.DatabaseDebugController_e_opening_debug_context, dataSourceContainer);
log.error(message, e);
throw new DBGException(message, e);
}
return createSession(monitor, configuration);
}
@Override
......
......@@ -178,7 +178,7 @@ public class DatabaseDebugTarget extends DatabaseDebugElement implements IDataba
} catch (DBGException e) {
process.terminate();
throw new CoreException(
GeneralUtils.makeExceptionStatus(NLS.bind("Failed to connect {0} to the target", getName()), e));
GeneralUtils.makeExceptionStatus(e));
}
// Initiate breakpoints
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(modelIdentifier);
......
......@@ -57,6 +57,9 @@ public class PostgreDebugController extends DBGBaseController {
log.error(e1);
}
}
if (e instanceof DBGException) {
throw (DBGException)e;
}
throw new DBGException("Error attaching debug session", e);
}
}
......
......@@ -92,6 +92,8 @@ public class PostgreDebugSession extends DBGJDBCSession {
private static final String MAGIC_PORT = "PLDBGBREAK";
private static final String SQL_CHECK_PLUGIN = "select 'Server version: ' || serverversionstr || '.\nProxy API version: ' || proxyapiver from pldbg_get_proxy_info()";
private static final String SQL_ATTACH = "select pldbg_wait_for_target(?sessionid)";
private static final String SQL_ATTACH_TO_PORT = "select pldbg_attach_to_port(?portnumber)";
private static final String SQL_PREPARE_SLOT = " select pldbg_oid_debug(?objectid)";
......@@ -361,6 +363,12 @@ public class PostgreDebugSession extends DBGJDBCSession {
* procedure
*/
public void attach(DBRProgressMonitor monitor, Map<String, Object> configuration) throws DBException {
if (!checkDebugPlagin(monitor)) {
throw new DBGException("PostgreSQL debug plugin is not installed on the server.\n" +
"Refer to this WIKI article for installation instructions:\n" +
"https://github.com/dbeaver/dbeaver/wiki/PGDebugger#installation");
}
int functionOid = CommonUtils.toInt(configuration.get(PostgreDebugConstants.ATTR_FUNCTION_OID));
String kind = String.valueOf(configuration.get(PostgreDebugConstants.ATTR_ATTACH_KIND));
boolean global = PostgreDebugConstants.ATTACH_KIND_GLOBAL.equals(kind);
......@@ -378,6 +386,17 @@ public class PostgreDebugSession extends DBGJDBCSession {
}
}
private boolean checkDebugPlagin(DBRProgressMonitor monitor) {
try (JDBCSession session = getControllerConnection().openSession(monitor, DBCExecutionPurpose.UTIL, "Check debug plugin installation")) {
String version = JDBCUtils.executeQuery(session, SQL_CHECK_PLUGIN);
log.debug("Debug plugin is installed:\n" + version);
return true;
} catch (Exception e) {
log.debug("Debug plugin not installed: " + e.getMessage());
return false;
}
}
private void detachLocal(DBRProgressMonitor monitor) throws DBGException {
try (JDBCSession session = getControllerConnection().openSession(monitor, DBCExecutionPurpose.UTIL, "Abort local session")) {
JDBCUtils.executeQuery(session, composeAbortCommand());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册