Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group