From nobody@FreeBSD.org  Tue Jan 31 09:06:12 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1AB0916A420
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 31 Jan 2006 09:06:12 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id C858C43D7F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 31 Jan 2006 09:06:11 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k0V96Bwq037254
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 31 Jan 2006 09:06:11 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k0V96BrS037253;
	Tue, 31 Jan 2006 09:06:11 GMT
	(envelope-from nobody)
Message-Id: <200601310906.k0V96BrS037253@www.freebsd.org>
Date: Tue, 31 Jan 2006 09:06:11 GMT
From: Victor Snezhko <snezhko@indorsoft.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] postgresql81-server startup script can't set default database encoding in initdb
X-Send-Pr-Version: www-2.3

>Number:         92594
>Category:       ports
>Synopsis:       [patch] postgresql81-server startup script can't set default database encoding in initdb
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    girgen
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 31 09:10:02 GMT 2006
>Closed-Date:    Fri Feb 17 20:04:34 GMT 2006
>Last-Modified:  Fri Feb 17 20:04:34 GMT 2006
>Originator:     Victor Snezhko
>Release:        6.0-RELEASE
>Organization:
IndorSoft Ltd.
>Environment:
FreeBSD  6.0-RELEASE-p4 FreeBSD 6.0-RELEASE-p4 #2: Sat Jan 28 10:06:27 NOVT 2006     root@:/usr/obj/usr/src/sys/VVS  i386
       
>Description:
There is no clean way to supply -E (default database encoding) option to initdb.
For now it's only possible to modify a startup script.
>How-To-Repeat:
install postgresql81-server     
>Fix:
I suggest adding an option 'postgresql_initdb_encoding'.

Here is the patch against postgresql81-server:

--- 010.pgsql.sh.orig   Tue Jan 31 21:02:49 2006
+++ 010.pgsql.sh        Tue Jan 31 21:22:55 2006
@@ -12,6 +12,7 @@
 #  # optional
 #  postgresql_data="/usr/local/pgsql/data"
 #  postgresql_flags="-w -s -m fast"
+#  postgresql_initdb_encoding="UTF8"
 #
 # This scripts takes one of the following commands:
 #
@@ -28,6 +29,7 @@
 # set defaults
 postgresql_enable=${postgresql_enable:-"NO"}
 postgresql_flags=${postgresql_flags:-"-w -s -m fast"}
+postgresql_initdb_encoding=${postgresql_initdb_encoding:-"SQL_ASCII"}
 postgresql_user=pgsql
 eval postgresql_data=${postgresql_data:-"~${postgresql_user}/data"}
 postgresql_class=${postgresql_class:-"default"}
@@ -53,7 +55,7 @@

 postgresql_initdb()
 {
-    su -l -c ${postgresql_class} ${postgresql_user} -c "exec ${prefix}/bin/initdb -D ${postgresql_data}"
+    su -l -c ${postgresql_class} ${postgresql_user} -c "exec ${prefix}/bin/initdb -D ${postgresql_data} -E ${postgresql_initdb_encoding}"
 }

 run_rc_command "$1"

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->girgen 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Jan 31 10:42:30 UTC 2006 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92594 
State-Changed-From-To: open->feedback 
State-Changed-By: girgen 
State-Changed-When: Tue Jan 31 11:05:14 UTC 2006 
State-Changed-Why:  
The postgresql_class was added for the same reason. 
Adding a login class to /etc/login.conf: 

unicode: 
:setenv=LC_ALL=sv_SE.UTF-8: 
:tc=default: 

and setting postgresql_class="unicode" will give the same 
result and is more flexible. Perhaps it would be enough to  
document this feature better, instead of adding yet another 
knob? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92594 

From: Victor Snezhko <snezhko@indorsoft.ru>
To: Palle Girgensohn <girgen@FreeBSD.org>
Cc: bug-followup@freebsd.org
Subject: Re: ports/92594: [patch] postgresql81-server startup script can't
 set default database encoding in initdb
