On 25.04.2012 14:22, Dave Page wrote:
On Wed, Apr 25, 2012 at 11:24 AM, Heikki Linnakangas
<[email protected]> 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
diff --git a/pgadmin/debugger/ctlCodeWindow.cpp b/pgadmin/debugger/ctlCodeWindow.cpp
index 5db7178..c6098f6 100644
--- a/pgadmin/debugger/ctlCodeWindow.cpp
+++ b/pgadmin/debugger/ctlCodeWindow.cpp
@@ -1067,12 +1067,20 @@ void ctlCodeWindow::displaySource(const wxString &packageOID, const wxString &fu
// Now erase any old code and write out the new listing
m_view->SetReadOnly( false );
- // Strip the leading blank line from the source as it looks ugly
+ // Get the source. Ignore any CRs.
wxString src = codeCache.getSource();
src.Replace(wxT("\r"), wxT(""));
+ // Before PostgreSQL 9.1, the server ignored an initial newline
+ // when calculating line numbers. The line numbers of what we display
+ // has to match the server's numbering, or all the highlighting and
+ // breakpoints are off, so if we're connected to a server older than
+ // 9.1, strip the initial newline from the display.
if (src.StartsWith(wxT("\n")))
- src = src.AfterFirst('\n');
+ {
+ if (!m_dbgConn->BackendMinimumVersion(9, 1))
+ src = src.AfterFirst('\n');
+ }
m_view->SetText(src);
diff --git a/pgadmin/schema/pgDatabase.cpp b/pgadmin/schema/pgDatabase.cpp
index 93b8672..66ce7f1 100644
--- a/pgadmin/schema/pgDatabase.cpp
+++ b/pgadmin/schema/pgDatabase.cpp
@@ -1036,7 +1036,18 @@ bool pgDatabase::CanDebugEdbspl()
if (GetServer()->GetSuperUser())
{
// Check the appropriate plugin is loaded
- if (!ExecuteScalar(wxT("SHOW shared_preload_libraries;")).Contains(wxT("plugin_spl_debugger")))
+
+ // Before EDBAS92, there was a separate library for SPL and PL/pgSQL.
+ // Starting with 9.2, EDB uses the community version of pldebugger,
+ // and support for both languages is built into plugin_debugger.so
+ wxString library_name;
+
+ if (server->GetConnection()->EdbMinimumVersion(9, 2))
+ library_name = wxT("plugin_debugger");
+ else
+ library_name = wxT("plugin_spl_debugger");
+
+ if (!ExecuteScalar(wxT("SHOW shared_preload_libraries;")).Contains(library_name))
{
canDebugEdbspl = 1;
return false;
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers