Обсуждение: digest as IMMUTABLE function

Поиск
Список
Период
Сортировка

digest as IMMUTABLE function

От
Mª José Sempere
Дата:
Hello,

We were trying to create an index using the digest function like that (where
picture is a bytea field):

create unique index my_index on my_table digest(picture, 'md5'));

but we got the error:


ERROR:  functions in index expression must be marked IMMUTABLE


So, we have created the function digestinmutable(), like that:

CREATE OR REPLACE FUNCTION digestinmutable(bytea, text)
  RETURNS bytea AS
'$libdir/pgcrypto', 'pg_digest'
  LANGUAGE 'c' IMMUTABLE;


And after that, we have created the index using the new function
(digestinmutable) :


create unique index my_index  on my_table digestinmutable(picture, 'md5'));



IT SEEMS TO WORK OK. Does Anybody know if we'll have any problem using md5
in that way?


Thank you very much for your help.

Bye