Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o08KE-0007ye-GA for pgsql-general@arkaria.postgresql.org; Sat, 11 Jun 2022 21:07:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o08JD-0008Re-R6 for pgsql-general@arkaria.postgresql.org; Sat, 11 Jun 2022 21:06:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o08JD-0008RV-GG for pgsql-general@lists.postgresql.org; Sat, 11 Jun 2022 21:06:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o08J3-0005uL-QA for pgsql-general@lists.postgresql.org; Sat, 11 Jun 2022 21:06:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 25BL62iK3105048; Sat, 11 Jun 2022 17:06:02 -0400 From: Tom Lane To: Markur Sens cc: pgsql-general Subject: Re: PG_GETARG_TEXT_PP vs PG_GETARG_TEXT_P In-reply-to: References: Comments: In-reply-to Markur Sens message dated "Sat, 11 Jun 2022 22:49:48 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3105046.1654981562.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sat, 11 Jun 2022 17:06:02 -0400 Message-ID: <3105047.1654981562@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Markur Sens 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