Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext()instead of gettext() so that it uses

2009-03-08 Thread Alvaro Herrera
Hiroshi Saito wrote:
 Hi Alvaro-san.

 Yeah, It seems that it saves also except pl. then, It also regards me as very 
 good.
 I tested just now, of course, it is very comfortable. :-)

Thanks, Hiroshi-san.  I just applied that last version.

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext() instead of gettext() so that it uses

2009-03-07 Thread Hiroshi Saito

Hi.

Ummm, I present is not understood by the reason of Japanese. ... 
Therefore, It was made into the Spanish case. 
I know that Alvaro-san will understand Spanish well. 


==postgresql.conf==
lc_messages= 'es' 

server.log of a patch before and after was applied. 
Please see it. 


Regards,
Hiroshi Saito

- Original Message - 
From: Hiroshi Saito z-sa...@guitar.ocn.ne.jp




Hi Peter-san.

I see the problem for being an original domain in plpgsql. It differs from what 
codeset meant at postmaster by Japanese windows
Please see, this look at the problem on which SJIS enters into a message. 
http://winpg.jp/~saito/pg_work/LC_MESSAGE_CHECK/plpgsql/before_plpgsql_server.log
This state is the following.  
==

lc_messages=ja
server_encoding=utf-8
==

Therefore,  it needs to be codeset called for an original domain. It is the 
procedure in which
only a server module must correspond. Then, It is solvable by this patch. 
http://winpg.jp/~saito/pg_work/LC_MESSAGE_CHECK/plpgsql/after_plpgsql_server.log


Please take this into consideration. 
Tahnks.


Regards,
Hiroshi Saito

- Original Message - 
From: Peter Eisentraut pete...@gmx.net




Alvaro Herrera wrote:

Peter Eisentraut wrote:

Log Message:
---
Redefine _() to dgettext() instead of gettext() so that it uses the plpgsql
text domain, instead of the postgres one (or whatever the default may be).


Hmm, so is this needed on all other PLs too?


In principle yes.  Or call dgettext() explicitly, which is also done in 
some cases.  However, in most cases messages are issued through 
ereport(), which handles this automatically (which you implemented, I 
recall).


plpgsql_es_before.log
Description: Binary data


plpgsql_es_after.log
Description: Binary data


plpgsql_test.sql
Description: Binary data

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext() instead of gettext() so that it uses

2009-03-07 Thread Alvaro Herrera
Hiroshi Saito wrote:
 Hi.

 Ummm, I present is not understood by the reason of Japanese. ...  
 Therefore, It was made into the Spanish case. I know that Alvaro-san will 
 understand Spanish well. 

 ==postgresql.conf==
 lc_messages= 'es' 

 server.log of a patch before and after was applied. Please see it. 

Understood.  In fact, after having a look at this patch and giving it a
little refactoring I think it's pretty obvious; right now we're calling
bind_textdomain_codeset only for the main domain, and with this patch we
also set it for all other domains we use.

Does this patch work for you?

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
Index: src/backend/utils/init/miscinit.c
===
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/init/miscinit.c,v
retrieving revision 1.172
diff -c -p -r1.172 miscinit.c
*** src/backend/utils/init/miscinit.c	5 Jan 2009 13:57:12 -	1.172
--- src/backend/utils/init/miscinit.c	7 Mar 2009 22:13:47 -
*** pg_bindtextdomain(const char *domain)
*** 1241,1246 
--- 1241,1248 
  
  		get_locale_path(my_exec_path, locale_path);
  		bindtextdomain(domain, locale_path);
+ 
+ 		SetDomainCodeSet(domain, GetDatabaseEncoding());
  	}
  #endif
  }
Index: src/backend/utils/mb/mbutils.c
===
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/mb/mbutils.c,v
retrieving revision 1.79
diff -c -p -r1.79 mbutils.c
*** src/backend/utils/mb/mbutils.c	2 Mar 2009 15:10:09 -	1.79
--- src/backend/utils/mb/mbutils.c	7 Mar 2009 22:13:47 -
*** SetDatabaseEncoding(int encoding)
*** 895,912 
  	 * On Windows, we need to explicitly bind gettext to the correct
  	 * encoding, because gettext() tends to get confused.
  	 */
  #if defined(ENABLE_NLS)  defined(WIN32)
! 	{
! 		int	i;
  
! 		for (i = 0; i  sizeof(codeset_map_array) / sizeof(codeset_map_array[0]); i++)
  		{
! 			if (codeset_map_array[i].encoding == encoding)
! 			{
! if (bind_textdomain_codeset(textdomain(NULL), codeset_map_array[i].codeset) == NULL)
! 	elog(LOG, bind_textdomain_codeset failed);
! break;
! 			}
  		}
  	}
  #endif
