forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit90fe625
committed
Disallow partitionwise grouping when collations don't match
If the collation of any grouping column doesn’t match the collation ofthe corresponding partition key, partitionwise grouping can yieldincorrect results. For example, rows that would be grouped under thegrouping collation may end up in different partitions under thepartitioning collation. In such cases, full partitionwise groupingwould produce results that differ from those without partitionwisegrouping, so disallowed that.Partial partitionwise aggregation is still allowed, as the Finalizestep reconciles partition-level aggregates with grouping requirementsacross all partitions, ensuring that the final output remainsconsistent.This commit also fixes group_by_has_partkey() by ensuring theRelabelType node is stripped from grouping expressions when matchingthem to partition key expressions to avoid false mismatches.Bug: #18568Reported-by: Webbo Han <1105066510@qq.com>Author: Webbo Han <1105066510@qq.com>Reviewed-by: Tender Wang <tndrwang@gmail.com>Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>Reviewed-by: Jian He <jian.universality@gmail.com>Discussion:https://postgr.es/m/18568-2a9afb6b9f7e6ed3@postgresql.orgDiscussion:https://postgr.es/m/tencent_9D9103CDA420C07768349CC1DFF88465F90A@qq.comDiscussion:https://postgr.es/m/CAHewXNno_HKiQ6PqyLYfuqDtwp7KKHZiH1J7Pqyz0nr+PS2Dwg@mail.gmail.comBackpatch-through: 121 parentf00ab1f commit90fe625
File tree
3 files changed
+163
-8
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+163
-8
lines changedLines changed: 36 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4094 | 4094 |
| |
4095 | 4095 |
| |
4096 | 4096 |
| |
4097 |
| - | |
4098 |
| - | |
4099 |
| - | |
| 4097 | + | |
| 4098 | + | |
| 4099 | + | |
| 4100 | + | |
4100 | 4101 |
| |
4101 | 4102 |
| |
4102 | 4103 |
| |
| |||
8105 | 8106 |
| |
8106 | 8107 |
| |
8107 | 8108 |
| |
8108 |
| - | |
8109 |
| - | |
| 8109 | + | |
| 8110 | + | |
8110 | 8111 |
| |
8111 | 8112 |
| |
8112 | 8113 |
| |
| |||
8134 | 8135 |
| |
8135 | 8136 |
| |
8136 | 8137 |
| |
| 8138 | + | |
8137 | 8139 |
| |
| 8140 | + | |
8138 | 8141 |
| |
8139 |
| - | |
| 8142 | + | |
8140 | 8143 |
| |
8141 |
| - | |
8142 |
| - | |
| 8144 | + | |
| 8145 | + | |
| 8146 | + | |
| 8147 | + | |
| 8148 | + | |
| 8149 | + | |
| 8150 | + | |
| 8151 | + | |
| 8152 | + | |
| 8153 | + | |
| 8154 | + | |
| 8155 | + | |
| 8156 | + | |
| 8157 | + | |
| 8158 | + | |
| 8159 | + | |
| 8160 | + | |
| 8161 | + | |
| 8162 | + | |
| 8163 | + | |
| 8164 | + | |
| 8165 | + | |
| 8166 | + | |
| 8167 | + | |
8143 | 8168 |
| |
| 8169 | + | |
| 8170 | + | |
| 8171 | + | |
8144 | 8172 |
| |
8145 | 8173 |
| |
8146 | 8174 |
| |
|
Lines changed: 90 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2054 | 2054 |
| |
2055 | 2055 |
| |
2056 | 2056 |
| |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
2057 | 2147 |
| |
2058 | 2148 |
| |
2059 | 2149 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
796 | 796 |
| |
797 | 797 |
| |
798 | 798 |
| |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
799 | 836 |
| |
800 | 837 |
| |
801 | 838 |
| |
|
0 commit comments
Comments
(0)