- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitbaa94eb
committed
Avoid statically allocating gmtsub()'s timezone workspace.
localtime.c's "struct state" is a rather large object, ~23KB. We werestatically allocating one for gmtsub() to use to represent the GMTtimezone, even though that function is not at all heavily used and isnever reached in most backends. Let's malloc it on-demand, instead.This does pose the question of how to handle a malloc failure, butthere's already a well-defined error report convention here, ieset errno and return NULL.We have but one caller of pg_gmtime in HEAD, and two in back branches,neither of which were troubling to check for error. Make them do so.The possible errors are sufficiently unlikely (out-of-range timestamp,and now malloc failure) that I think elog() is adequate.Back-patch to all supported branches to keep our copies of the IANAtimezone code in sync. This particular change is in a stanza thatalready differs from upstream, so it's a wash for maintenance purposes--- but only as long as we keep the branches the same.Discussion:https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de1 parent3a60c8b commitbaa94eb
File tree
3 files changed
+12
-5
lines changed- src
- backend/utils/adt
- timezone
3 files changed
+12
-5
lines changedLines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
113 | 113 |
| |
114 | 114 |
| |
115 | 115 |
| |
| 116 | + | |
| 117 | + | |
| 118 | + | |
116 | 119 |
| |
117 | 120 |
| |
118 | 121 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1877 | 1877 |
| |
1878 | 1878 |
| |
1879 | 1879 |
| |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
1880 | 1883 |
| |
1881 | 1884 |
| |
1882 | 1885 |
| |
|
Lines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1328 | 1328 |
| |
1329 | 1329 |
| |
1330 | 1330 |
| |
1331 |
| - | |
1332 |
| - | |
1333 |
| - | |
| 1331 | + | |
1334 | 1332 |
| |
1335 |
| - | |
| 1333 | + | |
1336 | 1334 |
| |
1337 |
| - | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
1338 | 1339 |
| |
1339 | 1340 |
| |
1340 | 1341 |
| |
|
0 commit comments
Comments
(0)