Re: "SELECT ... FROM DUAL" is not quite as silly as it appears
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-10-15T03:25:09Z
Lists: pgsql-hackers
Attachments
- get-rid-of-empty-jointrees-2.patch (text/x-diff) patch
I wrote: > * There's a hack in nodeResult.c to prevent the executor from crashing > on a whole-row Var for an RTE_RESULT RTE, which is something that the > planner will create in SELECT FOR UPDATE cases, because it thinks it > needs to provide a ROW_MARK_COPY image of the RTE's output. We might > be able to get rid of that if we could teach the planner that it need > not bother rowmarking RESULT RTEs, but that seemed like it would be > really messy. (At the point where the decision is made, we don't know > whether a subquery might end up as just a RESULT, or indeed vanish > entirely.) Since I couldn't measure any reproducible penalty from > having the extra setup cost for a Result plan, I left it like this. Well, I'd barely sent this when I realized that there was a better way. The nodeResult.c hack predates my decision to postpone cleaning up RTE_RESULT RTEs till near the end of the preprocessing phase, and given that code, it is easy to get rid of rowmarking RESULT RTEs ... in fact, the code was doing it already, except in the edge case of a SELECT with only a RESULT RTE. So here's a version that does not touch nodeResult.c. regards, tom lane
Commits
-
In the planner, replace an empty FROM clause with a dummy RTE.
- 4be058fe9ec5 12.0 landed
-
Fix jit compilation bug on wide tables.
- b238527664ec 12.0 cited