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

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

Hmm. True.

> So we have to not save the connection after a failed script \connect.

Yes, we shouldn't save a connection parameters that haven't made a
connection.

> 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.

Agreed.

> I went ahead and pushed it after adjusting that.

Thanks!

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



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

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: Re: Allow deleting enum value
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: MultiXact\SLRU buffers configuration