mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Add functional tests for ipv4 range function
This commit is contained in:
parent
0e67d424da
commit
31f8eecdc2
@ -0,0 +1,16 @@
|
|||||||
|
4
|
||||||
|
3
|
||||||
|
2
|
||||||
|
7
|
||||||
|
192.168.5.2 0 0.0.0.0 255.255.255.255
|
||||||
|
192.168.5.20 32 192.168.5.20 192.168.5.20
|
||||||
|
255.255.255.255 16 255.255.0.0 255.255.255.255
|
||||||
|
192.142.32.2 32 192.142.32.2 192.142.32.2
|
||||||
|
192.172.5.2 16 192.172.0.0 192.172.255.255
|
||||||
|
0.0.0.0 8 0.0.0.0 0.255.255.255
|
||||||
|
255.0.0.0 4 240.0.0.0 255.255.255.255
|
||||||
|
0.0.0.0 255.255.255.255
|
||||||
|
192.168.5.2 192.168.5.2
|
||||||
|
255.0.0.0 255.255.255.255
|
||||||
|
0.0.0.0 0.255.255.255
|
||||||
|
240.0.0.0 255.255.255.255
|
29
dbms/tests/queries/0_stateless/00937_ipv4_cidr_range.sql
Normal file
29
dbms/tests/queries/0_stateless/00937_ipv4_cidr_range.sql
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
USE test;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS ipv4_range;
|
||||||
|
CREATE TABLE ipv4_range(ip UInt32, cidr UInt8) ENGINE = Memory;
|
||||||
|
|
||||||
|
INSERT INTO ipv4_range (ip, cidr) VALUES (IPv4StringToNum('192.168.5.2'), 0), (IPv4StringToNum('192.168.5.20'), 32), (IPv4StringToNum('255.255.255.255'), 16), (IPv4StringToNum('192.142.32.2'), 32), (IPv4StringToNum('192.172.5.2'), 16), (IPv4StringToNum('0.0.0.0'), 8), (IPv4StringToNum('255.0.0.0'), 4);
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('192.168.0.0'), 8) as ip_range SELECT COUNT(*) FROM ipv4_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2);
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('192.168.0.0'), 13) as ip_range SELECT COUNT(*) FROM ipv4_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2);
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('192.168.0.0'), 16) as ip_range SELECT COUNT(*) FROM ipv4_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2);
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('192.168.0.0'), 0) as ip_range SELECT COUNT(*) FROM ipv4_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2);
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(ip, cidr) as ip_range SELECT IPv4NumToString(ip), cidr, IPv4NumToString(tupleElement(ip_range, 1)), IPv4NumToString(tupleElement(ip_range, 2)) FROM ipv4_range;
|
||||||
|
|
||||||
|
DROP TABLE ipv4_range;
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('192.168.5.2'), 0) as ip_range SELECT IPv4NumToString(tupleElement(ip_range, 1)) as lower_range, IPv4NumToString(tupleElement(ip_range, 2)) as higher_range;
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('192.168.5.2'), 32) as ip_range SELECT IPv4NumToString(tupleElement(ip_range, 1)) as lower_range, IPv4NumToString(tupleElement(ip_range, 2)) as higher_range;
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('255.255.255.255'), 8) as ip_range SELECT IPv4NumToString(tupleElement(ip_range, 1)) as lower_range, IPv4NumToString(tupleElement(ip_range, 2)) as higher_range;
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('0.0.0.0'), 8) as ip_range SELECT IPv4NumToString(tupleElement(ip_range, 1)) as lower_range, IPv4NumToString(tupleElement(ip_range, 2)) as higher_range;
|
||||||
|
|
||||||
|
WITH IPv4CIDRtoIPv4Range(IPv4StringToNum('255.0.0.0'), 4) as ip_range SELECT IPv4NumToString(tupleElement(ip_range, 1)) as lower_range, IPv4NumToString(tupleElement(ip_range, 2)) as higher_range;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user