Re: [EXTERNAL] Re: Add non-blocking version of PQcancel

Поиск
Список
Период
Сортировка
От Jelte Fennema-Nio
Тема Re: [EXTERNAL] Re: Add non-blocking version of PQcancel
Дата
Msg-id CAGECzQS2d-vGLa2xx-QNqvO4rk34dxhQx1vj94BXFqKZZxpfLQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [EXTERNAL] Re: Add non-blocking version of PQcancel  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Ответы Re: [EXTERNAL] Re: Add non-blocking version of PQcancel  (Jelte Fennema-Nio <postgres@jeltef.nl>)
Список pgsql-hackers
On Tue, 12 Mar 2024 at 10:19, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> If we do this and we see conn.status is not ALLOCATED, meaning a cancel
> is already ongoing, shouldn't we leave conn.status alone instead of
> changing to CONNECTION_BAD?  I mean, we shouldn't be juggling the elbow
> of whoever's doing that, should we?  Maybe just add the error message
> and return 0?

I'd rather fail as hard as possible when someone is using the API
wrongly. Not doing so is bound to cause confusion imho. e.g. if the
state is still CONNECTION_OK because the user forgot to call
PQcancelReset then keeping the connection status "as is" might seem as
if the cancel request succeeded even though nothing happened. So if
the user uses the API incorrectly then I'd rather use all the avenues
possible to indicate that there was an error. Especially since in all
other cases if PQcancelStart returns false CONNECTION_BAD is the
status, and this in turn means that PQconnectPoll will return
PGRES_POLLING_FAILED. So I doubt people will always check the actual
return value of the function to check if an error happened. They might
check PQcancelStatus or PQconnectPoll instead, because that integrates
easier with the rest of their code.



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

Предыдущее
От: Himanshu Upadhyaya
Дата:
Сообщение: Re: remaining sql/json patches
Следующее
От: John Naylor
Дата:
Сообщение: Re: Add bump memory context type and use it for tuplesorts