Cleanup: Use modern macro for text-to-CString conversion in plsample.c
Cleanup: Use modern macro for text-to-CString conversion in plsample.c
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
Re: Cleanup: Use modern macro for text-to-CString conversion in plsample.c
От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Fri, Apr 17, 2026 at 9:55 PM Amul Sul 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