"SELECT ... FROM DUAL" is not quite as silly as it appears

Поиск
Список
Период
Сортировка
От Tom Lane
Тема "SELECT ... FROM DUAL" is not quite as silly as it appears
Дата
Msg-id 15944.1521127664@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: "SELECT ... FROM DUAL" is not quite as silly as it appears  (Robert Haas <robertmhaas@gmail.com>)
Re: "SELECT ... FROM DUAL" is not quite as silly as it appears  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Re: "SELECT ... FROM DUAL" is not quite as silly as it appears  (Thomas Munro <thomas.munro@enterprisedb.com>)
Список pgsql-hackers
We've long made fun of Oracle(TM) for the fact that if you just want
to evaluate some expressions, you have to write "select ... from dual"
rather than just "select ...".  But I've realized recently that there's
a bit of method in that madness after all.  Specifically, having to
cope with FromExprs that contain no base relation is fairly problematic
in the planner.  prepjointree.c is basically unable to cope with
flattening a subquery that looks that way, although we've inserted a
lot of overly-baroque logic to handle some subsets of the case (cf
is_simple_subquery(), around line 1500).  If memory serves, there are
other places that are complicated by the case.

Suppose that, either in the rewriter or early in the planner, we were
to replace such cases with nonempty FromExprs, by adding a dummy RTE
representing a table with no columns and one row.  This would in turn
give rise to an ordinary Path that converts to a Result plan, so that
the case is handled without any special contortions later.  Then there
is no case where we don't have a nonempty relids set identifying a
subquery, so that all that special-case hackery in prepjointree.c
goes away, and we can simplify whatever else is having a hard time
with it.

I'm not planning to do anything about this soon (ie, not before v12),
but I thought I'd get the ideas down on electrons before they vanish.

            regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Removing [Merge]Append nodes which contain a single subpath
Следующее
От: Robert Haas
Дата:
Сообщение: Re: "SELECT ... FROM DUAL" is not quite as silly as it appears