[Dovecot] A questions about consume_results (driver-pgsql.c)
Rainer Weikusat
rweikusat at mssgmbh.com
Thu Mar 25 21:33:58 EET 2010
Rainer Weikusat <rweikusat at mssgmbh.com> writes:
> --------------
> static void consume_results(struct pgsql_db *db)
> {
> do {
> if (!PQconsumeInput(db->pg))
> break;
>
> if (PQisBusy(db->pg))
> return;
> } while (PQgetResult(db->pg) != NULL);
[...]
> ---------------
On a related note, the PQgetResult documentation
http://www.postgresql.org/docs/8.3/interactive/libpq-async.html
states that returned PGresults should be freed with PQclear and the
PQclear documentation
http://www.postgresql.org/docs/8.3/interactive/libpq-exec.html#LIBPQ-EXEC-MAIN
says
You can keep a PGresult object around for as long as you need
it; it does not go away when you issue a new command, nor even
if you close the connection. To get rid of it, you must call
PQclear. Failure to do this will result in memory leaks in
your application.
so the code quoted above should result in a memory leak if it ever
actually receives a PGresult.
More information about the dovecot
mailing list