ClickHouse/tests/queries/0_stateless/02234_cast_to_ip_address.sql
2022-11-24 20:42:36 +00:00

82 lines
2.0 KiB
SQL

SELECT 'IPv4 functions';
SELECT IPv4StringToNum('test'); --{serverError 671}
SELECT IPv4StringToNumOrDefault('test');
SELECT IPv4StringToNumOrNull('test');
SELECT IPv4StringToNum('127.0.0.1');
SELECT IPv4StringToNumOrDefault('127.0.0.1');
SELECT IPv4StringToNumOrNull('127.0.0.1');
SELECT '--';
SELECT toIPv4('test'); --{serverError 671}
SELECT toIPv4OrDefault('test');
SELECT toIPv4OrNull('test');
SELECT toIPv4('127.0.0.1');
SELECT toIPv4OrDefault('127.0.0.1');
SELECT toIPv4OrNull('127.0.0.1');
SELECT '--';
SELECT cast('test' , 'IPv4'); --{serverError 671}
SELECT cast('127.0.0.1' , 'IPv4');
SELECT '--';
SET cast_ipv4_ipv6_default_on_conversion_error = 1;
SELECT IPv4StringToNum('test');
SELECT toIPv4('test');
SELECT IPv4StringToNum('');
SELECT toIPv4('');
SELECT cast('test' , 'IPv4');
SELECT cast('' , 'IPv4');
SET cast_ipv4_ipv6_default_on_conversion_error = 0;
SELECT 'IPv6 functions';
SELECT IPv6StringToNum('test'); --{serverError 672}
SELECT IPv6StringToNumOrDefault('test');
SELECT IPv6StringToNumOrNull('test');
SELECT IPv6StringToNum('::ffff:127.0.0.1');
SELECT IPv6StringToNumOrDefault('::ffff:127.0.0.1');
SELECT IPv6StringToNumOrNull('::ffff:127.0.0.1');
SELECT '--';
SELECT toIPv6('test'); --{serverError 672}
SELECT toIPv6OrDefault('test');
SELECT toIPv6OrNull('test');
SELECT toIPv6('::ffff:127.0.0.1');
SELECT toIPv6OrDefault('::ffff:127.0.0.1');
SELECT toIPv6OrNull('::ffff:127.0.0.1');
SELECT '--';
SELECT cast('test' , 'IPv6'); --{serverError 672}
SELECT cast('::ffff:127.0.0.1', 'IPv6');
SELECT '--';
SET cast_ipv4_ipv6_default_on_conversion_error = 1;
SELECT IPv6StringToNum('test');
SELECT toIPv6('test');
SELECT IPv6StringToNum('');
SELECT toIPv6('');
SELECT cast('test' , 'IPv6');
SELECT cast('' , 'IPv6');
SELECT '--';
SET cast_ipv4_ipv6_default_on_conversion_error = 0;
SELECT toFixedString('::1', 5) as value, cast(value, 'IPv6'), toIPv6(value);
SELECT toFixedString('', 16) as value, cast(value, 'IPv6');
SELECT toFixedString('', 16) as value, toIPv6(value);