a contrib function to query current locale values - Mailing list pgsql-hackers

From Hannu Krosing
Subject a contrib function to query current locale values
Date
Msg-id 3A8089FA.28977A26@tm.ee
Whole thread Raw
Responses Re: a contrib function to query current locale values  (Karel Zak <zakkr@zf.jcu.cz>)
List pgsql-hackers
Hi,

I've written a small function that should go into contrib for 7.1

As locale issues are quite tricky, being able to find out what locale
backend thinks it is in is a good thing ;)

from my README.getlocale:

getlocale('category')
---------------------

return the locale setting of the backend
(see '> man setlocale for definitions)

If category is one of LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY,
LC_NUMERIC, LC_TIME the corresponding setting is returned.

[hannu@taru contrib]$ psql -c "select getlocale('LC_COLLATE')"
 getlocale
-----------
 en_US
(1 row)


for LC_ALL (and anything else) a string like the following is returned


[hannu@taru getlocale]$ psql -c "select getlocale('*')"
                                       getlocale
----------------------------------------------------------------------------------------

LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=C
(1 row)


IMHO some form of it should end up in the main distribution, probably by
7.2.

---------------------------------
Hannu Krosing <hannu@krosing.net>
Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: psql: why not pset PROMPT[0-2] ?
Next
From: Tom Lane
Date:
Subject: Re: OID from insert has extra letter