psql bug -- using old variables and database connection
We're currently printing the warning about connecting to the wrong version of
the server *before* syncing variables. On reconnecting this results in using
the *old* server version before reconnecting. I'm not sure what happens for
the initial connection but it can't be good. connection_warnings also uses
pset.db which isn't set until a few lines later too which can't be good.
e.g.
postgres=# \c
psql (8.4devel)
You are now connected to database "postgres".
postgres=# select version();
version
-----------------------------------------------------------------------------------------
PostgreSQL 8.2.5 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.2.1 (Debian 4.2.1-5)
(1 row)
postgres=# \c
psql (8.4devel, server 8.2.5)
WARNING: psql version 8.4, server version 8.2.
Some psql features might not work.
You are now connected to database "postgres".
--- command.c 30 Jul 2008 21:57:07 +0100 1.192
+++ command.c 12 Aug 2008 10:05:52 +0100
@@ -1197,10 +1197,10 @@
* Replace the old connection with the new one, and update
* connection-dependent variables.
*/
- connection_warnings();
PQsetNoticeProcessor(n_conn, NoticeProcessor, NULL);
pset.db = n_conn;
SyncVariables();
+ connection_warnings(); /* Must be after SyncVariables */
/* Tell the user about the new connection */
if (!pset.quiet)
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!
Thanks, applied.
---------------------------------------------------------------------------
Gregory Stark wrote:
We're currently printing the warning about connecting to the wrong version of
the server *before* syncing variables. On reconnecting this results in using
the *old* server version before reconnecting. I'm not sure what happens for
the initial connection but it can't be good. connection_warnings also uses
pset.db which isn't set until a few lines later too which can't be good.e.g.
postgres=# \c
psql (8.4devel)
You are now connected to database "postgres".
postgres=# select version();
version
-----------------------------------------------------------------------------------------
PostgreSQL 8.2.5 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.2.1 (Debian 4.2.1-5)
(1 row)postgres=# \c
psql (8.4devel, server 8.2.5)
WARNING: psql version 8.4, server version 8.2.
Some psql features might not work.
You are now connected to database "postgres".--- command.c 30 Jul 2008 21:57:07 +0100 1.192 +++ command.c 12 Aug 2008 10:05:52 +0100 @@ -1197,10 +1197,10 @@ * Replace the old connection with the new one, and update * connection-dependent variables. */ - connection_warnings(); PQsetNoticeProcessor(n_conn, NoticeProcessor, NULL); pset.db = n_conn; SyncVariables(); + connection_warnings(); /* Must be after SyncVariables *//* Tell the user about the new connection */
if (!pset.quiet)--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +