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

Started by Amul Sul7 months ago4 messageshackers
Jump to latest
#1Amul Sul
sulamul@gmail.com

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.

--
Regards,
Amul Sul
EDB: http://www.enterprisedb.com

Attachments:

0001-plsample-Use-TextDatumGetCString-for-text-to-CString.patchapplication/x-patch; name=0001-plsample-Use-TextDatumGetCString-for-text-to-CString.patchDownload+3-3
#2Fujii Masao
masao.fujii@gmail.com
In reply to: Amul Sul (#1)
Re: Cleanup: Use modern macro for text-to-CString conversion in plsample.c

On Fri, Apr 17, 2026 at 9:55 PM Amul Sul <sulamul@gmail.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

#3Fujii Masao
masao.fujii@gmail.com
In reply to: Fujii Masao (#2)
Re: Cleanup: Use modern macro for text-to-CString conversion in plsample.c

On Mon, Apr 20, 2026 at 9:20 PM Fujii Masao <masao.fujii@gmail.com> wrote:

LGTM.

I've pushed the patch. Thanks!

Regards,

--
Fujii Masao

#4Amul Sul
sulamul@gmail.com
In reply to: Fujii Masao (#3)
Re: Cleanup: Use modern macro for text-to-CString conversion in plsample.c

On Tue, Apr 21, 2026 at 5:11 AM Fujii Masao <masao.fujii@gmail.com> wrote:

On Mon, Apr 20, 2026 at 9:20 PM Fujii Masao <masao.fujii@gmail.com> wrote:

LGTM.

I've pushed the patch. Thanks!

Thank you, Fujii-san.

Regards,
Amul