diff --git a/dbcon/mysql/ha_mcs_impl.cpp b/dbcon/mysql/ha_mcs_impl.cpp index 906ae3631..193ad38ea 100644 --- a/dbcon/mysql/ha_mcs_impl.cpp +++ b/dbcon/mysql/ha_mcs_impl.cpp @@ -1348,7 +1348,6 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c // Save the item list List items; - SELECT_LEX select_lex; if (ha_mcs_common::isUpdateStatement(thd->lex->sql_command)) { @@ -1356,7 +1355,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c thd->lex->first_select_lex()->item_list = thd->lex->value_list; } - select_lex = *lex->first_select_lex(); + SELECT_LEX* select_lex = lex->first_select_lex(); //@Bug 2808 Error out on order by or limit clause //@bug5096. support dml limit. @@ -1412,7 +1411,7 @@ uint32_t doUpdateDelete(THD* thd, gp_walk_info& gwi, const std::vector& c gwi.clauseType = WHERE; - if (getSelectPlan(gwi, select_lex, updateCP, false, false, false, condStack) != + if (getSelectPlan(gwi, *select_lex, updateCP, false, false, false, condStack) != 0) //@Bug 3030 Modify the error message for unsupported functions { if (gwi.cs_vtable_is_update_with_derive) diff --git a/dbcon/mysql/ha_view.h b/dbcon/mysql/ha_view.h index de395efe6..86d3cabbb 100644 --- a/dbcon/mysql/ha_view.h +++ b/dbcon/mysql/ha_view.h @@ -54,7 +54,8 @@ class View uint32_t processJoin(gp_walk_info& gwi, std::stack&); private: - SELECT_LEX fSelect; + // Lifetime of fSelect is managed by MDB and must be longer than View object + SELECT_LEX& fSelect; gp_walk_info* fParentGwip; execplan::CalpontSystemCatalog::TableAliasName fViewName; };