Commit 8deafa80 authored by unknown's avatar unknown
Browse files

order_by.result, order_by.test:

  Added a test case for bug #7672.
sql_yacc.yy:
  Fixed bug #7672.
  Made queries of the form (SELECT ...) ORDER BY ... to
  be equivalent to SELECT ... ORDER BY ...


sql/sql_yacc.yy:
  Fixed bug #7672.
  Made queries of the form (SELECT ...) ORDER BY ... to
  be equivalent to SELECT ... ORDER BY ...
mysql-test/t/order_by.test:
  Added a test case for bug #7672.
mysql-test/r/order_by.result:
  Added a test case for bug #7672.
parent b7c59b9e
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -554,3 +554,20 @@ explain select id,t from t1 force index (primary) order by id;
table	type	possible_keys	key	key_len	ref	rows	Extra
t1	index	NULL	PRIMARY	4	NULL	1000	
drop table t1;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (2), (1), (1), (2), (1);
SELECT a FROM t1 ORDER BY a;
a
1
1
1
2
2
(SELECT a FROM t1) ORDER BY a;
a
1
1
1
2
2
DROP TABLE t1;
+12 −1
Original line number Diff line number Diff line
@@ -364,3 +364,14 @@ enable_query_log;
explain select id,t from t1 order by id;
explain select id,t from t1 force index (primary) order by id;
drop table t1;

#
# Bug #7672 - a wrong result for a select query in braces followed by order by
#

CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (2), (1), (1), (2), (1);
SELECT a FROM t1 ORDER BY a;
(SELECT a FROM t1) ORDER BY a;
DROP TABLE t1;
+8 −5
Original line number Diff line number Diff line
@@ -4033,12 +4033,15 @@ optional_order_or_limit:
	      send_error(&lex->thd->net, ER_SYNTAX_ERROR);
	      YYABORT;
	    }
            if (lex->select != &lex->select_lex)
            {
	      if (mysql_new_select(lex))
	        YYABORT;
	      mysql_init_select(lex);
	      lex->select->linkage=NOT_A_SELECT;
	      lex->select->select_limit=lex->thd->variables.select_limit;
            }
	  }
	  opt_order_clause limit_clause
	;