Date: Tue, 07 Feb 2006 02:19:08 +0600

 Victor Snezhko <snezhko@indorsoft.ru> writes:
 
 >> and setting postgresql_class="unicode" will give the same
 >> result and is more flexible. Perhaps it would be enough to 
 >> document this feature better, instead of adding yet another
 >> knob?
 >
 > Yes, login class solution will be enough for me, thanks.
 > It would be nice to document it right in the script comment.
 
 Hmm, another (real) scenario came to my mind. Now I need to store
 database data in UTF-8 and grant a right to administer my database
 server from a windows box via pgAdmin. I could set a locale (BTW, it
 seems simplier to me to do it not via login class but via
 ~pgsql/.profile, but YMMV) to ru_RU.UTF-8, but pgAdmin will not
 understand localized messages in utf-8. So I have to set utf-8 locale,
 run initdb and then change it to the ru_RU.CP1251, which is not cool.
 
 You can safely ignore this rant and close the PR, but I think this
 option would be convenient in such situations.
 
 -- 
 WBR, Victor V. Snezhko
 EMail: snezhko@indorsoft.ru
 
 

From: Palle Girgensohn <girgen@FreeBSD.org>
To: Victor Snezhko <snezhko@indorsoft.ru>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92594: [patch] postgresql81-server startup script can't
 set default database encoding in initdb
Date: Tue, 07 Feb 2006 11:02:13 +0100

 --On tisdag, februari 07, 2006 02.19.08 +0600 Victor Snezhko 
 <snezhko@indorsoft.ru> wrote:
 
 > Victor Snezhko <snezhko@indorsoft.ru> writes:
 >
 >>> and setting postgresql_class="unicode" will give the same
 >>> result and is more flexible. Perhaps it would be enough to
 >>> document this feature better, instead of adding yet another
 >>> knob?
 >>
 >> Yes, login class solution will be enough for me, thanks.
 >> It would be nice to document it right in the script comment.
 >
 > Hmm, another (real) scenario came to my mind. Now I need to store
 > database data in UTF-8 and grant a right to administer my database
 > server from a windows box via pgAdmin. I could set a locale (BTW, it
 > seems simplier to me to do it not via login class but via
 > ~pgsql/.profile, but YMMV) to ru_RU.UTF-8, but pgAdmin will not
 > understand localized messages in utf-8. So I have to set utf-8 locale,
 > run initdb and then change it to the ru_RU.CP1251, which is not cool.
 
 Does pgAdmin interpret the messages from postgresql. Then, perhaps it will 
 work if you build postgresql without gettext (i.e. uncheck "Use 
 internationalized messages"). Then you would get messages in English. Or 
 does pgAdmin just show them uncorrectly due to utf-8? Then pgAdmin is 
 either broken or you have a bad locale when running it - did you try to set 
 the client encoding? Perhaps you could make pgAdmin run "set client 
 encoding" after connecting?
 
 
 > You can safely ignore this rant and close the PR, but I think this
 > option would be convenient in such situations.
 
 It is still a workaround to pgAdmin not supporting utf-8, right? I'd rather 
 see pgAdmin fixed :)
 
 /Palle
 

From: Victor Snezhko <snezhko@indorsoft.ru>
To: Palle Girgensohn <girgen@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92594: [patch] postgresql81-server startup script can't
 set default database encoding in initdb
Date: Tue, 07 Feb 2006 16:25:46 +0600

 Palle Girgensohn <girgen@FreeBSD.org> writes:
 
 >> Hmm, another (real) scenario came to my mind. Now I need to store
 >> database data in UTF-8 and grant a right to administer my database
 >> server from a windows box via pgAdmin. I could set a locale (BTW, it
 >> seems simplier to me to do it not via login class but via
 >> ~pgsql/.profile, but YMMV) to ru_RU.UTF-8, but pgAdmin will not
 >> understand localized messages in utf-8. So I have to set utf-8 locale,
 >> run initdb and then change it to the ru_RU.CP1251, which is not cool.
 >
 > Does pgAdmin interpret the messages from postgresql. Then, perhaps it
 > will work if you build postgresql without gettext (i.e. uncheck "Use
 > internationalized messages"). Then you would get messages in
 > English. Or does pgAdmin just show them uncorrectly due to utf-8? Then
 > pgAdmin is either broken or you have a bad locale when running it -
 > did you try to set the client encoding? Perhaps you could make pgAdmin
 > run "set client encoding" after connecting?
 
 The problem is with windows, it doesn't work in utf-8. I will
 workaround this issue with two locales - first at initdb, second at
 regular postgresql startup, or en_US.UTF-8.
 
 >> You can safely ignore this rant and close the PR, but I think this
 >> option would be convenient in such situations.
 >
 > It is still a workaround to pgAdmin not supporting utf-8, right? I'd
 > rather see pgAdmin fixed :)
 
 OK, agreed.
 
 -- 
 WBR, Victor V. Snezhko
 EMail: snezhko@indorsoft.ru
 
 

