Commit 2707af2d authored by Ruihang Xia's avatar Ruihang Xia Committed by Igor Babaev

(1)mod: counter type from longlong to ha_rows

(2)fix: bug when call create tmp table
parent 95f35bb7
...@@ -5870,7 +5870,7 @@ class select_unit_ext :public select_unit ...@@ -5870,7 +5870,7 @@ class select_unit_ext :public select_unit
}; };
int send_data(List<Item> &items); int send_data(List<Item> &items);
void change_select(); void change_select();
int unfold_record(longlong cnt); int unfold_record(ha_rows cnt);
bool send_eof(); bool send_eof();
bool force_enable_index_if_needed() bool force_enable_index_if_needed()
{ {
......
...@@ -330,11 +330,6 @@ select_unit::create_result_table(THD *thd_arg, List<Item> *column_types, ...@@ -330,11 +330,6 @@ select_unit::create_result_table(THD *thd_arg, List<Item> *column_types,
tmp_table_param.bit_fields_as_long= bit_fields_as_long; tmp_table_param.bit_fields_as_long= bit_fields_as_long;
tmp_table_param.hidden_field_count= hidden; tmp_table_param.hidden_field_count= hidden;
/*
At least one of `duplicate_cnt` and `intersect_cnt` are used.
in this case table can keep unique actually.
*/
if (hidden > 0) is_union_distinct= true;
if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types, if (! (table= create_tmp_table(thd_arg, &tmp_table_param, *column_types,
(ORDER*) 0, is_union_distinct, 1, (ORDER*) 0, is_union_distinct, 1,
options, HA_POS_ERROR, alias, options, HA_POS_ERROR, alias,
...@@ -499,7 +494,7 @@ bool select_unit_ext::disable_index_if_needed(SELECT_LEX *curr_sl) ...@@ -499,7 +494,7 @@ bool select_unit_ext::disable_index_if_needed(SELECT_LEX *curr_sl)
-1 conversion happened -1 conversion happened
*/ */
int select_unit_ext::unfold_record(longlong cnt) int select_unit_ext::unfold_record(ha_rows cnt)
{ {
DBUG_ASSERT(cnt > 0); DBUG_ASSERT(cnt > 0);
...@@ -840,7 +835,7 @@ bool select_unit_ext::send_eof() ...@@ -840,7 +835,7 @@ bool select_unit_ext::send_eof()
else if (need_unfold) else if (need_unfold)
{ {
/* unfold if is ALL operation */ /* unfold if is ALL operation */
longlong dup_cnt; ha_rows dup_cnt;
if (unlikely(table->file->ha_rnd_init_with_error(1))) if (unlikely(table->file->ha_rnd_init_with_error(1)))
return 1; return 1;
do do
...@@ -854,7 +849,7 @@ bool select_unit_ext::send_eof() ...@@ -854,7 +849,7 @@ bool select_unit_ext::send_eof()
} }
break; break;
} }
dup_cnt= duplicate_cnt->val_int(); dup_cnt= (ha_rows)duplicate_cnt->val_int();
/* delete record if not exist in the second operand */ /* delete record if not exist in the second operand */
if (dup_cnt == 0) if (dup_cnt == 0)
{ {
...@@ -865,7 +860,7 @@ bool select_unit_ext::send_eof() ...@@ -865,7 +860,7 @@ bool select_unit_ext::send_eof()
{ {
longlong add_cnt= additional_cnt->val_int(); longlong add_cnt= additional_cnt->val_int();
if (dup_cnt > add_cnt && add_cnt > 0) if (dup_cnt > add_cnt && add_cnt > 0)
dup_cnt= add_cnt; dup_cnt= (ha_rows)add_cnt;
} }
if (dup_cnt == 1) if (dup_cnt == 1)
...@@ -1576,9 +1571,7 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, ...@@ -1576,9 +1571,7 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg,
if (join_union_item_types(thd, types, union_part_count + 1)) if (join_union_item_types(thd, types, union_part_count + 1))
goto err; goto err;
if (union_result->create_result_table(thd, &types, if (union_result->create_result_table(thd, &types,
MY_TEST(union_distinct) || MY_TEST(union_distinct),
have_except_all_or_intersect_all ||
have_intersect,
create_options, create_options,
&derived_arg->alias, false, &derived_arg->alias, false,
instantiate_tmp_table, false, instantiate_tmp_table, false,
...@@ -1698,7 +1691,9 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, ...@@ -1698,7 +1691,9 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg,
} }
bool error= bool error=
union_result->create_result_table(thd, &types, union_result->create_result_table(thd, &types,
MY_TEST(union_distinct), MY_TEST(union_distinct) ||
have_except_all_or_intersect_all ||
have_intersect,
create_options, &empty_clex_str, false, create_options, &empty_clex_str, false,
instantiate_tmp_table, false, instantiate_tmp_table, false,
hidden); hidden);
......
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