On 2019-Dec-04, Alvaro Herrera wrote:
> On 2019-Dec-04, Tom Lane wrote:
>
> > Andres Freund <andres@anarazel.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