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

Commit514f613

Browse files
committed
Second try at getting useful errors out of newlocale/_create_locale.
The early buildfarm returns for commit1e165d0 are pretty awful:not only does Windows not return a useful error, but it looks likea lot of Unix-ish platforms don't either. Given the number ofdifferent errnos seen so far, guess that what's really going on isthat some newlocale() implementations fail to set errno at all.Hence, let's try zeroing errno just before newlocale() and thenif it's still zero report as though it's ENOENT. That should coverthe Windows case too.It's clear that we'll have to drop the regression test case, unlesswe want to maintain a separate expected-file for platforms withoutHAVE_LOCALE_T. But I'll leave it there awhile longer to see if thisactually improves matters or not.Discussion:https://postgr.es/m/CAKKotZS-wcDcofXDCH=sidiuajE+nqHn2CGjLLX78anyDmi3gQ@mail.gmail.com
1 parent8e75372 commit514f613

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,15 @@ report_newlocale_failure(const char *localename)
12291229
{
12301230
intsave_errno;
12311231

1232-
/* On Windows, transform _create_locale() error to errno */
1233-
#ifdefWIN32
1234-
_dosmaperr(GetLastError());
1235-
#endif
1232+
/*
1233+
* Windows doesn't provide any useful error indication from
1234+
* _create_locale(), and BSD-derived platforms don't seem to feel they
1235+
* need to set errno either (even though POSIX is pretty clear that
1236+
* newlocale should do so). So, if errno hasn't been set, assume ENOENT
1237+
* is what to report.
1238+
*/
1239+
if (errno==0)
1240+
errno=ENOENT;
12361241

12371242
/*
12381243
* ENOENT means "no such locale", not "no such file", so clarify that
@@ -1311,6 +1316,7 @@ pg_newlocale_from_collation(Oid collid)
13111316
if (strcmp(collcollate,collctype)==0)
13121317
{
13131318
/* Normal case where they're the same */
1319+
errno=0;
13141320
#ifndefWIN32
13151321
loc=newlocale(LC_COLLATE_MASK |LC_CTYPE_MASK,collcollate,
13161322
NULL);
@@ -1326,9 +1332,11 @@ pg_newlocale_from_collation(Oid collid)
13261332
/* We need two newlocale() steps */
13271333
locale_tloc1;
13281334

1335+
errno=0;
13291336
loc1=newlocale(LC_COLLATE_MASK,collcollate,NULL);
13301337
if (!loc1)
13311338
report_newlocale_failure(collcollate);
1339+
errno=0;
13321340
loc=newlocale(LC_CTYPE_MASK,collctype,loc1);
13331341
if (!loc)
13341342
report_newlocale_failure(collctype);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp