summaryrefslogtreecommitdiff
path: root/plugin/type_inet/mysql-test/type_inet
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-08-11 12:35:19 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-11 12:35:19 +0400
commit6a7e646df339a0bf915548c500c99720af4976b3 (patch)
tree8fadd4b51c23652363135650a4a9e531b2cd8cbe /plugin/type_inet/mysql-test/type_inet
parent0718b8ecbf3be2351e65e63a5e21cd1db24355e1 (diff)
downloadmariadb-git-6a7e646df339a0bf915548c500c99720af4976b3.tar.gz
MDEV-23054 Assertion `!item->null_value' failed in Type_handler_inet6::make_sort_key_part (#2)
IFNULL(inet6_not_null_expr, 'foo') erroneously set its nullability to NOT NULL. Fix: - Moving the line "maybe_null= args[1]->maybe_null" before the call of fix_length_and_dec2(), so the call of Type_handler method Item_hybrid_func_fix_attributes() can reset it when desired. - Fixing Type_handler_inet6::Item_hybrid_func_fix_attributes() to ignore args[0] when detecting nullability of IFNULL().
Diffstat (limited to 'plugin/type_inet/mysql-test/type_inet')
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet6.result39
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet6.test26
2 files changed, 65 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 ecf64d8484a..da949481337 100644
--- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result
@@ -2120,3 +2120,42 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
DROP TABLE t1;
+#
+# MDEV-22758 Assertion `!item->null_value' failed in Type_handler_inet6::make_sort_key_part
+#
+CREATE TABLE t1 (c INET6);
+INSERT INTO t1 VALUES ('::'),(NULL);
+SELECT * FROM t1 ORDER BY IFNULL(c, 'foo');
+c
+NULL
+::
+Warnings:
+Warning 1292 Incorrect inet6 value: 'foo'
+DROP TABLE t1;
+CREATE TABLE t1 (c INET6);
+INSERT INTO t1 VALUES ('::'),(NULL);
+CREATE TABLE t2 AS SELECT IFNULL(c, 'foo') FROM t1;
+Warnings:
+Warning 1292 Incorrect inet6 value: 'foo'
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `IFNULL(c, 'foo')` inet6 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2;
+IFNULL(c, 'foo')
+::
+NULL
+DROP TABLE t2;
+CREATE TABLE t2 AS SELECT IFNULL(c, '::1') FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `IFNULL(c, '::1')` inet6 NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SELECT * FROM t2;
+IFNULL(c, '::1')
+::
+::1
+DROP TABLE t2;
+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 69583286380..ad4cfe57986 100644
--- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test
@@ -1560,3 +1560,29 @@ SHOW CREATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-22758 Assertion `!item->null_value' failed in Type_handler_inet6::make_sort_key_part
+--echo #
+
+CREATE TABLE t1 (c INET6);
+INSERT INTO t1 VALUES ('::'),(NULL);
+SELECT * FROM t1 ORDER BY IFNULL(c, 'foo');
+DROP TABLE t1;
+
+CREATE TABLE t1 (c INET6);
+INSERT INTO t1 VALUES ('::'),(NULL);
+
+# Expect a NULL column
+CREATE TABLE t2 AS SELECT IFNULL(c, 'foo') FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+# Expect a NOT NULL column
+CREATE TABLE t2 AS SELECT IFNULL(c, '::1') FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+DROP TABLE t1;