pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Markur Sens <markursens@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
Date: Sun, 12 Jun 2022 00:14:33 +0300
Message-ID: <5C935137-83B0-4E61-BBEB-2D9D2840B8E9@gmail.com> (raw)
In-Reply-To: <3105047.1654981562@sss.pgh.pa.us>
References: <CC37FB42-8BE2-43F6-A010-D61E439F4BA7@gmail.com>
<3105047.1654981562@sss.pgh.pa.us>
> 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?
view thread (4+ messages) latest in thread
Message-ID: <5C935137-83B0-4E61-BBEB-2D9D2840B8E9@gmail.com> Permalink: ../5C935137-83B0-4E61-BBEB-2D9D2840B8E9@gmail.com/ Also on: postgresql.org/message-id/5C935137-83B0-4E61-BBEB-2D9D2840B8E9@gmail.com ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients from your mail client; the link fills in the headers below: reply via email Some clients, webmail especially, drop In-Reply-To and References from a link, and the reply then starts a new thread: use the mbox below. To: pgsql-general@postgresql.org Cc: markursens@gmail.com, tgl@sss.pgh.pa.us Subject: Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P In-Reply-To: <5C935137-83B0-4E61-BBEB-2D9D2840B8E9@gmail.com> References: <CC37FB42-8BE2-43F6-A010-D61E439F4BA7@gmail.com> <3105047.1654981562@sss.pgh.pa.us> <5C935137-83B0-4E61-BBEB-2D9D2840B8E9@gmail.com> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
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