diff options
author | Alexander Barkov <bar@mariadb.org> | 2018-01-31 19:49:48 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2018-01-31 19:49:48 +0400 |
commit | 1e5e3d562b867ae83c3fbb003465e1596c748690 (patch) | |
tree | ed46f2af6e264dc05e61cecf3aad7c4c61fc862b /sql/sp_rcontext.h | |
parent | df2d67824811516fabcfb09dacd6d147f8f71d54 (diff) | |
download | mariadb-git-1e5e3d562b867ae83c3fbb003465e1596c748690.tar.gz |
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.
Diffstat (limited to 'sql/sp_rcontext.h')
-rw-r--r-- | sql/sp_rcontext.h | 26 |
1 files changed, 22 insertions, 4 deletions
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<Item> &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<Item *> m_var_items; + Bounds_checked_array<Item_field *> 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. |