← Back to team overview

maria-developers team mailing list archive

Re: [Commits] 01b2bb79bb78e42108e32af02f1418a660ca861d Fixed the bug mdev-13064.

 

Hi, Igor!

Am 15.06.2017 um 23:43 schrieb Igor Babaev:
commit 01b2bb79bb78e42108e32af02f1418a660ca861d
Author: Igor Babaev <igor@xxxxxxxxxxxx>
Commit: Igor Babaev <igor@xxxxxxxxxxxx>

     Fixed the bug mdev-13064.
This is another attempt to fix the bug mdev-12992.
     This patch introduces st_select_lex::context_analysis_place for
     the place in SELECT where context analysis is currently performed.
     It's similar to st_select_lex::parsing_place, but it is used at

It is OK to push.

     the preparation stage.
---
  mysql-test/r/func_group.result |    9 +++++++++
  mysql-test/t/func_group.test   |   13 +++++++++++++
  sql/item.cc                    |    5 ++---
  sql/item_windowfunc.cc         |    2 +-
  sql/sql_lex.h                  |    1 +
  sql/sql_select.cc              |   33 ++++++++++++++++++---------------
  6 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index cb97ea2..c4e991e 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -2447,3 +2447,12 @@ DROP TABLE t1;
  #
  # End of 10.1 tests
  #
+#
+# MDEV-13064: assertion `n < m_size' fails in Item::split_sum_func2()
+#
+create table t1 (i int) engine=MyISAM;
+insert into t1 value (1),(2);
+select count(*)+sleep(0) from t1;
+count(*)+sleep(0)
+2
+drop table t1;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 1e75099..8bbc9e6 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -1691,3 +1691,16 @@ DROP TABLE t1;
  --echo #
  --echo # End of 10.1 tests
  --echo #
+
+--echo #
+--echo # MDEV-13064: assertion `n < m_size' fails in Item::split_sum_func2()
+--echo #
+
+create table t1 (i int) engine=MyISAM;
+insert into t1 value (1),(2);
+
+select count(*)+sleep(0) from t1;
+
+drop table t1;
+
+
diff --git a/sql/item.cc b/sql/item.cc
index 8db5cfc..df615b5 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -490,8 +490,7 @@ int Item::save_str_value_in_field(Field *field, String *result)
      command => we should check thd->lex->current_select on zero (thd->lex
      can be uninitialised)
    */
-  if (thd->lex->current_select &&
-      thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
+  if (thd->lex->current_select)
    {
      enum_parsing_place place=
        thd->lex->current_select->parsing_place;
@@ -5513,7 +5512,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
SELECT_LEX *select= thd->lex->current_select;
              thd->change_item_tree(reference,
-                                  select->parsing_place == IN_GROUP_BY &&
+                                  select->context_analysis_place == IN_GROUP_BY &&
  				  alias_name_used  ?  *rf->ref : rf);
/*
diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc
index 59a22c6..27b0072 100644
--- a/sql/item_windowfunc.cc
+++ b/sql/item_windowfunc.cc
@@ -71,7 +71,7 @@
  {
    DBUG_ASSERT(fixed == 0);
- enum_parsing_place place= thd->lex->current_select->parsing_place;
+  enum_parsing_place place= thd->lex->current_select->context_analysis_place;
if (!(place == SELECT_LIST || place == IN_ORDER_BY))
    {
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index face3bc..0c55ffc 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -855,6 +855,7 @@ class st_select_lex: public st_select_lex_node
    /* reserved for exists 2 in */
    uint select_n_reserved;
    enum_parsing_place parsing_place; /* where we are parsing expression */
+  enum_parsing_place context_analysis_place; /* where we are in prepare */
    bool with_sum_func;   /* sum function indicator */
ulong table_join_options;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 4c64cf2..6c56f01 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -648,17 +648,15 @@ void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex)
thd->lex->allow_sum_func|= (nesting_map)1 << select->nest_level; - save_place= thd->lex->current_select->parsing_place;
-  thd->lex->current_select->parsing_place= IN_ORDER_BY;
+  save_place= thd->lex->current_select->context_analysis_place;
+  thd->lex->current_select->context_analysis_place= IN_ORDER_BY;
    res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields,
                            order);
