Re: [doc fix] Add operation of freeing output SQLDA

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: kato-sho(at)jp(dot)fujitsu(dot)com
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [doc fix] Add operation of freeing output SQLDA
Date: 2018-05-22 01:51:03
Message-ID: 20180522.105103.233653872.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

At Fri, 18 May 2018 06:03:59 +0000, "Kato, Sho" <kato-sho(at)jp(dot)fujitsu(dot)com> wrote in <25C1C6B2E7BE044889E4FE8643A58BA963A42097(at)G01JPEXMBKW03>
> Hello
>
> I think it is better to add freeing operation of output SQLDA to the current PostgreSQL documentation.
> As far as I can see src/interfaces/ecpg/ecpglib/execute.c,
> if a previously existing sqlda is set to output SQLDA,
> then a previously existing sqlda is freed.
> But, the new output SQLDA's memory space remain.

I didn't look it closer but generally speaking output sqlda
should be freed automatically (or by ecpg API) since users don't
know it in detail. It is a linked list so just freeing the first
one is not sufficient(*1). On the other hand ecpg library cannot
free input sqlda since it doesn't know how it was provided. Thus
I'm on the documentation side. I'm not sure of the reason for
freeing output sqlda explicitly in the test code, maybe it is to
avoid valgrind complaint or such like..

I think if output sqlda is not freed and finally orphaned after
correct API usage, it should be fixed. I suppose that EXEC SQL
DEALLOCATE DESCRIPTOR is responsible..

> ecpg regression test also free output SQLDA's memory space.
> The attached patch fixes the documentation.

*1: The test code knows the shape exactly so it can properly free
them in proper way.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2018-05-22 01:51:11 Time to put context diffs in the grave
Previous Message Masahiko Sawada 2018-05-22 01:30:44 Re: [HACKERS] Moving relation extension locks out of heavyweight lock manager