Re: pg_trgm

Tatsuo Ishii <ishii@postgresql.org>

From: Tatsuo Ishii <ishii@postgresql.org>
To: tgl@sss.pgh.pa.us
Cc: ishii@sraoss.co.jp, ishii@postgresql.org, andres@anarazel.de, pgsql-hackers@postgresql.org, teodor@sigaev.ru
Date: 2010-05-27T14:39:07Z
Lists: pgsql-hackers
> Well, that doesn't mean that the answer is to use C locale ;-)

Of course it's up to user whether to use C locale or not. I just want
pg_trgm work with C locale as well.

> However, you could possibly think about making this bit of code
> more flexible:
> 
> #ifdef KEEPONLYALNUM
> #define iswordchr(c)	(t_isalpha(c) || t_isdigit(c))
> #else
> #define iswordchr(c)	(!t_isspace(c))
> #endif
> 
> Currently it seems to be hard-wired to the first case in standard
> builds.

Yup. Here is the patch in my mind:

*** trgm_op.c~	2009-06-11 23:48:51.000000000 +0900
--- trgm_op.c	2010-05-27 23:38:20.000000000 +0900
***************
*** 59,65 ****
  }
  
  #ifdef KEEPONLYALNUM
! #define iswordchr(c)	(t_isalpha(c) || t_isdigit(c))
  #else
  #define iswordchr(c)	(!t_isspace(c))
  #endif
--- 59,65 ----
  }
  
  #ifdef KEEPONLYALNUM
! #define iswordchr(c)	(t_isalpha(c) || t_isdigit(c) || (lc_ctype_is_c() && !t_isspace(c)))
  #else
  #define iswordchr(c)	(!t_isspace(c))
  #endif