On Sun, 28 Jul 2024 at 16:30, Joseph Koshakow wrote:
> Attached is an updated patch with your approach. I removed the 0 from
> the negative case because I think it was unnecessary, but happy to add
> it back in if I missed something.
I made a few adjustments and pushed this. I did keep the 0 - p
On Sat, Jul 27, 2024 at 11:42 PM David Rowley wrote:
>
> I didn't test to see where that's coming from, but I did test the two
> attached .c files. int.c uses the 0 - (unsigned int) var method and
> int2.c uses (unsigned int) (-var). Using clang and -ftrapv, I get:
>
> $ clang int.c -o int -O2 -
On Sun, 28 Jul 2024 at 13:10, Joseph Koshakow wrote:
>
> On Sat, Jul 27, 2024 at 8:00 PM David Rowley wrote:
> > What if we spelt it out the same way as pg_lltoa() does?
> >
> > i.e: uint64 usize = size < 0 ? 0 - (uint64) size : (uint64) size;
>
> My understanding of pg_lltoa() is that it produce
On Sat, Jul 27, 2024 at 8:00 PM David Rowley wrote:
>
> On Sun, 28 Jul 2024 at 11:06, Joseph Koshakow wrote:
>> > + uint64 usize = size < 0 ? (uint64) (-size) : (uint64) size;
>>
>> I think that the explicit test for PG_INT64_MIN is still required. If
>> `size` is equal to PG_INT64_MIN then `-siz
On Sun, 28 Jul 2024 at 11:06, Joseph Koshakow wrote:
> > + uint64 usize = size < 0 ? (uint64) (-size) : (uint64) size;
>
> I think that the explicit test for PG_INT64_MIN is still required. If
> `size` is equal to PG_INT64_MIN then `-size` will overflow. You end up
> with the correct behavior if `
On Sat, Jul 27, 2024 at 6:28 PM David Rowley wrote:
>
> On Sun, 28 Jul 2024 at 07:18, Joseph Koshakow wrote:
>> Attached is a patch that resolves an overflow in pg_size_pretty() that
>> resulted in unexpected behavior when PG_INT64_MIN was passed in as an
>> argument.
>
> Could we just fix this m
On Sun, 28 Jul 2024 at 07:18, Joseph Koshakow wrote:
> Attached is a patch that resolves an overflow in pg_size_pretty() that
> resulted in unexpected behavior when PG_INT64_MIN was passed in as an
> argument.
Could we just fix this more simply by assigning the absolute value of
the signed variab
On Sat, Jul 27, 2024 at 3:18 PM Joseph Koshakow wrote:
>
> `SELECT -9223372036854775808::bigint` results in an out of range error,
> even though `-9223372036854775808` can fit in a `bigint` and
> `SELECT pg_typeof(-9223372036854775808)` returns `bigint`. That's why
> the `::bigint` cast is omitted