Use registerAlias for mysql comatibility of ntoa/aton functions

This commit is contained in:
vdimir 2021-07-16 16:18:06 +03:00
parent f79699df7b
commit 4cf2e33647
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
11 changed files with 14 additions and 19 deletions

View File

@ -8,7 +8,6 @@ namespace DB
struct NameFunctionIPv4NumToString { static constexpr auto name = "IPv4NumToString"; };
struct NameFunctionIPv4NumToStringClassC { static constexpr auto name = "IPv4NumToStringClassC"; };
void registerFunctionsCoding(FunctionFactory & factory)
{
factory.registerFunction<FunctionToStringCutToZero>();
@ -29,20 +28,16 @@ void registerFunctionsCoding(FunctionFactory & factory)
factory.registerFunction<FunctionIPv4NumToString<0, NameFunctionIPv4NumToString>>();
factory.registerFunction<FunctionIPv4NumToString<1, NameFunctionIPv4NumToStringClassC>>();
/// MysQL compatibility alias.
factory.registerFunction<FunctionIPv4NumToString<0, NameFunctionIPv4NumToString>>("INET_NTOA", FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionIPv4StringToNum>();
/// MysQL compatibility alias.
factory.registerFunction<FunctionIPv4StringToNum>("INET_ATON", FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionIPv6NumToString>();
/// MysQL compatibility alias.
factory.registerFunction<FunctionIPv6NumToString>("INET6_NTOA", FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionIPv6StringToNum>();
/// MysQL compatibility alias.
factory.registerFunction<FunctionIPv6StringToNum>("INET6_ATON", FunctionFactory::CaseInsensitive);
/// MysQL compatibility aliases:
factory.registerAlias("INET_ATON", FunctionIPv4StringToNum::name, FunctionFactory::CaseInsensitive);
factory.registerAlias("INET6_NTOA", FunctionIPv6NumToString::name, FunctionFactory::CaseInsensitive);
factory.registerAlias("INET6_ATON", FunctionIPv6StringToNum::name, FunctionFactory::CaseInsensitive);
factory.registerAlias("INET_NTOA", NameFunctionIPv4NumToString::name, FunctionFactory::CaseInsensitive);
}
}

View File

@ -0,0 +1,4 @@
2a02:6b8::11
2A0206B8000000000000000000000011
0.0.5.57
3232235521

View File

@ -0,0 +1,4 @@
SELECT INET6_NTOA(toFixedString(unhex('2A0206B8000000000000000000000011'), 16));
SELECT hex(INET6_ATON('2a02:6b8::11'));
SELECT INET_NTOA(toUInt32(1337));
SELECT INET_ATON('192.168.0.1');

View File

@ -1 +0,0 @@
SELECT INET6_NTOA(toFixedString(unhex('2A0206B8000000000000000000000011'), 16));

View File

@ -1 +0,0 @@
SELECT INET6_ATON('2a02:6b8::11');

View File

@ -1 +0,0 @@
SELECT INET_NTOA(toUInt32(1337));

View File

@ -1 +0,0 @@
SELECT INET_ATON('192.168.0.1');