--- 895,916 
  	 * On Windows, we need to explicitly bind gettext to the correct
  	 * encoding, because gettext() tends to get confused.
  	 */
+ 	SetDomainCodeSet(textdomain(NULL), encoding);
+ }
+ 
+ void
+ SetDomainCodeSet(const char *domainname, int encoding)
+ {
  #if defined(ENABLE_NLS)  defined(WIN32)
! 	int i;
  
! 	for (i = 0; i  sizeof(codeset_map_array) / sizeof(codeset_map_array[0]); i++)
! 	{
! 		if (codeset_map_array[i].encoding == encoding)
  		{
! 			if (bind_textdomain_codeset(domainname, codeset_map_array[i].codeset) == NULL)
! elog(LOG, bind_textdomain_codeset failed);
! 			break;
  		}
  	}
  #endif
Index: src/include/mb/pg_wchar.h
===
RCS file: /home/alvherre/Code/cvs/pgsql/src/include/mb/pg_wchar.h,v
retrieving revision 1.84
diff -c -p -r1.84 pg_wchar.h
*** src/include/mb/pg_wchar.h	10 Feb 2009 19:29:39 -	1.84
--- src/include/mb/pg_wchar.h	7 Mar 2009 22:21:51 -
*** extern const char *pg_get_client_encodin
*** 392,397 
--- 392,398 
  extern void SetDatabaseEncoding(int encoding);
  extern int	GetDatabaseEncoding(void);
  extern const char *GetDatabaseEncodingName(void);
+ extern void SetDomainCodeSet(const char *domainname, int encoding);
  
  extern int	pg_valid_client_encoding(const char *name);
  extern int	pg_valid_server_encoding(const char *name);

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext() instead of gettext() so that it uses

2009-03-07 Thread Tom Lane
Alvaro Herrera alvhe...@commandprompt.com writes:
 Understood.  In fact, after having a look at this patch and giving it a
 little refactoring I think it's pretty obvious; right now we're calling
 bind_textdomain_codeset only for the main domain, and with this patch we
 also set it for all other domains we use.

 Does this patch work for you?

Seems like this comment needs to move into the new function:
* On Windows, we need to explicitly bind gettext to the correct
* encoding, because gettext() tends to get confused.

More generally, should we push the bindtextdomain calls themselves into
the new function (and perhaps call it something else than
SetDomainCodeSet)?  Seems like logically this should be thought of as
all one operation, ie, it's not clear to me that it ever makes sense to
call bindtextdomain without also worrying about encoding.

regards, tom lane

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext() instead of gettext() so that it uses

2009-03-07 Thread Alvaro Herrera
Tom Lane wrote:
 Alvaro Herrera alvhe...@commandprompt.com writes:
  Understood.  In fact, after having a look at this patch and giving it a
  little refactoring I think it's pretty obvious; right now we're calling
  bind_textdomain_codeset only for the main domain, and with this patch we
  also set it for all other domains we use.

 More generally, should we push the bindtextdomain calls themselves into
 the new function (and perhaps call it something else than
 SetDomainCodeSet)?  Seems like logically this should be thought of as
 all one operation, ie, it's not clear to me that it ever makes sense to
 call bindtextdomain without also worrying about encoding.

I'm not sure that can be made to work easily.  On the backend itself we
call bindtextdomain in set_pglocale_pgservice() which is also used by
programs in src/bin/.  Shuffling things in there would be more involved
than seems worth.

As for names, how about pg_bind_textdomain_codeset?

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
Index: src/backend/utils/init/miscinit.c
===
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/init/miscinit.c,v
retrieving revision 1.172
diff -c -p -r1.172 miscinit.c
*** src/backend/utils/init/miscinit.c	5 Jan 2009 13:57:12 -	1.172
--- src/backend/utils/init/miscinit.c	7 Mar 2009 23:39:00 -
***
*** 30,35 
--- 30,36 
  #endif
  
  #include catalog/pg_authid.h
+ #include mb/pg_wchar.h
  #include miscadmin.h
  #include postmaster/autovacuum.h
  #include storage/fd.h
*** pg_bindtextdomain(const char *domain)
*** 1241,1246 
--- 1242,1248 
  
  		get_locale_path(my_exec_path, locale_path);
  		bindtextdomain(domain, locale_path);
+ 		pg_bind_textdomain_codeset(domain, GetDatabaseEncoding());
  	}
  #endif
  }
