pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Markur Sens <markursens@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
Date: Sat, 11 Jun 2022 17:06:02 -0400
Message-ID: <3105047.1654981562@sss.pgh.pa.us> (raw)
In-Reply-To: <CC37FB42-8BE2-43F6-A010-D61E439F4BA7@gmail.com>
References: <CC37FB42-8BE2-43F6-A010-D61E439F4BA7@gmail.com>

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





view thread (4+ messages)  latest in thread

Message-ID: <3105047.1654981562@sss.pgh.pa.us>
Permalink:  ../3105047.1654981562@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3105047.1654981562@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, markursens@gmail.com
  Subject: Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P
  In-Reply-To: <3105047.1654981562@sss.pgh.pa.us>
  References: <CC37FB42-8BE2-43F6-A010-D61E439F4BA7@gmail.com> <3105047.1654981562@sss.pgh.pa.us>

* 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