forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf807e34
committed
Work around portability issue with newer versions of mktime().
Recent glibc versions have made mktime() fail if tm_isdst isinconsistent with the prevailing timezone; in particular it fails fortm_isdst = 1 when the zone is UTC. (This seems wildly inconsistentwith the POSIX-mandated treatment of "incorrect" values for the otherfields of struct tm, so if you ask me it's a bug, but I bet they'llsay it's intentional.) This has been observed to cause cosmeticproblems when pg_restore'ing an archive created in a differenttimezone.To fix, do mktime() using the field values from the archive, and ifthat fails try again with tm_isdst = -1. This will give a resultthat's off by the UTC-offset difference from the original zone, butthat was true before, too. It's not terribly critical since we don'tdo anything with the result except possibly print it. (Someday weshould flush this entire bit of logic and record a standard-formattimestamp in the archive instead. That's not okay for a back-patchedbug fix, though.)Also, guard our only other use of mktime() by having initdb'sbuild_time_t() set tm_isdst = -1 not 0. This case could only havean issue in zones that are DST year-round; but I think some do exist,or could in future.Per report from Wells Oliver. Back-patch to all supportedversions, since any of them might need to run with a newer glibc.Discussion:https://postgr.es/m/CAOC+FBWDhDHO7G-i1_n_hjRzCnUeFO+H-Czi1y10mFhRWpBrew@mail.gmail.com1 parent9d97c34 commitf807e34
2 files changed
+27
-5
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
195 | 195 |
| |
196 | 196 |
| |
197 | 197 |
| |
| 198 | + | |
198 | 199 |
| |
199 | 200 |
| |
200 | 201 |
| |
|
Lines changed: 26 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3703 | 3703 |
| |
3704 | 3704 |
| |
3705 | 3705 |
| |
3706 |
| - | |
3707 | 3706 |
| |
3708 | 3707 |
| |
3709 | 3708 |
| |
| |||
3771 | 3770 |
| |
3772 | 3771 |
| |
3773 | 3772 |
| |
| 3773 | + | |
| 3774 | + | |
3774 | 3775 |
| |
3775 | 3776 |
| |
3776 | 3777 |
| |
| |||
3779 | 3780 |
| |
3780 | 3781 |
| |
3781 | 3782 |
| |
3782 |
| - | |
3783 |
| - | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
| 3789 | + | |
| 3790 | + | |
| 3791 | + | |
| 3792 | + | |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
3784 | 3796 |
| |
3785 |
| - | |
3786 | 3797 |
| |
3787 |
| - | |
| 3798 | + | |
| 3799 | + | |
| 3800 | + | |
| 3801 | + | |
| 3802 | + | |
| 3803 | + | |
| 3804 | + | |
| 3805 | + | |
| 3806 | + | |
| 3807 | + | |
| 3808 | + | |
3788 | 3809 |
| |
3789 | 3810 |
| |
3790 | 3811 |
| |
|
0 commit comments
Comments
(0)