diff --git a/innobase/include/univ.i b/innobase/include/univ.i index 4854e5a7b78..12846593977 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -86,8 +86,10 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ +#ifdef DBUG_ON +# define UNIV_DEBUG +#endif /* DBUG_ON */ /* -#define UNIV_DEBUG #define UNIV_SYNC_DEBUG #define UNIV_MEM_DEBUG diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 859d9d4cab0..4ea638dbc19 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -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; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 86ecc4aa70d..d65b2c257a1 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -363,4 +363,15 @@ while ($1) 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; \ No newline at end of file +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; + diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7b72c73a915..6d0237f5615 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4033,11 +4033,14 @@ optional_order_or_limit: send_error(&lex->thd->net, ER_SYNTAX_ERROR); YYABORT; } - 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; + 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 ;