-  thd->lex->current_select->parsing_place= save_place;
-   thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level);
-  save_place= thd->lex->current_select->parsing_place;
-  thd->lex->current_select->parsing_place= IN_GROUP_BY;
+  thd->lex->allow_sum_func&= ~((nesting_map)1 << select->nest_level);
+  thd->lex->current_select->context_analysis_place= IN_GROUP_BY;
    res= res || setup_group(thd, ref_pointer_array, tables, fields, all_fields,
                            group, hidden_group_fields);
-  thd->lex->current_select->parsing_place= save_place;
+  thd->lex->current_select->context_analysis_place= save_place;
    thd->lex->allow_sum_func|= (nesting_map)1 << select->nest_level;
    res= res || setup_windows(thd, ref_pointer_array, tables, fields, all_fields,
                              win_specs, win_funcs);
@@ -712,6 +710,7 @@ void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex)
    if (select_lex->handle_derived(thd->lex, DT_PREPARE))
      DBUG_RETURN(1);
+ thd->lex->current_select->context_analysis_place= NO_MATTER;
    thd->lex->current_select->is_item_list_lookup= 1;
    /*
      If we have already executed SELECT, then it have not sense to prevent
@@ -801,12 +800,13 @@ void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex)
ref_ptrs= ref_ptr_array_slice(0); - enum_parsing_place save_place= thd->lex->current_select->parsing_place;
-  thd->lex->current_select->parsing_place= SELECT_LIST;
+  enum_parsing_place save_place=
+                     thd->lex->current_select->context_analysis_place;
+  thd->lex->current_select->context_analysis_place= SELECT_LIST;
    if (setup_fields(thd, ref_ptrs, fields_list, MARK_COLUMNS_READ,
                     &all_fields, 1))
      DBUG_RETURN(-1);
-  thd->lex->current_select->parsing_place= save_place;
+  thd->lex->current_select->context_analysis_place= save_place;
if (setup_without_group(thd, ref_ptrs, tables_list,
                            select_lex->leaf_tables, fields_list,
@@ -22235,14 +22235,16 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
  		List<Item> &fields, List<Item> &all_fields, ORDER *order,
                  bool from_window_spec)
  {
-  enum_parsing_place parsing_place= thd->lex->current_select->parsing_place;
+  enum_parsing_place context_analysis_place=
+                     thd->lex->current_select->context_analysis_place;
    thd->where="order clause";
    for (; order; order=order->next)
    {
      if (find_order_in_list(thd, ref_pointer_array, tables, order, fields,
  			   all_fields, FALSE, from_window_spec))
        return 1;
-    if ((*order->item)->with_window_func && parsing_place != IN_ORDER_BY)
+    if ((*order->item)->with_window_func &&
+        context_analysis_place != IN_ORDER_BY)
      {
        my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0));
        return 1;
@@ -22284,7 +22286,8 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
  	    List<Item> &fields, List<Item> &all_fields, ORDER *order,
  	    bool *hidden_group_fields, bool from_window_spec)
  {
-  enum_parsing_place parsing_place= thd->lex->current_select->parsing_place;
+  enum_parsing_place context_analysis_place=
+                     thd->lex->current_select->context_analysis_place;
    *hidden_group_fields=0;
    ORDER *ord;
@@ -22300,14 +22303,14 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables,
  			   all_fields, TRUE, from_window_spec))
        return 1;
      (*ord->item)->marker= UNDEF_POS;		/* Mark found */
-    if ((*ord->item)->with_sum_func && parsing_place == IN_GROUP_BY)
+    if ((*ord->item)->with_sum_func && context_analysis_place == IN_GROUP_BY)
      {
        my_error(ER_WRONG_GROUP_FIELD, MYF(0), (*ord->item)->full_name());
        return 1;
      }
      if ((*ord->item)->with_window_func)
      {
-      if (parsing_place == IN_GROUP_BY)
+      if (context_analysis_place == IN_GROUP_BY)
          my_error(ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION, MYF(0));
        else
          my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0));
_______________________________________________
commits mailing list
commits@xxxxxxxxxxx
https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits