Thread: pgsql: Explicitly bind gettext() to the UTF8 locale when in use.

pgsql: Explicitly bind gettext() to the UTF8 locale when in use.

From
mha@postgresql.org (Magnus Hagander)
Date:
Log Message:
-----------
Explicitly bind gettext() to the  UTF8 locale when in use.
This is required on Windows due to the special locale
handling for UTF8 that doesn't change the full environment.

Fixes crash with translated error messages per bugs 4180
and 4196.

Tom Lane

Modified Files:
--------------
    pgsql/src/backend/utils/mb:
        mbutils.c (r1.70 -> r1.71)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/mb/mbutils.c?r1=1.70&r2=1.71)

Re: pgsql: Explicitly bind gettext() to the UTF8 locale when in use.

From
Hiroshi Inoue
Date:
Hi Magnus and all,

Magnus Hagander wrote:
> Log Message:
> -----------
> Explicitly bind gettext() to the  UTF8 locale when in use.
> This is required on Windows due to the special locale
> handling for UTF8 that doesn't change the full environment.

Thanks to this change UTF-8 case was solved but Japanese users
are still unhappy with Windows databases with EUC_JP encoding.
Shift_JIS which is a Japanese encoding under Windows doesn't
match any server encoding and causes a crash with the use of
gettext. So Saito-san removed ja message catalog just before
the 8.3 release.

Attached is a simple patch to avoid the crash and enable the
use of Japanese message catalog.
Please apply the patch if there's no problem.

regards,
Hiroshi Inoue

> Fixes crash with translated error messages per bugs 4180
> and 4196.
>
> Tom Lane
>
> Modified Files:
> --------------
>     pgsql/src/backend/utils/mb:
>         mbutils.c (r1.70 -> r1.71)
>         (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/mb/mbutils.c?r1=1.70&r2=1.71)


*** mbutils.c.orig    Sun Nov 23 08:42:57 2008
--- mbutils.c    Sun Nov 23 13:52:41 2008
***************
*** 825,830 ****
--- 825,832 ----
  void
  SetDatabaseEncoding(int encoding)
  {
+     const char *target_codeset = NULL;
+
      if (!PG_VALID_BE_ENCODING(encoding))
          elog(ERROR, "invalid database encoding: %d", encoding);

***************
*** 846,852 ****
       */
  #ifdef ENABLE_NLS
      if (encoding == PG_UTF8)
!         if (bind_textdomain_codeset("postgres", "UTF-8") == NULL)
              elog(LOG, "bind_textdomain_codeset failed");
  #endif
  }
--- 848,860 ----
       */
  #ifdef ENABLE_NLS
      if (encoding == PG_UTF8)
!         target_codeset = "UTF-8";
! #ifdef    WIN32
!     else if (encoding == PG_EUC_JP)
!         target_codeset = "EUC_JP";
! #endif /* WIN32 */
!     if (NULL != target_codeset)
!         if (bind_textdomain_codeset("postgres", target_codeset) == NULL)
              elog(LOG, "bind_textdomain_codeset failed");
  #endif
  }

Re: pgsql: Explicitly bind gettext() to the UTF8 locale when in use.

From
"Hiroshi Saito"
Date:
Hi.

It was comfortable in my environment. Then, as for me, to be contained
in the next release is desire.

BTW, I was wondering that it did not look at a problem in any countries
other than Japan. Probably, the environment with the runs locale which
can't be specified to be SERVER_ENCODING will be required.

Regards,
Hiroshi Saito

----- Original Message -----
From: "Hiroshi Inoue" <inoue@tpf.co.jp>


> Hi Magnus and all,
>
> Magnus Hagander wrote:
>> Log Message:
>> -----------
>> Explicitly bind gettext() to the  UTF8 locale when in use.
>> This is required on Windows due to the special locale
>> handling for UTF8 that doesn't change the full environment.
>
> Thanks to this change UTF-8 case was solved but Japanese users
> are still unhappy with Windows databases with EUC_JP encoding.
> Shift_JIS which is a Japanese encoding under Windows doesn't
> match any server encoding and causes a crash with the use of
> gettext. So Saito-san removed ja message catalog just before
> the 8.3 release.
>
> Attached is a simple patch to avoid the crash and enable the
> use of Japanese message catalog.
> Please apply the patch if there's no problem.
>
> regards,
> Hiroshi Inoue
>
>> Fixes crash with translated error messages per bugs 4180
>> and 4196.
>>
>> Tom Lane
>>
>> Modified Files:
>> --------------
>>     pgsql/src/backend/utils/mb:
>>         mbutils.c (r1.70 -> r1.71)
>>
>> (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/mb/mbutils.c?r1=1.70&r2=1.71)
>
>
>


