Re: How much data does server side "loread" return?

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Thorsten Schöning <tschoening(at)am-soft(dot)de>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How much data does server side "loread" return?
Date: 2021-06-24 14:19:28
Message-ID: 0c25500b51262c000a7a88ab5a5f573af03212b9.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Ivanov 2021-06-24 14:29:22 Re: insert ..... returning <column> problem
Previous Message Tom Lane 2021-06-24 14:19:17 Re: removing "serial" from table definitions.