Re: So what's null then if it's not nothing?



On Wed, 14 Dec 2005 23:10:28 +0100, Hugo Kornelis
<hugo@xxxxxxxxxxxxxxxxxxxxxx> wrote:

[snip]

>1. Predictability. The NULL propagation is simple - NULLS in, NULLS out,
>without any exceptions. Allowing exceptions means that there will be
>situations where the code does something that the developer didn't
>expect.

But NULL*0 not being zero is also doing that.

>2. Complexity. 'zero times NULL' is easy visible. But it's entirely
>possible to hide the zero-multiplication beyond recognistion. In fact, I
>once had a book with lots of different ways to prove that 1 = 2 and
>similar silly proofs. Most of them used division by zero somewhere in
>the process - but hidden away so cleverly that it took me hours to find
>the culprit. If you allow an exception for 'zero times NULL', you'll
>have to allow an exception for '2 * NULL - 2 * NULL' as well. And for
> EXTRACT(MONTH FROM CURRENT_TIMESTAMP) * NULL -
> NULL * POSITION('lm' IN 'abcdefghijklmno')

No in both cases, because we have no way of knowing whether the
two nulls are denoting the same value.

>There will always be some level of complexity where the DB doesn't
>understand that there a hidden zero multiplication involved. And then
>you're getting REALLY unpredictable resutls!

NULL does that.

>This is what SQL-99 does, but I don't like it. TRUE OR UNKNOWN has to
>evaluate to TRUE, but TRUE OR NULL has to evaluate to NULL, as a result
>of the NULL propagation rule. I know that it's just as illogical as
>defining 0 * NULL to be NULL, but at least it keeps NULL propagation as
>predictable as it currently is.

It is not that predictable. Consider the length of this thread.

Sincerely,

Gene Wirchenko

.



Relevant Pages

  • Re: So whats null then if its not nothing?
    ... The NULL propagation is simple - NULLS in, NULLS out, ... Allowing exceptions means that there will be ... That's why I was reminded of the 'zero * infinity' debate. ...
    (comp.databases.theory)
  • Re: C2124 is most disrespectful of IEEE floating point arithmetic
    ... Treatment of division by zero, forming a remainder using a zero ... For a compile-time expression, ... So depending on our handling of FP exceptions we should see one of two ... we have a compile-time error. ...
    (microsoft.public.vc.language)
  • Re: QA
    ... One problem is this will only detect nulls. ... Currently Using SQL Server 2000, ... "John Spencer" wrote: ... I'm trying to identify Columns that don't have any data (null or zero) ...
    (microsoft.public.access.queries)
  • Re: bitwise operator !!
    ... propagation on right shift by masking in bits as if the sign bit had ... Using / avoids the problem of undefined behavior, ... The shifting method doesn't round towards zero, ...
    (comp.lang.c)
  • Re: 7.0 wishlist?
    ... It also had some flaws in it, ... We're talking about catching bugs closer to their source, in the vast majority of cases. ... Catching 99% of nulls getting into the parts of the system that aren't supposed to have nulls would mean 99% of null-related bugs produced error messages pointing closer to the actual site of the error, which is a touch less than 100% but a heck of a lot more than the present fraction, maybe 50%. ... should also log each of the interims exceptions, ...
    (comp.lang.java.programmer)

Loading