psql should re-read connection variables after connection reset
Peter Billen <peter.billen@gmail.com>
From: Peter Billen <peter.billen@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Date: 2019-05-28T09:56:03Z
Lists: pgsql-bugs
Hi,
After a connection reset, psql should re-read the connection variables.
This was was initially reported by ysch on IRC and confirmed in the code by
Zr40. All I'm doing here is making sure that it is reported, as per ysch's
request.
I quickly verified this as following:
1. start 11 instance
2. psql into it
3. stop 11 instance
4. start 10 instance
5. in the existing psql session, first trigger a reconnect ('select 1')
and then '\df', which depends on the server version. I got:
ERROR: column p.prokind does not exist
LINE 5: CASE p.prokind
This happens because the psql session believes it is still connected to the
11 instance, as confirmed by Zr40:
[11:32:16] <Zr40> CheckConnection (
https://github.com/postgres/postgres/blob/master/src/bin/psql/common.c#L386)
doesn't call SyncVariables (
https://github.com/postgres/postgres/blob/master/src/bin/psql/command.c#L3286)
which is called on startup (
https://github.com/postgres/postgres/blob/master/src/bin/psql/startup.c#L312
)
Best regards.
Commits
-
Handle corner cases correctly in psql's reconnection logic.
- aef36238587c 13.0 landed
- b0b2ef25e3ff 9.6.16 landed
- 89535db970b0 9.4.25 landed
- 62724bd952a2 9.5.20 landed
- 5524ef55818b 11.6 landed
- 3080f8f6105e 10.11 landed
- 90433c38ec5a 12.0 landed