BUG #2821: xid cannot be casted to a different type - Mailing list pgsql-bugs

From Edwin Groothuis
Subject BUG #2821: xid cannot be casted to a different type
Date
Msg-id 200612100113.kBA1DW3h048968@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #2821: xid cannot be casted to a different type
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2821
Logged by:          Edwin Groothuis
Email address:      mavetju@gmail.com
PostgreSQL version: 8.0 / 8.1. / 8.
Operating system:   FreeBSD
Description:        xid cannot be casted to a different type
Details:

This statement is part of a longer one, which we used on 8.0
    to determine the status of the locks on the database:

    select relation,transaction::bigint,count(*) as waiting from
    pg_locks where not granted group by relation,transaction;

    This worked fine on 8.0.x. Now I'm preparing to move to 8.1
    and/or 8.2, but that above statement now gives me:

    ERROR:  could not identify an ordering operator for type xid
    HINT:  Use an explicit ordering operator or modify the query.

    According to a discussion on IRC with neilc and davidfetter:

    <neilc> davidfetter, Mavvie: we need an ordering operator to do GROUP
BY
    <neilc> for some reason that's not clear to me atm
    <neilc> perhaps because originally we only implemented grouping / aggs
via sorting?
    <davidfetter> neilc, makes sense, in a way
    <davidfetter> yeah
    <neilc> anyway, so the problem is just there aren't ordering operators
for the xid type
    <Mavvie> neilc: I've tried to cast the transaction field (which is the
xid) to a text, bigint or something else but it keeps coming back as "cannot
cast type xid to ..."
    <neilc> there probably should be, like we added for tid i think in 8.2
    <davidfetter> would this be an initdb-forcing thing? :f
    <neilc> well, you could package the changes as sql
    <davidfetter> cool :)
    <neilc> i wouldn't personally bother backporting it tho, it's not a bug
per se
    <davidfetter> hrm. i'd say anything that causes you not to be able to do
"expected" operations like aggregation is a bug

pgsql-bugs by date:

Previous
From: "trinchero"
Date:
Subject: BUG #2820: "select" faling with "distinct" clause on a subquery
Next
From: Tom Lane
Date:
Subject: Re: BUG #2821: xid cannot be casted to a different type