digest as IMMUTABLE function

From: Mª José Sempere <mjose(at)pixelart(dot)es>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: digest as IMMUTABLE function
Date: 2004-12-10 12:33:44
Message-ID: 000001c4deb4$7fa9f1e0$0900a8c0@mj
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-admin by date

  From Date Subject
Next Message Hemapriya 2004-12-10 16:51:28 vacuum analyze takes long time
Previous Message Mª José Sempere 2004-12-10 10:04:49 pgcrypto module for WINDOWS