pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thorsten Schöning <tschoening@am-soft.de>
To: pgsql-general@lists.postgresql.org
Subject: How much data does server side "loread" return?
Date: Thu, 24 Jun 2021 15:24:52 +0200
Message-ID: <841401823.20210624152452@am-soft.de> (raw)

Hi all,

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?

I didn't find any explicit docs regarding that point and almost all
examples I saw where issuing one call with large amounts of requested
data, regardless of the size of the large object. The latter most
likely means that if available, all requested data is always returned.

Besides that, if "loread" is used in a loop for various reasons
already, one would need to count the overall number of bytes read to
know when the last chunk was read. Instead, it would be enough to
check for if the last returned chunk is less than requested.

> LOOP
>       chunk           := loread(fd, CHUNK_SIZE);
>       chunkSize       := length(chunk);
>       fdRead          := fdRead + chunkSize;
> [...]
>       --EXIT WHEN (chunkSize < CHUNK_SIZE);
>       EXIT WHEN (fdRead = fdSize);
> END LOOP;

Is the first EXIT sufficient already and "fdRead" unnecessary?

Thanks!

Mit freundlichen Grüßen

Thorsten Schöning

-- 
AM-SoFT IT-Service - Bitstore Hameln GmbH
Mitglied der Bitstore Gruppe - Ihr Full-Service-Dienstleister für IT und TK

E-Mail: Thorsten.Schoening@AM-SoFT.de
Web:    http://www.AM-SoFT.de/

Tel:   05151-  9468- 0
Tel:   05151-  9468-55
Fax:   05151-  9468-88
Mobil:  0178-8 9468-04

AM-SoFT IT-Service - Bitstore Hameln GmbH, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 221853 - Geschäftsführer: Janine Galonska


Für Rückfragen stehe ich Ihnen sehr gerne zur Verfügung.

Mit freundlichen Grüßen

Thorsten Schöning


Tel: 05151 9468 0
Fax: 05151 9468 88
Mobil: 
Webseite: https://www.am-soft.de 

AM-Soft IT-Service - Bitstore Hameln GmbH i.G. ist ein Mitglied der Bitstore Gruppe - Ihr Full-Service-Dienstleister für IT und TK

AM-Soft IT-Service - Bitstore Hameln GmbH i.G.
Brandenburger Str. 7c
31789 Hameln
Tel: 05151 9468 0

Bitstore IT-Consulting GmbH
Zentrale - Berlin Lichtenberg
Frankfurter Allee 285
10317 Berlin
Tel: 030 453 087 80

CBS IT-Service - Bitstore Kaulsdorf UG
Tel: 030 453 087 880 1

Büro Dallgow-Döberitz
Tel: 03322 507 020

Büro Kloster Lehnin
Tel: 033207 566 530

PCE IT-Service - Bitstore Darmstadt UG
Darmstadt
Tel: 06151 392 973 0

Büro Neuruppin
Tel: 033932 606 090

ACI EDV Systemhaus - Bitstore Dresden GmbH
Dresden
Tel: 0351 254 410

Das Systemhaus - Bitstore Magdeburg GmbH
Magdeburg
Tel: 0391 636 651 0

Allerdata.IT - Bitstore Wittenberg GmbH
Wittenberg
Tel: 03491 876 735 7

Büro Liebenwalde
Tel: 033054 810 00

HSA - das Büro - Bitstore Altenburg UG
Altenburg
Tel: 0344 784 390 97

Bitstore IT – Consulting GmbH
NL Piesteritz 
Piesteritz
Tel: 03491 644 868 6

Solltec IT-Services - Bitstore Braunschweig UG
Braunschweig
Tel: 0531 206 068 0

MF Computer Service - Bitstore Gütersloh GmbH
Gütersloh
Tel: 05245 920 809 3

Firmensitz: AM-Soft IT-Service - Bitstore Hameln GmbH i.G. , Brandenburger Str. 7c , 31789 Hameln
Geschäftsführer Janine Galonska











view thread (2+ messages)  latest in thread

Message-ID: <841401823.20210624152452@am-soft.de>
Permalink:  ../841401823.20210624152452@am-soft.de/
Also on:    postgresql.org/message-id/841401823.20210624152452@am-soft.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tschoening@am-soft.de
  Subject: Re: How much data does server side "loread" return?
  In-Reply-To: <841401823.20210624152452@am-soft.de>
  References: <841401823.20210624152452@am-soft.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox