Re: detoast datum into the given buffer as a optimization.

Nikita Malakhov <hukutoc@gmail.com>

From: Nikita Malakhov <hukutoc@gmail.com>
To: Andy Fan <zhihuifan1213@163.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, David Rowley <dgrowley@gmail.com>, Tomas Vondra <tomas@vondra.me>
Date: 2024-10-29T13:44:27Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Avoid detoast in texteq/textne/byteaeq/byteane for unequal-length strings.

Hi!

Sorry for misguiding you, I've overlooked va_rawsize with va_extinfo.
You're right, va_rawsize holds uncompressed size, and extinfo actual
storage size. This was not intentional.

I'd better not count on caller's do know detoasted data length,
and much more the buffer is correctly initialized, because we cannot
check that inside and must rely on the caller, which would for sure
lead to unexpected segfaults, I agree with Tom Lane's proposal above.
Other options seem to be more crude and error-prone here. This is
an internal data fetching function and it should not generate new kinds
of errors, I think.

In case you're playing with this part of the code - I was always
confused with detoast_attr and detoast_external_attr functions
both marked as entry points of retrieving toasted data and both
look a lot the same. Have you ever thought of making a single
entry point by slightly redesigning this part?

-- 
Regards,
Nikita Malakhov
Postgres Professional
The Russian Postgres Company
https://postgrespro.ru/