psql bug -- using old variables and database connection - Mailing list pgsql-hackers

From Gregory Stark
Subject psql bug -- using old variables and database connection
Date
Msg-id 87wsimwqck.fsf@oxford.xeocode.com
Whole thread Raw
Responses Re: psql bug -- using old variables and database connection
List pgsql-hackers
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'sPostgreSQL training!
 


pgsql-hackers by date:

Previous
From: ITAGAKI Takahiro
Date:
Subject: Copy column storage parameters on CREATE TABLE LIKE/INHERITS
Next
From: Zdenek Kotala
Date:
Subject: Re: WIP: New Page API