Bug #58281 The documentation for 'INET_NTOA(expr)' is incorrect
Submitted: 18 Nov 2010 10:07 Modified: 19 Nov 2010 16:21
Reporter: Tim Rutter Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version: OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: inet_ntoa

[18 Nov 2010 10:07] Tim Rutter
The documentation reads
"- INET_NTOA(expr)

Given a numeric network address in network byte order (4 or 8 byte), returns the dotted-quad representation of the address as a string.

mysql> SELECT INET_NTOA(3520061480);
        -> ''
The error is " as a string." is actually is " as binary."

phpMyAdmin autocasts binary to hex by default

How to repeat:
Follow the documentation at

Suggested fix:
Example correction
"- INET_NTOA(expr)

Given a numeric network address in network byte order (4 or 8 byte), returns the dotted-quad representation of the address as binary, The mysql command will autocast this as a string.

mysql> SELECT INET_NTOA(3520061480);
        -> '' // Autocast to string

mysql> SELECT CAST( INET_NTOA(3520061480) AS CHAR );
        -> '' // Real string
[18 Nov 2010 13:55] Valeriy Kravchuk
Indeed, we have a binary string as a result:

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -uroot -proot -P3310 --column-
type-info test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.1.52-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT INET_NTOA(3520061480);
Field   1:  `INET_NTOA(3520061480)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  binary (63)
Length:     31
Max_length: 14
Decimals:   0
Flags:      BINARY

| INET_NTOA(3520061480) |
|        |
1 row in set (0.05 sec)

and this should be highlighted in the manual.
[19 Nov 2010 15:38] Paul DuBois
Will investigate the return type of this function. One note: A binary string *is* a "real string."

A nonbinary string is a character string. A binary string is a string of bytes with no character set (or the 'binary' character set, if you like). Both are strings.

More info: http://dev.mysql.com/doc/refman/5.5/en/binary-varbinary.html
[19 Nov 2010 15:50] Paul DuBois
The return type is a binary string up to MySQL 5.5.2:

mysql> SELECT CHARSET(INET_NTOA(3520061480));
| CHARSET(INET_NTOA(3520061480)) |
| binary                         |

In 5.5.3, the return type becomes a character string with the connection character set:

mysql> SELECT CHARSET(INET_NTOA(3520061480));
| CHARSET(INET_NTOA(3520061480)) |
| utf8                           |

I suspect this is due to the work done for WL#2649, although I do not see INET_NTOA() named there.
[19 Nov 2010 16:21] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Confirmed: This function was modified by WL#2649.

As of MySQL 5.5.3, the return value is a nonbinary string in the
connection character set. Before 5.5.3, the return value is a binary