More logic (or not)
The short-circuit results obtained above may lead you to the following ideas:
-
0 times
x
equals 0 for everyx
.Hence, even ifx
's value is unknown,0 * x
is 0.(Note: this only holds ifx’s datatype only contains numbers, not `NaN
or infinities.) -
The empty string is ordered lexicographically before every other string.Therefore,
S >= ''
is true whatever the value ofS
. -
Every value equals itself, whether it’s unknown or not.So, although
A = B
justifiably returnsNULL
ifA
andB
are differentNULL
entities,A = A
should always returntrue
, even if A isNULL
.The same goes forA ⇐ A
andA >= A
.By analogous logic,
A <> A
should always befalse
, as well asA < A
andA > A
. -
Every string contains itself, starts with itself and is like itself.So, “
S CONTAINING S
”, “S STARTING WITH S
” and “S LIKE S
” should always returntrue
.
How is this reflected in Firebird SQL?Well, I’m sorry I have to inform you that despite this compelling logic — and the analogy with the boolean results discussed above — the following expressions all resolve to NULL
:
-
0 * NULL
-
NULL >= ''
and'' ⇐ NULL
-
A = A
,A ⇐ A
andA >= A
-
A <> A
,A < A
andA > A
-
S CONTAINING S
,S STARTING WITH S
andS LIKE S
So much for consistency.