Skip site navigation (1) Skip section navigation (2)

Documentation improvement for PQgetResult

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: (view raw, whole thread or download thread mbox)
Lists: pgsql-docs

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 */

Marko Kreen has pointed out
( 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

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 by date

Next:From: Tom LaneDate: 2010-08-06 14:20:18
Subject: Re: Documentation improvement for PQgetResult
Previous:From: pgsql-docsDate: 2010-08-06 03:47:54
Subject: 32% OFF on Pfizer!

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group