Re: 8.0.3 regexp_replace()...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: 8.0.3 regexp_replace()...
Дата
Msg-id 4033.1138720931@sss.pgh.pa.us
обсуждение исходный текст
Ответ на 8.0.3 regexp_replace()...  ("rlee0001" <robeddielee@hotmail.com>)
Список pgsql-general
"rlee0001" <robeddielee@hotmail.com> writes:
> CREATE OR REPLACE FUNCTION "regexp_replacex" (source varchar, pattern
> varchar, replacement varchar) RETURNS varchar AS
> $body$
> DECLARE
>  retvalue VARCHAR;
> BEGIN
>  retvalue = "source";
>  LOOP
>   retvalue = REPLACE(retvalue, SUBSTRING(retvalue FROM "pattern"),
> "replacement");
>   EXIT WHEN retvalue = REPLACE(retvalue, SUBSTRING(retvalue FROM
> "pattern"), "replacement");
>  END LOOP;
>  RETURN retvalue;
> END;
> $body$
> LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

You probably don't want to be double-quoting the variable names.  Also,
I think this should be marked STRICT IMMUTABLE rather than the options
you have chosen.

> if you test it and do expect to have to kill the server when it enters
> the infinate loop.

Control-C cancels the query just fine for me ...

            regards, tom lane

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

Предыдущее
От: "P. Scott DeVos"
Дата:
Сообщение: plpython error logs
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Can't get the field = ANY(array) clause to work...