diff options
author | Igor Babaev <igor@askmonty.org> | 2016-04-14 00:47:28 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2016-04-14 00:47:28 -0700 |
commit | 5ff4b21e02dee1879436ebb4a484f0d2e756acaf (patch) | |
tree | e3da6ccb7f78662a3040807768711ee2f998b841 /sql/sql_window.cc | |
parent | b532be9f8ce4872be4a3f1ef2fa296a1de347859 (diff) | |
download | mariadb-git-5ff4b21e02dee1879436ebb4a484f0d2e756acaf.tar.gz |
Fixed bug mdev-9897.
This bug revealed a serious problem: if the same partition list
was used in two window specifications then the temporary table created
to calculate window functions contained fields for two identical
partitions. This problem was fixed as well.
Diffstat (limited to 'sql/sql_window.cc')
-rw-r--r-- | sql/sql_window.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/sql/sql_window.cc b/sql/sql_window.cc index cd7d8df0c93..6d45fac0a9d 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -122,9 +122,10 @@ setup_windows(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, bool hidden_group_fields; if (win_spec->check_window_names(itp) || setup_group(thd, ref_pointer_array, tables, fields, all_fields, - win_spec->partition_list->first, &hidden_group_fields) || + win_spec->partition_list->first, &hidden_group_fields, + true) || setup_order(thd, ref_pointer_array, tables, fields, all_fields, - win_spec->order_list->first) || + win_spec->order_list->first, true) || (win_spec->window_frame && win_spec->window_frame->check_frame_bounds())) { @@ -236,21 +237,21 @@ setup_windows(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, static int compare_order_elements(ORDER *ord1, ORDER *ord2) { + if (*ord1->item == *ord2->item) + return CMP_EQ; Item *item1= (*ord1->item)->real_item(); Item *item2= (*ord2->item)->real_item(); - if (item1->used_tables() == item2->used_tables()) + DBUG_ASSERT(item1->type() == Item::FIELD_ITEM && + item2->type() == Item::FIELD_ITEM); + int cmp= ((Item_field *) item1)->field - ((Item_field *) item2)->field; + if (cmp == 0) { - int cmp= strcmp(item1->name, item2->name); - if (cmp == 0) - { - if (ord1->direction == ord2->direction) - return CMP_EQ; - return ord1->direction > ord2->direction ? CMP_GT : CMP_LT; - } - else - return cmp > 0 ? CMP_GT : CMP_LT; + if (ord1->direction == ord2->direction) + return CMP_EQ; + return ord1->direction > ord2->direction ? CMP_GT : CMP_LT; } - return item1->used_tables() > item2->used_tables() ? CMP_GT : CMP_LT; + else + return cmp > 0 ? CMP_GT : CMP_LT; } static |