Commit f48718be authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-20632: Fix -Wmaybe-uninitialized

Create_tmp_table::add_fields(): Initialize uneven_delta= 0
to suppress the warning from GCC 9.2.1 and 10.0.1,
and consistently indent the code with spaces.
parent c57b2079
...@@ -18345,7 +18345,6 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18345,7 +18345,6 @@ bool Create_tmp_table::add_fields(THD *thd,
List_iterator_fast<Item> li(fields); List_iterator_fast<Item> li(fields);
Item *item; Item *item;
Field **tmp_from_field= m_from_field; Field **tmp_from_field= m_from_field;
uint uneven_delta;
while (!m_with_cycle && (item= li++)) while (!m_with_cycle && (item= li++))
if (item->common_flags & IS_IN_WITH_CYCLE) if (item->common_flags & IS_IN_WITH_CYCLE)
{ {
...@@ -18360,6 +18359,7 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18360,6 +18359,7 @@ bool Create_tmp_table::add_fields(THD *thd,
distinct_record_structure= true; distinct_record_structure= true;
} }
li.rewind(); li.rewind();
uint uneven_delta= 0;
while ((item=li++)) while ((item=li++))
{ {
current_counter= (((param->hidden_field_count < (fieldnr + 1)) && current_counter= (((param->hidden_field_count < (fieldnr + 1)) &&
...@@ -18383,13 +18383,13 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18383,13 +18383,13 @@ bool Create_tmp_table::add_fields(THD *thd,
if ((item->real_type() == Item::SUBSELECT_ITEM) || if ((item->real_type() == Item::SUBSELECT_ITEM) ||
(item->used_tables() & ~OUTER_REF_TABLE_BIT)) (item->used_tables() & ~OUTER_REF_TABLE_BIT))
{ {
/* /*
Mark that the we have ignored an item that refers to a summary Mark that the we have ignored an item that refers to a summary
function. We need to know this if someone is going to use function. We need to know this if someone is going to use
DISTINCT on the result. DISTINCT on the result.
*/ */
param->using_outer_summary_function=1; param->using_outer_summary_function=1;
continue; continue;
} }
} }
if (item->const_item() && if (item->const_item() &&
...@@ -18402,18 +18402,18 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18402,18 +18402,18 @@ bool Create_tmp_table::add_fields(THD *thd,
sum_item->result_field=0; sum_item->result_field=0;
for (uint i= 0 ; i < sum_item->get_arg_count() ; i++) for (uint i= 0 ; i < sum_item->get_arg_count() ; i++)
{ {
Item *arg= sum_item->get_arg(i); Item *arg= sum_item->get_arg(i);
if (!arg->const_item()) if (!arg->const_item())
{ {
Item *tmp_item; Item *tmp_item;
Field *new_field= Field *new_field=
create_tmp_field(table, arg, &copy_func, create_tmp_field(table, arg, &copy_func,
tmp_from_field, &m_default_field[fieldnr], tmp_from_field, &m_default_field[fieldnr],
m_group != 0, not_all_columns, m_group != 0, not_all_columns,
distinct_record_structure , false); distinct_record_structure , false);
if (!new_field) if (!new_field)
goto err; // Should be OOM goto err; // Should be OOM
tmp_from_field++; tmp_from_field++;
thd->mem_root= mem_root_save; thd->mem_root= mem_root_save;
if (!(tmp_item= new (thd->mem_root) if (!(tmp_item= new (thd->mem_root)
...@@ -18427,7 +18427,7 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18427,7 +18427,7 @@ bool Create_tmp_table::add_fields(THD *thd,
uneven_delta= m_uneven_bit_length - uneven_delta; uneven_delta= m_uneven_bit_length - uneven_delta;
m_field_count[current_counter]++; m_field_count[current_counter]++;
if (!(new_field->flags & NOT_NULL_FLAG)) if (!(new_field->flags & NOT_NULL_FLAG))
{ {
/* /*
new_field->maybe_null() is still false, it will be new_field->maybe_null() is still false, it will be
...@@ -18437,20 +18437,20 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18437,20 +18437,20 @@ bool Create_tmp_table::add_fields(THD *thd,
} }
if (current_counter == distinct) if (current_counter == distinct)
new_field->flags|= FIELD_PART_OF_TMP_UNIQUE; new_field->flags|= FIELD_PART_OF_TMP_UNIQUE;
} }
} }
} }
else else
{ {
/* /*
The last parameter to create_tmp_field_ex() is a bit tricky: The last parameter to create_tmp_field_ex() is a bit tricky:
We need to set it to 0 in union, to get fill_record() to modify the We need to set it to 0 in union, to get fill_record() to modify the
temporary table. temporary table.
We need to set it to 1 on multi-table-update and in select to We need to set it to 1 on multi-table-update and in select to
write rows to the temporary table. write rows to the temporary table.
We here distinguish between UNION and multi-table-updates by the fact We here distinguish between UNION and multi-table-updates by the fact
that in the later case group is set to the row pointer. that in the later case group is set to the row pointer.
The test for item->marker == 4 is ensure we don't create a group-by The test for item->marker == 4 is ensure we don't create a group-by
key over a bit field as heap tables can't handle that. key over a bit field as heap tables can't handle that.
...@@ -18473,9 +18473,9 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18473,9 +18473,9 @@ bool Create_tmp_table::add_fields(THD *thd,
param->force_copy_fields); param->force_copy_fields);
if (!new_field) if (!new_field)
{ {
if (unlikely(thd->is_fatal_error)) if (unlikely(thd->is_fatal_error))
goto err; // Got OOM goto err; // Got OOM
continue; // Some kind of const item continue; // Some kind of const item
} }
if (type == Item::SUM_FUNC_ITEM) if (type == Item::SUM_FUNC_ITEM)
{ {
...@@ -18512,7 +18512,7 @@ bool Create_tmp_table::add_fields(THD *thd, ...@@ -18512,7 +18512,7 @@ bool Create_tmp_table::add_fields(THD *thd,
if (item->marker == 4 && item->maybe_null) if (item->marker == 4 && item->maybe_null)
{ {
m_group_null_items++; m_group_null_items++;
new_field->flags|= GROUP_FLAG; new_field->flags|= GROUP_FLAG;
} }
if (current_counter == distinct) if (current_counter == distinct)
new_field->flags|= FIELD_PART_OF_TMP_UNIQUE; new_field->flags|= FIELD_PART_OF_TMP_UNIQUE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment