Re: to_char incompatibility

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: to_char incompatibility
Дата
Msg-id 162867790801100647i4162d014ufa109cdeee3802d9@mail.gmail.com
обсуждение исходный текст
Ответ на Re: to_char incompatibility  ("Roberts, Jon" <Jon.Roberts@asurion.com>)
Список pgsql-hackers
small non important note: your function is very expensive

exactly same but faster is:

CREATE OR REPLACE FUNCTION fn_to_date(p_date varchar, p_format varchar)
RETURNS timestamp AS $$SELECT to_timestamp(replace($1, ' ', ''), replace($2, ' ', ''));
$$ LANGUAGE SQL STRICT IMMUTABLE;

or

CREATE OR REPLACE FUNCTION fn_to_date(p_date varchar, p_format varchar)
RETURNS timestamp AS $$
BEGINRETURN  to_timestamp(replace(p_date, ' ', ''), replace(p_format, ' ', ''));
END$$ LANGUAGE SQL STRICT IMMUTABLE;

there isn't any reason for using security definer and you forgot IMMUTABLE,

Regards
Pavel Stehule


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

Предыдущее
От: "Roberts, Jon"
Дата:
Сообщение: Re: to_char incompatibility
Следующее
От: Alvaro Herrera
Дата:
Сообщение: tag REL8_2_6 not present in file xyz