Re: report expected contrecord size - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: report expected contrecord size
Date
Msg-id 20200903223308.GA25785@alvherre.pgsql
Whole thread Raw
In response to Re: report expected contrecord size  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: report expected contrecord size  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2020-Sep-03, Tom Lane wrote:

> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> > Well, the intention there is to cast the first operand (which is uint32)
> > so that it turns into signed 64-bits; the subtraction then occurs in 64
> > bit arithmetic normally.  If I let the subtraction occur in 32-bit width
> > unsigned, the result might overflow 32 bits.
> 
> Uh ... is it really possible for gotlen to be more than total_len?
> (I've not looked at the surrounding code here, but that seems weird.)

Well, as I understand, total_len comes from one page, and gotlen comes
from the continuation record(s) in the next page(s) of WAL.  So if
things are messed up, it could happen.  (This *is* the code that
validates the record, so it can't make too many assumptions.)

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: report expected contrecord size
Next
From: Tom Lane
Date:
Subject: Re: report expected contrecord size