summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-11-01 15:23:18 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-11-01 15:23:18 +0200
commitec40980ddd921a3a765c23cc430c9c219e48ea85 (patch)
tree6553832d3d3fb4b2cb39aea6a1d69e54275f6eb2 /sql/opt_subselect.cc
parent6801f80aface011811d2978f86c03a25ca7b9165 (diff)
parent9c72963d2aef783cae652b5b8ac01f7aa2bcb43a (diff)
downloadmariadb-git-ec40980ddd921a3a765c23cc430c9c219e48ea85.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc12
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;
}