postgresql/src/include/nodes
Tom Lane 14a158f9bf Fix interaction of CASE and ArrayCoerceExpr.
An array-type coercion appearing within a CASE that has a constant
(after const-folding) test expression was mangled by the planner, causing
all the elements of the resulting array to be equal to the coerced value
of the CASE's test expression.  This is my oversight in commit c12d570fa:
that changed ArrayCoerceExpr to use a subexpression involving a
CaseTestExpr, and I didn't notice that eval_const_expressions needed an
adjustment to keep from folding such a CaseTestExpr to a constant when
it's inside a suitable CASE.

This is another in what's getting to be a depressingly long line of bugs
associated with misidentification of the referent of a CaseTestExpr.
We're overdue to redesign that mechanism; but any such fix is unlikely
to be back-patchable into v11.  As a stopgap, fix eval_const_expressions
to do what it must here.  Also add a bunch of comments pointing out the
restrictions and assumptions that are needed to make this work at all.

Also fix a related oversight: contain_context_dependent_node() was not
aware of the relationship of ArrayCoerceExpr to CaseTestExpr.  That was
somewhat fail-soft, in that the outcome of a wrong answer would be to
prevent optimizations that could have been made, but let's fix it while
we're at it.

Per bug #15471 from Matt Williams.  Back-patch to v11 where the faulty
logic came in.

Discussion: https://postgr.es/m/15471-1117f49271989bad@postgresql.org
2018-10-30 15:26:11 -04:00
..
bitmapset.h Add bms_prev_member function 2018-04-07 17:54:39 -03:00
execnodes.h Improve some comments related to executor result relations. 2018-10-17 16:41:00 -04:00
extensible.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
lockoptions.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
makefuncs.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
memnodes.h Allow memory contexts to have both fixed and variable ident strings. 2018-03-27 16:46:51 -04:00
nodeFuncs.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
nodes.h Add a debugging option to stress-test outfuncs.c and readfuncs.c. 2018-09-18 17:11:54 -04:00
params.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
parsenodes.h Add option SKIP_LOCKED to VACUUM and ANALYZE 2018-10-04 09:00:33 +09:00
pg_list.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
plannodes.h Remove some unnecessary fields from Plan trees. 2018-10-07 14:33:17 -04:00
primnodes.h Fix interaction of CASE and ArrayCoerceExpr. 2018-10-30 15:26:11 -04:00
print.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
readfuncs.h Add a debugging option to stress-test outfuncs.c and readfuncs.c. 2018-09-18 17:11:54 -04:00
relation.h Remove some unnecessary fields from Plan trees. 2018-10-07 14:33:17 -04:00
replnodes.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
tidbitmap.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
value.h Change internal integer representation of Value node 2018-03-13 09:56:25 -04:00