1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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

into eagle.mysql.r18.ru:/home/vva/work/BUG_2310/mysql-4.1
This commit is contained in:
vva@eagle.mysql.r18.ru
2004-01-20 00:34:38 +04:00
3 changed files with 23 additions and 1 deletions

View File

@ -6,10 +6,19 @@ inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"))
NULL NULL
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255"); select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255") inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255")
1099511627775 4294902271 511 1099511627775 4294902271 65791
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511); select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511) inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511)
NULL 255.255.1.255 0.0.1.255 NULL 255.255.1.255 0.0.1.255
select hex(inet_aton('127'));
hex(inet_aton('127'))
7F
select hex(inet_aton('127.1'));
hex(inet_aton('127.1'))
7F000001
select hex(inet_aton('127.1.1'));
hex(inet_aton('127.1.1'))
7F010001
select length(format('nan', 2)) > 0; select length(format('nan', 2)) > 0;
length(format('nan', 2)) > 0 length(format('nan', 2)) > 0
1 1

View File

@ -8,6 +8,10 @@ select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255"); select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511); select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
select hex(inet_aton('127'));
select hex(inet_aton('127.1'));
select hex(inet_aton('127.1.1'));
# #
# Test for core dump with nan # Test for core dump with nan
# #

View File

@ -2618,6 +2618,7 @@ longlong Item_func_inet_aton::val_int()
const char *p,* end; const char *p,* end;
char c = '.'; // we mark c to indicate invalid IP in case length is 0 char c = '.'; // we mark c to indicate invalid IP in case length is 0
char buff[36]; char buff[36];
int dot_count= 0;
String *s,tmp(buff,sizeof(buff),&my_charset_bin); String *s,tmp(buff,sizeof(buff),&my_charset_bin);
if (!(s = args[0]->val_str(&tmp))) // If null value if (!(s = args[0]->val_str(&tmp))) // If null value
@ -2636,6 +2637,7 @@ longlong Item_func_inet_aton::val_int()
} }
else if (c == '.') else if (c == '.')
{ {
dot_count++;
result= (result << 8) + (ulonglong) byte_result; result= (result << 8) + (ulonglong) byte_result;
byte_result = 0; byte_result = 0;
} }
@ -2643,7 +2645,14 @@ longlong Item_func_inet_aton::val_int()
goto err; // Invalid character goto err; // Invalid character
} }
if (c != '.') // IP number can't end on '.' if (c != '.') // IP number can't end on '.'
{
switch (dot_count)
{
case 1: result<<= 8;
case 2: result<<= 8;
}
return (result << 8) + (ulonglong) byte_result; return (result << 8) + (ulonglong) byte_result;
}
err: err:
null_value=1; null_value=1;