summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2022-07-05 11:39:40 +0400
committerAlexander Barkov <bar@mariadb.com>2022-07-05 12:11:14 +0400
commitc12192b1c663a50d76245fc2f6f6617f6df5da66 (patch)
treec5138e9ff2cc7cd215ed34cb9f204fc70ae0a199
parent3dff84cd158ed09e9c5b1a390af7571fd671f012 (diff)
downloadmariadb-git-bb-10.7-bar.tar.gz
MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()bb-10.7-bar
The assuption that Field::is_null() is always false when Field_fbt::val_native() or Field_fbt::to_fbt() are called was wrong. In some cases, e.g. when this helper Field method is called: inline String *val_str(String *str, const uchar *new_ptr) we temporarily reset Field::ptr to some alternative record buffer but don't reset null_ptr, so null_ptr still points to null flags of the original record. In such cases it's meaningless to test the original Field::null_ptr when Field::ptr is temporarily reset: they don't relate to each other. Removing the DBUG_ASSERT.
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet6.result28
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet6.test15
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet6_sum.result51
-rw-r--r--plugin/type_inet/mysql-test/type_inet/type_inet6_sum.test41
-rw-r--r--plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.result17
-rw-r--r--plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.test17
-rw-r--r--sql/sql_type_fixedbin.h2
7 files changed, 169 insertions, 2 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 932f3a68625..570655a972b 100644
--- a/plugin/type_inet/mysql-test/type_inet/type_inet6.result
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.result
@@ -2213,3 +2213,31 @@ SELECT * FROM companies;
id name
DROP TABLE divisions;
DROP TABLE companies;
+#
+# MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
+#
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a INET6(6) DEFAULT '::10');
+INSERT INTO t1(id) VALUES (1), (2), (3), (4);
+INSERT INTO t1 VALUES (5,'::5'), (6,'::6');
+SELECT * FROM t1 ORDER BY a;
+id a
+5 ::5
+6 ::6
+1 ::10
+2 ::10
+3 ::10
+4 ::10
+CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a;
+CREATE TABLE t2 SELECT * FROM v1;
+SELECT * FROM v1 ORDER BY a;
+a m
+::5 5
+::6 6
+::10 1
+SELECT * FROM t2 ORDER BY a;
+a m
+::5 5
+::6 6
+::10 1
+DROP VIEW v1;
+DROP TABLE t1, t2;
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 72059bd060c..f7453d2d67e 100644
--- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test
@@ -1629,3 +1629,18 @@ DELETE FROM companies WHERE id IN (SELECT company_id FROM divisions);
SELECT * FROM companies;
DROP TABLE divisions;
DROP TABLE companies;
+
+--echo #
+--echo # MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
+--echo #
+
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a INET6(6) DEFAULT '::10');
+INSERT INTO t1(id) VALUES (1), (2), (3), (4);
+INSERT INTO t1 VALUES (5,'::5'), (6,'::6');
+SELECT * FROM t1 ORDER BY a;
+CREATE VIEW v1(a, m) AS SELECT a, MIN(id) FROM t1 GROUP BY a;
+CREATE TABLE t2 SELECT * FROM v1;
+SELECT * FROM v1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+DROP VIEW v1;
+DROP TABLE t1, t2;
diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_sum.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_sum.result
new file mode 100644
index 00000000000..df268156981
--- /dev/null
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_sum.result
@@ -0,0 +1,51 @@
+#
+# Start of 10.7 tests
+#
+#
+# MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
+#
+CREATE TABLE t1 (i6 INET6, a1 TIME, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::','09:43:12','uw'), ('70:ef59::46:c7b:f:678:bd9f','00:00:00','a');
+SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
+GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1)
+::
+Warnings:
+Warning 1292 Incorrect inet6 value: 'a'
+DROP TABLE t1;
+CREATE TABLE t1 (i6 inet6, a2 varchar(10));
+INSERT INTO t1 VALUES ('::','uw'), (null,'a');
+SELECT group_concat(coalesce(i6, a2) ORDER BY 1) FROM t1;
+group_concat(coalesce(i6, a2) ORDER BY 1)
+::
+Warnings:
+Warning 1292 Incorrect inet6 value: 'a'
+DROP TABLE t1;
+CREATE TABLE t1 (a INET6);
+INSERT INTO t1 VALUES();
+SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1;
+JSON_ARRAYAGG(a ORDER BY a DESC)
+[null]
+DROP TABLE t1;
+CREATE TABLE t1 (i6 INET6, a1 INT, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::',1,'uw'), ('70:ef59::46:c7b:f:678:bd9f',0,'a');
+SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
+GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1)
+::
+Warnings:
+Warning 1292 Incorrect inet6 value: 'a'
+DROP TABLE t1;
+CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
+SELECT GROUP_CONCAT(COALESCE(i6, a2) ORDER BY 1) FROM t1;
+GROUP_CONCAT(COALESCE(i6, a2) ORDER BY 1)
+::
+DROP TABLE t1;
+CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
+SELECT GROUP_CONCAT(DISTINCT COALESCE(i6, a2)) FROM t1;
+GROUP_CONCAT(DISTINCT COALESCE(i6, a2))
+::
+DROP TABLE t1;
+#
+# End of 10.7 tests
+#
diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_sum.test b/plugin/type_inet/mysql-test/type_inet/type_inet6_sum.test
new file mode 100644
index 00000000000..71dfcebf71a
--- /dev/null
+++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_sum.test
@@ -0,0 +1,41 @@
+--echo #
+--echo # Start of 10.7 tests
+--echo #
+
+--echo #
+--echo # MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
+--echo #
+
+CREATE TABLE t1 (i6 INET6, a1 TIME, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::','09:43:12','uw'), ('70:ef59::46:c7b:f:678:bd9f','00:00:00','a');
+SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (i6 inet6, a2 varchar(10));
+INSERT INTO t1 VALUES ('::','uw'), (null,'a');
+SELECT group_concat(coalesce(i6, a2) ORDER BY 1) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INET6);
+INSERT INTO t1 VALUES();
+SELECT JSON_ARRAYAGG(a ORDER BY a DESC) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (i6 INET6, a1 INT, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::',1,'uw'), ('70:ef59::46:c7b:f:678:bd9f',0,'a');
+SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
+SELECT GROUP_CONCAT(COALESCE(i6, a2) ORDER BY 1) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (i6 INET6, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('::',''), (NULL,NULL);
+SELECT GROUP_CONCAT(DISTINCT COALESCE(i6, a2)) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # End of 10.7 tests
+--echo #
diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.result
new file mode 100644
index 00000000000..e5d88c3df2a
--- /dev/null
+++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.result
@@ -0,0 +1,17 @@
+#
+# Start of 10.7 tests
+#
+#
+# MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
+#
+CREATE TABLE t1 (i6 UUID, a1 TIME, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-fffffffffffe','09:43:12','uw'), (uuid(),'00:00:00','a');
+SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
+GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1)
+ffffffff-ffff-ffff-ffff-fffffffffffe
+Warnings:
+Warning 1292 Incorrect uuid value: 'a'
+DROP TABLE t1;
+#
+# End of 10.7 tests
+#
diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.test
new file mode 100644
index 00000000000..45cdf927210
--- /dev/null
+++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid_sum.test
@@ -0,0 +1,17 @@
+--echo #
+--echo # Start of 10.7 tests
+--echo #
+
+--echo #
+--echo # MDEV-27015 Assertion `!is_null()' failed in FixedBinTypeBundle<FbtImpl>::Fbt FixedBinTypeBundle<FbtImpl>::Field_fbt::to_fbt()
+--echo #
+
+CREATE TABLE t1 (i6 UUID, a1 TIME, a2 VARCHAR(10));
+INSERT INTO t1 VALUES ('ffffffff-ffff-ffff-ffff-fffffffffffe','09:43:12','uw'), (uuid(),'00:00:00','a');
+SELECT GROUP_CONCAT(IF(a1, i6, a2) ORDER BY 1) FROM t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # End of 10.7 tests
+--echo #
diff --git a/sql/sql_type_fixedbin.h b/sql/sql_type_fixedbin.h
index bf771f1a878..546d585cc69 100644
--- a/sql/sql_type_fixedbin.h
+++ b/sql/sql_type_fixedbin.h
@@ -1190,7 +1190,6 @@ public:
bool val_native(Native *to) override
{
DBUG_ASSERT(marked_for_read());
- DBUG_ASSERT(!is_null());
if (to->alloc(FbtImpl::binary_length()))
return true;
to->length(FbtImpl::binary_length());
@@ -1201,7 +1200,6 @@ public:
Fbt to_fbt() const
{
DBUG_ASSERT(marked_for_read());
- DBUG_ASSERT(!is_null());
return Fbt::record_to_memory((const char*) ptr);
}