Обсуждение: Subselect returns too many attributes

Поиск
Список
Период
Сортировка

Subselect returns too many attributes

От
"Scott Muir"
Дата:
Here is an interesting one..

I'm trying to perform the following.. this is a simpler version of what I"m
actually working with..

SELECT p.name, c.mostrecentthingbought FROM parent p, child c WHERE c.name =
p.name AND c.tx_number = ANY( SELECT MAX(c.tx_number) AS "max" FROM child c
WHERE c.name = p.name GROUP BY c.name);

i think that is pretty close.. though in my case there are 4 fields in the
parent primary key and 5 in the child...

anyways, this is a view which I am storing..  when I store it, pgsql takes
it happily.. both from pgacces and psql...

when I view it again either from pgaccess or using psql, the subselect has
had added to the fields it returns, all the other fields in the group by or
in the where clause...  this still seems to work okay..

though if I want to modify the view, i have to remove the extra fields in
order for it to get back in, and it promptly replaces them anyways..

So the question is, do the ANY clause have an actual problem with the
subselect returning more than one field (attribute whatever)???


Thanks.
Scott.


Re: Subselect returns too many attributes

От
Tom Lane
Дата:
"Scott Muir" <wsmuir@islandnet.com> writes:
> when I view it again either from pgaccess or using psql, the subselect has
> had added to the fields it returns, all the other fields in the group by or
> in the where clause...  this still seems to work okay..

This is a bug ... it's fixed in 7.1 ...

            regards, tom lane

Re: Subselect returns too many attributes

От
Tom Lane
Дата:
I wrote:
> "Scott Muir" <wsmuir@islandnet.com> writes:
>> when I view it again either from pgaccess or using psql, the subselect has
>> had added to the fields it returns, all the other fields in the group by or
>> in the where clause...  this still seems to work okay..

> This is a bug ... it's fixed in 7.1 ...

Hm, I didn't actually answer your question, did I?  Yes, the view
will work fine.  The bug is just in the rule decompiler: it's showing
parts of the internal representation that it shouldn't.

            regards, tom lane