Commit 4211b1cd authored by Alexander Barkov's avatar Alexander Barkov

MDEV-4051 INET6_ATON() and INET6_NTOA()

Backporting functions from MySQL-5.6:

- INET6_ATON()
- INET6_NTOA()
- IS_IPV4()
- IS_IPV4_COMPAT()
- IS_IPV4_MAPPED()
- IS_IPV6()
parent 1449d1d5
This diff is collapsed.
......@@ -572,3 +572,297 @@ select release_lock(repeat('a', 193));
--echo #
--echo # End of 5.5 tests
--echo #
--echo
--echo # --
--echo # -- WL#5787: IPv6-capable INET_ATON and INET_NTOA functions.
--echo # --
--echo
--echo # -- INET6_ATON: checking NULL, invalid types, out-of range values...
--echo
SELECT INET6_ATON(NULL) IS NULL;
SELECT INET6_ATON(123) IS NULL;
SELECT INET6_ATON(123.45) IS NULL;
SELECT INET6_ATON(NOW()) IS NULL;
SELECT INET6_ATON('1.2.3') IS NULL;
SELECT INET6_ATON('1.2.3.') IS NULL;
SELECT INET6_ATON('1..3.4') IS NULL;
SELECT INET6_ATON('-1.2.3.4') IS NULL;
SELECT INET6_ATON('1.2.3.256') IS NULL;
SELECT INET6_ATON('1.2.3.4.5') IS NULL;
SELECT INET6_ATON('0001.2.3.4') IS NULL;
SELECT INET6_ATON('0x1.2.3.4') IS NULL;
SELECT INET6_ATON('a.2.3.4') IS NULL;
SELECT INET6_ATON('1.2.3.4:80') IS NULL;
SELECT INET6_ATON('1.2.3.4/32') IS NULL;
SELECT INET6_ATON('mysql.com') IS NULL;
SELECT INET6_ATON(':::') IS NULL;
SELECT INET6_ATON(':1:2:3') IS NULL;
SELECT INET6_ATON('1:2:3:') IS NULL;
SELECT INET6_ATON(':1::2:3') IS NULL;
SELECT INET6_ATON('1::2:3:') IS NULL;
SELECT INET6_ATON('::00001') IS NULL;
SELECT INET6_ATON('::00001:2') IS NULL;
SELECT INET6_ATON('::12345') IS NULL;
SELECT INET6_ATON('1020::3040::5060') IS NULL;
SELECT INET6_ATON('::ABCZ') IS NULL;
SELECT INET6_ATON('::0x1.2.3.4') IS NULL;
SELECT INET6_ATON('::1.0x2.3.4') IS NULL;
SELECT INET6_ATON('::a.b.c.d') IS NULL;
SELECT INET6_ATON('::FFFF:0x1.2.3.4') IS NULL;
SELECT INET6_ATON('::FFFF:1.0x2.3.4') IS NULL;
SELECT INET6_ATON('::FFFF:a.b.c.d') IS NULL;
SELECT INET6_ATON('::1.2.3.4:ABCD') IS NULL;
--echo # NOTE: such addresses are supported because getaddrinfo() supports them.
--echo # This is just to record the current behaviour.
SELECT HEX(INET6_ATON('::ABCD:1.2.3.4'));
--echo
--echo # -- INET6_ATON: checking binary representation...
--echo
SELECT HEX(INET6_ATON('0.0.0.0'));
SELECT HEX(INET6_ATON('00.00.00.00'));
SELECT HEX(INET6_ATON('000.000.000.000'));
SELECT HEX(INET6_ATON('1.2.3.4'));
SELECT HEX(INET6_ATON('01.02.03.04'));
SELECT HEX(INET6_ATON('001.002.003.004'));
SELECT HEX(INET6_ATON('255.255.255.255'));
SELECT HEX(INET6_ATON('::'));
SELECT HEX(INET6_ATON('0::0'));
SELECT HEX(INET6_ATON('1::2'));
SELECT HEX(INET6_ATON('0::'));
SELECT HEX(INET6_ATON('1::'));
SELECT HEX(INET6_ATON('::0'));
SELECT HEX(INET6_ATON('::1'));
SELECT HEX(INET6_ATON('1:2:3:4:5:6:7:8'));
SELECT HEX(INET6_ATON('::2:3:4:5:6:7:8'));
SELECT HEX(INET6_ATON('1::3:4:5:6:7:8'));
SELECT HEX(INET6_ATON('1:2::4:5:6:7:8'));
SELECT HEX(INET6_ATON('1:2:3::5:6:7:8'));
SELECT HEX(INET6_ATON('1:2:3:4::6:7:8'));
SELECT HEX(INET6_ATON('1:2:3:4:5::7:8'));
SELECT HEX(INET6_ATON('1:2:3:4:5:6::8'));
SELECT HEX(INET6_ATON('1:2:3:4:5:6:7::'));
SELECT HEX(INET6_ATON('0000:0000::0000:0001'));
SELECT HEX(INET6_ATON('1234:5678:9abc:def0:4321:8765:cba9:0fed'));
SELECT HEX(INET6_ATON('0000:0000:0000:0000:0000:0000:0000:0001'));
SELECT HEX(INET6_ATON('::C0A8:0102'));
SELECT HEX(INET6_ATON('::c0a8:0102'));
SELECT HEX(INET6_ATON('::192.168.1.2'));
SELECT HEX(INET6_ATON('::FfFf:C0a8:0102'));
SELECT HEX(INET6_ATON('::ffff:c0a8:0102'));
SELECT HEX(INET6_ATON('::ffff:192.168.1.2'));
SELECT HEX(INET6_ATON('::01.2.3.4'));
SELECT HEX(INET6_ATON('::1.02.3.4'));
SELECT HEX(INET6_ATON('::1.2.03.4'));
SELECT HEX(INET6_ATON('::1.2.3.04'));
SELECT HEX(INET6_ATON('::1.2.3.00'));
SELECT HEX(INET6_ATON('::FFFF:01.2.3.4'));
SELECT HEX(INET6_ATON('::FFFF:1.02.3.4'));
SELECT HEX(INET6_ATON('::FFFF:1.2.03.4'));
SELECT HEX(INET6_ATON('::FFFF:1.2.3.04'));
SELECT HEX(INET6_ATON('::FFFF:1.2.3.00'));
--echo
--echo # -- INET6_ATON: checking the length is either 4 or 16...
--echo
SELECT LENGTH(INET6_ATON('0.0.0.0'));
SELECT LENGTH(INET6_ATON('255.255.255.255'));
SELECT LENGTH(INET6_ATON('::'));
SELECT LENGTH(INET6_ATON('1020:3040:5060:7080:90A0:B0C0:D0E0:F010'));
--echo
--echo # -- INET6_NTOA: checking NULL, invalid types, out-of range values...
--echo
SELECT INET6_NTOA(NULL);
SELECT INET6_NTOA(123);
SELECT INET6_NTOA(123.456);
SELECT INET6_NTOA(NOW());
SELECT INET6_NTOA(UNHEX('C0A801')); # 3 bytes -> NULL
SELECT INET6_NTOA(UNHEX('C0A80102')); # 4 bytes -> 192.168.1.2
SELECT INET6_NTOA(UNHEX('C0A8010203')); # 5 bytes -> NULL
SELECT INET6_NTOA(UNHEX('0102030405060708090A0B0C0D0E0F')); # 15 bytes -> NULL
SELECT INET6_NTOA(UNHEX('0102030405060708090A0B0C0D0E0F10')); # 16 bytes -> IP
SELECT INET6_NTOA(UNHEX('0102030405060708090A0B0C0D0E0F1011')); # 17 bytes -> NULL
SELECT INET6_NTOA('1234'), INET6_NTOA(BINARY('1234'));
SELECT INET6_NTOA('0123456789abcdef'), INET6_NTOA(BINARY('0123456789abcdef'));
--echo
--echo # -- Checking double-conversion...
--echo
SELECT INET6_NTOA(INET6_ATON('::'));
SELECT INET6_NTOA(INET6_ATON('0::0'));
SELECT INET6_NTOA(INET6_ATON('1::2'));
SELECT INET6_NTOA(INET6_ATON('0::'));
SELECT INET6_NTOA(INET6_ATON('1::'));
SELECT INET6_NTOA(INET6_ATON('::0'));
SELECT INET6_NTOA(INET6_ATON('::1'));
SELECT INET6_NTOA(INET6_ATON('1:2:3:4:5:6:7:8'));
SELECT INET6_NTOA(INET6_ATON('::2:3:4:5:6:7:8'));
SELECT INET6_NTOA(INET6_ATON('1::3:4:5:6:7:8'));
SELECT INET6_NTOA(INET6_ATON('1:2::4:5:6:7:8'));
SELECT INET6_NTOA(INET6_ATON('1:2:3::5:6:7:8'));
SELECT INET6_NTOA(INET6_ATON('1:2:3:4::6:7:8'));
SELECT INET6_NTOA(INET6_ATON('1:2:3:4:5::7:8'));
SELECT INET6_NTOA(INET6_ATON('1:2:3:4:5:6::8'));
SELECT INET6_NTOA(INET6_ATON('1:2:3:4:5:6:7::'));
SELECT INET6_NTOA(INET6_ATON('0000:0000::0000:0001'));
SELECT INET6_NTOA(INET6_ATON('1234:5678:9abc:def0:4321:8765:cba9:0fed'));
SELECT INET6_NTOA(INET6_ATON('0000:0000:0000:0000:0000:0000:0000:0001'));
SELECT INET6_NTOA(INET6_ATON('::C0A8:0102'));
SELECT INET6_NTOA(INET6_ATON('::c0a8:0102'));
SELECT INET6_NTOA(INET6_ATON('::192.168.1.2'));
SELECT INET6_NTOA(INET6_ATON('::FfFf:C0a8:0102'));
SELECT INET6_NTOA(INET6_ATON('::ffff:c0a8:0102'));
SELECT INET6_NTOA(INET6_ATON('::ffff:192.168.1.2'));
SELECT INET6_NTOA(INET6_ATON('::01.2.3.4'));
SELECT INET6_NTOA(INET6_ATON('::1.02.3.4'));
SELECT INET6_NTOA(INET6_ATON('::1.2.03.4'));
SELECT INET6_NTOA(INET6_ATON('::1.2.3.04'));
SELECT INET6_NTOA(INET6_ATON('::1.2.3.00'));
SELECT INET6_NTOA(INET6_ATON('::FFFF:01.2.3.4'));
SELECT INET6_NTOA(INET6_ATON('::FFFF:1.02.3.4'));
SELECT INET6_NTOA(INET6_ATON('::FFFF:1.2.03.4'));
SELECT INET6_NTOA(INET6_ATON('::FFFF:1.2.3.04'));
SELECT INET6_NTOA(INET6_ATON('::FFFF:1.2.3.00'));
--echo
--echo # -- Comparing INET_ATON() and INET6_ATON()...
--echo
SELECT HEX(INET_ATON('192.168.1.2'));
SELECT HEX(INET6_ATON('192.168.1.2'));
SELECT HEX(INET_ATON('255.255.255.255'));
SELECT HEX(INET6_ATON('255.255.255.255'));
SELECT HEX(INET_ATON('192.168.08.2'));
SELECT HEX(INET6_ATON('192.168.08.2'));
SELECT HEX(INET_ATON('192.168.0x8.2'));
SELECT HEX(INET6_ATON('192.168.0x8.2'));
SELECT HEX(INET_ATON('1.2.255'));
SELECT HEX(INET6_ATON('1.2.255'));
SELECT HEX(INET_ATON('1.2.256'));
SELECT HEX(INET6_ATON('1.2.256'));
SELECT HEX(INET_ATON('1.0002.3.4'));
SELECT HEX(INET6_ATON('1.0002.3.4'));
SELECT HEX(INET_ATON('1.2.3.4.5'));
SELECT HEX(INET6_ATON('1.2.3.4.5'));
--echo
--echo # -- Checking mix of INET- and INET6- functions...
--echo
SELECT HEX(INET6_ATON(INET_NTOA(INET_ATON('1.2.3.4')))) AS x;
--echo
--echo # -- Checking IS_IPV4() / IS_IPV6()...
--echo
SELECT IS_IPV4(NULL);
SELECT IS_IPV4(1);
SELECT IS_IPV4(1.0);
SELECT IS_IPV4('1.2.3.4');
SELECT IS_IPV4('001.02.000.255');
SELECT IS_IPV4('::1.2.0.255');
SELECT IS_IPV4('::1');
SELECT IS_IPV4(BINARY('1.2.3.4'));
SELECT IS_IPV6(NULL);
SELECT IS_IPV6(1);
SELECT IS_IPV6(1.0);
SELECT IS_IPV6('1.2.3.4');
SELECT IS_IPV6('001.02.000.255');
SELECT IS_IPV6('::001.02.000.255');
SELECT IS_IPV6('::1.2.0.255');
SELECT IS_IPV6('::1');
SELECT IS_IPV6('0000:0000:0000:0000:0000:0000:0000:0001');
SELECT IS_IPV6(BINARY('0000:0000:0000:0000:0000:0000:0000:0001'));
--echo
--echo # -- Checking IS_IPV4_MAPPED() and IS_IPV4_COMPAT()...
--echo
SELECT IS_IPV4_MAPPED(INET6_ATON('1.2.3.4')),
IS_IPV4_COMPAT(INET6_ATON('1.2.3.4'));
SELECT IS_IPV4_MAPPED(INET6_ATON('::1.2.3.4')),
IS_IPV4_COMPAT(INET6_ATON('::1.2.3.4'));
SELECT IS_IPV4_MAPPED(INET6_ATON('::FFFF:1.2.3.4')),
IS_IPV4_COMPAT(INET6_ATON('::FFFF:1.2.3.4'));
SELECT IS_IPV4_MAPPED(INET6_ATON('::ABCD:1.2.3.4')),
IS_IPV4_COMPAT(INET6_ATON('::ABCD:1.2.3.4'));
SELECT IS_IPV4_MAPPED(INET6_ATON('::1')),
IS_IPV4_COMPAT(INET6_ATON('::1'));
SELECT IS_IPV4_MAPPED(INET6_ATON('::')),
IS_IPV4_COMPAT(INET6_ATON('::'));
# NOTE: IS_IPV4_COMPAT() / IS_IPV4_MAPPED() could work with "regular strings in
# binary collation" too, but there is no way to create a "regular string"
# starting with \0.
--echo
--echo # -- Checking IS_IPV4_COMPAT()...
--echo
--echo
--echo # -- Working with a table...
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings
CREATE TABLE t1(ip INT UNSIGNED);
CREATE TABLE t2(ip VARBINARY(16));
--echo
INSERT INTO t1 VALUES
(INET_ATON('1.2.3.4')), (INET_ATON('255.255.255.255'));
SELECT INET_NTOA(ip) FROM t1;
--echo
INSERT INTO t2 SELECT INET6_ATON(INET_NTOA(ip)) FROM t1;
SELECT INET6_NTOA(ip), HEX(ip), LENGTH(ip) FROM t2;
DELETE FROM t2;
--echo
INSERT INTO t2 VALUES
(INET6_ATON('1.2.3.4')), (INET6_ATON('255.255.255.255')),
(INET6_ATON('::1.2.3.4')), (INET6_ATON('::ffff:255.255.255.255')),
(INET6_ATON('::')), (INET6_ATON('::1')),
(INET6_ATON('1020:3040:5060:7080:90A0:B0C0:D0E0:F010'));
SELECT INET6_NTOA(ip), HEX(ip), LENGTH(ip) FROM t2;
--echo
DROP TABLE t1;
DROP TABLE t2;
--echo
--echo # -- Done.
--echo
......@@ -1344,6 +1344,84 @@ class Create_func_inet_aton : public Create_func_arg1
};
class Create_func_inet6_aton : public Create_func_arg1
{
public:
virtual Item *create_1_arg(THD *thd, Item *arg1);
static Create_func_inet6_aton s_singleton;
protected:
Create_func_inet6_aton() {}
virtual ~Create_func_inet6_aton() {}
};
class Create_func_inet6_ntoa : public Create_func_arg1
{
public:
virtual Item *create_1_arg(THD *thd, Item *arg1);
static Create_func_inet6_ntoa s_singleton;
protected:
Create_func_inet6_ntoa() {}
virtual ~Create_func_inet6_ntoa() {}
};
class Create_func_is_ipv4 : public Create_func_arg1
{
public:
virtual Item *create_1_arg(THD *thd, Item *arg1);
static Create_func_is_ipv4 s_singleton;
protected:
Create_func_is_ipv4() {}
virtual ~Create_func_is_ipv4() {}
};
class Create_func_is_ipv6 : public Create_func_arg1
{
public:
virtual Item *create_1_arg(THD *thd, Item *arg1);
static Create_func_is_ipv6 s_singleton;
protected:
Create_func_is_ipv6() {}
virtual ~Create_func_is_ipv6() {}
};
class Create_func_is_ipv4_compat : public Create_func_arg1
{
public:
virtual Item *create_1_arg(THD *thd, Item *arg1);
static Create_func_is_ipv4_compat s_singleton;
protected:
Create_func_is_ipv4_compat() {}
virtual ~Create_func_is_ipv4_compat() {}
};
class Create_func_is_ipv4_mapped : public Create_func_arg1
{
public:
virtual Item *create_1_arg(THD *thd, Item *arg1);
static Create_func_is_ipv4_mapped s_singleton;
protected:
Create_func_is_ipv4_mapped() {}
virtual ~Create_func_is_ipv4_mapped() {}
};
class Create_func_instr : public Create_func_arg2
{
public:
......@@ -4140,6 +4218,24 @@ Create_func_inet_ntoa::create_1_arg(THD *thd, Item *arg1)
}
Create_func_inet6_aton Create_func_inet6_aton::s_singleton;
Item*
Create_func_inet6_aton::create_1_arg(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_inet6_aton(arg1);
}
Create_func_inet6_ntoa Create_func_inet6_ntoa::s_singleton;
Item*
Create_func_inet6_ntoa::create_1_arg(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_inet6_ntoa(arg1);
}
Create_func_inet_aton Create_func_inet_aton::s_singleton;
Item*
......@@ -4149,6 +4245,42 @@ Create_func_inet_aton::create_1_arg(THD *thd, Item *arg1)
}
Create_func_is_ipv4 Create_func_is_ipv4::s_singleton;
Item*
Create_func_is_ipv4::create_1_arg(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_is_ipv4(arg1);
}
Create_func_is_ipv6 Create_func_is_ipv6::s_singleton;
Item*
Create_func_is_ipv6::create_1_arg(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_is_ipv6(arg1);
}
Create_func_is_ipv4_compat Create_func_is_ipv4_compat::s_singleton;
Item*
Create_func_is_ipv4_compat::create_1_arg(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_is_ipv4_compat(arg1);
}
Create_func_is_ipv4_mapped Create_func_is_ipv4_mapped::s_singleton;
Item*
Create_func_is_ipv4_mapped::create_1_arg(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_is_ipv4_mapped(arg1);
}
Create_func_instr Create_func_instr::s_singleton;
Item*
......@@ -5586,6 +5718,12 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("IFNULL") }, BUILDER(Create_func_ifnull)},
{ { C_STRING_WITH_LEN("INET_ATON") }, BUILDER(Create_func_inet_aton)},
{ { C_STRING_WITH_LEN("INET_NTOA") }, BUILDER(Create_func_inet_ntoa)},
{ { C_STRING_WITH_LEN("INET6_ATON") }, BUILDER(Create_func_inet6_aton)},
{ { C_STRING_WITH_LEN("INET6_NTOA") }, BUILDER(Create_func_inet6_ntoa)},
{ { C_STRING_WITH_LEN("IS_IPV4") }, BUILDER(Create_func_is_ipv4)},
{ { C_STRING_WITH_LEN("IS_IPV6") }, BUILDER(Create_func_is_ipv6)},
{ { C_STRING_WITH_LEN("IS_IPV4_COMPAT") }, BUILDER(Create_func_is_ipv4_compat)},
{ { C_STRING_WITH_LEN("IS_IPV4_MAPPED") }, BUILDER(Create_func_is_ipv4_mapped)},
{ { C_STRING_WITH_LEN("INSTR") }, BUILDER(Create_func_instr)},
{ { C_STRING_WITH_LEN("INTERIORRINGN") }, GEOM_BUILDER(Create_func_interiorringn)},
{ { C_STRING_WITH_LEN("INTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
......
This diff is collapsed.
......@@ -30,7 +30,13 @@ class Item_func_inet_aton : public Item_int_func
Item_func_inet_aton(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "inet_aton"; }
void fix_length_and_dec() { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;}
void fix_length_and_dec()
{
decimals= 0;
max_length= 21;
maybe_null= 1;
unsigned_flag= 1;
}
};
......@@ -41,17 +47,198 @@ class Item_func_inet_aton : public Item_int_func
class Item_func_inet_ntoa : public Item_str_func
{
public:
Item_func_inet_ntoa(Item *a) :Item_str_func(a)
{
}
Item_func_inet_ntoa(Item *a)
: Item_str_func(a)
{ }
String* val_str(String* str);
const char *func_name() const { return "inet_ntoa"; }
void fix_length_and_dec()
{
decimals= 0;
fix_length_and_charset(3 * 8 + 7, default_charset());
void fix_length_and_dec()
{
decimals= 0;
fix_length_and_charset(3 * 8 + 7, default_charset());
maybe_null= 1;
}
};
/*************************************************************************
Item_func_inet_bool_base implements common code for INET6/IP-related
functions returning boolean value.
*************************************************************************/
class Item_func_inet_bool_base : public Item_bool_func
{
public:
inline Item_func_inet_bool_base(Item *ip_addr)
: Item_bool_func(ip_addr)
{
null_value= false;
}
public:
virtual longlong val_int();
protected:
virtual bool calc_value(const String *arg) = 0;
};
/*************************************************************************
Item_func_inet_str_base implements common code for INET6/IP-related
functions returning string value.
*************************************************************************/
class Item_func_inet_str_base : public Item_str_ascii_func
{
public:
inline Item_func_inet_str_base(Item *arg)
: Item_str_ascii_func(arg)
{ }
public:
virtual String *val_str_ascii(String *buffer);
protected:
virtual bool calc_value(String *arg, String *buffer) = 0;
};
/*************************************************************************
Item_func_inet6_aton implements INET6_ATON() SQL-function.
*************************************************************************/
class Item_func_inet6_aton : public Item_func_inet_str_base
{
public:
inline Item_func_inet6_aton(Item *ip_addr)
: Item_func_inet_str_base(ip_addr)
{ }
public:
virtual const char *func_name() const
{ return "inet6_aton"; }
virtual void fix_length_and_dec()
{
decimals= 0;
fix_length_and_charset(16, &my_charset_bin);
maybe_null= 1;
}
protected:
virtual bool calc_value(String *arg, String *buffer);
};
/*************************************************************************
Item_func_inet6_ntoa implements INET6_NTOA() SQL-function.
*************************************************************************/
class Item_func_inet6_ntoa : public Item_func_inet_str_base
{
public:
inline Item_func_inet6_ntoa(Item *ip_addr)
: Item_func_inet_str_base(ip_addr)
{ }
public:
virtual const char *func_name() const
{ return "inet6_ntoa"; }
virtual void fix_length_and_dec()
{
decimals= 0;
// max length: IPv6-address -- 16 bytes
// 16 bytes / 2 bytes per group == 8 groups => 7 delimiter
// 4 symbols per group
fix_length_and_charset(8 * 4 + 7, default_charset());
maybe_null= 1;
}
protected:
virtual bool calc_value(String *arg, String *buffer);
};
/*************************************************************************
Item_func_is_ipv4 implements IS_IPV4() SQL-function.
*************************************************************************/
class Item_func_is_ipv4 : public Item_func_inet_bool_base
{
public:
inline Item_func_is_ipv4(Item *ip_addr)
: Item_func_inet_bool_base(ip_addr)
{ }
public:
virtual const char *func_name() const
{ return "is_ipv4"; }
protected:
virtual bool calc_value(const String *arg);
};
/*************************************************************************
Item_func_is_ipv6 implements IS_IPV6() SQL-function.
*************************************************************************/
class Item_func_is_ipv6 : public Item_func_inet_bool_base
{
public:
inline Item_func_is_ipv6(Item *ip_addr)
: Item_func_inet_bool_base(ip_addr)
{ }
public:
virtual const char *func_name() const
{ return "is_ipv6"; }
protected:
virtual bool calc_value(const String *arg);
};
/*************************************************************************
Item_func_is_ipv4_compat implements IS_IPV4_COMPAT() SQL-function.
*************************************************************************/
class Item_func_is_ipv4_compat : public Item_func_inet_bool_base
{
public:
inline Item_func_is_ipv4_compat(Item *ip_addr)
: Item_func_inet_bool_base(ip_addr)
{ }
public:
virtual const char *func_name() const
{ return "is_ipv4_compat"; }
protected:
virtual bool calc_value(const String *arg);
};
/*************************************************************************
Item_func_is_ipv4_mapped implements IS_IPV4_MAPPED() SQL-function.
*************************************************************************/
class Item_func_is_ipv4_mapped : public Item_func_inet_bool_base
{
public:
inline Item_func_is_ipv4_mapped(Item *ip_addr)
: Item_func_inet_bool_base(ip_addr)
{ }
public:
virtual const char *func_name() const
{ return "is_ipv4_mapped"; }
protected:
virtual bool calc_value(const String *arg);
};
#endif // ITEM_INETFUNC_INCLUDED
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment