From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | 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-01-09 00:52:42 |
Message-ID: | CA+TgmoZfaD3qpzjerSQwTAxHYsONAOWBcB1uUVktBJPN=x=7vA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jan 8, 2013 at 6:23 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> And functions that return static buffers are evil incarnate. I've
>> spent way too much of my life dealing with the supreme idiocy that is
>> fmtId(). If someone ever finds a way to make that go away, I will buy
>> them a beverage of their choice at the next conference we're both at.
>
> Yeah, that was exactly the case that was top-of-mind when I was
> complaining about static return buffers upthread.
>
> It's not hard to make the ugliness go away: just let it strdup its
> return value. The problem is that in the vast majority of usages it
> wouldn't be convenient to free the result, so we'd have a good deal
> of memory leakage. What might be interesting is to instrument it to
> see how much (adding a counter to the function ought to be easy enough)
> and then find out whether it's an amount we still care about in 2013.
> Frankly, pg_dump is a memory hog already - a few more identifier-sized
> strings laying about might not matter anymore.
>
> (Wanders away wondering how many relpathbackend callers bother to free
> its result, and whether that matters either ...)
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.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2013-01-09 00:54:38 | Re: proposal: Set effective_cache_size to greater of .conf value, shared_buffers |
Previous Message | Tom Lane | 2013-01-09 00:23:18 | Re: Index build temp files |