From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | pgsql-docs(at)postgresql(dot)org |
Cc: | Marko Kreen <markokr(at)gmail(dot)com> |
Subject: | Documentation improvement for PQgetResult |
Date: | 2010-08-06 13:53:38 |
Message-ID: | AANLkTikP5a0yHUNYJC+p+KadnyNH+Wmbt=QkZ=rZYE9O@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-08-06 14:20:18 | Re: Documentation improvement for PQgetResult |
Previous Message | pgsql-docs | 2010-08-06 03:47:54 | pgsql-docs@news.hub.org 32% OFF on Pfizer! |