Client-side merge & string sorting - Mailing list pgsql-hackers

From Daniele Orlandi
Subject Client-side merge & string sorting
Date
Msg-id 3DA724CF.80201@orlandi.com
Whole thread Raw
List pgsql-hackers
Hello,

I sometimes need to perform client-side merges, sometimes between two 
tables on the same database, sometimes between two different databases.

When the merge key is numeric all goes well but, when the merge key is a 
string a problem arises: string comparison operators often behave 
differently between the database(s) and the client's language.

Sometimes it is due to the locale settings, sometimes is the particular 
implementation of the operator, as a matter of facts, I cannot trust the 
strings comparison operators.

Si, the question is how client-side merge should be done...

- Perform the sorting locally... only one operator... maybe suboptimal 
sorting... etc....

- Compare the strings hex-encoded: overhead apart, I found myself unable 
to use encode(..) function on PostgreSQL since it accepts only BYTEA 
data and text isn't castable to bytea.

- Invent a new operator whose behaviour would be always consistent, 
locale-indepentent... (like the very-first C's strcmp).

Which do you think should be the correct approach ?

Thanks in advance!
Best regards!

--  Daniele Orlandi Planet Srl



pgsql-hackers by date:

Previous
From:
Date:
Subject: Re: Peer to peer replication of Postgresql databases
Next
From: Jeff Davis
Date:
Subject: Re: MySQL vs PostgreSQL.