From 1e5e3d562b867ae83c3fbb003465e1596c748690 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 31 Jan 2018 19:49:48 +0400 Subject: A cleanup in sp_rcontext, as requested by Monty - Changing sp_rcontext::m_var_items from list of Item to list of Item_field - Renaming sp_rcontext::get_item() to get_variable() and changing its return type from Item* to Item_field * - Adding sp_rcontext::get_parameter() and sp_rcontext::set_parameter(), wrappers for get_variable() and set_variable() with extra DBUG_ASSERT. Using new methods instead of get_variable()/set_variable() in relevant places. --- sql/sp_rcontext.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'sql/sp_rcontext.h') diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index ca438107593..00816b5ea8a 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -189,6 +189,11 @@ public: // SP-variables. ///////////////////////////////////////////////////////////////////////// + uint argument_count() const + { + return m_root_parsing_ctx->context_var_count(); + } + int set_variable(THD *thd, uint var_idx, Item **value); int set_variable_row_field(THD *thd, uint var_idx, uint field_idx, Item **value); @@ -196,11 +201,24 @@ public: const LEX_CSTRING &field_name, Item **value); int set_variable_row(THD *thd, uint var_idx, List &items); - Item *get_item(uint var_idx) const + + int set_parameter(THD *thd, uint var_idx, Item **value) + { + DBUG_ASSERT(var_idx < argument_count()); + return set_variable(thd, var_idx, value); + } + + Item_field *get_variable(uint var_idx) const { return m_var_items[var_idx]; } - Item **get_item_addr(uint var_idx) const - { return m_var_items.array() + var_idx; } + Item **get_variable_addr(uint var_idx) const + { return ((Item **) m_var_items.array()) + var_idx; } + + Item_field *get_parameter(uint var_idx) const + { + DBUG_ASSERT(var_idx < argument_count()); + return get_variable(var_idx); + } bool find_row_field_by_name_or_error(uint *field_idx, uint var_idx, const LEX_CSTRING &field_name); @@ -379,7 +397,7 @@ private: /// Collection of Item_field proxies, each of them points to the /// corresponding field in m_var_table. - Bounds_checked_array m_var_items; + Bounds_checked_array m_var_items; /// This is a pointer to a field, which should contain return value for /// stored functions (only). For stored procedures, this pointer is NULL. -- cgit v1.2.1