Commit 2a695127 authored by unknown's avatar unknown

Fixes during review


mysql-test/r/select.result:
  Better error message
mysql-test/t/select.test:
  Better error message
sql/hostname.cc:
  Join identical code
sql/sql_yacc.yy:
  Combine code (and get a better error message)
strings/ctype-ucs2.c:
  Cast pointer differencess
parent cbbc4ff6
...@@ -2451,7 +2451,7 @@ a ...@@ -2451,7 +2451,7 @@ a
select distinct distinct * from t1; select distinct distinct * from t1;
a a
select all distinct * from t1; 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 ERROR HY000: Incorrect usage of ALL and DISTINCT
select distinct all * from t1; 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 ERROR HY000: Incorrect usage of ALL and DISTINCT
drop table t1; drop table t1;
...@@ -1987,9 +1987,9 @@ drop table t1; ...@@ -1987,9 +1987,9 @@ drop table t1;
create table t1 (a int(11)); create table t1 (a int(11));
select all all * from t1; select all all * from t1;
select distinct distinct * from t1; select distinct distinct * from t1;
--error 1064 --error 1221
select all distinct * from t1; select all distinct * from t1;
--error 1064 --error 1221
select distinct all * from t1; select distinct all * from t1;
drop table t1; drop table t1;
......
...@@ -209,8 +209,8 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors) ...@@ -209,8 +209,8 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
DBUG_PRINT("error",("gethostbyaddr returned %d",errno)); DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
if (errno == HOST_NOT_FOUND || errno == NO_DATA) if (errno == HOST_NOT_FOUND || errno == NO_DATA)
add_wrong_ip(in); /* only cache negative responses, not failures */ goto add_wrong_ip_and_return;
/* Failure, don't cache responce */
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!hp->h_name[0]) // Don't allow empty hostnames if (!hp->h_name[0]) // Don't allow empty hostnames
......
...@@ -2467,7 +2467,14 @@ select_from: ...@@ -2467,7 +2467,14 @@ select_from:
select_options: select_options:
/* empty*/ /* empty*/
| select_option_list; | select_option_list
{
if (test_all_bits(Select->options, SELECT_ALL | SELECT_DISTINCT))
{
net_printf(Lex->thd, ER_WRONG_USAGE, "ALL", "DISTINCT");
YYABORT;
}
}
select_option_list: select_option_list:
select_option_list select_option select_option_list select_option
...@@ -2481,15 +2488,7 @@ select_option: ...@@ -2481,15 +2488,7 @@ select_option:
YYABORT; YYABORT;
Lex->lock_option= TL_READ_HIGH_PRIORITY; Lex->lock_option= TL_READ_HIGH_PRIORITY;
} }
| DISTINCT | DISTINCT { Select->options|= SELECT_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
...@@ -2509,15 +2508,7 @@ select_option: ...@@ -2509,15 +2508,7 @@ select_option:
{ {
Lex->select_lex.options|= OPTION_TO_QUERY_CACHE; Lex->select_lex.options|= OPTION_TO_QUERY_CACHE;
} }
| ALL | ALL { Select->options|= SELECT_ALL; }
{
if (Select->options & SELECT_DISTINCT)
{
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
Select->options|= SELECT_ALL;
}
; ;
select_lock_type: select_lock_type:
......
...@@ -1251,7 +1251,7 @@ static ...@@ -1251,7 +1251,7 @@ static
uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e) const char *b, const char *e)
{ {
return (e-b)/2; return (uint) (e-b)/2;
} }
...@@ -1261,7 +1261,8 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), ...@@ -1261,7 +1261,8 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *e __attribute__((unused)), const char *e __attribute__((unused)),
uint pos) uint pos)
{ {
return pos > e - b ? e - b + 2 : pos * 2; uint string_length= (uint) (e - b);
return pos > string_length ? string_length + 2 : pos * 2;
} }
...@@ -1270,7 +1271,8 @@ uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), ...@@ -1270,7 +1271,8 @@ uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e, const char *b, const char *e,
uint nchars, int *error) uint nchars, int *error)
{ {
uint nbytes= (e-b) & ~ (uint)1; /* Ensure string length is dividable with 2 */
uint nbytes= ((uint) (e-b)) & ~(uint) 1;
*error= 0; *error= 0;
nchars*= 2; nchars*= 2;
return min(nbytes, nchars); return min(nbytes, nchars);
......
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