summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-05-13 14:04:32 +0300
committerunknown <monty@mysql.com>2005-05-13 14:04:32 +0300
commit2a695127a65a321b98f0db6f1b113af3403376e3 (patch)
treee79a2291f34c9b4f5b7aa00b0d318368038008da
parentcbbc4ff6a25accdd3e11a0e2719c2201d23a7b68 (diff)
downloadmariadb-git-2a695127a65a321b98f0db6f1b113af3403376e3.tar.gz
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
-rw-r--r--mysql-test/r/select.result4
-rw-r--r--mysql-test/t/select.test4
-rw-r--r--sql/hostname.cc4
-rw-r--r--sql/sql_yacc.yy29
-rw-r--r--strings/ctype-ucs2.c8
5 files changed, 21 insertions, 28 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 50300ed9b76..387e7eff693 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2451,7 +2451,7 @@ 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
+ERROR HY000: Incorrect usage of ALL and DISTINCT
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;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 6d6d5f6b6e1..a46522c1510 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -1987,9 +1987,9 @@ drop table t1;
create table t1 (a int(11));
select all all * from t1;
select distinct distinct * from t1;
---error 1064
+--error 1221
select all distinct * from t1;
---error 1064
+--error 1221
select distinct all * from t1;
drop table t1;
diff --git a/sql/hostname.cc b/sql/hostname.cc
index ec5c6f29a27..39223556024 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -209,8 +209,8 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
DBUG_PRINT("error",("gethostbyaddr returned %d",errno));
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);
}
if (!hp->h_name[0]) // Don't allow empty hostnames
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index abe7a716a69..28d3560e5f0 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2467,7 +2467,14 @@ select_from:
select_options:
/* 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
@@ -2481,15 +2488,7 @@ select_option:
YYABORT;
Lex->lock_option= TL_READ_HIGH_PRIORITY;
}
- | DISTINCT
- {
- if (Select->options & SELECT_ALL)
- {
- yyerror(ER(ER_SYNTAX_ERROR));
- YYABORT;
- }
- Select->options|= SELECT_DISTINCT;
- }
+ | DISTINCT { Select->options|= SELECT_DISTINCT; }
| SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
| SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; }
| SQL_BUFFER_RESULT
@@ -2509,15 +2508,7 @@ select_option:
{
Lex->select_lex.options|= OPTION_TO_QUERY_CACHE;
}
- | ALL
- {
- if (Select->options & SELECT_DISTINCT)
- {
- yyerror(ER(ER_SYNTAX_ERROR));
- YYABORT;
- }
- Select->options|= SELECT_ALL;
- }
+ | ALL { Select->options|= SELECT_ALL; }
;
select_lock_type:
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index f12cfe3256e..12c1ae905cf 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1251,7 +1251,7 @@ static
uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)),
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)),
const char *e __attribute__((unused)),
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)),
const char *b, const char *e,
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;
nchars*= 2;
return min(nbytes, nchars);