Re: [PATCH] Fix INT_MIN % -1 overflow in int8mod().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Xi Wang <xi(dot)wang(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Fix INT_MIN % -1 overflow in int8mod().
Date: 2012-11-14 21:46:38
Message-ID: 26733.1352929598@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Xi Wang <xi(dot)wang(at)gmail(dot)com> writes:
> Return 0 for INT_MIN % -1 (64-bit) instead of throwing an exception.
> This patch complements commit f9ac414c that fixed int4mod().

Meh. I didn't care for the explicit dependency on INT_MIN in the
previous patch, and I like introducing INT64_MIN even less. I think
we should be able to reduce the test to just

if (arg2 == -1)
return 0;

since zero is the correct result for any value of arg1, not only
INT_MIN.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Xi Wang 2012-11-14 21:54:46 Re: [PATCH] Fix INT_MIN % -1 overflow in int8mod().
Previous Message Peter Geoghegan 2012-11-14 20:44:26 Doc patch making firm recommendation for setting the value of commit_delay