diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-10-14 18:26:25 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-10-14 18:26:25 +0400 |
commit | a11694b80d9494a94d4ce9d8e9294f9a4334657e (patch) | |
tree | 984e343b71eaad280f9b93e1b9fd56633cacee09 | |
parent | ba8e5e689c8a1756573c9cbf6a59e9ec32d86457 (diff) | |
download | mariadb-git-a11694b80d9494a94d4ce9d8e9294f9a4334657e.tar.gz |
MDEV-20826 Wrong result of MIN(inet6) with GROUP BY
Type_handler_inet6::is_val_native_ready() was not overriden and
returned "false" by default, so Item_sum_min_max::update_field()
erroneously went through the min_max_update_str_field() rather than
min_max_update_native_field() execution path. As a result '8888::'
was compared to 'fff::' in string format (rather than INET6 binary format)
and gave "less" instead of "greater".
Adding the forgotten overriding method returning "true".
-rw-r--r-- | plugin/type_inet/mysql-test/type_inet/type_inet6.result | 9 | ||||
-rw-r--r-- | plugin/type_inet/mysql-test/type_inet/type_inet6.test | 9 | ||||
-rw-r--r-- | plugin/type_inet/sql_type_inet.h | 1 |
3 files changed, 19 insertions, 0 deletions
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 4cc1ac370a0..3dbbbccb100 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result @@ -1968,3 +1968,12 @@ def CAST(a AS BINARY(16777215)) 250 16777215 0 Y 128 0 63 def CAST(a AS BINARY(16777216)) 251 16777216 0 Y 128 0 63 CAST(a AS BINARY(0)) CAST(a AS BINARY(1)) CAST(a AS BINARY(16)) CAST(a AS BINARY(255)) CAST(a AS BINARY(256)) CAST(a AS BINARY(512)) CAST(a AS BINARY(513)) CAST(a AS BINARY(65532)) CAST(a AS BINARY(65533)) CAST(a AS BINARY(65534)) CAST(a AS BINARY(65535)) CAST(a AS BINARY(65536)) CAST(a AS BINARY(16777215)) CAST(a AS BINARY(16777216)) DROP TABLE t1; +# +# MDEV-20826 Wrong result of MIN(inet6) with GROUP BY +# +CREATE TABLE t1 (id INT, a INET6) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 'fff::'),(1, '8888::'); +SELECT MIN(a), MAX(a) FROM t1 GROUP BY id; +MIN(a) MAX(a) +fff:: 8888:: +DROP TABLE t1; 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 875aaa0b7e9..8559748c7dd 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test @@ -1436,3 +1436,12 @@ SELECT FROM t1; --disable_metadata DROP TABLE t1; + +--echo # +--echo # MDEV-20826 Wrong result of MIN(inet6) with GROUP BY +--echo # + +CREATE TABLE t1 (id INT, a INET6) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 'fff::'),(1, '8888::'); +SELECT MIN(a), MAX(a) FROM t1 GROUP BY id; +DROP TABLE t1; diff --git a/plugin/type_inet/sql_type_inet.h b/plugin/type_inet/sql_type_inet.h index 970c3b63a3e..c00237cf4fc 100644 --- a/plugin/type_inet/sql_type_inet.h +++ b/plugin/type_inet/sql_type_inet.h @@ -386,6 +386,7 @@ public: } bool is_scalar_type() const override { return true; } + bool is_val_native_ready() const override { return true; } bool can_return_int() const override { return false; } bool can_return_decimal() const override { return false; } bool can_return_real() const override { return false; } |