Hi Dave,

Please find updated patch.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On Fri, Jun 23, 2017 at 2:38 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Yes, I'm looking into it, I will send updated patch.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, Jun 23, 2017 at 2:32 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> On Fri, Jun 23, 2017 at 9:56 AM, Murtuza Zabuawala
>> <murtuza.zabuaw...@enterprisedb.com> wrote:
>> > Yes Dave,
>> >
>> > You are right, I tested and found that indirect debugging is not
>> working.
>> > But otherwise for direct debugging it works properly.
>>
>> Does the patch take that into account, or are you modifying it?
>>
>> > On Fri, Jun 23, 2017 at 1:20 PM, Dave Page <dp...@pgadmin.org> wrote:
>> >>
>> >> On Fri, Jun 23, 2017 at 7:16 AM, Murtuza Zabuawala
>> >> <murtuza.zabuaw...@enterprisedb.com> wrote:
>> >> > Hi,
>> >> >
>> >> > PFA patch to fix the issue in Debugger module where it was unable to
>> >> > start
>> >> > debugging if 'plugin_debugger' can not found in
>> >> > shared_preload_libraries.
>> >> > RM#2162
>> >> >
>> >> > Original patch by: Kit Yam Tse
>> >> > (who reported the issue)
>> >> >
>> >> > I just re-based it against current code.
>> >>
>> >> Isn't that code required? We do need plugin_debugger to be present for
>> >> global (indirect) debugging to work. I suppose it may not be required
>> >> for direct debugging, but I haven't tested that.
>> >>
>> >>
>> >> --
>> >> Dave Page
>> >> Blog: http://pgsnake.blogspot.com
>> >> Twitter: @pgsnake
>> >>
>> >> EnterpriseDB UK: http://www.enterprisedb.com
>> >> The Enterprise PostgreSQL Company
>> >
>> >
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
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) {}
           }
         });
       },

Reply via email to