Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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)