Commit 76cb2f9d authored by Alexander Barkov's avatar Alexander Barkov

MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with INET6 field

Disallow BIT_AND(), BIT_OR(), BIT_XOR() for data types GEOMETRY and INET6,
as they cannot return any useful integer values.
parent 01e8459d
......@@ -5315,5 +5315,16 @@ SELECT EXTRACT(DAY FROM a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'extract(day)'
DROP TABLE t1;
#
# MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with INET6 field
#
CREATE TABLE t1 (a GEOMETRY);
SELECT BIT_AND(a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'bit_and('
SELECT BIT_OR(a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'bit_or('
SELECT BIT_XOR(a) FROM t1;
ERROR HY000: Illegal parameter data type geometry for operation 'bit_xor('
DROP TABLE t1;
#
# End of 10.5 tests
#
......@@ -3318,6 +3318,20 @@ CREATE TABLE t1 (a GEOMETRY);
SELECT EXTRACT(DAY FROM a) FROM t1;
DROP TABLE t1;
--echo #
--echo # MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with INET6 field
--echo #
CREATE TABLE t1 (a GEOMETRY);
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT BIT_AND(a) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT BIT_OR(a) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT BIT_XOR(a) FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -909,6 +909,17 @@ a GROUP_CONCAT(a ORDER BY a)
::2 ::2,::2,::2,::2
DROP TABLE t1;
#
# MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with INET6 field
#
CREATE TABLE t1 (a INET6);
SELECT BIT_AND(a) FROM t1;
ERROR HY000: Illegal parameter data type inet6 for operation 'bit_and('
SELECT BIT_OR(a) FROM t1;
ERROR HY000: Illegal parameter data type inet6 for operation 'bit_or('
SELECT BIT_XOR(a) FROM t1;
ERROR HY000: Illegal parameter data type inet6 for operation 'bit_xor('
DROP TABLE t1;
#
# Window functions
#
CREATE TABLE t1 (a INET6);
......
......@@ -536,6 +536,20 @@ SELECT GROUP_CONCAT(a ORDER BY a) FROM t1;
SELECT a, GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a;
DROP TABLE t1;
--echo #
--echo # MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with INET6 field
--echo #
CREATE TABLE t1 (a INET6);
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT BIT_AND(a) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT BIT_OR(a) FROM t1;
--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT BIT_XOR(a) FROM t1;
DROP TABLE t1;
--echo #
--echo # Window functions
--echo #
......
......@@ -1208,6 +1208,8 @@ class Item_sum_bit :public Item_sum_int
const Type_handler *type_handler() const { return &type_handler_ulonglong; }
bool fix_length_and_dec()
{
if (args[0]->check_type_can_return_int(func_name()))
return true;
decimals= 0; max_length=21; unsigned_flag= 1; maybe_null= null_value= 0;
return FALSE;
}
......
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