Re: lc_collate issue - Mailing list pgsql-general

From db@zigo.dhs.org
Subject Re: lc_collate issue
Date
Msg-id 1594.192.121.104.119.1188465343.squirrel@www.zigo.org
Whole thread Raw
In response to Re: lc_collate issue  (Cody Pisto <cpisto@rvweb.com>)
List pgsql-general
> I'm just looking for the correct workaround.

While adding a new collation is the "correct" solution it's a lot of work.
Even then pg can't use different collations anyway unless you reinit
the datadir using initdb.

One workaround is to cast the text value into a bytea value, and then it
will be sorted in byte order no matter what locale you have. Like this:

  SELECT *
    FROM foo
ORDER BY CAST (some_column AS BYTEA);

This work except that there is no cast from text to bytea. But we can add
one using:

  CREATE CAST (text AS bytea) WITHOUT FUNCTION AS ASSIGNMENT;

I can't promise that WITHOUT FUNCTION will always work but currently bytea
and text values are stored in the same way so it should work (and it
probably will in future versions as well).

/Dennis



pgsql-general by date:

Previous
From: Denis Gasparin
Date:
Subject: Autovacuum not vacuuming pg_largeobject
Next
From: rafikoko
Date:
Subject: Re: pg_dump.... pg_restore...how long does it take?