diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-31 13:51:28 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-07-31 13:51:28 +0300 |
commit | 66ec3a770f7854f500ece66c78f3c87c9cd6da15 (patch) | |
tree | 0777df9a8dc587b70851c1edc0cfe96895928717 /sql/item_windowfunc.h | |
parent | 6053eb1ce278ac1f566cd74498506bf457d6d048 (diff) | |
parent | f35d1721039f8f115fc55e8f4b4d2bb4012161d1 (diff) | |
download | mariadb-git-66ec3a770f7854f500ece66c78f3c87c9cd6da15.tar.gz |
Merge 10.2 into 10.3
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 977c217cd1e..81bfa8d7cd0 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -640,7 +640,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() @@ -653,11 +653,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; @@ -683,6 +685,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 @@ -702,6 +705,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, |