- Notifications
You must be signed in to change notification settings - Fork5
Commit915b703
committed
Fix handling of argument and result datatypes for partial aggregation.
When doing partial aggregation, the args list of the upper (combining)Aggref node is replaced by a Var representing the output of the partialaggregation steps, which has either the aggregate's transition data typeor a serialized representation of that. However, nodeAgg.c blindlycontinued to use the args list as an indication of the user-level argumenttypes. This broke resolution of polymorphic transition datatypes atexecutor startup (though it accidentally failed to fail for the ANYARRAYcase, which is likely the only one anyone had tested). Moreover, theconstructed FuncExpr passed to the finalfunc contained completely wronginformation, which would have led to bogus answers or crashes for any casewhere the finalfunc examined that information (which is only likely to bewith polymorphic aggregates using a non-polymorphic transition type).As an independent bug, apply_partialaggref_adjustment neglected to resolvea polymorphic transition datatype before assigning it as the output typeof the lower-level Aggref node. This again accidentally failed to failfor ANYARRAY but would be unlikely to work in other cases.To fix the first problem, record the user-level argument types in aseparate OID-list field of Aggref, and look to that rather than the argslist when asking what the argument types were. (It turns out to beconvenient to include any "direct" arguments in this list too, althoughthose are not currently subject to being overwritten.)Rather than adding yet another resolve_aggregate_transtype() call to fixthe second problem, add an aggtranstype field to Aggref, and store theresolved transition type OID there when the planner first computes it.(By doing this in the planner and not the parser, we can allow theaggregate's transition type to change from time to time, although no DDLsupport yet exists for that.) This saves nothing of consequence forsimple non-polymorphic aggregates, but for polymorphic transition typeswe save a catalog lookup during executor startup as well as severalplanner lookups that are new in 9.6 due to parallel query planning.In passing, fix an error that was introduced into count_agg_clauses_walkersome time ago: it was applying exprTypmod() to something that wasn't anexpression node at all, but a TargetEntry. exprTypmod silently returned-1 so that there was not an obvious failure, but this broke the intendedsensitivity of aggregate space consumption estimates to the typmod ofvarchar and similar data types. This part needs to be back-patched.Catversion bump due to change of stored Aggref nodes.Discussion: <8229.1466109074@sss.pgh.pa.us>1 parentd30d1ac commit915b703
File tree
13 files changed
+104
-53
lines changed- src
- backend
- executor
- nodes
- optimizer
- plan
- util
- parser
- include
- catalog
- nodes
13 files changed
+104
-53
lines changedLines changed: 6 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2715 | 2715 |
| |
2716 | 2716 |
| |
2717 | 2717 |
| |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
2718 | 2722 |
| |
2719 | 2723 |
| |
2720 | 2724 |
| |
| |||
2745 | 2749 |
| |
2746 | 2750 |
| |
2747 | 2751 |
| |
2748 |
| - | |
| 2752 | + | |
2749 | 2753 |
| |
2750 | 2754 |
| |
2751 | 2755 |
| |
| |||
2835 | 2839 |
| |
2836 | 2840 |
| |
2837 | 2841 |
| |
2838 |
| - | |
2839 |
| - | |
2840 |
| - | |
2841 |
| - | |
2842 |
| - | |
2843 |
| - | |
2844 | 2842 |
| |
2845 | 2843 |
| |
2846 | 2844 |
| |
| |||
3304 | 3302 |
| |
3305 | 3303 |
| |
3306 | 3304 |
| |
| 3305 | + | |
3307 | 3306 |
| |
3308 | 3307 |
| |
3309 | 3308 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1237 | 1237 |
| |
1238 | 1238 |
| |
1239 | 1239 |
| |
| 1240 | + | |
| 1241 | + | |
1240 | 1242 |
| |
1241 | 1243 |
| |
1242 | 1244 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
195 | 195 |
| |
196 | 196 |
| |
197 | 197 |
| |
| 198 | + | |
| 199 | + | |
198 | 200 |
| |
199 | 201 |
| |
200 | 202 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2451 | 2451 |
| |
2452 | 2452 |
| |
2453 | 2453 |
| |
| 2454 | + | |
| 2455 | + | |
2454 | 2456 |
| |
2455 | 2457 |
| |
2456 | 2458 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1033 | 1033 |
| |
1034 | 1034 |
| |
1035 | 1035 |
| |
| 1036 | + | |
| 1037 | + | |
1036 | 1038 |
| |
1037 | 1039 |
| |
1038 | 1040 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
549 | 549 |
| |
550 | 550 |
| |
551 | 551 |
| |
| 552 | + | |
| 553 | + | |
552 | 554 |
| |
553 | 555 |
| |
554 | 556 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2085 | 2085 |
| |
2086 | 2086 |
| |
2087 | 2087 |
| |
| 2088 | + | |
2088 | 2089 |
| |
2089 | 2090 |
| |
2090 | 2091 |
| |
|
Lines changed: 35 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
523 | 523 |
| |
524 | 524 |
| |
525 | 525 |
| |
526 |
| - | |
| 526 | + | |
527 | 527 |
| |
528 | 528 |
| |
529 | 529 |
| |
| |||
532 | 532 |
| |
533 | 533 |
| |
534 | 534 |
| |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
535 | 539 |
| |
536 | 540 |
| |
537 | 541 |
| |
| |||
572 | 576 |
| |
573 | 577 |
| |
574 | 578 |
| |
575 |
| - | |
576 |
| - | |
577 | 579 |
| |
578 | 580 |
| |
579 | 581 |
| |
| |||
597 | 599 |
| |
598 | 600 |
| |
599 | 601 |
| |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
600 | 624 |
| |
601 | 625 |
| |
602 | 626 |
| |
| |||
668 | 692 |
| |
669 | 693 |
| |
670 | 694 |
| |
671 |
| - | |
672 |
| - | |
673 |
| - | |
674 |
| - | |
675 |
| - | |
676 |
| - | |
677 |
| - | |
678 |
| - | |
679 |
| - | |
680 | 695 |
| |
681 | 696 |
| |
682 | 697 |
| |
| |||
698 | 713 |
| |
699 | 714 |
| |
700 | 715 |
| |
701 |
| - | |
702 |
| - | |
| 716 | + | |
703 | 717 |
| |
704 |
| - | |
705 |
| - | |
706 |
| - | |
707 |
| - | |
708 |
| - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
709 | 725 |
| |
710 | 726 |
| |
711 | 727 |
| |
|
Lines changed: 11 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
797 | 797 |
| |
798 | 798 |
| |
799 | 799 |
| |
800 |
| - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
801 | 806 |
| |
802 | 807 |
| |
803 | 808 |
| |
804 |
| - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
805 | 814 |
| |
806 | 815 |
| |
807 | 816 |
| |
|
Lines changed: 22 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
80 |
| - | |
81 |
| - | |
82 |
| - | |
83 |
| - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| |||
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
| 104 | + | |
104 | 105 |
| |
105 | 106 |
| |
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
109 | 110 |
| |
110 | 111 |
| |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
111 | 124 |
| |
112 | 125 |
| |
113 | 126 |
| |
| |||
1763 | 1776 |
| |
1764 | 1777 |
| |
1765 | 1778 |
| |
1766 |
| - | |
1767 |
| - | |
1768 |
| - | |
1769 |
| - | |
1770 |
| - | |
1771 |
| - | |
1772 |
| - | |
1773 |
| - | |
| 1779 | + | |
1774 | 1780 |
| |
1775 |
| - | |
1776 |
| - | |
| 1781 | + | |
1777 | 1782 |
| |
1778 |
| - | |
1779 |
| - | |
1780 |
| - | |
1781 |
| - | |
1782 |
| - | |
1783 |
| - | |
1784 |
| - | |
1785 |
| - | |
| 1783 | + | |
1786 | 1784 |
| |
1787 | 1785 |
| |
1788 | 1786 |
| |
| |||
1795 | 1793 |
| |
1796 | 1794 |
| |
1797 | 1795 |
| |
1798 |
| - | |
1799 |
| - | |
| 1796 | + | |
| 1797 | + | |
1800 | 1798 |
| |
1801 | 1799 |
| |
1802 | 1800 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
650 | 650 |
| |
651 | 651 |
| |
652 | 652 |
| |
| 653 | + | |
| 654 | + | |
653 | 655 |
| |
654 | 656 |
| |
655 | 657 |
| |
656 | 658 |
| |
657 | 659 |
| |
| 660 | + | |
| 661 | + | |
658 | 662 |
| |
659 | 663 |
| |
660 | 664 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 |
| - | |
| 56 | + | |
57 | 57 |
| |
58 | 58 |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
256 | 256 |
| |
257 | 257 |
| |
258 | 258 |
| |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
259 | 271 |
| |
260 | 272 |
| |
261 | 273 |
| |
| |||
272 | 284 |
| |
273 | 285 |
| |
274 | 286 |
| |
| 287 | + | |
| 288 | + | |
275 | 289 |
| |
276 | 290 |
| |
277 | 291 |
| |
|
0 commit comments
Comments
(0)