diff options
author | Alexander Barkov <bar@mariadb.org> | 2017-01-24 17:22:06 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-01-24 17:22:06 +0400 |
commit | ae91690d893c13e86fd9f84e0c37fd9640bca257 (patch) | |
tree | 2ed02394f8991629e64bf8ba7c5d0f4dc5f1532a /sql/item.h | |
parent | 836804499704396aacff58d415b63741b22ff2f6 (diff) | |
download | mariadb-git-ae91690d893c13e86fd9f84e0c37fd9640bca257.tar.gz |
MDEV-11780 Crash with PREPARE + SP out parameter + literal
Before "MDEV-10709 Expressions as parameters to Dynamic SQL" only
user variables were syntactically allowed as EXECUTE parameters.
User variables were OK as both IN and OUT parameters.
When Item_param was bound to an actual parameter (a user variable),
it automatically meant that the bound Item was settable.
The DBUG_ASSERT() in Protocol_text::send_out_parameters() guarded that
the actual parameter is really settable.
After MDEV-10709, any kind of expressions are allowed as EXECUTE IN parameters.
But the patch for MDEV-10709 forgot to check that only descendants of
Settable_routine_parameter should be allowed as OUT parameters.
So an attempt to pass a non-settable parameter as an OUT parameter
made server crash on the above mentioned DBUG_ASSERT.
This patch changes Item_param::get_settable_routine_parameter(),
which previously always returned "this". Now, when Item_param is bound
to some Item, it caches if the bound Item is settable.
Item_param::get_settable_routine_parameter() now returns "this" only
if the bound actual parameter is settable, and returns NULL otherwise.
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item.h b/sql/item.h index f9efd104b04..bb2f05b4c6d 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2982,7 +2982,7 @@ public: Rewritable_query_parameter *get_rewritable_query_parameter() { return this; } Settable_routine_parameter *get_settable_routine_parameter() - { return this; } + { return m_is_settable_routine_parameter ? this : NULL; } bool append_for_log(THD *thd, String *str); bool check_vcol_func_processor(void *int_arg) {return FALSE;} @@ -3002,6 +3002,7 @@ public: private: Send_field *m_out_param_info; + bool m_is_settable_routine_parameter; }; |