summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-06-05 10:25:39 +0400
committerAlexander Barkov <bar@mariadb.com>2018-06-05 10:25:39 +0400
commit106f0b5798a2b5d13b7d67c3cc678fc0cc2184c2 (patch)
tree051be6f9936bb23d3db3e3591016e09de159f19c /sql/sql_partition.cc
parentb50685af82508ca1cc83e1743dff527770e6e64b (diff)
downloadmariadb-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/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index c0ff1c54549..ffe632d5409 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -146,7 +146,7 @@ Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs)
item= item->safe_charset_converter(thd, cs);
context->table_list= NULL;
thd->where= "convert character set partition constant";
- if (!item || item->fix_fields(thd, (Item**)NULL))
+ if (item->fix_fields_if_needed(thd, (Item**)NULL))
item= NULL;
thd->where= save_where;
context->table_list= save_list;
@@ -859,7 +859,7 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
const nesting_map saved_allow_sum_func= thd->lex->allow_sum_func;
thd->lex->allow_sum_func= 0;
- if (likely(!(error= func_expr->fix_fields(thd, (Item**)&func_expr))))
+ if (likely(!(error= func_expr->fix_fields_if_needed(thd, (Item**)&func_expr))))
func_expr->walk(&Item::post_fix_fields_part_expr_processor, 0, NULL);
/*