diff --git a/web/pgadmin/tools/debugger/__init__.py b/web/pgadmin/tools/debugger/__init__.py index 79e5eae..39bf23f 100644 --- a/web/pgadmin/tools/debugger/__init__.py +++ b/web/pgadmin/tools/debugger/__init__.py @@ -207,17 +207,6 @@ def init_function(node_type, sid, did, scid, fid, trid=None): " and cannot be debugged." ) else: - # If user is super user then we should check debugger library is loaded or not - if user['is_superuser']: - status_in, rid_pre = conn.execute_scalar("SHOW shared_preload_libraries") - if not status_in: - return internal_server_error(gettext("Could not fetch debugger plugin information.")) - - # Need to check if plugin is really loaded or not with "plugin_debugger" string - if "plugin_debugger" not in rid_pre: - ret_status = False - msg = gettext("The debugger plugin is not enabled. Please add the plugin to the shared_preload_libraries setting in the postgresql.conf file and restart the database server.") - status_in, rid_tar = conn.execute_scalar( "SELECT count(*) FROM pg_proc WHERE proname = 'pldbg_get_target_info'") if not status_in: @@ -385,6 +374,31 @@ def initialize_target(debug_type, sid, did, scid, func_id, tri_id=None): if not status: return internal_server_error(errormsg=str(msg)) + user = manager.user_info + if debug_type == 'indirect': + # If user is super user then we should check debugger library is + # loaded or not + if user['is_superuser']: + status_in, rid_pre = conn.execute_scalar( + "SHOW shared_preload_libraries" + ) + if not status_in: + return internal_server_error( + gettext("Could not fetch debugger plugin information.") + ) + + # Need to check if plugin is really loaded or not with + # "plugin_debugger" string + if "plugin_debugger" not in rid_pre: + msg = gettext( + "The debugger plugin is not enabled. " \ + "Please add the plugin to the shared_preload_libraries " \ + "setting in the postgresql.conf file and restart the " \ + "database server.(Indirect debugging prerequisite)" + ) + current_app.logger.debug(msg) + return internal_server_error(msg) + # Set the template path required to read the sql files template_path = 'debugger/sql' diff --git a/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js b/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js index 7e7e31f..c18e0d3 100644 --- a/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js +++ b/web/pgadmin/tools/debugger/templates/debugger/js/debugger.js @@ -269,10 +269,13 @@ define([ }); } }, - error: function(e) { - Alertify.alert( - 'Debugger target initialization error' - ); + error: function(xhr, status, error) { + try { + var err = $.parseJSON(xhr.responseText); + if (err.success == 0) { + Alertify.alert(err.errormsg); + } + } catch (e) {} } }); },