diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-09-09 20:59:14 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-09-09 21:10:45 +0200 |
commit | ce7cd5141998e2f48b0b5a6448a94fddee1da750 (patch) | |
tree | a2fb7edd4fcd923d84bddc904c86099042b4f593 | |
parent | f899bcbca80c8ab5a7b0192c36b0979cb173909c (diff) | |
download | mariadb-git-bb-10.7-MDEV-4958-uuid.tar.gz |
-rw-r--r-- | plugin/type_inet/item_inetfunc.cc | 21 | ||||
-rw-r--r-- | plugin/type_inet/sql_type_inet.cc | 6 | ||||
-rw-r--r-- | plugin/type_inet/sql_type_inet.h | 20 | ||||
-rw-r--r-- | sql/sql_type_fixedbin.h | 6 |
4 files changed, 28 insertions, 25 deletions
diff --git a/plugin/type_inet/item_inetfunc.cc b/plugin/type_inet/item_inetfunc.cc index 8b32eb7366b..4d2f96f7cc9 100644 --- a/plugin/type_inet/item_inetfunc.cc +++ b/plugin/type_inet/item_inetfunc.cc @@ -221,23 +221,6 @@ longlong Item_func_is_ipv4::val_int() return !tmp.is_null() && !Inet4_null(*tmp.string()).is_null(); } -class IP6 : public Inet6Bundle::Fbt -{ -public: - IP6(Item* arg) : Inet6Bundle::Fbt(arg) {} - bool is_v4compat() const - { - static_assert(sizeof(in6_addr) == IN6_ADDR_SIZE, "unexpected in6_addr size"); - return IN6_IS_ADDR_V4COMPAT((struct in6_addr *) m_buffer); - } - bool is_v4mapped() const - { - static_assert(sizeof(in6_addr) == IN6_ADDR_SIZE, "unexpected in6_addr size"); - return IN6_IS_ADDR_V4MAPPED((struct in6_addr *) m_buffer); - } -}; - - /** Checks if the passed string represents an IPv6-address. */ @@ -255,7 +238,7 @@ longlong Item_func_is_ipv6::val_int() longlong Item_func_is_ipv4_compat::val_int() { - IP6 ip6(args[0]); + Inet6Bundle::Fbt ip6(args[0]); return !ip6.is_null() && ip6.is_v4compat(); } @@ -266,6 +249,6 @@ longlong Item_func_is_ipv4_compat::val_int() longlong Item_func_is_ipv4_mapped::val_int() { - IP6 ip6(args[0]); + Inet6Bundle::Fbt ip6(args[0]); return !ip6.is_null() && ip6.is_v4mapped(); } diff --git a/plugin/type_inet/sql_type_inet.cc b/plugin/type_inet/sql_type_inet.cc index b05972e6942..a91b6b41a6f 100644 --- a/plugin/type_inet/sql_type_inet.cc +++ b/plugin/type_inet/sql_type_inet.cc @@ -169,7 +169,7 @@ bool Inet4::ascii_to_ipv4(const char *str, size_t str_length) */ template<> -bool Inet6::ascii_to_fbt(const char *str, size_t str_length) +bool Inet6_int::ascii_to_fbt(const char *str, size_t str_length) { if (str_length < 2) { @@ -383,7 +383,7 @@ size_t Inet4::to_string(char *dst, size_t dstsize) const */ template<> -size_t Inet6::fbt_to_ascii(char *dst, size_t dstsize) const +size_t Inet6_int::fbt_to_ascii(char *dst, size_t dstsize) const { struct Region { @@ -510,7 +510,7 @@ size_t Inet6::fbt_to_ascii(char *dst, size_t dstsize) const } template<> -const Name &Inet6::default_value() +const Name &Inet6_int::default_value() { static Name def(STRING_WITH_LEN("::")); return def; diff --git a/plugin/type_inet/sql_type_inet.h b/plugin/type_inet/sql_type_inet.h index 85eb4255925..77e321f0aa9 100644 --- a/plugin/type_inet/sql_type_inet.h +++ b/plugin/type_inet/sql_type_inet.h @@ -31,8 +31,26 @@ static const size_t IN6_ADDR_NUM_WORDS= IN6_ADDR_SIZE / 2; */ static const uint IN6_ADDR_MAX_CHAR_LENGTH= 8 * 4 + 7; +#define MYSQL_SERVER #include "sql_type_fixedbin.h" -typedef FixedBinImpl<IN6_ADDR_SIZE, IN6_ADDR_MAX_CHAR_LENGTH> Inet6; +typedef FixedBinImpl<IN6_ADDR_SIZE, IN6_ADDR_MAX_CHAR_LENGTH> Inet6_int; + +class Inet6: public Inet6_int +{ + using Inet6_int::Inet6_int; + public: + bool is_v4compat() const + { + static_assert(sizeof(in6_addr) == IN6_ADDR_SIZE, "unexpected in6_addr size"); + return IN6_IS_ADDR_V4COMPAT((struct in6_addr *) m_buffer); + } + bool is_v4mapped() const + { + static_assert(sizeof(in6_addr) == IN6_ADDR_SIZE, "unexpected in6_addr size"); + return IN6_IS_ADDR_V4MAPPED((struct in6_addr *) m_buffer); + } +}; + typedef FixedBinTypeBundle<Inet6> Inet6Bundle; /***********************************************************************/ diff --git a/sql/sql_type_fixedbin.h b/sql/sql_type_fixedbin.h index 608c31ceaf9..a8dc7dd1f36 100644 --- a/sql/sql_type_fixedbin.h +++ b/sql/sql_type_fixedbin.h @@ -23,9 +23,7 @@ Examples are INET6 and UUID types. */ -#define MYSQL_SERVER #include "sql_class.h" // THD, SORT_FIELD_ATTR -#include "opt_range.h" // SEL_ARG, null_element /***********************************************************************/ template<size_t NATIVE_LEN, size_t MAX_CHAR_LEN> @@ -134,6 +132,9 @@ public: } }; +#ifdef MYSQL_SERVER +#include "opt_range.h" // SEL_ARG, null_element + template<class FbtImpl> class FixedBinTypeBundle { @@ -1837,4 +1838,5 @@ public: } }; +#endif #endif /* SQL_TYPE_FIXEDBIN_H */ |