More logic (or not)
The short-circuit results obtained above may lead you to the following ideas:
-
0 times
xequals 0 for everyx.Hence, even ifx's value is unknown,0 * xis 0.(Note: this only holds ifx’s datatype only contains numbers, not `NaNor 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 = Bjustifiably returnsNULLifAandBare differentNULLentities,A = Ashould always returntrue, even if A isNULL.The same goes forA ⇐ AandA >= A.By analogous logic,
A <> Ashould always befalse, as well asA < AandA > 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 ⇐ AandA >= A -
A <> A,A < AandA > A -
S CONTAINING S,S STARTING WITH SandS LIKE S
So much for consistency.