Re: functions in WHERE clause

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: functions in WHERE clause
Дата
Msg-id 4338.1141581591@sss.pgh.pa.us
обсуждение исходный текст
Ответ на functions in WHERE clause  (sramsay@uga.edu)
Ответы Re: functions in WHERE clause  (Greg Stark <gsstark@mit.edu>)
Список pgsql-sql
sramsay@uga.edu writes:
> I've got one of these:
> SELECT * from some_table WHERE
> test_for_equality_is_syntactically_ugly;
> What I'd like to do is encapsulate the WHERE clause in a function,

You mean like replacing

SELECT * from some_table WHERE x = 42 AND y = 77

with

create function mytest(int,int) returns bool as
$$select $1 = 42 AND $2 = 77$$ language sql;

SELECT * from some_table WHERE mytest(x,y);

A SQL-language function like this should get inlined into the query,
so that you don't lose any performance compared to writing out the
full expression each time.
        regards, tom lane


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

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Re: Check/unique constraint question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: functions in WHERE clause