Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hqkSc-0008D5-9B for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jul 2019 20:35:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hqkSa-0006vY-2H for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jul 2019 20:35:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hqkSZ-0006tG-O6 for pgsql-hackers@lists.postgresql.org; Thu, 25 Jul 2019 20:35:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hqkSW-0005ST-Cg for pgsql-hackers@postgresql.org; Thu, 25 Jul 2019 20:35:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6PKZFkU003962; Thu, 25 Jul 2019 16:35:15 -0400 From: Tom Lane To: Thomas Munro cc: Andrew Gierth , Robert Haas , Stephen Frost , Andres Freund , Christoph Berg , PostgreSQL Hackers Subject: Re: UCT (Re: pgsql: Update time zone data files to tzdata release 2019a.) In-reply-to: References: <24452.1560285699@sss.pgh.pa.us> <20190614095546.GA15107@msg.df7cb.de> <26948.1560517875@sss.pgh.pa.us> <87ef3w3u8a.fsf@news-spur.riddles.org.uk> <7114.1560539536@sss.pgh.pa.us> <875zp74zpf.fsf@news-spur.riddles.org.uk> <871rzv4yes.fsf@news-spur.riddles.org.uk> <20190617173943.z3ttxqenbcwrlag4@alap3.anarazel.de> <20190617183458.GG2480@tamriel.snowman.net> <20190617183828.hj7ci362zbxd4nax@alap3.anarazel.de> <20190617184053.GI2480@tamriel.snowman.net> <25314.1560980148@sss.pgh.pa.us> <27991.1560984458@sss.pgh.pa.us> <877e9h18df.fsf@news-spur.riddles.org.uk> <2643.1561508327@sss.pgh.pa.us> <877e98syi5.fsf@news-spur.riddles.org.uk> <8736jwsdv2.fsf@news-spur.riddles.org.uk> <17148.1561568815@sss.pgh.pa.us> <87y31oq9g6.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Thomas Munro message dated "Wed, 17 Jul 2019 19:16:00 +1200" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <3883.1564086806.0@sss.pgh.pa.us> Date: Thu, 25 Jul 2019 16:35:15 -0400 Message-ID: <3961.1564086915@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3883.1564086806.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Thomas Munro writes: > FWIW this is now fixed for FreeBSD 13-CURRENT, with a good chance of > back-patch. I don't know if there are any other operating systems > that are shipping zoneinfo but failing to install zone1970.tab, but if > there are it's a mistake IMHO and they'll probably fix that if someone > complains, considering that zone.tab literally tells you to go and use > the newer version, and Paul Eggert has implied that zone1970.tab is > the "full" and "canonical" list[1]. I'm not sure we're any closer to a meeting of the minds on whether consulting zone[1970].tab is a good thing to do, but we got an actual user complaint[1] about how "localtime" should not be a preferred spelling. So I want to go ahead and insert the discussed anti-preference against "localtime" and "posixrules", as per 0001 below. If we do do something with zone[1970].tab, we'd still need these special rules, so I don't think this is blocking anything. Also, I poked into the question of the "Factory" zone a bit more, and was disappointed to find that not only does FreeBSD still install the "Factory" zone, but they are apparently hacking the data so that it emits the two-changes-back abbreviation "Local time zone must be set--use tzsetup". This bypasses the filter in pg_timezone_names that is expressly trying to prevent showing such silly "abbreviations". So I now feel that not only can we not remove initdb's discrimination against "Factory", but we indeed need to make the pg_timezone_names filter more aggressive. Hence, I now propose 0002 below to tweak what we're doing with "Factory". I did remove our special cases for it in zic.c, as we don't need them anymore with modern tzdb data, and there's no reason to support running "zic -P" with hacked-up data. regards, tom lane [1] https://www.postgresql.org/message-id/CADT4RqCCnj6FKLisvT8tTPfTP4azPhh= DFJqDF1JfBbOH5w4oyQ@mail.gmail.com ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="0001-ignore-localtime-and-posixrules.patch"; charset="us-ascii" Content-ID: <3883.1564086806.2@sss.pgh.pa.us> Content-Description: 0001-ignore-localtime-and-posixrules.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/initdb/findtimezone.c b/src/bin/initdb/findtimezone.c index a5c9c9e..786e787 100644 --- a/src/bin/initdb/findtimezone.c +++ b/src/bin/initdb/findtimezone.c @@ -608,22 +608,28 @@ check_system_link_file(const char *linkname, struct = tztry *tt, /* * Given a timezone name, determine whether it should be preferred over o= ther * names which are equally good matches. The output is arbitrary but we w= ill - * use 0 for "neutral" default preference. - * - * Ideally we'd prefer the zone.tab/zone1970.tab names, since in general = those - * are the ones offered to the user to select from. But for the moment, t= o - * minimize changes in behaviour, simply prefer UTC over alternative spel= lings - * such as UCT that otherwise cause confusion. The existing "shortest fir= st" - * rule would prefer "UTC" over "Etc/UTC" so keep that the same way (whil= e - * still preferring Etc/UTC over Etc/UCT). + * use 0 for "neutral" default preference; larger values are more preferr= ed. */ static int zone_name_pref(const char *zonename) { + /* + * Prefer UTC over alternatives such as UCT. Also prefer Etc/UTC over + * Etc/UCT; but UTC is preferred to Etc/UTC. + */ if (strcmp(zonename, "UTC") =3D=3D 0) return 50; if (strcmp(zonename, "Etc/UTC") =3D=3D 0) return 40; + + /* + * We don't want to pick "localtime" or "posixrules", unless we can find + * no other name for the prevailing zone. Those aren't real zone names. + */ + if (strcmp(zonename, "localtime") =3D=3D 0 || + strcmp(zonename, "posixrules") =3D=3D 0) + return -50; + return 0; } = ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="0002-tweak-Factory-cases.patch"; charset="us-ascii" Content-ID: <3883.1564086806.3@sss.pgh.pa.us> Content-Description: 0002-tweak-Factory-cases.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/date= time.c index 4d8db1a..972fcd2 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -4826,16 +4826,15 @@ pg_timezone_names(PG_FUNCTION_ARGS) continue; /* ignore if conversion fails */ = /* - * Ignore zic's rather silly "Factory" time zone. The long string - * about "see zic manual page" is used in tzdata versions before - * 2016g; we can drop it someday when we're pretty sure no such data - * exists in the wild on platforms using --with-system-tzdata. In - * 2016g and later, the time zone abbreviation "-00" is used for - * "Factory" as well as some invalid cases, all of which we can - * reasonably omit from the pg_timezone_names view. + * IANA's rather silly "Factory" time zone used to emit ridiculously + * long "abbreviations" such as "Local time zone must be set--see zic + * manual page" or "Local time zone must be set--use tzsetup". While + * modern versions of tzdb emit the much saner "-00", it seems some + * benighted packagers are hacking the IANA data so that it continues + * to produce these strings. To prevent producing a weirdly wide + * abbrev column, reject ridiculously long abbreviations. */ - if (tzn && (strcmp(tzn, "-00") =3D=3D 0 || - strcmp(tzn, "Local time zone must be set--see zic manual page") =3D=3D= 0)) + if (tzn && strlen(tzn) > 31) continue; = /* Found a displayable zone */ diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 95ab854..c27fb45 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -2443,13 +2443,10 @@ writezone(const char *const name, const char *cons= t string, char version, unsigned char tm =3D types[i]; char *thisabbrev =3D &thischars[indmap[desigidx[tm]]]; = - /* filter out assorted junk entries */ - if (strcmp(thisabbrev, GRANDPARENTED) !=3D 0 && - strcmp(thisabbrev, "zzz") !=3D 0) - fprintf(stdout, "%s\t" INT64_FORMAT "%s\n", - thisabbrev, - utoffs[tm], - isdsts[tm] ? "\tD" : ""); + fprintf(stdout, "%s\t" INT64_FORMAT "%s\n", + thisabbrev, + utoffs[tm], + isdsts[tm] ? "\tD" : ""); } } /* Print the default type if we have no transitions at all */ @@ -2458,13 +2455,10 @@ writezone(const char *const name, const char *cons= t string, char version, unsigned char tm =3D defaulttype; char *thisabbrev =3D &thischars[indmap[desigidx[tm]]]; = - /* filter out assorted junk entries */ - if (strcmp(thisabbrev, GRANDPARENTED) !=3D 0 && - strcmp(thisabbrev, "zzz") !=3D 0) - fprintf(stdout, "%s\t" INT64_FORMAT "%s\n", - thisabbrev, - utoffs[tm], - isdsts[tm] ? "\tD" : ""); + fprintf(stdout, "%s\t" INT64_FORMAT "%s\n", + thisabbrev, + utoffs[tm], + isdsts[tm] ? "\tD" : ""); } } = ------- =_aaaaaaaaaa0--