> > Yeah, it's sticky. Where in the code does the sorting get set up?
> See optimizer/prep/prepunion.c::plan_union_queries(). You will see me
> calling transformSortClause() from there to set up a query using
> UNION/UNION ALL. I think that is where the problem is happening.
> Whatever you did in the parser to get these types converted is not in
> that function. Can you check into it? Should I be doing that in
> another place. I am unsure, but it looks like the best place for it.
OK, made a change to transformSortClause() called from
plan_union_queries():
postgres=> select null union select null;
?column?
--------
(1 row)
postgres=> select null union select null union all select null;
?column?
--------
(2 rows)
I decided to use the int4 sorting routines when the type is
"InvalidOid", the type apparently assigned to null constants. The sort
routines probably don't get called anyway since everything is a null,
and if they did the "pass by value" int4 routines are probably safest.
Will continue testing, and need to look into this still:
postgres=> select 1 union select null union all select null;
Backend message type 0x44 arrived while idle
...
- Tom