Commit ee403cc1 authored by Ramil Kalimullin's avatar Ramil Kalimullin

Fix for bug#49570: Assertion failed: !(order->used & map)

on re-execution of prepared statement

Problem: some (see eq_ref_table()) ORDER BY/GROUP BY optimization
is called before each PS execution. However, we don't properly 
initialize its stucture every time before the call.

Fix: properly initialize the sturture used.
parent 27c09398
...@@ -1916,4 +1916,26 @@ execute stmt; ...@@ -1916,4 +1916,26 @@ execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1,t2; drop table t1,t2;
# #
#
# Bug #49570: Assertion failed: !(order->used & map)
# on re-execution of prepared statement
#
CREATE TABLE t1(a INT PRIMARY KEY);
INSERT INTO t1 VALUES(0), (1);
PREPARE stmt FROM
"SELECT 1 FROM t1 JOIN t1 t2 USING(a) GROUP BY t2.a, t1.a";
EXECUTE stmt;
1
1
1
EXECUTE stmt;
1
1
1
EXECUTE stmt;
1
1
1
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
End of 5.0 tests. End of 5.0 tests.
...@@ -1996,4 +1996,20 @@ deallocate prepare stmt; ...@@ -1996,4 +1996,20 @@ deallocate prepare stmt;
drop table t1,t2; drop table t1,t2;
--echo # --echo #
--echo #
--echo # Bug #49570: Assertion failed: !(order->used & map)
--echo # on re-execution of prepared statement
--echo #
CREATE TABLE t1(a INT PRIMARY KEY);
INSERT INTO t1 VALUES(0), (1);
PREPARE stmt FROM
"SELECT 1 FROM t1 JOIN t1 t2 USING(a) GROUP BY t2.a, t1.a";
EXECUTE stmt;
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo End of 5.0 tests. --echo End of 5.0 tests.
...@@ -6777,6 +6777,7 @@ static void update_depend_map(JOIN *join, ORDER *order) ...@@ -6777,6 +6777,7 @@ static void update_depend_map(JOIN *join, ORDER *order)
table_map depend_map; table_map depend_map;
order->item[0]->update_used_tables(); order->item[0]->update_used_tables();
order->depend_map=depend_map=order->item[0]->used_tables(); order->depend_map=depend_map=order->item[0]->used_tables();
order->used= 0;
// Not item_sum(), RAND() and no reference to table outside of sub select // Not item_sum(), RAND() and no reference to table outside of sub select
if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT)) if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT))
&& !order->item[0]->with_sum_func) && !order->item[0]->with_sum_func)
......
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