Index: src/backend/utils/mb/mbutils.c
===
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/utils/mb/mbutils.c,v
retrieving revision 1.79
diff -c -p -r1.79 mbutils.c
*** src/backend/utils/mb/mbutils.c	2 Mar 2009 15:10:09 -	1.79
--- src/backend/utils/mb/mbutils.c	7 Mar 2009 23:37:22 -
*** SetDatabaseEncoding(int encoding)
*** 891,912 
  	DatabaseEncoding = pg_enc2name_tbl[encoding];
  	Assert(DatabaseEncoding-encoding == encoding);
  
! 	/*
! 	 * On Windows, we need to explicitly bind gettext to the correct
! 	 * encoding, because gettext() tends to get confused.
! 	 */
  #if defined(ENABLE_NLS)  defined(WIN32)
! 	{
! 		int	i;
  
! 		for (i = 0; i  sizeof(codeset_map_array) / sizeof(codeset_map_array[0]); i++)
  		{
! 			if (codeset_map_array[i].encoding == encoding)
! 			{
! if (bind_textdomain_codeset(textdomain(NULL), codeset_map_array[i].codeset) == NULL)
! 	elog(LOG, bind_textdomain_codeset failed);
! break;
! 			}
  		}
  	}
  #endif
--- 891,917 
  	DatabaseEncoding = pg_enc2name_tbl[encoding];
  	Assert(DatabaseEncoding-encoding == encoding);
  
