Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit55862b2

Browse files
committed
Tweak our special-case logic for the IANA "Factory" timezone.
pg_timezone_names() tries to avoid showing the "Factory" zone inthe 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 packagersare so wedded to backwards compatibility that they hack the IANA datato keep the old spelling --- and not just that old spelling, but evenolder spellings that IANA used back in the stone age. This caused thefilter 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 aboutexactly what Factory's abbreviation is, and instead reject abbreviationsexceeding 31 characters. This will allow Factory to appear in the viewif 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'sabbreviation. Unlike pg_timezone_names(), there's no reason forthat code to support old/nonstandard timezone data.Since we generally prefer to keep timezone-related behavior thesame 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
1 parentae9b91b commit55862b2

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

‎src/backend/utils/adt/datetime.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4854,16 +4854,15 @@ pg_timezone_names(PG_FUNCTION_ARGS)
48544854
continue;/* ignore if conversion fails */
48554855

48564856
/*
4857-
*Ignore zic's rather silly "Factory" time zone. The long string
4858-
*about "see zic manual page" is used in tzdata versions before
4859-
*2016g; we can drop it someday when we're pretty sure no such data
4860-
*exists in the wild on platforms using --with-system-tzdata. In
4861-
*2016g and later,thetime zone abbreviation "-00" is used for
4862-
*"Factory" as well as some invalid cases, all of which we can
4863-
*reasonably omit from the pg_timezone_names view.
4857+
*IANA's rather silly "Factory" time zone used to emit ridiculously
4858+
*long "abbreviations" such as "Local time zone must be set--see zic
4859+
*manual page" or "Local time zone must be set--use tzsetup". While
4860+
*modern versions of tzdb emit the much saner "-00", it seems some
4861+
*benighted packagers are hackingtheIANA data so that it continues
4862+
*to produce these strings. To prevent producing a weirdly wide
4863+
*abbrev column, reject ridiculously long abbreviations.
48644864
*/
4865-
if (tzn&& (strcmp(tzn,"-00")==0||
4866-
strcmp(tzn,"Local time zone must be set--see zic manual page")==0))
4865+
if (tzn&&strlen(tzn)>31)
48674866
continue;
48684867

48694868
/* Found a displayable zone */

‎src/timezone/zic.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,13 +2443,10 @@ writezone(const char *const name, const char *const string, char version,
24432443
unsignedchartm=types[i];
24442444
char*thisabbrev=&thischars[indmap[desigidx[tm]]];
24452445

2446-
/* filter out assorted junk entries */
2447-
if (strcmp(thisabbrev,GRANDPARENTED)!=0&&
2448-
strcmp(thisabbrev,"zzz")!=0)
2449-
fprintf(stdout,"%s\t"INT64_FORMAT"%s\n",
2450-
thisabbrev,
2451-
utoffs[tm],
2452-
isdsts[tm] ?"\tD" :"");
2446+
fprintf(stdout,"%s\t"INT64_FORMAT"%s\n",
2447+
thisabbrev,
2448+
utoffs[tm],
2449+
isdsts[tm] ?"\tD" :"");
24532450
}
24542451
}
24552452
/* Print the default type if we have no transitions at all */
@@ -2458,13 +2455,10 @@ writezone(const char *const name, const char *const string, char version,
24582455
unsignedchartm=defaulttype;
24592456
char*thisabbrev=&thischars[indmap[desigidx[tm]]];
24602457

2461-
/* filter out assorted junk entries */
2462-
if (strcmp(thisabbrev,GRANDPARENTED)!=0&&
2463-
strcmp(thisabbrev,"zzz")!=0)
2464-
fprintf(stdout,"%s\t"INT64_FORMAT"%s\n",
2465-
thisabbrev,
2466-
utoffs[tm],
2467-
isdsts[tm] ?"\tD" :"");
2458+
fprintf(stdout,"%s\t"INT64_FORMAT"%s\n",
2459+
thisabbrev,
2460+
utoffs[tm],
2461+
isdsts[tm] ?"\tD" :"");
24682462
}
24692463
}
24702464

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp