RE: Add function to release an allocated SQLDA

From: "Kato, Sho" <kato-sho(at)jp(dot)fujitsu(dot)com>
To: 'Thomas Munro' <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Add function to release an allocated SQLDA
Date: 2018-06-19 09:11:52
Message-ID: 25C1C6B2E7BE044889E4FE8643A58BA963A76A93@G01JPEXMBKW03
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Thomas

Thank you for your reply.

>This is not clear to me. ECPGfreeSQLDA() releases a whole chain, but
>free() only releases a single SQLDA(), so they are obviously not interchangeable. When exactly should a user prefer one over the other?

If an application use FETCH ALL to get the result set at once, a user should use ECPGfreeSQLDA().
Because the user does not know that the SQLDA holds the result set in the chain.
If it does not release it will remain leaked.

Considering the use of people who know the structure of SQLDA, I described the releasing method using free () in the document.

>If there is a good reason to free just one OR the whole chain, shouldn't we provide a way to do both of those things without the user having to use libc free(), for the benefit of Windows users who can't safely use free()?

I think so.
Ok, The behavior when releasing one SQLDA with ECPGfreeSQLDA() is the same as free() and using free() is not safety for Windows users.
So, how about trying to delete the release method using free ()?

>This seems to be a spurious hunk, but I cannot see what changed.

Sorry, this is a mistake..
-----Original Message-----
From: Thomas Munro [mailto:thomas(dot)munro(at)enterprisedb(dot)com]
Sent: Monday, June 18, 2018 2:42 PM
To: Kato, Sho/加藤 翔 <kato-sho(at)jp(dot)fujitsu(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add function to release an allocated SQLDA

On Wed, Jun 13, 2018 at 4:29 PM, Kato, Sho <kato-sho(at)jp(dot)fujitsu(dot)com> wrote:
> I add a function called ECPGfreeSQLDA() becasue there is no API for releasing the SQLDA stored the result set.

Hello Kato-san,

Thank you for sending the patch!

+ Alternatively, use the standard C library's free() function as
in the example below.

+ If the result set contains more than one record, an SQLDA
corresponding to each records is saved as linked list.
+ There is a possibility to free allocated memory area doubly and
cause the application crash,
+ because ECPGfreeSQLDA() releases all SQLDAs associated with the
specified the SQLDA.

This is not clear to me. ECPGfreeSQLDA() releases a whole chain, but
free() only releases a single SQLDA(), so they are obviously not interchangeable. When exactly should a user prefer one over the other? If there is a good reason to free just one OR the whole chain, shouldn't we provide a way to do both of those things without the user having to use libc free(), for the benefit of Windows users who can't safely use free()?

- * the new partition's info into its partition descriptor. If there is a
+ * the new partition's info into its partition descriptor. If there is
+ a

This seems to be a spurious hunk, but I cannot see what changed.

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2018-06-19 09:15:28 Re: Postgres 11 release notes
Previous Message Konstantin Knizhnik 2018-06-19 09:08:27 Re: WAL prefetch