forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0927bf8
committed
Guard against bad "dscale" values in numeric_recv().
We were not checking to see if the supplied dscale was valid for the givendigit array when receiving binary-format numeric values. While dscale canvalidly be more than the number of nonzero fractional digits, it shouldn'tbe less; that case causes fractional digits to be hidden on display eventhough they're there and participate in arithmetic.Bug #12053 from Tommaso Sala indicates that there's at least one brokenclient library out there that sometimes supplies an incorrect dscale value,leading to strange behavior. This suggests that simply throwing an errormight not be the best response; it would lead to failures in applicationsthat might seem to be working fine today. What seems the least risky fixis to truncate away any digits that would be hidden by dscale. Thispreserves the existing behavior in terms of what will be printed for thetransmitted value, while preventing subsequent arithmetic from producingresults inconsistent with that.In passing, throw a specific error for the case of dscale being outsidethe range that will fit into a numeric's header. Before you got "valueoverflows numeric format", which is a bit misleading.Back-patch to all supported branches.1 parentdf761e3 commit0927bf8
1 file changed
+15
-0
lines changedLines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
717 | 717 |
| |
718 | 718 |
| |
719 | 719 |
| |
| 720 | + | |
| 721 | + | |
720 | 722 |
| |
721 | 723 |
| |
722 | 724 |
| |
| |||
726 | 728 |
| |
727 | 729 |
| |
728 | 730 |
| |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
729 | 736 |
| |
730 | 737 |
| |
731 | 738 |
| |
| |||
737 | 744 |
| |
738 | 745 |
| |
739 | 746 |
| |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
740 | 755 |
| |
741 | 756 |
| |
742 | 757 |
| |
|
0 commit comments
Comments
(0)