Re: Mop-up around psql's \connect behavior

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Mop-up around psql's \connect behavior
Дата
Msg-id 270665.1603487564@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Mop-up around psql's \connect behavior  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Ответы Re: Mop-up around psql's \connect behavior  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Список pgsql-hackers
Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> At Thu, 22 Oct 2020 15:23:04 -0400, Tom Lane <tgl@sss.pgh.pa.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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Mark Dilger
Дата:
Сообщение: Re: new heapcheck contrib module
Следующее
От: Tom Lane
Дата:
Сообщение: Re: new heapcheck contrib module