Skip to main content
Version: V1.0.0

IS_IPV4

Declaration

IS_IPV4(expr)

Description

Returns 1 if the expr parameter is a valid IPv4 address string, otherwise returns 0.

For the specified parameter, if IS_IPV4() returns 1, then INET_ATON() and INET6_ATON() return a non-NULL value. Conversely, it is not always true that when IS_IPV4() returns 0, INET_ATON() returns a non-NULL value. IS_IPV4() has stricter requirements for IPv4 addresses than INET_ATON(), and INET6_ATON() is as powerful as IS_IPV4() in checking IPv4 addresses.

Examples

SELECT IS_IPV4('10.x.x.9'), IS_IPV4('10.x.x.256');
+---------------------+-----------------------+
| IS_IPV4('10.x.x.9') | IS_IPV4('10.x.x.256') |
+---------------------+-----------------------+
| 1 | 0 |
+---------------------+-----------------------+
1 row in set (0.001 sec)