Re: [HACKERS] Curiously confused query parser.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Curiously confused query parser.
Дата
Msg-id 2550.943025762@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Curiously confused query parser.  ("Gene Sokolov" <hook@aktrad.ru>)
Список pgsql-hackers
"Gene Sokolov" <hook@aktrad.ru> writes:
> This query is fine:

> test=> select o1.id from ord as o1, ord as o2 where o1.pos>2 and o2.pos<2
test-> and o1.tp=o2.tp;
> id
> --
>  5
>  3
> (2 rows)

> And this one is invalid:

> test=> select o1.id from ord as o1, ord as o2 where o1.pos>2 and o2.pos<2
test-> and o1.tp=o2.tp and ord.id>3;
> id
> --
>  5
>  5
>  3
>  3
> (4 rows)

It's not invalid, at least not according to Postgres' view of the world;
your reference to ord.id adds an implicit "FROM ord AS ord" to the FROM
clause, turning the query into a 3-way join.  The output is correct for
that interpretation.

Implicit FROM clauses are a POSTQUEL leftover that is not to be found
in the SQL92 spec.  There's been some talk of emitting a warning message
when one is added, because we do regularly see questions from confused
users.  But if we took the feature out entirely, we'd doubtless break
some existing applications :-(
        regards, tom lane


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

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: [HACKERS] Primary key requires SERIAL
Следующее
От: Thomas Lockhart
Дата:
Сообщение: Mandrake Postgres RPMs