Re: default values for views

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: default values for views
Date: 2002-04-16 00:40:46
Message-ID: 7702.1018917646@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> Apparently, you need to make two calls to appendPQExpBuffer() to
> use fmtId() twice, because it uses a static buffer (thanks for
> spotting this Tom).

I think people have been bit by that before. It's fairly easy to miss
at present, because fmtId only uses the static buffer if it decides to
quote the name. If your test case doesn't exercise that path, you'll
not notice the problem.

We could improve the odds at a cost of a small number of cycles, by
having fmtId copy the name into its static buffer even if it doesn't
need to quote. Then the buffer would always be used, and erroneous
reuse of fmtId should be pretty obvious.

(In case anyone's about to suggest that we avoid the problem by
malloc'ing the result, the trouble with that approach is it means
memory leakage --- at least unless the call sites are uglified
quite a lot to free the returned strings after use. I like this
way better; but we should try to make it a tad less error-prone.)

Any objections?

regards, tom lane

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2002-04-16 00:47:39 Re: ANSI Compliant Inserts
Previous Message Tom Lane 2002-04-16 00:15:53 Re: default values for views