forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit25cd2d6
committed
Detect Julian-date overflow in timestamp[tz]_pl_interval.
We perform addition of the days field of an interval viaarithmetic on the Julian-date representation of the timestamp's date.This step is subject to int32 overflow, and we also should not letthe Julian date become very negative, for fear of weird results fromj2date. (In the timestamptz case, allow a Julian date of -1 to pass,since it might convert back to zero after timezone rotation.)The additions of the months and microseconds fields could alsooverflow, of course. However, I believe we need no additionalchecks there; the existing range checks should catch such cases.The difficulty here is that j2date's magic modular arithmetic couldproduce something that looks like it's in-range.Per bug #18313 from Christian Maurer. This has been wrong fora long time, so back-patch to all supported branches.Discussion:https://postgr.es/m/18313-64d2c8952d81e84b@postgresql.org1 parent5ddf997 commit25cd2d6
File tree
3 files changed
+29
-4
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+29
-4
lines changedLines changed: 23 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3120 | 3120 |
| |
3121 | 3121 |
| |
3122 | 3122 |
| |
3123 |
| - | |
3124 |
| - | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
3125 | 3133 |
| |
3126 | 3134 |
| |
3127 | 3135 |
| |
| |||
3256 | 3264 |
| |
3257 | 3265 |
| |
3258 | 3266 |
| |
3259 |
| - | |
3260 |
| - | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
3261 | 3280 |
| |
3262 | 3281 |
| |
3263 | 3282 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
482 | 482 |
| |
483 | 483 |
| |
484 | 484 |
| |
| 485 | + | |
| 486 | + | |
485 | 487 |
| |
486 | 488 |
| |
487 | 489 |
| |
| |||
742 | 744 |
| |
743 | 745 |
| |
744 | 746 |
| |
| 747 | + | |
| 748 | + | |
745 | 749 |
| |
746 | 750 |
| |
747 | 751 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
| 123 | + | |
123 | 124 |
| |
124 | 125 |
| |
125 | 126 |
| |
| |||
151 | 152 |
| |
152 | 153 |
| |
153 | 154 |
| |
| 155 | + | |
154 | 156 |
| |
155 | 157 |
| |
156 | 158 |
| |
|
0 commit comments
Comments
(0)