Re: Cleanup: Use modern macro for text-to-CString conversion in plsample.c

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Cleanup: Use modern macro for text-to-CString conversion in plsample.c
Date: 2026-04-20 12:20:22
Message-ID: CAHGQGwHRAs4LQwtWM2OY0w3Z6kM3fCwnjGdy=nx4oGsCA3SC7w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Apr 17, 2026 at 9:55 PM Amul Sul <sulamul(at)gmail(dot)com> wrote:
>
> Hi,
>
> I noticed that plsample.c uses an outdated method to convert text data
> to a C string. This old method calls the textout function manually,
> which adds unnecessary overhead.
>
> The attached patch replaces this with the TextDatumGetCString() macro.
> This macro is more efficient and automatically handles "detoasting"
> (decompressing/fetching) the data.
>
> Since plsample serves as a template for developers writing new
> extensions, it should follow current best practices. This patch
> updates the code in both the function and trigger handlers.

LGTM.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Xuneng Zhou 2026-04-20 13:03:41 Re: First draft of PG 19 release notes
Previous Message vignesh C 2026-04-20 12:13:15 Re: Skipping schema changes in publication