Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P

From: Markur Sens <markursens(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
Date: 2022-06-11 21:14:33
Message-ID: 5C935137-83B0-4E61-BBEB-2D9D2840B8E9@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On 12 Jun 2022, at 12:06 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Markur Sens <markursens(at)gmail(dot)com> writes:
>> In the “Extending SQL” chapter I see both of these forms are mentioned.
>> But can’t find info about when to use which one.
>
> PG_GETARG_TEXT_P returns a traditional-format, 4-byte-header value.
>
> PG_GETARG_TEXT_PP is allowed to return either that or a 1-byte-header
> value, in case that's what the input is.
>
> PG_GETARG_TEXT_PP is preferred in new code since it can avoid one
> step of palloc-and-copy-the-value; the only real downside is you
> have to use the appropriate macros to get the string's start address
> and length.
>
> regards, tom lane

Ah Thanks. I wouldn’t have guessed that.
And I don’t see this mentioned in the header files either.

Is it worth adding a relevant comment in the documentation section?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2022-06-11 21:25:27 Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
Previous Message Tom Lane 2022-06-11 21:06:02 Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P