Re: parser oddity (t.count)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: parser oddity (t.count)
Дата
Msg-id 23194.959272120@sss.pgh.pa.us
обсуждение исходный текст
Ответ на parser oddity (t.count)  (Ed Loehr <eloehr@austin.rr.com>)
Ответы Re: parser oddity (t.count)  (Andreas Zeugswetter <andreas.zeugswetter@telecom.at>)
Список pgsql-hackers
Ed Loehr <eloehr@austin.rr.com> writes:
> insert into foo (id, h_count) select t.id, t.count from temp_foo t;

> ERROR:  Attribute t.id must be GROUPed or used in an aggregate function

> I mislabeled the 't.h_count' column in my INSERT statement as 't.count',
> and what I found strange was that the parser evidently thinks t.count is
> an aggregate.  Is 't.count' valid use/syntax for an aggregate?

Hmm.  Due to some ancient Postquel features that you probably don't want
to hear about, foo.bar and bar(foo) are considered near-equivalent
notations by the parser.  It looks like when it couldn't find 'count' as
a field name, it tried and succeeded to interpret it as a function call
instead.

(A contributing problem here is that the parser is absolutely lax about
what it will take as the argument of count().  IMHO you should have
gotten something like "Unable to select an aggregate function
count(unknown)", which might have been a little less confusing.)

It works in the other direction too: field(foo) will be interpreted as
foo.field if foo has a column named field.

This equivalence can be pretty confusing if you don't know about it, but
I'm hesitant to suggest ripping it out because of the risk of breaking
old applications.  Anyone have strong opinions one way or the other?
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Zeugswetter Andreas SB
Дата:
Сообщение: AW: AW: AW: More Performance
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Create user/create database outside template1