diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-08-01 16:11:51 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-08-01 16:11:51 -0400 |
commit | 1e165d05fe06a9072867607886f818bc255507db (patch) | |
tree | f1970479542b1bb0c043c97a891dd9a766cea5cc /src/backend/utils/adt/pg_locale.c | |
parent | c1bb7870463bd8ab2b28b363616ec60a9041e13a (diff) | |
download | postgresql-1e165d05fe06a9072867607886f818bc255507db.tar.gz postgresql-1e165d05fe06a9072867607886f818bc255507db.zip |
Try to deliver a sane message for _create_locale() failure on Windows.
We were just printing errno, which is certainly not gonna work on
Windows. Now, it's not entirely clear from Microsoft's documentation
whether _create_locale() adheres to standard Windows error reporting
conventions, but let's assume it does and try to map the GetLastError
result to an errno. If this turns out not to work, probably the best
thing to do will be to assume the error is always ENOENT on Windows.
This is a longstanding bug, but given the lack of previous field
complaints, I'm not excited about back-patching it.
Per report from Murtuza Zabuawala.
Discussion: https://postgr.es/m/CAKKotZS-wcDcofXDCH=sidiuajE+nqHn2CGjLLX78anyDmi3gQ@mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/pg_locale.c')
-rw-r--r-- | src/backend/utils/adt/pg_locale.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 12419fc8df9..9500c6b39f8 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1227,13 +1227,18 @@ lc_ctype_is_c(Oid collation) static void report_newlocale_failure(const char *localename) { - /* copy errno in case one of the ereport auxiliary functions changes it */ - int save_errno = errno; + int save_errno; + + /* On Windows, transform _create_locale() error to errno */ +#ifdef WIN32 + _dosmaperr(GetLastError()); +#endif /* * ENOENT means "no such locale", not "no such file", so clarify that * errno with an errdetail message. */ + save_errno = errno; /* auxiliary funcs might change errno */ ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("could not create locale \"%s\": %m", |