forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit61f9dae
committed
Fix check_agg_arguments' examination of aggregate FILTER clauses.
Recursion into the FILTER clause was mis-implemented, such that arelevant Var or Aggref at the very top of the FILTER clause wouldbe ignored. (Of course, that'd have to be a plain boolean Var orboolean-returning aggregate.) The consequence would bemis-identification of the correct semantic level of the aggregate,which could lead to not-per-spec query behavior. If the FILTERexpression is an aggregate, this could also lead to failure to issuean expected "aggregate function calls cannot be nested" error, whichwould likely result in a core dump later on, since the planner andexecutor aren't expecting such cases to appear.The root cause is that commitb560ec1 blindly copied some codethat assumed it's recursing into a List, and thus didn't examine thetop-level node. To forestall questions about why this call doesn'tlook like the others, as well as possible future copy-and-pastemistakes, let's change all three check_agg_arguments_walker calls incheck_agg_arguments, even though only the one for the filter clauseis really broken.Per bug #17152 from Zhiyong Wu. This has been wrong since weimplemented FILTER, so back-patch to all supported versions.(Testing suggests that pre-v11 branches manage to avoid crashingin the bad-Aggref case, thanks to "redundant" checks in ExecInitAgg.But I'm not sure how thorough that protection is, and anyway thewrong-behavior issue remains, so fix 9.6 and 10 too.)Discussion:https://postgr.es/m/17152-c7f906cc1a88e61b@postgresql.org1 parent5310c61 commit61f9dae
File tree
3 files changed
+44
-10
lines changed- src
- backend/parser
- test/regress
- expected
- sql
3 files changed
+44
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
| 630 | + | |
| 631 | + | |
637 | 632 | | |
638 | 633 | | |
639 | 634 | | |
| |||
680 | 675 | | |
681 | 676 | | |
682 | 677 | | |
683 | | - | |
684 | | - | |
685 | | - | |
| 678 | + | |
686 | 679 | | |
687 | 680 | | |
688 | 681 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1845 | 1845 | | |
1846 | 1846 | | |
1847 | 1847 | | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
1848 | 1878 | | |
1849 | 1879 | | |
1850 | 1880 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
685 | 696 | | |
686 | 697 | | |
687 | 698 | | |
| |||
0 commit comments
Comments
(0)