Skip to content

Commit 5184f11

Browse files
committed
Fix bad formula in previous commit.
Commit d5406de used a slightly novel, and wrong, approach to compute the length of the last toast chunk. It worked fine unless the last chunk happened to have the largest possible size.
1 parent d5406de commit 5184f11

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/access/common/detoast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ toast_fetch_datum(struct varlena *attr)
443443
toast_pointer.va_valueid,
444444
RelationGetRelationName(toastrel))));
445445
expected_size = curchunk < totalchunks - 1 ? TOAST_MAX_CHUNK_SIZE
446-
: attrsize % TOAST_MAX_CHUNK_SIZE;
446+
: attrsize - ((totalchunks - 1) * TOAST_MAX_CHUNK_SIZE);
447447
if (chunksize != expected_size)
448448
ereport(ERROR,
449449
(errcode(ERRCODE_DATA_CORRUPTED),
@@ -676,7 +676,7 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset,
676676
toast_pointer.va_valueid,
677677
RelationGetRelationName(toastrel))));
678678
expected_size = curchunk < totalchunks - 1 ? TOAST_MAX_CHUNK_SIZE
679-
: attrsize % TOAST_MAX_CHUNK_SIZE;
679+
: attrsize - ((totalchunks - 1) * TOAST_MAX_CHUNK_SIZE);
680680
if (chunksize != expected_size)
681681
ereport(ERROR,
682682
(errcode(ERRCODE_DATA_CORRUPTED),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy