Re: lc_collate issue

From: db(at)zigo(dot)dhs(dot)org
To: "Cody Pisto" <cpisto(at)rvweb(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: lc_collate issue
Date: 2007-08-30 09:15:43
Message-ID: 1594.192.121.104.119.1188465343.squirrel@www.zigo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message rafikoko 2007-08-30 10:03:43 Re: pg_dump.... pg_restore...how long does it take?
Previous Message Denis Gasparin 2007-08-30 09:11:56 Autovacuum not vacuuming pg_largeobject