summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2022-10-03 14:21:26 +0300
committerSergei Petrunia <sergey@mariadb.com>2023-02-02 23:57:43 +0300
commit99db92f61807054b6072c523744c8ab512fa4ff2 (patch)
tree32ad178a3edecbbb2e44e98954cc3a014337351c /sql/item.cc
parentd9d0e78039fd3fbeac814edd27fabfe3e4450bc5 (diff)
downloadmariadb-git-99db92f61807054b6072c523744c8ab512fa4ff2.tar.gz
Indexes where not used for sorting in sub queries
This happens when the subquery marks some index fields as constant but the fields are still present in GROUP BY Fixed by checking if the 'constant field' is still part of GROUP BY before skipping it. Other things: - Added Item_field::contains() to make it easier to check if a field is equal to a Item_field or part of Item_equal.
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 5bcddb5cd67..aa0553228b3 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -6348,6 +6348,24 @@ Item_equal *Item_field::find_item_equal(COND_EQUAL *cond_equal)
}
+/*
+ Check if field is is equal to current field or any of the fields in
+ item_equal
+*/
+
+bool Item_field::contains(Field *field_arg)
+{
+ if (field == field_arg)
+ return 1;
+ /*
+ Check if there is a multiple equality that allows to infer that field
+ (see also: compute_part_of_sort_key_for_equals)
+ */
+ if (item_equal && item_equal->contains(field_arg))
+ return 1;
+ return 0;
+}
+
/**
Set a pointer to the multiple equality the field reference belongs to
(if any).