--------------------------------------------------------------------------------


> *** mbutils.c.orig Sun Nov 23 08:42:57 2008
> --- mbutils.c Sun Nov 23 13:52:41 2008
> ***************
> *** 825,830 ****
> --- 825,832 ----
>  void
>  SetDatabaseEncoding(int encoding)
>  {
> + const char *target_codeset = NULL;
> +
>  if (!PG_VALID_BE_ENCODING(encoding))
>  elog(ERROR, "invalid database encoding: %d", encoding);
>
> ***************
> *** 846,852 ****
>  */
>  #ifdef ENABLE_NLS
>  if (encoding == PG_UTF8)
> ! if (bind_textdomain_codeset("postgres", "UTF-8") == NULL)
>  elog(LOG, "bind_textdomain_codeset failed");
>  #endif
>  }
> --- 848,860 ----
>  */
>  #ifdef ENABLE_NLS
>  if (encoding == PG_UTF8)
> ! target_codeset = "UTF-8";
> ! #ifdef WIN32
> ! else if (encoding == PG_EUC_JP)
> ! target_codeset = "EUC_JP";
> ! #endif /* WIN32 */
> ! if (NULL != target_codeset)
> ! if (bind_textdomain_codeset("postgres", target_codeset) == NULL)
>  elog(LOG, "bind_textdomain_codeset failed");
>  #endif
>  }
>


--------------------------------------------------------------------------------


>
> --
> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-committers
>


Re: pgsql: Explicitly bind gettext() to the UTF8 locale when in use.

From
Bruce Momjian
Date:
Is this patch still needed?

---------------------------------------------------------------------------

Hiroshi Inoue wrote:
> Hi Magnus and all,
>
> Magnus Hagander wrote:
> > Log Message:
> > -----------
> > Explicitly bind gettext() to the  UTF8 locale when in use.
> > This is required on Windows due to the special locale
> > handling for UTF8 that doesn't change the full environment.
>
> Thanks to this change UTF-8 case was solved but Japanese users
> are still unhappy with Windows databases with EUC_JP encoding.
> Shift_JIS which is a Japanese encoding under Windows doesn't
> match any server encoding and causes a crash with the use of
> gettext. So Saito-san removed ja message catalog just before
> the 8.3 release.
>
> Attached is a simple patch to avoid the crash and enable the
> use of Japanese message catalog.
> Please apply the patch if there's no problem.
>
> regards,
> Hiroshi Inoue
>
> > Fixes crash with translated error messages per bugs 4180
> > and 4196.
> >
> > Tom Lane
> >
> > Modified Files:
> > --------------
> >     pgsql/src/backend/utils/mb:
> >         mbutils.c (r1.70 -> r1.71)
> >         (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/mb/mbutils.c?r1=1.70&r2=1.71)
>
>

> *** mbutils.c.orig    Sun Nov 23 08:42:57 2008
> --- mbutils.c    Sun Nov 23 13:52:41 2008
> ***************
> *** 825,830 ****
> --- 825,832 ----
>   void
>   SetDatabaseEncoding(int encoding)
>   {
> +     const char *target_codeset = NULL;
> +
>       if (!PG_VALID_BE_ENCODING(encoding))
>           elog(ERROR, "invalid database encoding: %d", encoding);
>
> ***************
> *** 846,852 ****
>        */
>   #ifdef ENABLE_NLS
>       if (encoding == PG_UTF8)
> !         if (bind_textdomain_codeset("postgres", "UTF-8") == NULL)
>               elog(LOG, "bind_textdomain_codeset failed");
>   #endif
>   }
> --- 848,860 ----
>        */
>   #ifdef ENABLE_NLS
>       if (encoding == PG_UTF8)
> !         target_codeset = "UTF-8";
> ! #ifdef    WIN32
> !     else if (encoding == PG_EUC_JP)
> !         target_codeset = "EUC_JP";
> ! #endif /* WIN32 */
> !     if (NULL != target_codeset)
> !         if (bind_textdomain_codeset("postgres", target_codeset) == NULL)
>               elog(LOG, "bind_textdomain_codeset failed");
>   #endif
>   }
>
>
> --
> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-committers

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: pgsql: Explicitly bind gettext() to the UTF8 locale when in use.

From
Tom Lane
Date:
Bruce Momjian <bruce@momjian.us> writes:
> Is this patch still needed?

No; this is the beginning of the still-continuing thread about
lc_messages and Windows.  I'm not sure what we'll end up applying,
but not this.

            regards, tom lane