From: | Christoph Zwerschke <cito(at)online(dot)de> |
---|---|
To: | pgadmin-hackers(at)postgresql(dot)org |
Subject: | Fix for a problem with auto reconnection |
Date: | 2013-11-14 19:04:57 |
Message-ID: | 52851ED9.1050003@online.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgadmin-hackers |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Grechko | 2013-11-14 22:06:34 | Support for non standard SSH port |
Previous Message | Neel Patel | 2013-11-11 13:16:18 | Re: pgAdmin 1.18.0 + slony-I 2.2.0 + PG 9.3 |