forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita72ad63
committed
Fix division-by-zero error in to_char() with 'EEEE' format.
This fixes a long-standing bug when using to_char() to format anumeric value in scientific notation -- if the value's exponent isless than -NUMERIC_MAX_DISPLAY_SCALE-1 (-1001), it produced adivision-by-zero error.The reason for this error was that get_str_from_var_sci() divides itsinput by 10^exp, which it produced using power_var_int(). However, theunderflow test in power_var_int() causes it to return zero if theresult scale is too small. That's not a problem for power_var_int()'sonly other caller, power_var(), since that limits the rscale to 1000,but in get_str_from_var_sci() the exponent can be much smaller,requiring a much larger rscale. Fix by introducing a new function tocompute 10^exp directly, with no rscale limit. This also allows 10^expto be computed more efficiently, without any numeric multiplication,division or rounding.Discussion:https://postgr.es/m/CAEZATCWhojfH4whaqgUKBe8D5jNHB8ytzemL-PnRx+KCTyMXmg@mail.gmail.com1 parent47a573d commita72ad63
File tree
3 files changed
+78
-29
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+78
-29
lines changedLines changed: 37 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
383 | 383 |
| |
384 | 384 |
| |
385 | 385 |
| |
386 |
| - | |
387 |
| - | |
388 |
| - | |
389 |
| - | |
390 |
| - | |
391 |
| - | |
392 |
| - | |
393 |
| - | |
394 |
| - | |
395 |
| - | |
396 | 386 |
| |
397 | 387 |
| |
398 | 388 |
| |
| |||
526 | 516 |
| |
527 | 517 |
| |
528 | 518 |
| |
| 519 | + | |
529 | 520 |
| |
530 | 521 |
| |
531 | 522 |
| |
| |||
6354 | 6345 |
| |
6355 | 6346 |
| |
6356 | 6347 |
| |
6357 |
| - | |
6358 |
| - | |
6359 |
| - | |
| 6348 | + | |
6360 | 6349 |
| |
6361 | 6350 |
| |
6362 | 6351 |
| |
| |||
6393 | 6382 |
| |
6394 | 6383 |
| |
6395 | 6384 |
| |
6396 |
| - | |
6397 |
| - | |
6398 |
| - | |
6399 |
| - | |
| 6385 | + | |
| 6386 | + | |
6400 | 6387 |
| |
6401 |
| - | |
6402 |
| - | |
6403 |
| - | |
6404 |
| - | |
6405 |
| - | |
6406 |
| - | |
6407 |
| - | |
| 6388 | + | |
6408 | 6389 |
| |
6409 |
| - | |
6410 |
| - | |
6411 |
| - | |
| 6390 | + | |
| 6391 | + | |
| 6392 | + | |
6412 | 6393 |
| |
6413 |
| - | |
6414 |
| - | |
| 6394 | + | |
6415 | 6395 |
| |
6416 | 6396 |
| |
6417 | 6397 |
| |
| |||
9498 | 9478 |
| |
9499 | 9479 |
| |
9500 | 9480 |
| |
| 9481 | + | |
| 9482 | + | |
| 9483 | + | |
| 9484 | + | |
| 9485 | + | |
| 9486 | + | |
| 9487 | + | |
| 9488 | + | |
| 9489 | + | |
| 9490 | + | |
| 9491 | + | |
| 9492 | + | |
| 9493 | + | |
| 9494 | + | |
| 9495 | + | |
| 9496 | + | |
| 9497 | + | |
| 9498 | + | |
| 9499 | + | |
| 9500 | + | |
| 9501 | + | |
| 9502 | + | |
| 9503 | + | |
| 9504 | + | |
| 9505 | + | |
| 9506 | + | |
| 9507 | + | |
| 9508 | + | |
9501 | 9509 |
| |
9502 | 9510 |
| |
9503 | 9511 |
| |
|
Lines changed: 33 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1278 | 1278 |
| |
1279 | 1279 |
| |
1280 | 1280 |
| |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
1281 | 1314 |
| |
1282 | 1315 |
| |
1283 | 1316 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
798 | 798 |
| |
799 | 799 |
| |
800 | 800 |
| |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
801 | 809 |
| |
802 | 810 |
| |
803 | 811 |
| |
|
0 commit comments
Comments
(0)