Commit db80acf
committed
Fix sharing Agg transition state of DISTINCT or ordered aggs.
If a query contained two aggregates that could share the transition value,
we would correctly collect the input into a tuplesort only once, but
incorrectly run the transition function over the accumulated input twice,
in finalize_aggregates(). That caused a crash, when we tried to call
tuplesort_performsort() on an already-freed NULL tuplestore.
Backport to 9.6, where sharing of transition state and this bug were
introduced.
Analysis by Tom Lane.
Discussion: https://www.postgresql.org/message-id/ac5b0b69-744c-9114-6218-8300ac920e61@iki.fi1 parent 7cd0fd6 commit db80acf
File tree
3 files changed
+30
-3
lines changed- src
- backend/executor
- test/regress
- expected
- sql
3 files changed
+30
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
| 1578 | + | |
1578 | 1579 | | |
1579 | 1580 | | |
1580 | 1581 | | |
1581 | 1582 | | |
1582 | 1583 | | |
1583 | 1584 | | |
1584 | | - | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
1585 | 1590 | | |
1586 | | - | |
1587 | | - | |
1588 | 1591 | | |
1589 | 1592 | | |
1590 | 1593 | | |
| |||
1603 | 1606 | | |
1604 | 1607 | | |
1605 | 1608 | | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
1606 | 1621 | | |
1607 | 1622 | | |
1608 | 1623 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1816 | 1816 | | |
1817 | 1817 | | |
1818 | 1818 | | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
1819 | 1828 | | |
1820 | 1829 | | |
1821 | 1830 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
727 | 727 | | |
728 | 728 | | |
729 | 729 | | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
730 | 733 | | |
731 | 734 | | |
732 | 735 | | |
| |||
0 commit comments