Re: More tzdb fun: POSIXRULES is being deprecated upstream
Seems like I'm not getting any traction in convincing people that back-patching this change is wise. To get this closed out before the CF starts, I'm just going to put it into HEAD/v13 and call it a day. I remain of the opinion that we'll probably regret not doing anything in the back branches, sometime in the next 4+ years. regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Peter Eisentraut writes: > What you are saying is, instead of the OS dropping POSIXRULES support, > it would be better if we dropped it first and release-noted that. > However, I don't agree with the premise of that. OSes with long-term > support aren't going to drop it. You might be right, or you might not. I think the tzdata distribution is in a weird gray area so far as long-term-support platforms are concerned: they have to keep updating it, no matter how far it diverges from what they originally shipped with. Maybe they will figure out that they're not required to drop POSIXRULES just because upstream did. Or maybe they will go with the flow on that, figuring that it's not any worse than any politically-driven time zone change. I wouldn't be a bit surprised if it ends up depending on whether the particular distro is using IANA's makefile more or less verbatim. In Red Hat's case I found that they'd have to take positive action to drop POSIXRULES, so I'd agree that it won't happen there for a long time, and not in any existing RHEL release. In some other distros, it might take explicit addition of a patch to keep from dropping POSIXRULES, in which case I think there'd be quite good odds that that won't happen and the changeover occurs with the next IANA zone updates. The nasty thing about that scenario from our perspective is that it means that the same timezone spec means different things on different platforms, even ones nominally using the same tzdata release. Do we want to deal with that, or take pre-emptive action to prevent it? (You could argue that that hazard already exists for people who are intentionally using nonstandard posixrules files. But I think the set of such people can be counted without running out of fingers. If there's some evidence to the contrary I'd like to see it.) I'm also worried about what the endgame looks like. It seems clear that at some point IANA is going to remove their code's support for reading a posixrules file. Eggert hasn't tipped his hand as to when he thinks that might happen, but I wouldn't care to bet that it's more than five years away. I don't want to find ourselves in a situation where we have to maintain code that upstream has nuked. If they only do something comparable to the patch I posted, it wouldn't be so bad; but if they then undertake any significant follow-on cleanup we'd be in a very bad place for tracking them. regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
On 2020-06-19 21:55, Tom Lane wrote: Yeah, we can do nothing in the back branches and hope that that doesn't happen for the remaining lifespan of v12. But I wonder whether that doesn't amount to sticking our heads in the sand. I suppose it'd be possible to have a release-note entry in the back branches that isn't tied to any actual code change on our part, but just warns that such a tzdata change might happen at some unpredictable future time. That feels weird and squishy though; and people would likely have forgotten it by the time the change actually hits them. In my mind, this isn't really that different from other external libraries making API changes. But we are not going to forcibly remove Python 2 support in PostgreSQL 9.6 just because it's no longer supported upstream. If Debian or RHEL $veryold want to keep maintaining Python 2, they are free to do so, and users thereof are free to continue using it. Similarly, Debian or RHEL $veryold are surely not going to drop a whole class of time zone codes from their stable distribution just because upstream is phasing it out. What you are saying is, instead of the OS dropping POSIXRULES support, it would be better if we dropped it first and release-noted that. However, I don't agree with the premise of that. OSes with long-term support aren't going to drop it. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Robert Haas writes: > It might be nice to know what > Debian, RHEL, etc. plan to do about this, but I'm not sure how > practical it is to find out. By luck, we now have a moderately well-educated guess about that from Paul Eggert himself [1]: : Probably NetBSD will go first as they tend to buy these changes : quickly; maybe six months from now? Debian and RHEL probably a couple : of years. These are all just guesses. Based on that, I'd say that assuming v12 and earlier won't have to deal with this issue does indeed amount to sticking our heads in the sand. I don't intend to do anything about this until this week's beta wrap cycle is complete, but I'm still leaning to the idea that we ought to back-patch something. Maybe the "something" could be less than a full posixrules-ectomy, but I'm not really satisfied with any of the other alternatives I've thought about. regards, tom lane [1] https://www.postgresql.org/message-id/9d8b5ec4-7094-04f6-d270-db0198d09bd1%40cs.ucla.edu
Re: More tzdb fun: POSIXRULES is being deprecated upstream
I wrote: > Robert Haas writes: >> It might be nice to know what >> Debian, RHEL, etc. plan to do about this, but I'm not sure how >> practical it is to find out. > There's probably no way to know until it happens :-(. On the other hand, for the open-source players, it might be easier to guess. I took a look at the Fedora/RHEL tzdata specfile, and I see that "-p America/New_York" is hard-wired into it: zic -y ./yearistype -d zoneinfo -L /dev/null -p America/New_York $FILES This means that IANA's change of their sample Makefile will have no direct impact, and things will only change if the Red Hat packager actively changes the specfile. It's still anyone's guess whether he/she will do so, but the odds of a change seem a good bit lower than if the IANA-supplied Makefile were being used directly. I'm less familiar with Debian so I won't venture to dig into their package, but maybe somebody else would like to. regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Robert Haas writes: > On Fri, Jun 19, 2020 at 3:55 PM Tom Lane wrote: >> What I'm concerned about is that people depending on the existing >> behavior are likely to wake up one fine morning and discover that it's >> broken after a routine tzdata update. I think that it'd be a better >> user experience for them to see a release-note entry in a PG update >> release explaining that this will break and here's what to do to fix it. > I was assuming that if you did an update of the tzdata, you'd notice > if posixrules had been nuked. I guess that wouldn't help people who > are using the system tzdata, though. Yeah, exactly. We can control this easily enough for PG-supplied tzdata trees, but I think a significant majority of actual users are using --with-system-tzdata builds, because we've been telling packagers to do it that way for years. (Nor does changing that advice seem like a smart move.) > It might be nice to know what > Debian, RHEL, etc. plan to do about this, but I'm not sure how > practical it is to find out. There's probably no way to know until it happens :-(. We can hope that they'll be conservative, but it's hard to be sure. It doesn't help that the bigger players rely on glibc: if I understand what Eggert was saying, nuking posixrules would bring tzcode's behavior into closer sync with what glibc does, so they might well feel it's a desirable change. regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
On Fri, Jun 19, 2020 at 3:55 PM Tom Lane wrote: > The code delta is small enough that I don't foresee any real maintenance > problem if we let the back branches differ from HEAD/v13 on this point. > What I'm concerned about is that people depending on the existing > behavior are likely to wake up one fine morning and discover that it's > broken after a routine tzdata update. I think that it'd be a better > user experience for them to see a release-note entry in a PG update > release explaining that this will break and here's what to do to fix it. I was assuming that if you did an update of the tzdata, you'd notice if posixrules had been nuked. I guess that wouldn't help people who are using the system tzdata, though. It might be nice to know what Debian, RHEL, etc. plan to do about this, but I'm not sure how practical it is to find out. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Robert Haas writes: > It's really unclear to me why we should back-patch this into > already-released branches. I grant your point that perhaps few people > will notice, and also that this might happen at some point the change > will be forced upon us. Nonetheless, we bill our back-branches as > being stable, which seems inconsistent with forcing a potentially > breaking change into them without a clear and pressing need. If you > commit this patch to master and v13, no already-release branches will > be affected immediately, and it's conceivable that some or even all of > the older branches will age out before the issue is forced. That would > be all to the good. And even if the issue is forced sooner rather than > later, how much do we really lose by waiting until we have that > problem in front of us? > I'm not in a position to judge how much additional maintenance > overhead would be imposed by not back-patching this at once, so if you > tell me that it's an intolerable burden, I can't really argue with > that. But if it's possible to take a wait-and-see attitude for the > time being, so much the better. The code delta is small enough that I don't foresee any real maintenance problem if we let the back branches differ from HEAD/v13 on this point. What I'm concerned about is that people depending on the existing behavior are likely to wake up one fine morning and discover that it's broken after a routine tzdata update. I think that it'd be a better user experience for them to see a release-note entry in a PG update release explaining that this will break and here's what to do to fix it. Yeah, we can do nothing in the back branches and hope that that doesn't happen for the remaining lifespan of v12. But I wonder whether that doesn't amount to sticking our heads in the sand. I suppose it'd be possible to have a release-note entry in the back branches that isn't tied to any actual code change on our part, but just warns that such a tzdata change might happen at some unpredictable future time. That feels weird and squishy though; and people would likely have forgotten it by the time the change actually hits them. regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
On Fri, Jun 19, 2020 at 3:27 PM Tom Lane wrote: > Anyway, as I write this I'm kind of talking myself into the position > that we should indeed back-patch this. The apparent stability > benefits of not doing so may be illusory, and if we back-patch then > at least we get to document that there's a change. But an argument > could be made in the other direction too. It's really unclear to me why we should back-patch this into already-released branches. I grant your point that perhaps few people will notice, and also that this might happen at some point the change will be forced upon us. Nonetheless, we bill our back-branches as being stable, which seems inconsistent with forcing a potentially breaking change into them without a clear and pressing need. If you commit this patch to master and v13, no already-release branches will be affected immediately, and it's conceivable that some or even all of the older branches will age out before the issue is forced. That would be all to the good. And even if the issue is forced sooner rather than later, how much do we really lose by waiting until we have that problem in front of us? I'm not in a position to judge how much additional maintenance overhead would be imposed by not back-patching this at once, so if you tell me that it's an intolerable burden, I can't really argue with that. But if it's possible to take a wait-and-see attitude for the time being, so much the better. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Peter Eisentraut writes: > On 2020-06-17 20:08, Tom Lane wrote: >> I would definitely be in favor of "nuke it now" with respect to HEAD. >> It's a bit more debatable for the back branches. However, all branches >> are going to be equally exposed to updated system tzdata trees, so >> we've typically felt that changes in the tz-related code should be >> back-patched. > It seems sensible to me to remove it in master and possibly > REL_13_STABLE, but leave it alone in the back branches. For purposes of discussion, here's a patch that rips out posixrules support altogether. (Note that further code simplifications could be made --- the "load_ok" variable is vestigial, for instance. This formulation is intended to minimize the diffs from upstream.) A less aggressive idea would be to leave the code alone and just change the makefiles to not install a posixrules file in our own builds. That'd leave the door open for somebody who really needed posixrules behavior to get it back by just creating a posixrules file. I'm not sure this idea has much else to recommend it though. I'm honestly not sure what I think we should do exactly. The main arguments in favor of the full-rip-out option seem to be (1) It'd ensure consistent behavior of POSIX zone specs across platforms, whether or not --with-system-tzdata is used and whether or not the platform supplies a posixrules file. (2) We'll presumably be forced into the no-posixrules behavior at some point, so forcing the issue lets us dictate the timing rather than having it be dictated to us. If nothing else, that means we can release-note the behavioral change in a timely fashion. Point (2) seems like an argument for doing it only in master (possibly plus v13), but on the other hand I'm not convinced about how much control we really have if we wait. What seems likely to happen is that posixrules files will disappear from platform tz databases over some hard-to-predict timespan. Even if no major platforms drop them immediately at the next IANA update, it seems quite likely that some/many will do so within the remaining support lifetime of v12. So even if we continue to support the feature, it's likely to vanish in practice at some uncertain point. Given that the issue only affects people using nonstandard TimeZone settings, it may be that we shouldn't agonize over it too much either way. Anyway, as I write this I'm kind of talking myself into the position that we should indeed back-patch this. The apparent stability benefits of not doing so may be illusory, and if we back-patch then at least we get to document that there's a change. But an argument could be made in the other direction too. Thoughts? regards, tom lane diff --git a/doc/src/sgml/datetime.sgml b/doc/src/sgml/datetime.sgml index 71fbf842cc..bbf50b76f8 100644 --- a/doc/src/sgml/datetime.sgml +++ b/doc/src/sgml/datetime.sgml @@ -718,33 +718,12 @@ If a daylight-savings abbreviation is given but the transition rule field is omitted, - PostgreSQL attempts to determine the - transition times by consulting the posixrules file - in the IANA time zone database. This file has the same format as a - full time zone entry, but only its transition timing rules are used, - not its UTC offsets. Typically, this file has the same contents as the - US/Eastern file, so that POSIX-style time zone - specifications follow USA daylight-savings rules. If needed, you can - adjust this behavior by replacing the posixrules - file. - - - - -The facility to consult a posixrules file has -been deprecated by IANA, and it is likely to go away in the future. -One bug in this feature, which is unlikely to be fixed before it -disappears, is that it fails to apply DST rules to dates after 2038. - - - - - If the posixrules file is not present, the fallback behavior is to use the rule M3.2.0,M11.1.0, which corresponds to USA practice as of 2020 (that is, spring forward on the second Sunday of March, fall back on the first Sunday of November, both transitions - occurring at 2AM prevailing time). + occurring at 2AM prevailing time). Note that this rule does not + give correct USA transition dates for years before 2007. @@ -765,8 +744,7 @@ because (for historical reasons) there are files by those names in the IANA time zone database. The practical implication of this is that these zone names will produce valid historical USA daylight-savings - transitions, even when a plain POSIX specification would not due to - lack of a suitable posixrules file. + transitions, even when a plain POSIX specification would not. diff --git a/src/timezone/Makefile b/src/timezone/Makefile index bf23ac9da9..715b63cee0 100644 --- a/src/timezone/Makefile +++ b/src/timezone/Makefile @@ -29,10 +29,6 @@ ZICOBJS = \ # we now distribute the timezone data as a single file TZDATAFILES = $(srcdir)/data/tzdata.zi
Re: More tzdb fun: POSIXRULES is being deprecated upstream
I wrote: > I experimented with removing the posixrules support, and was quite glad > I did, because guess what: our regression tests fall over. If we do > nothing we can expect that they'll start failing on various random systems > come this fall. To clarify, you can produce this failure without any code changes: build a standard installation (*not* using --with-system-tzdata), remove its .../share/timezone/posixrules file, and run "make installcheck". So builds that do use --with-system-tzdata will fail both "make check" and "make installcheck" if the platform's tzdata packager decides to get rid of the posixrules file. However, on closer inspection, all the test cases that depend on 'PST8PDT' are fine, because we *do* pick up the zone file by that name. The cases that fall over are a few in horology.sql that depend on SET TIME ZONE 'CST7CDT'; There is no such zone file, because that's a mistake: the central US zone is more properly rendered 'CST6CDT'. So this is indeed a bare POSIX zone specification, and its behavior changes if there's no posixrules file to back-fill knowledge about pre-2007 DST laws. These test cases originated in commit b2b6548c7. That was too long ago to be sure, but I suspect that the use of a bogus zone was just a thinko; there's certainly nothing in the commit log or the text of the patch suggesting that it was intentional. Still, it seems good to be testing our POSIX-zone-string code paths, so I'm inclined to leave it as CST7CDT but remove the dependence on posixrules by adding an explicit transition rule. Also, I notice a couple of related documentation issues: * The same commit added a documentation example that also cites CST7CDT. That needs to be fixed to correspond to something that would actually be used in the real world, probably America/Denver. Otherwise the example will fail to work for some people. * We should add something to the new appendix about POSIX zone specs pointing out that while EST5EDT, CST6CDT, MST7MDT, PST8PDT look like they are POSIX strings, they actually are captured by IANA zone files, so that they produce valid historical US DST transitions even when a plain POSIX string wouldn't. I'm less excited than I was yesterday about removing the tests' dependency on 'PST8PDT'. It remains possible that we might need to do that someday, but I doubt it'd happen without plenty of warning. regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
On 2020-06-17 20:08, Tom Lane wrote: I would definitely be in favor of "nuke it now" with respect to HEAD. It's a bit more debatable for the back branches. However, all branches are going to be equally exposed to updated system tzdata trees, so we've typically felt that changes in the tz-related code should be back-patched. It seems sensible to me to remove it in master and possibly REL_13_STABLE, but leave it alone in the back branches. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: More tzdb fun: POSIXRULES is being deprecated upstream
I wrote: > ... We should expect that, starting probably this fall, there > will be installations with no posixrules file. > The minimum thing that we have to do, I'd say, is to change the > documentation to explain what happens if there's no posixrules file. > However, in view of the fact that the posixrules feature doesn't work > past 2037 and isn't going to be fixed, maybe we should just nuke it > now rather than waiting for our hand to be forced. I'm not sure that > I've ever heard of anyone replacing the posixrules file anyway. > (The fallback case is actually better in that it works for dates past > 2037; it's worse only in that you can't configure it.) I experimented with removing the posixrules support, and was quite glad I did, because guess what: our regression tests fall over. If we do nothing we can expect that they'll start failing on various random systems come this fall. The cause of the failure is that we set the timezone for all regression tests to just 'PST8PDT', which is exactly the underspecified POSIX syntax that is affected by the posixrules feature. So, with the fallback rule of "M3.2.0,M11.1.0" (which corresponds to US law since 2007) we get the wrong answers for some old test cases involving dates in 2005. I'm inclined to think that the simplest fix is to replace 'PST8PDT' with 'America/Los_Angeles' as the standard zone setting for the regression tests. We definitely should be testing behavior with time-varying DST laws, and we can no longer count on POSIX-style zone names to do that. Another point, which I've not looked into yet, is that I'd always supposed that PST8PDT and the other legacy US zone names would result in loading the zone files of those names, ie /usr/share/zoneinfo/PST8PDT and friends. This seems not to be happening though. Should we try to make it happen? It would probably result in fewer surprises once posixrules goes away, because our regression tests are likely not the only users of these zone names. (I'd still be inclined to do the first thing though; it seems to me that the historical behavior of 'America/Los_Angeles' is way more likely to hold still than that of 'PST8PDT'. The IANA crew might nuke the latter zone entirely at some point, especially if the repeated proposals to get rid of DST in the US ever get anywhere.) regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Robert Haas writes: > You could consider something along the lines of: > This form specifies a transition that always happens during the same > month and on the same day of the week. m identifies the month, from 1 > to 12. n specifies the n'th occurrence of the day number identified by > d. n is a value between 1 and 4, or 5 meaning the last occurrence of > that weekday in the month (which could be the fourth or the fifth). d > is a value between 0 and 6, with 0 indicating Sunday. Adopted with some minor tweaks. Thanks for the suggestion! regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
On Thu, Jun 18, 2020 at 1:05 PM Tom Lane wrote: > Robert Haas writes: > > It's a little confusing, though, that you documented it as Mm.n.d but > > then in the text the order of explanation is d then m then n. Maybe > > switch the text around so the order matches, or even use something > > like Mmonth.occurrence.day. > > Yeah, I struggled with that text for a bit. It doesn't seem to make sense > to explain that n means the n'th occurrence of a particular d value before > we've explained what d is, so explaining the fields in their syntactic > order seems like a loser. But we could describe m first without that > problem. You could consider something along the lines of: This form specifies a transition that always happens during the same month and on the same day of the week. m identifies the month, from 1 to 12. n specifies the n'th occurrence of the day number identified by d. n is a value between 1 and 4, or 5 meaning the last occurrence of that weekday in the month (which could be the fourth or the fifth). d is a value between 0 and 6, with 0 indicating Sunday. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Robert Haas writes: > It's a little confusing, though, that you documented it as Mm.n.d but > then in the text the order of explanation is d then m then n. Maybe > switch the text around so the order matches, or even use something > like Mmonth.occurrence.day. Yeah, I struggled with that text for a bit. It doesn't seem to make sense to explain that n means the n'th occurrence of a particular d value before we've explained what d is, so explaining the fields in their syntactic order seems like a loser. But we could describe m first without that problem. Not sure about replacing the m/n/d notation --- that's straight out of POSIX, so inventing our own terminology might just confuse people who do know the spec. regards, tom lane
Re: More tzdb fun: POSIXRULES is being deprecated upstream
On Thu, Jun 18, 2020 at 12:26 AM Tom Lane wrote: > Here's a proposed patch to do that. To explain this, we more or less > have to fully document the POSIX timezone string format (otherwise > nobody's gonna understand what "M3.2.0,M11.1.0" means). That's something > we've glossed over for many years, and I still feel like it's not > something to explain in-line in section 8.5.3, so I shoved all the gory > details into a new section in Appendix B. To be clear, nothing here is > new behavior, it was just undocumented before. I'm glad you are proposing to document this, because the set of people who had no idea what "M3.2.0,M11.1.0" means definitely included me. It's a little confusing, though, that you documented it as Mm.n.d but then in the text the order of explanation is d then m then n. Maybe switch the text around so the order matches, or even use something like Mmonth.occurrence.day. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Re: More tzdb fun: POSIXRULES is being deprecated upstream
I wrote: > The minimum thing that we have to do, I'd say, is to change the > documentation to explain what happens if there's no posixrules file. Here's a proposed patch to do that. To explain this, we more or less have to fully document the POSIX timezone string format (otherwise nobody's gonna understand what "M3.2.0,M11.1.0" means). That's something we've glossed over for many years, and I still feel like it's not something to explain in-line in section 8.5.3, so I shoved all the gory details into a new section in Appendix B. To be clear, nothing here is new behavior, it was just undocumented before. regards, tom lane diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 3df189ad85..ca61439501 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -2492,25 +2492,10 @@ TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02' In addition to the timezone names and abbreviations, PostgreSQL will accept POSIX-style time zone -specifications of the form STDoffset or -STDoffsetDST, where -STD is a zone abbreviation, offset is a -numeric offset in hours west from UTC, and DST is an -optional daylight-savings zone abbreviation, assumed to stand for one -hour ahead of the given offset. For example, if EST5EDT -were not already a recognized zone name, it would be accepted and would -be functionally equivalent to United States East Coast time. In this -syntax, a zone abbreviation can be a string of letters, or an -arbitrary string surrounded by angle brackets (). -When a daylight-savings zone abbreviation is present, -it is assumed to be used -according to the same daylight-savings transition rules used in the -IANA time zone database's posixrules entry. -In a standard PostgreSQL installation, -posixrules is the same as US/Eastern, so -that POSIX-style time zone specifications follow USA daylight-savings -rules. If needed, you can adjust this behavior by replacing the -posixrules file. +specifications, as described in +. This option is not +normally preferable to using a named time zone, but it may be +necessary if no suitable IANA time zone entry is available. @@ -2537,19 +2522,6 @@ TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02' above, this is not necessarily the same as local civil time on that date. - - One should be wary that the POSIX-style time zone feature can - lead to silently accepting bogus input, since there is no check on the - reasonableness of the zone abbreviations. For example, SET - TIMEZONE TO FOOBAR0 will work, leaving the system effectively using - a rather peculiar abbreviation for UTC. - Another issue to keep in mind is that in POSIX time zone names, - positive offsets are used for locations west of Greenwich. - Everywhere else, PostgreSQL follows the - ISO-8601 convention that positive timezone offsets are east - of Greenwich. - - In all cases, timezone names and abbreviations are recognized case-insensitively. (This is a change from PostgreSQL diff --git a/doc/src/sgml/datetime.sgml b/doc/src/sgml/datetime.sgml index 7cce826e2d..fb210b377b 100644 --- a/doc/src/sgml/datetime.sgml +++ b/doc/src/sgml/datetime.sgml @@ -555,6 +555,210 @@ + + POSIX Time Zone Specifications + + + time zone + POSIX-style specification + + + + PostgreSQL can accept time zone specifications that + are written according to the POSIX standard's rules + for the TZ environment + variable. POSIX time zone specifications are + inadequate to deal with the complexity of real-world time zone history, + but there are sometimes reasons to use them. + + + + A POSIX time zone specification has the form + +STD offset DST dstoffset , rule + + (For readability, we show spaces between the fields, but spaces should + not be used in practice.) The fields are: + + + + STD is the zone abbreviation to be used + for standard time. + + + + + offset is the zone's standard-time offset + from UTC. + + + + + DST is the zone abbreviation to be used + for daylight-savings time. If this field and the following ones are + omitted, the zone uses a fixed UTC offset with no daylight-savings + rule. + + + + + dstoffset is the daylight-savings offset + from UTC. This field is typically omitted, since it defaults to one + hour less than the standard-time offset, + which is usually the right thing. + + + + + rule defines the rule for when daylight + savings is in effect, as described below. + + + + + + + In this syntax, a zone abbreviation can be a
Re: More tzdb fun: POSIXRULES is being deprecated upstream
Last year I wrote: > Paul Eggert, in https://mm.icann.org/pipermail/tz/2019-June/028172.html: >> zic’s -p option was intended as a transition from historical >> System V code that treated TZ="XXXnYYY" as meaning US >> daylight-saving rules in a time zone n hours west of UT, >> with XXX abbreviating standard time and YYY abbreviating DST. >> zic -p allows the tzdata installer to specify (say) >> Europe/Brussels's rules instead of US rules. This behavior >> is not well documented and often fails in practice; for example it >> does not work with current glibc for contemporary timestamps, and >> it does not work in tzdb itself for timestamps after 2037. >> So, document it as being obsolete, with the intent that it >> will be removed in a future version. This change does not >> affect behavior of the default installation. Well, we ignored this for a year, but it's about to become unavoidable: http://mm.icann.org/pipermail/tz/2020-June/029093.html IANA upstream is changing things so that by default there will not be any "posixrules" file in the tz database. That wouldn't directly affect our builds, since we don't use their Makefile anyway. But it will affect installations that use --with-system-tzdata, which I believe is most vendor-packaged Postgres installations. It's possible that most or even all tzdata packagers will ignore the change and continue to ship a posixrules file, for backwards compatibility's sake. But I doubt we should bet that way. glibc-based distros, in particular, would have little motivation to do so. We should expect that, starting probably this fall, there will be installations with no posixrules file. The minimum thing that we have to do, I'd say, is to change the documentation to explain what happens if there's no posixrules file. However, in view of the fact that the posixrules feature doesn't work past 2037 and isn't going to be fixed, maybe we should just nuke it now rather than waiting for our hand to be forced. I'm not sure that I've ever heard of anyone replacing the posixrules file anyway. (The fallback case is actually better in that it works for dates past 2037; it's worse only in that you can't configure it.) I would definitely be in favor of "nuke it now" with respect to HEAD. It's a bit more debatable for the back branches. However, all branches are going to be equally exposed to updated system tzdata trees, so we've typically felt that changes in the tz-related code should be back-patched. Thoughts? regards, tom lane
More tzdb fun: POSIXRULES is being deprecated upstream
Paul Eggert, in https://mm.icann.org/pipermail/tz/2019-June/028172.html: > zic’s -p option was intended as a transition from historical > System V code that treated TZ="XXXnYYY" as meaning US > daylight-saving rules in a time zone n hours west of UT, > with XXX abbreviating standard time and YYY abbreviating DST. > zic -p allows the tzdata installer to specify (say) > Europe/Brussels's rules instead of US rules. This behavior > is not well documented and often fails in practice; for example it > does not work with current glibc for contemporary timestamps, and > it does not work in tzdb itself for timestamps after 2037. > So, document it as being obsolete, with the intent that it > will be removed in a future version. This change does not > affect behavior of the default installation. As he says, this doesn't work for post-2038 dates: regression=# set timezone = 'FOO5BAR'; SET regression=# select now(); now --- 2019-07-04 11:55:46.905382-04 (1 row) regression=# select timeofday(); timeofday - Thu Jul 04 11:56:14.102770 2019 BAR (1 row) regression=# select '2020-07-04'::timestamptz; timestamptz 2020-07-04 00:00:00-04 (1 row) regression=# select '2040-07-04'::timestamptz; timestamptz 2040-07-04 00:00:00-05 <<-- should be -04 (1 row) and this note makes it clear that the IANA crew aren't planning on fixing that. It does work if you write a full POSIX-style DST specification: regression=# set timezone = 'FOO5BAR,M3.2.0,M11.1.0'; SET regression=# select '2040-07-04'::timestamptz; timestamptz 2040-07-04 00:00:00-04 (1 row) so I think what Eggert has in mind here is that they'll remove the TZDEFRULES-loading logic and always fall back to TZDEFRULESTRING when presented with a POSIX-style zone spec that lacks explicit transition date rules. So, what if anything should we do about this? We do document posixrules, very explicitly, see datatype.sgml around line 2460: When a daylight-savings zone abbreviation is present, it is assumed to be used according to the same daylight-savings transition rules used in the IANA time zone database's posixrules entry. In a standard PostgreSQL installation, posixrules is the same as US/Eastern, so that POSIX-style time zone specifications follow USA daylight-savings rules. If needed, you can adjust this behavior by replacing the posixrules file. One option is to do nothing until the IANA code actually changes, but as 2038 gets closer, people are more likely to start noticing that this "feature" doesn't work as one would expect. We could get out front of the problem and remove the TZDEFRULES-loading logic ourselves. That would be a bit of a maintenance hazard, but perhaps not too awful, because we already deviate from the IANA code in that area (we have our own ideas about when/whether to try to load TZDEFRULES). I don't think we'd want to change this behavior in the back branches, but it might be OK to do it as a HEAD change. I think I'd rather do it like that than be forced into playing catchup when the IANA code does change. A more aggressive idea would be to stop supporting POSIX-style timezone specs altogether, but I'm not sure I like that answer. Even if we could get away with it from a users'-eye standpoint, I think we have some internal dependencies on being able to use such specifications. regards, tom lane