2 Aug 2010 08:56
Re: Infinite loop on error
On 8/2/10, Daniele Varrazzo <daniele.varrazzo@...> wrote: > On Wed, Jul 28, 2010 at 4:54 PM, Marko Kreen <markokr@...> wrote: > > Psycopg has several loops in form: > > > > while ((curs->pgres = PQgetResult()) != NULL) > > { > > } > > > > or > > > > do { > > pgres = PQgetResult(); > > } while (pgres != 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. Yeah, found out via strace/gdb... strace was showing infinite close(-1) - thus libpq was trying to close already closed connection. > But, if it doesn't return a NULL with the > connection in broken state... what does it return? Probably PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR)(Continue reading)
RSS Feed