md5 checksum of a given/previous row

From: Iaam Onkara <iamonkara(at)gmail(dot)com>
To: pgsql-in-general(at)postgresql(dot)org
Subject: md5 checksum of a given/previous row
Date: 2017-11-12 18:26:33
Message-ID: CAMz9UCYQHf8+U8KGwdvLvBvjgMcvt+i0nNpyO15jYP2gc-2ubg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-in-general

Hi,

I have a requirement to create an tamper proof chain of records for audit
purposes. The pseudo code is as follows

before_insert:
1. compute checksum of previous row (or conditionally selected row)
2. insert the computed checksum in the current row

For now lets assume we are using md5 checksum, I can easily get the md5 of
current row using

select md5(textin(record_out(test))) as md5_checksum FROM test;

but how do I compute md5 of previous row or of a row selected by where
column=val;?

Thanks.
Onkara

Responses

Browse pgsql-in-general by date

  From Date Subject
Next Message Iaam Onkara 2017-11-12 19:55:22 Re: md5 checksum of a given/previous row
Previous Message Michael Paquier 2017-11-08 00:32:19 Re: Fwd: standby stop replicating, then picked back up