Re: Union-ifying RangeTblEntry

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Craig Ringer <craig(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Union-ifying RangeTblEntry
Date: 2014-01-28 15:36:09
Message-ID: 22398.1390923369@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Tue, Jan 28, 2014 at 1:18 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
>> In the process I noticed the comment:
>>
>> /*
>> * XXX the fields applicable to only some rte kinds should be
>> * merged into a union. I didn't do this yet because the diffs
>> * would impact a lot of code that is being actively worked on.
>> * FIXME someday.
>> */

> I'd be more inclined to just remove the comment. Does a RangeTblEntry
> really use enough memory that we need to conserve bytes there?

It doesn't; RTEs aren't that big, and more to the point, there aren't that
many of them per query. I think I wrote that comment, many years ago,
when memory was more precious ... but even then it was more out of
neatnik-ism than any real need to conserve space.

A bigger consideration is the risk of introducing bugs: how certain are
we that no code ever touches fields that are not supposed to be used for
the current rtekind? I'm sure not. Right now, it's safe to assume that
e.g. subquery is NULL if it's not an RTE_SUBQUERY, and I think there
are probably places that depend on that.

And lastly, we'd be touching enough code to make such a change a serious
PITA for back-patching, and for third-party modules. In return for not
much.

So yeah, let's just drop the comment in favor of a note that irrelevant
fields should be zero/null.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christian Kruse 2014-01-28 15:43:07 Suspicion of a compiler bug in clang: using ternary operator in ereport()
Previous Message Ioseph Kim 2014-01-28 15:30:14 Mailing subscription test