Minimize footprint of TOAST_MAX_CHUNK_SIZE in heap and amcheck code

This refactoring eases a little bit a follow-up change to add support
for 8-byte TOAST value IDs, as the maximum chunk size allowed for a
single chunk of TOASTed data depends on the size of varatt_external, its
value ID being part of it.

It is worth noting that TOAST_MAX_CHUNK_SIZE resolves as a uintptr_t, so
the previous calculations were in 64-bit unsigned arithmetic.  These are
now done in int32, which still works the same way due to an external
TOAST value being bounded to 1GB.

Author: Michael Paquier <[email protected]>
Reviewed-by: Yugo Nagata <[email protected]>
Reviewed-by: Bharath Rupireddy <[email protected]>
Discussion: 
https://postgr.es/m/CALj2ACVnO6jjs5aRx3dSOBy9LV7=iakpbr1eovoeb8rl8q4...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2b3d11aaed891958f24aed05bf454524d603b6ea

Modified Files
--------------
contrib/amcheck/verify_heapam.c     | 13 +++++++++----
src/backend/access/heap/heaptoast.c | 20 ++++++++++++--------
2 files changed, 21 insertions(+), 12 deletions(-)

Reply via email to