Re: Fix for a problem with auto reconnection - Mailing list pgadmin-hackers

From Ashesh Vashi
Subject Re: Fix for a problem with auto reconnection
Date
Msg-id CAG7mmoxNgTBxR=xSNU6iKU06NW_J58L05toLAkOCLjnZjcAfVw@mail.gmail.com
Whole thread Raw
In response to Re: Fix for a problem with auto reconnection  (Dave Page <dpage@pgadmin.org>)
Responses Re: Fix for a problem with auto reconnection  (Christoph Zwerschke <cito@online.de>)
List pgadmin-hackers
Sure - I will look into it..


On Fri, Nov 15, 2013 at 6:43 AM, Dave Page <dpage@pgadmin.org> wrote:
Ashesh, can you look at this please?

Thanks for the report and investigation Christoph.

On Thu, Nov 14, 2013 at 7:04 PM, Christoph Zwerschke <cito@online.de> wrote:
> My colleagues and I recently stumbled over a quite perplexing issue with
> pgadmin3 (1.18.1), namely that the pgadmin query tool sometimes did not show
> values in the database which were definitely set.
>
> After further investigation it turned out that this happened when the values
> contained non-ascii characters and after the database connection had been
> reset by pgadmin (which happened sometimes when the database was restarted
> or there was a timeout in the firewall), and if that reset happened via the
> query tool window, not via the main window.
>
> The explanation for this behavior is obvious: The connection is reset with
> conn->Reset() in frm/frmQuery.cpp, but the Reset() method does not set the
> client side encoding for the connection to match the encoding of the
> database, as is done in DoConnect(). It also fails to do some other things
> that DoConnect() cares about, such as setting the DateStyle to ISO and
> setting the default role. This could cause additional problems.
>
> So my solution was to replace the call to conn->Reset() with a call to
> conn->Reconnect() which essentially does the same, but calls DoConnect()
> internally so that everything gets initialized.
>
> This fix works nicely for me. Another solution would be to add the
> initialization code in DoConnect() to the Reset() method as well.
>
> Here are the steps to reproduce the problem:
>
> * Open the SQL query tool and create a test table like this:
>
>   create table t(a varchar , b varchar);
>   insert into t values ('Wurst', 'Käse');
>
> * Query the table with "select * from t".
>   You should get "Wurst" and "Käse".
>
> * Kill the server process for the connection
>
> * Query the table again with "select * from t".
>   You should get a Fatal error: connection lost.
>
> * Rerun the query.
>   You should now get a dialog box asking
>   "... attempt to reconnect ... ?"
>
> * Answer "Yes".
>   You should get the message "Connection reset."
>
> * Rerun the query.
>   Now you get the query result again,
>   but this time only with the cell "Wurst";
>   the cell that should say "Käse" stays empty.
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers



--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



--
--

Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA:
Enterprise PostgreSQL Company

 

http://www.linkedin.com/in/asheshvashi

pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: Re: Fix for a problem with auto reconnection
Next
From: Christoph Zwerschke
Date:
Subject: Re: Fix for a problem with auto reconnection