Re: Remove dependence on integer wrapping

From: Joseph Koshakow <koshy44(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Matthew Kim <matthewkmkim(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Remove dependence on integer wrapping
Date: 2024-08-10 15:41:31
Message-ID: CAAvxfHfuxiMG4_YB5oBmJtK7mQx6FRKcUhNueXGwKT6_r=4W_Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 8, 2024 at 9:01 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> Should the error about integers be out of range?
>
> SELECT make_date(-2147483648, 1, 1);
> "-2147483648" is not an allowed integer.
>
> \df make_date
> List of functions
> Schema | Name | Result data type | Argument data
> types | Type
>
------------+-----------+------------------+------------------------------------------+------
> pg_catalog | make_date | date | year integer, month
> integer, day integer | func

Are you saying that with the patch applied you're seeing the above
error? If so, I see a different error.

test=# SELECT make_date(-2147483648, 1, 1);
ERROR: date field value out of range

Or are you saying that we should change the code in the patch so that
it returns the above error? If so, I'm not sure I understand the
reasoning. -2147483648 is an allowed integer, it's the minimum allowed
value for integers.

test=# SELECT (-2147483648)::integer;
int4
-------------
-2147483648
(1 row)

Thanks,
Joseph Koshakow

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2024-08-10 15:43:59 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message Nathan Bossart 2024-08-10 15:35:46 Re: optimizing pg_upgrade's once-in-each-database steps