Hi all, I'm new to the list, so don't flame at the first date ;).
I usually use PostgreSQL for multiple languages, so I needed to set locale per connection, or can change the locale on the fly. I don't know if there is any such ability integrated in or not, so I have wrote my 10lines function as a wrapper around setlocale, that is attached. So what I do is just a simple "SELECT locale('LC_COLLATE', 'fa_IR');" at connection time. Let me know if there is any standard way already implemented. Another silly question, isn't any way to get rid of seqscan, when doing 'SELECT count(*) FROM tab;'? Yours, behdad -- Behdad Esfahbod 11 Tir 1382, 2003 Jul 2 http://behdad.org/ [Finger for Geek Code] If you do a job too well, you'll get stuck with it.
#include <pgsql/postgres.h> #include <locale.h> bool pgbe_setlocale (void *cat, void *loc) { int category; void *catstr; if (!loc) return false; if (cat) catstr = VARDATA (cat); else catstr = "LC_ALL"; /* default to LC_ALL */ #define CHECKCATEGORY(s, i) if (!strcmp (s, catstr)) category = i; /* *INDENT-OFF* */ CHECKCATEGORY ("LC_ALL", LC_ALL) else CHECKCATEGORY ("LC_COLLATE", LC_COLLATE) else CHECKCATEGORY ("LC_CTYPE", LC_CTYPE) else CHECKCATEGORY ("LC_MESSAGES", LC_MESSAGES) else CHECKCATEGORY ("LC_MONETARY", LC_MONETARY) else CHECKCATEGORY ("LC_NUMERIC", LC_NUMERIC) else CHECKCATEGORY ("LC_TIME", LC_TIME) else return false; /* *INDENT-ON* */ #undef CHECKCATEGORY return setlocale (category, VARDATA (loc)) ? true : false; }
---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend