. , , =, , .
, ( comparators Arg_comparator::set_compare_func , ).
int Arg_comparator::compare_row()
{
int res= 0;
bool was_null= 0;
(*a)->bring_value();
(*b)->bring_value();
if ((*a)->null_value || (*b)->null_value)
{
owner->null_value= 1;
return -1;
}
uint n= (*a)->cols();
for (uint i= 0; i<n; i++)
{
res= comparators[i].compare();
if (owner->null_value && owner->type() == Item::FUNC_ITEM)
{
switch (((Item_func*)owner)->functype()) {
case Item_func::NE_FUNC:
break;
case Item_func::LT_FUNC:
case Item_func::LE_FUNC:
case Item_func::GT_FUNC:
case Item_func::GE_FUNC:
return -1;
default:
if (((Item_bool_func2*)owner)->abort_on_null)
return -1;
}
was_null= 1;
owner->null_value= 0;
res= 0;
}
else if (res)
return res;
}
if (was_null)
{
owner->null_value= 1;
return -1;
}
return 0;
}
, . - , . - null, , , !=.
, . , true, unknown.
SELECT (1,2) <> (1,2),
(1,NULL,2) <> (1,NULL,2),
(1,NULL,2) <> (1,NULL,3)
FROM dual
+----------------+--------------------------+--------------------------+
| (1,2) <> (1,2) | (1,NULL,2) <> (1,NULL,2) | (1,NULL,2) <> (1,NULL,3) |
+----------------+--------------------------+--------------------------+
| 0 | NULL | 1 |
+----------------+--------------------------+--------------------------+
null, 0, , .