"WildWezyr" <wi.ld.we.zy.r@gmail.com> writes:
> If I eliminate polish national chars from function spb_getWord i.e. it will
> generate words with plain ascii chars there is no error and everything works
> fine.
What that sounds like is a locale/encoding conflict. Postgres depends
on strcoll() or local equivalent to produce consistent sort results,
and sometimes if strcoll is presented with data that it thinks is
invalidly encoded, it doesn't behave sanely.
What locale setting and database encoding are you using?
regards, tom lane