Commit b62033c8 authored by marko's avatar marko

branches/zip: row_merge_tuple_cmp(): Do not report a duplicate key value

if any of the fields are NULL.  While the tuples are equal in the
sorting order, SQL NULL is defined to be logically inequal to
anything else. (Bug #41904)

rb://70 approved by Heikki Tuuri
parent 5a5c6897
...@@ -442,14 +442,29 @@ row_merge_tuple_cmp( ...@@ -442,14 +442,29 @@ row_merge_tuple_cmp(
int cmp; int cmp;
const dfield_t* field = a; const dfield_t* field = a;
/* Compare the fields of the tuples until a difference is
found or we run out of fields to compare. If !cmp at the
end, the tuples are equal. */
do { do {
cmp = cmp_dfield_dfield(a++, b++); cmp = cmp_dfield_dfield(a++, b++);
} while (!cmp && --n_field); } while (!cmp && --n_field);
if (UNIV_UNLIKELY(!cmp) && UNIV_LIKELY_NULL(dup)) { if (UNIV_UNLIKELY(!cmp) && UNIV_LIKELY_NULL(dup)) {
/* Report a duplicate value error if the tuples are
logically equal. NULL columns are logically inequal,
although they are equal in the sorting order. Find
out if any of the fields are NULL. */
for (b = field; b != a; b++) {
if (dfield_is_null(b)) {
goto func_exit;
}
}
row_merge_dup_report(dup, field); row_merge_dup_report(dup, field);
} }
func_exit:
return(cmp); return(cmp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment