Re: Problem with planer

Поиск
Список
Период
Сортировка
От Russell Smith
Тема Re: Problem with planer
Дата
Msg-id 48BCBF33.5030809@pws.com.au
обсуждение исходный текст
Ответ на Problem with planer  (<Eugen.Konkov@aldec.com>)
Список pgsql-bugs
Eugen.Konkov@aldec.com wrote:
> select ats.id, ap.value from akh_test_suit ats
> LEFT JOIN akh_properties ap on ap.ID = ats.test_suit_type_id
> where ats.ID = 472
>
> id | value
> 472 | 472
> ID -- integer
> value -- text
>
>
> select * from akh_test_suit ats
> LEFT JOIN akh_properties ap on ap.ID = ats.test_suit_type_id
> where ats.ID = 472 and ap.value::integer = ats.ID
>
> ERROR:  invalid input syntax for integer: "--username sergeiz
> --password sergeiz --non-interactive svn://sergeiz"
>
where clauses are not evaluated in the order written.  There is no
guarantee that ats.ID = 472 will be evaluated before ap.value::integer.
You can't write SQL queries like they are a piece of programming logic,
they are not always evaluated in order and may not be evaluated in the
order you wrote them.  My first guess it to write it up as a subquery;

select * from (select * from akh_test_suit ats
LEFT JOIN akh_properties ap on ap.ID = ats.test_suit_type_id
where ats.ID = 472) as sub WHERE value::integer = ID;

Or unless you are specifically needing the performance, you could just
allow pg to automatically coerce ats.ID to text.

Regards

Russell.

> akh_properties.values has non numeric values, but those rows do not
> (MUST NOT) participate in results as showed in first query
> Why PG check them?

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Bug with FOR ... LOOP and composite types
Следующее
От: "Hemavathi B N"
Дата:
Сообщение: BUG #4393: failed toget system metics for terminal services:87