IS_IPV4_STRING

IS_IPV4_STRING

Description

Syntax

BOOLEAN IS_IPV4_STRING(STRING ipv4_str)

Receive an IPv4 address in the form of a string as a parameter. If it is a correctly formatted and valid IPv4 address, return true; On the contrary, return false.

Notice

If the input parameter is NULL, return NULL, indicating invalid input

Example

  1. mysql> select is_ipv4_string(NULL);
  2. +----------------------+
  3. | is_ipv4_string(NULL) |
  4. +----------------------+
  5. | NULL |
  6. +----------------------+
  7. mysql> CREATE TABLE `test_is_ipv4_string` (
  8. `id` int,
  9. `ip_v4` string
  10. ) ENGINE=OLAP
  11. DISTRIBUTED BY HASH(`id`) BUCKETS 4
  12. PROPERTIES (
  13. "replication_allocation" = "tag.location.default: 1"
  14. );
  15. mysql> insert into test_is_ipv4_string values(0, NULL), (1, '0.0.0.'), (2, ''), (3, '.'), (4, '255.255.255.255');
  16. mysql> select id, is_ipv4_string(ip_v4) from test_is_ipv4_string order by id;
  17. +------+-----------------------+
  18. | id | is_ipv4_string(ip_v4) |
  19. +------+-----------------------+
  20. | 0 | NULL |
  21. | 1 | 0 |
  22. | 2 | 0 |
  23. | 3 | 0 |
  24. | 4 | 1 |
  25. +------+-----------------------+

Keywords

IS_IPV4_STRING, IP