views:

55

answers:

2

There is a function in our system that writes a file to a postgres BLOB, the function is pg_lo_write, our system uses PHP, ADODB and PostgreSQL.

What I would like to know is where is this data stored, is it a file in a postgres directory, in a table?

Many thanks!

Answer Information

Thanks to Ben Fransen for the answer, the BLOB is in fact stored in the pg_largeobject table. I'm using pgAdmin and the table is hidden from view, however it can be accessed using a query.

SELECT * FROM pg_largeobject WHERE LOID = 123456
+1  A: 

Correct me if I'm wrong but as far as i know when you are storing files in a database they are stored as binary data. The binary value of your file is stored in your BLOB field. When you are trying to get that file the binary value is then reconstructed to the original file.

Ben Fransen
In my table I have an OID of six characters, but I don't have any binary fields. I have looked at the statistics of each table and none of them exceed a couple kilobytes, and I have about 10MB+ of files in there.
ILMV
Are there 'location' references to the files that should be BLOB? Maybe you can figure out by that where the files are stored?
Ben Fransen
I think i figured it out. There should be a `pg_largeobject` table in your database. The OID you mentioned is the key to the record in that table. I think you'll find a binary value in the `pg_largeobject` table matching your OID.
Ben Fransen
Ben Franson you deserve 2 vote ups for that! Many thanks :D
ILMV
Hehe you're welcome! ;)
Ben Fransen
+2  A: 

For future reference the relevant sections in the PostgreSQL manual:

Chapter 31. Large Objects, 31.2. Implementation Features.

Chapter 44. System Catalogs, 44.23. pg_largeobject.

Milen A. Radev
Cheers Milen :-)
ILMV