diff options
author | Sachin <sachinsetia1001@gmail.com> | 2020-09-14 15:27:02 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-11-07 09:50:59 +0100 |
commit | 10132ad26119205e1b53e5d3389bedb71d444201 (patch) | |
tree | 0b48d28cc01c1bb9a5a1503a7d7571cebc67f274 /sql | |
parent | 0d927a57d2bfb32384dd024b9b4d1009fa22555a (diff) | |
download | mariadb-git-10132ad26119205e1b53e5d3389bedb71d444201.tar.gz |
MDEV-23264 Unique blobs allow duplicate values upon UPDATE
Problem:-
We are able to insert duplicate value in table because cmp_binary_offset
is not able to differentiate between NULL and empty string. So
check_duplicate_long_entry_key is never called and we don't check for
duplicate.
Solution
Added a if condition with is_null() on field which can differentiate
between NULL and empty string.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index bf819733b81..5e9c9dc3a71 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6750,8 +6750,13 @@ static int check_duplicate_long_entries_update(TABLE *table, handler *h, uchar * for (uint j= 0; j < key_parts; j++, keypart++) { field= keypart->field; - /* Compare fields if they are different then check for duplicates*/ - if(field->cmp_binary_offset(reclength)) + /* + Compare fields if they are different then check for duplicates + cmp_binary_offset cannot differentiate between null and empty string + So also check for that too + */ + if((field->is_null(0) != field->is_null(reclength)) || + field->cmp_binary_offset(reclength)) { if((error= check_duplicate_long_entry_key(table, table->update_handler, new_rec, i))) |