forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd3237e0
committed
Fix SELECT DISTINCT with index-optimized MIN/MAX on inheritance trees.
In a query such as "SELECT DISTINCT min(x) FROM tab", the DISTINCT ispretty useless (there being only one output row), but nonetheless itshouldn't fail. But it could fail if "tab" is an inheritance parent,because planagg.c's code for fixing up equivalence classes after making theindex-optimized MIN/MAX transformation wasn't prepared to find child-tableversions of the aggregate expression. The least ugly fix seems to beto add an option to mutate_eclass_expressions() to skip child-tableequivalence class members, which aren't used anymore at this stage ofplanning so it's not really necessary to fix them. Since child membersare ignored in many cases already, it seems plausible formutate_eclass_expressions() to have an option to ignore them too.Per bug #7703 from Maxim Boguk.Back-patch to 9.1. Although the same code exists before that, it cannotencounter child-table aggregates AFAICS, because the index optimizationtransformation cannot succeed on inheritance trees before 9.1 (for lackof MergeAppend).1 parent6b711cf commitd3237e0
File tree
5 files changed
+59
-6
lines changed- src
- backend/optimizer
- path
- plan
- include/optimizer
- test/regress
- expected
- sql
5 files changed
+59
-6
lines changedLines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1973 | 1973 |
| |
1974 | 1974 |
| |
1975 | 1975 |
| |
1976 |
| - | |
| 1976 | + | |
1977 | 1977 |
| |
1978 | 1978 |
| |
1979 | 1979 |
| |
1980 | 1980 |
| |
1981 |
| - | |
| 1981 | + | |
1982 | 1982 |
| |
1983 | 1983 |
| |
1984 | 1984 |
| |
| |||
1988 | 1988 |
| |
1989 | 1989 |
| |
1990 | 1990 |
| |
1991 |
| - | |
| 1991 | + | |
| 1992 | + | |
1992 | 1993 |
| |
1993 | 1994 |
| |
1994 | 1995 |
| |
| |||
2001 | 2002 |
| |
2002 | 2003 |
| |
2003 | 2004 |
| |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
2004 | 2008 |
| |
2005 | 2009 |
| |
2006 | 2010 |
| |
|
Lines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
257 | 257 |
| |
258 | 258 |
| |
259 | 259 |
| |
260 |
| - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
261 | 264 |
| |
262 | 265 |
| |
263 | 266 |
| |
264 | 267 |
| |
265 | 268 |
| |
266 | 269 |
| |
267 | 270 |
| |
268 |
| - | |
| 271 | + | |
| 272 | + | |
269 | 273 |
| |
270 | 274 |
| |
271 | 275 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
127 |
| - | |
| 127 | + | |
| 128 | + | |
128 | 129 |
| |
129 | 130 |
| |
130 | 131 |
| |
|
Lines changed: 39 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
740 | 740 |
| |
741 | 741 |
| |
742 | 742 |
| |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
743 | 782 |
| |
744 | 783 |
| |
745 | 784 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
278 | 278 |
| |
279 | 279 |
| |
280 | 280 |
| |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
281 | 286 |
| |
282 | 287 |
| |
283 | 288 |
| |
|
0 commit comments
Comments
(0)