Commit c3b5d2f1 authored by Alvaro Herrera's avatar Alvaro Herrera

On Windows, call bind_textdomain_codeset on domains other than the default one,

too, so that the codeset is properly mapped on the newly added PL domains.
parent 387efd36
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.172 2009/01/05 13:57:12 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.173 2009/03/08 16:07:12 alvherre Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#endif #endif
#include "catalog/pg_authid.h" #include "catalog/pg_authid.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "postmaster/autovacuum.h" #include "postmaster/autovacuum.h"
#include "storage/fd.h" #include "storage/fd.h"
...@@ -1241,6 +1242,7 @@ pg_bindtextdomain(const char *domain) ...@@ -1241,6 +1242,7 @@ pg_bindtextdomain(const char *domain)
get_locale_path(my_exec_path, locale_path); get_locale_path(my_exec_path, locale_path);
bindtextdomain(domain, locale_path); bindtextdomain(domain, locale_path);
pg_bind_textdomain_codeset(domain, GetDatabaseEncoding());
} }
#endif #endif
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* (currently mule internal code (mic) is used) * (currently mule internal code (mic) is used)
* Tatsuo Ishii * Tatsuo Ishii
* *
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.79 2009/03/02 15:10:09 teodor Exp $ * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.80 2009/03/08 16:07:12 alvherre Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -891,24 +891,29 @@ SetDatabaseEncoding(int encoding) ...@@ -891,24 +891,29 @@ SetDatabaseEncoding(int encoding)
DatabaseEncoding = &pg_enc2name_tbl[encoding]; DatabaseEncoding = &pg_enc2name_tbl[encoding];
Assert(DatabaseEncoding->encoding == encoding); Assert(DatabaseEncoding->encoding == encoding);
/* pg_bind_textdomain_codeset(textdomain(NULL), encoding);
}
/*
* On Windows, we need to explicitly bind gettext to the correct * On Windows, we need to explicitly bind gettext to the correct
* encoding, because gettext() tends to get confused. * encoding, because gettext() tends to get confused.
*/ */
void
pg_bind_textdomain_codeset(const char *domainname, int encoding)
{
#if defined(ENABLE_NLS) && defined(WIN32) #if defined(ENABLE_NLS) && defined(WIN32)
{
int i; int i;
for (i = 0; i < sizeof(codeset_map_array) / sizeof(codeset_map_array[0]); i++) for (i = 0; i < lengthof(codeset_map_array); i++)
{ {
if (codeset_map_array[i].encoding == encoding) if (codeset_map_array[i].encoding == encoding)
{ {
if (bind_textdomain_codeset(textdomain(NULL), codeset_map_array[i].codeset) == NULL) if (bind_textdomain_codeset(domainname,
codeset_map_array[i].codeset) == NULL)
elog(LOG, "bind_textdomain_codeset failed"); elog(LOG, "bind_textdomain_codeset failed");
break; break;
} }
} }
}
#endif #endif
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.84 2009/02/10 19:29:39 petere Exp $ * $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.85 2009/03/08 16:07:12 alvherre Exp $
* *
* NOTES * NOTES
* This is used both by the backend and by libpq, but should not be * This is used both by the backend and by libpq, but should not be
...@@ -392,6 +392,7 @@ extern const char *pg_get_client_encoding_name(void); ...@@ -392,6 +392,7 @@ extern const char *pg_get_client_encoding_name(void);
extern void SetDatabaseEncoding(int encoding); extern void SetDatabaseEncoding(int encoding);
extern int GetDatabaseEncoding(void); extern int GetDatabaseEncoding(void);
extern const char *GetDatabaseEncodingName(void); extern const char *GetDatabaseEncodingName(void);
extern void pg_bind_textdomain_codeset(const char *domainname, int encoding);
extern int pg_valid_client_encoding(const char *name); extern int pg_valid_client_encoding(const char *name);
extern int pg_valid_server_encoding(const char *name); extern int pg_valid_server_encoding(const char *name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment