Re: Function call order dependency

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Function call order dependency
Дата
Msg-id 27126.1220462013@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Function call order dependency  (pgsql@mohawksoft.com)
Ответы Re: Function call order dependency
Список pgsql-hackers
pgsql@mohawksoft.com writes:
> I need to perform an operation during query time and there are multiple
> results based on the outcome. For instance: (Lets try this)

> select myrank(t1.column1, t2.column2, 1) as rank,
> myscore(t1.column1,t2.column2, 1) as score from t1, t2 where
> myrank(t1.column1,t2.column2) > 10 order by myscore(t1.column1,
> t2.column2, 1) desc;

Why not have one function that produces multiple output columns?

> Now, can I assume that in the above select statement, that each
> permutation of t1.column1 and t2.column2 will only be evaluated once and
> that myscore(...) and myrank(...) will all be called before the next
> permutation is evaluated?

You can assume that functions in the SELECT target list are evaluated
exactly once per output row (at least as long as no
SRFs-in-the-targetlist are involved).  I don't think it'd be wise to
assume anything about order of evaluation, though it's probably true
that it's left-to-right at the moment.
        regards, tom lane


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

Предыдущее
От: Andrew Chernow
Дата:
Сообщение: Re: libpq object hooks (libpq events)
Следующее
От: pgsql@mohawksoft.com
Дата:
Сообщение: Re: Function call order dependency