On Thu, 2021-06-24 at 15:24 +0200, Thorsten Schöning wrote: > I need to read some large object and am wondering how much data > "loread" returns in case it successfully reads at all AND the object > contains at least as much data as requested. > > In that case, does "loread" always return the requested amount of data > or does one need to always loop when calling that function? That SQL function just calls the C function lo_read, see https://www.postgresql.org/docs/current/lo-interfaces.html#LO-READ The documentation there says: "The number of bytes actually read is returned; this will be less than 'len' if the end of the large object is reached first. In the event of an error, the return value is -1." So it will always read as many bytes as possible. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com