public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Andy Fan <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: David Rowley <[email protected]>
Cc: Tomas Vondra <[email protected]>
Subject: Re: detoast datum into the given buffer as a optimization.
Date: Wed, 18 Sep 2024 19:21:37 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Andy Fan <[email protected]> writes:
> * Note if caller provides a non-NULL buffer, it is the duty of caller
> * to make sure it has enough room for the detoasted format (Usually
> * they can use toast_raw_datum_size to get the size)
This is a pretty awful, unsafe API design. It puts it on the caller
to know how to get the detoasted length, and it implies double
decoding of the toast datum.
> One of the key point is we can always get the varlena rawsize cheaply
> without any real detoast activity in advance, thanks to the existing
> varlena design.
This is not an assumption I care to wire into the API design.
How about a variant like
struct varlena *
detoast_attr_cxt(struct varlena *attr, MemoryContext cxt)
which promises to allocate the result in the specified context?
That would cover most of the practical use-cases, I think.
regards, tom lane
view thread (2+ messages)
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: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: detoast datum into the given buffer as a optimization.
In-Reply-To: <[email protected]>
* 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