Documentation improvement for PQgetResult

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Documentation improvement for PQgetResult
Дата
Msg-id AANLkTikP5a0yHUNYJC+p+KadnyNH+Wmbt=QkZ=rZYE9O@mail.gmail.com
обсуждение исходный текст
Ответы Re: Documentation improvement for PQgetResult  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-docs
Hello,

documentation about the PQgetResult function suggests to "[call]
repeatedly until it returns a null pointer, indicating that the
command is done". This has lead psycopg developers to write code with
the pattern:

    while (NULL != (res = PQgetResult(conn))) {
        /* do something with res */
        PQclear(res);
    }

Marko Kreen has pointed out
(http://lists.initd.org/pipermail/psycopg/2010-July/007149.html) that
this can lead to an infinite loop if the connection goes bad at the
rightly wrong time, advising then to check for the connection status
in the middle of the loop. libpq code seems actually returning
PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR) in case of something
unexpected.

If this is the case (I've not managed to reproduce it but the libpq
code seems clear), shouldn't the function documentation warn for this
risk, advising to check the connection status in the middle of the
loop and bail out if it's bad? Would it be better to perform a check
on the connection or on the result?

Thank you, cheers.

-- Daniele

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

Предыдущее
От: pgsql-docs@news.hub.org
Дата:
Сообщение: pgsql-docs@news.hub.org 32% OFF on Pfizer!
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Documentation improvement for PQgetResult