summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2017-01-05 13:54:31 -0800
committerIgor Babaev <igor@askmonty.org>2017-01-05 13:54:31 -0800
commitae1b3d1991b679bb38095711de27934d7683deda (patch)
tree982182ec011e6114a7874920748ea376a48baec2
parent9e528d4fdeab83fcc75ec788da939937ce27b98d (diff)
downloadmariadb-git-ae1b3d1991b679bb38095711de27934d7683deda.tar.gz
Fixed bug mdev-10705.
The fix for bug mdev-5104 did not take into account that for any call of setup_order the size of ref_array must be big enough. This patch fixes this problem.
-rw-r--r--mysql-test/r/order_by.result11
-rw-r--r--mysql-test/t/order_by.test10
-rw-r--r--sql/sql_select.cc7
3 files changed, 27 insertions, 1 deletions
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 6ce12651dba..94a38ca7827 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -2050,4 +2050,15 @@ t2 A, t2 B
where A.b = B.b
order by A.col2, B.col2 limit 10, 1000000;
drop table t1,t2,t3;
+#
+# mdev-10705 : long order by list that can be skipped
+#
+SELECT 1
+UNION
+( SELECT 2
+ORDER BY NULL, @a0 := 3, @a1 := 3, @a2 := 3, @a3 := 3, @a4 := 3,
+@a5 := 3, @a6 := 3, @a7 := 3, @a8 := 3, @a9 := 3, @a10 := 3 );
+1
+1
+2
End of 5.5 tests
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 2ebf8ba5af1..c96d5c2996a 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -1746,6 +1746,16 @@ order by A.col2, B.col2 limit 10, 1000000;
drop table t1,t2,t3;
+--echo #
+--echo # mdev-10705 : long order by list that can be skipped
+--echo #
+
+SELECT 1
+UNION
+( SELECT 2
+ ORDER BY NULL, @a0 := 3, @a1 := 3, @a2 := 3, @a3 := 3, @a4 := 3,
+ @a5 := 3, @a6 := 3, @a7 := 3, @a8 := 3, @a9 := 3, @a10 := 3 );
+
--echo End of 5.5 tests
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c406fab5a3a..2c65c59ad7e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -714,10 +714,15 @@ JOIN::prepare(Item ***rref_pointer_array,
if (mixed_implicit_grouping && tbl->table)
tbl->table->maybe_null= 1;
}
+
+ uint real_og_num= og_num;
+ if (skip_order_by &&
+ select_lex != select_lex->master_unit()->global_parameters)
+ real_og_num+= select_lex->order_list.elements;
if ((wild_num && setup_wild(thd, tables_list, fields_list, &all_fields,
wild_num)) ||
- select_lex->setup_ref_array(thd, og_num) ||
+ select_lex->setup_ref_array(thd, real_og_num) ||
setup_fields(thd, (*rref_pointer_array), fields_list, MARK_COLUMNS_READ,
&all_fields, 1) ||
setup_without_group(thd, (*rref_pointer_array), tables_list,