Skip to content

Commit c3b5d2f

Browse files
committed
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.
1 parent 387efd3 commit c3b5d2f

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/backend/utils/init/miscinit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.172 2009/01/05 13:57:12 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.173 2009/03/08 16:07:12 alvherre Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -30,6 +30,7 @@
3030
#endif
3131

3232
#include "catalog/pg_authid.h"
33+
#include "mb/pg_wchar.h"
3334
#include "miscadmin.h"
3435
#include "postmaster/autovacuum.h"
3536
#include "storage/fd.h"
@@ -1241,6 +1242,7 @@ pg_bindtextdomain(const char *domain)
12411242

12421243
get_locale_path(my_exec_path, locale_path);
12431244
bindtextdomain(domain, locale_path);
1245+
pg_bind_textdomain_codeset(domain, GetDatabaseEncoding());
12441246
}
12451247
#endif
12461248
}

src/backend/utils/mb/mbutils.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* (currently mule internal code (mic) is used)
55
* Tatsuo Ishii
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.79 2009/03/02 15:10:09 teodor Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.80 2009/03/08 16:07:12 alvherre Exp $
88
*/
99
#include "postgres.h"
1010

@@ -891,22 +891,27 @@ SetDatabaseEncoding(int encoding)
891891
DatabaseEncoding = &pg_enc2name_tbl[encoding];
892892
Assert(DatabaseEncoding->encoding == encoding);
893893

894-
/*
895-
* On Windows, we need to explicitly bind gettext to the correct
896-
* encoding, because gettext() tends to get confused.
897-
*/
894+
pg_bind_textdomain_codeset(textdomain(NULL), encoding);
895+
}
896+
897+
/*
898+
* On Windows, we need to explicitly bind gettext to the correct
899+
* encoding, because gettext() tends to get confused.
900+
*/
901+
void
902+
pg_bind_textdomain_codeset(const char *domainname, int encoding)
903+
{
898904
#if defined(ENABLE_NLS) && defined(WIN32)
899-
{
900-
int i;
905+
int i;
901906

902-
for (i = 0; i < sizeof(codeset_map_array) / sizeof(codeset_map_array[0]); i++)
907+
for (i = 0; i < lengthof(codeset_map_array); i++)
908+
{
909+
if (codeset_map_array[i].encoding == encoding)
903910
{
904-
if (codeset_map_array[i].encoding == encoding)
905-
{
906-
if (bind_textdomain_codeset(textdomain(NULL), codeset_map_array[i].codeset) == NULL)
907-
elog(LOG, "bind_textdomain_codeset failed");
908-
break;
909-
}
911+
if (bind_textdomain_codeset(domainname,
912+
codeset_map_array[i].codeset) == NULL)
913+
elog(LOG, "bind_textdomain_codeset failed");
914+
break;
910915
}
911916
}
912917
#endif

src/include/mb/pg_wchar.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.84 2009/02/10 19:29:39 petere Exp $
9+
* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.85 2009/03/08 16:07:12 alvherre Exp $
1010
*
1111
* NOTES
1212
* 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);
392392
extern void SetDatabaseEncoding(int encoding);
393393
extern int GetDatabaseEncoding(void);
394394
extern const char *GetDatabaseEncodingName(void);
395+
extern void pg_bind_textdomain_codeset(const char *domainname, int encoding);
395396

396397
extern int pg_valid_client_encoding(const char *name);
397398
extern int pg_valid_server_encoding(const char *name);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy