Re: BUG #5234: ALTER TABLE ... RENAME COLUMN change view definition incorrectly

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: BUG #5234: ALTER TABLE ... RENAME COLUMN change view definition incorrectly
Дата
Msg-id 603c8f070912101049p18e50f2at34bf4fe22c153550@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #5234: ALTER TABLE ... RENAME COLUMN change view definition incorrectly  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Thu, Dec 10, 2009 at 12:32 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> On Thu, Dec 10, 2009 at 11:54 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> The problem with USING is that it is not merely a join condition but
>>> affects the set of columns emitted by the join. =A0It can't be converted
>>> to a simple ON without changing the semantics, and I don't believe we
>>> should try.
>
>> The OP seemed to be pretty clear on what the semantics should be, and
>> I'm not confused either. =A0Why are you? =A0:-)
>
> I'm not confused: it's an error condition. =A0You have not explained why
> it isn't.

Well, it's obviously not an error condition at present, because the
view works perfectly well.  As far as running SELECT statements
against the view, the QUERY structure in ev_rewrite is semantically
equivalent to one without the usingClause.  buildMergedJoinVar()
builds a target list entry that refers to one or both of the
underlying base tables, using COALESCE if necessary.  Nothing in that
join var depends IN ANY WAY on the usingClause.  The JoinExpr
similarly gets rewritten in terms of an equality construct - while
it's true that the usingClause is still present, nothing outside the
parser/deparser actually looks at it.

For that reason, your claim that we CAN'T rewrite USING to a simple ON
without changing the semantics seems to me to be false.  For purposes
of 99.44% of the code, we are already doing it.  The only problem is,
after we do it, and after using that rewritten version to execute the
query, we maintain the fiction that we haven't done it when we dump
the view back out, leading to inconsistent results.

...Robert

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: BUG #5234: ALTER TABLE ... RENAME COLUMN change view definition incorrectly
Следующее
От: "Recursive complex query"
Дата:
Сообщение: BUG #5239: Recursive complex query