Re: Something's not (de)compressing right... - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Something's not (de)compressing right...
Date
Msg-id 23668.963030612@sss.pgh.pa.us
Whole thread Raw
In response to Something's not (de)compressing right...  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> When using psql's \dd command, the backend crashes with a segfault.

The new query \dd is issuing is tickling a longstanding UNION bug.
For now I'd suggest that you work around the problem by explicitly
coercing the result of format_type() to NAME:

...
UNION ALL
SELECT DISTINCT format_type(t.oid, NULL)::name as "Name", 'type'::text as "Object", d.description as "Description"
...

The crash occurs because text_lt is used to sort a column of NAME values
--- the result of format_type is coerced to NAME so that it can be
union'd with the NAME results of the other sub-selects, but by the time
that happens we've already chosen the sort operator for the DISTINCT,
and what we chose was text_lt :-(.  If you do the coercion explicitly
then name_lt gets chosen for DISTINCT and everything works.

Actually, given that the result of format_type might well exceed 32
characters, you might think it better to coerce the results of all the
sub-selects to "text".  But the point is you can't rely on UNION's auto-
coercion to do the right thing when a sub-select requires its own sort.

I have a list of about two dozen UNION/INTERSECT/EXCEPT bugs (including
this one) that I don't think can be fixed without a querytree redesign.
So hold your nose and coerce explicitly until 7.2 ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Chris Bitmead
Date:
Subject: Re: libpq / SQL3
Next
From: Philip Warner
Date:
Subject: 'errno' undefined?