diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-31 18:09:08 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-31 18:09:08 +0300 |
commit | 9216114ce729733e6b0c4ce952bfdf57595ff387 (patch) | |
tree | 7a541ed87a6a8174d3d94c5f780724a34e08dc1c /sql/item_windowfunc.h | |
parent | dc513dff911d72eaaf9f752f390fef8d1ef9a4b0 (diff) | |
parent | 66ec3a770f7854f500ece66c78f3c87c9cd6da15 (diff) | |
download | mariadb-git-9216114ce729733e6b0c4ce952bfdf57595ff387.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql/item_windowfunc.h')
-rw-r--r-- | sql/item_windowfunc.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index 846acd74b29..c038cb8d15f 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -646,7 +646,7 @@ class Item_sum_ntile : public Item_sum_int, { public: Item_sum_ntile(THD* thd, Item* num_quantiles_expr) : - Item_sum_int(thd, num_quantiles_expr) + Item_sum_int(thd, num_quantiles_expr), n_old_val_(0) { } longlong val_int() @@ -659,11 +659,13 @@ class Item_sum_ntile : public Item_sum_int, longlong num_quantiles= get_num_quantiles(); - if (num_quantiles <= 0) { + if (num_quantiles <= 0 || + (static_cast<ulonglong>(num_quantiles) != n_old_val_ && n_old_val_ > 0)) + { my_error(ER_INVALID_NTILE_ARGUMENT, MYF(0)); return true; } - + n_old_val_= static_cast<ulonglong>(num_quantiles); null_value= false; ulonglong quantile_size = get_row_count() / num_quantiles; ulonglong extra_rows = get_row_count() - quantile_size * num_quantiles; @@ -689,6 +691,7 @@ class Item_sum_ntile : public Item_sum_int, { current_row_count_= 0; partition_row_count_= 0; + n_old_val_= 0; } const char*func_name() const @@ -710,6 +713,7 @@ class Item_sum_ntile : public Item_sum_int, private: longlong get_num_quantiles() { return args[0]->val_int(); } + ulonglong n_old_val_; }; class Item_sum_percentile_disc : public Item_sum_num, |