On Mon, 15 Sep 2014 21:13:01 +0100
Simon Slavin <slav...@bigfraud.org> wrote:

> > I suppose we then get into a discussion of what is the 'correct
> > result'. I completely understand that NULL is unknown, but I've
> > always thought that there is a difference between unknown and
> > 'error'.
> 
> It is not an error to divide things by zero as long as that's what
> you meant to do.  An error would be to divide by 6 when you meant to
> divide by zero.

Whether or not something "is an error" is a matter of definition.
SQLite defines division by zero to be NULL.  It's very unusual in that
regard.  It's also unhelpful because the NULL can mask an error in the
data or logic.  I hope SQL 4.0 will define it as an error instead.  

> Ask a mathematician.  They didn't stop at school but they still don't
> have a good answer.  It's a way of avoiding the problem.  

It's not a problem in any sense.  It's known to be undefined.  

http://mathworld.wolfram.com/DivisionbyZero.html

Some operations in math are undefined.  It's not cop-out; it's an
example of a meaningless expression that the syntax happens to
permit.  "Colorless green ideas sleep furiously."  George Carlin's line,
"Hand me the piano", might be a better example because "piano" is not
among the things that can be "handed" by most people.  

Functions in math are defined on a domain and -- what else? --
*undefined* outside that domain.  You can't get the circumference of a
cube or the slope of a curve.  You can't multiply nonconformable
matrices.  Division by zero stands out because it's so primitive that
the arithmetic unit has to cope with it.  

Part of SQLite's success derives from the care it takes with backward
compatibility, and I appreciate "it has always been thus" will
sometimes mean, "thus it will always be".  Progress requires change,
though.  One useful guideline for introducing "new" errors might be,
are the function's preconditions met?  Also known as, "do the inputs
belong to the domain on which the function is defined?"  

--jkl
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to