diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-06-05 10:25:39 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-06-05 10:25:39 +0400 |
commit | 106f0b5798a2b5d13b7d67c3cc678fc0cc2184c2 (patch) | |
tree | 051be6f9936bb23d3db3e3591016e09de159f19c /sql/item_row.cc | |
parent | b50685af82508ca1cc83e1743dff527770e6e64b (diff) | |
download | mariadb-git-106f0b5798a2b5d13b7d67c3cc678fc0cc2184c2.tar.gz |
MDEV-16385 ROW SP variable is allowed in unexpected context
The problem described in the bug report happened because the code
did not test check_cols(1) after fix_fields() in a few places.
Additionally, fix_fields() could be called multiple times for SP variables,
because they are all fixed at a early stage in append_for_log().
Solution:
1. Adding a few helper methods
- fix_fields_if_needed()
- fix_fields_if_needed_for_scalar()
- fix_fields_if_needed_for_bool()
- fix_fields_if_needed_for_order_by()
and using it in many cases instead of fix_fields() where
the "fixed" status is not definitely known to be "false".
2. Adding DBUG_ASSERT(!fixed) into Item_splocal*::fix_fields()
to catch double execution.
3. Adding tests.
As a good side effect, the patch removes a lot of duplicate code (~60 lines):
if (!item->fixed &&
item->fix_fields(..) &&
item->check_cols(1))
return true;
Diffstat (limited to 'sql/item_row.cc')
-rw-r--r-- | sql/item_row.cc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/sql/item_row.cc b/sql/item_row.cc index 74ea9ecc0c2..8233ba00f06 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -41,8 +41,7 @@ bool Item_row::fix_fields(THD *thd, Item **ref) Item **arg, **arg_end; for (arg= args, arg_end= args + arg_count; arg != arg_end ; arg++) { - if (!(*arg)->fixed && - (*arg)->fix_fields(thd, arg)) + if ((*arg)->fix_fields_if_needed(thd, arg)) return TRUE; // we can't assign 'item' before, because fix_fields() can change arg Item *item= *arg; |