summaryrefslogtreecommitdiff
path: root/sql/opt_split.cc
diff options
context:
space:
mode:
authorVarun Gupta <varunraiko1803@gmail.com>2018-04-30 13:05:01 +0530
committerVarun Gupta <varunraiko1803@gmail.com>2018-05-06 23:05:37 +0530
commit724ab9a1cb7b23ba93ca5df77f631b5c565f3059 (patch)
tree0b52669af7d518a3ca9796bc6b2e75ea0ecd8923 /sql/opt_split.cc
parent0bfd45f63419c45b68448cbd210a6e73e5c1ab34 (diff)
downloadmariadb-git-724ab9a1cb7b23ba93ca5df77f631b5c565f3059.tar.gz
MDEV-16057: Using optimization Splitting with Group BY we see an unnecessary attached condition
t1.pk IS NOT NULL where pk is a PRIMARY KEY For equalites in the WHERE clause we create a keyuse array that contains the set of all equalities. For each KEYUSE inside the keyuse array we have a field "null_rejecting" which tells that the equality will not hold if either the left or right hand side of the equality is NULL. If the equality is NULL rejecting then we accordingly add a NOT NULL condition for the field present in the item val(present in the KEYUSE struct) when we are doing ref access. For the optimization of splitting with GROUP BY we always set the null_rejecting to TRUE and we are doing ref access on the GROUP by field. This does create a problem when the equality is NOT NULL rejecting. This happens in this case as in the equality we have the right hand side as t1.pk where pk is a PRIMARY KEY , hence it is NOT NULLABLE. So we should have null rejecting set to FALSE for such a case.
Diffstat (limited to 'sql/opt_split.cc')
-rw-r--r--sql/opt_split.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index b81556e56a2..37853bdbbe9 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -544,7 +544,14 @@ void TABLE::add_splitting_info_for_key_field(KEY_FIELD *key_field)
added_key_field->level= 0;
added_key_field->optimize= KEY_OPTIMIZE_EQ;
added_key_field->eq_func= true;
- added_key_field->null_rejecting= true;
+
+ Item *real= key_field->val->real_item();
+ if ((real->type() == Item::FIELD_ITEM) &&
+ ((Item_field*)real)->field->maybe_null())
+ added_key_field->null_rejecting= true;
+ else
+ added_key_field->null_rejecting= false;
+
added_key_field->cond_guard= NULL;
added_key_field->sj_pred_no= UINT_MAX;
return;