Skip to content

Commit

Permalink
MDEV-21765 Possibly inconsistent behavior of BIT_xx functions with IN…
Browse files Browse the repository at this point in the history
…ET6 field

Disallow BIT_AND(), BIT_OR(), BIT_XOR() for data types GEOMETRY and INET6,
as they cannot return any useful integer values.
  • Loading branch information
abarkov committed Jun 9, 2020
1 parent 01e8459 commit 76cb2f9
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mysql-test/main/gis.result
Expand Up @@ -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
#
14 changes: 14 additions & 0 deletions mysql-test/main/gis.test
Expand Up @@ -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 #
11 changes: 11 additions & 0 deletions plugin/type_inet/mysql-test/type_inet/type_inet6.result
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions plugin/type_inet/mysql-test/type_inet/type_inet6.test
Expand Up @@ -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 #
Expand Down
2 changes: 2 additions & 0 deletions sql/item_sum.h
Expand Up @@ -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;
}
Expand Down

0 comments on commit 76cb2f9

Please sign in to comment.