[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


states that returned PGresults should be freed with PQclear and the
PQclear documentation


	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