summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-08-26 14:13:02 +0400
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-08-26 14:13:02 +0400
commitd8b3cde7c34ecb2e0d767de2dc29b4037b973e0e (patch)
treed10c150611af90c3997fe141f32ecf8ae51048c4 /mysql-test
parent6a65524619449639619ff2179d3bf4a0550ee3e9 (diff)
downloadmariadb-git-d8b3cde7c34ecb2e0d767de2dc29b4037b973e0e.tar.gz
Bug #53544: Server hangs during JOIN query in stored procedure
called twice in a row Queries with nested joins could cause an infinite loop in the server when used from SP/PS. When flattening nested joins, simplify_joins() tracks if the name resolution list needs to be updated by setting fix_name_res to TRUE if the current loop iteration has done any transformations to the join table list. The problem was that the flag was not reset before the next loop iteration leading to unnecessary "fixing" of the name resolution list which in turn could lead to a loop (i.e. circularly-linked part) in that list. This was causing problems on subsequent execution when used together with stored procedures or prepared statements. Fixed by making sure fix_name_res is reset on every loop iteration. mysql-test/r/join.result: Added a test case for bug #53544. mysql-test/t/join.test: Added a test case for bug #53544. sql/sql_select.cc: Make sure fix_name_res is reset on every loop iteration.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/join.result20
-rw-r--r--mysql-test/t/join.test20
2 files changed, 40 insertions, 0 deletions
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index c3c292b2106..9a8b441b363 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -1235,4 +1235,24 @@ ORDER BY t1.a, t1.a LIMIT 1) AS d)
1
1
DROP TABLE t1;
+#
+# Bug #53544: Server hangs during JOIN query in stored procedure called
+# twice in a row
+#
+CREATE TABLE t1(c INT);
+INSERT INTO t1 VALUES (1), (2);
+PREPARE stmt FROM "SELECT t2.c AS f1 FROM t1 LEFT JOIN
+ t1 t2 ON t1.c=t2.c RIGHT JOIN
+ t1 t3 ON t1.c=t3.c
+ GROUP BY f1;";
+EXECUTE stmt;
+f1
+1
+2
+EXECUTE stmt;
+f1
+1
+2
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index 6969be6fdc4..73a1ae5eb82 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -897,4 +897,24 @@ GREATEST(t1.a,
DROP TABLE t1;
+--echo #
+--echo # Bug #53544: Server hangs during JOIN query in stored procedure called
+--echo # twice in a row
+--echo #
+
+CREATE TABLE t1(c INT);
+
+INSERT INTO t1 VALUES (1), (2);
+
+PREPARE stmt FROM "SELECT t2.c AS f1 FROM t1 LEFT JOIN
+ t1 t2 ON t1.c=t2.c RIGHT JOIN
+ t1 t3 ON t1.c=t3.c
+ GROUP BY f1;";
+
+EXECUTE stmt;
+EXECUTE stmt;
+
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
--echo End of 5.1 tests