From 7a30af3eb03f702538a9f30cdb11b4e925a27ecf Mon Sep 17 00:00:00 2001 From: marko <> Date: Wed, 7 Jan 2009 14:17:47 +0000 Subject: [PATCH] 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 --- row/row0merge.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/row/row0merge.c b/row/row0merge.c index 9958f934f70..6f0b9a65acb 100644 --- a/row/row0merge.c +++ b/row/row0merge.c @@ -442,14 +442,29 @@ row_merge_tuple_cmp( int cmp; 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 { cmp = cmp_dfield_dfield(a++, b++); } while (!cmp && --n_field); 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); } +func_exit: return(cmp); }