Re: [opendbx] More fun with postgresql
Brought to you by:
nose
From: Norbert S. <no...@li...> - 2011-06-16 20:47:04
|
Hi Murray libpq seems to be a source of eternal fun ;-) > When odbx_result() fails in this scenario, it gives an error code > without giving me a result handle (i.e., the returned odbx_result_t > is NULL). That prevents me from calling odbx_result_finish() in a > useful way, which in turn leaves the underlying database handle in an > unusable state. This appears to be unrecoverable. After having a look at backends/pgsql/pgsql_basic.c, it must be the result of PQresultStatus() (either PGRES_NONFATAL_ERROR or PGRES_BAD_RESPONSE) which is not one of the named ones (line 416). Afterwards, a cleanup is done but PQclear() doesn't seem to do its work. The documentation doesn't state that there is another command than PQclear() to cleanup the result sets if an error occurs. Maybe it's a bug in libpq. The PQ calls in your case are: - PQsendQuery() - PQgetResult() - PQresultStatus() - PQclear() - PQsendQuery() -> already in progress > The sequence of calls is: > > odbx_escape(), returns successfully > odbx_query(), returns successfully > odbx_result(), fails > odbx_error_type() returns 1 (non-fatal) > odbx_result_finish() > > Then later, with the same odbx_t handle, odbx_query() still fails, > reporting "another command is already in progress". Is calling > odbx_result_finish() here not enough? The last odbx_result_finish() should not be called because no result handle is returned and in the worst case a duplicate free() could happen. For a test you can try to call odbx_result() again after the error occured. Maybe a second call to PQgetResult() may help. If yes, we may be able to change the pgsql_odbx_result() for this special case. Norbert |