forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4284e11
committed
Fix mishandling of NaN counts in numeric_[avg_]combine.
When merging two NumericAggStates, the code missed adding the newstate's NaNcount unless its N was also nonzero; since those countsare independent, this is wrong.This would only have visible effect if some partial aggregate scansfound only NaNs while earlier ones found only non-NaNs; then we couldend up falsely deciding that there were no NaNs and fail to return aNaN final result as expected. That's pretty improbable, so it's nosurprise this hasn't been reported from the field. Still, it's a bug.I didn't try to produce a regression test that would show the bug,but I did notice that these functions weren't being reached at allin our regression tests, so I improved the tests to at leastexercise them. With these additions, I see pretty complete codecoverage on the aggregation-related functions in numeric.c.Back-patch to 9.6 where this code was introduced. (I only addedthe improved test case as far back as v10, though, since therelevant part of aggregates.sql isn't there at all in 9.6.)1 parente620a38 commit4284e11
File tree
3 files changed
+101
-23
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+101
-23
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3772 | 3772 |
| |
3773 | 3773 |
| |
3774 | 3774 |
| |
| 3775 | + | |
| 3776 | + | |
| 3777 | + | |
3775 | 3778 |
| |
3776 | 3779 |
| |
3777 |
| - | |
3778 |
| - | |
3779 |
| - | |
3780 | 3780 |
| |
3781 | 3781 |
| |
3782 | 3782 |
| |
| |||
3859 | 3859 |
| |
3860 | 3860 |
| |
3861 | 3861 |
| |
| 3862 | + | |
| 3863 | + | |
| 3864 | + | |
3862 | 3865 |
| |
3863 | 3866 |
| |
3864 |
| - | |
3865 |
| - | |
3866 |
| - | |
3867 | 3867 |
| |
3868 | 3868 |
| |
3869 | 3869 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2244 | 2244 |
| |
2245 | 2245 |
| |
2246 | 2246 |
| |
| 2247 | + | |
2247 | 2248 |
| |
2248 | 2249 |
| |
2249 | 2250 |
| |
2250 | 2251 |
| |
2251 | 2252 |
| |
2252 |
| - | |
2253 |
| - | |
2254 |
| - | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
2255 | 2260 |
| |
2256 |
| - | |
| 2261 | + | |
2257 | 2262 |
| |
2258 |
| - | |
| 2263 | + | |
2259 | 2264 |
| |
2260 | 2265 |
| |
2261 |
| - | |
2262 |
| - | |
2263 |
| - | |
2264 |
| - | |
2265 |
| - | |
2266 |
| - | |
2267 |
| - | |
2268 |
| - | |
2269 |
| - | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
2270 | 2324 |
| |
2271 | 2325 |
| |
2272 | 2326 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
981 | 981 |
| |
982 | 982 |
| |
983 | 983 |
| |
| 984 | + | |
984 | 985 |
| |
985 | 986 |
| |
986 | 987 |
| |
987 | 988 |
| |
988 | 989 |
| |
989 | 990 |
| |
990 |
| - | |
991 |
| - | |
992 |
| - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
993 | 1017 |
| |
994 | 1018 |
| |
995 | 1019 |
| |
|
0 commit comments
Comments
(0)