From: Christoph Berg <myon@debian.org>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-committers <pgsql-hackers@postgresql.org>
Subject: Re: pgsql: Provide overflow safe integer math inline functions.
Date: Thu, 14 Dec 2017 09:28:08 +0100
Message-ID: <20171214082808.GA5775@msg.df7cb.de> (raw)
In-Reply-To: <20171213173524.rjs7b3ahsong5zko@alap3.anarazel.de>
References: <E1eOvQF-00075r-Cy@gemulon.postgresql.org>
<20171213101037.GA28753@msg.df7cb.de>
<CA+TgmoaBj4vDrbGK15mf-nvQ6N=fD7SBJSFr0Vi6Edoy0x2E3g@mail.gmail.com>
<20171213173524.rjs7b3ahsong5zko@alap3.anarazel.de>
Re: Andres Freund 2017-12-13 <20171213173524.rjs7b3ahsong5zko@alap3.anarazel.de>
> On 2017-12-13 09:37:25 -0500, Robert Haas wrote:
> > On Wed, Dec 13, 2017 at 5:10 AM, Christoph Berg <myon@debian.org> wrote:
> > > Re: Andres Freund 2017-12-13 <E1eOvQF-00075r-Cy@gemulon.postgresql.org>
> > >> Provide overflow safe integer math inline functions.
> > >
> > > The new _overflow functions have buggy comments:
> > >
> > > /*
> > > * If a - b overflows, return true, otherwise store the result of a + b into
> > > * *result. ^ there
> >
> > What's wrong with that?
>
> After staring at it for a while, I seem to have partially mis-copied the
> note for addition to the subtraction operation...
I believe the attached is the correct version.
Christoph
Attachments:int.h-comments (text/plain, 2.9K) downloaddiff --git a/src/include/common/int.h b/src/include/common/int.hnew file mode 100644index e44d42f..e6907c6
*** a/src/include/common/int.h
--- b/src/include/common/int.h
*************** pg_add_s16_overflow(int16 a, int16 b, in
*** 41,47 ****
}
/*
! * If a - b overflows, return true, otherwise store the result of a + b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
--- 41,47 ----
}
/*
! * If a - b overflows, return true, otherwise store the result of a - b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
*************** pg_sub_s16_overflow(int16 a, int16 b, in
*** 61,67 ****
}
/*
! * If a * b overflows, return true, otherwise store the result of a + b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
--- 61,67 ----
}
/*
! * If a * b overflows, return true, otherwise store the result of a * b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
*************** pg_add_s32_overflow(int32 a, int32 b, in
*** 101,107 ****
}
/*
! * If a - b overflows, return true, otherwise store the result of a + b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
--- 101,107 ----
}
/*
! * If a - b overflows, return true, otherwise store the result of a - b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
*************** pg_sub_s32_overflow(int32 a, int32 b, in
*** 121,127 ****
}
/*
! * If a * b overflows, return true, otherwise store the result of a + b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
--- 121,127 ----
}
/*
! * If a * b overflows, return true, otherwise store the result of a * b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
*************** pg_add_s64_overflow(int64 a, int64 b, in
*** 167,173 ****
}
/*
! * If a - b overflows, return true, otherwise store the result of a + b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
--- 167,173 ----
}
/*
! * If a - b overflows, return true, otherwise store the result of a - b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
*************** pg_sub_s64_overflow(int64 a, int64 b, in
*** 193,199 ****
}
/*
! * If a * b overflows, return true, otherwise store the result of a + b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
--- 193,199 ----
}
/*
! * If a * b overflows, return true, otherwise store the result of a * b into
* *result. The content of *result is implementation defined in case of
* overflow.
*/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: myon@debian.org, andres@anarazel.de, pgsql-hackers@postgresql.org
Subject: Re: pgsql: Provide overflow safe integer math inline functions.
In-Reply-To: <20171214082808.GA5775@msg.df7cb.de>
References: <E1eOvQF-00075r-Cy@gemulon.postgresql.org> <20171213101037.GA28753@msg.df7cb.de> <CA+TgmoaBj4vDrbGK15mf-nvQ6N=fD7SBJSFr0Vi6Edoy0x2E3g@mail.gmail.com> <20171213173524.rjs7b3ahsong5zko@alap3.anarazel.de> <20171214082808.GA5775@msg.df7cb.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox