Commit d8e599bb authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20808 CAST from INET6 to FLOAT does not produce an error

parent b42294bc
......@@ -698,6 +698,8 @@ DROP TABLE t1,t2;
#
SELECT CAST(CAST('::' AS INET6) AS DOUBLE);
ERROR HY000: Illegal parameter data type inet6 for operation 'double_typecast'
SELECT CAST(CAST('::' AS INET6) AS FLOAT);
ERROR HY000: Illegal parameter data type inet6 for operation 'float_typecast'
SELECT CAST(CAST('::' AS INET6) AS DECIMAL);
ERROR HY000: Illegal parameter data type inet6 for operation 'decimal_typecast'
SELECT CAST(CAST('::' AS INET6) AS SIGNED);
......@@ -1621,3 +1623,11 @@ SELECT HEX(CAST(a AS BINARY(16))) FROM t1;
HEX(CAST(a AS BINARY(16)))
20010DB8000000000000FF0000428329
DROP TABLE t1;
#
# MDEV-20808 CAST from INET6 to FLOAT does not produce an error
#
CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('::');
SELECT CAST(a AS FLOAT) FROM t1;
ERROR HY000: Illegal parameter data type inet6 for operation 'float_typecast'
DROP TABLE t1;
......@@ -360,6 +360,9 @@ DROP TABLE t1,t2;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CAST(CAST('::' AS INET6) AS DOUBLE);
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CAST(CAST('::' AS INET6) AS FLOAT);
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CAST(CAST('::' AS INET6) AS DECIMAL);
......@@ -1114,3 +1117,13 @@ INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT HEX(CAST(a AS BINARY)) FROM t1;
SELECT HEX(CAST(a AS BINARY(16))) FROM t1;
DROP TABLE t1;
--echo #
--echo # MDEV-20808 CAST from INET6 to FLOAT does not produce an error
--echo #
CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('::');
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT CAST(a AS FLOAT) FROM t1;
DROP TABLE t1;
......@@ -923,6 +923,12 @@ class Type_handler_inet6: public Type_handler
return Item_func_or_sum_illegal_param(item);
}
bool
Item_float_typecast_fix_length_and_dec(Item_float_typecast *item)
const override
{
return Item_func_or_sum_illegal_param(item);
}
bool
Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *item)
const override
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment