From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Eric B(dot) Ridge" <ebr(at)tcdi(dot)com>, <pgsql-general(at)postgresql(dot)org>, <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: division by zero |
Date: | 2003-03-08 19:28:24 |
Message-ID: | 20030308111114.O8453-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Sat, 8 Mar 2003, Tom Lane wrote:
> "Eric B. Ridge" <ebr(at)tcdi(dot)com> writes:
> > select 1/0; fails as expected on my x86 Linux box, so yer right, it's
> > just my little Mac. "I switched because Mac's can divide by zero."
>
> I checked into this, and indeed OS X 10.2 is behaving funny: integer
> divide by zero doesn't raise any signal, it just returns a bogus answer.
> They're within their rights to do so according to the ANSI C spec
> (wherein division by zero is stated to have undefined behavior).
> But since other BSD-derived Unixen all seem to raise SIGFPE, I can't
> help wondering if this shouldn't be considered a bug.
>
> I think we have three possible responses:
>
> 1. Put explicit tests for zero into the integer division SQL function
> routines.
>
> 2. Consider this Apple's problem and file a bug report.
>
> 3. Both.
>
> I don't care for answer #1 alone, because it would only catch zero
> divides in the specific places we put in tests; internal errors would
> likely go uncaught. So I think a complaint to Apple is in order.
> I'm not sure whether to also put in zero-divide guards. Comments?
We probably should put in guards since relying on sane behavior for
division by zero is probably unsafe from a portability standpoint. This
could hide some internal error on a system that has this problem (since we
could otherwise put it into a regression test) but those systems are
currently broken if the internal error occurs anyway.
From | Date | Subject | |
---|---|---|---|
Next Message | Matt Johnson | 2003-03-08 19:51:16 | cross tab confusion |
Previous Message | Bruce Momjian | 2003-03-08 19:20:52 | Re: My contract has been renewed |
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2003-03-08 19:46:34 | Re: regression failure in CVS HEAD |
Previous Message | Bruce Momjian | 2003-03-08 19:20:52 | Re: My contract has been renewed |