mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-06 21:59:20 +02:00
Tweak our special-case logic for the IANA "Factory" timezone.
pg_timezone_names() tries to avoid showing the "Factory" zone in the view, mainly because that has traditionally had a very long "abbreviation" such as "Local time zone must be set--see zic manual page", so that showing it messes up psql's formatting of the whole view. Since tzdb version 2016g, IANA instead uses the abbreviation "-00", which is sane enough that there's no reason to discriminate against it. On the other hand, it emerges that FreeBSD and possibly other packagers are so wedded to backwards compatibility that they hack the IANA data to keep the old spelling --- and not just that old spelling, but even older spellings that IANA used back in the stone age. This caused the filter logic to fail to suppress "Factory" at all on such platforms, though the formatting problem is definitely real in that case. To solve both problems, get rid of the hard-wired assumption about exactly what Factory's abbreviation is, and instead reject abbreviations exceeding 31 characters. This will allow Factory to appear in the view if and only if it's using the modern abbreviation. In passing, simplify the code we add to zic.c to support "zic -P" to remove its now-obsolete hacks to not print the Factory zone's abbreviation. Unlike pg_timezone_names(), there's no reason for that code to support old/nonstandard timezone data. Since we generally prefer to keep timezone-related behavior the same in all branches, and since this is arguably a bug fix, back-patch to all supported branches. Discussion: https://postgr.es/m/3961.1564086915@sss.pgh.pa.us
This commit is contained in:
parent
e31dfe99c8
commit
d095b2fe67
@ -4826,16 +4826,15 @@ pg_timezone_names(PG_FUNCTION_ARGS)
|
|||||||
continue; /* ignore if conversion fails */
|
continue; /* ignore if conversion fails */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ignore zic's rather silly "Factory" time zone. The long string
|
* IANA's rather silly "Factory" time zone used to emit ridiculously
|
||||||
* about "see zic manual page" is used in tzdata versions before
|
* long "abbreviations" such as "Local time zone must be set--see zic
|
||||||
* 2016g; we can drop it someday when we're pretty sure no such data
|
* manual page" or "Local time zone must be set--use tzsetup". While
|
||||||
* exists in the wild on platforms using --with-system-tzdata. In
|
* modern versions of tzdb emit the much saner "-00", it seems some
|
||||||
* 2016g and later, the time zone abbreviation "-00" is used for
|
* benighted packagers are hacking the IANA data so that it continues
|
||||||
* "Factory" as well as some invalid cases, all of which we can
|
* to produce these strings. To prevent producing a weirdly wide
|
||||||
* reasonably omit from the pg_timezone_names view.
|
* abbrev column, reject ridiculously long abbreviations.
|
||||||
*/
|
*/
|
||||||
if (tzn && (strcmp(tzn, "-00") == 0 ||
|
if (tzn && strlen(tzn) > 31)
|
||||||
strcmp(tzn, "Local time zone must be set--see zic manual page") == 0))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Found a displayable zone */
|
/* Found a displayable zone */
|
||||||
|
@ -2443,9 +2443,6 @@ writezone(const char *const name, const char *const string, char version,
|
|||||||
unsigned char tm = types[i];
|
unsigned char tm = types[i];
|
||||||
char *thisabbrev = &thischars[indmap[desigidx[tm]]];
|
char *thisabbrev = &thischars[indmap[desigidx[tm]]];
|
||||||
|
|
||||||
/* filter out assorted junk entries */
|
|
||||||
if (strcmp(thisabbrev, GRANDPARENTED) != 0 &&
|
|
||||||
strcmp(thisabbrev, "zzz") != 0)
|
|
||||||
fprintf(stdout, "%s\t" INT64_FORMAT "%s\n",
|
fprintf(stdout, "%s\t" INT64_FORMAT "%s\n",
|
||||||
thisabbrev,
|
thisabbrev,
|
||||||
utoffs[tm],
|
utoffs[tm],
|
||||||
@ -2458,9 +2455,6 @@ writezone(const char *const name, const char *const string, char version,
|
|||||||
unsigned char tm = defaulttype;
|
unsigned char tm = defaulttype;
|
||||||
char *thisabbrev = &thischars[indmap[desigidx[tm]]];
|
char *thisabbrev = &thischars[indmap[desigidx[tm]]];
|
||||||
|
|
||||||
/* filter out assorted junk entries */
|
|
||||||
if (strcmp(thisabbrev, GRANDPARENTED) != 0 &&
|
|
||||||
strcmp(thisabbrev, "zzz") != 0)
|
|
||||||
fprintf(stdout, "%s\t" INT64_FORMAT "%s\n",
|
fprintf(stdout, "%s\t" INT64_FORMAT "%s\n",
|
||||||
thisabbrev,
|
thisabbrev,
|
||||||
utoffs[tm],
|
utoffs[tm],
|
||||||
|
Loading…
Reference in New Issue
Block a user