diff options
author | Robert Haas <rhaas@postgresql.org> | 2019-12-17 15:53:17 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2019-12-17 15:53:17 -0500 |
commit | 5184f110aa4130ec87b0b3e0834292cd8cb1fd8a (patch) | |
tree | 22a68c0a88b09175903f096b6d986fdc064dc542 | |
parent | d5406dea25b600408e7acf17d5a06e82d3ce6d0d (diff) | |
download | postgresql-5184f110aa4130ec87b0b3e0834292cd8cb1fd8a.tar.gz postgresql-5184f110aa4130ec87b0b3e0834292cd8cb1fd8a.zip |
Fix bad formula in previous commit.
Commit d5406dea25b600408e7acf17d5a06e82d3ce6d0d 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.
-rw-r--r-- | src/backend/access/common/detoast.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/access/common/detoast.c b/src/backend/access/common/detoast.c index 61d7e64c449..6341107e882 100644 --- a/src/backend/access/common/detoast.c +++ b/src/backend/access/common/detoast.c @@ -443,7 +443,7 @@ toast_fetch_datum(struct varlena *attr) toast_pointer.va_valueid, RelationGetRelationName(toastrel)))); expected_size = curchunk < totalchunks - 1 ? TOAST_MAX_CHUNK_SIZE - : attrsize % TOAST_MAX_CHUNK_SIZE; + : attrsize - ((totalchunks - 1) * TOAST_MAX_CHUNK_SIZE); if (chunksize != expected_size) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), @@ -676,7 +676,7 @@ toast_fetch_datum_slice(struct varlena *attr, int32 sliceoffset, toast_pointer.va_valueid, RelationGetRelationName(toastrel)))); expected_size = curchunk < totalchunks - 1 ? TOAST_MAX_CHUNK_SIZE - : attrsize % TOAST_MAX_CHUNK_SIZE; + : attrsize - ((totalchunks - 1) * TOAST_MAX_CHUNK_SIZE); if (chunksize != expected_size) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), |