summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2022-06-27 18:01:16 +0400
committerAlexander Barkov <bar@mariadb.com>2022-06-27 19:52:48 +0400
commit4a7e337e5f85e488849e5cb2f780659a3d7b1266 (patch)
tree6dfbf66df876d4a6af2a364e1401e2e87b342e04 /sql/sp_head.cc
parentc4bfb61803640e9e0c4b7fff441ac71b1996779d (diff)
downloadmariadb-git-4a7e337e5f85e488849e5cb2f780659a3d7b1266.tar.gz
MDEV-28963 Incompatible data type assignment through SP vars is not consistent with columns
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 393f2016a87..3557e21d53b 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -411,6 +411,26 @@ Item *THD::sp_fix_func_item(Item **it_addr)
/**
+ Prepare an Item for evaluation as an assignment source,
+ for assignment to the given target.
+
+ @param to - the assignment target
+ @param it_addr - a pointer on item refernce
+
+ @retval - NULL on error
+ @retval - a prepared item pointer on success
+*/
+Item *THD::sp_fix_func_item_for_assignment(const Field *to, Item **it_addr)
+{
+ DBUG_ENTER("THD::sp_fix_func_item_for_assignment");
+ Item *res= sp_fix_func_item(it_addr);
+ if (res && (!res->check_assignability_to(to)))
+ DBUG_RETURN(res);
+ DBUG_RETURN(NULL);
+}
+
+
+/**
Evaluate an expression and store the result in the field.
@param result_field the field to store the result
@@ -4071,7 +4091,7 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp)
Item *it;
int res;
- it= thd->sp_prepare_func_item(&m_expr);
+ it= thd->sp_prepare_func_item(&m_expr, 1);
if (! it)
{
res= -1;