IS_IPV6_STRING

SinceVersion dev

IS_IPV6_STRING

description

Syntax

BOOLEAN IS_IPV6_STRING(STRING ipv6_str)

接收一个表示形式为字符串的IPv6地址作为参数,如果为格式正确且合法的IPv6地址,返回true;反之,返回false。

notice

如果入参为NULL,则返回NULL,表示无效输入

example

  1. mysql> select is_ipv6_string(NULL);
  2. +----------------------+
  3. | is_ipv6_string(NULL) |
  4. +----------------------+
  5. | NULL |
  6. +----------------------+
  7. mysql> CREATE TABLE `test_is_ipv6_string` (
  8. `id` int,
  9. `ip_v6` 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_ipv6_string values(0, NULL), (1, '::'), (2, ''), (3, '2001:1b70:a1:610::b102:2'), (4, 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffffg');
  16. mysql> select id, is_ipv6_string(ip_v6) from test_is_ipv6_string order by id;
  17. +------+-----------------------+
  18. | id | is_ipv6_string(ip_v6) |
  19. +------+-----------------------+
  20. | 0 | NULL |
  21. | 1 | 1 |
  22. | 2 | 0 |
  23. | 3 | 1 |
  24. | 4 | 0 |
  25. +------+-----------------------+

keywords

IS_IPV6_STRING, IP