pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mª José Sempere <mjose@pixelart.es>
To: pgsql-admin@postgresql.org
Subject: digest as IMMUTABLE function
Date: Fri, 10 Dec 2004 13:33:44 +0100
Message-ID: <000001c4deb4$7fa9f1e0$0900a8c0@mj> (raw)

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






Message-ID: <000001c4deb4$7fa9f1e0$0900a8c0@mj>
Permalink:  ../000001c4deb4$7fa9f1e0$0900a8c0@mj/
Also on:    postgresql.org/message-id/000001c4deb4$7fa9f1e0$0900a8c0@mj

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mjose@pixelart.es
  Subject: Re: digest as IMMUTABLE function
  In-Reply-To: <000001c4deb4$7fa9f1e0$0900a8c0@mj>
  References: <000001c4deb4$7fa9f1e0$0900a8c0@mj>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox