Re: Load Image File From PostgreSQL DB - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Load Image File From PostgreSQL DB
Date
Msg-id D960CB61B694CF459DCFB4B0128514C202EA75C7@exadv11.host.magwien.gv.at
Whole thread Raw
In response to Re: Load Image File From PostgreSQL DB  (Julius Tuskenis <julius.tuskenis@gmail.com>)
Responses Re: Load Image File From PostgreSQL DB
List pgsql-general
Please don't top post.

Julius Tuskenis wrote:
>> Large Objects (http://www.postgresql.org/docs/current/static/largeobjects.html)
>> use OID columns, and they work fine for storing binary data like images.
>
> In the article you provided it is said that "The return value is the OID 
> that was assigned to the new large object..." (function Oid 
> lo_creat(PGconn *conn, int mode);). That means that not the large object 
> is stored in OID field - its just the reference to it.

Yes, that's true.
You'll have to use the large object API to access the data.
All I wanted to point out is that while you cannot store binary data
*IN* an OID column, you can very well do so *USING* an OID column.

> Any way I find it much easier to get a relatively small blob in a result 
> set and not directly using lo_read function, because in delphi zeos 
> components does work with  libpq, so theres no need to bypass them?

Yes, it is easier, and probably in most cases better, to use bytea.
I think that large objects are preferrable ony if
a) you need to store more than 1GB or
b) you need the operations that only large objects provide, like
   reading out only part of the binary data.

I don't quite understand what you wrote about lo_read and libpq,
because libpq provides lo_open.

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: return X number of refcursors from a function
Next
From: Julius Tuskenis
Date:
Subject: Re: Load Image File From PostgreSQL DB