Re: Remove dependence on integer wrapping - Mailing list pgsql-hackers

From jian he
Subject Re: Remove dependence on integer wrapping
Date
Msg-id CACJufxFUKTQx8wUpxtRPT31D+a7fNxAL_A_-S4XaR-oZkKEgxA@mail.gmail.com
Whole thread Raw
In response to Re: Remove dependence on integer wrapping  (Joseph Koshakow <koshy44@gmail.com>)
Responses Re: Remove dependence on integer wrapping
List pgsql-hackers
On Sat, Aug 10, 2024 at 11:41 PM Joseph Koshakow <koshy44@gmail.com> wrote:
>
>
>
> On Thu, Aug 8, 2024 at 9:01 PM jian he <jian.universality@gmail.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)
>

sorry, i mixed up
select (-2147483648)::int;
with
select -2147483648::int;

looks good to me.
maybe make it more explicit:
errmsg("date field (year) value out of range")));
i don't have a huge opinion though.



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: minor comments issue in ResultRelInfo src/include/nodes/execnodes.h
Next
From: Bertrand Drouvot
Date:
Subject: Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state