Thread: Display large object from database
I am using pgSQL 8.1.4. I have a table that stores pictures, using an oid column.
Now using the SQL functions provided I have successfully saved an image to the table, and managed to export it from the table again.
I am battling to open the image for reading into a stream. The mentioned functions support opening for exporting a file in SQL are
SELECT lo_export(image.raster, '/tmp/motd') FROM image
WHERE name = 'beautiful image';
But how do I open a stream for reading?
inv_fd = lo_open(conn, inv_oid, INV_READ|INV_WRITE);
I have tried to convert this into a SQL statement but INV_READ is not seen as an accepted parameter.
"Greg" <greg@officium.co.za> writes: > I am battling to open the image for reading into a stream. From what? The lo_xxx functions are intended to be used from C, not from SQL. You might be better off using a bytea column, which is a far simpler construct than a large object. It won't give you streamwise access, just fetch or store the whole value at once, but that might be all you need. regards, tom lane
Thanks, I read the pgAdmin help on a bytea column, but it doesn't specify its maximum size. What is the largest filesize I can fit into a bytea column? Thanks ----- Original Message ----- From: Tom Lane To: Cc: pgsql-novice@postgresql.org Sent: Mon, 05 Jun 2006 10:55:26 -0400 Subject: Re: [NOVICE] Display large object from database "Greg" <greg@officium.co.za> writes: > I am battling to open the image for reading into a stream. From what? The lo_xxx functions are intended to be used from C, not from SQL. You might be better off using a bytea column, which is a far simpler construct than a large object. It won't give you streamwise access, just fetch or store the whole value at once, but that might be all you need. regards, tom lane
<greg@officium.co.za> writes: > Thanks, I read the pgAdmin help on a bytea column, but it doesn't specify its maximum size. What is > the largest filesize I can fit into a bytea column? The hard limit is 1Gb. Practical limit is probably a good deal less, depending on your machine, but I don't know of anyone who's tried to measure performance with such wide column values. regards, tom lane