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

amul sul <sulamul@gmail.com>

From: Amul Sul <sulamul@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-17T12:54:58Z
Lists: pgsql-hackers

Attachments

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

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. plsample: Use TextDatumGetCString() for text-to-CString conversion