Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I access large object store on foreign table

I have set up postgres_fdw to access a 'remote' database (in fact its on the same server). Works fine. Except one of the columns is the oid of a large object, how can I read that data?

like image 801
pm100 Avatar asked Feb 02 '26 00:02

pm100


1 Answers

I worked out how to do this. The large object store can also be accessed via the pg_largeobject table. So I did

create foreign table if not exists global_lo (
    loid oid not null,
    pageno integer not null,
    data bytea 
)
server glob_serv options(table_name 'pg_largeobject', schema_name 'pg_catalog');

Now I can read a large object (all of it, I cannot stream etc) with

select data from global_lo where loid = 1234
like image 98
pm100 Avatar answered Feb 04 '26 14:02

pm100