Re: Infinite loop on error
Daniele Varrazzo <[email protected]> Mon, 2 Aug 2010 01:56:24 +0100
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Jul 28, 2010 at 4:54 PM, Marko Kreen <[email protected]> wrote: > Psycopg has several loops in form: > > while ((curs->pgres =3D PQgetResult()) !=3D NULL) > { > } > > or > > do { > =A0pgres =3D PQgetResult(); > } while (pgres !=3D NULL); > > > The problem is that if libpq gets so fatal error it decides > to close the connection, PQgetResult() will never return NULL > from that connection, thus infinite loop. Are you sure about that? I don't have the libpq source code handy, I will surely check that. But, if it doesn't return a NULL with the connection in broken state... what does it return? PQgetResult() also returns null when there is no result to fetch. I may have extrapolated excessively assuming that it returns null when the connection is closed too, but it doesn't seem an excessively stretched interpretation. I'm curious to do some test in the next days. -- Daniele