Repository navigation
Commit 61c3472
authored
fix: restore floating-point rounding mode after panic (apache#26412)
## Which issue does this PR close?
- Closes apache#7356.
## Rationale for this change
A caught panic in `alter_fp_rounding_mode` leaves the thread using the
temporary rounding mode, which can affect later floating-point
calculations on that thread.
## What changes are included in this PR?
Restore the saved rounding mode with a private `Drop` guard so cleanup
also runs during unwinding. The change is confined to `rounding.rs` and
adds no dependency or public API.
## What is the testing strategy for this PR?
The regression test starts in downward rounding mode, panics during an
upward-rounded operation, catches the panic, and checks that downward
rounding was restored. It restores the test thread's original mode
before asserting. This requires a Rust unit test because SQL and the
DataFrame API cannot directly supply the panicking callback.
The test was run against the unfixed implementation and failed because
upward rounding remained active.
Validation:
- `cargo fmt --all` and `cargo fmt --all -- --check` passed.
- `cargo test --profile ci -p datafusion-common -p
datafusion-expr-common` passed: 847 unit tests and 89 documentation
tests, with five documentation tests ignored.
- `cargo clippy -p datafusion-common -p datafusion-expr-common
--all-targets --all-features -- -D warnings` passed.
`cargo clippy --all-targets --all-features -- -D warnings` reported
three pre-existing `mutable_key_type` errors in
`datafusion/optimizer/src/push_down_filter.rs`, tracked by apache#26181. Its
remaining bundled Protobuf build was stopped after these errors.
The full lint suite, SQL logic suite, and extended workspace tests were
started but did not complete locally. The separate core and CLI test run
was not reached.
## Are there any user-facing changes?
After a caught panic, subsequent floating-point calculations on the same
thread retain the rounding mode that was active before the operation. No
public API or normal SQL behavior changes.1 parent 3470bd0 commit 61c3472
1 file changed
Lines changed: 40 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
275 | 284 | | |
276 | | - | |
277 | | - | |
278 | | - | |
| 285 | + | |
279 | 286 | | |
280 | 287 | | |
281 | 288 | | |
| |||
288 | 295 | | |
289 | 296 | | |
290 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
291 | 327 | | |
292 | 328 | | |
293 | 329 | | |
| |||
0 commit comments