Re: [GENERAL] Order-independent multi-field uniqueness constraint?

2007-10-20 Thread Kynn Jones
On 10/19/07, Gregory Stark <[EMAIL PROTECTED]> wrote: > "Kynn Jones" <[EMAIL PROTECTED]> writes: > > > CREATE OR REPLACE FUNCTION canonicalize( anyelement, anyelement ) > > RETURNS anyarray AS > > $$ > > BEGIN > > IF $1 < $2 THEN RETURN ARRAY[ $1, $2 ]; > > ELSERETURN ARRAY[ $2, $

Re: [GENERAL] Order-independent multi-field uniqueness constraint?

2007-10-19 Thread Gregory Stark
"Kynn Jones" <[EMAIL PROTECTED]> writes: > CREATE OR REPLACE FUNCTION canonicalize( anyelement, anyelement ) > RETURNS anyarray AS > $$ > BEGIN > IF $1 < $2 THEN RETURN ARRAY[ $1, $2 ]; > ELSERETURN ARRAY[ $2, $1 ]; > END IF; > END; > $$ LANGUAGE plpgsql; You need to add IMMUT

Re: [GENERAL] Order-independent multi-field uniqueness constraint?

2007-10-19 Thread brian
Kynn Jones wrote: I have a table used to store information about pairs of items. This information is independent of the order of the two items in the pair, so having two records X Y Y X in the table would be redundant. But as far as I can tell, this situation would n

[GENERAL] Order-independent multi-field uniqueness constraint?

2007-10-19 Thread Kynn Jones
I have a table used to store information about pairs of items. This information is independent of the order of the two items in the pair, so having two records X Y Y X in the table would be redundant. But as far as I can tell, this situation would not violate a uniquen