pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <rhaas@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Code cleanup for toast_fetch_datum and toast_fetch_datum_slice.
Date: Tue, 17 Dec 2019 19:52:30 +0000
Message-ID: <E1ihItS-0006Rn-Ps@gemulon.postgresql.org> (raw)

Code cleanup for toast_fetch_datum and toast_fetch_datum_slice.

Rework some of the checks for bad TOAST chunks to be a bit simpler
and easier to understand. These checks verify that (1) we get all
and only the chunk numbers we expect to see and (2) each chunk has
the expected size. However, the existing code was a bit hard to
understand, at least for me; try to make it clearer.

As part of that, have toast_fetch_datum_slice check the relationship
between endchunk and totalchunks only with an Assert() rather than
checking every chunk number against both values. There's no need to
check that relationship in production builds because it's not a
function of whether on-disk corruption is present; it's just a
question of whether the code does the right math.

Also, have toast_fetch_datum_slice() use ereport(ERROR) rather than
elog(ERROR). Commit fd6ec93bf890314ac694dc8a7f3c45702ecc1bbd made
the two functions inconsistent with each other.

Rename assorted variables for better clarity and consistency, and
move assorted variables from function scope to the function's main
loop. Remove a few variables that are used only once entirely.

Patch by me, reviewed by Peter Eisentraut.

Discussion: http://postgr.es/m/CA+TgmobBzxwFojJ0zV0Own3dr09y43hp+OzU2VW+nos4PMXWEg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d5406dea25b600408e7acf17d5a06e82d3ce6d0d

Modified Files
--------------
src/backend/access/common/detoast.c | 220 +++++++++++++++++-------------------
1 file changed, 102 insertions(+), 118 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1ihItS-0006Rn-Ps@gemulon.postgresql.org>
Permalink:  ../E1ihItS-0006Rn-Ps@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ihItS-0006Rn-Ps@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: rhaas@postgresql.org
  Subject: Re: pgsql: Code cleanup for toast_fetch_datum and toast_fetch_datum_slice.
  In-Reply-To: <E1ihItS-0006Rn-Ps@gemulon.postgresql.org>
  References: <E1ihItS-0006Rn-Ps@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