pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
4+ messages / 2 participants
[nested] [flat]
* PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
@ 2022-06-11 19:49 Markur Sens <markursens@gmail.com>
2022-06-11 21:06 ` Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Markur Sens @ 2022-06-11 19:49 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
In the “Extending SQL” chapter I see both of these forms are mentioned.
But can’t find info about when to use which one.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
2022-06-11 19:49 PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Markur Sens <markursens@gmail.com>
@ 2022-06-11 21:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-06-11 21:14 ` Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Markur Sens <markursens@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2022-06-11 21:06 UTC (permalink / raw)
To: Markur Sens <markursens@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Markur Sens <markursens@gmail.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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
2022-06-11 19:49 PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Markur Sens <markursens@gmail.com>
2022-06-11 21:06 ` Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Tom Lane <tgl@sss.pgh.pa.us>
@ 2022-06-11 21:14 ` Markur Sens <markursens@gmail.com>
2022-06-11 21:25 ` Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Markur Sens @ 2022-06-11 21:14 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
> On 12 Jun 2022, at 12:06 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Markur Sens <markursens@gmail.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?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
2022-06-11 19:49 PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Markur Sens <markursens@gmail.com>
2022-06-11 21:06 ` Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Tom Lane <tgl@sss.pgh.pa.us>
2022-06-11 21:14 ` Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Markur Sens <markursens@gmail.com>
@ 2022-06-11 21:25 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2022-06-11 21:25 UTC (permalink / raw)
To: Markur Sens <markursens@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Markur Sens <markursens@gmail.com> writes:
> On 12 Jun 2022, at 12:06 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 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.
> Is it worth adding a relevant comment in the documentation section?
It is documented in the source code where these macros are defined
(fmgr.h).
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2022-06-11 21:25 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-06-11 19:49 PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P Markur Sens <markursens@gmail.com>
2022-06-11 21:06 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-06-11 21:14 ` Markur Sens <markursens@gmail.com>
2022-06-11 21:25 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox