forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfe3b1b5
committed
Fix mis-rounding and overflow hazards in date_bin().
In the case where the target timestamp is before the origin timestampand their difference is already an exact multiple of the stride, thecode incorrectly subtracted the stride anyway.Also detect several integer-overflow cases that previously producedbogus results. (The submitted patch tried to avoid overflow, butI'm not convinced it's right, and problematic cases are so far out ofthe plausibly-useful range that they don't seem worth sweating over.Let's just use overflow-detecting arithmetic and throw errors.)timestamp_bin() and timestamptz_bin() are basically identical andso had identical bugs. Fix both.Report and patch by Moaaz Assali, adjusted some by me. Back-patchto v14 where date_bin() was introduced.Discussion:https://postgr.es/m/CALkF+nvtuas-2kydG-WfofbRSJpyODAJWun==W-yO5j2R4meqA@mail.gmail.com1 parent09f0988 commitfe3b1b5
File tree
5 files changed
+97
-19
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
5 files changed
+97
-19
lines changedLines changed: 53 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3870 | 3870 |
| |
3871 | 3871 |
| |
3872 | 3872 |
| |
3873 |
| - | |
3874 | 3873 |
| |
| 3874 | + | |
| 3875 | + | |
3875 | 3876 |
| |
3876 | 3877 |
| |
3877 | 3878 |
| |
| |||
3887 | 3888 |
| |
3888 | 3889 |
| |
3889 | 3890 |
| |
3890 |
| - | |
| 3891 | + | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
3891 | 3896 |
| |
3892 | 3897 |
| |
3893 | 3898 |
| |
3894 | 3899 |
| |
3895 | 3900 |
| |
3896 | 3901 |
| |
3897 |
| - | |
3898 |
| - | |
| 3902 | + | |
| 3903 | + | |
| 3904 | + | |
| 3905 | + | |
| 3906 | + | |
| 3907 | + | |
| 3908 | + | |
| 3909 | + | |
| 3910 | + | |
3899 | 3911 |
| |
3900 | 3912 |
| |
3901 |
| - | |
3902 |
| - | |
| 3913 | + | |
| 3914 | + | |
| 3915 | + | |
3903 | 3916 |
| |
3904 |
| - | |
3905 |
| - | |
3906 |
| - | |
3907 |
| - | |
| 3917 | + | |
| 3918 | + | |
| 3919 | + | |
| 3920 | + | |
| 3921 | + | |
| 3922 | + | |
| 3923 | + | |
| 3924 | + | |
3908 | 3925 |
| |
3909 | 3926 |
| |
3910 | 3927 |
| |
| |||
4055 | 4072 |
| |
4056 | 4073 |
| |
4057 | 4074 |
| |
| 4075 | + | |
4058 | 4076 |
| |
4059 | 4077 |
| |
4060 | 4078 |
| |
| |||
4070 | 4088 |
| |
4071 | 4089 |
| |
4072 | 4090 |
| |
4073 |
| - | |
| 4091 | + | |
| 4092 | + | |
| 4093 | + | |
| 4094 | + | |
| 4095 | + | |
4074 | 4096 |
| |
4075 | 4097 |
| |
4076 | 4098 |
| |
4077 | 4099 |
| |
4078 | 4100 |
| |
4079 | 4101 |
| |
4080 |
| - | |
4081 |
| - | |
| 4102 | + | |
| 4103 | + | |
| 4104 | + | |
| 4105 | + | |
| 4106 | + | |
| 4107 | + | |
| 4108 | + | |
| 4109 | + | |
| 4110 | + | |
4082 | 4111 |
| |
4083 | 4112 |
| |
4084 |
| - | |
4085 |
| - | |
| 4113 | + | |
| 4114 | + | |
| 4115 | + | |
4086 | 4116 |
| |
4087 |
| - | |
4088 |
| - | |
4089 |
| - | |
4090 |
| - | |
| 4117 | + | |
| 4118 | + | |
| 4119 | + | |
| 4120 | + | |
| 4121 | + | |
| 4122 | + | |
| 4123 | + | |
| 4124 | + | |
4091 | 4125 |
| |
4092 | 4126 |
| |
4093 | 4127 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
699 | 699 |
| |
700 | 700 |
| |
701 | 701 |
| |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
702 | 709 |
| |
703 | 710 |
| |
704 | 711 |
| |
| |||
710 | 717 |
| |
711 | 718 |
| |
712 | 719 |
| |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
713 | 727 |
| |
714 | 728 |
| |
715 | 729 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
743 | 743 |
| |
744 | 744 |
| |
745 | 745 |
| |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
746 | 753 |
| |
747 | 754 |
| |
748 | 755 |
| |
| |||
754 | 761 |
| |
755 | 762 |
| |
756 | 763 |
| |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
757 | 771 |
| |
758 | 772 |
| |
759 | 773 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
259 | 259 |
| |
260 | 260 |
| |
261 | 261 |
| |
| 262 | + | |
| 263 | + | |
| 264 | + | |
262 | 265 |
| |
263 | 266 |
| |
264 | 267 |
| |
| |||
269 | 272 |
| |
270 | 273 |
| |
271 | 274 |
| |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
272 | 280 |
| |
273 | 281 |
| |
274 | 282 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
234 | 234 |
| |
235 | 235 |
| |
236 | 236 |
| |
| 237 | + | |
| 238 | + | |
| 239 | + | |
237 | 240 |
| |
238 | 241 |
| |
239 | 242 |
| |
| |||
244 | 247 |
| |
245 | 248 |
| |
246 | 249 |
| |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
247 | 255 |
| |
248 | 256 |
| |
249 | 257 |
| |
|
0 commit comments
Comments
(0)