Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 58376
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: rweikusat [...] mssgmbh.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 2.17.2



Subject: Potential loss of async result in dbd_st_execute.
At least the 2.17.1 dbd_st_execute unconditionally PQclears any existing result still attached to a statement handle before starting a new query on it. This is not necessary when starting an asynchronous query because the routine will then return without assigning a new value to the imp_sth->result pointer and could be considered wrong because a caller might start another asychronous query before examining the result of the last one and the 'early PQclear' would then cause the result of the last query which was executed to be thrown away before any of its data was retrieved by an application. The attached patch works around this by not clearing the old result if an asynchronous query is to be started. It will be cleared the next time pg_db_result fetches a new result for the statement.
Subject: patch.txt
--- DBD-Pg/dbdimp.c 3 Jun 2010 13:28:17 -0000 1.1.1.3 +++ DBD-Pg/dbdimp.c 14 Jun 2010 14:27:45 -0000 1.1.1.3.2.1 @@ -2910,8 +2910,13 @@ } } - /* clear old result (if any) */ - if (imp_sth->result) { + /* + Clear old result (if any), except if starting the + query asynchronously. Old async results will be + deleted implicitly the next time pg_db_result is + called. + */ + if (imp_sth->result && !(imp_sth->async_flag & PG_ASYNC)) { TRACE_PQCLEAR; PQclear(imp_sth->result); imp_sth->result = NULL;
Thank you - patch was applied in r14538 and appeared in DBD::PG 2.17.2