• unknown's avatar
    Clumsy but working fix for bug #11973 "SELECT .. INTO var_name; in trigger · 61a68ed6
    unknown authored
    cause crash on update".
    
    Let us update "thd" pointer in LEX, all its units and in LEX::result before
    executing statement in trigger body, since triggers are associated with TABLE
    object and because of this can be used in different threads.
    
    
    mysql-test/r/trigger.result:
      Added test case for bug #11973 "SELECT .. INTO var_name; in trigger cause
      crash on update".
    mysql-test/t/trigger.test:
      Added test case for bug #11973 "SELECT .. INTO var_name; in trigger cause
      crash on update".
    sql/item_subselect.cc:
      subselect_engine:
        Moved implementation of set_thd() method to item_subselect.cc,
        since now it also sets "thd" for subselect_engine::result.
    sql/item_subselect.h:
      subselect_engine:
        Moved implementation of set_thd() method to item_subselect.cc,
        since now it also sets "thd" for subselect_engine::result.
    sql/sql_class.h:
      select_result:
        Added set_thd() method for updating select_result::thd value (we need this
        in cases when statement to which this select_result belongs will be used
        in different threads, as it happens for statements in trigger body).
      multi_delete/multi_update:
        Got rid of redundant "thd" member (we already have it in select_result).
    sql/sql_delete.cc:
      multi_delete:
        Got rid of redundant "thd" member (we already have it in select_result).
    sql/sql_lex.h:
      st_select_lex_unit:
        Added set_thd() method for updating st_select_lex_unit::thd value
        (we need this in cases when statement to which this unit belongs will
         be used in different threads, as it happens for statements in trigger body).
        We don't update thd of select_result pointed by st_select_lex_unit::result
        in this method, since it is either have too short lifetime (i.e. created for
        each execution) or is accessible via Item_subquery or LEX::result and thus
        already taken care of.
    sql/sql_parse.cc:
      multi_delete:
        Got rid of redundant "thd" member (we already have it in select_result).
    sql/sql_prepare.cc:
      reinit_stmt_before_use():
        We have to update "thd" pointer in LEX, all its units and in LEX::result,
        since statements which belong to trigger body are associated with TABLE
        object and because of this can be used in different threads.
    sql/sql_update.cc:
      multi_update:
        Got rid of redundant "thd" member (we already have it in select_result).
    61a68ed6
item_subselect.h 11.6 KB