Re: checksumming data - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: checksumming data
Date
Msg-id 20050104011413.GA60141@winnie.fuhr.org
Whole thread Raw
In response to checksumming data  (Can Burak Cilingir <canburak@cs.bilgi.edu.tr>)
Responses Re: checksumming data  (Can Burak Cilingir <canburak@cs.bilgi.edu.tr>)
List 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/

pgsql-novice by date:

Previous
From: Ramon Orticio
Date:
Subject: postgresql for windows
Next
From: Keith Worthington
Date:
Subject: Creating a clean database