Re: [ANNC][RFC] crypto hashes for PostgreSQL 7.0, 7.1

Поиск
Список
Период
Сортировка
От Horst Herb
Тема Re: [ANNC][RFC] crypto hashes for PostgreSQL 7.0, 7.1
Дата
Msg-id 00a901c03b62$c451c1a0$e7d2fea9@esmith.midgard
обсуждение исходный текст
Ответ на [ANNC][RFC] crypto hashes for PostgreSQL 7.0, 7.1  (Marko Kreen <marko@l-t.ee>)
Ответы Re: [ANNC][RFC] crypto hashes for PostgreSQL 7.0, 7.1  (Marko Kreen <marko@l-t.ee>)
Список pgsql-hackers
> > >   http://www.l-t.ee/marko/pgsql/pgcrypto-0.1.tar.gz    (11k)

First of all, thankd for tis contribution. I had impemented a similar thing for my own purposes. A problem I still have
isusing the digest for "checksumming" rows in my tables - which is a 'MUST' for medico-legal reasons in my case. I use
thefollwing trigger and function (just a proof of concept implementation)
 

DROP TRIGGER trig_crc ON crclog;
DROP FUNCTION trigfunc_crc();

CREATE FUNCTION trigfunc_crc()
RETURNS OPAQUE as '# create a string by concatenating all field contentsset cstr "";set len [llength $TG_relatts];for
{seti 1}  {$i < $len} {incr i} {     set istr [lindex $TG_relatts $i]     # skip the crc field!     if {[string compare
"crc"$istr] == 0} continue;      # beware of NULL fields     if [catch {set cstr $cstr$NEW($istr)}] continue; }  #
calculatethe strong hashspi_exec "select pg_crc32(''$cstr'') as crcs";# update the new recordset NEW(crc)
$crcs;#spi_exec"insert into logger(crc) values (''$crcs'')";
 
return [array get NEW]  
' LANGUAGE 'pltcl';   

CREATE TRIGGER trig_crc
BEFORE INSERT OR UPDATE ON crclog
FOR EACH ROW
EXECUTE PROCEDURE trigfunc_crc(); 

----------------------------------------------------------------------

As you can see, the trigfunc_crc is fairly generic and will work with any table containing the attribute "crc".

Have you found a way of 
- making the trigger generic as well (I hate to rebuild all triggers for 300+ tables whenever I modify trigfunc_crc)
- any better performing way to implement trigfunc_crc ?

Horst



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Philip Warner
Дата:
Сообщение: Re: Problem do backup/restore for empty database
Следующее
От: Philip Warner
Дата:
Сообщение: Last builtin OID?