summaryrefslogtreecommitdiff
path: root/mysql-test/r/join.result
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2013-03-17 14:36:20 +0200
committerMichael Widenius <monty@askmonty.org>2013-03-17 14:36:20 +0200
commit8b047ac5c4b7d326742fd8b7a165a17089a9d83b (patch)
tree04387528ba7b255c3c15b95989e1ee854c502dc8 /mysql-test/r/join.result
parentdeeed04137908c0a30ef93f12bbdda0ed06e9c0a (diff)
downloadmariadb-git-8b047ac5c4b7d326742fd8b7a165a17089a9d83b.tar.gz
Patch by Hartmut Holzgraefe
STRAIGHT_JOIN couldn't be combined with NATURAL or USING(), INNER JOIN not with NATURAL (MDEV-4271, MySQL Bug #35268) Separate rules existed for "natural" (non-outer) joins and for STRAIGHT_JOIN, with the only difference code wise being that with STRAIGHT_JOIN the "straight" property of the right side table was set before calling the appropriate add_...() function. The "natural_join" parser rule has now been extended to also accept STRAIGHT_JOIN, and the rule result value is set to 1 for straight joins, 0 otherwise, so acting as a "straight" flag that can directly be assigned to the "straight" property of the right side table. The rule parsing NATURAL JOIN was hard coded to accept just this keyword combination, without support for either STRAIGHT_JOIN or the optional INNER. The "natural_join" rule has now been split up in an inner "inner_join" rule that matches the JOIN, INNER JOIN and STRAIGHT_JOIN cases while "natural_join" also matches CROSS JOIN. The NATURAL rule has been changed to accept "inner_join" instead of just JOIN, so now NATURAL STRAIGHT_JOIN and NATURAL INNER JOIN also work as expected. As a side effect the removal of the duplciated rules for STRAIGHT_JOIN handling has reduced the shift/reduce conflict count by one. mysql-test/r/join.result: Added new test cases mysql-test/t/join.test: Added new test cases sql/sql_yacc.yy: The "natural_join" parser rule was extended to also accept STRAIGHT_JOIN NATURAL STRAIGHT_JOIN and NATURAL INNER JOIN also now work as expected
Diffstat (limited to 'mysql-test/r/join.result')
-rw-r--r--mysql-test/r/join.result41
1 files changed, 41 insertions, 0 deletions
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index ba16d7dd9de..1d045d0a58d 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -1473,3 +1473,44 @@ dog_id dog_id birthday dog_id t_id birthday dog_id t_id birthday a_id dog_id
SET optimizer_switch=@tmp_optimizer_switch;
DROP TABLE t1,t2,t3,t4,t5;
SET optimizer_switch=@save_optimizer_switch;
+#
+# Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
+#
+CREATE TABLE t1 (a int);
+INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
+CREATE TABLE t2 (a int);
+INSERT INTO t2 (a) VALUES (1),(2),(3),(4);
+EXPLAIN
+SELECT t1.a FROM t1 NATURAL INNER JOIN t2 ORDER BY t1.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
+SELECT t1.a FROM t1 NATURAL INNER JOIN t2 ORDER BY t1.a;
+a
+1
+2
+3
+4
+EXPLAIN
+SELECT t1.a FROM t1 STRAIGHT_JOIN t2 USING(a) ORDER BY t1.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
+SELECT t1.a FROM t1 STRAIGHT_JOIN t2 USING(a) ORDER BY t1.a;
+a
+1
+2
+3
+4
+EXPLAIN
+SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
+SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a;
+a
+1
+2
+3
+4
+DROP TABLE t1,t2;