Recursive SQL functions

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Recursive SQL functions
Дата
Msg-id Pine.LNX.4.30.0110122157060.648-100000@peter.localdomain
обсуждение исходный текст
Ответы Re: Recursive SQL functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
While looking to implement the ODBC replace() function (replace occurences
of $2 in $1 by $3), I found that it could be expressed as:

CREATE FUNCTION replace(text, text, text) RETURNS text AS '   select       case when position($2 in $1) = 0 or
char_length($2)= 0           then $1           else substring($1 from 1 for position($2 in $1) - 1)                ||
$3               || replace(substring($1 from position($2 in $1) + char_length($2)), $2, $3)       end;
 
' LANGUAGE SQL WITH (isstrict);

Now this command doesn't actually work because it requires the replace()
function to exist already.  But it does work if one first creates a stub
replace() function and then uses CREATE OR REPLACE.

(So much about the claim that procedural languages are a security hole
because they allow infinite loops.)

I was wondering whether, as a future project, we could make this more
convenient by parsing the body of the function with the binding of the
function already in effect.

Comments?

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Warning of OID wraparound
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Warning of OID wraparound