Re: [bug fix] strerror() returns ??? in a UTF-8/C database with LC_MESSAGES=non-ASCII

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [bug fix] strerror() returns ??? in a UTF-8/C database with LC_MESSAGES=non-ASCII
Дата
Msg-id 29000.1378478236@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [bug fix] strerror() returns ??? in a UTF-8/C database with LC_MESSAGES=non-ASCII  ("MauMau" <maumau307@gmail.com>)
Ответы Re: [bug fix] strerror() returns ??? in a UTF-8/C database with LC_MESSAGES=non-ASCII  (Andres Freund <andres@2ndquadrant.com>)
Re: [bug fix] strerror() returns ??? in a UTF-8/C database with LC_MESSAGES=non-ASCII  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
"MauMau" <maumau307@gmail.com> writes:
> I've been suffering from PostgreSQL's problems related to character encoding 
> for some time.  I really wish to solve those problems, because they make 
> troubleshooting difficult.  I'm going to propose fixes for them, and I would 
> appreciate if you could help release the official patches as soon as 
> possible.

I don't find either of these patches to be a particularly good idea.
There is certainly no way we'd risk back-patching something with as
many potential side-effects as fooling with libc's textdomain.

I wonder though if we could attack the specific behavior you're
complaining of by testing to see if strerror() returned "???", and
substituting the numeric value for that, ie
 * Some strerror()s return an empty string for out-of-range errno. This is * ANSI C spec compliant, but not exactly
useful.*/
 
-    if (str == NULL || *str == '\0')
+    if (str == NULL || *str == '\0' || strcmp(str, "???") == 0){    snprintf(errorstr_buf, sizeof(errorstr_buf),
/*------

This would only work if glibc always returns that exact string for a
codeset translation failure, but a look into the glibc sources should
quickly confirm that.

BTW: personally, I would say that what you're looking at is a glibc bug.
I always thought the contract of gettext was to return the ASCII version
if it fails to produce a translated version.  That might not be what the
end user really wants to see, but surely returning something like "???"
is completely useless to anybody.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: [RFC] Extend namespace of valid guc names
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [bug fix] strerror() returns ??? in a UTF-8/C database with LC_MESSAGES=non-ASCII