Обсуждение: Debugger line numbering is off by one
In PostgreSQL 9.1, the line numbering of PL/pgSQL functions was changed by this commit: > commit c3a05881de21438a29b6dc721ebd7d1e028a905a > Author: Robert Haas <rhaas@postgresql.org> > Date: Mon Aug 2 03:46:54 2010 +0000 > > Remove ancient PL/pgsql line numbering hack. > > While this hack arguably has some benefit in terms of making PL/pgsql's > line numbering match the programmer's expectations, it also makes > PL/pgsql inconsistent with the remaining PLs, making it difficult for > clients to reliably determine where the error actually is. On balance, > it seems better to be consistent. > > Pavel Stehule The hack that was removed skipped an initial newline when counting line numbers. The PL/pgSQL debugger has a similar hack, but it didn't get the memo that it was removed in the backend, so the green current line marker is off by one when connected to a 9.1 server. Attached is a patch to fix that. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com
Вложения
On Wed, Apr 25, 2012 at 11:24 AM, Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote: > > The hack that was removed skipped an initial newline when counting line > numbers. The PL/pgSQL debugger has a similar hack, but it didn't get the > memo that it was removed in the backend, so the green current line marker is > off by one when connected to a 9.1 server. Attached is a patch to fix that. Hi It looks fine, except that the "Paused at line" message in the status bar is still off by one. I tried using the offset you calculated there as well, and things started getting really weird (like, starting on line -15, then after single stepping, going back to being 1 off). I assume that the offset is being used there before it's actually calculated, but don't have time to play further right now. Can you fix it please? -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
On 25.04.2012 14:22, Dave Page wrote: > On Wed, Apr 25, 2012 at 11:24 AM, Heikki Linnakangas > <heikki.linnakangas@enterprisedb.com> wrote: >> >> The hack that was removed skipped an initial newline when counting line >> numbers. The PL/pgSQL debugger has a similar hack, but it didn't get the >> memo that it was removed in the backend, so the green current line marker is >> off by one when connected to a 9.1 server. Attached is a patch to fix that. > > Hi > > It looks fine, except that the "Paused at line" message in the status > bar is still off by one. I tried using the offset you calculated there > as well, and things started getting really weird (like, starting on > line -15, then after single stepping, going back to being 1 off). I > assume that the offset is being used there before it's actually > calculated, but don't have time to play further right now. I simply missed that, and didn't adjust it with the offset like i did elsewhere. I also just noticed that the line numbers displayed in the stack window are also off by one. They would be hard to adjust with the approach I tried, because you need the source of a function before you know whether there's a newline in the beginning, and we don't load the sources for a function until you display it. And the line numbers in any error messages you get on the console also won't match what we display. This becomes particularly visible if you enable line numbering in the left margin. I tried to be clever and merely hide the first blank line in the text box, so that the control's numbering would seem to start from 2, but I couldn't get wxStyledTextCtrl::HideLines() to hide the first line. If you pass it 0, it does nothing, and 1 means the 2nd line. Ugh. I think we have to give up on hiding the initial newline. A blank line in the beginning is a bit ugly, but it's better to be consistent. Attached is a patch to do that. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com
Вложения
On Thu, Apr 26, 2012 at 11:42 AM, Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote: > On 25.04.2012 14:22, Dave Page wrote: >> >> On Wed, Apr 25, 2012 at 11:24 AM, Heikki Linnakangas >> <heikki.linnakangas@enterprisedb.com> wrote: >>> >>> >>> The hack that was removed skipped an initial newline when counting line >>> numbers. The PL/pgSQL debugger has a similar hack, but it didn't get the >>> memo that it was removed in the backend, so the green current line marker >>> is >>> off by one when connected to a 9.1 server. Attached is a patch to fix >>> that. >> >> >> Hi >> >> It looks fine, except that the "Paused at line" message in the status >> bar is still off by one. I tried using the offset you calculated there >> as well, and things started getting really weird (like, starting on >> line -15, then after single stepping, going back to being 1 off). I >> assume that the offset is being used there before it's actually >> calculated, but don't have time to play further right now. > > > I simply missed that, and didn't adjust it with the offset like i did > elsewhere. > > I also just noticed that the line numbers displayed in the stack window are > also off by one. They would be hard to adjust with the approach I tried, > because you need the source of a function before you know whether there's a > newline in the beginning, and we don't load the sources for a function until > you display it. And the line numbers in any error messages you get on the > console also won't match what we display. > > This becomes particularly visible if you enable line numbering in the left > margin. I tried to be clever and merely hide the first blank line in the > text box, so that the control's numbering would seem to start from 2, but I > couldn't get wxStyledTextCtrl::HideLines() to hide the first line. If you > pass it 0, it does nothing, and 1 means the 2nd line. Ugh. Urgh indeed. > I think we have to give up on hiding the initial newline. A blank line in > the beginning is a bit ugly, but it's better to be consistent. Attached is a > patch to do that. Agreed. Thanks - patch applied. -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company