From: | Reece Hart <reece(at)in-machina(dot)com> |
---|---|
To: | Jon Earle <je_pgsql(at)kronos(dot)honk(dot)org> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: md5 function |
Date: | 2003-12-18 22:50:48 |
Message-ID: | 1071787848.3668.22.camel@tallac |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2003-12-17 at 06:30, Jon Earle wrote:
> Is there a way to, when I add a record to a table, have the md5 hash
> computed and stored in the same table and then returned to the calling
> program?
I recommend that you write a trigger to compute the md5 and shove that
into a column. There are several integrity advantages of having
postgresql do it in a trigger: 1) you can guarantee that it gets done,
2) you don't have to worry about a clients lying about the md5 or
computing the md5 in different ways, 3) the md5 gets computed regardless
of how the record is inserted, and 4) you can attach the trigger to
updates as well.
As for returning the md5 to the caller/client, that's probably best done
with a function whose job is to insert a record and return the md5. I
have functions like serial# <- ins_record(datum,datum,datum), which
merely do an insert into table and return the serial number for that
record.
-Reece
--
Reece Hart, Ph.D. rkh(at)gene(dot)com, http://www.gene.com/
Genentech, Inc. 650/225-6133 (voice), -5389 (fax)
Bioinformatics and Protein Engineering
1 DNA Way, MS-93 http://www.in-machina.com/~reece/
South San Francisco, CA 94080-4990 reece(at)in-machina(dot)com, GPG: 0x25EC91A0
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2003-12-18 23:03:30 | Re: functions returning sets |
Previous Message | Bruno Wolff III | 2003-12-18 22:37:24 | Re: automatic verifications |