Re: pg_trgm

Tatsuo Ishii <ishii@postgresql.org>

From: Tatsuo Ishii <ishii@postgresql.org>
To: ishii@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter_e@gmx.net, ishii@sraoss.co.jp, andres@anarazel.de, pgsql-hackers@postgresql.org, teodor@sigaev.ru
Date: 2010-05-29T08:13:28Z
Lists: pgsql-hackers
> > It's not a practical solution for people working with prebuilt Postgres
> > versions, which is most people.  I don't object to finding a way to
> > provide a "not-space" behavior instead of an "is-alnum" behavior,
> > but as noted upthread a GUC isn't the right way.  How do you feel
> > about a new set of functions with an additional flag argument of
> > some sort?
> 
> Let me see how many functions we need to create...

After thinking a little bit more, I think following patch would not
break existing behavior and also adopts mutibyte + C locale case. What
do you think?

*** trgm_op.c~	2009-06-11 23:48:51.000000000 +0900
--- trgm_op.c	2010-05-29 17:07:28.000000000 +0900
***************
*** 59,65 ****
  }
  
  #ifdef KEEPONLYALNUM
! #define iswordchr(c)	(t_isalpha(c) || t_isdigit(c))
  #else
  #define iswordchr(c)	(!t_isspace(c))
  #endif
--- 59,67 ----
  }
  
  #ifdef KEEPONLYALNUM
! #define iswordchr(c)	(lc_ctype_is_c()? \
! 								((*(c) & 0x80)? !t_isspace(c) : (t_isalpha(c) || t_isdigit(c))) : \
! 								(t_isalpha(c) || t_isdigit(c)))
  #else
  #define iswordchr(c)	(!t_isspace(c))
  #endif