diff options
author | Alexander Barkov <bar@mariadb.com> | 2020-06-09 12:54:04 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2020-06-09 12:54:04 +0400 |
commit | 76cb2f9dd677d91df9ce135475a66db7048f7d8c (patch) | |
tree | 9a1447970986bee75bfab2ad1fac34477bc8c628 | |
parent | 01e8459d93ce69b8b540f9fb5d7e68eb68f8d3f3 (diff) | |
download | mariadb-git-76cb2f9dd677d91df9ce135475a66db7048f7d8c.tar.gz |
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.
-rw-r--r-- | mysql-test/main/gis.result | 11 | ||||
-rw-r--r-- | mysql-test/main/gis.test | 14 | ||||
-rw-r--r-- | plugin/type_inet/mysql-test/type_inet/type_inet6.result | 11 | ||||
-rw-r--r-- | plugin/type_inet/mysql-test/type_inet/type_inet6.test | 14 | ||||
-rw-r--r-- | sql/item_sum.h | 2 |
5 files changed, 52 insertions, 0 deletions
diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index f6d582c42a6..8bcb98143a2 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -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 # diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index 6ece15bd235..17a93291b77 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -3319,5 +3319,19 @@ 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 # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.result b/plugin/type_inet/mysql-test/type_inet/type_inet6.result index d508ca79a18..ecf64d8484a 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result @@ -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); diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.test b/plugin/type_inet/mysql-test/type_inet/type_inet6.test index 0cdf830c43c..69583286380 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test @@ -537,6 +537,20 @@ 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 # diff --git a/sql/item_sum.h b/sql/item_sum.h index d3c78c245d6..d1b9303d3d6 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -1208,6 +1208,8 @@ public: 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; } |