forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit77a3be3
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 parent92c58fd commit77a3be3
File tree
3 files changed
+101
-23
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+101
-23
lines changedLines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3967 | 3967 |
| |
3968 | 3968 |
| |
3969 | 3969 |
| |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
3970 | 3973 |
| |
3971 | 3974 |
| |
3972 |
| - | |
3973 |
| - | |
3974 |
| - | |
3975 | 3975 |
| |
3976 | 3976 |
| |
3977 | 3977 |
| |
| |||
4054 | 4054 |
| |
4055 | 4055 |
| |
4056 | 4056 |
| |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
4057 | 4060 |
| |
4058 | 4061 |
| |
4059 |
| - | |
4060 |
| - | |
4061 |
| - | |
4062 | 4062 |
| |
4063 | 4063 |
| |
4064 | 4064 |
| |
|
Lines changed: 68 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2294 | 2294 |
| |
2295 | 2295 |
| |
2296 | 2296 |
| |
| 2297 | + | |
2297 | 2298 |
| |
2298 | 2299 |
| |
2299 | 2300 |
| |
2300 | 2301 |
| |
2301 | 2302 |
| |
2302 |
| - | |
2303 |
| - | |
2304 |
| - | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
2305 | 2310 |
| |
2306 |
| - | |
| 2311 | + | |
2307 | 2312 |
| |
2308 |
| - | |
| 2313 | + | |
2309 | 2314 |
| |
2310 | 2315 |
| |
2311 |
| - | |
2312 |
| - | |
2313 |
| - | |
2314 |
| - | |
2315 |
| - | |
2316 |
| - | |
2317 |
| - | |
2318 |
| - | |
2319 |
| - | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
2320 | 2374 |
| |
2321 | 2375 |
| |
2322 | 2376 |
| |
|
Lines changed: 27 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1000 | 1000 |
| |
1001 | 1001 |
| |
1002 | 1002 |
| |
| 1003 | + | |
1003 | 1004 |
| |
1004 | 1005 |
| |
1005 | 1006 |
| |
1006 | 1007 |
| |
1007 | 1008 |
| |
1008 | 1009 |
| |
1009 |
| - | |
1010 |
| - | |
1011 |
| - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
1012 | 1036 |
| |
1013 | 1037 |
| |
1014 | 1038 |
| |
|
0 commit comments
Comments
(0)