Skip to content

[pull] master from postgres:master#364

Merged
pull[bot] merged 1 commit intoMu-L:masterfrom
postgres:master
Oct 23, 2020
Merged

[pull] master from postgres:master#364
pull[bot] merged 1 commit intoMu-L:masterfrom
postgres:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull bot commented Oct 23, 2020

See Commits and Changes for more details.


Created by pull[bot]. Want to support this open source service? Please star it : )

Instead of immediately PQfinish'ing a dead connection, save it aside
so that we can still extract its parameters for \connect attempts.
(This works because PQconninfo doesn't care whether the PGconn is in
CONNECTION_BAD state.)  This allows developers to reconnect with
just \c after a database crash and restart.

It's tempting to use the same approach instead of closing the old
connection after a failed non-interactive \connect command.  However,
that would not be very safe: consider a script containing
	\c db1 user1 live_server
	\c db2 user2 dead_server
	\c db3
The script would be expecting to connect to db3 at dead_server, but
if we re-use parameters from the first connection then it might
successfully connect to db3 at live_server.  This'd defeat the goal
of not letting a script accidentally execute commands against the
wrong database.

Discussion: https://postgr.es/m/38464.1603394584@sss.pgh.pa.us
@pull pull bot added the ⤵️ pull label Oct 23, 2020
@pull pull bot merged commit 1b62d0f into Mu-L:master Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant