[postgresql] postgresql.init script and localization problem
Jérôme Augé
jerome.auge at cesamnet.fr
Mon Oct 30 16:14:05 CET 2006
Hi,
I noticed that the postgresql init script was unable restart postgres,
telling me that postmaster died or that the service is not running.
The problem is in the pgstatus function and the output from pg_ctl which
seems to be locale dependent. This prevent the init script from finding
de postmaster PID correctly.
My system uses the fr_FR locale, and the output from pg_ctl contains an
extra space before the colon character:
/^pg_ctl :.*PID : \([0-9]\+\).*/
instead of:
/^pg_ctl:.*PID: \([0-9]\+\).*/
I fixed it by forcing LANG=C when calling pg_ctl:
--- /etc/rc.d/init.d/postgresql.orig 2006-10-30 15:44:17.000000000 +0100
+++ /etc/rc.d/init.d/postgresql 2006-10-30 15:44:35.000000000 +0100
@@ -71,7 +71,7 @@
pgstatus() {
PG_STATUS="unknown"
PG_PID="unknown"
- output=`TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -D $1 status"`
+ output=`LANG=C TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -D $1 status"`
status=`echo $?`
if [ $status -eq 1 ]; then
That way, the output from pg_ctl should be the same, whatever the system
locale is.
Regards,
Jérôme Augé
More information about the pld-devel-en
mailing list