"Antal Attila" <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to