From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Mop-up around psql's \connect behavior |
Date: | 2020-10-23 21:12:44 |
Message-ID: | 270665.1603487564@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> writes:
> At Thu, 22 Oct 2020 15:23:04 -0400, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote in
>> ... The only real objection I can see is that it could
>> hold a server connection open when the user thinks there is none;
>> but that could only happen in a non-interactive script, and it does
>> not seem like a big problem in that case. We could alternatively
>> not stash the "dead" connection after a non-interactive \connect
>> failure, but I doubt that's better.
> Agreed. Thanks!
After further thought I decided we *must* do it as per my "alternative"
idea. 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.
So we have to not save the connection after a failed script \connect.
However, it seems OK to save after a connection loss whether we're
in a script or not; that is,
\c db1 user1 server1
...
(connection dies here)
... --- these commands will fail
\c db2
The script will be expecting the second \c to re-use parameters
from the first one, and that will still work as expected.
I went ahead and pushed it after adjusting that.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-10-23 21:20:59 | Re: new heapcheck contrib module |
Previous Message | Mark Dilger | 2020-10-23 20:52:18 | Re: new heapcheck contrib module |