postgresql/src/include/nodes
Tom Lane f3b3b8d5be Compute correct em_nullable_relids in get_eclass_for_sort_expr().
Bug #8591 from Claudio Freire demonstrates that get_eclass_for_sort_expr
must be able to compute valid em_nullable_relids for any new equivalence
class members it creates.  I'd worried about this in the commit message
for db9f0e1d9a, but claimed that it wasn't a
problem because multi-member ECs should already exist when it runs.  That
is transparently wrong, though, because this function is also called by
initialize_mergeclause_eclasses, which runs during deconstruct_jointree.
The example given in the bug report (which the new regression test item
is based upon) fails because the COALESCE() expression is first seen by
initialize_mergeclause_eclasses rather than process_equivalence.

Fixing this requires passing the appropriate nullable_relids set to
get_eclass_for_sort_expr, and it requires new code to compute that set
for top-level expressions such as ORDER BY, GROUP BY, etc.  We store
the top-level nullable_relids in a new field in PlannerInfo to avoid
computing it many times.  In the back branches, I've added the new
field at the end of the struct to minimize ABI breakage for planner
plugins.  There doesn't seem to be a good alternative to changing
get_eclass_for_sort_expr's API signature, though.  There probably aren't
any third-party extensions calling that function directly; moreover,
if there are, they probably need to think about what to pass for
nullable_relids anyway.

Back-patch to 9.2, like the previous patch in this area.
2013-11-15 16:46:18 -05:00
..
bitmapset.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
execnodes.h Fix whitespace issues found by git diff --check, add gitattributes 2013-11-10 14:48:29 -05:00
makefuncs.h Add a convenience routine makeFuncCall to reduce duplication. 2013-07-01 14:46:54 -04:00
memnodes.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
nodeFuncs.h Move strip_implicit_coercions() from optimizer to nodeFuncs.c. 2013-07-23 18:21:19 -04:00
nodes.h Add the notion of REPLICA IDENTITY for a table. 2013-11-08 12:30:43 -05:00
params.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
parsenodes.h Fix whitespace issues found by git diff --check, add gitattributes 2013-11-10 14:48:29 -05:00
pg_list.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
plannodes.h Add SQL Standard WITH ORDINALITY support for UNNEST (and any other SRF) 2013-07-29 16:38:01 +01:00
primnodes.h Allow aggregate functions to be VARIADIC. 2013-09-03 17:08:46 -04:00
print.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
readfuncs.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
relation.h Compute correct em_nullable_relids in get_eclass_for_sort_expr(). 2013-11-15 16:46:18 -05:00
replnodes.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tidbitmap.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
value.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00