agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Andy Fan <zhihuifan1213@163.com>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: GetRelationPath() vs critical sections
Date: Sun, 06 Oct 2024 11:53:59 +0800
Message-ID: <874j5plwdk.fsf@163.com> (raw)
In-Reply-To: <CA+hUKGLAznzOPc34+qYAumJz+P66sc58XkM+68NO=xstoVwQ6A@mail.gmail.com>
References: <h3a7ftrxypgxbw6ukcrrkspjon5dlninedwb5udkrase3rgqvn@3cokde6btlrl>
<CA+hUKGLAznzOPc34+qYAumJz+P66sc58XkM+68NO=xstoVwQ6A@mail.gmail.com>
Thomas Munro <thomas.munro@gmail.com> writes:
> On Thu, Sep 5, 2024 at 3:58 AM Andres Freund <andres@anarazel.de> wrote:
>> Obviously we could add a version of GetRelationPath() that just prints into a
>> caller provided buffer - but that's somewhat awkward API wise.
>
> For the record, that's exactly what I did in the patch I proposed to
> fix our long standing RelationTruncate() data-eating bug:
>
> https://www.postgresql.org/message-id/flat/CA%2BhUKG%2B5nfWcpnZ%3DZ%3DUpGvY1tTF%3D4QU_0U_07EFaKmH7Nr...
I want to have a dicussion on the user provided buffer APIs. I just get
the similar feedback on [1] because of this recently..
I agree that "user provided buffer" API is bad for the reasons like:
a). inconvenient since user need to provide the buffer. b) unsafe
because user may provide a incorrect buffer. But it still have some
advantages, like c). allocate the memory in a expected MemoryContext
rather than CurrentMemoryContext. d). Allocating the memory at the
different time rather than executing the API e). API can write the data
to the user descired buffer directly rather than another
copy after. My user case at [1] is because of (c) and (e), and the user
case here looks because of factor (d).
Come to the badness of "user provided buffer" API, I think we can ease
them by providing both the non-user-buffer API and user-provided-buffer
API. Since the later one is safe and convenient, so
people probably user the non-user-buffer API by default and just the
user who wants the benefits of "provided-buffer" would use that API.
Am I miss some important factors on this topic?
[1]
https://www.postgresql.org/message-id/1882669.1726701697%40sss.pgh.pa.us
(I read the above topic [1] now, I just realize I proposed to [change] the
API rather than adding an new variant, that's not my intention and
that's my fault).
--
Best Regards
Andy Fan
view thread (19+ messages) latest in thread
Message-ID: <874j5plwdk.fsf@163.com>
Permalink: ../874j5plwdk.fsf@163.com/
Also on: postgresql.org/message-id/874j5plwdk.fsf@163.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: zhihuifan1213@163.com, thomas.munro@gmail.com, andres@anarazel.de
Subject: Re: GetRelationPath() vs critical sections
In-Reply-To: <874j5plwdk.fsf@163.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox