- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitc776cd4
committed
Improve tzparse's handling of TZDEFRULES ("posixrules") zone data.
In the IANA timezone code, tzparse() always tries to load the zonefile named by TZDEFRULES ("posixrules"). Previously, we'd hackedthat logic to skip the load in the "lastditch" code path, which we useonly to initialize the default "GMT" zone during GUC initialization.That's critical for a couple of reasons: since we do not support leapseconds, we *must not* allow "GMT" to have leap seconds, and since thiscase runs before the GUC subsystem is fully alive, we'd really rathernot take the risk of pg_open_tzfile throwing any errors.However, that still left the code reading TZDEFRULES on every othercall, something we'd noticed to the extent of having added code to cachethe result so it was only done once per process not a lot of times.Andres Freund complained about the static data space used up for thecache; but as long as the logic was like this, there was no point intrying to get rid of that space.We can improve matters by looking a bit more closely at what the IANAcode actually needs the TZDEFRULES data for. One thing it does isthat if "posixrules" is a leap-second-aware zone, the leap-secondbehavior will be absorbed into every POSIX-style zone specification.However, that's a behavior we'd really prefer to do without, sincefor our purposes the end effect is to render every POSIX-style zonename unsupported. Otherwise, the TZDEFRULES data is used only ifthe POSIX zone name specifies DST but doesn't include a transitiondate rule (e.g., "EST5EDT" rather than "EST5EDT,M3.2.0,M11.1.0").That is a minority case for our purposes --- in particular, itnever happens when tzload() invokes tzparse() to interpret atransition date rule string found in a tzdata zone file.Hence, if we legislate that we're going to ignore leap-second datafrom "posixrules", we can postpone the TZDEFRULES load into the pathwhere we actually need to substitute for a missing date rule string.That means it will never happen at all in common scenarios, making itreasonable to dynamically allocate the cache space when it does happen.Even when the data is already loaded, this saves some cycles in thecommon code path since we avoid a memcpy of 23KB or so. And, IMO atleast, this is a less ugly hack on the IANA logic than what we hadbefore, since it's not messing with the lastditch-vs-regular code paths.Back-patch to all supported branches, not so much because this is acritical change as that I want to keep all our copies of the IANAtimezone code in sync.Discussion:https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de1 parent19ac2cb commitc776cd4
2 files changed
+54
-36
lines changedLines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
87 |
| - | |
88 |
| - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 |
| |
90 | 92 |
| |
91 | 93 |
| |
|
Lines changed: 50 additions & 34 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
57 |
| - | |
| 57 | + | |
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
| |||
908 | 908 |
| |
909 | 909 |
| |
910 | 910 |
| |
911 |
| - | |
912 |
| - | |
913 |
| - | |
914 |
| - | |
915 |
| - | |
916 |
| - | |
| 911 | + | |
917 | 912 |
| |
918 | 913 |
| |
919 |
| - | |
920 |
| - | |
921 |
| - | |
922 | 914 |
| |
923 |
| - | |
924 |
| - | |
925 | 915 |
| |
926 | 916 |
| |
927 | 917 |
| |
| |||
945 | 935 |
| |
946 | 936 |
| |
947 | 937 |
| |
948 |
| - | |
949 |
| - | |
950 |
| - | |
951 |
| - | |
952 |
| - | |
953 |
| - | |
954 |
| - | |
955 |
| - | |
956 |
| - | |
957 |
| - | |
958 |
| - | |
959 |
| - | |
960 |
| - | |
961 |
| - | |
962 |
| - | |
963 |
| - | |
964 |
| - | |
965 |
| - | |
966 | 938 |
| |
967 |
| - | |
968 |
| - | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
969 | 955 |
| |
970 | 956 |
| |
971 | 957 |
| |
| |||
996 | 982 |
| |
997 | 983 |
| |
998 | 984 |
| |
999 |
| - | |
1000 |
| - | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
1001 | 1017 |
| |
1002 | 1018 |
| |
1003 | 1019 |
| |
|
0 commit comments
Comments
(0)