Bug #21466 INET_ATON() returns signed value, not unsigned
Submitted: 6 Aug 2006 23:59 Modified: 11 Dec 2006 4:41
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:all OS:
Assigned to: Jay Pipes CPU Architecture:Any

[6 Aug 2006 23:59] Paul DuBois
Description:
INET_ATON() appears to return a signed BIGINT value,
whereas IP numbers are better represented as unsigned
values.

How to repeat:
mysql> create table t select inet_aton('127.0.0.1') as i;
Query OK, 1 row affected (0.07 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> show create table t;
+-------+-----------------------------------------------------------------------------------------+
| Table | Create Table                                                                            |
+-------+-----------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `i` bigint(21) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | 
+-------+-----------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
[7 Aug 2006 12:07] Hartmut Holzgraefe
verified on the API level, too:

<?php

mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

$result = mysql_query("select inet_aton('129.0.0.1') as i, CAST(inet_aton('129.0.0.1') as unsigned) as j") or die(mysql_error());
   $meta = mysql_fetch_field($result, 0);
   echo "
name:        $meta->name
type:        $meta->type
unsigned:    $meta->unsigned
";

   $meta = mysql_fetch_field($result, 1);
   echo "
name:        $meta->name
type:        $meta->type
unsigned:    $meta->unsigned
";
?>

name:        i
type:        int
unsigned:    0

name:        j
type:        int
unsigned:    1
[22 Sep 2006 2:51] Jay Pipes
Fixed in mysql-5.1-new-maint

Created new test (func_inetaton) all tests pass.
[25 Sep 2006 18:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/12498

ChangeSet@1.2287, 2006-09-25 14:58:10-04:00, jpipes@shakedown.(none) +3 -0
  Fix for Bug #21466: INET_ATON() returns signed int, not unsigned
[25 Sep 2006 20:31] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/12502

ChangeSet@1.2322, 2006-09-25 15:43:28-04:00, jpipes@shakedown.(none) +3 -0
  Test and fix for Bug #21466: INET_ATON() returns signed int, not unsigned
[11 Dec 2006 4:41] Paul DuBois
Noted in 5.0.32, 5.1.15 changelogs.

INET_ATON() returned a signed BIGINT value, not an unsigned value.