forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdb8855b
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 parent172d7f7 commitdb8855b
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 | |
---|---|---|---|
| |||
3924 | 3924 |
| |
3925 | 3925 |
| |
3926 | 3926 |
| |
3927 |
| - | |
3928 | 3927 |
| |
| 3928 | + | |
| 3929 | + | |
3929 | 3930 |
| |
3930 | 3931 |
| |
3931 | 3932 |
| |
| |||
3941 | 3942 |
| |
3942 | 3943 |
| |
3943 | 3944 |
| |
3944 |
| - | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
3945 | 3950 |
| |
3946 | 3951 |
| |
3947 | 3952 |
| |
3948 | 3953 |
| |
3949 | 3954 |
| |
3950 | 3955 |
| |
3951 |
| - | |
3952 |
| - | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
| 3963 | + | |
| 3964 | + | |
3953 | 3965 |
| |
3954 | 3966 |
| |
3955 |
| - | |
3956 |
| - | |
| 3967 | + | |
| 3968 | + | |
| 3969 | + | |
3957 | 3970 |
| |
3958 |
| - | |
3959 |
| - | |
3960 |
| - | |
3961 |
| - | |
| 3971 | + | |
| 3972 | + | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
| 3977 | + | |
| 3978 | + | |
3962 | 3979 |
| |
3963 | 3980 |
| |
3964 | 3981 |
| |
| |||
4109 | 4126 |
| |
4110 | 4127 |
| |
4111 | 4128 |
| |
| 4129 | + | |
4112 | 4130 |
| |
4113 | 4131 |
| |
4114 | 4132 |
| |
| |||
4124 | 4142 |
| |
4125 | 4143 |
| |
4126 | 4144 |
| |
4127 |
| - | |
| 4145 | + | |
| 4146 | + | |
| 4147 | + | |
| 4148 | + | |
| 4149 | + | |
4128 | 4150 |
| |
4129 | 4151 |
| |
4130 | 4152 |
| |
4131 | 4153 |
| |
4132 | 4154 |
| |
4133 | 4155 |
| |
4134 |
| - | |
4135 |
| - | |
| 4156 | + | |
| 4157 | + | |
| 4158 | + | |
| 4159 | + | |
| 4160 | + | |
| 4161 | + | |
| 4162 | + | |
| 4163 | + | |
| 4164 | + | |
4136 | 4165 |
| |
4137 | 4166 |
| |
4138 |
| - | |
4139 |
| - | |
| 4167 | + | |
| 4168 | + | |
| 4169 | + | |
4140 | 4170 |
| |
4141 |
| - | |
4142 |
| - | |
4143 |
| - | |
4144 |
| - | |
| 4171 | + | |
| 4172 | + | |
| 4173 | + | |
| 4174 | + | |
| 4175 | + | |
| 4176 | + | |
| 4177 | + | |
| 4178 | + | |
4145 | 4179 |
| |
4146 | 4180 |
| |
4147 | 4181 |
| |
|
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)