TO_IPV4_OR_DEFAULT

SinceVersion dev

TO_IPV4_OR_DEFAULT

description

Syntax

IPV4 TO_IPV4_OR_DEFAULT(STRING ipv4_str)

Same as to_ipv4, but if the IPv4 address has an invalid format, it returns 0.0.0.0 (0 as IPv4).

notice

If input is NULL, return 0.0.0.0 (0 as IPv4).

example

1. mysql> select to_ipv4_or_default('.');
2. +-------------------------+
3. | to_ipv4_or_default('.') |
4. +-------------------------+
5. | 0.0.0.0                 |
6. +-------------------------+

8. mysql> select to_ipv4_or_default(NULL);
9. +--------------------------+
10. | to_ipv4_or_default(NULL) |
11. +--------------------------+
12. | 0.0.0.0                  |
13. +--------------------------+

keywords

TO_IPV4_OR_DEFAULT, IP