]> granicus.if.org Git - postgresql/commit
Fix mishandling of sortgroupref labels while splitting SRF targetlists.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 21 Jun 2018 14:58:42 +0000 (10:58 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 21 Jun 2018 14:58:42 +0000 (10:58 -0400)
commit07e5a213524853c06684155d4af5a0291d95d25a
treefa3637b6b2905d64544c1b12d127809bc9b0446f
parentbee6a683a5c35ddcdb8253771450c6cf641f3d60
Fix mishandling of sortgroupref labels while splitting SRF targetlists.

split_pathtarget_at_srfs() neglected to worry about sortgroupref labels
in the intermediate PathTargets it constructs.  I think we'd supposed
that their labeling didn't matter, but it does at least for the case that
GroupAggregate/GatherMerge nodes appear immediately under the ProjectSet
step(s).  This results in "ERROR: ORDER/GROUP BY expression not found in
targetlist" during create_plan(), as reported by Rajkumar Raghuwanshi.

To fix, make this logic track the sortgroupref labeling of expressions,
not just their contents.  This also restores the pre-v10 behavior that
separate GROUP BY expressions will be kept distinct even if they are
textually equal().

Discussion: https://postgr.es/m/CAKcux6=1_Ye9kx8YLBPmJs_xE72PPc6vNi5q2AOHowMaCWjJ2w@mail.gmail.com
src/backend/optimizer/util/tlist.c
src/test/regress/expected/select_parallel.out
src/test/regress/sql/select_parallel.sql