pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <jdavis@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: logtape.c: allocate read buffer even for an empty tape.
Date: Wed, 19 Feb 2020 18:12:23 +0000
Message-ID: <E1j4Tpf-0003eL-0x@gemulon.postgresql.org> (raw)

logtape.c: allocate read buffer even for an empty tape.

Prior to this commit, the read buffer was allocated at the time the tape
was rewound; but as an optimization, would not be allocated at all if
the tape was empty.

That optimization meant that it was valid to have a rewound tape with
the buffer set to NULL, but only if a number of conditions were met
and only if the API was used properly. After 7fdd919a refactored the
code to support lazily-allocating the buffer, Coverity started
complaining.

The optimization for empty tapes doesn't seem important, so just
allocate the buffer whether the tape has any data or not.

Discussion: https://postgr.es/m/20351.1581868306%40sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8021985d791902a9eeda51acdede759fbc67ae01

Modified Files
--------------
src/backend/utils/sort/logtape.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)



Message-ID: <E1j4Tpf-0003eL-0x@gemulon.postgresql.org>
Permalink:  ../E1j4Tpf-0003eL-0x@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1j4Tpf-0003eL-0x@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: jdavis@postgresql.org
  Subject: Re: pgsql: logtape.c: allocate read buffer even for an empty tape.
  In-Reply-To: <E1j4Tpf-0003eL-0x@gemulon.postgresql.org>
  References: <E1j4Tpf-0003eL-0x@gemulon.postgresql.org>

* 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