forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd8a2953
committed
Strip off ORDER BY/DISTINCT aggregate pathkeys in create_agg_path
1349d27 added code to adjust the PlannerInfo.group_pathkeys so thatORDER BY / DISTINCT aggregate functions could obtain pre-sorted inputsto allow faster execution. That commit forgot to adjust the pathkeys increate_agg_path(). Some code in there assumed that it was always fineto make the AggPath's pathkeys the same as its subpath's. That seems tohave been ok up until1349d27, but since that commit adds pathkeys forcolumns which are within the aggregate function, those columns won't beavailable above the aggregate node. This can result in "could not findpathkey item to sort" during create_plan().The fix here is to strip off the additional pathkeys added byadjust_group_pathkeys_for_groupagg(). It seems that the pathkeys herewill only ever be group_pathkeys, so all we need to do is check if thelength of the pathkey list is longer than the num_groupby_pathkeys andget rid of the additional ones only if we see extras.Reported-by: Justin PryzbyReviewed-by: Richard GuoDiscussion:https://postgr.es/m/ZQhYYRhUxpW3PSf9%40telsasoft.comBackpatch-through: 16, where1349d27 was introduced1 parent77db132 commitd8a2953
1 file changed
+17
-1
lines changedLines changed: 17 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3133 | 3133 |
| |
3134 | 3134 |
| |
3135 | 3135 |
| |
| 3136 | + | |
3136 | 3137 |
| |
3137 |
| - | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
3138 | 3153 |
| |
3139 | 3154 |
| |
| 3155 | + | |
3140 | 3156 |
| |
3141 | 3157 |
| |
3142 | 3158 |
| |
|
0 commit comments
Comments
(0)