Re: checksumming data

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Can Burak Cilingir <canburak(at)cs(dot)bilgi(dot)edu(dot)tr>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: checksumming data
Date: 2005-01-04 01:14:13
Message-ID: 20050104011413.GA60141@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, Jan 04, 2005 at 01:04:48AM +0200, Can Burak Cilingir wrote:

> How can I get the sha1 sum of large objects? or md5. but sha1 is better.

PostgreSQL 7.4 and later has a built-in MD5() function, but it takes
a TEXT argument and might return unexpected results for binary data.
For a digest function that handles binary data and can do SHA1, see
the contrib/pgcrypto module.

I haven't used large objects much, but running \df in psql shows
several functions like lo_open() and loread() that appear to work
like the C functions described in the "Client Interfaces" section
of the "Large Objects" chapter in the documentation. I don't know
why they're not documented as server-side functions callable from
SQL or PL/pgSQL -- I just did some tests and was able to read large
object data from a PL/pgSQL function. I did have to consult the
documentation for the C functions and search through C headers to
find values for constants like INV_READ, so maybe there's an easier
way that I don't know about.

How committed are you to using large objects? You might be able
to use BYTEA instead, but search the list archives for the debate
about which is more appropriate for a given situation.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Keith Worthington 2005-01-04 02:13:56 Creating a clean database
Previous Message Ramon Orticio 2005-01-04 00:59:17 postgresql for windows