Re: pgsql: Fix memory leak in pgbench
От | Masahiko Sawada |
---|---|
Тема | Re: pgsql: Fix memory leak in pgbench |
Дата | |
Msg-id | CAD21AoCXhMNiVLYqNtitzKzE07Z88WzV-2FNFxa9VNZC9WZu1w@mail.gmail.com обсуждение исходный текст |
Ответ на | pgsql: Fix memory leak in pgbench (Alvaro Herrera <alvherre@alvh.no-ip.org>) |
Ответы |
Re: pgsql: Fix memory leak in pgbench
Re: pgsql: Fix memory leak in pgbench Re: pgsql: Fix memory leak in pgbench |
Список | pgsql-committers |
On Wed, Apr 10, 2019 at 2:00 AM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: > > Fix memory leak in pgbench > > Commit 25ee70511ec2 introduced a memory leak in pgbench: some PGresult > structs were not being freed during error bailout, because we're now > doing more PQgetResult() calls than previously. Since there's more > cleanup code outside the discard_response() routine than in it, refactor > the cleanup code, removing the routine. > > This has little effect currently, since we abandon processing after > hitting errors, but if we ever get further pgbench features (such as > testing for serializable transactions), it'll matter. > This change leads a compiler warning on my machine: pgbench.c: In function ‘readCommandResponse’: pgbench.c:2730: warning: ISO C90 forbids mixed declarations and code @@ -2739,7 +2726,7 @@ readCommandResponse(CState *st, char *varprefix) while (res != NULL) { /* look now at the next result to know whether it is the last */ - PGresult *next_res = PQgetResult(st->con); + next_res = PQgetResult(st->con); bool is_last = (next_res == NULL); I think we should declare is_last before doing next_res = PQgetResult(st->con). Attached patch fixes it. Regards, -- Masahiko Sawada NIPPON TELEGRAPH AND TELEPHONE CORPORATION NTT Open Source Software Center
Вложения
В списке pgsql-committers по дате отправления: