Skip to content

Commit

Permalink
Remove has_error as a member from Item_sum and use THD::is_error() in…
Browse files Browse the repository at this point in the history
…stead

Additionally, allow a query with window functions to be killed by the user during
its execution.
  • Loading branch information
cvicentiu authored and varunraiko committed Nov 1, 2017
1 parent f4ba298 commit 24e219b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
3 changes: 1 addition & 2 deletions sql/item_sum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ Item_sum::Item_sum(THD *thd, List<Item> &list): Item_func_or_sum(thd, list)
mark_as_sum_func();
init_aggregator();
list.empty(); // Fields are used
has_error= FALSE;
}


Expand All @@ -453,7 +452,7 @@ Item_sum::Item_sum(THD *thd, Item_sum *item):
Item_func_or_sum(thd, item),
aggr_sel(item->aggr_sel),
nest_level(item->nest_level), aggr_level(item->aggr_level),
quick_group(item->quick_group), has_error(FALSE),
quick_group(item->quick_group),
orig_args(NULL)
{
if (arg_count <= 2)
Expand Down
7 changes: 3 additions & 4 deletions sql/item_sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ class Item_sum :public Item_func_or_sum
int8 max_arg_level; /* max level of unbound column references */
int8 max_sum_func_level;/* max level of aggregation for embedded functions */
bool quick_group; /* If incremental update of fields */
bool has_error;
/*
This list is used by the check for mixing non aggregated fields and
sum functions in the ONLY_FULL_GROUP_BY_MODE. We save all outer fields
Expand All @@ -389,19 +388,19 @@ class Item_sum :public Item_func_or_sum
public:

void mark_as_sum_func();
Item_sum(THD *thd): Item_func_or_sum(thd), quick_group(1), has_error(0)
Item_sum(THD *thd): Item_func_or_sum(thd), quick_group(1)
{
mark_as_sum_func();
init_aggregator();
}
Item_sum(THD *thd, Item *a): Item_func_or_sum(thd, a), quick_group(1),
has_error(0), orig_args(tmp_orig_args)
orig_args(tmp_orig_args)
{
mark_as_sum_func();
init_aggregator();
}
Item_sum(THD *thd, Item *a, Item *b): Item_func_or_sum(thd, a, b),
quick_group(1), has_error(0), orig_args(tmp_orig_args)
quick_group(1), orig_args(tmp_orig_args)
{
mark_as_sum_func();
init_aggregator();
Expand Down
6 changes: 0 additions & 6 deletions sql/item_windowfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,6 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
if (prev_value >1 || prev_value < 0)
{
my_error(ER_ARGUMENT_OUT_OF_RANGE, MYF(0));
has_error= TRUE;
return true;
}
first_call= false;
Expand All @@ -778,7 +777,6 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,
if (prev_value != arg_val)
{
my_error(ER_ARGUMENT_NOT_CONSTANT, MYF(0));
has_error= TRUE;
return true;
}

Expand All @@ -805,7 +803,6 @@ class Item_sum_percentile_disc : public Item_sum_cume_dist,

void clear()
{
has_error= false;
val_calculated= false;
first_call= true;
value->clear();
Expand Down Expand Up @@ -890,7 +887,6 @@ class Item_sum_percentile_cont : public Item_sum_cume_dist,
if (prev_value >1 || prev_value < 0)
{
my_error(ER_ARGUMENT_OUT_OF_RANGE, MYF(0));
has_error= TRUE;
return true;
}
}
Expand All @@ -899,7 +895,6 @@ class Item_sum_percentile_cont : public Item_sum_cume_dist,
if (prev_value != arg_val)
{
my_error(ER_ARGUMENT_NOT_CONSTANT, MYF(0));
has_error= TRUE;
return true;
}

Expand Down Expand Up @@ -937,7 +932,6 @@ class Item_sum_percentile_cont : public Item_sum_cume_dist,
void clear()
{
first_call= true;
has_error= false;
floor_value->clear();
ceil_value->clear();
floor_val_calculated= false;
Expand Down
10 changes: 4 additions & 6 deletions sql/sql_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,6 @@ class Frame_cursor : public Sql_alloc
while ((item_sum= it++))
{
item_sum->add();
if (item_sum->has_error)
return;
}
}

Expand Down Expand Up @@ -2807,10 +2805,11 @@ bool compute_window_func(THD *thd,
cursor_manager->notify_cursors_next_row();
}

/* check if we found any error in the window function while calling the add function */
/* Check if we found any error in the window function while adding values
through cursors. */
if (thd->is_error() || thd->is_killed())
break;

if (win_func->window_func()->has_error)
goto label;

/* Return to current row after notifying cursors for each window
function. */
Expand All @@ -2824,7 +2823,6 @@ bool compute_window_func(THD *thd,
rownum++;
}

label:
my_free(rowid_buf);
partition_trackers.delete_elements();
end_read_record(&info);
Expand Down

0 comments on commit 24e219b

Please sign in to comment.