digest as IMMUTABLE function - Mailing list pgsql-admin

From Mª José Sempere
Subject digest as IMMUTABLE function
Date
Msg-id 000001c4deb4$7fa9f1e0$0900a8c0@mj
Whole thread Raw
List pgsql-admin
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




pgsql-admin by date:

Previous
From: Ron Peterson
Date:
Subject: fallback authentication
Next
From: rray@tcmail.mstc.state.ms.us
Date:
Subject: Login with blank password