Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icZrf-0001ps-AV for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 18:59:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icZrc-0007sT-CR for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 18:59:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icZrc-0007sM-3d for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 18:59:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icZrU-0002Oe-OY for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 18:59:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xB4IwnL3027821; Wed, 4 Dec 2019 13:58:49 -0500 From: Tom Lane To: Andres Freund cc: Alvaro Herrera , Pg Hackers Subject: Re: adding strndup In-reply-to: <20191204180457.6yo3dhjsmhlj52ky@alap3.anarazel.de> References: <20191204144021.GA17976@alvherre.pgsql> <20191204180457.6yo3dhjsmhlj52ky@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 04 Dec 2019 10:04:57 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27819.1575485929.1@sss.pgh.pa.us> Date: Wed, 04 Dec 2019 13:58:49 -0500 Message-ID: <27820.1575485929@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2019-12-04 11:40:21 -0300, Alvaro Herrera wrote: >> I think this should be pretty uncontroversial, but wanted to give a >> heads-up outside that thread. I attach the patch here for completeness. > I'd just provide pnstrdup() in the frontend, without adding strndup(). +1 --- seems like a bunch more mechanism than is warranted. Let's just open-code it in pnstrdup. We can rely on strnlen, since that's already supported, and there's not much more there beyond that. > I also see no point in adding both pnstrdup() and pg_strndup(). I'm fine > with moving towards pg_strndup(), but then we just ought to remove > pnstrdup(). There's a fair number of uses of pnstrdup in the backend. While it wouldn't be too painful to rename them, I'm not sure I see the point. (What I'd really argue for, if we did rename, is "pstrndup".) regards, tom lane