Re: where clause + function, execution order

Поиск
Список
Период
Сортировка
Искать
От
Julius Tuskenis
Тема
Re: where clause + function, execution order
Дата
Msg-id
4EBD4518.5070508@nsoft.lt
Ответ на
Список
Дерево обсуждения
where clause + function, execution order Sorin Dudui <sd@wigeogis.com>
Re: where clause + function, execution order Julius Tuskenis <julius@nsoft.lt>
Re: where clause + function, execution order Richard Huxton <dev@archonet.com>
Re: where clause + function, execution order Sorin Dudui <sd@wigeogis.com>
Re: where clause + function, execution order Richard Huxton <dev@archonet.com>
Re: where clause + function, execution order Tom Lane <tgl@sss.pgh.pa.us>
Hello,

On 2011.11.11 17:38, Sorin Dudui wrote:

Hi,

 

I have the following function:

 

===============================

CREATE OR REPLACE FUNCTION xxx(text)

  RETURNS SETOF vvvvv AS

$BODY$

select a.x, a.y,

    CASE

    WHEN strpos($1,b.x) > 0

    THEN b.x

    ELSE NULL

    END AS mp_hm

from  a LEFT JOIN  b ON a.id=b.id

 

                $BODY$

  LANGUAGE sql STABLE

  COST 1000

  ROWS 10000;

===============================

 

which I call as:

 

select * from xxx(‘test0|test1‘)  where a.x = ‘value’

You should get an error as there is no "a" in this statement...

 

 

I am wondering when the where clause (a.x = ‘value’) is executed. After the select statement in the function finishes? Or is it appended at the select statement in the function?

 

Function execute plan is prepared when creating it, so the "where" clause should check the function result not altering its execution..

--
Julius Tuskenis
Head of the programming department
UAB nSoft
mob. +37068233050
В списке pgsql-performance по дате отправления
От: Sorin Dudui
Дата:
От: Richard Huxton
Дата:
FAQ