Re: define pg_structiszero(addr, s, r) - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: define pg_structiszero(addr, s, r)
Date
Msg-id ZzXuECLOduurf4NX@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: define pg_structiszero(addr, s, r)  (Ranier Vilela <ranier.vf@gmail.com>)
List pgsql-hackers
Hi,

On Thu, Nov 14, 2024 at 09:13:19AM -0300, Ranier Vilela wrote:
> Em qui., 14 de nov. de 2024 às 08:58, Bertrand Drouvot <
> Maybe I'm doing something wrong.
> But I'm testing in 32-bit, with the size set to 63, with v12 and I'm seeing
> the SIMD loop execute.

Yeah, that's expected and safe as each iteration reads 32 bytes on 32-bit.

> if (len < sizeof(size_t) * 8) // 8-63 bytes
> failed.
> 
> I expected that with size 63, it would be solved by case 2, or am I wrong?

Case 2 should be read as "in the 4-31" bytes range on 32-bit system as all 
comparisons are done in size_t.

What would be unsafe on 32-bit would be to read up to 32 bytes while len < 32
and that can not happen.

As mentioned up-thread the comments are wrong on 32-bit, indeed they must be read
as:

Case 1: len < 4 bytes
Case 2: len in the 4-31 bytes range
Case 3: len >= 32 bytes

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: SQL:2023 JSON simplified accessor support
Next
From: Alvaro Herrera
Date:
Subject: Re: Difference in dump from original and restored database due to NOT NULL constraints on children