summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2021-08-13 16:54:52 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2021-09-05 10:38:12 +0200
commit391f6b4f1ebe4dccfaf0181257aa46edb6253015 (patch)
treeacd4b92512ee8d76d55af6f2ff2225609a93025b
parente835cc851e389770219a33037af65db8887cc9a8 (diff)
downloadmariadb-git-391f6b4f1ebe4dccfaf0181257aa46edb6253015.tar.gz
MDEV-26362: incorrect nest_level value with INTERSECTbb-10.3-MDEV-26362
Add DBUG_ASSERT (should be kept in merge) Fix nest_level assignment in LEX::add_unit_in_brackets (should be ignored in merge to 10.4)
-rw-r--r--sql/sql_base.cc11
-rw-r--r--sql/sql_lex.cc2
2 files changed, 11 insertions, 2 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index f5eb0857d54..dc24ef7f37e 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7513,6 +7513,17 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array,
thd->column_usage= column_usage;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
+ /*
+ Followimg 2 condition always should be true (but they was added
+ due to an error present only in 10.3):
+ 1) nest_level shoud be 0 or positive;
+ 2) nest level of all SELECTs on the same level shoud be equal first
+ SELECT on this level (and each other).
+ */
+ DBUG_ASSERT(thd->lex->current_select->nest_level >= 0);
+ DBUG_ASSERT(thd->lex->current_select->master_unit()->first_select()
+ ->nest_level ==
+ thd->lex->current_select->nest_level);
if (allow_sum_func)
thd->lex->allow_sum_func.set_bit(thd->lex->current_select->nest_level);
thd->where= THD::DEFAULT_WHERE;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 8ee2afc3e00..4fc8ebb5a60 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -5288,7 +5288,6 @@ bool LEX::add_unit_in_brackets(SELECT_LEX *nselect)
DBUG_ASSERT(nselect->outer_select() == dummy_select);
current_select= dummy_select;
- current_select->nest_level--;
SELECT_LEX_UNIT *unit= nselect->master_unit();
Table_ident *ti= new (thd->mem_root) Table_ident(unit);
@@ -5314,7 +5313,6 @@ bool LEX::add_unit_in_brackets(SELECT_LEX *nselect)
derived_tables|= DERIVED_SUBQUERY;
current_select= nselect;
- current_select->nest_level++;
DBUG_RETURN(rc);
}