Rename isIPAddressContainedIn -> isIPAddressInRange

This commit is contained in:
vdimir 2021-03-29 12:56:11 +03:00
parent 81ff4f4791
commit ae4b8e3181
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
2 changed files with 23 additions and 23 deletions

View File

@ -123,7 +123,7 @@ namespace DB
class FunctionIsIPAddressContainedIn : public IFunction class FunctionIsIPAddressContainedIn : public IFunction
{ {
public: public:
static constexpr auto name = "isIPAddressContainedIn"; static constexpr auto name = "isIPAddressInRange";
String getName() const override { return name; } String getName() const override { return name; }
static FunctionPtr create(const Context &) { return std::make_shared<FunctionIsIPAddressContainedIn>(); } static FunctionPtr create(const Context &) { return std::make_shared<FunctionIsIPAddressContainedIn>(); }

View File

@ -1,43 +1,43 @@
SELECT '# Invocation with constants'; SELECT '# Invocation with constants';
SELECT isIPAddressContainedIn('127.0.0.1', '127.0.0.0/8'); SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8');
SELECT isIPAddressContainedIn('128.0.0.1', '127.0.0.0/8'); SELECT isIPAddressInRange('128.0.0.1', '127.0.0.0/8');
SELECT isIPAddressContainedIn('ffff::1', 'ffff::/16'); SELECT isIPAddressInRange('ffff::1', 'ffff::/16');
SELECT isIPAddressContainedIn('fffe::1', 'ffff::/16'); SELECT isIPAddressInRange('fffe::1', 'ffff::/16');
SELECT '# Invocation with non-constant addresses'; SELECT '# Invocation with non-constant addresses';
WITH arrayJoin(['192.168.99.255', '192.168.100.1', '192.168.103.255', '192.168.104.0']) as addr, '192.168.100.0/22' as prefix SELECT addr, prefix, isIPAddressContainedIn(addr, prefix); WITH arrayJoin(['192.168.99.255', '192.168.100.1', '192.168.103.255', '192.168.104.0']) as addr, '192.168.100.0/22' as prefix SELECT addr, prefix, isIPAddressInRange(addr, prefix);
WITH arrayJoin(['::192.168.99.255', '::192.168.100.1', '::192.168.103.255', '::192.168.104.0']) as addr, '::192.168.100.0/118' as prefix SELECT addr, prefix, isIPAddressContainedIn(addr, prefix); WITH arrayJoin(['::192.168.99.255', '::192.168.100.1', '::192.168.103.255', '::192.168.104.0']) as addr, '::192.168.100.0/118' as prefix SELECT addr, prefix, isIPAddressInRange(addr, prefix);
SELECT '# Invocation with non-constant prefixes'; SELECT '# Invocation with non-constant prefixes';
WITH '192.168.100.1' as addr, arrayJoin(['192.168.100.0/22', '192.168.100.0/24', '192.168.100.0/32']) as prefix SELECT addr, prefix, isIPAddressContainedIn(addr, prefix); WITH '192.168.100.1' as addr, arrayJoin(['192.168.100.0/22', '192.168.100.0/24', '192.168.100.0/32']) as prefix SELECT addr, prefix, isIPAddressInRange(addr, prefix);
WITH '::192.168.100.1' as addr, arrayJoin(['::192.168.100.0/118', '::192.168.100.0/120', '::192.168.100.0/128']) as prefix SELECT addr, prefix, isIPAddressContainedIn(addr, prefix); WITH '::192.168.100.1' as addr, arrayJoin(['::192.168.100.0/118', '::192.168.100.0/120', '::192.168.100.0/128']) as prefix SELECT addr, prefix, isIPAddressInRange(addr, prefix);
SELECT '# Invocation with non-constants'; SELECT '# Invocation with non-constants';
WITH arrayJoin(['192.168.100.1', '192.168.103.255']) as addr, arrayJoin(['192.168.100.0/22', '192.168.100.0/24']) as prefix SELECT addr, prefix, isIPAddressContainedIn(addr, prefix); WITH arrayJoin(['192.168.100.1', '192.168.103.255']) as addr, arrayJoin(['192.168.100.0/22', '192.168.100.0/24']) as prefix SELECT addr, prefix, isIPAddressInRange(addr, prefix);
WITH arrayJoin(['::192.168.100.1', '::192.168.103.255']) as addr, arrayJoin(['::192.168.100.0/118', '::192.168.100.0/120']) as prefix SELECT addr, prefix, isIPAddressContainedIn(addr, prefix); WITH arrayJoin(['::192.168.100.1', '::192.168.103.255']) as addr, arrayJoin(['::192.168.100.0/118', '::192.168.100.0/120']) as prefix SELECT addr, prefix, isIPAddressInRange(addr, prefix);
SELECT '# Mismatching IP versions is not an error.'; SELECT '# Mismatching IP versions is not an error.';
SELECT isIPAddressContainedIn('127.0.0.1', 'ffff::/16'); SELECT isIPAddressInRange('127.0.0.1', 'ffff::/16');
SELECT isIPAddressContainedIn('127.0.0.1', '::127.0.0.1/128'); SELECT isIPAddressInRange('127.0.0.1', '::127.0.0.1/128');
SELECT isIPAddressContainedIn('::1', '127.0.0.0/8'); SELECT isIPAddressInRange('::1', '127.0.0.0/8');
SELECT isIPAddressContainedIn('::127.0.0.1', '127.0.0.1/32'); SELECT isIPAddressInRange('::127.0.0.1', '127.0.0.1/32');
SELECT '# Unparsable arguments'; SELECT '# Unparsable arguments';
SELECT isIPAddressContainedIn('unparsable', '127.0.0.0/8'); -- { serverError 6 } SELECT isIPAddressInRange('unparsable', '127.0.0.0/8'); -- { serverError 6 }
SELECT isIPAddressContainedIn('127.0.0.1', 'unparsable'); -- { serverError 6 } SELECT isIPAddressInRange('127.0.0.1', 'unparsable'); -- { serverError 6 }
SELECT '# Wrong argument types'; SELECT '# Wrong argument types';
SELECT isIPAddressContainedIn(100, '127.0.0.0/8'); -- { serverError 43 } SELECT isIPAddressInRange(100, '127.0.0.0/8'); -- { serverError 43 }
SELECT isIPAddressContainedIn(NULL, '127.0.0.0/8'); -- { serverError 43 } SELECT isIPAddressInRange(NULL, '127.0.0.0/8'); -- { serverError 43 }
SELECT isIPAddressContainedIn(CAST(NULL, 'Nullable(String)'), '127.0.0.0/8'); -- { serverError 43 } SELECT isIPAddressInRange(CAST(NULL, 'Nullable(String)'), '127.0.0.0/8'); -- { serverError 43 }
SELECT isIPAddressContainedIn('127.0.0.1', 100); -- { serverError 43 } SELECT isIPAddressInRange('127.0.0.1', 100); -- { serverError 43 }
SELECT isIPAddressContainedIn(100, NULL); -- { serverError 43 } SELECT isIPAddressInRange(100, NULL); -- { serverError 43 }
WITH arrayJoin([NULL, NULL, NULL, NULL]) AS prefix SELECT isIPAddressContainedIn([NULL, NULL, 0, 255, 0], prefix); -- { serverError 43 } WITH arrayJoin([NULL, NULL, NULL, NULL]) AS prefix SELECT isIPAddressInRange([NULL, NULL, 0, 255, 0], prefix); -- { serverError 43 }