forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitecbdbdf
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 parentfa604e0 commitecbdbdf
File tree
3 files changed
+76
-29
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+76
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | 431 | | |
442 | 432 | | |
443 | 433 | | |
| |||
579 | 569 | | |
580 | 570 | | |
581 | 571 | | |
| 572 | + | |
582 | 573 | | |
583 | 574 | | |
584 | 575 | | |
| |||
7215 | 7206 | | |
7216 | 7207 | | |
7217 | 7208 | | |
7218 | | - | |
7219 | | - | |
7220 | | - | |
| 7209 | + | |
7221 | 7210 | | |
7222 | 7211 | | |
7223 | 7212 | | |
| |||
7254 | 7243 | | |
7255 | 7244 | | |
7256 | 7245 | | |
7257 | | - | |
7258 | | - | |
7259 | | - | |
7260 | | - | |
| 7246 | + | |
| 7247 | + | |
7261 | 7248 | | |
7262 | | - | |
7263 | | - | |
7264 | | - | |
7265 | | - | |
7266 | | - | |
7267 | | - | |
7268 | | - | |
| 7249 | + | |
7269 | 7250 | | |
7270 | | - | |
7271 | | - | |
7272 | | - | |
| 7251 | + | |
| 7252 | + | |
| 7253 | + | |
7273 | 7254 | | |
7274 | | - | |
7275 | | - | |
| 7255 | + | |
7276 | 7256 | | |
7277 | 7257 | | |
7278 | 7258 | | |
| |||
10480 | 10460 | | |
10481 | 10461 | | |
10482 | 10462 | | |
| 10463 | + | |
| 10464 | + | |
| 10465 | + | |
| 10466 | + | |
| 10467 | + | |
| 10468 | + | |
| 10469 | + | |
| 10470 | + | |
| 10471 | + | |
| 10472 | + | |
| 10473 | + | |
| 10474 | + | |
| 10475 | + | |
| 10476 | + | |
| 10477 | + | |
| 10478 | + | |
| 10479 | + | |
| 10480 | + | |
| 10481 | + | |
| 10482 | + | |
| 10483 | + | |
| 10484 | + | |
| 10485 | + | |
| 10486 | + | |
| 10487 | + | |
| 10488 | + | |
| 10489 | + | |
| 10490 | + | |
10483 | 10491 | | |
10484 | 10492 | | |
10485 | 10493 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1794 | 1794 | | |
1795 | 1795 | | |
1796 | 1796 | | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
1797 | 1829 | | |
1798 | 1830 | | |
1799 | 1831 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
939 | 939 | | |
940 | 940 | | |
941 | 941 | | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
942 | 949 | | |
943 | 950 | | |
944 | 951 | | |
| |||
0 commit comments
Comments
(0)