diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2020-11-09 18:47:55 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2020-11-09 19:29:21 +0300 |
commit | f81eef62e7742806e5e74b5f37f35b7cd2f82291 (patch) | |
tree | 23f0e571625f01d1d42ded5221727ac09e5b184a /sql/opt_range.cc | |
parent | 2845b656a3ed058bc424ca371760fb17b2a28703 (diff) | |
download | mariadb-git-f81eef62e7742806e5e74b5f37f35b7cd2f82291.tar.gz |
MDEV-24117: Memory management problem in statistics state for ... IN
Part#1: Revert the patch that caused it:
commit 291be494744abe90f4bdf6b5a35c4c26ee8ddda5
Author: Igor Babaev <igor@askmonty.org>
Date: Thu Sep 24 22:02:00 2020 -0700
MDEV-23811: With large number of indexes optimizer chooses an inefficient plan
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index cd58202ef5f..e933d2af355 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1852,9 +1852,6 @@ SEL_ARG::SEL_ARG(SEL_ARG &arg) :Sql_alloc() next_key_part=arg.next_key_part; max_part_no= arg.max_part_no; use_count=1; elements=1; - next= 0; - if (next_key_part) - ++next_key_part->use_count; } @@ -8872,15 +8869,9 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) } bool no_imerge_from_ranges= FALSE; - SEL_TREE *rt1= tree1; - SEL_TREE *rt2= tree2; /* Build the range part of the tree for the formula (1) */ if (sel_trees_can_be_ored(param, tree1, tree2, &ored_keys)) { - if (no_merges1) - rt1= new SEL_TREE(tree1, TRUE, param); - if (no_merges2) - rt2= new SEL_TREE(tree2, TRUE, param); bool must_be_ored= sel_trees_must_be_ored(param, tree1, tree2, ored_keys); no_imerge_from_ranges= must_be_ored; @@ -8938,6 +8929,12 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) else if (!no_ranges1 && !no_ranges2 && !no_imerge_from_ranges) { /* Build the imerge part of the tree for the formula (1) */ + SEL_TREE *rt1= tree1; + SEL_TREE *rt2= tree2; + if (no_merges1) + rt1= new SEL_TREE(tree1, TRUE, param); + if (no_merges2) + rt2= new SEL_TREE(tree2, TRUE, param); if (!rt1 || !rt2 || result->merges.push_back(imerge_from_ranges) || imerge_from_ranges->or_sel_tree(param, rt1) || @@ -9600,11 +9597,10 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2) if (!tmp->next_key_part) { - SEL_ARG *key2_next= key2->next; if (key2->use_count) { SEL_ARG *key2_cpy= new SEL_ARG(*key2); - if (!key2_cpy) + if (key2_cpy) return 0; key2= key2_cpy; } @@ -9625,7 +9621,7 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2) Move on to next range in key2 */ key2->increment_use_count(-1); // Free not used tree - key2=key2_next; + key2=key2->next; continue; } else |