From: Palle Girgensohn <girgen@FreeBSD.org>
To: Victor Snezhko <snezhko@indorsoft.ru>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92594: [patch] postgresql81-server startup script can't
 set default database encoding in initdb
Date: Tue, 07 Feb 2006 11:30:59 +0100

 --On tisdag, februari 07, 2006 16.25.46 +0600 Victor Snezhko 
 <snezhko@indorsoft.ru> wrote:
 
 > Palle Girgensohn <girgen@FreeBSD.org> writes:
 >
 >>> Hmm, another (real) scenario came to my mind. Now I need to store
 >>> database data in UTF-8 and grant a right to administer my database
 >>> server from a windows box via pgAdmin. I could set a locale (BTW, it
 >>> seems simplier to me to do it not via login class but via
 >>> ~pgsql/.profile, but YMMV) to ru_RU.UTF-8, but pgAdmin will not
 >>> understand localized messages in utf-8. So I have to set utf-8 locale,
 >>> run initdb and then change it to the ru_RU.CP1251, which is not cool.
 >>
 >> Does pgAdmin interpret the messages from postgresql. Then, perhaps it
 >> will work if you build postgresql without gettext (i.e. uncheck "Use
 >> internationalized messages"). Then you would get messages in
 >> English. Or does pgAdmin just show them uncorrectly due to utf-8? Then
 >> pgAdmin is either broken or you have a bad locale when running it -
 >> did you try to set the client encoding? Perhaps you could make pgAdmin
 >> run "set client encoding" after connecting?
 >
 > The problem is with windows, it doesn't work in utf-8. I will
 > workaround this issue with two locales - first at initdb, second at
 > regular postgresql startup, or en_US.UTF-8.
 
 The proper way would still be to set client encoding somehow..
 
 Check man page for postmaster(1):
 
 ENVIRONMENT
        PGCLIENTENCODING
               Default character encoding used by  clients.  (The  clients 
 may
               override  this  individually.) This value can also be set in 
 the
               configuration file.
 
 Regards,
 Palle
 

From: Victor Snezhko <snezhko@indorsoft.ru>
To: Palle Girgensohn <girgen@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/92594: [patch] postgresql81-server startup script can't
 set default database encoding in initdb
Date: Tue, 07 Feb 2006 16:34:01 +0600

 Palle Girgensohn <girgen@FreeBSD.org> writes:
 
 >> The problem is with windows, it doesn't work in utf-8. I will
 >> workaround this issue with two locales - first at initdb, second at
 >> regular postgresql startup, or en_US.UTF-8.
 >
 > The proper way would still be to set client encoding somehow..
 >
 > Check man page for postmaster(1):
 >
 > ENVIRONMENT
 >        PGCLIENTENCODING
 >               Default character encoding used by  clients.  (The
 > clients may
 >               override  this  individually.) This value can also be
 > set in the
 >               configuration file.
 
 Aha, thanks.
 
 -- 
 WBR, Victor V. Snezhko
 EMail: snezhko@indorsoft.ru
 
 
State-Changed-From-To: feedback->closed 
State-Changed-By: girgen 
State-Changed-When: Fri Feb 17 20:03:58 UTC 2006 
State-Changed-Why:  
Setting PGCLIENTENCODING seems to a good enough solution. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92594 
>Unformatted:
