public inbox for [email protected]  
help / color / mirror / Atom feed
From: Murtuza Zabuawala <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: PATCH: To fix the issue in Debugger module (pgAdmin4)
Date: Thu, 6 Oct 2016 14:35:16 +0530
Message-ID: <CAKKotZSz3kgLYGNyu_BGORF+J=F2qmLa-2z9Rzq1HgSjXjTyZg@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxoyF37xc+S4=r37KRAEh+zUfN4-WBSSv1YSe1VZpMmNfkg@mail.gmail.com>
References: <CAKKotZQz6mGEiky_Szo91tzm_RFvwJTYGriTmuxVYrhcWi5nJg@mail.gmail.com>
	<CA+OCxoxkphr1YF6F53j3sTreTMvoBOKqV+wjF6CnxoQ-SA+rzA@mail.gmail.com>
	<CAKKotZRMetEEPzFTuqiw_8Vit2_STHSN22=K+5frJBu7=Jp6PQ@mail.gmail.com>
	<CAKKotZQGdhiFrtNK0xz8OVLKOA2QCk_yfOZDFT+HEMfELzbk4A@mail.gmail.com>
	<CA+OCxoyzS4_cST0qJ7CbmxqOry4wGZCQkoiLpcXgjr2N4snPQw@mail.gmail.com>
	<CAKKotZSjyeZT_bS8_No-cEftRjqPPptLx+zV2+_DqV=KYZYRcw@mail.gmail.com>
	<CA+OCxoyLMvyRpPSMztrUf0st7yGvyeYquOmyFabQzg6Czieh=Q@mail.gmail.com>
	<CAKKotZRW4WF2gsaPu-cRZJmrAia0GiDTOhwDKQdUpBC5VRoVjQ@mail.gmail.com>
	<CA+OCxoyF37xc+S4=r37KRAEh+zUfN4-WBSSv1YSe1VZpMmNfkg@mail.gmail.com>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi Dave,

PFA updated patch with suggestion given.

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

On Wed, Oct 5, 2016 at 7:29 PM, Dave Page <[email protected]> wrote:

> OK, that's much better. I think I've figured out what's causing the
> remaining execution error as well - we're not disabling the buttons
> until we get a response from the server, so if you click too quickly,
> you make multiple requests at once. I tested this by adding a "SELECT
> pg_sleep(2);" to a loop in a function.
>
> If you can fix that as well, then I think we can call this issue fixed.
>
> Thanks!
>
> On Wed, Oct 5, 2016 at 1:09 PM, Murtuza Zabuawala
> <[email protected]> wrote:
> > Hi Dave,
> >
> > PFA updated patch for the same.
> > RM#1227
> >
> > Please review.
> >
> >
> > --
> > Regards,
> > Murtuza Zabuawala
> > EnterpriseDB: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Mon, Oct 3, 2016 at 6:05 PM, Dave Page <[email protected]> wrote:
> >>
> >> Hi
> >>
> >> On Tue, Sep 27, 2016 at 7:40 AM, Murtuza Zabuawala
> >> <[email protected]> wrote:
> >> > Hi Dave,
> >> >
> >> > PFA updated patch to fix mentioned issue as well as incremental msgs
> >> > updates
> >> > in Messages Tab.
> >>
> >> This doesn't seem to work well. In pgAdmin 4 I get the following:
> >>
> >> ====
> >> SELECT 1
> >> INFO: EMPNO ENAME
> >>
> >>
> >> INFO: ----- -------
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7369 SMITH
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7499 ALLEN
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7521 WARD
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7566 JONES
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7654 MARTIN
> >>
> >>
> >> SELECT 1
> >> INFO: 7698 BLAKE
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7782 CLARK
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7788 SCOTT
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7839 KING
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7844 TURNER
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7876 ADAMS
> >>
> >>
> >> SELECT 1
> >> INFO: 7900 JAMES
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7902 FORD
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> SELECT 1
> >> INFO: 7934 MILLER
> >>
> >>
> >> SELECT 1
> >> SELECT 1
> >> SELECT 1
> >> SELECT 1
> >> ====
> >>
> >> Whilst in pgAdmin III I get:
> >>
> >> ====
> >> INFO:  EMPNO    ENAME
> >> INFO:  -----    -------
> >> INFO:  7369     SMITH
> >> INFO:  7499     ALLEN
> >> INFO:  7521     WARD
> >> INFO:  7566     JONES
> >> INFO:  7654     MARTIN
> >> INFO:  7698     BLAKE
> >> INFO:  7782     CLARK
> >> INFO:  7788     SCOTT
> >> INFO:  7839     KING
> >> INFO:  7844     TURNER
> >> INFO:  7876     ADAMS
> >> INFO:  7900     JAMES
> >> INFO:  7902     FORD
> >> INFO:  7934     MILLER
> >> SELECT 1
> >> ====
> >>
> >> Sidenote: pgAdmin III uses a fixed-width font for this output which
> >> works far better than pgAdmin 4's variable width font.
> >>
> >> --
> >> 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
>


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM_1227_v4.patch (12.6K, 3-RM_1227_v4.patch)
  download | inline diff:
diff --git a/web/pgadmin/tools/debugger/__init__.py b/web/pgadmin/tools/debugger/__init__.py
index f7d0e7b..f9d1f36 100644
--- a/web/pgadmin/tools/debugger/__init__.py
+++ b/web/pgadmin/tools/debugger/__init__.py
@@ -1342,9 +1342,18 @@ def poll_end_execution_result(trans_id):
 
     if conn.connected():
         statusmsg = conn.status_message()
+        if statusmsg and statusmsg == 'SELECT 1':
+            statusmsg = ''
         status, result, col_info = conn.poll()
-        if status == ASYNC_OK and session['functionData'][str(trans_id)]['language'] == 'edbspl':
+        if status == ASYNC_OK and \
+                not session['functionData'][str(trans_id)]['is_func'] and \
+                session['functionData'][str(trans_id)]['language'] == 'edbspl':
             status = 'Success'
+            additional_msgs = conn.messages()
+            if len(additional_msgs) > 0:
+                additional_msgs = [msg.strip("\n") for msg in additional_msgs]
+                statusmsg = "<br>".join(additional_msgs) + "<br>" + \
+                            statusmsg if statusmsg is not None else ''
             return make_json_response(success=1, info=gettext("Execution Completed."),
                                       data={'status': status, 'status_message': statusmsg})
         if result:
@@ -1354,6 +1363,12 @@ def poll_end_execution_result(trans_id):
                                           data={'status': status, 'status_message': result})
             else:
                 status = 'Success'
+                additional_msgs = conn.messages()
+                if len(additional_msgs) > 0:
+                    additional_msgs = [msg.strip("\n") for msg in additional_msgs]
+                    statusmsg = "<br>".join(additional_msgs) + "<br>" + \
+                                statusmsg if statusmsg is not None else ''
+
                 columns = []
                 # Check column info is available or not
                 if col_info is not None and len(col_info) > 0:
@@ -1369,6 +1384,14 @@ def poll_end_execution_result(trans_id):
                                                 'col_info': columns, 'status_message': statusmsg})
         else:
             status = 'Busy'
+            additional_msgs = conn.messages()
+            if len(additional_msgs) > 0:
+                additional_msgs = [msg.strip("\n") for msg in additional_msgs]
+                statusmsg = "<br>".join(additional_msgs) + "<br>" + \
+                            statusmsg if statusmsg is not None else ''
+            return make_json_response(data={
+                'status': status, 'result': result, 'status_message': statusmsg
+            })
     else:
         status = 'NotConnected'
         result = gettext('Not connected to server or connection with the server has been closed.')
diff --git a/web/pgadmin/tools/debugger/static/css/debugger.css b/web/pgadmin/tools/debugger/static/css/debugger.css
index 4386775..e1177a8 100644
--- a/web/pgadmin/tools/debugger/static/css/debugger.css
+++ b/web/pgadmin/tools/debugger/static/css/debugger.css
@@ -67,3 +67,14 @@
 .CodeMirror-foldgutter-folded:after {
   content: "\25B6";
 }
+
+/* To make font same as Query tool in messages tab */
+.messages {
+    white-space: pre-wrap;
+    font-family: monospace;
+    padding-top: 5px;
+    padding-left: 10px;
+    overflow: auto;
+    height: 100%;
+    font-size: 0.925em;
+}
\ No newline at end of file
diff --git a/web/pgadmin/tools/debugger/templates/debugger/js/direct.js b/web/pgadmin/tools/debugger/templates/debugger/js/direct.js
index 452617b..478fcff 100644
--- a/web/pgadmin/tools/debugger/templates/debugger/js/direct.js
+++ b/web/pgadmin/tools/debugger/templates/debugger/js/direct.js
@@ -363,6 +363,20 @@ define(
 
     },
 
+    // This function will update messages tab
+    update_messages: function(msg) {
+      var old_msgs='', new_msgs='';
+        old_msgs = pgTools.DirectDebug.messages_panel.$container.find('.messages').html();
+        if(old_msgs) {
+          new_msgs = (old_msgs + '\n' + msg)
+                        .replace(/(?:\r\n|\r|\n)/g, '<br />') // Newlines with <br>
+                        .replace(/(<br\ ?\/?>)+/g, '<br />'); // multiple <br> with single <br>
+        } else {
+          new_msgs = msg;
+        }
+        pgTools.DirectDebug.messages_panel.$container.find('.messages').html(new_msgs);
+    },
+
     /*
       For the direct debugging, we need to check weather the functions execution is completed or not. After completion
       of the debugging, we will stop polling the result  until new execution starts.
@@ -411,7 +425,9 @@ define(
                 );
 
                 // Update the message tab of the debugger
-                pgTools.DirectDebug.dbmsMessages.$elem.text(res.data.status_message);
+                if (res.data.status_message) {
+                  self.update_messages(res.data.status_message);
+                }
 
                 // Execution completed so disable the buttons other than "Continue/Start" button because user can still
                 // start the same execution again.
@@ -420,6 +436,7 @@ define(
                 self.enable('step_into', false);
                 self.enable('toggle_breakpoint', false);
                 self.enable('clear_all_breakpoints', false);
+                self.enable('continue', true);
               }
               else {
                 // Call function to create and update local variables ....
@@ -439,7 +456,9 @@ define(
                   );
 
                   // Update the message tab of the debugger
-                  pgTools.DirectDebug.messages_panel.$container.find('.messages').text(res.data.status_message);
+                  if (res.data.status_message) {
+                    self.update_messages(res.data.status_message);
+                  }
 
                   // Execution completed so disable the buttons other than "Continue/Start" button because user can still
                   // start the same execution again.
@@ -448,12 +467,17 @@ define(
                   self.enable('step_into', false);
                   self.enable('toggle_breakpoint', false);
                   self.enable('clear_all_breakpoints', false);
+                  self.enable('continue', true);
                 }
               }
             }
             else if (res.data.status === 'Busy') {
               // If status is Busy then poll the result by recursive call to the poll function
               //self.poll_end_execution_result(trans_id);
+              // Update the message tab of the debugger
+              if (res.data.status_message) {
+                self.update_messages(res.data.status_message);
+              }
             }
             else if (res.data.status === 'NotConnected') {
               Alertify.alert(
@@ -473,7 +497,11 @@ define(
                 function() { }
               );
 
-              pgTools.DirectDebug.messages_panel.$container.find('.messages').text(res.data.status_message);
+              // Update the message tab of the debugger
+              if (res.data.status_message) {
+                self.update_messages(res.data.status_message);
+              }
+
               pgTools.DirectDebug.messages_panel.focus();
 
               // Execution completed so disable the buttons other than "Continue/Start" button because user can still
@@ -498,7 +526,15 @@ define(
 
     Restart: function(trans_id) {
 
-      var baseUrl = "{{ url_for('debugger.index') }}" + "restart/" + trans_id;
+      var self = this,
+        baseUrl = "{{ url_for('debugger.index') }}" + "restart/" + trans_id;
+      self.enable('stop', false);
+      self.enable('step_over', false);
+      self.enable('step_into', false);
+      self.enable('toggle_breakpoint', false);
+      self.enable('clear_all_breakpoints', false);
+      self.enable('continue', false);
+
 
       $.ajax({
         url: baseUrl,
@@ -546,6 +582,12 @@ define(
     // Continue the execution until the next breakpoint
     Continue: function(trans_id) {
       var self = this;
+      self.enable('stop', false);
+      self.enable('step_over', false);
+      self.enable('step_into', false);
+      self.enable('toggle_breakpoint', false);
+      self.enable('clear_all_breakpoints', false);
+      self.enable('continue', false);
 
       //Check first if previous execution was completed or not
       if (pgTools.DirectDebug.direct_execution_completed &&
@@ -583,6 +625,12 @@ define(
 
       Step_over: function(trans_id) {
         var self = this;
+        self.enable('stop', false);
+        self.enable('step_over', false);
+        self.enable('step_into', false);
+        self.enable('toggle_breakpoint', false);
+        self.enable('clear_all_breakpoints', false);
+        self.enable('continue', false);
 
         // Make ajax call to listen the database message
         var baseUrl = "{{ url_for('debugger.index') }}" + "execute_query/" + trans_id + "/" + "step_over";
@@ -613,6 +661,12 @@ define(
 
       Step_into: function(trans_id) {
         var self = this;
+        self.enable('stop', false);
+        self.enable('step_over', false);
+        self.enable('step_into', false);
+        self.enable('toggle_breakpoint', false);
+        self.enable('clear_all_breakpoints', false);
+        self.enable('continue', false);
 
         // Make ajax call to listen the database message
         var baseUrl = "{{ url_for('debugger.index') }}" + "execute_query/" + trans_id + "/" + "step_into";
@@ -643,6 +697,12 @@ define(
 
       Stop: function(trans_id) {
         var self = this;
+        self.enable('stop', false);
+        self.enable('step_over', false);
+        self.enable('step_into', false);
+        self.enable('toggle_breakpoint', false);
+        self.enable('clear_all_breakpoints', false);
+        self.enable('continue', false);
 
         // Make ajax call to listen the database message
         var baseUrl = "{{ url_for('debugger.index') }}" + "execute_query/" + trans_id + "/" + "abort_target";
@@ -665,12 +725,8 @@ define(
               );
 
               //Disable the buttons other than continue button. If user wants to again then it should allow to debug again...
-              self.enable('stop', false);
-              self.enable('step_over', false);
-              self.enable('step_into', false);
-              self.enable('continue', false);
-              self.enable('toggle_breakpoint', false);
-              self.enable('clear_all_breakpoints', false);
+              self.enable('continue', true);
+
             }
             else if (res.data.status === 'NotConnected') {
               Alertify.alert(
@@ -688,6 +744,13 @@ define(
 
       toggle_breakpoint: function(trans_id) {
         var self = this;
+        self.enable('stop', false);
+        self.enable('step_over', false);
+        self.enable('step_into', false);
+        self.enable('toggle_breakpoint', false);
+        self.enable('clear_all_breakpoints', false);
+        self.enable('continue', false);
+
 
         var info = pgTools.DirectDebug.editor.lineInfo(self.active_line_no);
         var baseUrl = '';
@@ -720,6 +783,12 @@ define(
                     return marker;
                 }());
               }
+              self.enable('stop', true);
+              self.enable('step_over', true);
+              self.enable('step_into', true);
+              self.enable('toggle_breakpoint', true);
+              self.enable('clear_all_breakpoints', true);
+              self.enable('continue', true);
             }
             else if (res.data.status === 'NotConnected') {
               Alertify.alert(
@@ -736,14 +805,20 @@ define(
       },
 
       clear_all_breakpoint: function(trans_id) {
-        var self = this;
-
-        var br_list = self.GetBreakpointInformation(trans_id);
+        var self = this,
+          br_list = self.GetBreakpointInformation(trans_id);
 
         // If there is no break point to clear then we should return from here.
         if ((br_list.length == 1) && (br_list[0].linenumber == -1))
           return;
 
+        self.enable('stop', false);
+        self.enable('step_over', false);
+        self.enable('step_into', false);
+        self.enable('toggle_breakpoint', false);
+        self.enable('clear_all_breakpoints', false);
+        self.enable('continue', false);
+
         var breakpoint_list = new Array();
 
         for (i = 0; i < br_list.length; i++) {
@@ -771,6 +846,12 @@ define(
                 }
               }
             }
+          self.enable('stop', true);
+          self.enable('step_over', true);
+          self.enable('step_into', true);
+          self.enable('toggle_breakpoint', true);
+          self.enable('clear_all_breakpoints', true);
+          self.enable('continue', true);
           },
           error: function(e) {
             Alertify.alert(


view thread (21+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: PATCH: To fix the issue in Debugger module (pgAdmin4)
  In-Reply-To: <CAKKotZSz3kgLYGNyu_BGORF+J=F2qmLa-2z9Rzq1HgSjXjTyZg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox