Re: [PATCH 2/5] Make relpathbackend return a statically result instead of palloc()'ing it

From: Noah Misch <noah(at)leadboat(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH 2/5] Make relpathbackend return a statically result instead of palloc()'ing it
Date: 2013-02-20 03:28:04
Message-ID: 20130220032804.GA9455@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 08, 2013 at 08:02:16PM -0500, Robert Haas wrote:
> On Tue, Jan 8, 2013 at 7:57 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> >> I was thinking more about a sprintf()-type function that only
> >> understands a handful of escapes, but adds the additional and novel
> >> escapes %I (quote as identifier) and %L (quote as literal). I think
> >> that would allow a great deal of code simplification, and it'd be more
> >> efficient, too.
> >
> > Seems like a great idea. Are you offering to code it?
>
> Not imminently.
>
> > Note that this wouldn't entirely fix the fmtId problem, as not all the
> > uses of fmtId are directly in sprintf calls. Still, it might get rid of
> > most of the places where it'd be painful to avoid a memory leak with
> > a strdup'ing version of fmtId.
>
> Yeah, I didn't think about that. Might be worth a look to see how
> comprehensively it would solve the problem. But I'll have to leave
> that for another day.

As a cheap solution addressing 95+% of the trouble, how about giving fmtId() a
ring of, say, eight static buffers to cycle through? That satisfies code
merely wishing to pass multiple fmtId()'d values to one appendPQExpBuffer().

--
Noah Misch
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2013-02-20 03:59:45 Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system
Previous Message Joachim Wieland 2013-02-20 03:16:30 Re: posix_fadvise missing in the walsender