Re: full-text indexing, locales, triggers, SPI & more fun - Mailing list pgsql-hackers

From Karel Zak
Subject Re: full-text indexing, locales, triggers, SPI & more fun
Date
Msg-id Pine.LNX.3.96.1000602115251.17301A-100000@ara.zf.jcu.cz
Whole thread Raw
In response to full-text indexing, locales, triggers, SPI & more fun  (Charlie Hornberger <charlie@pressflex.com>)
List pgsql-hackers
On Wed, 31 May 2000, Charlie Hornberger wrote:

> I want to aggregate text in multiple languages in a single full-text index
> much like the current structure used by the current fti() function. In order
> to correctly parse the strings, however, I've got to know what locale
> they're written in/for (otherwise, isalpha() thinks that characters such as
> the Hungarian letter u" -- that's a 'u' with a double acute accent -- aren't
> very alphabetic.)
> 
> My initial thinking (which could certainly be very wrong) is that the
> easiest way to get around this would be to allow client apps to set their
> LC_ALL environment variables, and then to have the new fti() function use
> that locale while doing string manipulation.
> 
> But the way I'm doing things, it doesn't appear that the LC_ALL environment
> variable is available.  (Maybe it was never meant to be ... but I'm not a 
> very skilled C programmer, and I don't know the first thing about the SPI 
> interface, so please forgive me if I'm asking why the sun doesn't rise in 
> the west more often ;-)).

The PostgreSQL set in main() next locale catg. (if you compile it with locale
support)

#ifdef USE_LOCALE       setlocale(LC_CTYPE, "");               setlocale(LC_COLLATE, "");       setlocale(LC_MONETARY,
"");
#endif
If you need in your routines ctype.h's functions a solution is a set LANG
env. :# LANG=Czech        (for me)# start_postmaster
It works very well, and you not need any other setting. 
IMHO use setlocale(LC_ALL, ..) is a very strong hard to backend, because
a example all float data will crashed.
If you (still:-) need all locales see pg_locale.c in pg's sources in
utils/atd and usage of these routines in formatting.c (to_char()) which use 
full locale for numbers. 

But don't remember - you must always return all to state before LC_ALL.                  Karel



pgsql-hackers by date:

Previous
From: Kovacs Zoltan
Date:
Subject: Re: announcing pgbrowse
Next
From: Keith Parks
Date:
Subject: Re: Problems with recent CVS versions and Solaris.