diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-01 15:23:18 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-01 15:23:18 +0200 |
commit | ec40980ddd921a3a765c23cc430c9c219e48ea85 (patch) | |
tree | 6553832d3d3fb4b2cb39aea6a1d69e54275f6eb2 /sql/opt_subselect.cc | |
parent | 6801f80aface011811d2978f86c03a25ca7b9165 (diff) | |
parent | 9c72963d2aef783cae652b5b8ac01f7aa2bcb43a (diff) | |
download | mariadb-git-ec40980ddd921a3a765c23cc430c9c219e48ea85.tar.gz |
Merge 10.3 into 10.4
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 c51f5a1a6e2..f0d6fc74242 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; } |