Commit ddf6225d authored by antony@ltantony.mysql.com's avatar antony@ltantony.mysql.com

Merge acurtis@bk-internal.mysql.com:/home/bk/mysql-4.1

into ltantony.mysql.com:/usr/home/antony/work2/p3-bug8733
parents fee81b6d cc3bfc6f
...@@ -2445,3 +2445,13 @@ cast((a - b) as unsigned) ...@@ -2445,3 +2445,13 @@ cast((a - b) as unsigned)
1 1
18446744073709551615 18446744073709551615
drop table t1; drop table t1;
create table t1 (a int(11));
select all all * from t1;
a
select distinct distinct * from t1;
a
select all distinct * from t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct * from t1' at line 1
select distinct all * from t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'all * from t1' at line 1
drop table t1;
...@@ -1979,3 +1979,19 @@ select a-b , (a-b < 0) from t1 order by 1; ...@@ -1979,3 +1979,19 @@ select a-b , (a-b < 0) from t1 order by 1;
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
select cast((a - b) as unsigned) from t1 order by 1; select cast((a - b) as unsigned) from t1 order by 1;
drop table t1; drop table t1;
#
# Bug#8733 server accepts malformed query (multiply mentioned distinct)
#
create table t1 (a int(11));
select all all * from t1;
select distinct distinct * from t1;
--error 1064
select all distinct * from t1;
--error 1064
select distinct all * from t1;
drop table t1;
#
...@@ -211,6 +211,9 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; ...@@ -211,6 +211,9 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
key checks in some cases */ key checks in some cases */
#define OPTION_RELAXED_UNIQUE_CHECKS (1L << 27) #define OPTION_RELAXED_UNIQUE_CHECKS (1L << 27)
#define SELECT_NO_UNLOCK (1L << 28) #define SELECT_NO_UNLOCK (1L << 28)
/* Thr following is used to detect a conflict with DISTINCT
in the user query has requested */
#define SELECT_ALL (1L << 29)
/* If set to 0, then the thread will ignore all warnings with level notes. /* If set to 0, then the thread will ignore all warnings with level notes.
Set by executing SET SQL_NOTES=1 */ Set by executing SET SQL_NOTES=1 */
......
...@@ -2481,7 +2481,15 @@ select_option: ...@@ -2481,7 +2481,15 @@ select_option:
YYABORT; YYABORT;
Lex->lock_option= TL_READ_HIGH_PRIORITY; Lex->lock_option= TL_READ_HIGH_PRIORITY;
} }
| DISTINCT { Select->options|= SELECT_DISTINCT; } | DISTINCT
{
if (Select->options & SELECT_ALL)
{
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
Select->options|= SELECT_DISTINCT;
}
| SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; } | SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
| SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; } | SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; }
| SQL_BUFFER_RESULT | SQL_BUFFER_RESULT
...@@ -2501,7 +2509,15 @@ select_option: ...@@ -2501,7 +2509,15 @@ select_option:
{ {
Lex->select_lex.options|= OPTION_TO_QUERY_CACHE; Lex->select_lex.options|= OPTION_TO_QUERY_CACHE;
} }
| ALL {} | ALL
{
if (Select->options & SELECT_DISTINCT)
{
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
Select->options|= SELECT_ALL;
}
; ;
select_lock_type: select_lock_type:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment