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 1icZxZ-000242-Uy for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 19:05:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icZxY-0003qP-EY for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 19:05:12 +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 1icZxY-0003qI-5q for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 19:05:12 +0000 Received: from mail-vk1-xa41.google.com ([2607:f8b0:4864:20::a41]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icZxU-0002Wr-Gt for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 19:05:11 +0000 Received: by mail-vk1-xa41.google.com with SMTP id l5so300411vkb.4 for ; Wed, 04 Dec 2019 11:05:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=0TpSFRXsXWhpsCUC42OQD+huVMI9TeVpX0HNxtZpj2o=; b=o/wl47AN8NfX6fBX+iLcIXLjS+kqaQS64MDqXbX09d7v67I57J9n5oVw1XX7ubzpM1 HAcBwNrOISWaiFbA82PrBbU7DjP04dec21qhikZMX7UcTWeQE8G1vxgsWQMUt8JwWQuI kC9V+NLucfiUWipgXpITZyrASGDVx5BEN1WlriiNDo3pVNd/SFj75PkMeQGbADiZNNiv jJeZGJsICnYz449qtRrsYgR1oFXRfaBug7IwrQm7arN5BImonKsgEuLob3Y2SfDTbmGz 4VMeU3d7+rLX+MLoWK1Rj303Zhjj+Wq3QGG5in/jMXOYvLvtuOYFnKuGZPZ0dR/UOrhx 7mzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=0TpSFRXsXWhpsCUC42OQD+huVMI9TeVpX0HNxtZpj2o=; b=WaHszF2c44H5SBRXpK9ZxRInusyng+LLKQN5zN7kxD/S6/mNmydiUl2c8n0GndJDt0 teBy9Q3NKrCODhJOQYYJnZ714ZQJlxM6+1QP0el7tdfsHFEn0GJugi0Uw+uwhNZkWIa8 jw7ole+uWUE7R6KLMXaoj5ikF3gZU76zqWTPViW+fQmL6oIoptImMRfsZPk52vXSUWUn o1HOLyl3uCpX8Qf3p0a/FwEN/NfKDl4CCnf8N8wzsR6si3g82EZTCL9oeyyXlkomZ6M2 GSlVsncBYr6Ah9Z3PbpvFpdRQhv3srm682Xlh1SsyMcXpFTrJjM0/R38vFLWs3gvJ23a ke9w== X-Gm-Message-State: APjAAAU3+OYSl8307JJRYOjaoQpiPOv1Uio22nT+mwYWEwEf6EenmFda d3SiDLTx3Twrv0IUZiZRyuwI2g== X-Google-Smtp-Source: APXvYqzRsBGao7y32fK/NVPWyVEg98T+OQ2OxkHPlAEuwPsQjv6pUGuyxOEwGj5jEIeHX2oIXeVY9g== X-Received: by 2002:a1f:20c2:: with SMTP id g185mr3288351vkg.44.1575486305780; Wed, 04 Dec 2019 11:05:05 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id w4sm1844184vsq.18.2019.12.04.11.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 11:05:04 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 491F6300815; Wed, 4 Dec 2019 16:05:01 -0300 (-03) Date: Wed, 4 Dec 2019 16:05:01 -0300 From: Alvaro Herrera To: Tom Lane Cc: Andres Freund , Pg Hackers Subject: Re: adding strndup Message-ID: <20191204190501.GA29287@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <27820.1575485929@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Dec-04, Tom Lane wrote: > 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 can get behind that ... it makes the patch a lot smaller. I'm gonna send an updated version in a jiffy. > > 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".) *shrug* I also looked for pstrndup() first. And Peter E also in https://postgr.es/m/1339713732.11971.79.camel@vanquo.pezone.net submitted an implementation of pstrndup(). I'm not opposed to renaming it, but I hesitate to do it at the same time as putting it in pgport. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services