! 	pg_bind_textdomain_codeset(textdomain(NULL), encoding);
! }
! 
! /*
!  * On Windows, we need to explicitly bind gettext to the correct
!  * encoding, because gettext() tends to get confused.
!  */
! void
! pg_bind_textdomain_codeset(const char *domainname, int encoding)
! {
  #if defined(ENABLE_NLS)  defined(WIN32)
! 	int i;
  
! 	for (i = 0; i  lengthof(codeset_map_array); i++)
! 	{
! 		if (codeset_map_array[i].encoding == encoding)
  		{
! 			if (bind_textdomain_codeset(domainname,
! 		codeset_map_array[i].codeset) == NULL)
! elog(LOG, bind_textdomain_codeset failed);
! 			break;
  		}
  	}
  #endif
Index: src/include/mb/pg_wchar.h
===
RCS file: /home/alvherre/Code/cvs/pgsql/src/include/mb/pg_wchar.h,v
retrieving revision 1.84
diff -c -p -r1.84 pg_wchar.h
*** src/include/mb/pg_wchar.h	10 Feb 2009 19:29:39 -	1.84
--- src/include/mb/pg_wchar.h	7 Mar 2009 23:37:42 -
*** extern const char *pg_get_client_encodin
*** 392,397 
--- 392,398 
  extern void SetDatabaseEncoding(int encoding);
  extern int	GetDatabaseEncoding(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_server_encoding(const char *name);

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext()instead of gettext() so that it uses

2009-03-07 Thread Hiroshi Saito

Hi Alvaro-san.

Yeah, It seems that it saves also except pl. then, It also regards me as very 
good.
I tested just now, of course, it is very comfortable. :-)

== try ==
C:\workpsql -e -f plpgsql_test.sql
show client_encoding;
client_encoding
-
latin1
(1 row)


show server_encoding;
server_encoding
-
UTF8
(1 row)


set lc_messages to es;
SET
show lc_messages;
lc_messages
-
es
(1 row)


create function func1() returns int as '
begin
select a;
end;
' language 'plpgsql';
psql:plpgsql_test.sql:10: ERROR:  un identificador entre comillas está 
inconcluso
CONTEXT:  compilation of PL/pgSQL function func1 near line 2

==/END

Thanks!

Regards,
Hiroshi Saito

- Original Message - 
From: Alvaro Herrera alvhe...@commandprompt.com




Tom Lane wrote:

Alvaro Herrera alvhe...@commandprompt.com writes:
 Understood.  In fact, after having a look at this patch and giving it a
 little refactoring I think it's pretty obvious; right now we're calling
 bind_textdomain_codeset only for the main domain, and with this patch we
 also set it for all other domains we use.



More generally, should we push the bindtextdomain calls themselves into
the new function (and perhaps call it something else than
SetDomainCodeSet)?  Seems like logically this should be thought of as
all one operation, ie, it's not clear to me that it ever makes sense to
call bindtextdomain without also worrying about encoding.


I'm not sure that can be made to work easily.  On the backend itself we
call bindtextdomain in set_pglocale_pgservice() which is also used by
programs in src/bin/.  Shuffling things in there would be more involved
than seems worth.

As for names, how about pg_bind_textdomain_codeset?

--
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.




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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext() instead of gettext() so that it uses

2009-03-02 Thread Hiroshi Saito

Hi Peter-san.

I see the problem for being an original domain in plpgsql. It differs from what 
codeset meant at postmaster by Japanese windows
Please see, this look at the problem on which SJIS enters into a message. 
http://winpg.jp/~saito/pg_work/LC_MESSAGE_CHECK/plpgsql/before_plpgsql_server.log
This state is the following.  
==

lc_messages=ja
server_encoding=utf-8
==

Therefore,  it needs to be codeset called for an original domain. It is the 
procedure in which
only a server module must correspond. Then, It is solvable by this patch. 
http://winpg.jp/~saito/pg_work/LC_MESSAGE_CHECK/plpgsql/after_plpgsql_server.log


Please take this into consideration. 
Tahnks.


Regards,
Hiroshi Saito

- Original Message - 
From: Peter Eisentraut pete...@gmx.net




Alvaro Herrera wrote:

Peter Eisentraut wrote:

Log Message:
---
Redefine _() to dgettext() instead of gettext() so that it uses the plpgsql
text domain, instead of the postgres one (or whatever the default may be).


Hmm, so is this needed on all other PLs too?


In principle yes.  Or call dgettext() explicitly, which is also done in 
some cases.  However, in most cases messages are issued through 
ereport(), which handles this automatically (which you implemented, I 
recall).

*** src/backend/utils/mb/mbutils.c.orig Sun Mar  1 01:46:59 2009
--- src/backend/utils/mb/mbutils.c  Sun Mar  1 01:46:48 2009
***
*** 883,888 
--- 883,905 
 #endif /* WIN32 */
 
 void

+ SetDomainCodeSet(const char *domainname)
+ {
+ #if defined(ENABLE_NLS)  defined(WIN32)
+   int i;
+   for (i = 0; i  sizeof(codeset_map_array) / 
sizeof(codeset_map_array[0]); i++)
+   {
+   if (codeset_map_array[i].encoding == GetDatabaseEncoding())
+   {
+   if (bind_textdomain_codeset(domainname, 
codeset_map_array[i].codeset) == NULL)
+   elog(LOG, bind_textdomain_codeset failed);
+   break;
+   }
+   }
+ #endif
+ }
+ 
+ void

 SetDatabaseEncoding(int encoding)
 {
if (!PG_VALID_BE_ENCODING(encoding))
*** src/include/mb/pg_wchar.h.orig  Sun Mar  1 01:49:00 2009
--- src/include/mb/pg_wchar.h   Sun Mar  1 01:49:48 2009
***
*** 389,394 
--- 389,395 
 extern int pg_get_client_encoding(void);
 extern const char *pg_get_client_encoding_name(void);
 
+ extern void SetDomainCodeSet(const char *domainname);

 extern void SetDatabaseEncoding(int encoding);
 extern int GetDatabaseEncoding(void);
 extern const char *GetDatabaseEncodingName(void);
*** src/pl/plpgsql/src/pl_handler.c.origSun Mar  1 01:55:34 2009
--- src/pl/plpgsql/src/pl_handler.c Sun Mar  1 01:57:58 2009
***
*** 22,27 
--- 22,28 
 #include utils/guc.h
 #include utils/lsyscache.h
 #include utils/syscache.h
+ #include mb/pg_wchar.h
 
 PG_MODULE_MAGIC;
 
***

*** 43,48 
--- 44,51 
return;
 
 	pg_bindtextdomain(TEXTDOMAIN);

+   /* domain codeset */
+   SetDomainCodeSet(TEXTDOMAIN);
 
 	plpgsql_HashTableInit();

RegisterXactCallback(plpgsql_xact_cb, NULL);

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


Re: [HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext() instead of gettext() so that it uses

2009-02-18 Thread Peter Eisentraut

Alvaro Herrera wrote:

Peter Eisentraut wrote:

Log Message:
---
Redefine _() to dgettext() instead of gettext() so that it uses the plpgsql
text domain, instead of the postgres one (or whatever the default may be).


Hmm, so is this needed on all other PLs too?


In principle yes.  Or call dgettext() explicitly, which is also done in 
some cases.  However, in most cases messages are issued through 
ereport(), which handles this automatically (which you implemented, I 
recall).


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


[HACKERS] Re: [COMMITTERS] pgsql: Redefine _() to dgettext() instead of gettext() so that it uses

2009-02-17 Thread Alvaro Herrera
Peter Eisentraut wrote:
 Log Message:
 ---
 Redefine _() to dgettext() instead of gettext() so that it uses the plpgsql
 text domain, instead of the postgres one (or whatever the default may be).

Hmm, so is this needed on all other PLs too?

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