diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-11-05 16:15:20 +0100 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-07 08:52:30 +0100 |
commit | 3ad37ed0eb343cd173b103974aded5783958a88e (patch) | |
tree | f4ff854553d26a9e7d57791e7d671d4349a58d2d /sql/opt_subselect.cc | |
parent | 46f2f24ec43e9c1fa2d994afd615f58736c00d65 (diff) | |
parent | 0339cbe2f628f8a122ba7ea3a75fc99fa1dc4c96 (diff) | |
download | mariadb-git-3ad37ed0eb343cd173b103974aded5783958a88e.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index eeefe4200da..484836af23e 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -2681,9 +2681,17 @@ bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables) { do /* For all equalities on all key parts */ { - /* Check if this is "t.keypart = expr(outer_tables) */ + /* + Check if this is "t.keypart = expr(outer_tables) + + Don't allow variants that can produce duplicates: + - Dont allow "ref or null" + - the keyuse (that is, the operation) must be null-rejecting, + unless the other expression is non-NULLable. + */ if (!(keyuse->used_tables & sj_inner_tables) && - !(keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL)) + !(keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL) && + (keyuse->null_rejecting || !keyuse->val->maybe_null)) { bound_parts |= 1 << keyuse->keypart; } |