Fix for a problem with auto reconnection

Поиск
Список
Период
Сортировка
От Christoph Zwerschke
Тема Fix for a problem with auto reconnection
Дата
Msg-id 52851ED9.1050003@online.de
обсуждение исходный текст
Ответы Re: Fix for a problem with auto reconnection
Список 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.


В списке pgadmin-hackers по дате отправления:

Предыдущее
От: Neel Patel
Дата:
Сообщение: Re: [pgadmin-support] pgAdmin 1.18.0 + slony-I 2.2.0 + PG 9.3
Следующее
От: Dave Page
Дата:
Сообщение: Re: Fix for a problem with auto reconnection