From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Antal Attila" <antal(dot)attila(at)ritek(dot)hu> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Multi ordered select and indexing |
Date: | 2004-04-29 19:34:13 |
Message-ID: | 14669.1083267253@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Antal Attila" <antal(dot)attila(at)ritek(dot)hu> writes:
> CREATE OPERATOR CLASS int4_reverse_order_ops
> FOR TYPE int4 USING btree AS
> OPERATOR 1 /< ,
> OPERATOR 2 /<= ,
> OPERATOR 3 /= ,
> OPERATOR 4 />= ,
> OPERATOR 5 /> ,
> FUNCTION 1 int4_reverse_order_cmp(int4, int4);
This is the wrong way to go about it. A useful descending-order opclass
simply rearranges the logical relationships of the standard comparison
operators. You do need a new comparison function, but nothing else:
CREATE OPERATOR CLASS int4_reverse_order_ops
FOR TYPE int4 USING btree AS
OPERATOR 1 > ,
OPERATOR 2 >= ,
OPERATOR 3 = ,
OPERATOR 4 <= ,
OPERATOR 5 < ,
FUNCTION 1 int4_reverse_order_cmp(int4, int4);
Now you can just use ASC/DESC in your ORDER BY ...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Roelant Ossewaarde | 2004-04-29 20:26:40 | Re: Use arrays or not? |
Previous Message | Josh Berkus | 2004-04-29 19:20:01 | Re: Equivalant of SQL Server's Nchar and NVARCHAR |