Re: adding strndup

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: adding strndup
Date: 2019-12-04 22:01:46
Message-ID: 20191204220146.GA28850@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-Dec-04, Alvaro Herrera wrote:

> On 2019-Dec-04, Tom Lane wrote:
>
> > Andres Freund <andres(at)anarazel(dot)de> 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.

Here it is.

I noticed that ECPG's copy was setting errno. I had forgot to do that
in my previous patch, but on second look, malloc failure already sets
it, so doing it again is pointless.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v4-0001-Offer-pnstrdup-to-frontend-code.patch text/x-diff 5.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-12-04 22:17:10 Re: adding strndup
Previous Message Tom Lane 2019-12-04 21:34:42 Re: more backtraces