Commit 31fb045c authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

Make ntile use args[0] for it's argument.

Don't hold a separate pointer as args[0] changes during fix_fields /
split_sum_func.
parent 3dd08a11
...@@ -429,7 +429,6 @@ class Item_sum_ntile : public Item_sum_window_with_row_count ...@@ -429,7 +429,6 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
public: public:
Item_sum_ntile(THD* thd, Item* num_quantiles_expr) : Item_sum_ntile(THD* thd, Item* num_quantiles_expr) :
Item_sum_window_with_row_count(thd, num_quantiles_expr), Item_sum_window_with_row_count(thd, num_quantiles_expr),
num_quantiles_expr_(num_quantiles_expr),
current_row_count_(0) {}; current_row_count_(0) {};
double val_real() double val_real()
...@@ -445,7 +444,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count ...@@ -445,7 +444,7 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
return 0; return 0;
} }
longlong num_quantiles= num_quantiles_expr_->val_int(); longlong num_quantiles= get_num_quantiles();
if (num_quantiles <= 0) { if (num_quantiles <= 0) {
my_error(ER_INVALID_NTILE_ARGUMENT, MYF(0)); my_error(ER_INVALID_NTILE_ARGUMENT, MYF(0));
...@@ -489,19 +488,8 @@ class Item_sum_ntile : public Item_sum_window_with_row_count ...@@ -489,19 +488,8 @@ class Item_sum_ntile : public Item_sum_window_with_row_count
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
bool fix_fields(THD *thd, Item **ref)
{
if (Item_sum_window_with_row_count::fix_fields(thd, ref))
return true;
// TODO-cvicentiu is ref as a parameter here ok?
if (!num_quantiles_expr_->fixed)
num_quantiles_expr_->fix_fields(thd, ref);
return false;
}
private: private:
Item* num_quantiles_expr_; longlong get_num_quantiles() { return args[0]->val_int(); }
ulong current_row_count_; ulong current_row_count_;
}; };
......
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