diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index c26a324d00b1aa2bd687886e01485f7cef3ee2f0..1e67bfa7d376dbdc22c8967aa90acce98c470a6e 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -1942,6 +1942,28 @@ execute stmt;
 deallocate prepare stmt;
 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.
 create procedure proc_1() reset query cache;
 call proc_1();
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index b0930a42b4153758e090d2dfe037dafa8e775ab9..d5f7eda50329731bbed65760cd4e8ef429cc83e4 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -2014,6 +2014,22 @@ deallocate prepare stmt;
 drop table t1,t2;
 --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.
 
 #
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d50bb8888501aa77919f6225c39e4ea966bf9103..644f0072b7b2ac9ae070d1f24251d67a58712d76 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7067,6 +7067,7 @@ static void update_depend_map(JOIN *join, ORDER *order)
     table_map depend_map;
     order->item[0]->update_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
     if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT))
         && !order->item[0]->with_sum_func)